Re: [PATCH 2/2] x86/cea: Index exception stacks by the ordering enum
From: Dave Hansen
Date: Mon Nov 23 2026 - 11:22:29 EST
On 11/20/26 15:50, Sohil Mehta wrote:
> +/* The exception stacks' physical storage. No guard pages required */
> +struct exception_stacks {
> + char ESTACK_DF_stack [EXCEPTION_STKSZ];
> + char ESTACK_NMI_stack[EXCEPTION_STKSZ];
> + char ESTACK_DB_stack [EXCEPTION_STKSZ];
> + char ESTACK_MCE_stack[EXCEPTION_STKSZ];
/* The #VC stack storage is conditionally compiled out: */
> + char ESTACK_VC_stack [VC_EXCEPTION_STKSZ];
> + char ESTACK_VC2_stack[VC_EXCEPTION_STKSZ];
> +};
Please vertically align the [EXCEPTION_STKSZ] like I did ^. Also, please
add some kind of comment about why the VC stacks need to be different.
Honestly, though, looking at this, two #ifdefs would be perfectly
readable here.
struct exception_stacks {
char ESTACK_DF_stack [EXCEPTION_STKSZ];
char ESTACK_NMI_stack[EXCEPTION_STKSZ];
char ESTACK_DB_stack [EXCEPTION_STKSZ];
char ESTACK_MCE_stack[EXCEPTION_STKSZ];
#ifdef CONFIG_AMD_MEM_ENCRYPT
char ESTACK_VC_stack [EXCEPTION_STKSZ];
char ESTACK_VC2_stack[EXCEPTION_STKSZ];
#endif
};
Because, without it, we have to explain VC_EXCEPTION_STKSZ anyway.
> +/* The effective cpu entry area mapping with guard pages. */
> +struct cea_exception_stacks {
> + struct {
> + char stack_guard[PAGE_SIZE];
> + char stack[EXCEPTION_STKSZ];
> + } stacks[N_EXCEPTION_STACKS];
> + char IST_top_guard[PAGE_SIZE];
> +};
I dislike the asymmetry here. I'd rather just have two explicit lists of
stacks. This also begs the question but doesn't offer an answer about
why it's OK to have EXCEPTION_STKSZ vs. VC_EXCEPTION_STKSZ in the
"exception_stacks" but have EXCEPTION_STKSZ for all in
"cea_exception_stacks".