Skip to contentSkip to conversation

xen/vPMU: Do not clobber IA32_MISC_ENABLE

PATCH In review Andrew Cooper 2 participants 4 messages Mar 7, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/vPMU: Do not clobber IA32_MISC_ENABLE

The VMX RDMSR intercept for MSR_IA32_MISC_ENABLE falls through into vpmu_do_rdmsr(), so that core2_vpmu_do_rdmsr() may play with the PTS and PEBS UNAVAIL bits.

Some 64bit Windows include IA32_MISC_ENABLE in the set of items checked by PatchGuard, and will suffer a BSOD 0x109 CRITICAL_STRUCTURE_CORRUPTION if the contents change on migrate.

The vPMU infrastructure should not clobber IA32_MISC_ENABLE at all.

---
CC: Jan Beulich <[email protected]>
CC: Boris Ostrovsky <[email protected]>

This appears to have been broken since the vPMU code was first introduced. It appears to have lurked this log due to a hole (now fixed) in XenServers upgrade testing. The BSODs occur ~80% of the time on Win 8 thru 10, but appear very hard to provoke on Windows 7.

This MSR still leaks mostly host state through into the guest. Therefore migration of windows is still liable to crash if moving between two non-identical servers. I need to get proper MSR levelling sorted before this issue can be resolved fully.

---
 xen/arch/x86/cpu/vpmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/vpmu.c +1 -1
