Aleksa Paunovic
bb4b0f8a1b
riscv: hwprobe: Add MIPS vendor extension probing
...
Add a new hwprobe key "RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0" which allows
userspace to probe for the new xmipsexectl vendor extension.
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250724-p8700-pause-v5-4-a6cbbe1c3412@htecgroup.com
[pjw@kernel.org: fixed some checkpatch issues]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-19 10:33:56 -06:00
Aleksa Paunovic
1d4ce63e33
riscv: Add xmipsexectl instructions
...
Add xmipsexectl instruction opcodes. This includes the MIPS.PAUSE,
MIPS.EHB, and MIPS.IHB instructions.
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250724-p8700-pause-v5-3-a6cbbe1c3412@htecgroup.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-19 10:33:56 -06:00
Aleksa Paunovic
a8fed1bc03
riscv: Add xmipsexectl as a vendor extension
...
Add support for MIPS vendor extensions. Add support for the xmipsexectl
vendor extension.
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250724-p8700-pause-v5-2-a6cbbe1c3412@htecgroup.com
[pjw@kernel.org: added the MIPS vendor ID from another patch to fix the build]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-18 20:36:00 -06:00
Aleksa Paunovic
f79671dc87
dt-bindings: riscv: Add xmipsexectl ISA extension description
...
The xmipsexectl extension is described in the MIPS RV64 P8700/P8700-F
Multiprocessing System Programmer’s Guide linked at [1].
Link: https://mips.com/wp-content/uploads/2025/06/P8700_Programmers_Reference_Manual_Rev1.84_5-31-2025.pdf
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com >
Acked-by: Conor Dooley <conor.dooley@microchip.com >
Link: https://lore.kernel.org/r/20250724-p8700-pause-v5-1-a6cbbe1c3412@htecgroup.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 20:32:08 -06:00
Clément Léger
2e2cf5581f
riscv: cpufeature: add validation for zfa, zfh and zfhmin
...
These extensions depends on the F one. Add a validation callback
checking for the F extension to be present. Now that extensions are
correctly reported using the F/D presence, we can remove the
has_fpu() check in hwprobe_isa_ext0().
Signed-off-by: Clément Léger <cleger@rivosinc.com >
Reviewed-by: Conor Dooley <conor.dooley@microchip.com >
Link: https://lore.kernel.org/r/20250527100001.33284-1-cleger@rivosinc.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 19:51:09 -06:00
Yunhui Cui
568a2fa10d
perf: riscv: skip empty batches in counter start
...
Avoid unnecessary SBI calls when starting non-overflowed counters
in pmu_sbi_start_ovf_ctrs_sbi() by checking ctr_start_mask.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com >
Reviewed-by: Anup Patel <anup@brainfault.org >
Link: https://lore.kernel.org/r/20250804025110.11088-1-cuiyunhui@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 19:28:13 -06:00
Bala-Vignesh-Reddy
f68cd7ddd0
selftests: riscv: Add README for RISC-V KSelfTest
...
Add a README file for RISC-V specific kernel selftests under
tools/testing/selftests/riscv/. This mirrors the existing README
for arm64, providing clear guidance on how the tests are architecture
specific and skipped on non-riscv systems. It also includes
standard make commands for building, running and installing the
tests, along with a reference to general kselftest documentation.
Signed-off-by: Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com >
Reviewed-by: Andrew Jones <ajones@ventanamicro.com >
Link: https://lore.kernel.org/r/20250815180724.14459-1-reddybalavignesh9979@gmail.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 19:26:07 -06:00
Andrew Davis
70ddf86d76
riscv: sbi: Switch to new sys-off handler API
...
Kernel now supports chained power-off handlers. Use
register_platform_power_off() that registers a platform level power-off
handler. Legacy pm_power_off() will be removed once all drivers and archs
are converted to the new sys-off API.
Signed-off-by: Andrew Davis <afd@ti.com >
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250813151855.105237-1-afd@ti.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 17:48:04 -06:00
Guo Ren (Alibaba DAMO Academy)
16d18e3eaf
riscv: Move vendor errata definitions to new header
...
Move vendor errata definitions into errata_list_vendors.h.
Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Tested-by: Han Gao <rabenda.cn@gmail.com >
Link: https://lore.kernel.org/r/20250713155321.2064856-2-guoren@kernel.org
[pjw@kernel.org: updated to apply and to make the whitespace consistent]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-18 08:22:00 -06:00
Heinrich Schuchardt
92c4995b4d
RISC-V: ACPI: enable parsing the BGRT table
...
The BGRT table is used to display a vendor logo during the boot process.
Add the code for parsing it.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com >
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com >
Link: https://lore.kernel.org/r/20250729131535.522205-2-heinrich.schuchardt@canonical.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 08:21:45 -06:00
Pu Lehui
205cbc7148
riscv: Enable ARCH_HAVE_NMI_SAFE_CMPXCHG
...
The implement of cmpxchg() in riscv is based on atomic primitives and
has NMI-safe features, so it can be used safely in the in_nmi context.
ftrace's ringbuffer relies on NMI-safe cmpxchg() in the NMI context.
Currently, in_nmi() is true when riscv kprobe is in trap-based mode, so
this config needs to be selected, otherwise kprobetrace will not be
available.
Signed-off-by: Pu Lehui <pulehui@huawei.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250711090443.1688404-1-pulehui@huaweicloud.com
[pjw@kernel.org: moved to preserve alphabetical order]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-18 08:20:59 -06:00
Masahiro Yamada
6dab7e15c0
riscv: pi: use 'targets' instead of extra-y in Makefile
...
%.pi.o files are built as prerequisites of other objects.
There is no need to use extra-y, which is planned for deprecation.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org >
Link: https://lore.kernel.org/r/20250602181023.528550-1-masahiroy@kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 08:20:56 -06:00
Ignacio Encinas
cc2294d3f9
riscv: introduce asm/swab.h
...
Implement endianness swap macros for RISC-V.
Use the rev8 instruction when Zbb is available. Otherwise, rely on the
default mask-and-shift implementation.
Acked-by: Palmer Dabbelt <palmer@rivosinc.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Signed-off-by: Ignacio Encinas <ignacio@iencinas.com >
Link: https://lore.kernel.org/r/20250723-riscv-swab-v6-1-fc11e9a2efc9@iencinas.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 08:20:25 -06:00
Jessica Liu
316b60b984
riscv: mmap(): use unsigned offset type in riscv_sys_mmap
...
The variable type of offset should be consistent with the relevant
interfaces of mmap which described in commit 295f10061a ("syscalls:
mmap(): use unsigned offset type consistently"). Otherwise, a user input
with the top bit set would result in a negative page offset rather than a
large one.
Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn >
Tested-by: Han Gao <rabenda.cn@gmail.com >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com >
Link: https://lore.kernel.org/r/20250801104948133AaMr5S6E382PbNNhoJgHA@zte.com.cn
[pjw@kernel.org: hand-applied mangled patch; fixed checkpatch error]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-18 08:19:47 -06:00
Liao Yuanhong
01dc937ac1
drivers/perf: riscv: Remove redundant ternary operators
...
For ternary operators in the form of "a ? true : false", if 'a' itself
returns a boolean result, the ternary operator can be omitted. Remove
redundant ternary operators to clean up the code.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com >
Reviewed-by: Atish Patra <atishp@rivosinc.com >
Link: https://lore.kernel.org/r/20250828122510.30843-1-liaoyuanhong@vivo.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 08:18:43 -06:00
Junhui Liu
17e9521044
riscv: mm: Use mmu-type from FDT to limit SATP mode
...
Some RISC-V implementations may hang when attempting to write an
unsupported SATP mode, even though the latest RISC-V specification
states such writes should have no effect. To avoid this issue, the
logic for selecting SATP mode has been refined:
The kernel now determines the SATP mode limit by taking the minimum of
the value specified by the kernel command line (noXlvl) and the
"mmu-type" property in the device tree (FDT). If only one is specified,
use that.
- If the resulting limit is sv48 or higher, the kernel will probe SATP
modes from this limit downward until a supported mode is found.
- If the limit is sv39, the kernel will directly use sv39 without
probing.
This ensures SATP mode selection is safe and compatible with both
hardware and user configuration, minimizing the risk of hangs.
Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com >
Link: https://lore.kernel.org/r/20250722-satp-from-fdt-v1-2-5ba22218fa5f@pigmoral.tech
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-18 08:18:14 -06:00
Junhui Liu
f3243bed39
riscv: mm: Return intended SATP mode for noXlvl options
...
Change the return value of match_noXlvl() to return the SATP mode that
will be used, rather than the mode being disabled. This enables unified
logic for return value judgement with the function that obtains mmu-type
from the fdt, avoiding extra conversion. This only changes the naming,
with no functional impact.
Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com >
Link: https://lore.kernel.org/r/20250722-satp-from-fdt-v1-1-5ba22218fa5f@pigmoral.tech
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-17 17:00:59 -06:00
Nam Cao
4d4a3cc7f2
riscv: kprobes: Remove duplication of RV_EXTRACT_ITYPE_IMM
...
Use RV_EXTRACT_ITYPE_IMM, instead of re-implementing it in simulate_jalr().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/8ae34e966c312ae5cf6c09a35ddc290cce942208.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
7843b48dbf
riscv: kprobes: Remove duplication of RV_EXTRACT_UTYPE_IMM
...
Use RV_EXTRACT_UTYPE_IMM, instead of reimplementing it in simulate_auipc().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/8f0defce9f1f23f1b44bb9750ed083cfc124213c.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
e333496302
riscv: kprobes: Remove duplication of RV_EXTRACT_RD_REG
...
Use RV_EXTRACT_RD_REG, instead of reimplementing its code.
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/b31e5b41df5839a76103348e54dc034c8a43447a.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
05df05bb04
riscv: kprobes: Remove duplication of RVC_EXTRACT_BTYPE_IMM
...
Use RVC_EXTRACT_BTYPE_IMM, instead of reimplementing it in
simulate_c_bnez_beqz().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/8a8ed970f279fa5f24c90d840c2130e37bc6d16e.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
580c11cd0b
riscv: kprobes: Remove duplication of RVC_EXTRACT_C2_RS1_REG
...
Use RVC_EXTRACT_C2_RS1_REG, instead of reimplementing it in
simulate_c_jr_jalr().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/d56955cd683411c6d2f63d13c78e0572462a3269.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
05ede658d4
riscv: kprobes: Remove duplication of RVC_EXTRACT_JTYPE_IMM
...
Use RVC_EXTRACT_JTYPE_IMM, instead of reimplementing it in simulate_c_j().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/24497deaab06d6b12cb84923606ec26f67e25424.1747215274.git.namcao@linutronix.de/
[pjw@kernel.org: fixed subject line typo]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-16 18:46:44 -06:00
Nam Cao
76494817df
riscv: kprobes: Remove duplication of RV_EXTRACT_BTYPE_IMM
...
Use RV_EXTRACT_BTYPE_IMM, instead of reimplementing it in
simulate_branch().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/b441038c991da11a7a48ea7140ab00e3bb119387.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
d57676c21e
riscv: kprobes: Remove duplication of RV_EXTRACT_RS1_REG
...
Use RV_EXTRACT_RS1_REG instead of reimplementing its code.
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/b441038c991da11a7a48ea7140ab00e3bb119387.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:44 -06:00
Nam Cao
8f1ea7f04e
riscv: kprobes: Remove duplication of RV_EXTRACT_JTYPE_IMM
...
Use RV_EXTRACT_JTYPE_IMM, instead of reimplementing it in simulate_jal().
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/af502036738d381c6bdb96a236d21bab8c343f74.1747215274.git.namcao@linutronix.de/
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 18:46:43 -06:00
Nam Cao
518c550eeb
riscv: kprobes: Move branch_funct3 to insn.h
...
Similar to other instruction-processing macros/functions, branch_funct3
should be in insn.h.
Move it into insn.h as RV_EXTRACT_FUNCT3. This new name matches the style
in insn.h.
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/200c29a26338f19d09963fa02562787e8cfa06f2.1747215274.git.namcao@linutronix.de/
[pjw@kernel.org: updated to use RV_X_MASK and to apply]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-16 18:46:43 -06:00
Nam Cao
5fe5914027
riscv: kprobes: Move branch_rs2_idx to insn.h
...
Similar to other instruction-processing macros/functions, branch_rs2_idx
should be in insn.h.
Move it into insn.h as RV_EXTRACT_RS2_REG. This new name matches the style
in insn.h.
Signed-off-by: Nam Cao <namcao@linutronix.de >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/linux-riscv/107d4a6c1818bf169be2407b273a0483e6d55bbb.1747215274.git.namcao@linutronix.de/
[pjw@kernel.org: updated to use RV_X_MASK and to apply]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-16 18:46:43 -06:00
Chunyan Zhang
2dfb75cd56
raid6: riscv: replace one load with a move to speed up the caculation
...
Since wp$$==wq$$, it doesn't need to load the same data twice, use move
instruction to replace one of the loads to let the program run faster.
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn >
Link: https://lore.kernel.org/r/20250718072711.3865118-3-zhangchunyan@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:43:27 -06:00
Chunyan Zhang
f8a03516a5
raid6: riscv: Clean up unused header file inclusion
...
These two C files don't reference things defined in simd.h or types.h
so remove these redundant #inclusions.
Fixes: 6093faaf95 ("raid6: Add RISC-V SIMD syndrome and recovery calculations")
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn >
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com >
Link: https://lore.kernel.org/r/20250718072711.3865118-2-zhangchunyan@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:29:55 -06:00
Alexandre Ghiti
a601732236
riscv: Move all duplicate insn parsing macros into asm/insn.h
...
kernel/traps_misaligned.c and kvm/vcpu_insn.c define the same macros to
extract information from the instructions.
Let's move the definitions into asm/insn.h to avoid this duplication.
Reviewed-by: Andrew Jones <ajones@ventanamicro.com >
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Clément Léger <cleger@rivosinc.com >
Link: https://lore.kernel.org/r/20250620-dev-alex-insn_duplicate_v5_manual-v5-3-d865dc9ad180@rivosinc.com
[pjw@kernel.org: updated to apply]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-16 16:29:07 -06:00
Alexandre Ghiti
833bbb0d91
riscv: Strengthen duplicate and inconsistent definition of RV_X()
...
RV_X() macro is defined in two different ways which is error prone.
So harmonize its first definition and add another macro RV_X_MASK() for
the second one.
Reviewed-by: Andrew Jones <ajones@ventanamicro.com >
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250620-dev-alex-insn_duplicate_v5_manual-v5-2-d865dc9ad180@rivosinc.com
[pjw@kernel.org: upcase the macro name to conform with previous practice]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-09-16 16:28:30 -06:00
Alexandre Ghiti
932131fd3e
riscv: Fix typo EXRACT -> EXTRACT
...
Simply fix a typo.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Andrew Jones <ajones@ventanamicro.com >
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Clément Léger <cleger@rivosinc.com >
Link: https://lore.kernel.org/r/20250620-dev-alex-insn_duplicate_v5_manual-v5-1-d865dc9ad180@rivosinc.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:28:02 -06:00
Nam Cao
f2fab61282
riscv: Add kprobes KUnit test
...
Add KUnit test for riscv kprobes, mostly for simulated instructions. The
test install kprobes into multiple sample functions, and check that these
functions still return the expected magic value.
This test can detect some kprobe bugs reported in the past (in Link:).
Link: https://lore.kernel.org/linux-riscv/20241119111056.2554419-1-namcao@linutronix.de/
Link: https://lore.kernel.org/stable/c7e463c0-8cad-4f4e-addd-195c06b7b6de@iscas.ac.cn/
Link: https://lore.kernel.org/linux-riscv/20230829182500.61875-1-namcaov@gmail.com/
Signed-off-by: Nam Cao <namcao@linutronix.de >
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250513151631.3520793-1-namcao@linutronix.de
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:25:51 -06:00
Thomas Huth
f811f58597
riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers
...
While the GCC and Clang compilers already define __ASSEMBLER__
automatically when compiling assembly code, __ASSEMBLY__ is a
macro that only gets defined by the Makefiles in the kernel.
This can be very confusing when switching between userspace
and kernelspace coding, or when dealing with uapi headers that
rather should use __ASSEMBLER__ instead. So let's standardize on
the __ASSEMBLER__ macro that is provided by the compilers now.
This originally was a completely mechanical patch (done with a
simple "sed -i" statement), with some manual fixups during
rebasing of the patch later.
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: linux-riscv@lists.infradead.org
Signed-off-by: Thomas Huth <thuth@redhat.com >
Link: https://lore.kernel.org/r/20250606070952.498274-3-thuth@redhat.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:25:30 -06:00
Thomas Huth
35ebe00307
riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
...
__ASSEMBLY__ is only defined by the Makefile of the kernel, so
this is not really useful for uapi headers (unless the userspace
Makefile defines it, too). Let's switch to __ASSEMBLER__ which
gets set automatically by the compiler when compiling assembly
code.
This is a completely mechanical patch (done with a simple "sed -i"
statement).
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: linux-riscv@lists.infradead.org
Signed-off-by: Thomas Huth <thuth@redhat.com >
Link: https://lore.kernel.org/r/20250606070952.498274-2-thuth@redhat.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:25:17 -06:00
Yunhui Cui
3a8ee3a9f4
riscv: introduce ioremap_wc()
...
Compared with IO attributes, NC attributes can improve performance,
specifically in these aspects: Relaxed Order, Gathering, Supports Read
Speculation, Supports Unaligned Access.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com >
Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250722091504.45974-2-cuiyunhui@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-16 16:24:27 -06:00
Alexandre Ghiti
a03ee11b8f
riscv: Fix sparse warning about different address spaces
...
We did not propagate the __user attribute of the pointers in
__get_kernel_nofault() and __put_kernel_nofault(), which results in
sparse complaining:
>> mm/maccess.c:41:17: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *from @@ got unsigned long long [usertype] * @@
mm/maccess.c:41:17: sparse: expected void const [noderef] __user *from
mm/maccess.c:41:17: sparse: got unsigned long long [usertype] *
So fix this by correctly casting those pointers.
Reported-by: kernel test robot <lkp@intel.com >
Closes: https://lore.kernel.org/oe-kbuild-all/202508161713.RWu30Lv1-lkp@intel.com/
Suggested-by: Al Viro <viro@zeniv.linux.org.uk >
Fixes: f6bff7827a ("riscv: uaccess: use 'asm_goto_output' for get_user()")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Cyril Bur <cyrilbur@tenstorrent.com >
Link: https://lore.kernel.org/r/20250903-dev-alex-sparse_warnings_v1-v1-2-7e6350beb700@rivosinc.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:33:52 -06:00
Alexandre Ghiti
fef7ded169
riscv: Fix sparse warning in __get_user_error()
...
We used to assign 0 to x without an appropriate cast which results in
sparse complaining when x is a pointer:
>> block/ioctl.c:72:39: sparse: sparse: Using plain integer as NULL pointer
So fix this by casting 0 to the correct type of x.
Reported-by: kernel test robot <lkp@intel.com >
Closes: https://lore.kernel.org/oe-kbuild-all/202508062321.gHv4kvuY-lkp@intel.com/
Fixes: f6bff7827a ("riscv: uaccess: use 'asm_goto_output' for get_user()")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Reviewed-by: Clément Léger <cleger@rivosinc.com >
Reviewed-by: Cyril Bur <cyrilbur@tenstorrent.com >
Link: https://lore.kernel.org/r/20250903-dev-alex-sparse_warnings_v1-v1-1-7e6350beb700@rivosinc.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:33:44 -06:00
Breno Leitao
95c54cd9c7
riscv: kexec: Initialize kexec_buf struct
...
The kexec_buf structure was previously declared without initialization.
commit bf454ec31a ("kexec_file: allow to place kexec_buf randomly")
added a field that is always read but not consistently populated by all
architectures. This un-initialized field will contain garbage.
This is also triggering a UBSAN warning when the uninitialized data was
accessed:
------------[ cut here ]------------
UBSAN: invalid-load in ./include/linux/kexec.h:210:10
load of value 252 is not a valid value for type '_Bool'
Zero-initializing kexec_buf at declaration ensures all fields are
cleanly set, preventing future instances of uninitialized memory being
used.
Fixes: bf454ec31a ("kexec_file: allow to place kexec_buf randomly")
Signed-off-by: Breno Leitao <leitao@debian.org >
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250827-kbuf_all-v1-2-1df9882bb01a@debian.org
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:31:28 -06:00
Radim Krčmář
f4ea67a722
riscv: use lw when reading int cpu in asm_per_cpu
...
REG_L is wrong, because thread_info.cpu is 32-bit, not xlen-bit wide.
The struct currently has a hole after cpu, so little endian accesses
seemed fine.
Fixes: be97d0db5f ("riscv: VMAP_STACK overflow detection thread-safe")
Cc: stable@vger.kernel.org
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com >
Link: https://lore.kernel.org/r/20250725165410.2896641-5-rkrcmar@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:31:24 -06:00
Radim Krčmář
8a16586fa7
riscv, bpf: use lw when reading int cpu in bpf_get_smp_processor_id
...
emit_ld is wrong, because thread_info.cpu is 32-bit, not xlen-bit wide.
The struct currently has a hole after cpu, so little endian accesses
seemed fine.
Fixes: 2ddec2c80b ("riscv, bpf: inline bpf_get_smp_processor_id()")
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com >
Reviewed-by: Pu Lehui <pulehui@huawei.com >
Link: https://lore.kernel.org/r/20250812090256.757273-4-rkrcmar@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:31:20 -06:00
Radim Krčmář
ad5348c765
riscv, bpf: use lw when reading int cpu in BPF_MOV64_PERCPU_REG
...
emit_ld is wrong, because thread_info.cpu is 32-bit, not xlen-bit wide.
The struct currently has a hole after cpu, so little endian accesses
seemed fine.
Fixes: 19c56d4e5b ("riscv, bpf: add internal-only MOV instruction to resolve per-CPU addrs")
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com >
Reviewed-by: Pu Lehui <pulehui@huawei.com >
Acked-by: Björn Töpel <bjorn@kernel.org >
Tested-by: Björn Töpel <bjorn@rivosinc.com > # QEMU
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Link: https://lore.kernel.org/r/20250812090256.757273-3-rkrcmar@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:31:17 -06:00
Aurelien Jarno
1046791390
riscv: uaccess: fix __put_user_nocheck for unaligned accesses
...
The type of the value to write should be determined by the size of the
destination, not by the value itself, which may be a constant. This
aligns the behavior with x86_64, where __typeof__(*(__gu_ptr)) is used
to infer the correct type.
This fixes an issue in put_cmsg, which was only writing 4 out of 8
bytes to the cmsg_len field, causing the glibc tst-socket-timestamp test
to fail.
Fixes: ca1a66cdd6 ("riscv: uaccess: do not do misaligned accesses in get/put_user()")
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net >
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250724220853.1969954-1-aurelien@aurel32.net
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:30:48 -06:00
Radim Krčmář
e108c8a94f
riscv: use lw when reading int cpu in new_vmalloc_check
...
REG_L is wrong, because thread_info.cpu is 32-bit, not xlen-bit wide.
The struct currently has a hole after cpu, so little endian accesses
seemed fine.
Fixes: 503638e0ba ("riscv: Stop emitting preventive sfence.vma for new vmalloc mappings")
Cc: stable@vger.kernel.org
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com >
Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com >
Link: https://lore.kernel.org/r/20250725165410.2896641-4-rkrcmar@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-05 15:30:45 -06:00
Anup Patel
5b3706597b
ACPI: RISC-V: Fix FFH_CPPC_CSR error handling
...
The cppc_ffh_csr_read() and cppc_ffh_csr_write() returns Linux error
code in "data->ret.error" so cpc_read_ffh() and cpc_write_ffh() must
not use sbi_err_map_linux_errno() for FFH_CPPC_CSR.
Fixes: 30f3ffbee8 ("ACPI: RISC-V: Add CPPC driver")
Signed-off-by: Anup Patel <apatel@ventanamicro.com >
Reviewed-by: Andrew Jones <ajones@ventanamicro.com >
Reviewed-by: Troy Mitchell <troy.mitchell@linux.dev >
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com >
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com >
Reviewed-by: Atish Patra <atishp@rivosinc.com >
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250818143600.894385-2-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-04 16:25:50 -06:00
Nathan Chancellor
41f9049cff
riscv: Only allow LTO with CMODEL_MEDANY
...
When building with CONFIG_CMODEL_MEDLOW and CONFIG_LTO_CLANG, there is a
series of errors due to some files being unconditionally compiled with
'-mcmodel=medany', mismatching with the rest of the kernel built with
'-mcmodel=medlow':
ld.lld: error: Function Import: link error: linking module flags 'Code Model': IDs have conflicting values: 'i32 3' from vmlinux.a(init.o at 899908), and 'i32 1' from vmlinux.a(net-traces.o at 1014628)
Only allow LTO to be performed when CONFIG_CMODEL_MEDANY is enabled to
ensure there will be no code model mismatch errors. An alternative
solution would be disabling LTO for the files with a different code
model than the main kernel like some specialized areas of the kernel do
but doing that for individual files is not as sustainable than
forbidding the combination altogether.
Cc: stable@vger.kernel.org
Fixes: 021d23428b ("RISC-V: build: Allow LTO to be selected")
Reported-by: kernel test robot <lkp@intel.com >
Closes: https://lore.kernel.org/oe-kbuild-all/202506290255.KBVM83vZ-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org >
Link: https://lore.kernel.org/r/20250710-riscv-restrict-lto-to-medany-v1-1-b1dac9871ecf@kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org >
2025-09-04 16:25:46 -06:00
Linus Torvalds
8f5ae30d69
Linux 6.17-rc1
v6.17-rc1
2025-08-10 19:41:16 +03:00
Linus Torvalds
2b38afce25
Merge tag 'turbostat-2025.09.09' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
...
Pull turbostat updates from Len Brown:
"tools/power turbostat: version 2025.09.09
- Probe and display L3 Cache topology
- Add ability to average an added counter (useful for pre-integrated
"counters", such as Watts)
- Break the limit of 64 built-in counters
- Assorted bug fixes and minor feature tweaks"
* tag 'turbostat-2025.09.09' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
tools/power turbostat: version 2025.09.09
tools/power turbostat: Handle non-root legacy-uncore sysfs permissions
tools/power turbostat: standardize PER_THREAD_PARAMS
tools/power turbostat: Fix DMR support
tools/power turbostat: add format "average" for external attributes
tools/power turbostat: delete GET_PKG()
tools/power turbostat: probe and display L3 cache topology
tools/power turbostat: Support more than 64 built-in-counters
tools/power turbostat.8: Document Totl%C0, Any%C0, GFX%C0, CPUGFX% columns
tools/power turbostat: Fix bogus SysWatt for forked program
tools/power turbostat: Handle cap_get_proc() ENOSYS
tools/power turbostat: Fix build with musl
tools/power turbostat: verify arguments to params --show and --hide
tools/power turbostat: regression fix: --show C1E%
2025-08-10 09:02:36 +03:00
Linus Torvalds
b96ddbc5c8
Merge tag 'smp_urgent_for_v6.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
...
Pull smp fixes from Borislav Petkov:
- Remove an obsolete comment and fix spelling
* tag 'smp_urgent_for_v6.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
cpu: Remove obsolete comment from takedown_cpu()
smp: Fix spelling in on_each_cpu_cond_mask()'s doc-comment
2025-08-10 08:51:37 +03:00