Skip to content

Commit fe69107

Browse files
committed
Merge tag 'riscv-for-linux-6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: - Disable CFI with Rust for any platform other than x86 and ARM64 - Keep task mm_cpumasks up-to-date to avoid triggering M-mode firmware warnings if the kernel tries to send an IPI to an offline CPU - Improve kprobe address validation performance and avoid desyncs (following x86) - Avoid duplicate device probes by avoiding DT hardware probing when ACPI is enabled in early boot - Use the correct set of dependencies for CONFIG_ARCH_HAS_ELF_CORE_EFLAGS, avoiding an allnoconfig warning - Fix a few other minor issues * tag 'riscv-for-linux-6.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: kprobes: convert one final __ASSEMBLY__ to __ASSEMBLER__ riscv: Respect dependencies of ARCH_HAS_ELF_CORE_EFLAGS riscv: acpi: avoid errors caused by probing DT devices when ACPI is used riscv: kprobes: Fix probe address validation riscv: entry: fix typo in comment 'instruciton' -> 'instruction' RISC-V: clear hot-unplugged cores from all task mm_cpumasks to avoid rfence errors riscv: kgdb: Ensure that BUFMAX > NUMREGBYTES rust: cfi: only 64-bit arm and x86 support CFI_CLANG
2 parents 6f3b6e9 + 852947b commit fe69107

File tree

8 files changed

+27
-12
lines changed

8 files changed

+27
-12
lines changed

arch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
965965
def_bool y
966966
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS
967967
depends on RUSTC_VERSION >= 107900
968+
depends on ARM64 || X86_64
968969
# With GCOV/KASAN we need this fix: https://github.com/rust-lang/rust/pull/129373
969970
depends on (RUSTC_LLVM_VERSION >= 190103 && RUSTC_VERSION >= 108200) || \
970971
(!GCOV_KERNEL && !KASAN_GENERIC && !KASAN_SW_TAGS)

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ config RISCV
2929
select ARCH_HAS_DEBUG_VIRTUAL if MMU
3030
select ARCH_HAS_DEBUG_VM_PGTABLE
3131
select ARCH_HAS_DEBUG_WX
32-
select ARCH_HAS_ELF_CORE_EFLAGS
32+
select ARCH_HAS_ELF_CORE_EFLAGS if BINFMT_ELF && ELF_CORE
3333
select ARCH_HAS_FAST_MULTIPLIER
3434
select ARCH_HAS_FORTIFY_SOURCE
3535
select ARCH_HAS_GCOV_PROFILE_ALL

arch/riscv/include/asm/kgdb.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
#ifndef __ASM_KGDB_H_
44
#define __ASM_KGDB_H_
55

6+
#include <linux/build_bug.h>
7+
68
#ifdef __KERNEL__
79

810
#define GDB_SIZEOF_REG sizeof(unsigned long)
911

10-
#define DBG_MAX_REG_NUM (36)
11-
#define NUMREGBYTES ((DBG_MAX_REG_NUM) * GDB_SIZEOF_REG)
12+
#define DBG_MAX_REG_NUM 36
13+
#define NUMREGBYTES (DBG_MAX_REG_NUM * GDB_SIZEOF_REG)
1214
#define CACHE_FLUSH_IS_SAFE 1
1315
#define BUFMAX 2048
16+
static_assert(BUFMAX > NUMREGBYTES,
17+
"As per KGDB documentation, BUFMAX must be larger than NUMREGBYTES");
1418
#ifdef CONFIG_RISCV_ISA_C
1519
#define BREAK_INSTR_SIZE 2
1620
#else
@@ -97,6 +101,7 @@ extern unsigned long kgdb_compiled_break;
97101
#define DBG_REG_STATUS_OFF 33
98102
#define DBG_REG_BADADDR_OFF 34
99103
#define DBG_REG_CAUSE_OFF 35
104+
/* NOTE: increase DBG_MAX_REG_NUM if you add more values here. */
100105

101106
extern const char riscv_gdb_stub_feature[64];
102107

arch/riscv/kernel/cpu-hotplug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
5454

5555
pr_notice("CPU%u: off\n", cpu);
5656

57+
clear_tasks_mm_cpumask(cpu);
5758
/* Verify from the firmware if the cpu is really stopped*/
5859
if (cpu_ops->cpu_is_stopped)
5960
ret = cpu_ops->cpu_is_stopped(cpu);

arch/riscv/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ SYM_DATA_START_LOCAL(excp_vect_table)
455455
RISCV_PTR do_trap_ecall_s
456456
RISCV_PTR do_trap_unknown
457457
RISCV_PTR do_trap_ecall_m
458-
/* instruciton page fault */
458+
/* instruction page fault */
459459
ALT_PAGE_FAULT(RISCV_PTR do_page_fault)
460460
RISCV_PTR do_page_fault /* load page fault */
461461
RISCV_PTR do_trap_unknown

arch/riscv/kernel/probes/kprobes.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ static void __kprobes arch_simulate_insn(struct kprobe *p, struct pt_regs *regs)
4949
post_kprobe_handler(p, kcb, regs);
5050
}
5151

52-
static bool __kprobes arch_check_kprobe(struct kprobe *p)
52+
static bool __kprobes arch_check_kprobe(unsigned long addr)
5353
{
54-
unsigned long tmp = (unsigned long)p->addr - p->offset;
55-
unsigned long addr = (unsigned long)p->addr;
54+
unsigned long tmp, offset;
55+
56+
/* start iterating at the closest preceding symbol */
57+
if (!kallsyms_lookup_size_offset(addr, NULL, &offset))
58+
return false;
59+
60+
tmp = addr - offset;
5661

5762
while (tmp <= addr) {
5863
if (tmp == addr)
@@ -71,7 +76,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
7176
if ((unsigned long)insn & 0x1)
7277
return -EILSEQ;
7378

74-
if (!arch_check_kprobe(p))
79+
if (!arch_check_kprobe((unsigned long)p->addr))
7580
return -EILSEQ;
7681

7782
/* copy instruction */

arch/riscv/kernel/setup.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,14 @@ void __init setup_arch(char **cmdline_p)
331331
/* Parse the ACPI tables for possible boot-time configuration */
332332
acpi_boot_table_init();
333333

334+
if (acpi_disabled) {
334335
#if IS_ENABLED(CONFIG_BUILTIN_DTB)
335-
unflatten_and_copy_device_tree();
336+
unflatten_and_copy_device_tree();
336337
#else
337-
unflatten_device_tree();
338+
unflatten_device_tree();
338339
#endif
340+
}
341+
339342
misc_mem_init();
340343

341344
init_resources();

arch/riscv/kernel/tests/kprobes/test-kprobes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
#define KPROBE_TEST_MAGIC_LOWER 0x0000babe
1212
#define KPROBE_TEST_MAGIC_UPPER 0xcafe0000
1313

14-
#ifndef __ASSEMBLY__
14+
#ifndef __ASSEMBLER__
1515

1616
/* array of addresses to install kprobes */
1717
extern void *test_kprobes_addresses[];
1818

1919
/* array of functions that return KPROBE_TEST_MAGIC */
2020
extern long (*test_kprobes_functions[])(void);
2121

22-
#endif /* __ASSEMBLY__ */
22+
#endif /* __ASSEMBLER__ */
2323

2424
#endif /* TEST_KPROBES_H */

0 commit comments

Comments
 (0)