Skip to contentSkip to conversation

x86/alternative: delay freeing of smp_locks section

PATCH Superseded Mike Rapoport 4 participants 13 messages Mar 28 – Jun 29

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/alternative: delay freeing of smp_locks section

From: "Mike Rapoport (Microsoft)" <[email protected]>

On UP systems alternative_instructions() frees memory occupied by smp_locks section immediately after patching the lock instructions.

With CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled this happens before the memory map is fully initialized and the struct pages representing the freed memory might get overwritten by deferred initialization of the memory map.

Move freeing of smp_locks section to an initcall to ensure it will happen after the memory map is fully initialized.

---
 arch/x86/kernel/alternative.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
arch/x86/kernel/alternative.c +17 -5
index e87da25d1236..62936a3bde19 100644
@@ -2448,19 +2448,31 @@ void __init alternative_instructions(void)
 					    __smp_locks, __smp_locks_end,
 					    _text, _etext);
 	}
+#endif
 
+	restart_nmi();
+	alternatives_patched = 1;
+
+	alt_reloc_selftest();
+}
+
+#ifdef CONFIG_SMP
+/*
+ * With CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled we can free_init_pages() only
+ * after the deferred initialization of the memory map is complete.
+ */
+static int __init free_smp_locks(void)
+{
 	if (!uniproc_patched || num_possible_cpus() == 1) {
 		free_init_pages("SMP alternatives",
 				(unsigned long)__smp_locks,
 				(unsigned long)__smp_locks_end);
 	}
-#endif
 
-	restart_nmi();
-	alternatives_patched = 1;
-
-	alt_reloc_selftest();
+	return 0;
 }
