Skip to contentSkip to conversation

s390: Guard emitting assembler macros for insn-common-asm.h

PATCH Applied Steffen Eiden 4 participants 4 messages Nov 5 – Nov 9 s390

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s390: Guard emitting assembler macros for insn-common-asm.h

The CPP include guard of insn-common-asm.h is ineffective when the file is read via a gas-level .include from inline asm. The assembler ignores all '#' lines, so every .include redefines GR_NUM/VX_NUM and fails with "Macro was already defined" if a translation unit emits more than one such include. This is not the case right now but may lead to future build issues.

Add a header 'asm/insn-common-asm-emit.h' that can be used by C/H files which want to emit those macros. The header guards the GAS include to prevent multiple includes in one compilation unit.

---
Changes in v2:
- Use a separate -emit header and CPP Guards to guard the asm .include. (Andreas)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 arch/s390/include/asm/fpu-insn.h             | 2 +-
 arch/s390/include/asm/insn-common-asm-emit.h | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
arch/s390/include/asm/fpu-insn.h +1 -1
index eeb0a233d5c7..aaf1faeb3dc5 100644
@@ -14,8 +14,8 @@
 #include <linux/instrumented.h>
 #include <linux/kmsan.h>
 #include <asm/asm-extable.h>
+#include <asm/insn-common-asm-emit.h>
 
-asm(".include \"asm/insn-common-asm.h\"\n");
 asm(".include \"asm/fpu-insn-asm.h\"\n");
 
 /*
arch/s390/include/asm/insn-common-asm-emit.h new file +8 -0
new file mode 100644
index 000000000000..26a31e8439bf
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_S390_INSN_COMMON_ASM_EMIT_H
+#define __ASM_S390_INSN_COMMON_ASM_EMIT_H
+
+asm(".include \"asm/insn-common-asm.h\"\n");
+
+#endif /* __ASM_S390_INSN_COMMON_ASM_EMIT_H */
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

The CPP include guard of insn-common-asm.h is ineffective when the file is read via a gas-level .include from inline asm. The assembler ignores all '#' lines, so every .include redefines GR_NUM/VX_NUM and fails with "Macro was already defined" if a translation unit emits more than one such include. This is not the case right now but may lead to future build issues.

Quoted 7 lines

Add a header 'asm/insn-common-asm-emit.h' that can be used by C/H files which want to emit those macros. The header guards the GAS include to prevent multiple includes in one compilation unit.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Steffen Eiden
Quoted 44 lines · Steffen Eiden

The CPP include guard of insn-common-asm.h is ineffective when the file is read via a gas-level .include from inline asm. The assembler ignores all '#' lines, so every .include redefines GR_NUM/VX_NUM and fails with "Macro was already defined" if a translation unit emits more than one such include. This is not the case right now but may lead to future build issues.

Add a header 'asm/insn-common-asm-emit.h' that can be used by C/H files which want to emit those macros. The header guards the GAS include to prevent multiple includes in one compilation unit.

---
Changes in v2:
- Use a separate -emit header and CPP Guards to guard the asm .include. (Andreas)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 arch/s390/include/asm/fpu-insn.h             | 2 +-
 arch/s390/include/asm/insn-common-asm-emit.h | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
arch/s390/include/asm/fpu-insn.h +1 -1
index eeb0a233d5c7..aaf1faeb3dc5 100644
@@ -14,8 +14,8 @@
 #include <linux/instrumented.h>
 #include <linux/kmsan.h>
 #include <asm/asm-extable.h>
+#include <asm/insn-common-asm-emit.h>
 
-asm(".include \"asm/insn-common-asm.h\"\n");
 asm(".include \"asm/fpu-insn-asm.h\"\n");
 
 /*
arch/s390/include/asm/insn-common-asm-emit.h new file +0 -0
new file mode 100644
index 000000000000..26a31e8439bf

arch/s390/include/asm/insn-common-asm-emit.h line 8

Quoted 8 lines
arch/s390/include/asm/insn-common-asm-emit.h new file +8 -0
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_S390_INSN_COMMON_ASM_EMIT_H
+#define __ASM_S390_INSN_COMMON_ASM_EMIT_H
+
+asm(".include \"asm/insn-common-asm.h\"\n");
+
+#endif /* __ASM_S390_INSN_COMMON_ASM_EMIT_H */
reviewer Applied
#3 lore raw
In reply to Steffen Eiden

Am 05.11.26 um 14:46 schrieb Steffen Eiden:

Quoted 11 lines

The CPP include guard of insn-common-asm.h is ineffective when the file is read via a gas-level .include from inline asm. The assembler ignores all '#' lines, so every .include redefines GR_NUM/VX_NUM and fails with "Macro was already defined" if a translation unit emits more than one such include. This is not the case right now but may lead to future build issues.

Add a header 'asm/insn-common-asm-emit.h' that can be used by C/H files which want to emit those macros. The header guards the GAS include to prevent multiple includes in one compilation unit.

Quoted 8 lines

---
Changes in v2:
- Use a separate -emit header and CPP Guards to guard the asm .include. (Andreas)
- Link to v1: https://lore.kernel.org/r/[email protected]

Thanks applied.

As we need this for the 2nd series of the arm on s390 support I will take it via the kvms390 tree and queue it for kvms390/next as the first patch on top of 7.4-rc2. So if we ever have a (unlikely) complex conflict we can create a topic branch pointing to that commit at any time.

Quoted 33 lines
---
  arch/s390/include/asm/fpu-insn.h             | 2 +-
  arch/s390/include/asm/insn-common-asm-emit.h | 8 ++++++++
  2 files changed, 9 insertions(+), 1 deletion(-)
arch/s390/include/asm/fpu-insn.h +1 -1
index eeb0a233d5c7..aaf1faeb3dc5 100644
@@ -14,8 +14,8 @@
  #include <linux/instrumented.h>
  #include <linux/kmsan.h>
  #include <asm/asm-extable.h>
+#include <asm/insn-common-asm-emit.h>
 
-asm(".include \"asm/insn-common-asm.h\"\n");
  asm(".include \"asm/fpu-insn-asm.h\"\n");
 
  /*
arch/s390/include/asm/insn-common-asm-emit.h new file +8 -0
new file mode 100644
index 000000000000..26a31e8439bf
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_S390_INSN_COMMON_ASM_EMIT_H
+#define __ASM_S390_INSN_COMMON_ASM_EMIT_H
+
+asm(".include \"asm/insn-common-asm.h\"\n");
+
+#endif /* __ASM_S390_INSN_COMMON_ASM_EMIT_H */