index 237b5ff..2f9ddf6 100644
@@ -169,7 +169,7 @@ int vpmu_do_msr(unsigned int msr, uint64_t *msr_content,
     return ret;
 
  nop:
-    if ( !is_write )
+    if ( !is_write && (msr != MSR_IA32_MISC_ENABLE) )
         *msr_content = 0;
 
     return 0;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw
Quoted 33 lines · Andrew Cooper

The VMX RDMSR intercept for MSR_IA32_MISC_ENABLE falls through into vpmu_do_rdmsr(), so that core2_vpmu_do_rdmsr() may play with the PTS and PEBS UNAVAIL bits.

Some 64bit Windows include IA32_MISC_ENABLE in the set of items checked by PatchGuard, and will suffer a BSOD 0x109 CRITICAL_STRUCTURE_CORRUPTION if the contents change on migrate.

The vPMU infrastructure should not clobber IA32_MISC_ENABLE at all.

---
CC: Jan Beulich <[email protected]>
CC: Boris Ostrovsky <[email protected]>

This appears to have been broken since the vPMU code was first introduced. It appears to have lurked this log due to a hole (now fixed) in XenServers upgrade testing. The BSODs occur ~80% of the time on Win 8 thru 10, but appear very hard to provoke on Windows 7.

This MSR still leaks mostly host state through into the guest. Therefore migration of windows is still liable to crash if moving between two non-identical servers. I need to get proper MSR levelling sorted before this issue can be resolved fully.

---
  xen/arch/x86/cpu/vpmu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/vpmu.c +0 -0
index 237b5ff..2f9ddf6 100644

xen/arch/x86/cpu/vpmu.c int vpmu_do_msr(unsigned int msr, uint64_t *msr_content, · line 175

Quoted 8 lines
xen/arch/x86/cpu/vpmu.c +1 -1
@@ -169,7 +169,7 @@ int vpmu_do_msr(unsigned int msr, uint64_t *msr_content,
      return ret;
 
   nop:
-    if ( !is_write )
+    if ( !is_write && (msr != MSR_IA32_MISC_ENABLE) )
          *msr_content = 0;
 
      return 0;

This is Intel-specific register so the test should really be happening in vpmu_intel.c. Of course then you'd need to always dereference vcpu_vpmu() and possibly add more checks to read/write ops (to mirror the one at the top of vpmu_do_msr()).

So maybe at least have the vendor check too??

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 54 lines · Boris Ostrovsky
Quoted 39 lines · Andrew Cooper

The VMX RDMSR intercept for MSR_IA32_MISC_ENABLE falls through into vpmu_do_rdmsr(), so that core2_vpmu_do_rdmsr() may play with the PTS and PEBS
UNAVAIL bits.

Some 64bit Windows include IA32_MISC_ENABLE in the set of items checked by
PatchGuard, and will suffer a BSOD 0x109 CRITICAL_STRUCTURE_CORRUPTION if the
contents change on migrate.

The vPMU infrastructure should not clobber IA32_MISC_ENABLE at all.

---
CC: Jan Beulich <[email protected]>
CC: Boris Ostrovsky <[email protected]>

This appears to have been broken since the vPMU code was first introduced. It
appears to have lurked this log due to a hole (now fixed) in XenServers upgrade testing. The BSODs occur ~80% of the time on Win 8 thru 10, but appear very hard to provoke on Windows 7.

This MSR still leaks mostly host state through into the guest. Therefore
migration of windows is still liable to crash if moving between two non-identical servers. I need to get proper MSR levelling sorted before this
issue can be resolved fully.

---
  xen/arch/x86/cpu/vpmu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/vpmu.c +0 -0
index 237b5ff..2f9ddf6 100644

xen/arch/x86/cpu/vpmu.c int vpmu_do_msr(unsigned int msr, uint64_t · line 174

Quoted 7 lines
xen/arch/x86/cpu/vpmu.c +1 -1
@@ -169,7 +169,7 @@ int vpmu_do_msr(unsigned int msr, uint64_t
 *msr_content,
      return ret;
     nop:
-    if ( !is_write )
+    if ( !is_write && (msr != MSR_IA32_MISC_ENABLE) )
          *msr_content = 0;
        return 0;

This is Intel-specific register so the test should really be happening in vpmu_intel.c. Of course then you'd need to always dereference vcpu_vpmu() and possibly add more checks to read/write ops (to mirror the one at the top of vpmu_do_msr()).

Quoted 1 line

So maybe at least have the vendor check too??

Strictly speaking, if we were to do a vendor check, it should be a guest vendor check, not a host vendor check.

OTOH, we won't get here on a non-Intel host system, and emulating a cross-vendor vPMU is going to end in disaster. I personally don't think its worth it.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by
#3 lore raw
Quoted 54 lines · Andrew Cooper
Quoted 53 lines · Boris Ostrovsky
Quoted 39 lines · Andrew Cooper

The VMX RDMSR intercept for MSR_IA32_MISC_ENABLE falls through into vpmu_do_rdmsr(), so that core2_vpmu_do_rdmsr() may play with the PTS and PEBS
UNAVAIL bits.

Some 64bit Windows include IA32_MISC_ENABLE in the set of items checked by
PatchGuard, and will suffer a BSOD 0x109 CRITICAL_STRUCTURE_CORRUPTION if the
contents change on migrate.

The vPMU infrastructure should not clobber IA32_MISC_ENABLE at all.

---
CC: Jan Beulich <[email protected]>
CC: Boris Ostrovsky <[email protected]>

This appears to have been broken since the vPMU code was first introduced. It
appears to have lurked this log due to a hole (now fixed) in XenServers upgrade testing. The BSODs occur ~80% of the time on Win 8 thru 10, but appear very hard to provoke on Windows 7.

This MSR still leaks mostly host state through into the guest. Therefore
migration of windows is still liable to crash if moving between two non-identical servers. I need to get proper MSR levelling sorted before this
issue can be resolved fully.

---
   xen/arch/x86/cpu/vpmu.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/vpmu.c +0 -0
index 237b5ff..2f9ddf6 100644

xen/arch/x86/cpu/vpmu.c int vpmu_do_msr(unsigned int msr, uint64_t · line 174

Quoted 7 lines
xen/arch/x86/cpu/vpmu.c +1 -1
@@ -169,7 +169,7 @@ int vpmu_do_msr(unsigned int msr, uint64_t
 *msr_content,
       return ret;
      nop:
-    if ( !is_write )
+    if ( !is_write && (msr != MSR_IA32_MISC_ENABLE) )
           *msr_content = 0;
         return 0;

This is Intel-specific register so the test should really be happening in vpmu_intel.c. Of course then you'd need to always dereference vcpu_vpmu() and possibly add more checks to read/write ops (to mirror the one at the top of vpmu_do_msr()).

Quoted 7 lines
Quoted 1 line

So maybe at least have the vendor check too??

Strictly speaking, if we were to do a vendor check, it should be a guest vendor check, not a host vendor check.

OTOH, we won't get here on a non-Intel host system, and emulating a cross-vendor vPMU is going to end in disaster. I personally don't think its worth it.

I wasn't thinking about cross-vendor cases. But I forgot that we now go to VPMU code only for VPMU registers.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel