RISC-V updates for v6.19-rc7

- Fix the RISC-V timer compare register update sequence on RV32
   systems to use the recommended sequence in the RISC-V ISA manual.
   This avoids spurious interrupts during updates.
 
 - Add a dependence on the new CONFIG_CACHEMAINT_FOR_DMA Kconfig symbol
   for Renesas and StarFive RISC-V SoCs
 
 - Add a temporary workaround for a Clang compiler bug caused by using
   asm_goto_output for get_user()
 
 - Clarify our documentation to specifically state a particular ISA
   specification version for a chapter number reference
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEElRDoIDdEz9/svf2Kx4+xDQu9KksFAml1U4IACgkQx4+xDQu9
 KkuGrg//VxWHcESotmJYSLBHAnR9jmwq/cubv/yX0WQuGqpAYVW8703F2QspvbxW
 iUa2SDMqiLodWvtz9T91exlNjcbbayyiltdmFeu+cj2vr1r5GRCrHDIFMwAhM6Yu
 zc0ZO/1Trmom75yNTC8A93X0AE9yYx71VWll7KvdPhng5Tewq1sKIYCZ33GKP7LN
 EkDWymE4tATK+Wz7Orb5Rm7krfJirf8jWkUYu7Br+rQ6WelHK/tc///wqGRluHit
 7x8ca+86ASAVf9QZ73ODckc7h+rtXS5jGu3bBpXmr/BthpYc1awW/jrIFl7MbeXI
 ZHzNndijENnkl0ULsYOvGQOxy+PKtEfP70OQyRvmOqavMMaKLC/rkoBOosXPEpe/
 Br9wMIFwUYWAyi8z2Wx0GV+rBTVQx+A83Y/ODq0b5kgXzOhRbQlc1WIQnhOGvXIr
 PDbxKQxdz/fQ19eJsR8Sr2JtDlORUxc8UjhkDY6BL30TYCYyhAhZUF9d2A6wZgGy
 dqrlG0mODwcKBJINZ+r0gyEW8DFkL7t99Ju1YiUK4eIO4Bequb7Q26KoUGriXwOy
 7UPQ5d4svdxNnSwDkT73oUJop9Y34f0cNQmThKNaPTN2hulFzAVCdsLI0rCWAEzQ
 Z+XFncMkfAe3vnH9m/Vr/i5ndAHnMk5H09f5lZRn6KhtVedx0AM=
 =XHMU
 -----END PGP SIGNATURE-----

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

Pull RISC-V fixes from Paul Walmsley:
 "The notable changes here are the three RISC-V timer compare register
  update sequence patches. These only apply to RV32 systems and are
  related to the 64-bit timer compare value being split across two
  separate 32-bit registers.

  We weren't using the appropriate three-write sequence, documented in
  the RISC-V ISA specifications, to avoid spurious timer interrupts
  during the update sequence; so, these patches now use the recommended
  sequence.

  This doesn't affect 64-bit RISC-V systems, since the timer compare
  value fits inside a single register and can be updated with a single
  write.

   - Fix the RISC-V timer compare register update sequence on RV32
     systems to use the recommended sequence in the RISC-V ISA manual

     This avoids spurious interrupts during updates

   - Add a dependence on the new CONFIG_CACHEMAINT_FOR_DMA Kconfig
     symbol for Renesas and StarFive RISC-V SoCs

   - Add a temporary workaround for a Clang compiler bug caused by using
     asm_goto_output for get_user()

   - Clarify our documentation to specifically state a particular ISA
     specification version for a chapter number reference"

* tag 'riscv-for-linus-6.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: Add intermediate cast to 'unsigned long' in __get_user_asm
  riscv: Use 64-bit variable for output in __get_user_asm
  soc: renesas: Fix missing dependency on new CONFIG_CACHEMAINT_FOR_DMA
  riscv: ERRATA_STARFIVE_JH7100: Fix missing dependency on new CONFIG_CACHEMAINT_FOR_DMA
  riscv: suspend: Fix stimecmp update hazard on RV32
  riscv: kvm: Fix vstimecmp update hazard on RV32
  riscv: clocksource: Fix stimecmp update hazard on RV32
  Documentation: riscv: uabi: Clarify ISA spec version for canonical order
This commit is contained in:
Linus Torvalds 2026-01-24 18:55:48 -08:00
commit d91a46d680
7 changed files with 25 additions and 7 deletions

