Re: [PATCH v1 3/3] x86/entry: Set FRED RSP0 on return to userspace instead of context switch
From: Sean Christopherson
Date: Wed Aug 07 2024 - 17:55:21 EST
On Wed, Aug 07, 2024, Thomas Gleixner wrote:
> Though I wonder if this should not have a per CPU cache for that.
>
> if (cpu_feature_enabled(X86_FEATURE_FRED) {
> unsigned long rsp0 = (unsigned long) task_stack_page(current) + THREAD_SIZE;
>
> if (__this_cpu_read(cpu_fred_rsp0) != rsp0) {
> wrmsrns(MSR_IA32_FRED_RSP0, fred_rsp0);
> this_cpu_write(cpu_fred_rsp0, rsp0);
> }
> }
>
> Hmm?
A per-CPU cache would work for KVM too, KVM would just need to stuff the cache
with the guest's value instead of setting _TIF_LOAD_USER_STATES.