ia64/xen-unstable

changeset 11578:0e9055d69f12

This patch fixes an error booting 32bit vista on VMX.

The shadow code uses hvm_get_guest_ctrl_reg(v, 4) to test whether
PAE is enabled or not. But it is not always right if the hypervisor
calls hvm_get_guest_ctrl_reg(v, 4) between vmxassist_invoke and
vmxassist_restore

The patch uses the d->arch.hvm_vmx.cpu_state to test if the PAE is
enabled.

Also update SVM code to use the new 'pae_enabled' hvm func.

Signed-off-by: Xiaohui Xin <xiaohui.xin@intel.com>
Signed-off-by: Steven Hand <steven@xensource.com>
author Steven Hand <steven@xensource.com>
date Fri Sep 22 12:27:28 2006 +0100 (2006-09-22)
parents 3236311a23a5
children 1ca87f35ee4e
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/mm/shadow/common.c xen/include/asm-x86/hvm/hvm.h xen/include/asm-x86/hvm/vmx/vmcs.h xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Sep 22 12:14:22 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Sep 22 12:27:28 2006 +0100
     1.3 @@ -259,6 +259,17 @@ static int svm_paging_enabled(struct vcp
     1.4      return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
     1.5  }
     1.6  
     1.7 +static int svm_pae_enabled(struct vcpu *v)
     1.8 +{
     1.9 +    unsigned long cr4;
    1.10 +
    1.11 +    if(!svm_paging_enabled(v))
    1.12 +        return 0;
    1.13 +
    1.14 +    cr4 = v->arch.hvm_svm.cpu_shadow_cr4;
    1.15 +
    1.16 +    return (cr4 & X86_CR4_PAE);
    1.17 +}
    1.18  
    1.19  #define IS_CANO_ADDRESS(add) 1
    1.20  
    1.21 @@ -865,6 +876,7 @@ int start_svm(void)
    1.22      hvm_funcs.realmode = svm_realmode;
    1.23      hvm_funcs.paging_enabled = svm_paging_enabled;
    1.24      hvm_funcs.long_mode_enabled = svm_long_mode_enabled;
    1.25 +    hvm_funcs.pae_enabled = svm_pae_enabled;
    1.26      hvm_funcs.guest_x86_mode = svm_guest_x86_mode;
    1.27      hvm_funcs.instruction_length = svm_instruction_length;
    1.28      hvm_funcs.get_guest_ctrl_reg = svm_get_ctrl_reg;
     2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Sep 22 12:14:22 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Sep 22 12:27:28 2006 +0100
     2.3 @@ -746,6 +746,7 @@ static void vmx_setup_hvm_funcs(void)
     2.4      hvm_funcs.realmode = vmx_realmode;
     2.5      hvm_funcs.paging_enabled = vmx_paging_enabled;
     2.6      hvm_funcs.long_mode_enabled = vmx_long_mode_enabled;
     2.7 +    hvm_funcs.pae_enabled = vmx_pae_enabled;
     2.8      hvm_funcs.guest_x86_mode = vmx_guest_x86_mode;
     2.9      hvm_funcs.instruction_length = vmx_instruction_length;
    2.10      hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
     3.1 --- a/xen/arch/x86/mm/shadow/common.c	Fri Sep 22 12:14:22 2006 +0100
     3.2 +++ b/xen/arch/x86/mm/shadow/common.c	Fri Sep 22 12:27:28 2006 +0100
     3.3 @@ -2343,7 +2343,7 @@ void sh_update_paging_modes(struct vcpu 
     3.4              }
     3.5              else
     3.6  #endif
     3.7 -                if ( hvm_get_guest_ctrl_reg(v, 4) & X86_CR4_PAE )
     3.8 +                if ( hvm_pae_enabled(v) )
     3.9                  {
    3.10  #if CONFIG_PAGING_LEVELS >= 3
    3.11                      // 32-bit PAE mode guest...
     4.1 --- a/xen/include/asm-x86/hvm/hvm.h	Fri Sep 22 12:14:22 2006 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Fri Sep 22 12:27:28 2006 +0100
     4.3 @@ -57,6 +57,7 @@ struct hvm_function_table {
     4.4      int (*realmode)(struct vcpu *v);
     4.5      int (*paging_enabled)(struct vcpu *v);
     4.6      int (*long_mode_enabled)(struct vcpu *v);
     4.7 +    int (*pae_enabled)(struct vcpu *v);
     4.8      int (*guest_x86_mode)(struct vcpu *v);
     4.9      int (*instruction_length)(struct vcpu *v);
    4.10      unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
    4.11 @@ -146,6 +147,12 @@ hvm_long_mode_enabled(struct vcpu *v)
    4.12      return hvm_funcs.long_mode_enabled(v);
    4.13  }
    4.14  
    4.15 + static inline int
    4.16 +hvm_pae_enabled(struct vcpu *v)
    4.17 +{
    4.18 +    return hvm_funcs.pae_enabled(v);
    4.19 +}
    4.20 +
    4.21  static inline int
    4.22  hvm_guest_x86_mode(struct vcpu *v)
    4.23  {
     5.1 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h	Fri Sep 22 12:14:22 2006 +0100
     5.2 +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h	Fri Sep 22 12:27:28 2006 +0100
     5.3 @@ -39,6 +39,9 @@ enum {
     5.4  #define VMX_LONG_GUEST(ed)    \
     5.5    (test_bit(VMX_CPU_STATE_LMA_ENABLED, &ed->arch.hvm_vmx.cpu_state))
     5.6  
     5.7 +#define VMX_PAE_GUEST(ed)       \
     5.8 +  (test_bit(VMX_CPU_STATE_PAE_ENABLED, &ed->arch.hvm_vmx.cpu_state))
     5.9 +
    5.10  struct vmcs_struct {
    5.11      u32 vmcs_revision_id;
    5.12      unsigned char data [0]; /* vmcs size is read from MSR */
     6.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Fri Sep 22 12:14:22 2006 +0100
     6.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Fri Sep 22 12:27:28 2006 +0100
     6.3 @@ -418,6 +418,12 @@ static inline int vmx_long_mode_enabled(
     6.4      return VMX_LONG_GUEST(current);
     6.5  }
     6.6  
     6.7 +static inline int vmx_pae_enabled(struct vcpu *v)
     6.8 +{
     6.9 +    ASSERT(v == current);
    6.10 +    return VMX_PAE_GUEST(current);
    6.11 +}
    6.12 +
    6.13  /* Works only for vcpu == current */
    6.14  static inline int vmx_realmode(struct vcpu *v)
    6.15  {