Commit 225a97d6 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'riscv-for-linus-6.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Paul Walmsley:

 - A fix to disable KASAN checks while walking a non-current task's
   stackframe (following x86)

 - A fix for a kvrealloc()-related memory leak in
   module_frob_arch_sections()

 - Two replacements of strcpy() with strscpy()

 - A change to use the RISC-V .insn assembler directive when possible to
   assemble instructions from hex opcodes

 - Some low-impact fixes in the ptdump code and kprobes test code

* tag 'riscv-for-linus-6.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  cpuidle: riscv-sbi: Replace deprecated strcpy in sbi_cpuidle_init_cpu
  riscv: KGDB: Replace deprecated strcpy in kgdb_arch_handle_qxfer_pkt
  riscv: asm: use .insn for making custom instructions
  riscv: tests: Make RISCV_KPROBES_KUNIT tristate
  riscv: tests: Rename kprobes_test_riscv to kprobes_riscv
  riscv: Fix memory leak in module_frob_arch_sections()
  riscv: ptdump: use seq_puts() in pt_dump_seq_puts() macro
  riscv: stacktrace: Disable KASAN checks for non-current tasks
parents 3a157bdf 2e448567
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -12,6 +12,12 @@
#define __ASM_STR(x)	#x
#endif

#ifdef CONFIG_AS_HAS_INSN
#define ASM_INSN_I(__x) ".insn " __x
#else
#define ASM_INSN_I(__x) ".4byte " __x
#endif

#if __riscv_xlen == 64
#define __REG_SEL(a, b)	__ASM_STR(a)
#elif __riscv_xlen == 32
+4 −4
Original line number Diff line number Diff line
@@ -256,10 +256,10 @@
	INSN_S(OPCODE_OP_IMM, FUNC3(6), __RS2(3),		\
	       SIMM12((offset) & 0xfe0), RS1(base))

#define RISCV_PAUSE	".4byte 0x100000f"
#define ZAWRS_WRS_NTO	".4byte 0x00d00073"
#define ZAWRS_WRS_STO	".4byte 0x01d00073"
#define RISCV_NOP4	".4byte 0x00000013"
#define RISCV_PAUSE	ASM_INSN_I("0x100000f")
#define ZAWRS_WRS_NTO	ASM_INSN_I("0x00d00073")
#define ZAWRS_WRS_STO	ASM_INSN_I("0x01d00073")
#define RISCV_NOP4	ASM_INSN_I("0x00000013")

#define RISCV_INSN_NOP4	_AC(0x00000013, U)

+3 −3
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_mips;
 * allowing any subsequent instructions to fetch.
 */

#define MIPS_PAUSE	".4byte 0x00501013\n\t"
#define MIPS_EHB	".4byte 0x00301013\n\t"
#define MIPS_IHB	".4byte 0x00101013\n\t"
#define MIPS_PAUSE	ASM_INSN_I("0x00501013\n\t")
#define MIPS_EHB	ASM_INSN_I("0x00301013\n\t")
#define MIPS_IHB	ASM_INSN_I("0x00101013\n\t")

#endif // _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_H
+2 −2
Original line number Diff line number Diff line
@@ -265,10 +265,10 @@ void kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
{
	if (!strncmp(remcom_in_buffer, gdb_xfer_read_target,
		     sizeof(gdb_xfer_read_target)))
		strcpy(remcom_out_buffer, riscv_gdb_stub_target_desc);
		strscpy(remcom_out_buffer, riscv_gdb_stub_target_desc, BUFMAX);
	else if (!strncmp(remcom_in_buffer, gdb_xfer_read_cpuxml,
			  sizeof(gdb_xfer_read_cpuxml)))
		strcpy(remcom_out_buffer, riscv_gdb_stub_cpuxml);
		strscpy(remcom_out_buffer, riscv_gdb_stub_cpuxml, BUFMAX);
}

static inline void kgdb_arch_update_addr(struct pt_regs *regs,
+6 −2
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
	unsigned int num_plts = 0;
	unsigned int num_gots = 0;
	Elf_Rela *scratch = NULL;
	Elf_Rela *new_scratch;
	size_t scratch_size = 0;
	int i;

@@ -168,10 +169,13 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
		scratch_size_needed = (num_scratch_relas + num_relas) * sizeof(*scratch);
		if (scratch_size_needed > scratch_size) {
			scratch_size = scratch_size_needed;
			scratch = kvrealloc(scratch, scratch_size, GFP_KERNEL);
			if (!scratch)
			new_scratch = kvrealloc(scratch, scratch_size, GFP_KERNEL);
			if (!new_scratch) {
				kvfree(scratch);
				return -ENOMEM;
			}
			scratch = new_scratch;
		}

		for (size_t j = 0; j < num_relas; j++)
			if (rela_needs_plt_got_entry(&relas[j]))
Loading