View file

@ -7,7 +7,9 @@ ISA string ordering in /proc/cpuinfo
------------------------------------
The canonical order of ISA extension names in the ISA string is defined in
chapter 27 of the unprivileged specification.
Chapter 27 of the RISC-V Instruction Set Manual Volume I Unprivileged ISA
(Document Version 20191213).
The specification uses vague wording, such as should, when it comes to ordering,
so for our purposes the following rules apply:

View file

@ -84,6 +84,7 @@ config ERRATA_STARFIVE_JH7100
select DMA_GLOBAL_POOL
select RISCV_DMA_NONCOHERENT
select RISCV_NONSTANDARD_CACHE_OPS
select CACHEMAINT_FOR_DMA
select SIFIVE_CCACHE
default n
help

View file

@ -97,13 +97,23 @@ static inline unsigned long __untagged_addr_remote(struct mm_struct *mm, unsigne
*/
#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
/*
* Use a temporary variable for the output of the asm goto to avoid a
* triggering an LLVM assertion due to sign extending the output when
* it is used in later function calls:
* https://github.com/llvm/llvm-project/issues/143795
*/
#define __get_user_asm(insn, x, ptr, label) \
do { \
u64 __tmp; \
asm_goto_output( \
"1:\n" \
" " insn " %0, %1\n" \
_ASM_EXTABLE_UACCESS_ERR(1b, %l2, %0) \
: "=&r" (x) \
: "m" (*(ptr)) : : label)
: "=&r" (__tmp) \
: "m" (*(ptr)) : : label); \
(x) = (__typeof__(x))(unsigned long)__tmp; \
} while (0)
#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */
#define __get_user_asm(insn, x, ptr, label) \
do { \

View file

@ -51,10 +51,11 @@ void suspend_restore_csrs(struct suspend_context *context)
#ifdef CONFIG_MMU
if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SSTC)) {
csr_write(CSR_STIMECMP, context->stimecmp);
#if __riscv_xlen < 64
csr_write(CSR_STIMECMP, ULONG_MAX);
csr_write(CSR_STIMECMPH, context->stimecmph);
#endif
csr_write(CSR_STIMECMP, context->stimecmp);
}
csr_write(CSR_SATP, context->satp);

View file

@ -72,8 +72,9 @@ static int kvm_riscv_vcpu_timer_cancel(struct kvm_vcpu_timer *t)
static int kvm_riscv_vcpu_update_vstimecmp(struct kvm_vcpu *vcpu, u64 ncycles)
{
#if defined(CONFIG_32BIT)
ncsr_write(CSR_VSTIMECMP, ncycles & 0xFFFFFFFF);
ncsr_write(CSR_VSTIMECMP, ULONG_MAX);
ncsr_write(CSR_VSTIMECMPH, ncycles >> 32);
ncsr_write(CSR_VSTIMECMP, (u32)ncycles);
#else
ncsr_write(CSR_VSTIMECMP, ncycles);
#endif
@ -307,8 +308,9 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
return;
#if defined(CONFIG_32BIT)
ncsr_write(CSR_VSTIMECMP, (u32)t->next_cycles);
ncsr_write(CSR_VSTIMECMP, ULONG_MAX);
ncsr_write(CSR_VSTIMECMPH, (u32)(t->next_cycles >> 32));
ncsr_write(CSR_VSTIMECMP, (u32)(t->next_cycles));
#else
ncsr_write(CSR_VSTIMECMP, t->next_cycles);
#endif

View file

@ -50,8 +50,9 @@ static int riscv_clock_next_event(unsigned long delta,
if (static_branch_likely(&riscv_sstc_available)) {
#if defined(CONFIG_32BIT)
csr_write(CSR_STIMECMP, next_tval & 0xFFFFFFFF);
csr_write(CSR_STIMECMP, ULONG_MAX);
csr_write(CSR_STIMECMPH, next_tval >> 32);
csr_write(CSR_STIMECMP, next_tval & 0xFFFFFFFF);
#else
csr_write(CSR_STIMECMP, next_tval);
#endif

View file

@ -445,6 +445,7 @@ config ARCH_R9A07G043
depends on RISCV_SBI
select ARCH_RZG2L
select AX45MP_L2_CACHE
select CACHEMAINT_FOR_DMA
select DMA_GLOBAL_POOL
select ERRATA_ANDES
select ERRATA_ANDES_CMO