RISC-V updates for v6.19-rc5

- Fix CONFIG_RELOCATABLE=y boots by building Image files from vmlinux,
   rather than vmlinux.unstripped, now that the .modinfo section is
   included in vmlinux.unstripped.
 
 - Prevent branch predictor poisoning microarchitectural attacks that
   use the syscall index as a vector by using array_index_nospec() to
   clamp the index after the bounds check (as x86 and ARM64 already
   do).
 
 - Fix a crash in test_kprobes when building with Clang.
 
 - Fix a deadlock possible when tracing is enabled for SBI ecalls.
 
 - Fix the definition of the Zk standard RISC-V ISA extension bundle,
   which was missing the Zknh extension.
 
 - A few other miscellaneous non-functional cleanups, removing unused
   macros, fixing an out-of-date path in code comments, resolving a
   compile-time warning for a type mismatch in a pr_crit(), and removing
   an unnecessary header file inclusion.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEElRDoIDdEz9/svf2Kx4+xDQu9KksFAmli+L4ACgkQx4+xDQu9
 KksPjA/9HMJ2spKYkMl3GGNjBauy+u8wY2BHMBI/zIw2TOu86nWGw2SrAnuZJWK3
 MCXn5/QAUpn4sgEy4yMiUg2a+nGUygJyPmodWWg7SMETpoNUz6HbXTuq/1Mjr1i5
 nk2FpOTu2/IRHFRJt1aC6QSd39Gu3LTd/Nv4h4TN/pKcutdR/ghNzeOW4e6Ld2Kg
 w+r1Sa+aXoJpGOHCcTgL0e18lovO6eW/yuIWKCyBQC9DkmEI1boLZre8dD0l317W
 f6g6RKyqCnZv6TUxNHgkgTJ/muM2ihc5LDFBHPXdnPp2wT5msYQG8epp3fjEw9jg
 a744xFMY73jBWGJH0Z3sJgm77CAc+iCBkz2Gy9wnpc7M1i2IyETj8U7GWU/RJDSH
 ANZLgNRxtEqjDZz37XvAH1e1NhciNH0OEaUEL7byBAR2yu4eIPRIBwRMYnJ3ezkZ
 hRDyxWC7AKhcumtcJ11Ee8hlSM4WI0GYSBE0aWGtqpiRFyDN2OvZEDpozpyJLvXB
 vPwlggjdIkNjcbB+t7x1F7sW6n81MU44oXt3qXYJjNlO0MtZxPVn5S5mSIEOoEWp
 gv0vk/PRY5a1ErnKiZxuHqFR8IciR6H9rOInuueJmAbWvasYjGlzuDqPCGcaosrq
 S4NbZowFQiw4jBEMtpyQISg4sI2ixVQKEqinWSbTXPINReTeAuI=
 =BtHz
 -----END PGP SIGNATURE-----

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

Pull RISC-V fixes from Paul Walmsley:
 "Notable changes include a fix to close one common microarchitectural
  attack vector for out-of-order cores. Another patch exposed an
  omission in my boot test coverage, which is currently missing
  relocatable kernels. Otherwise, the fixes seem to be settling down for
  us.

   - Fix CONFIG_RELOCATABLE=y boots by building Image files from
     vmlinux, rather than vmlinux.unstripped, now that the .modinfo
     section is included in vmlinux.unstripped

   - Prevent branch predictor poisoning microarchitectural attacks that
     use the syscall index as a vector by using array_index_nospec() to
     clamp the index after the bounds check (as x86 and ARM64 already
     do)

   - Fix a crash in test_kprobes when building with Clang

   - Fix a deadlock possible when tracing is enabled for SBI ecalls

   - Fix the definition of the Zk standard RISC-V ISA extension bundle,
     which was missing the Zknh extension

   - A few other miscellaneous non-functional cleanups, removing unused
     macros, fixing an out-of-date path in code comments, resolving a
     compile-time warning for a type mismatch in a pr_crit(), and
     removing an unnecessary header file inclusion"

