1. 05 Nov, 2023 3 commits
    • Jinyu Tang's avatar
      riscv: defconfig : add CONFIG_MMC_DW for starfive · 07863871
      Jinyu Tang authored
      If these config not set, mmc can't run for jh7110, rootfs can't
      be found when using SD card. So set CONFIG_MMC_DW=y like arm64
      defconfig, and set CONFIG_MMC_DW_STARFIVE=y for starfive. Then
      starfive vf2 board can start SD card rootfs with mainline defconfig
      and dtb.
      Signed-off-by: default avatarJinyu Tang <tangjinyu@tinylab.org>
      Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20230912133128.5247-1-tangjinyu@tinylab.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      07863871
    • Haorong Lu's avatar
      riscv: signal: handle syscall restart before get_signal · ce4f78f1
      Haorong Lu authored
      In the current riscv implementation, blocking syscalls like read() may
      not correctly restart after being interrupted by ptrace. This problem
      arises when the syscall restart process in arch_do_signal_or_restart()
      is bypassed due to changes to the regs->cause register, such as an
      ebreak instruction.
      
      Steps to reproduce:
      1. Interrupt the tracee process with PTRACE_SEIZE & PTRACE_INTERRUPT.
      2. Backup original registers and instruction at new_pc.
      3. Change pc to new_pc, and inject an instruction (like ebreak) to this
         address.
      4. Resume with PTRACE_CONT and wait for the process to stop again after
         executing ebreak.
      5. Restore original registers and instructions, and detach from the
         tracee process.
      6. Now the read() syscall in tracee will return -1 with errno set to
         ERESTARTSYS.
      
      Specifically, during an interrupt, the regs->cause changes from
      EXC_SYSCALL to EXC_BREAKPOINT due to the injected ebreak, which is
      inaccessible via ptrace so we cannot restore it. This alteration breaks
      the syscall restart condition and ends the read() syscall with an
      ERESTARTSYS error. According to include/linux/errno.h, it should never
      be seen by user programs. X86 can avoid this issue as it checks the
      syscall condition using a register (orig_ax) exposed to user space.
      Arm64 handles syscall restart before calling get_signal, where it could
      be paused and inspected by ptrace/debugger.
      
      This patch adjusts the riscv implementation to arm64 style, which also
      checks syscall using a kernel register (syscallno). It ensures the
      syscall restart process is not bypassed when changes to the cause
      register occur, providing more consistent behavior across various
      architectures.
      
      For a simplified reproduction program, feel free to visit:
      https://github.com/ancientmodern/riscv-ptrace-bug-demo.
      Signed-off-by: default avatarHaorong Lu <ancientmodern4@gmail.com>
      Link: https://lore.kernel.org/r/20230803224458.4156006-1-ancientmodern4@gmail.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      ce4f78f1
    • Palmer Dabbelt's avatar
      Merge patch series "Add support to handle misaligned accesses in S-mode" · 0619ff9f
      Palmer Dabbelt authored
      Clément Léger <cleger@rivosinc.com> says:
      
      Since commit 61cadb9 ("Provide new description of misaligned load/store
      behavior compatible with privileged architecture.") in the RISC-V ISA
      manual, it is stated that misaligned load/store might not be supported.
      However, the RISC-V kernel uABI describes that misaligned accesses are
      supported. In order to support that, this series adds support for S-mode
      handling of misaligned accesses as well support for prctl(PR_UNALIGN).
      
      Handling misaligned access in kernel allows for a finer grain control
      of the misaligned accesses behavior, and thanks to the prctl() call,
      can allow disabling misaligned access emulation to generate SIGBUS. User
      space can then optimize its software by removing such access based on
      SIGBUS generation.
      
      This series is useful when using a SBI implementation that does not
      handle misaligned traps as well as detecting misaligned accesses
      generated by userspace application using the prctrl(PR_SET_UNALIGN)
      feature.
      
      This series can be tested using the spike simulator[1] and a modified
      openSBI version[2] which allows to always delegate misaligned load/store to
      S-mode. A test[3] that exercise various instructions/registers can be
      executed to verify the unaligned access support.
      
      [1] https://github.com/riscv-software-src/riscv-isa-sim
      [2] https://github.com/rivosinc/opensbi/tree/dev/cleger/no_misaligned
      [3] https://github.com/clementleger/unaligned_test
      
      * b4-shazam-merge:
        riscv: add support for PR_SET_UNALIGN and PR_GET_UNALIGN
        riscv: report misaligned accesses emulation to hwprobe
        riscv: annotate check_unaligned_access_boot_cpu() with __init
        riscv: add support for sysctl unaligned_enabled control
        riscv: add floating point insn support to misaligned access emulation
        riscv: report perf event for misaligned fault
        riscv: add support for misaligned trap handling in S-mode
        riscv: remove unused functions in traps_misaligned.c
      
      Link: https://lore.kernel.org/r/20231004151405.521596-1-cleger@rivosinc.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      0619ff9f
  2. 02 Nov, 2023 5 commits
  3. 01 Nov, 2023 20 commits
  4. 27 Oct, 2023 6 commits
  5. 26 Oct, 2023 4 commits
  6. 21 Sep, 2023 2 commits