aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2018-03-14 14:53:34 +0000
committerEd Maste <emaste@FreeBSD.org>2026-10-09 14:50:40 +0000
commit74d971fe156113cc63add2e6701e369c93c4f52b (patch)
tree015c29436ff8179e3033093e8bafe1b0df2dba5f
parent81b5b2265d7734f9c4d4603031b3e8254c7e23d8 (diff)
x86: Add external retpoline thunk
This allows use of -mindirect-branch=thunk-extern, and is only a few bytes of dead code if not used. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D60524
-rw-r--r--sys/amd64/amd64/support.S10
-rw-r--r--sys/i386/i386/support.S10
2 files changed, 20 insertions, 0 deletions
diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S
index 1d7d05843ba8..b037e03f87f2 100644
--- a/sys/amd64/amd64/support.S
+++ b/sys/amd64/amd64/support.S
@@ -1996,4 +1996,14 @@ ENTRY(cpu_sync_core)
iretq
END(cpu_sync_core)
+/* External Retpoline thunk */
+ENTRY(__x86_indirect_thunk_r11)
+ callq 2f
+1: pause
+ lfence
+ jmp 1b
+2: movq %r11, (%rsp)
+ retq
+END(__x86_indirect_thunk_r11)
+
.section .note.GNU-stack,"",%progbits
diff --git a/sys/i386/i386/support.S b/sys/i386/i386/support.S
index e5e39c9ec5d4..cb6420750f77 100644
--- a/sys/i386/i386/support.S
+++ b/sys/i386/i386/support.S
@@ -587,4 +587,14 @@ ENTRY(cpu_sync_core)
iretl
END(cpu_sync_core)
+/* External retpoline thunk */
+ENTRY(__x86_indirect_thunk_eax)
+ calll 2f
+1: pause
+ lfence
+ jmp 1b
+2: movl %eax, (%esp)
+ retl
+END(__x86_indirect_thunk_eax)
+
.section .note.GNU-stack,"",%progbits