* tag 'riscv-for-linus-6.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: trace: fix snapshot deadlock with sbi ecall
  riscv: remove irqflags.h inclusion in asm/bitops.h
  riscv: cpu_ops_sbi: smp_processor_id() returns int, not unsigned int
  riscv: configs: Clean up references to non-existing configs
  riscv: kexec_image: Fix dead link to boot-image-header.rst
  riscv: pgtable: Cleanup useless VA_USER_XXX definitions
  riscv: cpufeature: Fix Zk bundled extension missing Zknh
  riscv: fix KUnit test_kprobes crash when building with Clang
  riscv: Sanitize syscall table indexing under speculation
  riscv: boot: Always make Image from vmlinux, not vmlinux.unstripped
This commit is contained in:
Linus Torvalds 2026-01-10 15:54:41 -10:00
commit 755bc1335e
12 changed files with 26 additions and 35 deletions

View file

@ -31,11 +31,7 @@ $(obj)/xipImage: vmlinux FORCE
endif
ifdef CONFIG_RELOCATABLE
$(obj)/Image: vmlinux.unstripped FORCE
else
$(obj)/Image: vmlinux FORCE
endif
$(call if_changed,objcopy)
$(obj)/Image.gz: $(obj)/Image FORCE

View file

@ -55,7 +55,6 @@ CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_HW_RANDOM is not set
# CONFIG_DEVMEM is not set
CONFIG_I2C=y
# CONFIG_I2C_COMPAT is not set
CONFIG_I2C_CHARDEV=y
# CONFIG_I2C_HELPER_AUTO is not set
CONFIG_I2C_DESIGNWARE_CORE=y
@ -89,7 +88,6 @@ CONFIG_PRINTK_TIME=y
# CONFIG_FRAME_POINTER is not set
# CONFIG_DEBUG_MISC is not set
CONFIG_PANIC_ON_OOPS=y
# CONFIG_SCHED_DEBUG is not set
# CONFIG_RCU_TRACE is not set
# CONFIG_FTRACE is not set
# CONFIG_RUNTIME_TESTING_MENU is not set

View file

@ -86,7 +86,6 @@ CONFIG_PRINTK_TIME=y
# CONFIG_FRAME_POINTER is not set
# CONFIG_DEBUG_MISC is not set
CONFIG_PANIC_ON_OOPS=y
# CONFIG_SCHED_DEBUG is not set
# CONFIG_RCU_TRACE is not set
# CONFIG_FTRACE is not set
# CONFIG_RUNTIME_TESTING_MENU is not set

View file

@ -66,7 +66,6 @@ CONFIG_EXT2_FS=y
# CONFIG_MISC_FILESYSTEMS is not set
CONFIG_LSM="[]"
CONFIG_PRINTK_TIME=y
# CONFIG_SCHED_DEBUG is not set
# CONFIG_RCU_TRACE is not set
# CONFIG_FTRACE is not set
# CONFIG_RUNTIME_TESTING_MENU is not set

View file

@ -11,7 +11,6 @@
#endif /* _LINUX_BITOPS_H */
#include <linux/compiler.h>
#include <linux/irqflags.h>
#include <asm/barrier.h>
#include <asm/bitsperlong.h>

View file

@ -124,10 +124,6 @@
#ifdef CONFIG_64BIT
#include <asm/pgtable-64.h>
#define VA_USER_SV39 (UL(1) << (VA_BITS_SV39 - 1))
#define VA_USER_SV48 (UL(1) << (VA_BITS_SV48 - 1))
#define VA_USER_SV57 (UL(1) << (VA_BITS_SV57 - 1))
#define MMAP_VA_BITS_64 ((VA_BITS >= VA_BITS_SV48) ? VA_BITS_SV48 : VA_BITS)
#define MMAP_MIN_VA_BITS_64 (VA_BITS_SV39)
#define MMAP_VA_BITS (is_compat_task() ? VA_BITS_SV32 : MMAP_VA_BITS_64)

View file

