# HG changeset patch
# User Steven Hand <steven@xxxxxxxxxxxxx>
# Node ID 0e9055d69f12e230ed086bd9445aef863a16e129
# Parent 3236311a23a5083ec78cac53ccad1e92d619e8a1
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@xxxxxxxxx>
Signed-off-by: Steven Hand <steven@xxxxxxxxxxxxx>
---
xen/arch/x86/hvm/svm/svm.c | 12 ++++++++++++
xen/arch/x86/hvm/vmx/vmx.c | 1 +
xen/arch/x86/mm/shadow/common.c | 2 +-
xen/include/asm-x86/hvm/hvm.h | 7 +++++++
xen/include/asm-x86/hvm/vmx/vmcs.h | 3 +++
xen/include/asm-x86/hvm/vmx/vmx.h | 6 ++++++
6 files changed, 30 insertions(+), 1 deletion(-)
diff -r 3236311a23a5 -r 0e9055d69f12 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Fri Sep 22 12:14:22 2006 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c Fri Sep 22 12:27:28 2006 +0100
@@ -259,6 +259,17 @@ static int svm_paging_enabled(struct vcp
return (cr0 & X86_CR0_PE) && (cr0 & X86_CR0_PG);
}
+static int svm_pae_enabled(struct vcpu *v)
+{
+ unsigned long cr4;
+
+ if(!svm_paging_enabled(v))
+ return 0;
+
+ cr4 = v->arch.hvm_svm.cpu_shadow_cr4;
+
+ return (cr4 & X86_CR4_PAE);
+}
#define IS_CANO_ADDRESS(add) 1
@@ -865,6 +876,7 @@ int start_svm(void)
hvm_funcs.realmode = svm_realmode;
hvm_funcs.paging_enabled = svm_paging_enabled;
hvm_funcs.long_mode_enabled = svm_long_mode_enabled;
+ hvm_funcs.pae_enabled = svm_pae_enabled;
hvm_funcs.guest_x86_mode = svm_guest_x86_mode;
hvm_funcs.instruction_length = svm_instruction_length;
hvm_funcs.get_guest_ctrl_reg = svm_get_ctrl_reg;
diff -r 3236311a23a5 -r 0e9055d69f12 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Fri Sep 22 12:14:22 2006 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c Fri Sep 22 12:27:28 2006 +0100
@@ -746,6 +746,7 @@ static void vmx_setup_hvm_funcs(void)
hvm_funcs.realmode = vmx_realmode;
hvm_funcs.paging_enabled = vmx_paging_enabled;
hvm_funcs.long_mode_enabled = vmx_long_mode_enabled;
+ hvm_funcs.pae_enabled = vmx_pae_enabled;
hvm_funcs.guest_x86_mode = vmx_guest_x86_mode;
hvm_funcs.instruction_length = vmx_instruction_length;
hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
diff -r 3236311a23a5 -r 0e9055d69f12 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c Fri Sep 22 12:14:22 2006 +0100
+++ b/xen/arch/x86/mm/shadow/common.c Fri Sep 22 12:27:28 2006 +0100
@@ -2343,7 +2343,7 @@ void sh_update_paging_modes(struct vcpu
}
else
#endif
- if ( hvm_get_guest_ctrl_reg(v, 4) & X86_CR4_PAE )
+ if ( hvm_pae_enabled(v) )
{
#if CONFIG_PAGING_LEVELS >= 3
// 32-bit PAE mode guest...
diff -r 3236311a23a5 -r 0e9055d69f12 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h Fri Sep 22 12:14:22 2006 +0100
+++ b/xen/include/asm-x86/hvm/hvm.h Fri Sep 22 12:27:28 2006 +0100
@@ -57,6 +57,7 @@ struct hvm_function_table {
int (*realmode)(struct vcpu *v);
int (*paging_enabled)(struct vcpu *v);
int (*long_mode_enabled)(struct vcpu *v);
+ int (*pae_enabled)(struct vcpu *v);
int (*guest_x86_mode)(struct vcpu *v);
int (*instruction_length)(struct vcpu *v);
unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
@@ -146,6 +147,12 @@ hvm_long_mode_enabled(struct vcpu *v)
return hvm_funcs.long_mode_enabled(v);
}
+ static inline int
+hvm_pae_enabled(struct vcpu *v)
+{
+ return hvm_funcs.pae_enabled(v);
+}
+
static inline int
hvm_guest_x86_mode(struct vcpu *v)
{
diff -r 3236311a23a5 -r 0e9055d69f12 xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Fri Sep 22 12:14:22 2006 +0100
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Fri Sep 22 12:27:28 2006 +0100
@@ -38,6 +38,9 @@ enum {
#define VMX_LONG_GUEST(ed) \
(test_bit(VMX_CPU_STATE_LMA_ENABLED, &ed->arch.hvm_vmx.cpu_state))
+
+#define VMX_PAE_GUEST(ed) \
+ (test_bit(VMX_CPU_STATE_PAE_ENABLED, &ed->arch.hvm_vmx.cpu_state))
struct vmcs_struct {
u32 vmcs_revision_id;
diff -r 3236311a23a5 -r 0e9055d69f12 xen/include/asm-x86/hvm/vmx/vmx.h
--- a/xen/include/asm-x86/hvm/vmx/vmx.h Fri Sep 22 12:14:22 2006 +0100
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h Fri Sep 22 12:27:28 2006 +0100
@@ -418,6 +418,12 @@ static inline int vmx_long_mode_enabled(
return VMX_LONG_GUEST(current);
}
+static inline int vmx_pae_enabled(struct vcpu *v)
+{
+ ASSERT(v == current);
+ return VMX_PAE_GUEST(current);
+}
+
/* Works only for vcpu == current */
static inline int vmx_realmode(struct vcpu *v)
{
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|