Re: [PATCH 2/2] x86/cea: Index exception stacks by the ordering enum

From: Sohil Mehta

Date: Mon Nov 23 2026 - 15:43:02 EST


On 11/23/2026 10:34 AM, Sohil Mehta wrote:

>> 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.
>>
>
> I think commit 541ac97186d9 ("x86/sev: Make the #VC exception stacks
> part of the default stacks storage") added the #ifdefs in the header

I meant ^ VC_EXCEPTION_STKSZ

> file to avoid the #ifdefs in percpu_setup_exception_stacks().
>
>> 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.
>>
>
>

...

>> 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".
>
>
> The exception_stacks tracks to real storage so it uses
> VC_EXCEPTION_STKSZ to save space in case CONFIG_AMD_MEM_ENCRYPT isn't
> enabled. The cea_exception_stacks only reserve a slot with no PTEs so
> they are using EXCEPTION_STKSZ for simplicity.
>

Ah! This isn't just for simplicity. The EPAGERANGE(ESTACK_VC/VC2) usage
in dumpstack has a compile issue if the CEA_ESTACK_SIZE is zero.

Overall, Patch 1 was the most useful (Thanks for merging that). The name
pasting macros have been working fine for a few years. I am not seeing a
lot of value in disturbing the status quo with Patch 2 especially since
we want to keep the two structs symmetric.

Maybe some clarifying code comments would be useful, but I can't think
of anything beyond that. Please let me know if you feel otherwise.