[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen stable-4.18] x86/ucode: Fix stability of the raw CPU Policy rescan
commit b1fdd7d0e47e0831ac7a99d0417385fc10d3068c Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Thu Feb 1 18:02:24 2024 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Feb 1 18:02:24 2024 +0100 x86/ucode: Fix stability of the raw CPU Policy rescan Always run microcode_update_helper() on the BSP, so the the updated Raw CPU policy doesn't get non-BSP topology details included. Have calculate_raw_cpu_policy() clear the instantanious XSTATE sizes. The value XCR0 | MSR_XSS had when we scanned the policy isn't terribly interesting to report. When CPUID Masking is active, it affects CPUID instructions issued by Xen too. Transiently disable masking to get a clean scan. Fixes: 694d79ed5aac ("x86/ucode: Refresh raw CPU policy after microcode load") Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> master commit: cf7fe8b72deaa94157ddf97d4bb391480205e9c2 master date: 2024-01-25 17:46:57 +0000 --- xen/arch/x86/cpu-policy.c | 7 +++++++ xen/arch/x86/cpu/microcode/core.c | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c index 81e574390f..bcb17b7ce3 100644 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -353,6 +353,13 @@ void calculate_raw_cpu_policy(void) /* Nothing good will come from Xen and libx86 disagreeing on vendor. */ ASSERT(p->x86_vendor == boot_cpu_data.x86_vendor); + /* + * Clear the truly dynamic fields. These vary with the in-context XCR0 + * and MSR_XSS, and aren't interesting fields in the raw policy. + */ + p->xstate.raw[0].b = 0; + p->xstate.raw[1].b = 0; + /* 0x000000ce MSR_INTEL_PLATFORM_INFO */ /* Was already added by probe_cpuid_faulting() */ } diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index 65ebeb50de..4e011cdc41 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -680,8 +680,18 @@ static long cf_check microcode_update_helper(void *data) microcode_update_cache(patch); spin_unlock(µcode_mutex); - /* Refresh the raw CPU policy, in case the features have changed. */ + /* + * Refresh the raw CPU policy, in case the features have changed. + * Disable CPUID masking if in use, to avoid having current's + * cpu_policy affect the rescan. + */ + if ( ctxt_switch_masking ) + alternative_vcall(ctxt_switch_masking, NULL); + calculate_raw_cpu_policy(); + + if ( ctxt_switch_masking ) + alternative_vcall(ctxt_switch_masking, current); } else microcode_free_patch(patch); @@ -721,8 +731,12 @@ int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) } buffer->len = len; - return continue_hypercall_on_cpu(smp_processor_id(), - microcode_update_helper, buffer); + /* + * Always queue microcode_update_helper() on CPU0. Most of the logic + * won't care, but the update of the Raw CPU policy wants to (re)run on + * the BSP. + */ + return continue_hypercall_on_cpu(0, microcode_update_helper, buffer); } static int __init cf_check microcode_init(void) -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.18
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |