[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240311164638.2015063-12-pasha.tatashin@soleen.com>
Date: Mon, 11 Mar 2024 16:46:35 +0000
From: Pasha Tatashin <pasha.tatashin@...een.com>
To: linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
akpm@...ux-foundation.org,
x86@...nel.org,
bp@...en8.de,
brauner@...nel.org,
bristot@...hat.com,
bsegall@...gle.com,
dave.hansen@...ux.intel.com,
dianders@...omium.org,
dietmar.eggemann@....com,
eric.devolder@...cle.com,
hca@...ux.ibm.com,
hch@...radead.org,
hpa@...or.com,
jacob.jun.pan@...ux.intel.com,
jgg@...pe.ca,
jpoimboe@...nel.org,
jroedel@...e.de,
juri.lelli@...hat.com,
kent.overstreet@...ux.dev,
kinseyho@...gle.com,
kirill.shutemov@...ux.intel.com,
lstoakes@...il.com,
luto@...nel.org,
mgorman@...e.de,
mic@...ikod.net,
michael.christie@...cle.com,
mingo@...hat.com,
mjguzik@...il.com,
mst@...hat.com,
npiggin@...il.com,
peterz@...radead.org,
pmladek@...e.com,
rick.p.edgecombe@...el.com,
rostedt@...dmis.org,
surenb@...gle.com,
tglx@...utronix.de,
urezki@...il.com,
vincent.guittot@...aro.org,
vschneid@...hat.com,
pasha.tatashin@...een.com
Subject: [RFC 11/14] x86: add support for Dynamic Kernel Stacks
Add dynamic_stack_fault() calls to the kernel faults, and also declare
HAVE_ARCH_DYNAMIC_STACK = y, so that dynamic kernel stacks can be
enabled on x86 architecture.
Signed-off-by: Pasha Tatashin <pasha.tatashin@...een.com>
---
arch/x86/Kconfig | 1 +
arch/x86/kernel/traps.c | 3 +++
arch/x86/mm/fault.c | 3 +++
3 files changed, 7 insertions(+)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5edec175b9bf..9bb0da3110fa 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -197,6 +197,7 @@ config X86
select HAVE_ARCH_USERFAULTFD_WP if X86_64 && USERFAULTFD
select HAVE_ARCH_USERFAULTFD_MINOR if X86_64 && USERFAULTFD
select HAVE_ARCH_VMAP_STACK if X86_64
+ select HAVE_ARCH_DYNAMIC_STACK if X86_64
select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
select HAVE_ARCH_WITHIN_STACK_FRAMES
select HAVE_ASM_MODVERSIONS
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index c3b2f863acf0..cc05401e729f 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -413,6 +413,9 @@ DEFINE_IDTENTRY_DF(exc_double_fault)
}
#endif
+ if (dynamic_stack_fault(current, address))
+ return;
+
irqentry_nmi_enter(regs);
instrumentation_begin();
notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index d6375b3c633b..651c558b10eb 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1198,6 +1198,9 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
if (is_f00f_bug(regs, hw_error_code, address))
return;
+ if (dynamic_stack_fault(current, address))
+ return;
+
/* Was the fault spurious, caused by lazy TLB invalidation? */
if (spurious_kernel_fault(hw_error_code, address))
return;
--
2.44.0.278.ge034bb2e1d-goog
Powered by blists - more mailing lists