[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v9 12/36] x86/fred: Update MSR_IA32_FRED_RSP0 during task switch
- To: linux-doc@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-edac@xxxxxxxxxxxxxxx, linux-hyperv@xxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Xin Li <xin3.li@xxxxxxxxx>
- Date: Tue, 1 Aug 2023 01:32:54 -0700
- Cc: Jonathan Corbet <corbet@xxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, "H . Peter Anvin" <hpa@xxxxxxxxx>, Andy Lutomirski <luto@xxxxxxxxxx>, Oleg Nesterov <oleg@xxxxxxxxxx>, Tony Luck <tony.luck@xxxxxxxxx>, "K . Y . Srinivasan" <kys@xxxxxxxxxxxxx>, Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>, Wei Liu <wei.liu@xxxxxxxxxx>, Dexuan Cui <decui@xxxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Wanpeng Li <wanpengli@xxxxxxxxxxx>, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Sean Christopherson <seanjc@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Josh Poimboeuf <jpoimboe@xxxxxxxxxx>, "Paul E . McKenney" <paulmck@xxxxxxxxxx>, Catalin Marinas <catalin.marinas@xxxxxxx>, Randy Dunlap <rdunlap@xxxxxxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Kim Phillips <kim.phillips@xxxxxxx>, Xin Li <xin3.li@xxxxxxxxx>, Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>, "Liam R . Howlett" <Liam.Howlett@xxxxxxxxxx>, Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>, "Kirill A . Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>, Suren Baghdasaryan <surenb@xxxxxxxxxx>, Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>, Babu Moger <babu.moger@xxxxxxx>, Jim Mattson <jmattson@xxxxxxxxxx>, Sandipan Das <sandipan.das@xxxxxxx>, Lai Jiangshan <jiangshanlai@xxxxxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, Reinette Chatre <reinette.chatre@xxxxxxxxx>, Daniel Sneddon <daniel.sneddon@xxxxxxxxxxxxxxx>, Breno Leitao <leitao@xxxxxxxxxx>, Nikunj A Dadhania <nikunj@xxxxxxx>, Brian Gerst <brgerst@xxxxxxxxx>, Sami Tolvanen <samitolvanen@xxxxxxxxxx>, Alexander Potapenko <glider@xxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, "Eric W . Biederman" <ebiederm@xxxxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, Masami Hiramatsu <mhiramat@xxxxxxxxxx>, Masahiro Yamada <masahiroy@xxxxxxxxxx>, Ze Gao <zegao2021@xxxxxxxxx>, Fei Li <fei1.li@xxxxxxxxx>, Conghui <conghui.chen@xxxxxxxxx>, Ashok Raj <ashok.raj@xxxxxxxxx>, "Jason A . Donenfeld" <Jason@xxxxxxxxx>, Mark Rutland <mark.rutland@xxxxxxx>, Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>, Jiapeng Chong <jiapeng.chong@xxxxxxxxxxxxxxxxx>, Jane Malalane <jane.malalane@xxxxxxxxxx>, David Woodhouse <dwmw@xxxxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>, Yantengsi <siyanteng@xxxxxxxxxxx>, Christophe Leroy <christophe.leroy@xxxxxxxxxx>, Sathvika Vasireddy <sv@xxxxxxxxxxxxx>
- Delivery-date: Tue, 01 Aug 2023 09:02:11 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: "H. Peter Anvin (Intel)" <hpa@xxxxxxxxx>
MSR_IA32_FRED_RSP0 is used during ring 3 event delivery, and needs to
be updated to point to the top of next task stack during task switch.
Update MSR_IA32_FRED_RSP0 with WRMSR instruction for now, and will use
WRMSRNS/WRMSRLIST for performance once it gets upstreamed.
Signed-off-by: H. Peter Anvin (Intel) <hpa@xxxxxxxxx>
Tested-by: Shan Kang <shan.kang@xxxxxxxxx>
Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
---
arch/x86/include/asm/switch_to.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
index f42dbf17f52b..6c911fd400b2 100644
--- a/arch/x86/include/asm/switch_to.h
+++ b/arch/x86/include/asm/switch_to.h
@@ -70,9 +70,16 @@ static inline void update_task_stack(struct task_struct
*task)
#ifdef CONFIG_X86_32
this_cpu_write(cpu_tss_rw.x86_tss.sp1, task->thread.sp0);
#else
- /* Xen PV enters the kernel on the thread stack. */
- 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,
+ (unsigned long)task_stack_page(task) + THREAD_SIZE);
+ } else if (cpu_feature_enabled(X86_FEATURE_XENPV)) {
+ /* Xen PV enters the kernel on the thread stack. */
load_sp0(task_top_of_stack(task));
+ }
#endif
}
--
2.34.1
|