]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/CPU/AMD: WARN when setting EFER.AUTOIBRS if and only if the WRMSR fails
authorSean Christopherson <seanjc@google.com>
Fri, 6 Dec 2024 16:20:06 +0000 (08:20 -0800)
committerIngo Molnar <mingo@kernel.org>
Fri, 6 Dec 2024 18:57:05 +0000 (19:57 +0100)
When ensuring EFER.AUTOIBRS is set, WARN only on a negative return code
from msr_set_bit(), as '1' is used to indicate the WRMSR was successful
('0' indicates the MSR bit was already set).

Fixes: 8cc68c9c9e92 ("x86/CPU/AMD: Make sure EFER[AIBRSE] is set")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/Z1MkNofJjt7Oq0G6@google.com
Closes: https://lore.kernel.org/all/20241205220604.GA2054199@thelio-3990X
arch/x86/kernel/cpu/amd.c

index d8408aafeed988454a570b0d7c423a8cee2a1bc4..79d2e17f6582e922630f9b5b54c025543d73d576 100644 (file)
@@ -1065,7 +1065,7 @@ static void init_amd(struct cpuinfo_x86 *c)
         */
        if (spectre_v2_in_eibrs_mode(spectre_v2_enabled) &&
            cpu_has(c, X86_FEATURE_AUTOIBRS))
-               WARN_ON_ONCE(msr_set_bit(MSR_EFER, _EFER_AUTOIBRS));
+               WARN_ON_ONCE(msr_set_bit(MSR_EFER, _EFER_AUTOIBRS) < 0);
 
        /* AMD CPUs don't need fencing after x2APIC/TSC_DEADLINE MSR writes. */
        clear_cpu_cap(c, X86_FEATURE_APIC_MSRS_FENCE);