RISC-V updates for v6.18-rc2

Some RISC-V fixes for v6.18-rc2, including changes to:
 
 - 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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEElRDoIDdEz9/svf2Kx4+xDQu9KksFAmjx8FsACgkQx4+xDQu9
 KkuXEQ/7BDWfsM7XReMU1Nt8nUXsJRXxM8USSkJR0jx7+kHPSkOXOTeT5I0oz2kX
 1CE5OEReZUlbKEkbmdBaHgO+oqAOzPWQhLtA4Cx+t0Tzj5ruCEA0jh1Z0jP42OFT
 gKQjuJoLIavNYplER+HRdOELdnQgdaoqfys7Ym6j0ReXpRnJ1mB9M/9PCqM+9t7Z
 QQGIJk8sUeAeeedtsEs3db7KmjZalBX16/BnDq2SV8lqgQRfDps94yIFzH8FVc6h
 641oATm9CJQFii8Vm356ndEpp9ta7jjkPVJbzvXsIv8GE+RoSrm2fiYB1PsZaU3Q
 C+pGMxVu/y3xImJTIJUFp250b/p4u5AIbUDdFIKKE/Szp8J/Svue6ojlT9LvKaEl
 Ontc/XIVJ9s5bf+oB+L9HUqH+LEdui4edD3Ovy2DurSTXfvzkr2AD8f93fziHfnI
 VyUUhludzMCRv3X2oAqvc3qrUEtilJb0tATAiJYpmWDI/RQLF3bTSaaurqrq1l9L
 HOehShBRnVXmDHhoxzRzh+FHFfViSPYOqA0SEjMjIPobN60zxULNohMjyFndA8jO
 MD1QrJqgRKNCBBmtmZadzeXksKTgCtPtR+isnDahS8o7q0UOhDeZliQqyHq++SsH
 sd+28DnZY0evVpOW7+nuxwlMu7jzEduMsDuqRgTpBx2GbkYkQd4=
 =ZOFG
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2025-10-17 12:59:31 -10:00
commit fe69107ec7
8 changed files with 27 additions and 12 deletions

View file

@ -965,6 +965,7 @@ config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
def_bool y
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS
depends on RUSTC_VERSION >= 107900
depends on ARM64 || X86_64
# With GCOV/KASAN we need this fix: https://github.com/rust-lang/rust/pull/129373
depends on (RUSTC_LLVM_VERSION >= 190103 && RUSTC_VERSION >= 108200) || \
(!GCOV_KERNEL && !KASAN_GENERIC && !KASAN_SW_TAGS)

View file

@ -29,7 +29,7 @@ config RISCV
select ARCH_HAS_DEBUG_VIRTUAL if MMU
select ARCH_HAS_DEBUG_VM_PGTABLE
select ARCH_HAS_DEBUG_WX
select ARCH_HAS_ELF_CORE_EFLAGS
select ARCH_HAS_ELF_CORE_EFLAGS if BINFMT_ELF && ELF_CORE
select ARCH_HAS_FAST_MULTIPLIER
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL

View file

@ -3,14 +3,18 @@
#ifndef __ASM_KGDB_H_
#define __ASM_KGDB_H_
#include <linux/build_bug.h>
#ifdef __KERNEL__
#define GDB_SIZEOF_REG sizeof(unsigned long)
#define DBG_MAX_REG_NUM (36)
#define NUMREGBYTES ((DBG_MAX_REG_NUM) * GDB_SIZEOF_REG)
#define DBG_MAX_REG_NUM 36
#define NUMREGBYTES (DBG_MAX_REG_NUM * GDB_SIZEOF_REG)
#define CACHE_FLUSH_IS_SAFE 1
#define BUFMAX 2048
static_assert(BUFMAX > NUMREGBYTES,
"As per KGDB documentation, BUFMAX must be larger than NUMREGBYTES");
#ifdef CONFIG_RISCV_ISA_C
#define BREAK_INSTR_SIZE 2
#else
@ -97,6 +101,7 @@ extern unsigned long kgdb_compiled_break;
#define DBG_REG_STATUS_OFF 33
#define DBG_REG_BADADDR_OFF 34
#define DBG_REG_CAUSE_OFF 35
/* NOTE: increase DBG_MAX_REG_NUM if you add more values here. */
extern const char riscv_gdb_stub_feature[64];

View file

@ -54,6 +54,7 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
pr_notice("CPU%u: off\n", cpu);
clear_tasks_mm_cpumask(cpu);
/* Verify from the firmware if the cpu is really stopped*/
if (cpu_ops->cpu_is_stopped)
ret = cpu_ops->cpu_is_stopped(cpu);

View file

@ -455,7 +455,7 @@ SYM_DATA_START_LOCAL(excp_vect_table)
RISCV_PTR do_trap_ecall_s
RISCV_PTR do_trap_unknown
RISCV_PTR do_trap_ecall_m
/* instruciton page fault */
/* instruction page fault */
ALT_PAGE_FAULT(RISCV_PTR do_page_fault)
RISCV_PTR do_page_fault /* load page fault */
RISCV_PTR do_trap_unknown

View file

@ -49,10 +49,15 @@ static void __kprobes arch_simulate_insn(struct kprobe *p, struct pt_regs *regs)
post_kprobe_handler(p, kcb, regs);
}
static bool __kprobes arch_check_kprobe(struct kprobe *p)
static bool __kprobes arch_check_kprobe(unsigned long addr)
{
unsigned long tmp = (unsigned long)p->addr - p->offset;
unsigned long addr = (unsigned long)p->addr;
unsigned long tmp, offset;
/* start iterating at the closest preceding symbol */
if (!kallsyms_lookup_size_offset(addr, NULL, &offset))
return false;
tmp = addr - offset;
while (tmp <= addr) {
if (tmp == addr)
@ -71,7 +76,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
if ((unsigned long)insn & 0x1)
return -EILSEQ;
if (!arch_check_kprobe(p))
if (!arch_check_kprobe((unsigned long)p->addr))
return -EILSEQ;
/* copy instruction */

View file

@ -331,11 +331,14 @@ void __init setup_arch(char **cmdline_p)
/* Parse the ACPI tables for possible boot-time configuration */
acpi_boot_table_init();
if (acpi_disabled) {
#if IS_ENABLED(CONFIG_BUILTIN_DTB)
unflatten_and_copy_device_tree();
unflatten_and_copy_device_tree();
#else
unflatten_device_tree();
unflatten_device_tree();
#endif
}
misc_mem_init();
init_resources();

View file

@ -11,7 +11,7 @@
#define KPROBE_TEST_MAGIC_LOWER 0x0000babe
#define KPROBE_TEST_MAGIC_UPPER 0xcafe0000
#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
/* array of addresses to install kprobes */
extern void *test_kprobes_addresses[];
@ -19,6 +19,6 @@ extern void *test_kprobes_addresses[];
/* array of functions that return KPROBE_TEST_MAGIC */
extern long (*test_kprobes_functions[])(void);
#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */
#endif /* TEST_KPROBES_H */