[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201109112319.264511-19-alexandre.chartre@oracle.com>
Date: Mon, 9 Nov 2020 12:23:13 +0100
From: Alexandre Chartre <alexandre.chartre@...cle.com>
To: "tglx@...utronix.de"@aserv0121.oracle.com,
"mingo@...hat.com"@aserv0121.oracle.com,
"bp@...en8.de"@aserv0121.oracle.com,
"hpa@...or.com"@aserv0121.oracle.com,
"x86@...nel.org"@aserv0121.oracle.com,
"dave.hansen@...ux.intel.com"@aserv0121.oracle.com,
"luto@...nel.org"@aserv0121.oracle.com,
"peterz@...radead.org"@aserv0121.oracle.com,
"linux-kernel@...r.kernel.org"@aserv0121.oracle.com,
"thomas.lendacky@....com"@aserv0121.oracle.com,
"jroedel@...e.de"@aserv0121.oracle.com
Cc: "konrad.wilk@...cle.com"@aserv0121.oracle.com,
"jan.setjeeilers@...cle.com"@aserv0121.oracle.com,
"junaids@...gle.com"@aserv0121.oracle.com,
"oweisse@...gle.com"@aserv0121.oracle.com,
"rppt@...ux.vnet.ibm.com"@aserv0121.oracle.com,
"graf@...zon.de"@aserv0121.oracle.com,
"mgross@...ux.intel.com"@aserv0121.oracle.com,
"kuzuno@...il.com"@aserv0121.oracle.com,
"alexandre.chartre@...cle.com"@aserv0121.oracle.com
Subject: [RFC][PATCH 18/24] x86/pti: Execute system vector handlers on the kernel stack
After an interrupt/exception in userland, the kernel is entered
and it switches the stack to the PTI stack which is mapped both in
the kernel and in the user page-table. When executing the interrupt
function, switch to the kernel stack (which is mapped only in the
kernel page-table) so that no kernel data leak to the userland
through the stack.
Changes system vector handlers to execute on the kernel stack.
Signed-off-by: Alexandre Chartre <alexandre.chartre@...cle.com>
---
arch/x86/include/asm/idtentry.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index a82e31b45442..0c5d9f027112 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -66,6 +66,17 @@ void run_idt_errcode(void (*func)(struct pt_regs *, unsigned long),
CALL_ON_STACK_2(pti_kernel_stack(regs), func, regs, error_code);
}
+static __always_inline
+void run_sysvec(void (*func)(struct pt_regs *regs), struct pt_regs *regs)
+{
+ void *stack = pti_kernel_stack(regs);
+
+ if (stack)
+ asm_call_on_stack_1(stack, (void (*)(void))func, regs);
+ else
+ run_sysvec_on_irqstack_cond(func, regs);
+}
+
/**
* DECLARE_IDTENTRY - Declare functions for simple IDT entry points
* No error code pushed by hardware
@@ -295,7 +306,7 @@ __visible noinstr void func(struct pt_regs *regs) \
instrumentation_begin(); \
irq_enter_rcu(); \
kvm_set_cpu_l1tf_flush_l1d(); \
- run_sysvec_on_irqstack_cond(__##func, regs); \
+ run_sysvec(__##func, regs); \
irq_exit_rcu(); \
instrumentation_end(); \
irqentry_exit(regs, state); \
--
2.18.4
Powered by blists - more mailing lists