lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200308231718.931465601@linutronix.de>
Date:   Mon, 09 Mar 2020 00:14:15 +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>,
        Frederic Weisbecker <frederic@...nel.org>,
        Alexandre Chartre <alexandre.chartre@...cle.com>
Subject: [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs

From: Thomas Gleixner <tglx@...utronix.de>

32 and 64 bit have unnecessary different ways to populate the exception
entry code. Provide a idtentry macro which allows to consolidate all of
that.

Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@...cle.com>

---
 arch/x86/entry/entry_32.S |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -44,6 +44,7 @@
 #include <asm/asm.h>
 #include <asm/smap.h>
 #include <asm/frame.h>
+#include <asm/trapnr.h>
 #include <asm/nospec-branch.h>
 
 #include "calling.h"
@@ -726,6 +727,47 @@
 
 .Lend_\@:
 .endm
+
+#ifdef CONFIG_X86_INVD_BUG
+.macro idtentry_push_func vector cfunc
+	.if \vector == X86_TRAP_XF
+		/* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */
+		ALTERNATIVE "pushl	$do_general_protection",	\
+			    "pushl	$do_simd_coprocessor_error",	\
+			    X86_FEATURE_XMM
+	.else
+		pushl $\cfunc
+	.endif
+.endm
+#else
+.macro idtentry_push_func vector cfunc
+	pushl $\cfunc
+.endm
+#endif
+
+/**
+ * idtentry - Macro to generate entry stubs for simple IDT entries
+ * @vector:		Vector number
+ * @asmsym:		ASM symbol for the entry point
+ * @cfunc:		C function to be called
+ * @has_error_code:	Hardware pushed error code on stack
+ */
+.macro idtentry vector asmsym cfunc has_error_code:req
+SYM_CODE_START(\asmsym)
+	ASM_CLAC
+	cld
+
+	.if \has_error_code == 0
+		pushl	$0		/* Clear the error code */
+	.endif
+
+	/* Push the C-function address into the GS slot */
+	idtentry_push_func \vector \cfunc
+	/* Invoke the common exception entry */
+	jmp	common_exception
+SYM_CODE_END(\asmsym)
+.endm
+
 /*
  * %eax: prev task
  * %edx: next task

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