Skip to content

Commit 44aa25c

Browse files
bjdooks-ctPaul Walmsley
authored andcommitted
riscv: asm: use .insn for making custom instructions
The assembler has .insn for building custom instructions now, so change the .4byte to .insn. This ensures the output is marked as an instruction and not as data which may confuse both debuggers and anything else that relies on this sort of marking. Add an ASM_INSN_I() wrapper in asm.h to allow the selecting of how this is output so older assemblers are still good. Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Link: https://lore.kernel.org/r/20251024171640.65232-1-ben.dooks@codethink.co.uk Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 5fada16 commit 44aa25c

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

arch/riscv/include/asm/asm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
#define __ASM_STR(x) #x
1313
#endif
1414

15+
#ifdef CONFIG_AS_HAS_INSN
16+
#define ASM_INSN_I(__x) ".insn " __x
17+
#else
18+
#define ASM_INSN_I(__x) ".4byte " __x
19+
#endif
20+
1521
#if __riscv_xlen == 64
1622
#define __REG_SEL(a, b) __ASM_STR(a)
1723
#elif __riscv_xlen == 32

arch/riscv/include/asm/insn-def.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@
256256
INSN_S(OPCODE_OP_IMM, FUNC3(6), __RS2(3), \
257257
SIMM12((offset) & 0xfe0), RS1(base))
258258

259-
#define RISCV_PAUSE ".4byte 0x100000f"
260-
#define ZAWRS_WRS_NTO ".4byte 0x00d00073"
261-
#define ZAWRS_WRS_STO ".4byte 0x01d00073"
262-
#define RISCV_NOP4 ".4byte 0x00000013"
259+
#define RISCV_PAUSE ASM_INSN_I("0x100000f")
260+
#define ZAWRS_WRS_NTO ASM_INSN_I("0x00d00073")
261+
#define ZAWRS_WRS_STO ASM_INSN_I("0x01d00073")
262+
#define RISCV_NOP4 ASM_INSN_I("0x00000013")
263263

264264
#define RISCV_INSN_NOP4 _AC(0x00000013, U)
265265

arch/riscv/include/asm/vendor_extensions/mips.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_mips;
3030
* allowing any subsequent instructions to fetch.
3131
*/
3232

33-
#define MIPS_PAUSE ".4byte 0x00501013\n\t"
34-
#define MIPS_EHB ".4byte 0x00301013\n\t"
35-
#define MIPS_IHB ".4byte 0x00101013\n\t"
33+
#define MIPS_PAUSE ASM_INSN_I("0x00501013\n\t")
34+
#define MIPS_EHB ASM_INSN_I("0x00301013\n\t")
35+
#define MIPS_IHB ASM_INSN_I("0x00101013\n\t")
3636

3737
#endif // _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_H

0 commit comments

Comments
 (0)