x86/svm: Drop support for AMD's Lightweight Profiling
PATCH 1/1 x86/svm: Drop support for AMD's Lightweight Profiling
Lightweight Profiling was introduced in Bulldozer (Fam15h), but was dropped from Zen (Fam17h) processors. Furthermore, LWP was dropped from Fam15/16 CPUs when IBPB for Spectre v2 was introduced in microcode, owing to LWP not being used in practice.
As a result, CPUs which are operating within specification (i.e. with up to date microcode) no longer have this feature, and therefore are not using it.
Drop support from Xen. The main motivation here is to remove unnecessary complexity from CPUID handling, but it also tidies up the SVM code nicely.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Brian Woods <[email protected]>
--- xen/arch/x86/cpuid.c | 22 +-------- xen/arch/x86/hvm/svm/svm.c | 77 ----------------------------- xen/arch/x86/hvm/svm/vmcb.c | 5 -- xen/arch/x86/msr.c | 4 ++ xen/arch/x86/xstate.c | 3 +- xen/include/asm-x86/cpufeature.h | 1 - xen/include/asm-x86/hvm/svm/vmcb.h | 4 -- xen/include/asm-x86/xstate.h | 3 +- xen/include/public/arch-x86/cpufeatureset.h | 2 +- 9 files changed, 8 insertions(+), 113 deletions(-)
xen/arch/x86/cpuid.c +1 -21
@@ -163,14 +163,6 @@ static void recalculate_xstate(struct cpuid_policy *p) xstate_sizes[X86_XCR0_PKRU_POS]); } -if ( p->extd.lwp ) - { - xstates |=X86_XCR0_LWP ; - xstate_size =max (xstate_size, - xstate_offsets[X86_XCR0_LWP_POS ] + - xstate_sizes[X86_XCR0_LWP_POS ]); - } - p->xstate.max_size = xstate_size; p->xstate.xcr0_low = xstates & ~XSTATE_XSAVES_ONLY ; p->xstate.xcr0_high = (xstates & ~XSTATE_XSAVES_ONLY ) >>32 ;
@@ -265,8 +257,7 @@ static void recalculate_misc(struct cpuid_policy *p)zero_leaves (p->extd.raw,0xb ,0x18 ); p->extd.raw[0x1b ] =EMPTY_LEAF ;/* IBS - not supported. */ - - p->extd.raw[0x1c ].a =0 ;/* LWP.a entirely dynamic. */ + p->extd.raw[0x1c ] =EMPTY_LEAF ;/* LWP - not supported. */ break ; } }
@@ -581,11 +572,6 @@ void recalculate_cpuid_policy(struct domain *d)if ( !p->extd.page1gb ) p->extd.raw[0x19 ] =EMPTY_LEAF ; - -if ( p->extd.lwp ) - p->extd.raw[0x1c ].d &= max->extd.raw[0x1c ].d; -else - p->extd.raw[0x1c ] =EMPTY_LEAF ; }int init_domain_cpuid_policy (struct domain *d)
@@ -972,12 +958,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, res->d |=cpufeat_mask (X86_FEATURE_MTRR ); }break ; - -case 0x8000001c : -if ( (v->arch.xcr0 &X86_XCR0_LWP ) && cpu_has_svm ) -/* Turn on available bit and other features specified in lwp_cfg. */ - res->a = (res->d & v->arch.hvm.svm.guest_lwp_cfg) |1 ; -break ; } }
xen/arch/x86/hvm/svm/svm.c +0 -77
107 lines not on this page · raw message
xen/arch/x86/hvm/svm/vmcb.c +0 -5
@@ -100,11 +100,6 @@ static int construct_vmcb(struct vcpu *v)svm_disable_intercept_for_msr (v,MSR_STAR );svm_disable_intercept_for_msr (v,MSR_SYSCALL_MASK ); -/* LWP_CBADDR MSR is saved and restored by FPU code. So SVM doesn't need to -* intercept it. */ -if ( cpu_has_lwp ) -svm_disable_intercept_for_msr (v,MSR_AMD64_LWP_CBADDR ); - vmcb->_msrpm_base_pa =virt_to_maddr (svm->msrpm); vmcb->_iopm_base_pa =__pa (v->domain->arch.hvm.io_bitmap);
xen/arch/x86/msr.c +4 -0
@@ -132,6 +132,8 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)case MSR_FLUSH_CMD :/* Write-only */ case MSR_TSX_FORCE_ABORT : +case MSR_AMD64_LWP_CFG : +case MSR_AMD64_LWP_CBADDR :/* Not offered to guests. */ goto gp_fault;
@@ -272,6 +274,8 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)case MSR_ARCH_CAPABILITIES :/* Read-only */ case MSR_TSX_FORCE_ABORT : +case MSR_AMD64_LWP_CFG : +case MSR_AMD64_LWP_CBADDR :/* Not offered to guests. */ goto gp_fault;
xen/arch/x86/xstate.c +1 -2
@@ -725,8 +725,7 @@ int handle_xsetbv(u32 index, u64 new_bv) curr->arch.xcr0 = new_bv; curr->arch.xcr0_accum |= new_bv; -/* LWP sets nonlazy_xstate_used independently. */ -if ( new_bv & (XSTATE_NONLAZY & ~X86_XCR0_LWP ) ) +if ( new_bv &XSTATE_NONLAZY ) curr->arch.nonlazy_xstate_used =1 ; mask &= curr->fpu_dirtied ? ~XSTATE_FP_SSE :XSTATE_NONLAZY ;
xen/include/asm-x86/cpufeature.h +0 -1
@@ -78,7 +78,6 @@#define cpu_has_svm boot_cpu_has(X86_FEATURE_SVM)#define cpu_has_sse4a boot_cpu_has(X86_FEATURE_SSE4A)#define cpu_has_xop boot_cpu_has(X86_FEATURE_XOP) -#define cpu_has_lwp boot_cpu_has(X86_FEATURE_LWP)#define cpu_has_fma4 boot_cpu_has(X86_FEATURE_FMA4)#define cpu_has_tbm boot_cpu_has(X86_FEATURE_TBM)
xen/include/asm-x86/hvm/svm/vmcb.h +0 -4
@@ -534,10 +534,6 @@ struct svm_vcpu {uint64_t guest_sysenter_cs;uint64_t guest_sysenter_esp;uint64_t guest_sysenter_eip; - -/* AMD lightweight profiling MSR */ -uint64_t guest_lwp_cfg;/* guest version */ -uint64_t cpu_lwp_cfg;/* CPU version */ };struct vmcb_struct *alloc_vmcb (void );
xen/include/asm-x86/xstate.h +1 -2
@@ -35,8 +35,7 @@ extern uint32_t mxcsr_mask; XSTATE_NONLAZY)#define XSTATE_ALL (~(1ULL << 63)) -#define XSTATE_NONLAZY (X86_XCR0_LWP | X86_XCR0_BNDREGS | X86_XCR0_BNDCSR | \ - X86_XCR0_PKRU) +#define XSTATE_NONLAZY (X86_XCR0_BNDREGS | X86_XCR0_BNDCSR | X86_XCR0_PKRU)#define XSTATE_LAZY (XSTATE_ALL & ~XSTATE_NONLAZY)#define XSTATE_XSAVES_ONLY 0#define XSTATE_COMPACTION_ENABLED (1ULL << 63)
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -176,7 +176,7 @@ XEN_CPUFEATURE(IBS, 3*32+10) /* Instruction Based Sampling */ XEN_CPUFEATURE(XOP, 3*32+11) /*A extended AVX instructions */ XEN_CPUFEATURE(SKINIT, 3*32+12) /* SKINIT/STGI instructions */ XEN_CPUFEATURE(WDT, 3*32+13) /* Watchdog timer */ -XEN_CPUFEATURE(LWP, 3*32+15) /*S Light Weight Profiling */ +XEN_CPUFEATURE(LWP, 3*32+15) /* Light Weight Profiling */ XEN_CPUFEATURE(FMA4, 3*32+16) /*A 4 operands MAC instructions */ XEN_CPUFEATURE(NODEID_MSR, 3*32+19) /* NodeId MSR */XEN_CPUFEATURE (TBM ,3 *32 +21 )/*A trailing bit manipulations */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.05.19 at 12:13, <[email protected]> wrote:
Lightweight Profiling was introduced in Bulldozer (Fam15h), but was dropped from Zen (Fam17h) processors. Furthermore, LWP was dropped from Fam15/16 CPUs when IBPB for Spectre v2 was introduced in microcode, owing to LWP not being used in practice.
Quoted 7 lines
As a result, CPUs which are operating within specification (i.e. with up to date microcode) no longer have this feature, and therefore are not using it.
Drop support from Xen. The main motivation here is to remove unnecessary complexity from CPUID handling, but it also tidies up the SVM code nicely.
Signed-off-by Andrew Cooper <[email protected]>
xen/include/public/arch-x86/cpufeatureset.h XEN_CPUFEATURE(IBS, 3*32+10) /* Instruction Based Sampling */ · line 179
Quoted 8 lines
xen/include/public/arch-x86/cpufeatureset.h +1
-1@@ -176,7 +176,7 @@ XEN_CPUFEATURE(IBS, 3*32+10) /* Instruction Based Sampling */ XEN_CPUFEATURE(XOP, 3*32+11) /*A extended AVX instructions */ XEN_CPUFEATURE(SKINIT, 3*32+12) /* SKINIT/STGI instructions */ XEN_CPUFEATURE(WDT, 3*32+13) /* Watchdog timer */ -XEN_CPUFEATURE (LWP ,3 *32 +15 )/*S Light Weight Profiling */ +XEN_CPUFEATURE (LWP ,3 *32 +15 )/* Light Weight Profiling */
Strictly speaking this is not permitted (see the other thread on this being part of the public interface). But of course strictly speaking it was also not permitted for AMD to remove the feature in a ucode update (I wonder btw whether the insns indeed #UD now on Fam15/16).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.05.19 at 12:13, <[email protected]> wrote:
Lightweight Profiling was introduced in Bulldozer (Fam15h), but was dropped from Zen (Fam17h) processors. Furthermore, LWP was dropped from Fam15/16 CPUs when IBPB for Spectre v2 was introduced in microcode, owing to LWP not being used in practice.
Quoted 8 lines
Quoted 7 lines
As a result, CPUs which are operating within specification (i.e. with up to date microcode) no longer have this feature, and therefore are not using it.
Drop support from Xen. The main motivation here is to remove unnecessary complexity from CPUID handling, but it also tidies up the SVM code nicely.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
Quoted 14 lines
xen/include/public/arch-x86/cpufeatureset.h XEN_CPUFEATURE(IBS, 3*32+10) /* Instruction Based Sampling */ · line 179
Quoted 9 lines
xen/include/public/arch-x86/cpufeatureset.h +1
-1@@ -176,7 +176,7 @@ XEN_CPUFEATURE(IBS, 3*32+10) /* Instruction Based Sampling */ XEN_CPUFEATURE(XOP, 3*32+11) /*A extended AVX instructions */ XEN_CPUFEATURE(SKINIT, 3*32+12) /* SKINIT/STGI instructions */ XEN_CPUFEATURE(WDT, 3*32+13) /* Watchdog timer */ -XEN_CPUFEATURE (LWP ,3 *32 +15 )/*S Light Weight Profiling */ +XEN_CPUFEATURE (LWP ,3 *32 +15 )/* Light Weight Profiling */ Strictly speaking this is not permitted (see the other thread on this being part of the public interface). But of course strictly speaking it was also not permitted for AMD to remove the feature in a ucode update (I wonder btw whether the insns indeed #UD now on Fam15/16).
There is nothing "not permitted" about it. AMD can do whatever they want in microcode, as can we with our feature support.
It is certainly in their (and our) interest to not break backwards compatibility, which is why there should be a very good reason to regress the customer experience.
In this case, LWP had already been dropped from Zen because it wasn't used in practice, and then suddenly Spectre/Meltdown came along and urgently needed a fix. AMD didn't drop LWP lightly, and would have avoided doing so if it was possible.
However, given a choice between fixing Spectre, and retaining support for a feature which isn't used, dropping LWP was the correct decision to make, however uncomfortable the decision was to make.
As for #UD, I haven't tried but I'd expect so. All the instructions were already specified to #UD anyway when XCR0.LWP was clear.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · Andy Cooper
Lightweight Profiling was introduced in Bulldozer (Fam15h), but was dropped from Zen (Fam17h) processors. Furthermore, LWP was dropped from Fam15/16 CPUs when IBPB for Spectre v2 was introduced in microcode, owing to LWP not being used in practice.
Quoted 7 lines
As a result, CPUs which are operating within specification (i.e. with up to date microcode) no longer have this feature, and therefore are not using it.
Drop support from Xen. The main motivation here is to remove unnecessary complexity from CPUID handling, but it also tidies up the SVM code nicely.
Signed-off-by Andrew Cooper <[email protected]>
I've confirmed with HW engineers that it's going away.
Signature · 6 lines
Brian Woods _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel