[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add one more parameter to __vmread_vcpu and clean some code.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 801b2bd7ef2ef3a200b1034d363b429a01a08896
# Parent  a4df9003c54d7c1d6b6b6e108403352f4a7f63d2
Add one more parameter to __vmread_vcpu and clean some code.

Signed-off-by: Xin Xiaohui <Xiaohui.xin@xxxxxxxxx>
Signed-off-by: Li Chengyuan <Chengyuan.li@xxxxxxxxx>
Signed-off-by: Nakajima Jun <jun.nakajima@xxxxxxxxx>

diff -r a4df9003c54d -r 801b2bd7ef2e xen/arch/x86/vmx.c
--- a/xen/arch/x86/vmx.c        Sat Oct  8 08:51:43 2005
+++ b/xen/arch/x86/vmx.c        Sat Oct  8 08:54:06 2005
@@ -425,12 +425,13 @@
 static void vmx_do_no_device_fault(void)
 {
     unsigned long cr0;
+    struct vcpu *v = current;
 
     clts();
     setup_fpu(current);
-    __vmread_vcpu(CR0_READ_SHADOW, &cr0);
+    __vmread_vcpu(v, CR0_READ_SHADOW, &cr0);
     if (!(cr0 & X86_CR0_TS)) {
-        __vmread_vcpu(GUEST_CR0, &cr0);
+        __vmread_vcpu(v, GUEST_CR0, &cr0);
         cr0 &= ~X86_CR0_TS;
         __vmwrite(GUEST_CR0, cr0);
     }
@@ -1347,6 +1348,7 @@
 {
     unsigned int gp, cr;
     unsigned long value;
+    struct vcpu *v = current;
 
     switch (exit_qualification & CONTROL_REG_ACCESS_TYPE) {
     case TYPE_MOV_TO_CR:
@@ -1369,17 +1371,17 @@
         clts();
         setup_fpu(current);
 
-        __vmread_vcpu(GUEST_CR0, &value);
+        __vmread_vcpu(v, GUEST_CR0, &value);
         value &= ~X86_CR0_TS; /* clear TS */
         __vmwrite(GUEST_CR0, value);
 
-        __vmread_vcpu(CR0_READ_SHADOW, &value);
+        __vmread_vcpu(v, CR0_READ_SHADOW, &value);
         value &= ~X86_CR0_TS; /* clear TS */
         __vmwrite(CR0_READ_SHADOW, value);
         break;
     case TYPE_LMSW:
         TRACE_VMEXIT(1,TYPE_LMSW);
-        __vmread_vcpu(CR0_READ_SHADOW, &value);
+        __vmread_vcpu(v, CR0_READ_SHADOW, &value);
         value = (value & ~0xF) |
             (((exit_qualification & LMSW_SOURCE_DATA) >> 16) & 0xF);
         return vmx_set_cr0(value);
diff -r a4df9003c54d -r 801b2bd7ef2e xen/arch/x86/vmx_io.c
--- a/xen/arch/x86/vmx_io.c     Sat Oct  8 08:51:43 2005
+++ b/xen/arch/x86/vmx_io.c     Sat Oct  8 08:54:06 2005
@@ -891,7 +891,7 @@
     struct vcpu *v = current;
 
     highest_vector = find_highest_pending_irq(v, &intr_type);
-    __vmread_vcpu(CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
+    __vmread_vcpu(v, CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
 
     if (highest_vector == -1) {
         disable_irq_window(cpu_exec_control);
diff -r a4df9003c54d -r 801b2bd7ef2e xen/include/asm-x86/vmx.h
--- a/xen/include/asm-x86/vmx.h Sat Oct  8 08:51:43 2005
+++ b/xen/include/asm-x86/vmx.h Sat Oct  8 08:54:06 2005
@@ -314,10 +314,8 @@
 }
 
 
-static always_inline void __vmwrite_vcpu(unsigned long field, unsigned long 
value)
-{
-    struct vcpu *v = current;
-
+static always_inline void __vmwrite_vcpu(struct vcpu *v, unsigned long field, 
unsigned long value)
+{
     switch(field) {
     case CR0_READ_SHADOW:
        v->arch.arch_vmx.cpu_shadow_cr0 = value;
@@ -334,10 +332,8 @@
     }
 }
 
-static always_inline void __vmread_vcpu(unsigned long field, unsigned long 
*value)
-{
-    struct vcpu *v = current;
-
+static always_inline void __vmread_vcpu(struct vcpu *v, unsigned long field, 
unsigned long *value)
+{
     switch(field) {
     case CR0_READ_SHADOW:
        *value = v->arch.arch_vmx.cpu_shadow_cr0;
@@ -352,24 +348,15 @@
        printk("__vmread_cpu: invalid field %lx\n", field);
        break;
     }
-
-   /* 
-    * __vmwrite() can be used for non-current vcpu, and it's possible that
-    * the vcpu field is not initialized at that case.
-    * 
-    */
-    if (!*value) {
-       __vmread(field, value);
-       __vmwrite_vcpu(field, *value);
-    }
 }
 
 static inline int __vmwrite (unsigned long field, unsigned long value)
 {
     unsigned long eflags;
+    struct vcpu *v = current;
 
     __asm__ __volatile__ ( VMWRITE_OPCODE
-                           MODRM_EAX_ECX       
+                           MODRM_EAX_ECX
                            :
                            : "a" (field) , "c" (value)
                            : "memory");
@@ -381,7 +368,7 @@
     case CR0_READ_SHADOW:
     case GUEST_CR0:
     case CPU_BASED_VM_EXEC_CONTROL:
-       __vmwrite_vcpu(field, value);
+       __vmwrite_vcpu(v, field, value);
        break;
     }
 
@@ -437,13 +424,14 @@
 static inline void vmx_stts(void)
 {
     unsigned long cr0;
-
-    __vmread_vcpu(GUEST_CR0, &cr0);
+    struct vcpu *v = current;
+
+    __vmread_vcpu(v, GUEST_CR0, &cr0);
     if (!(cr0 & X86_CR0_TS)) {
         __vmwrite(GUEST_CR0, cr0 | X86_CR0_TS);
     }
 
-    __vmread_vcpu(CR0_READ_SHADOW, &cr0);
+    __vmread_vcpu(v, CR0_READ_SHADOW, &cr0);
     if (!(cr0 & X86_CR0_TS))
        __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_NM);
 }
@@ -453,7 +441,7 @@
 {
     unsigned long cr0;
 
-    __vmread_vcpu(CR0_READ_SHADOW, &cr0);
+    __vmread_vcpu(v, CR0_READ_SHADOW, &cr0);
     return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.