[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200225224145.444611199@linutronix.de>
Date: Tue, 25 Feb 2020 23:33:34 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: x86@...nel.org, Steven Rostedt <rostedt@...dmis.org>,
Brian Gerst <brgerst@...il.com>,
Juergen Gross <jgross@...e.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Arnd Bergmann <arnd@...db.de>
Subject: [patch 13/16] x86/entry: Move irqflags and context tracking to C for simple idtentries
Now that everything is converted to the new IDTENTRY mechansim, move the
irq tracing and the invocation of enter_to_user_mode() to C code, i.e. into
the idtentry_enter() inline which is invoked through the IDTENTRY magic.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
arch/x86/entry/entry_32.S | 1 -
arch/x86/entry/entry_64.S | 9 ---------
arch/x86/include/asm/idtentry.h | 19 ++++++++++++++++++-
3 files changed, 18 insertions(+), 11 deletions(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -1452,7 +1452,6 @@ SYM_CODE_START_LOCAL_NOALIGN(common_exce
movl PT_ORIG_EAX(%esp), %edx # get the error code
movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
- TRACE_IRQS_OFF
movl %esp, %eax # pt_regs pointer
CALL_NOSPEC %edi
jmp ret_from_exception
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -511,15 +511,6 @@ SYM_CODE_END(spurious_entries_start)
GET_CR2_INTO(%r12);
.endif
- TRACE_IRQS_OFF
-
-#ifdef CONFIG_CONTEXT_TRACKING
- testb $3, CS(%rsp)
- jz .Lfrom_kernel_no_ctxt_tracking_\@
- CALL_enter_from_user_mode
-.Lfrom_kernel_no_ctxt_tracking_\@:
-#endif
-
movq %rsp, %rdi /* pt_regs pointer into 1st argument*/
.if \has_error_code == 1
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -7,14 +7,31 @@
#ifndef __ASSEMBLY__
+#ifdef CONFIG_CONTEXT_TRACKING
+static __always_inline void enter_from_user_context(void)
+{
+ CT_WARN_ON(ct_state() != CONTEXT_USER);
+ user_exit_irqoff();
+}
+#else
+static __always_inline void enter_from_user_context(void) { }
+#endif
+
/**
* idtentry_enter - Handle state tracking on idtentry
* @regs: Pointer to pt_regs of interrupted context
*
- * Place holder for now.
+ * Invokes:
+ * - The hardirq tracer to keep the state consistent as low level ASM
+ * entry disabled interrupts.
+ *
+ * - Context tracking if the exception hit user mode
*/
static __always_inline void idtentry_enter(struct pt_regs *regs)
{
+ trace_hardirqs_off();
+ if (user_mode(regs))
+ enter_from_user_context();
}
/**
Powered by blists - more mailing lists