+arch_initcall(free_smp_locks);
+#endif
 
 /**
  * text_poke_early - Update instructions on a live kernel at boot time

base-commit: e77a5a5cfe43b4c25bd44a3818e487033287517f

Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 3 lines · Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

On UP systems alternative_instructions() frees memory occupied by smp_locks

UP systems?

I don't understand - Bert's machine is a SMP.

Quoted 11 lines

section immediately after patching the lock instructions.

With CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled this happens before the memory map is fully initialized and the struct pages representing the freed memory might get overwritten by deferred initialization of the memory map.

Move freeing of smp_locks section to an initcall to ensure it will happen after the memory map is fully initialized.

I don't understand even more: why have we not hit this before?

No Fixes: tag?

Something must've changed for this to fire...

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#2 lore raw
Quoted 8 lines · Borislav Petkov
Quoted 3 lines · Mike Rapoport

From: "Mike Rapoport (Microsoft)" <[email protected]>

On UP systems alternative_instructions() frees memory occupied by smp_locks

UP systems?

I don't understand - Bert's machine is a SMP.

Argh, I misread the 'if (!uniproc_patched' :(

Quoted 6 lines
Quoted 6 lines

section immediately after patching the lock instructions.

With CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled this happens before the memory map is fully initialized and the struct pages representing the freed memory might get overwritten by deferred initialization of the memory map.

Quoted 7 lines
Quoted 5 lines

Move freeing of smp_locks section to an initcall to ensure it will happen after the memory map is fully initialized.

I don't understand even more: why have we not hit this before?

That memory was never actually freed, it remained reserved because free_init_pages() calls free_reserved_area() but does not update memblock.

Quoted 1 line

No Fixes: tag?

It's as old as CONFIG_DEFERRED_STRUCT_PAGE_INIT (v4.2) or even before that. If you think that fixing this leak is important enough to backport, it affects all mainlined stable releases.

Quoted 1 line

Something must've changed for this to fire...

Yes, I added a WARN() in free_reserved_area() to lure such cases and prevent them in the future.

I'll wait a bit for more comments before rewriting changelog and reposting.

Quoted 3 lines
Signature · 2 lines
Regards/Gruss,
    Boris.
Signature · 2 lines
Sincerely yours,
Mike.
maintainer Tested-by Bert Karwatzki
#3 lore raw
Quoted 3 lines · Mike Rapoport

It's as old as CONFIG_DEFERRED_STRUCT_PAGE_INIT (v4.2) or even before that. If you think that fixing this leak is important enough to backport, it affects all mainlined stable releases.

Probably not all but perhaps the last two - 6.12 and 6.18...

Quoted 2 lines

Yes, I added a WARN() in free_reserved_area() to lure such cases and prevent them in the future.

This warn is supposed to catch the leaks. I guess it is important enough to add the warning so it is just as important to fix them leaks, right :-)

As to the fix itself, arch_initcall() is the magic time where deferred initialization is complete, I presume?

Quoted 1 line

I'll wait a bit for more comments before rewriting changelog and reposting.

Yes please. You could also expand on why the arch initcall is the proper fix. I guess deferred init completes with an earlier initcall. So yeah, it would be good to have that written down explicitly too.

On and pls use those tags:

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#4 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Mike Rapoport

It's as old as CONFIG_DEFERRED_STRUCT_PAGE_INIT (v4.2) or even before that. If you think that fixing this leak is important enough to backport, it affects all mainlined stable releases.

Quoted 7 lines

Probably not all but perhaps the last two - 6.12 and 6.18...

Quoted 2 lines

Yes, I added a WARN() in free_reserved_area() to lure such cases and prevent them in the future.

This warn is supposed to catch the leaks. I guess it is important enough to add the warning so it is just as important to fix them leaks, right :-)

After sleeping on it, I realised there was no leak, and this is only an integration issue of recent memblock changes, so there's no need for cc @stable.

Since this fixes a fallout from memblock changes, I can take it together with them via memblock tree with Ack from x86 folks if you prefer.

Quoted 22 lines

As to the fix itself, arch_initcall() is the magic time where deferred initialization is complete, I presume?

Quoted 1 line

I'll wait a bit for more comments before rewriting changelog and reposting.

Yes please. You could also expand on why the arch initcall is the proper fix. I guess deferred init completes with an earlier initcall. So yeah, it would be good to have that written down explicitly too.

On and pls use those tags:

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Signature · 2 lines
Sincerely yours,
Mike.
maintainer
#5 lore raw
Quoted 2 lines · Mike Rapoport

Since this fixes a fallout from memblock changes, I can take it together with them via memblock tree with Ack from x86 folks if you prefer.

Sure, once you send me a patch with a proper explanation which I can ack... :)

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#6 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Mike Rapoport

Since this fixes a fallout from memblock changes, I can take it together with them via memblock tree with Ack from x86 folks if you prefer.

Sure, once you send me a patch with a proper explanation which I can ack... :)

Another silly question; why not delete the whole SMP locks thing? I mean, who cares about UP these days?

#7 lore raw
Quoted 9 lines · Peter Zijlstra
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Mike Rapoport

Since this fixes a fallout from memblock changes, I can take it together with them via memblock tree with Ack from x86 folks if you prefer.

Sure, once you send me a patch with a proper explanation which I can ack... :)

Another silly question; why not delete the whole SMP locks thing? I mean, who cares about UP these days?

Specifically, who cares about *running SMP kernels on UP?*

Compiling for UP explicitly is an entirely different matter.

maintainer
#8 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines

Another silly question; why not delete the whole SMP locks thing? I mean, who cares about UP these days?

Specifically, who cares about *running SMP kernels on UP?*

Compiling for UP explicitly is an entirely different matter.

Yah, let's zap them.

That close to the merge window maybe not but something for 7.2 perhaps...

So patches are welcome.

:-)

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#9 lore raw

PATCH 1/1 x86/alternative: Drop smp_locks glue

From: "Borislav Petkov (AMD)" <[email protected]>
Date: Sat, 13 Jun 2026 10:15:27 -0700

This was there to be able to patch out locking instructions when running a SMP kernel build on a UP CPU. The times are long gone when single-CPU x86 machines were relevant so drop that machinery and simplify the code considerably.

LOCK_PREFIX needs to stay for when one wants to do a UP build for whatever reason. That'll go away when CONFIG_SMP becomes unconditional.

Kill a bunch of leftover, unused prototypes while at it.

---
 arch/um/kernel/um_arch.c           |  12 --
 arch/x86/include/asm/alternative.h |  47 +------
 arch/x86/include/asm/cmpxchg_32.h  |   4 +-
 arch/x86/kernel/alternative.c      | 190 -----------------------------
 arch/x86/kernel/kprobes/core.c     |   3 -
 arch/x86/kernel/kprobes/opt.c      |   1 -
 arch/x86/kernel/module.c           |  13 +-
 arch/x86/kernel/smpboot.c          |   3 -
 arch/x86/kernel/vmlinux.lds.S      |  12 --
 arch/x86/tools/relocs.c            |   2 +-
 tools/objtool/check.c              |   1 -
 tools/objtool/klp-diff.c           |   1 -
 12 files changed, 9 insertions(+), 280 deletions(-)
arch/um/kernel/um_arch.c +0 -12
index 2141f5f1f5a2..e4ee693961e4 100644
@@ -451,18 +451,6 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
 {
 }
 
-#if IS_ENABLED(CONFIG_SMP)
-void alternatives_smp_module_add(struct module *mod, char *name,
-				 void *locks, void *locks_end,
-				 void *text,  void *text_end)
-{
-}
-
-void alternatives_smp_module_del(struct module *mod)
-{
-}
-#endif
-
 void *text_poke(void *addr, const void *opcode, size_t len)
 {
 	/*
arch/x86/include/asm/alternative.h +5 -42

73 lines not on this page · raw message

arch/x86/include/asm/cmpxchg_32.h +2 -2
index 1f80a62be969..e85c221ed1c9 100644
@@ -104,7 +104,7 @@ static __always_inline bool __try_cmpxchg64_local(volatile u64 *ptr, u64 *oldp,
 
 static __always_inline u64 arch_cmpxchg64(volatile u64 *ptr, u64 old, u64 new)
 {
-	return __arch_cmpxchg64_emu(ptr, old, new, LOCK_PREFIX_HERE, "lock ");
+	return __arch_cmpxchg64_emu(ptr, old, new, , "lock ");
 }
 #define arch_cmpxchg64 arch_cmpxchg64
 
@@ -138,7 +138,7 @@ static __always_inline u64 arch_cmpxchg64_local(volatile u64 *ptr, u64 old, u64
 
 static __always_inline bool arch_try_cmpxchg64(volatile u64 *ptr, u64 *oldp, u64 new)
 {
-	return __arch_try_cmpxchg64_emu(ptr, oldp, new, LOCK_PREFIX_HERE, "lock ");
+	return __arch_try_cmpxchg64_emu(ptr, oldp, new, , "lock ");
 }
 #define arch_try_cmpxchg64 arch_try_cmpxchg64
 
arch/x86/kernel/alternative.c +0 -190

214 lines not on this page · raw message

arch/x86/kernel/kprobes/core.c +0 -3
index c1fac3a9fecc..4e5f8c1736ec 100644
@@ -762,9 +762,6 @@ int arch_prepare_kprobe(struct kprobe *p)
 {
 	int ret;
 
-	if (alternatives_text_reserved(p->addr, p->addr))
-		return -EINVAL;
-
 	if (!can_probe((unsigned long)p->addr))
 		return -EILSEQ;
 
arch/x86/kernel/kprobes/opt.c +0 -1
index 6f826a00eca2..6e5f1b8a158c 100644
@@ -213,7 +213,6 @@ static int copy_optimized_instructions(u8 *dest, u8 *src, u8 *real)
 	}
 	/* Check whether the address range is reserved */
 	if (ftrace_text_reserved(src, src + len - 1) ||
-	    alternatives_text_reserved(src, src + len - 1) ||
 	    jump_label_text_reserved(src, src + len - 1) ||
 	    static_call_text_reserved(src, src + len - 1))
 		return -EBUSY;