@ -3,12 +3,6 @@
# Makefile for the RISC-V Linux kernel
#
ifdef CONFIG_FTRACE
CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_patch.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE)
endif
CFLAGS_syscall_table.o += $(call cc-disable-warning, override-init)
CFLAGS_compat_syscall_table.o += $(call cc-disable-warning, override-init)
@ -24,7 +18,6 @@ CFLAGS_sbi_ecall.o := -mcmodel=medany
ifdef CONFIG_FTRACE
CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_sbi_ecall.o = $(CC_FLAGS_FTRACE)
endif
ifdef CONFIG_RELOCATABLE
CFLAGS_alternative.o += -fno-pie
@ -43,6 +36,14 @@ CFLAGS_sbi_ecall.o += -D__NO_FORTIFY
endif
endif
ifdef CONFIG_FTRACE
CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_patch.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_sbi_ecall.o = $(CC_FLAGS_FTRACE)
endif
always-$(KBUILD_BUILTIN) += vmlinux.lds
obj-y += head.o

View file

@ -85,7 +85,7 @@ static void sbi_cpu_stop(void)
int ret;
ret = sbi_hsm_hart_stop();
pr_crit("Unable to stop the cpu %u (%d)\n", smp_processor_id(), ret);
pr_crit("Unable to stop the cpu %d (%d)\n", smp_processor_id(), ret);
}
static int sbi_cpu_is_stopped(unsigned int cpuid)

View file

@ -301,23 +301,22 @@ static const unsigned int riscv_a_exts[] = {
RISCV_ISA_EXT_ZALRSC,
};
#define RISCV_ISA_EXT_ZKN \
RISCV_ISA_EXT_ZBKB, \
RISCV_ISA_EXT_ZBKC, \
RISCV_ISA_EXT_ZBKX, \
RISCV_ISA_EXT_ZKND, \
RISCV_ISA_EXT_ZKNE, \
RISCV_ISA_EXT_ZKNH
static const unsigned int riscv_zk_bundled_exts[] = {
RISCV_ISA_EXT_ZBKB,
RISCV_ISA_EXT_ZBKC,
RISCV_ISA_EXT_ZBKX,
RISCV_ISA_EXT_ZKND,
RISCV_ISA_EXT_ZKNE,
RISCV_ISA_EXT_ZKN,
RISCV_ISA_EXT_ZKR,
RISCV_ISA_EXT_ZKT,
RISCV_ISA_EXT_ZKT
};
static const unsigned int riscv_zkn_bundled_exts[] = {
RISCV_ISA_EXT_ZBKB,
RISCV_ISA_EXT_ZBKC,
RISCV_ISA_EXT_ZBKX,
RISCV_ISA_EXT_ZKND,
RISCV_ISA_EXT_ZKNE,
RISCV_ISA_EXT_ZKNH,
RISCV_ISA_EXT_ZKN
};
static const unsigned int riscv_zks_bundled_exts[] = {

View file

@ -22,7 +22,7 @@ static int image_probe(const char *kernel_buf, unsigned long kernel_len)
if (!h || kernel_len < sizeof(*h))
return -EINVAL;
/* According to Documentation/riscv/boot-image-header.rst,
/* According to Documentation/arch/riscv/boot-image-header.rst,
* use "magic2" field to check when version >= 0.2.
*/

View file

@ -181,6 +181,7 @@ SYM_FUNC_END(test_kprobes_c_bnez)
#endif /* CONFIG_RISCV_ISA_C */
.section .rodata
SYM_DATA_START(test_kprobes_addresses)
RISCV_PTR test_kprobes_add_addr1
RISCV_PTR test_kprobes_add_addr2
@ -212,6 +213,7 @@ SYM_DATA_START(test_kprobes_addresses)
RISCV_PTR 0
SYM_DATA_END(test_kprobes_addresses)
.section .rodata
SYM_DATA_START(test_kprobes_functions)
RISCV_PTR test_kprobes_add
RISCV_PTR test_kprobes_jal

View file

@ -339,8 +339,10 @@ void do_trap_ecall_u(struct pt_regs *regs)
add_random_kstack_offset();
if (syscall >= 0 && syscall < NR_syscalls)
if (syscall >= 0 && syscall < NR_syscalls) {
syscall = array_index_nospec(syscall, NR_syscalls);
syscall_handler(regs, syscall);
}
/*
* Ultimately, this value will get limited by KSTACK_OFFSET_MAX(),