Re: [PATCH v5 22/34] x86/fred: FRED initialization code

Lai Jiangshan
2023-03-17T13:36:15Z

Hello

Comments in cpu_init_fred_exceptions() seem scarce for understanding.

On Tue, Mar 7, 2023 at 11:07 AM Xin Li <xin3.li@intel.com> wrote:

> +/*
> + * Initialize FRED on this CPU. This cannot be __init as it is called
> + * during CPU hotplug.
> + */
> +void cpu_init_fred_exceptions(void)
> +{
> + wrmsrl(MSR_IA32_FRED_CONFIG,
> + FRED_CONFIG_ENTRYPOINT(fred_entrypoint_user) |
> + FRED_CONFIG_REDZONE(8) | /* Reserve for CALL emulation */
> + FRED_CONFIG_INT_STKLVL(0));

What is it about "Reserve for CALL emulation"?

I guess it relates to X86_TRAP_BP. In entry_64.S:

.if \vector == X86_TRAP_BP
/*
* If coming from kernel space, create a 6-word gap to allow the
* int3 handler to emulate a call instruction.
*/

> +
> + wrmsrl(MSR_IA32_FRED_STKLVLS,
> + FRED_STKLVL(X86_TRAP_DB, 1) |
> + FRED_STKLVL(X86_TRAP_NMI, 2) |
> + FRED_STKLVL(X86_TRAP_MC, 2) |
> + FRED_STKLVL(X86_TRAP_DF, 3));

Why each exception here needs a stack level > 0?
Especially for X86_TRAP_DB and X86_TRAP_NMI.

Why does or why does not X86_TRAP_VE have a stack level > 0?

X86_TRAP_DF is the highest stack level, is it accidental
or deliberate?

Thanks
Lai