Skip to contentSkip to conversation

x86/msr: fix handling of MSR_IA32_PERF_{STATUS/CTL} (again)

PATCH In review Jan Beulich 4 participants 7 messages Feb 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/msr: fix handling of MSR_IA32_PERF_{STATUS/CTL} (again)

X86_VENDOR_* aren't bit masks in the older trees.

xen/arch/x86/msr.c +2 -1
@@ -226,7 +226,8 @@ int guest_rdmsr(const struct vcpu *v, ui
          */
     case MSR_IA32_PERF_STATUS:
     case MSR_IA32_PERF_CTL:
-        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )
+        if ( cp->x86_vendor != X86_VENDOR_INTEL &&
+             cp->x86_vendor != X86_VENDOR_CENTAUR )
             goto gp_fault;
 
         *val = 0;
#2 lore raw
Quoted 7 lines · Roger Pau Monné
Quoted 4 lines · Jan Beulich

X86_VENDOR_* aren't bit masks in the older trees.

Thanks.

Quoted 1 line

Should this have a set of Fixes tag for the commit hashes on <= 4.12?

I'd prefer Fixes: to only reference non-backports. The tag is mainly meant to allow noticing what needs backporting, after all.

Jan

#3 lore raw
In reply to Jan Beulich

Hi Jan,

Quoted 8 lines · Jan Beulich

X86_VENDOR_* aren't bit masks in the older trees.

xen/arch/x86/msr.c int guest_rdmsr(const struct vcpu *v, ui · line 233

Quoted 9 lines
xen/arch/x86/msr.c +2 -1
@@ -226,7 +226,8 @@ int guest_rdmsr(const struct vcpu *v, ui
          */
     case MSR_IA32_PERF_STATUS:
     case MSR_IA32_PERF_CTL:
-        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )
+        if ( cp->x86_vendor != X86_VENDOR_INTEL &&
+             cp->x86_vendor != X86_VENDOR_CENTAUR )
             goto gp_fault;
 
         *val = 0;

Thanks for this patch, I've applied it and the Windows guest no longer crashes.

Regards,
James

#5 lore raw
In reply to Jan Beulich
Quoted 8 lines · Jan Beulich

X86_VENDOR_* aren't bit masks in the older trees.

xen/arch/x86/msr.c int guest_rdmsr(const struct vcpu *v, ui · line 233

Quoted 9 lines
xen/arch/x86/msr.c +2 -1
@@ -226,7 +226,8 @@ int guest_rdmsr(const struct vcpu *v, ui
          */
     case MSR_IA32_PERF_STATUS:
     case MSR_IA32_PERF_CTL:
-        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )
+        if ( cp->x86_vendor != X86_VENDOR_INTEL &&
+             cp->x86_vendor != X86_VENDOR_CENTAUR )
             goto gp_fault;
 
         *val = 0;

Darn - this was only half of it. There's a similar construct in guest_wrmsr() which also wants replacing.

Jan

#6 lore raw
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Jan Beulich

X86_VENDOR_* aren't bit masks in the older trees.

xen/arch/x86/msr.c +2 -1
@@ -226,7 +226,8 @@ int guest_rdmsr(const struct vcpu *v, ui
          */
     case MSR_IA32_PERF_STATUS:
     case MSR_IA32_PERF_CTL:
-        if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) )
+        if ( cp->x86_vendor != X86_VENDOR_INTEL &&
+             cp->x86_vendor != X86_VENDOR_CENTAUR )
             goto gp_fault;
 
Quoted 3 lines

xen/arch/x86/msr.c int guest_rdmsr(const struct vcpu *v, ui · line 233

Quoted 1 line
xen/arch/x86/msr.c +0 -0
         *val = 0;

Darn - this was only half of it. There's a similar construct in guest_wrmsr() which also wants replacing.

I really should have renamed the constants when I changed their layout...

My R-by stands in light of that change.

~Andrew