[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v9 18/36] x86/fred: Add a page fault entry stub for FRED
- 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:33:00 -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:20 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: "H. Peter Anvin (Intel)" <hpa@xxxxxxxxx>
Add a page fault entry stub for FRED.
On a FRED system, the faulting address (CR2) is passed on the stack,
to avoid the problem of transient state. Thus we get the page fault
address from the stack instead of CR2.
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/fred.h | 2 ++
arch/x86/mm/fault.c | 18 ++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/fred.h b/arch/x86/include/asm/fred.h
index b45c1bea5b7f..fb8e7b4f2d38 100644
--- a/arch/x86/include/asm/fred.h
+++ b/arch/x86/include/asm/fred.h
@@ -112,6 +112,8 @@ static __always_inline unsigned long fred_event_data(struct
pt_regs *regs)
typedef DECLARE_FRED_HANDLER((*fred_handler));
+DECLARE_FRED_HANDLER(fred_exc_page_fault);
+
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_X86_FRED */
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index e8711b2cafaf..dd3df092d0f2 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -34,6 +34,7 @@
#include <asm/kvm_para.h> /* kvm_handle_async_pf */
#include <asm/vdso.h> /* fixup_vdso_exception() */
#include <asm/irq_stack.h>
+#include <asm/fred.h>
#define CREATE_TRACE_POINTS
#include <asm/trace/exceptions.h>
@@ -1495,9 +1496,10 @@ handle_page_fault(struct pt_regs *regs, unsigned long
error_code,
}
}
-DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault)
+static __always_inline void page_fault_common(struct pt_regs *regs,
+ unsigned int error_code,
+ unsigned long address)
{
- unsigned long address = read_cr2();
irqentry_state_t state;
prefetchw(¤t->mm->mmap_lock);
@@ -1544,3 +1546,15 @@ DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault)
irqentry_exit(regs, state);
}
+
+DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault)
+{
+ page_fault_common(regs, error_code, read_cr2());
+}
+
+#ifdef CONFIG_X86_FRED
+DEFINE_FRED_HANDLER(fred_exc_page_fault)
+{
+ page_fault_common(regs, regs->orig_ax, fred_event_data(regs));
+}
+#endif
--
2.34.1
|