Re: [PATCH v10 05/28] x86/cea: Use array indexing to simplify exception stack access
From: Sohil Mehta
Date: Fri Nov 20 2026 - 22:13:34 EST
On 9/11/2026 2:36 PM, Sohil Mehta wrote:
> From: "Xin Li (Intel)" <xin@xxxxxxxxx>
>
> Refactor struct cea_exception_stacks to leverage array indexing for
> exception stack access, improving code clarity and eliminating the
> need for the ESTACKS_MEMBERS() macro.
>
> Convert __this_cpu_ist_{bottom,top}_va() from macros to functions,
While, separating out these patches, I realized that this is no longer
needed. this_cpu_fred_rsp() is planned to be exported instead of
__this_cpu_ist_top_va().
So the FRED KVM enabling doesn't depend on patches 4 and 5 anymore. Even
without the macro conversion the cleanups are useful. So, I posted them
separately.
https://lore.kernel.org/lkml/20261120235025.2809042-1-sohil.mehta@xxxxxxxxx/
Planning to stop carrying the CEA patches in the FRED KVM series.
> -#define __this_cpu_ist_top_va(name) \
> - CEA_ESTACK_TOP(__this_cpu_read(cea_exception_stacks), name)
> -
> -#define __this_cpu_ist_bottom_va(name) \
> - CEA_ESTACK_BOT(__this_cpu_read(cea_exception_stacks), name)
> -
> #endif
...
> +/*
> + * Typically invoked by entry code, so must be noinstr.
> + */
> +noinstr unsigned long __this_cpu_ist_bottom_va(enum exception_stack_ordering stack)
> +{
> + struct cea_exception_stacks *s;
> +
> + BUILD_BUG_ON(ESTACK_DF != 0);
> + BUG_ON(stack >= N_EXCEPTION_STACKS);
> +
> + s = __this_cpu_read(cea_exception_stacks);
> +
> + return (unsigned long)&s->event_stacks[stack].stack;
> +}
> +
> +noinstr unsigned long __this_cpu_ist_top_va(enum exception_stack_ordering stack)
> +{
> + return __this_cpu_ist_bottom_va(stack) + EXCEPTION_STKSZ;
> +}
> +
> static DEFINE_PER_CPU_READ_MOSTLY(unsigned long, _cea_offset);