Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
SUSE:SLE-12-SP5:Update
xen.9110
xsa269.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xsa269.patch of Package xen.9110
From: Andrew Cooper <andrew.cooper3@citrix.com> Subject: x86/vtx: Fix the checking for unknown/invalid MSR_DEBUGCTL bits The VPMU_MODE_OFF early-exit in vpmu_do_wrmsr() introduced by c/s 11fe998e56 bypasses all reserved bit checking in the general case. As a result, a guest can enable BTS when it shouldn't be permitted to, and lock up the entire host. With vPMU active (not a security supported configuration, but useful for debugging), the reserved bit checking in broken, caused by the original BTS changeset 1a8aa75ed. From a correctness standpoint, it is not possible to have two different pieces of code responsible for different parts of value checking, if there isn't an accumulation of bits which have been checked. A practical upshot of this is that a guest can set any value it wishes (usually resulting in a vmentry failure for bad guest state). Therefore, fix this by implementing all the reserved bit checking in the main MSR_DEBUGCTL block, and removing all handling of DEBUGCTL from the vPMU MSR logic. This is XSA-269 Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> --- sle12sp2.orig/xen/arch/x86/cpu/vpmu_intel.c 2018-08-14 13:52:44.835597386 +0200 +++ sle12sp2/xen/arch/x86/cpu/vpmu_intel.c 2018-07-16 08:48:07.000000000 +0200 @@ -68,10 +68,6 @@ #define MSR_PMC_ALIAS_MASK (~(MSR_IA32_PERFCTR0 ^ MSR_IA32_A_PERFCTR0)) static bool_t __read_mostly full_width_write; -/* Intel-specific VPMU features */ -#define VPMU_CPU_HAS_DS 0x100 /* Has Debug Store */ -#define VPMU_CPU_HAS_BTS 0x200 /* Has Branch Trace Store */ - /* * MSR_CORE_PERF_FIXED_CTR_CTRL contains the configuration of all fixed * counters. 4 bits for every counter. @@ -563,27 +559,7 @@ static int core2_vpmu_do_wrmsr(unsigned uint64_t *enabled_cntrs; if ( !core2_vpmu_msr_common_check(msr, &type, &index) ) - { - /* Special handling for BTS */ - if ( msr == MSR_IA32_DEBUGCTLMSR ) - { - supported |= IA32_DEBUGCTLMSR_TR | IA32_DEBUGCTLMSR_BTS | - IA32_DEBUGCTLMSR_BTINT; - - if ( cpu_has(¤t_cpu_data, X86_FEATURE_DSCPL) ) - supported |= IA32_DEBUGCTLMSR_BTS_OFF_OS | - IA32_DEBUGCTLMSR_BTS_OFF_USR; - if ( !(msr_content & ~supported) && - vpmu_is_set(vpmu, VPMU_CPU_HAS_BTS) ) - return 0; - if ( (msr_content & supported) && - !vpmu_is_set(vpmu, VPMU_CPU_HAS_BTS) ) - printk(XENLOG_G_WARNING - "%pv: Debug Store unsupported on this CPU\n", - current); - } return -EINVAL; - } ASSERT(!supported); --- sle12sp2.orig/xen/arch/x86/hvm/vmx/vmx.c 2018-08-14 13:52:44.835597386 +0200 +++ sle12sp2/xen/arch/x86/hvm/vmx/vmx.c 2018-07-16 08:48:07.000000000 +0200 @@ -2970,6 +2970,8 @@ static int vmx_msr_write_intercept(unsig switch ( msr ) { + uint64_t rsvd; + case MSR_IA32_SYSENTER_CS: __vmwrite(GUEST_SYSENTER_CS, msr_content); break; @@ -2984,17 +2986,29 @@ static int vmx_msr_write_intercept(unsig __vmwrite(GUEST_SYSENTER_EIP, msr_content); break; case MSR_IA32_DEBUGCTLMSR: { + uint32_t ebx, ecx = 0; int i, rc = 0; - uint64_t supported = IA32_DEBUGCTLMSR_LBR | IA32_DEBUGCTLMSR_BTF; - if ( boot_cpu_has(X86_FEATURE_RTM) ) - supported |= IA32_DEBUGCTLMSR_RTM; - if ( msr_content & ~supported ) + rsvd = ~(IA32_DEBUGCTLMSR_LBR | IA32_DEBUGCTLMSR_BTF); + + /* TODO: Wire vPMU settings properly through the CPUID policy */ + if ( vpmu_is_set(vcpu_vpmu(v), VPMU_CPU_HAS_BTS) ) { - /* Perhaps some other bits are supported in vpmu. */ - if ( vpmu_do_wrmsr(msr, msr_content, supported) ) - break; + rsvd &= ~(IA32_DEBUGCTLMSR_TR | IA32_DEBUGCTLMSR_BTS | + IA32_DEBUGCTLMSR_BTINT); + + if ( cpu_has(¤t_cpu_data, X86_FEATURE_DSCPL) ) + rsvd &= ~(IA32_DEBUGCTLMSR_BTS_OFF_OS | + IA32_DEBUGCTLMSR_BTS_OFF_USR); } + + hvm_cpuid(7, NULL, &ebx, &ecx, NULL); + if ( ebx & cpufeat_mask(X86_FEATURE_RTM) ) + rsvd &= ~IA32_DEBUGCTLMSR_RTM; + + if ( msr_content & rsvd ) + goto gp_fault; + if ( msr_content & IA32_DEBUGCTLMSR_LBR ) { const struct lbr_info *lbr = last_branch_msr_get(); --- sle12sp2.orig/xen/include/asm-x86/vpmu.h 2018-08-14 12:30:01.970303890 +0200 +++ sle12sp2/xen/include/asm-x86/vpmu.h 2018-07-16 08:48:07.000000000 +0200 @@ -77,6 +77,10 @@ struct vpmu_struct { /* PV(H) guests: VPMU registers are accessed by guest from shared page */ #define VPMU_CACHED 0x40 +/* Intel-specific VPMU features */ +#define VPMU_CPU_HAS_DS 0x100 /* Has Debug Store */ +#define VPMU_CPU_HAS_BTS 0x200 /* Has Branch Trace Store */ + static inline void vpmu_set(struct vpmu_struct *vpmu, const u32 mask) { vpmu->flags |= mask;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor