[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v9 17/36] x86/fred: Define a common function type fred_handler
- 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:59 -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:19 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
FRED event delivery establishes a full supervisor context by saving
the essential information about an event to a FRED stack frame, e.g.,
the faulting linear address of a #PF is saved as event data of a FRED
stack frame. Thus a struct pt_regs has all the needed data to handle
an event and it's the only input argument of a FRED event handler.
Define fred_handler, a common function type used in the FRED event
dispatch framework, which makes it easier to find the entry points
(via grep), allows the prototype to change if necessary without
requiring changing changes everywhere, and makes sure that all the
entry points have the proper decorations (currently noinstr, but
could change in the future.)
Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
---
arch/x86/include/asm/fred.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/x86/include/asm/fred.h b/arch/x86/include/asm/fred.h
index d76e681a806f..b45c1bea5b7f 100644
--- a/arch/x86/include/asm/fred.h
+++ b/arch/x86/include/asm/fred.h
@@ -68,6 +68,19 @@
#define FRED_SSX_64_BIT_MODE_BIT 57
#define FRED_SSX_64_BIT_MODE _BITUL(FRED_SSX_64_BIT_MODE_BIT)
+/*
+ * FRED event delivery establishes a full supervisor context by
+ * saving the essential information about an event to a FRED
+ * stack frame, e.g., the faulting linear address of a #PF is
+ * saved as event data of a FRED #PF stack frame. Thus a struct
+ * pt_regs has all the needed data to handle an event and it's
+ * the only input argument of a FRED event handler.
+ *
+ * FRED handlers need to be placed in the noinstr text section.
+ */
+#define DECLARE_FRED_HANDLER(f) void f (struct pt_regs *regs)
+#define DEFINE_FRED_HANDLER(f) noinstr DECLARE_FRED_HANDLER(f)
+
#ifdef CONFIG_X86_FRED
#ifndef __ASSEMBLY__
@@ -97,6 +110,8 @@ static __always_inline unsigned long fred_event_data(struct
pt_regs *regs)
return fred_info(regs)->edata;
}
+typedef DECLARE_FRED_HANDLER((*fred_handler));
+
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_X86_FRED */
--
2.34.1
|