Skip to contentSkip to conversation

x86/msr: don't inject #GP when trying to read FEATURE_CONTROL

PATCH Superseded Roger Pau Monne 2 participants 3 messages Nov 27, 2020 – Dec 29, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/msr: don't inject #GP when trying to read FEATURE_CONTROL

Windows 10 will triple fault if #GP is injected when attempting to read the FEATURE_CONTROL MSR on Intel or compatible hardware. Fix this by injecting a #GP only when the vendor doesn't support the MSR, even if there are no features to expose.

Fixes 39ab598c50a2 ('x86/pv: allow reading FEATURE_CONTROL MSR')
---
 xen/arch/x86/msr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/msr.c +1 -1
index be8e363862..38b0a046e1 100644
@@ -176,7 +176,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
     switch ( msr )
     {
     case MSR_IA32_FEATURE_CONTROL:
-        if ( !cp->basic.vmx && !vmce_has_lmce(v) )
+        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )
             goto gp_fault;
 
         *val = IA32_FEATURE_CONTROL_LOCK;
Signature · 1 line
2.29.2
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Roger Pau Monne

Windows 10 will triple fault if #GP is injected when attempting to read the FEATURE_CONTROL MSR on Intel or compatible hardware. Fix this by injecting a #GP only when the vendor doesn't support the MSR, even if there are no features to expose.

Fixes 39ab598c50a2 ('x86/pv: allow reading FEATURE_CONTROL MSR')

In principle

However, iirc it was Andrew who had suggested the conditional you now replace, so I'd like to wait for him to voice a view.

xen/arch/x86/msr.c int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) · line 179

Quoted 8 lines
xen/arch/x86/msr.c +1 -1
@@ -176,7 +176,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
     switch ( msr )
     {
     case MSR_IA32_FEATURE_CONTROL:
-        if ( !cp->basic.vmx && !vmce_has_lmce(v) )
+        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )

What about Shanghai? init_shanghai() calling init_intel_cacheinfo() suggests to me it's at least as Intel-like as Centaur/VIA.

Jan

#2 lore raw
Quoted 15 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monne

Windows 10 will triple fault if #GP is injected when attempting to read the FEATURE_CONTROL MSR on Intel or compatible hardware. Fix this by injecting a #GP only when the vendor doesn't support the MSR, even if there are no features to expose.

Fixes 39ab598c50a2 ('x86/pv: allow reading FEATURE_CONTROL MSR')

In principle

However, iirc it was Andrew who had suggested the conditional you now replace, so I'd like to wait for him to voice a view.

Quoted 11 lines

xen/arch/x86/msr.c int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) · line 179

Quoted 8 lines
xen/arch/x86/msr.c +1 -1
@@ -176,7 +176,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
     switch ( msr )
     {
     case MSR_IA32_FEATURE_CONTROL:
-        if ( !cp->basic.vmx && !vmce_has_lmce(v) )
+        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )

What about Shanghai? init_shanghai() calling init_intel_cacheinfo() suggests to me it's at least as Intel-like as Centaur/VIA.

Right, and it also has VMX AFAICT. I'm not sure whether we could also gate on the presence of VMX and LMCE on the physical CPU. I will send and updated version with Shanghai added and will keep your Ack.

Thanks, Roger.