RE: [PATCH v5 23/34] x86/fred: update MSR_IA32_FRED_RSP0 during task switch

Li, Xin3
2023-03-20T23:55:05Z

> > - if (cpu_feature_enabled(X86_FEATURE_XENPV))
> > + if (cpu_feature_enabled(X86_FEATURE_FRED)) {
> > + /*
> > + * Will use WRMSRNS/WRMSRLIST for performance once it's
> upstreamed.
> > + */
> > + wrmsrl(MSR_IA32_FRED_RSP0,
> > + task_top_of_stack(task) +
> TOP_OF_KERNEL_STACK_PADDING);
> > + } else if (cpu_feature_enabled(X86_FEATURE_XENPV)) {
>
> Whee, so hardware will really only ever look at this when RSP0? I don't need to
> worry about exceptions during context switch?

You're right, we don't.

RSP0 is only used in ring3. Exceptions from ring0 just keep using the current
kernel stack unless a higher stack level needs to be used, e.g., RSP3 for #DF.

Thanks!
Xin