Skip to contentSkip to conversation

arm32: simplify ARM_MMU_KEEP usage

PATCH In review Rolf Eike Beer 2 participants 4 messages Oct 7, 2024 – Mar 11, 2025 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm32: simplify ARM_MMU_KEEP usage

All current users need to add a KEEP() around the argument so the value is actually kept, which doesn't feel very natural and is prone to upcoming bugs as the name suggests that this macro alone already keeps things. Move that directly into the definition.

---
I'm unsure if ARM_MMU_DISCARD() needs the same treatment for the non-MMU case. I suspect noone has tried dead code elimination for non-MMU?

 arch/arm/include/asm/vmlinux.lds.h | 2 +-
 arch/arm/kernel/vmlinux-xip.lds.S  | 2 +-
 arch/arm/kernel/vmlinux.lds.S      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/vmlinux.lds.h +1 -1
index d60f6e83a9f7..89697f204715 100644
@@ -19,7 +19,7 @@
 #endif
 
 #ifdef CONFIG_MMU
-#define ARM_MMU_KEEP(x)		x
+#define ARM_MMU_KEEP(x)		KEEP(x)
 #define ARM_MMU_DISCARD(x)
 #else
 #define ARM_MMU_KEEP(x)
arch/arm/kernel/vmlinux-xip.lds.S +1 -1
index 5eddb75a7174..f2e8d4fac068 100644
@@ -63,7 +63,7 @@ SECTIONS
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
-		ARM_MMU_KEEP(KEEP(*(__ex_table)))
+		ARM_MMU_KEEP(*(__ex_table))
 		__stop___ex_table = .;
 	}
 
arch/arm/kernel/vmlinux.lds.S +1 -1
index de373c6c2ae8..d592a203f9c6 100644
@@ -74,7 +74,7 @@ SECTIONS
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
-		ARM_MMU_KEEP(KEEP(*(__ex_table)))
+		ARM_MMU_KEEP(*(__ex_table))
 		__stop___ex_table = .;
 	}
 
Signature · 17 lines
2.46.1


-- 
Rolf Eike Beer

emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail [email protected]
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com

emlix - your embedded Linux partner
#1 lore raw
Quoted 7 lines · On Montag, 7. Oktober 2024 15:11:40 Mitteleuropäische Normalzeit Rolf Eike…

All current users need to add a KEEP() around the argument so the value is actually kept, which doesn't feel very natural and is prone to upcoming bugs as the name suggests that this macro alone already keeps things. Move that directly into the definition.

---

Ping?

Quoted 47 lines

I'm unsure if ARM_MMU_DISCARD() needs the same treatment for the non-MMU case. I suspect noone has tried dead code elimination for non-MMU?

 arch/arm/include/asm/vmlinux.lds.h | 2 +-
 arch/arm/kernel/vmlinux-xip.lds.S  | 2 +-
 arch/arm/kernel/vmlinux.lds.S      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/include/asm/vmlinux.lds.h index d60f6e83a9f7..89697f204715 100644

arch/arm/include/asm/vmlinux.lds.h +1 -1
@@ -19,7 +19,7 @@
 #endif
 
 #ifdef CONFIG_MMU
-#define ARM_MMU_KEEP(x)		x
+#define ARM_MMU_KEEP(x)		KEEP(x)
 #define ARM_MMU_DISCARD(x)
 #else
 #define ARM_MMU_KEEP(x)
(quoted diff) +0 -0

b/arch/arm/kernel/vmlinux-xip.lds.S index 5eddb75a7174..f2e8d4fac068 100644

arch/arm/kernel/vmlinux-xip.lds.S +1 -1
@@ -63,7 +63,7 @@ SECTIONS
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
-		ARM_MMU_KEEP(KEEP(*(__ex_table)))
+		ARM_MMU_KEEP(*(__ex_table))
 		__stop___ex_table = .;
 	}
 
arch/arm/kernel/vmlinux.lds.S +1 -1
index de373c6c2ae8..d592a203f9c6 100644
@@ -74,7 +74,7 @@ SECTIONS
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
-		ARM_MMU_KEEP(KEEP(*(__ex_table)))
+		ARM_MMU_KEEP(*(__ex_table))
 		__stop___ex_table = .;
 	}
Signature · 13 lines
Rolf Eike Beer

emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail [email protected]
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com

emlix - your embedded Linux partner
Reviewed-by
#2 lore raw
Quoted 11 lines · Rolf Eike Beer
Quoted 7 lines · On Montag, 7. Oktober 2024 15:11:40 Mitteleuropäische Normalzeit Rolf Eike…

All current users need to add a KEEP() around the argument so the value is actually kept, which doesn't feel very natural and is prone to upcoming bugs as the name suggests that this macro alone already keeps things. Move that directly into the definition.

---

Ping?

Please put the patch into Russell's patch tracker so he can apply it.

Yours,
Linus Walleij

#3 lore raw
Quoted 10 lines · On Dienstag, 24. Dezember 2024 20:25:19 Mitteleuropäische Normalzeit Linus…
Quoted 9 lines · Rolf Eike Beer

On Montag, 7. Oktober 2024 15:11:40 Mitteleuropäische Normalzeit Rolf Eike

Quoted 6 lines · Beer

All current users need to add a KEEP() around the argument so the value is
actually kept, which doesn't feel very natural and is prone to upcoming bugs as the name suggests that this macro alone already keeps things. Move that directly into the definition.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

---

Ping?

Please put the patch into Russell's patch tracker so he can apply it.

Ping?

It's available in the tracker here:
https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9439/1

Signature · 17 lines
Rolf Eike Beer

We are nominated for the embedded award Visit us at the embedded 
world 2025 March 11th to 13th, 2025 | Nuremberg Find us in hall 4 at 
booth 336

emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail [email protected]
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com

emlix - your embedded Linux partner