xen: fix cpuid reporting on PVH Dom0
RFC PATCH 1/1 xen: fix cpuid reporting on PVH Dom0
dab11417d also caused some problems regarding HVM guest creation on PVH Dom0, mainly the CR4 mask returned by hvm_cr4_guest_reserved_bits changed from 0xfffffffffffff800 to 0xfffffffffffff893, which means HVM guests created from a PVH Dom0 are unable to set VME, PVI, PSE or PGE CR4 flags.
This is because cpuid on PVH guests mask PSE, PGE, PSE36 and VME flags, so the white listing done in xc_cpuid_hvm_policy doesn't enable those features, and the guest ends up with a very restrictive cpuid policy.
---
TBH, I'm not sure what's the best way to fix this, the cpuid stuff is so convoluted and it's done in so many different places that I've probably missed something.
--- xen/arch/x86/traps.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
xen/arch/x86/traps.c +9 -4
@@ -803,12 +803,17 @@ void pv_cpuid(struct cpu_user_regs *regs)if ( (regs->eax &0x7fffffff ) ==0x00000001 ) {/* Modify Feature Information. */ -__clear_bit (X86_FEATURE_VME , &d);if ( !cpu_has_apic )__clear_bit (X86_FEATURE_APIC , &d); -__clear_bit (X86_FEATURE_PSE , &d); -__clear_bit (X86_FEATURE_PGE , &d); -__clear_bit (X86_FEATURE_PSE36 , &d); +if ( !is_pvh_vcpu (curr) || !is_control_domain (curr->domain) || + !is_hardware_domain (curr->domain) ) + { +__clear_bit (X86_FEATURE_PSE , &d); +__clear_bit (X86_FEATURE_PGE , &d); +__clear_bit (X86_FEATURE_PSE36 , &d); +__clear_bit (X86_FEATURE_VME , &d); + } + } switch ( (uint32_t)regs->eax )
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines · Roger Pau Monne
dab11417dalso caused some problems regarding HVM guest creation on PVH Dom0, mainly the CR4 mask returned byhvm_cr4_guest_reserved_bitschanged from0xfffffffffffff800to0xfffffffffffff893, which means HVM guests created from a PVH Dom0 are unable to set VME, PVI, PSE or PGE CR4 flags.This is because cpuid on PVH guests mask PSE, PGE, PSE36 and VME flags, so the white listing done in
xc_cpuid_hvm_policydoesn't enable those features, and the guest ends up with a very restrictive cpuid policy.
Quoted 7 lines
Signed-off-by Roger Pau Monné <[email protected]>Cc Jan Beulich <[email protected]>Cc Andrew Cooper <[email protected]>---
TBH, I'm not sure what's the best way to fix this, the cpuid stuff is so convoluted and it's done in so many different places that I've probably missed something.
The whole cpuid setup is a mess which I plan to address once migration v2 is sorted.
For now, my best suggestion is hack it until it works.
Quoted 10 lines
--- xen/arch/x86/traps.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)xen/arch/x86/traps.c +0
-0@@ -803,12 +803,17 @@ void pv_cpuid(struct cpu_user_regs *regs)if ( (regs->eax &0x7fffffff ) ==0x00000001 )
xen/arch/x86/traps.c void pv_cpuid(struct cpu_user_regs *regs) · line 809
Quoted 10 lines
xen/arch/x86/traps.c +2
-4{/* Modify Feature Information. */ -__clear_bit (X86_FEATURE_VME , &d);if ( !cpu_has_apic )__clear_bit (X86_FEATURE_APIC , &d); -__clear_bit (X86_FEATURE_PSE , &d); -__clear_bit (X86_FEATURE_PGE , &d); -__clear_bit (X86_FEATURE_PSE36 , &d); +if ( !is_pvh_vcpu (curr) || !is_control_domain (curr->domain) || + !is_hardware_domain (curr->domain) )
I am not really sure what the expected difference between is_control_domain() and is_hardware_domain() actually is, but they are synonymous for anyone not using hardware_dom=<something other than 0>
I suspect that is_control_domain() is irrelevant here however.
~Andrew
xen/arch/x86/traps.c void pv_cpuid(struct cpu_user_regs *regs) · line 819
Quoted 10 lines
xen/arch/x86/traps.c +7
-0+ { +__clear_bit (X86_FEATURE_PSE , &d); +__clear_bit (X86_FEATURE_PGE , &d); +__clear_bit (X86_FEATURE_PSE36 , &d); +__clear_bit (X86_FEATURE_VME , &d); + } + } switch ( (uint32_t)regs->eax )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 24.07.14 at 18:42, <[email protected]> wrote:
dab11417dalso caused some problems regarding HVM guest creation on PVH Dom0, mainly the CR4 mask returned byhvm_cr4_guest_reserved_bitschanged from0xfffffffffffff800to0xfffffffffffff893, which means HVM guests created from a PVH Dom0 are unable to set VME, PVI, PSE or PGE CR4 flags.This is because cpuid on PVH guests mask PSE, PGE, PSE36 and VME flags, so the white listing done in
xc_cpuid_hvm_policydoesn't enable those features, and the guest ends up with a very restrictive cpuid policy.Signed-off-by Roger Pau Monné <[email protected]>Cc Jan Beulich <[email protected]>Cc Andrew Cooper <[email protected]>---
TBH, I'm not sure what's the best way to fix this, the cpuid stuff is so convoluted and it's done in so many different places that I've probably missed something.--- xen/arch/x86/traps.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)xen/arch/x86/traps.c +0
-0@@ -803,12 +803,17 @@ void pv_cpuid(struct cpu_user_regs *regs)if ( (regs->eax &0x7fffffff ) ==0x00000001 )
xen/arch/x86/traps.c void pv_cpuid(struct cpu_user_regs *regs) · line 809
Quoted 10 lines
xen/arch/x86/traps.c +2
-4{/* Modify Feature Information. */ -__clear_bit (X86_FEATURE_VME , &d);if ( !cpu_has_apic )__clear_bit (X86_FEATURE_APIC , &d); -__clear_bit (X86_FEATURE_PSE , &d); -__clear_bit (X86_FEATURE_PGE , &d); -__clear_bit (X86_FEATURE_PSE36 , &d); +if ( !is_pvh_vcpu (curr) || !is_control_domain (curr->domain) || + !is_hardware_domain (curr->domain) )
Don't you rather mean
if ( !is_pvh_vcpu(curr) || (!is_control_domain(curr->domain) &&
!is_hardware_domain(curr->domain)) )in which case, considering earlier logic in this function, this just becomes
if ( !is_pvh_vcpu(curr) )
? And I can't see anyway why the control/hardware domain property would matter for any of these features, so I think even from a logical standpoint it should just be the latter.
Jan
Quoted 12 lines
xen/arch/x86/traps.c +7
-0+ { +__clear_bit (X86_FEATURE_PSE , &d); +__clear_bit (X86_FEATURE_PGE , &d); +__clear_bit (X86_FEATURE_PSE36 , &d); +__clear_bit (X86_FEATURE_VME , &d); + } + } switch ( (uint32_t)regs->eax )Signature · 1 line
1.7.7.5 (Apple Git-26)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel