Re: [PATCH v2] x86/fred: Consolidate the FRED stack pointer assignments
From: Dave Hansen
Date: Mon Nov 30 2026 - 17:43:59 EST
On 11/24/26 12:06, Sohil Mehta wrote:
> +static unsigned long this_cpu_fred_sp(u32 msr)
> +{
I don't super like where this is going.
The previous code kinda showed in one place how the FRED stack levels
map to the exception stacks:
> /* The FRED equivalents to IST stacks... */
> - wrmsrq(MSR_IA32_FRED_RSP1, __this_cpu_ist_top_va(ESTACK_DB));
> - wrmsrq(MSR_IA32_FRED_RSP2, __this_cpu_ist_top_va(ESTACK_NMI));
> - wrmsrq(MSR_IA32_FRED_RSP3, __this_cpu_ist_top_va(ESTACK_DF));
But the new abstraction hides it completely:
> + wrmsrq(MSR_IA32_FRED_RSP1, this_cpu_fred_sp(MSR_IA32_FRED_RSP1));
> + wrmsrq(MSR_IA32_FRED_RSP2, this_cpu_fred_sp(MSR_IA32_FRED_RSP2));
> + wrmsrq(MSR_IA32_FRED_RSP3, this_cpu_fred_sp(MSR_IA32_FRED_RSP3));
> }
It also says MSR_IA32_FRED_RSPX in a redundant way.
Can this be done without the redundancy? Could it also be done with a
build warning instead of a runtime one? I'd honestly be OK with this
thing going in a header even. It's *tiny*.
BTW, does the KVM code need the MSR value or does it also need to do a
wrmsr()?