arch/x86/kernel/module.c +1 -12
index 11c45ce42694..9a4b766eaf4c 100644
@@ -242,7 +242,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
 		    struct module *me)
 {
-	const Elf_Shdr *s, *alt = NULL, *locks = NULL,
+	const Elf_Shdr *s, *alt = NULL,
 		*orc = NULL, *orc_ip = NULL,
 		*retpolines = NULL, *returns = NULL, *ibt_endbr = NULL,
 		*calls = NULL, *cfi = NULL;
@@ -251,8 +251,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 	for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
 		if (!strcmp(".altinstructions", secstrings + s->sh_name))
 			alt = s;
-		if (!strcmp(".smp_locks", secstrings + s->sh_name))
-			locks = s;
 		if (!strcmp(".orc_unwind", secstrings + s->sh_name))
 			orc = s;
 		if (!strcmp(".orc_unwind_ip", secstrings + s->sh_name))
@@ -315,14 +313,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 		void *iseg = (void *)ibt_endbr->sh_addr;
 		apply_seal_endbr(iseg, iseg + ibt_endbr->sh_size);
 	}
-	if (locks) {
-		void *lseg = (void *)locks->sh_addr;
-		void *text = me->mem[MOD_TEXT].base;
-		void *text_end = text + me->mem[MOD_TEXT].size;
-		alternatives_smp_module_add(me, me->name,
-					    lseg, lseg + locks->sh_size,
-					    text, text_end);
-	}
 
 	if (orc && orc_ip)
 		unwind_module_init(me, (void *)orc_ip->sh_addr, orc_ip->sh_size,
@@ -333,6 +323,5 @@ int module_finalize(const Elf_Ehdr *hdr,
 
 void module_arch_cleanup(struct module *mod)
 {
-	alternatives_smp_module_del(mod);
 	its_free_mod(mod);
 }
arch/x86/kernel/smpboot.c +0 -3
index cb999feb66b0..ba01a9e919b7 100644
@@ -991,9 +991,6 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
 {
 	int ret;
 
-	/* Just in case we booted with a single CPU. */
-	alternatives_enable_smp();
-
 	per_cpu(current_task, cpu) = idle;
 	cpu_init_stack_canary(cpu, idle);
 
arch/x86/kernel/vmlinux.lds.S +0 -12
index 4711a35e706c..273e7845b411 100644
@@ -346,18 +346,6 @@ SECTIONS
 		__init_end = .;
 	}
 
-	/*
-	 * smp_locks might be freed after init
-	 * start/end must be page aligned
-	 */
-	. = ALIGN(PAGE_SIZE);
-	.smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
-		__smp_locks = .;
-		*(.smp_locks)
-		. = ALIGN(PAGE_SIZE);
-		__smp_locks_end = .;
-	}
-
 #ifdef CONFIG_X86_64
 	.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
 		NOSAVE_DATA
arch/x86/tools/relocs.c +1 -1
index e5a2b9a912d1..5ea9bc7eeb14 100644
@@ -73,7 +73,7 @@ static const char * const	sym_regex_kernel[S_NSYMTYPES] = {
 	"^(__init_(begin|end)|"
 	"__x86_cpu_dev_(start|end)|"
 	"__alt_instructions(_end)?|"
-	"(__iommu_table|__apicdrivers|__smp_locks)(_end)?|"
+	"(__iommu_table|__apicdrivers)(_end)?|"
 	"__(start|end)_pci_.*|"
 #if CONFIG_FW_LOADER
 	"__(start|end)_builtin_fw|"
tools/objtool/check.c +0 -1
index 10b18cf9c360..5f714e8b383a 100644
@@ -4644,7 +4644,6 @@ static int validate_ibt(struct objtool_file *file)
 		    !strcmp(sec->name, ".kcfi_traps")			||
 		    !strcmp(sec->name, ".orc_unwind_ip")		||
 		    !strcmp(sec->name, ".retpoline_sites")		||
-		    !strcmp(sec->name, ".smp_locks")			||
 		    !strcmp(sec->name, ".static_call_sites")		||
 		    !strcmp(sec->name, "_error_injection_whitelist")	||
 		    !strcmp(sec->name, "_kprobe_blacklist")		||
tools/objtool/klp-diff.c +0 -1
index f8787d7d1454..07b7ef34cc92 100644
@@ -297,7 +297,6 @@ static bool is_special_section(struct section *sec)
 	static const char * const specials[] = {
 		".altinstructions",
 		".kcfi_traps",
-		".smp_locks",
 		"__bug_table",
 		"__ex_table",
 		"__jump_table",
Signature · 8 lines
2.53.0


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer Acked-by on v1 1/1
#10 lore raw

Re: [PATCH] x86/alternative: Drop smp_locks glue

Quoted 8 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>
Date: Sat, 13 Jun 2026 10:15:27 -0700

This was there to be able to patch out locking instructions when running a SMP kernel build on a UP CPU. The times are long gone when single-CPU x86 machines were relevant so drop that machinery and simplify the code considerably.

Quoted 6 lines

LOCK_PREFIX needs to stay for when one wants to do a UP build for whatever reason. That'll go away when CONFIG_SMP becomes unconditional.

Kill a bunch of leftover, unused prototypes while at it.

Good riddance

author Acked-by on v1 1/1
#11 lore raw

Re: [PATCH] x86/alternative: Drop smp_locks glue

In reply to Borislav Petkov
Quoted 8 lines · Borislav Petkov

From: "Borislav Petkov (AMD)" <[email protected]>
Date: Sat, 13 Jun 2026 10:15:27 -0700

This was there to be able to patch out locking instructions when running a SMP kernel build on a UP CPU. The times are long gone when single-CPU x86 machines were relevant so drop that machinery and simplify the code considerably.

Quoted 6 lines

LOCK_PREFIX needs to stay for when one wants to do a UP build for whatever reason. That'll go away when CONFIG_SMP becomes unconditional.

Kill a bunch of leftover, unused prototypes while at it.

FWIW:

Quoted 14 lines
---
 arch/um/kernel/um_arch.c           |  12 --
 arch/x86/include/asm/alternative.h |  47 +------
 arch/x86/include/asm/cmpxchg_32.h  |   4 +-
 arch/x86/kernel/alternative.c      | 190 -----------------------------
 arch/x86/kernel/kprobes/core.c     |   3 -
 arch/x86/kernel/kprobes/opt.c      |   1 -
 arch/x86/kernel/module.c           |  13 +-
 arch/x86/kernel/smpboot.c          |   3 -
 arch/x86/kernel/vmlinux.lds.S      |  12 --
 arch/x86/tools/relocs.c            |   2 +-
 tools/objtool/check.c              |   1 -
 tools/objtool/klp-diff.c           |   1 -
 12 files changed, 9 insertions(+), 280 deletions(-)
Signature · 2 lines
Sincerely yours,
Mike.
maintainer
#12 lore raw

PATCH 1/1 x86/alternative: Drop smp_locks glue

Hi,

here's v1.1 with a couple of minor things Sashiko reported here:

https://sashiko.dev/#/message/20260613185632.GAai2n4GkGXFsBm6gT%40fat_crate.local

which I forgot to clean up as part of the removal.

I've kept the Acked-by:'s because nothing really changes to the intent and the code is the same - changes are mostly comments removal and X86_FEATURE_UP which is not needed anymore and is freeing one slot in the synthetic map.

Thx.

---
From: "Borislav Petkov (AMD)" <[email protected]>
Date: Sat, 13 Jun 2026 10:15:27 -0700
Subject: [PATCH] x86/alternative: Drop smp_locks glue

This was there to be able to patch out locking instructions when running a SMP kernel build on a UP CPU. The times are long gone when single-CPU x86 machines were relevant so drop that machinery and simplify the code considerably.

LOCK_PREFIX needs to stay for when one wants to do a UP build for whatever reason. That'll go away when CONFIG_SMP becomes unconditional.

Kill a bunch of leftover, unused prototypes while at it.

---
 .../admin-guide/kernel-parameters.txt         |   3 -
 arch/um/kernel/um_arch.c                      |  12 --
 arch/x86/include/asm/alternative.h            |  68 +------
 arch/x86/include/asm/cmpxchg_32.h             |   4 +-
 arch/x86/include/asm/cpufeatures.h            |   2 +-
 arch/x86/kernel/alternative.c                 | 190 ------------------
 arch/x86/kernel/kprobes/core.c                |   3 -
 arch/x86/kernel/kprobes/opt.c                 |   1 -
 arch/x86/kernel/module.c                      |  13 +-
 arch/x86/kernel/smpboot.c                     |   3 -
 arch/x86/kernel/vmlinux.lds.S                 |  12 --
 arch/x86/tools/relocs.c                       |   2 +-
 tools/arch/x86/include/asm/cpufeatures.h      |   2 +-
 tools/objtool/check.c                         |   1 -
 tools/objtool/klp-diff.c                      |   1 -
 15 files changed, 11 insertions(+), 306 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -3
index b5493a7f8f22..9f454abab159 100644
@@ -4587,9 +4587,6 @@ Kernel parameters
 	norandmaps	Don't use address space randomization.  Equivalent to
 			echo 0 > /proc/sys/kernel/randomize_va_space
 
-	noreplace-smp	[X86-32,SMP] Don't replace SMP instructions
-			with UP alternatives
-
 	noresume	[SWSUSP] Disables resume and restores original swap
 			space.
 
arch/um/kernel/um_arch.c +0 -12
index 2141f5f1f5a2..e4ee693961e4 100644
@@ -451,18 +451,6 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
 {
 }
 
-#if IS_ENABLED(CONFIG_SMP)
-void alternatives_smp_module_add(struct module *mod, char *name,
-				 void *locks, void *locks_end,
-				 void *text,  void *text_end)
-{
-}
-
-void alternatives_smp_module_del(struct module *mod)
-{
-}
-#endif
-
 void *text_poke(void *addr, const void *opcode, size_t len)
 {
 	/*
arch/x86/include/asm/alternative.h +5 -63

95 lines not on this page · raw message

arch/x86/include/asm/cmpxchg_32.h +2 -2
index 1f80a62be969..e85c221ed1c9 100644
@@ -104,7 +104,7 @@ static __always_inline bool __try_cmpxchg64_local(volatile u64 *ptr, u64 *oldp,
 
 static __always_inline u64 arch_cmpxchg64(volatile u64 *ptr, u64 old, u64 new)
 {
-	return __arch_cmpxchg64_emu(ptr, old, new, LOCK_PREFIX_HERE, "lock ");
+	return __arch_cmpxchg64_emu(ptr, old, new, , "lock ");
 }
 #define arch_cmpxchg64 arch_cmpxchg64
 
@@ -138,7 +138,7 @@ static __always_inline u64 arch_cmpxchg64_local(volatile u64 *ptr, u64 old, u64
 
 static __always_inline bool arch_try_cmpxchg64(volatile u64 *ptr, u64 *oldp, u64 new)
 {
-	return __arch_try_cmpxchg64_emu(ptr, oldp, new, LOCK_PREFIX_HERE, "lock ");
+	return __arch_try_cmpxchg64_emu(ptr, oldp, new, , "lock ");
 }
 #define arch_try_cmpxchg64 arch_try_cmpxchg64
 
arch/x86/include/asm/cpufeatures.h +1 -1
index 1b4a48bff18f..3d0940a3b9f3 100644
@@ -78,7 +78,7 @@
 #define X86_FEATURE_ZEN6		( 3*32+ 6) /* CPU based on Zen6 microarchitecture */
 /* Free                                 ( 3*32+ 7) */
 #define X86_FEATURE_CONSTANT_TSC	( 3*32+ 8) /* "constant_tsc" TSC ticks at a constant rate */
-#define X86_FEATURE_UP			( 3*32+ 9) /* "up" SMP kernel running on UP */
+/* free: was #define X86_FEATURE_UP	( 3*32+ 9) * "up" SMP kernel running on UP */
 #define X86_FEATURE_ART			( 3*32+10) /* "art" Always running timer (ART) */
 #define X86_FEATURE_ARCH_PERFMON	( 3*32+11) /* "arch_perfmon" Intel Architectural PerfMon */
 #define X86_FEATURE_PEBS		( 3*32+12) /* "pebs" Precise-Event Based Sampling */
arch/x86/kernel/alternative.c +0 -190

214 lines not on this page · raw message

arch/x86/kernel/kprobes/core.c +0 -3
index c1fac3a9fecc..4e5f8c1736ec 100644
@@ -762,9 +762,6 @@ int arch_prepare_kprobe(struct kprobe *p)
 {
 	int ret;
 
-	if (alternatives_text_reserved(p->addr, p->addr))
-		return -EINVAL;
-
 	if (!can_probe((unsigned long)p->addr))
 		return -EILSEQ;
 
arch/x86/kernel/kprobes/opt.c +0 -1
index 6f826a00eca2..6e5f1b8a158c 100644
@@ -213,7 +213,6 @@ static int copy_optimized_instructions(u8 *dest, u8 *src, u8 *real)
 	}
 	/* Check whether the address range is reserved */
 	if (ftrace_text_reserved(src, src + len - 1) ||
-	    alternatives_text_reserved(src, src + len - 1) ||
 	    jump_label_text_reserved(src, src + len - 1) ||
 	    static_call_text_reserved(src, src + len - 1))
 		return -EBUSY;
arch/x86/kernel/module.c +1 -12
index b5b4de4f08e6..33080ad889b7 100644
@@ -227,7 +227,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
 		    struct module *me)
 {
-	const Elf_Shdr *s, *alt = NULL, *locks = NULL,
+	const Elf_Shdr *s, *alt = NULL,
 		*orc = NULL, *orc_ip = NULL,
 		*retpolines = NULL, *returns = NULL, *ibt_endbr = NULL,
 		*calls = NULL, *cfi = NULL;
@@ -236,8 +236,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 	for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
 		if (!strcmp(".altinstructions", secstrings + s->sh_name))
 			alt = s;
-		if (!strcmp(".smp_locks", secstrings + s->sh_name))
-			locks = s;
 		if (!strcmp(".orc_unwind", secstrings + s->sh_name))
 			orc = s;
 		if (!strcmp(".orc_unwind_ip", secstrings + s->sh_name))
@@ -300,14 +298,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 		void *iseg = (void *)ibt_endbr->sh_addr;
 		apply_seal_endbr(iseg, iseg + ibt_endbr->sh_size);
 	}
-	if (locks) {
-		void *lseg = (void *)locks->sh_addr;
-		void *text = me->mem[MOD_TEXT].base;
-		void *text_end = text + me->mem[MOD_TEXT].size;
-		alternatives_smp_module_add(me, me->name,
-					    lseg, lseg + locks->sh_size,
-					    text, text_end);
-	}
 
 	if (orc && orc_ip)
 		unwind_module_init(me, (void *)orc_ip->sh_addr, orc_ip->sh_size,
@@ -318,6 +308,5 @@ int module_finalize(const Elf_Ehdr *hdr,
 
 void module_arch_cleanup(struct module *mod)
 {
-	alternatives_smp_module_del(mod);
 	its_free_mod(mod);
 }
arch/x86/kernel/smpboot.c +0 -3
index cb999feb66b0..ba01a9e919b7 100644
@@ -991,9 +991,6 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
 {
 	int ret;
 
-	/* Just in case we booted with a single CPU. */
-	alternatives_enable_smp();
-
 	per_cpu(current_task, cpu) = idle;
 	cpu_init_stack_canary(cpu, idle);
 
arch/x86/kernel/vmlinux.lds.S +0 -12
index 74e336d7f9dd..fb310995f94b 100644
@@ -346,18 +346,6 @@ SECTIONS
 		__init_end = .;
 	}
 
-	/*
-	 * smp_locks might be freed after init
-	 * start/end must be page aligned
-	 */
-	. = ALIGN(PAGE_SIZE);
-	.smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
-		__smp_locks = .;
-		*(.smp_locks)
-		. = ALIGN(PAGE_SIZE);
-		__smp_locks_end = .;
-	}
-
 #ifdef CONFIG_X86_64
 	.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
 		NOSAVE_DATA
arch/x86/tools/relocs.c +1 -1
index e5a2b9a912d1..5ea9bc7eeb14 100644
@@ -73,7 +73,7 @@ static const char * const	sym_regex_kernel[S_NSYMTYPES] = {
 	"^(__init_(begin|end)|"
 	"__x86_cpu_dev_(start|end)|"
 	"__alt_instructions(_end)?|"
-	"(__iommu_table|__apicdrivers|__smp_locks)(_end)?|"
+	"(__iommu_table|__apicdrivers)(_end)?|"
 	"__(start|end)_pci_.*|"
 #if CONFIG_FW_LOADER
 	"__(start|end)_builtin_fw|"
tools/arch/x86/include/asm/cpufeatures.h +1 -1
index 86d17b195e79..8860778305ca 100644
@@ -78,7 +78,7 @@
 #define X86_FEATURE_ZEN6		( 3*32+ 6) /* CPU based on Zen6 microarchitecture */
 /* Free                                 ( 3*32+ 7) */
 #define X86_FEATURE_CONSTANT_TSC	( 3*32+ 8) /* "constant_tsc" TSC ticks at a constant rate */
-#define X86_FEATURE_UP			( 3*32+ 9) /* "up" SMP kernel running on UP */
+/* free: was #define X86_FEATURE_UP	( 3*32+ 9) * "up" SMP kernel running on UP */
 #define X86_FEATURE_ART			( 3*32+10) /* "art" Always running timer (ART) */
 #define X86_FEATURE_ARCH_PERFMON	( 3*32+11) /* "arch_perfmon" Intel Architectural PerfMon */
 #define X86_FEATURE_PEBS		( 3*32+12) /* "pebs" Precise-Event Based Sampling */
tools/objtool/check.c +0 -1
index 10b18cf9c360..5f714e8b383a 100644
@@ -4644,7 +4644,6 @@ static int validate_ibt(struct objtool_file *file)
 		    !strcmp(sec->name, ".kcfi_traps")			||
 		    !strcmp(sec->name, ".orc_unwind_ip")		||
 		    !strcmp(sec->name, ".retpoline_sites")		||
-		    !strcmp(sec->name, ".smp_locks")			||
 		    !strcmp(sec->name, ".static_call_sites")		||
 		    !strcmp(sec->name, "_error_injection_whitelist")	||
 		    !strcmp(sec->name, "_kprobe_blacklist")		||
tools/objtool/klp-diff.c +0 -1
index f8787d7d1454..07b7ef34cc92 100644
@@ -297,7 +297,6 @@ static bool is_special_section(struct section *sec)
 	static const char * const specials[] = {
 		".altinstructions",
 		".kcfi_traps",
-		".smp_locks",
 		"__bug_table",
 		"__ex_table",
 		"__jump_table",
Signature · 8 lines
2.53.0


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette