ia64/xen-unstable

changeset 7275:801b2bd7ef2e

Add one more parameter to __vmread_vcpu and clean some code.

Signed-off-by: Xin Xiaohui <Xiaohui.xin@intel.com>
Signed-off-by: Li Chengyuan <Chengyuan.li@intel.com>
Signed-off-by: Nakajima Jun <jun.nakajima@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Oct 08 09:54:06 2005 +0100 (2005-10-08)
parents a4df9003c54d
children e69413dca684
files xen/arch/x86/vmx.c xen/arch/x86/vmx_io.c xen/include/asm-x86/vmx.h
line diff
     1.1 --- a/xen/arch/x86/vmx.c	Sat Oct 08 09:51:43 2005 +0100
     1.2 +++ b/xen/arch/x86/vmx.c	Sat Oct 08 09:54:06 2005 +0100
     1.3 @@ -425,12 +425,13 @@ static int vmx_do_page_fault(unsigned lo
     1.4  static void vmx_do_no_device_fault(void)
     1.5  {
     1.6      unsigned long cr0;
     1.7 +    struct vcpu *v = current;
     1.8  
     1.9      clts();
    1.10      setup_fpu(current);
    1.11 -    __vmread_vcpu(CR0_READ_SHADOW, &cr0);
    1.12 +    __vmread_vcpu(v, CR0_READ_SHADOW, &cr0);
    1.13      if (!(cr0 & X86_CR0_TS)) {
    1.14 -        __vmread_vcpu(GUEST_CR0, &cr0);
    1.15 +        __vmread_vcpu(v, GUEST_CR0, &cr0);
    1.16          cr0 &= ~X86_CR0_TS;
    1.17          __vmwrite(GUEST_CR0, cr0);
    1.18      }
    1.19 @@ -1347,6 +1348,7 @@ static int vmx_cr_access(unsigned long e
    1.20  {
    1.21      unsigned int gp, cr;
    1.22      unsigned long value;
    1.23 +    struct vcpu *v = current;
    1.24  
    1.25      switch (exit_qualification & CONTROL_REG_ACCESS_TYPE) {
    1.26      case TYPE_MOV_TO_CR:
    1.27 @@ -1369,17 +1371,17 @@ static int vmx_cr_access(unsigned long e
    1.28          clts();
    1.29          setup_fpu(current);
    1.30  
    1.31 -        __vmread_vcpu(GUEST_CR0, &value);
    1.32 +        __vmread_vcpu(v, GUEST_CR0, &value);
    1.33          value &= ~X86_CR0_TS; /* clear TS */
    1.34          __vmwrite(GUEST_CR0, value);
    1.35  
    1.36 -        __vmread_vcpu(CR0_READ_SHADOW, &value);
    1.37 +        __vmread_vcpu(v, CR0_READ_SHADOW, &value);
    1.38          value &= ~X86_CR0_TS; /* clear TS */
    1.39          __vmwrite(CR0_READ_SHADOW, value);
    1.40          break;
    1.41      case TYPE_LMSW:
    1.42          TRACE_VMEXIT(1,TYPE_LMSW);
    1.43 -        __vmread_vcpu(CR0_READ_SHADOW, &value);
    1.44 +        __vmread_vcpu(v, CR0_READ_SHADOW, &value);
    1.45          value = (value & ~0xF) |
    1.46              (((exit_qualification & LMSW_SOURCE_DATA) >> 16) & 0xF);
    1.47          return vmx_set_cr0(value);
     2.1 --- a/xen/arch/x86/vmx_io.c	Sat Oct 08 09:51:43 2005 +0100
     2.2 +++ b/xen/arch/x86/vmx_io.c	Sat Oct 08 09:54:06 2005 +0100
     2.3 @@ -891,7 +891,7 @@ asmlinkage void vmx_intr_assist(void)
     2.4      struct vcpu *v = current;
     2.5  
     2.6      highest_vector = find_highest_pending_irq(v, &intr_type);
     2.7 -    __vmread_vcpu(CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
     2.8 +    __vmread_vcpu(v, CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
     2.9  
    2.10      if (highest_vector == -1) {
    2.11          disable_irq_window(cpu_exec_control);
     3.1 --- a/xen/include/asm-x86/vmx.h	Sat Oct 08 09:51:43 2005 +0100
     3.2 +++ b/xen/include/asm-x86/vmx.h	Sat Oct 08 09:54:06 2005 +0100
     3.3 @@ -314,10 +314,8 @@ static always_inline int ___vmread (cons
     3.4  }
     3.5  
     3.6  
     3.7 -static always_inline void __vmwrite_vcpu(unsigned long field, unsigned long value)
     3.8 +static always_inline void __vmwrite_vcpu(struct vcpu *v, unsigned long field, unsigned long value)
     3.9  {
    3.10 -    struct vcpu *v = current;
    3.11 -
    3.12      switch(field) {
    3.13      case CR0_READ_SHADOW:
    3.14  	v->arch.arch_vmx.cpu_shadow_cr0 = value;
    3.15 @@ -334,10 +332,8 @@ static always_inline void __vmwrite_vcpu
    3.16      }
    3.17  }
    3.18  
    3.19 -static always_inline void __vmread_vcpu(unsigned long field, unsigned long *value)
    3.20 +static always_inline void __vmread_vcpu(struct vcpu *v, unsigned long field, unsigned long *value)
    3.21  {
    3.22 -    struct vcpu *v = current;
    3.23 -
    3.24      switch(field) {
    3.25      case CR0_READ_SHADOW:
    3.26  	*value = v->arch.arch_vmx.cpu_shadow_cr0;
    3.27 @@ -352,24 +348,15 @@ static always_inline void __vmread_vcpu(
    3.28  	printk("__vmread_cpu: invalid field %lx\n", field);
    3.29  	break;
    3.30      }
    3.31 -
    3.32 -   /* 
    3.33 -    * __vmwrite() can be used for non-current vcpu, and it's possible that
    3.34 -    * the vcpu field is not initialized at that case.
    3.35 -    * 
    3.36 -    */
    3.37 -    if (!*value) {
    3.38 -	__vmread(field, value);
    3.39 -	__vmwrite_vcpu(field, *value);
    3.40 -    }
    3.41  }
    3.42  
    3.43  static inline int __vmwrite (unsigned long field, unsigned long value)
    3.44  {
    3.45      unsigned long eflags;
    3.46 +    struct vcpu *v = current;
    3.47  
    3.48      __asm__ __volatile__ ( VMWRITE_OPCODE
    3.49 -                           MODRM_EAX_ECX       
    3.50 +                           MODRM_EAX_ECX
    3.51                             :
    3.52                             : "a" (field) , "c" (value)
    3.53                             : "memory");
    3.54 @@ -381,7 +368,7 @@ static inline int __vmwrite (unsigned lo
    3.55      case CR0_READ_SHADOW:
    3.56      case GUEST_CR0:
    3.57      case CPU_BASED_VM_EXEC_CONTROL:
    3.58 -	__vmwrite_vcpu(field, value);
    3.59 +	__vmwrite_vcpu(v, field, value);
    3.60  	break;
    3.61      }
    3.62  
    3.63 @@ -437,13 +424,14 @@ static inline int __vmxon (u64 addr)
    3.64  static inline void vmx_stts(void)
    3.65  {
    3.66      unsigned long cr0;
    3.67 +    struct vcpu *v = current;
    3.68  
    3.69 -    __vmread_vcpu(GUEST_CR0, &cr0);
    3.70 +    __vmread_vcpu(v, GUEST_CR0, &cr0);
    3.71      if (!(cr0 & X86_CR0_TS)) {
    3.72          __vmwrite(GUEST_CR0, cr0 | X86_CR0_TS);
    3.73      }
    3.74  
    3.75 -    __vmread_vcpu(CR0_READ_SHADOW, &cr0);
    3.76 +    __vmread_vcpu(v, CR0_READ_SHADOW, &cr0);
    3.77      if (!(cr0 & X86_CR0_TS))
    3.78         __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_NM);
    3.79  }
    3.80 @@ -453,7 +441,7 @@ static inline int vmx_paging_enabled(str
    3.81  {
    3.82      unsigned long cr0;
    3.83  
    3.84 -    __vmread_vcpu(CR0_READ_SHADOW, &cr0);
    3.85 +    __vmread_vcpu(v, CR0_READ_SHADOW, &cr0);
    3.86      return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
    3.87  }
    3.88