hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/x86/kernel/vmlinux.lds.S
....@@ -133,7 +133,20 @@
133133 LOCK_TEXT
134134 KPROBES_TEXT
135135 ALIGN_ENTRY_TEXT_BEGIN
136
+#ifdef CONFIG_CPU_SRSO
137
+ *(.text..__x86.rethunk_untrain)
138
+#endif
139
+
136140 ENTRY_TEXT
141
+
142
+#ifdef CONFIG_CPU_SRSO
143
+ /*
144
+ * See the comment above srso_alias_untrain_ret()'s
145
+ * definition.
146
+ */
147
+ . = srso_alias_untrain_ret | (1 << 2) | (1 << 8) | (1 << 14) | (1 << 20);
148
+ *(.text..__x86.rethunk_safe)
149
+#endif
137150 ALIGN_ENTRY_TEXT_END
138151 SOFTIRQENTRY_TEXT
139152 STATIC_CALL_TEXT
....@@ -142,13 +155,15 @@
142155
143156 #ifdef CONFIG_RETPOLINE
144157 __indirect_thunk_start = .;
145
- *(.text.__x86.*)
158
+ *(.text..__x86.indirect_thunk)
159
+ *(.text..__x86.return_thunk)
146160 __indirect_thunk_end = .;
147161 #endif
148162 } :text =0xcccc
149163
150164 /* End of text section, which should occupy whole number of pages */
151165 _etext = .;
166
+
152167 . = ALIGN(PAGE_SIZE);
153168
154169 X86_ALIGN_RODATA_BEGIN
....@@ -502,6 +517,27 @@
502517 "fixed_percpu_data is not at start of per-cpu area");
503518 #endif
504519
520
+#ifdef CONFIG_RETHUNK
521
+. = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned");
522
+. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned");
523
+#endif
524
+
525
+#ifdef CONFIG_CPU_SRSO
526
+/*
527
+ * GNU ld cannot do XOR until 2.41.
528
+ * https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
529
+ *
530
+ * LLVM lld cannot do XOR until lld-17.
531
+ * https://github.com/llvm/llvm-project/commit/fae96104d4378166cbe5c875ef8ed808a356f3fb
532
+ *
533
+ * Instead do: (A | B) - (A & B) in order to compute the XOR
534
+ * of the two function addresses:
535
+ */
536
+. = ASSERT(((ABSOLUTE(srso_alias_untrain_ret) | srso_alias_safe_ret) -
537
+ (ABSOLUTE(srso_alias_untrain_ret) & srso_alias_safe_ret)) == ((1 << 2) | (1 << 8) | (1 << 14) | (1 << 20)),
538
+ "SRSO function pair won't alias");
539
+#endif
540
+
505541 #endif /* CONFIG_X86_32 */
506542
507543 #ifdef CONFIG_KEXEC_CORE