riscv: backport prerequisites for user CFI support#284
riscv: backport prerequisites for user CFI support#284zhuzhenxxx-collab wants to merge 8 commits into
Conversation
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26393444735 参数解析结果
测试完成 详细结果:
Kunit Test Result[09:31:38] Testing complete. Ran 457 tests: passed: 445, skipped: 12
Check Patch Result
|
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26393444735 参数解析结果
测试完成 详细结果:
Kunit Test Result[03:24:35] Testing complete. Ran 457 tests: passed: 445, skipped: 12
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check fail!
LAVA Check (sg2042)
result: Lava check fail!
LAVA Check (spacemit-k1-bananapi-f3)
result: Lava check fail!
LAVA Check (lpi4a)
result: Lava check fail!
|
|
请尽快解决CI报错,或者澄清原因。 |
|
/check 开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26564460672 参数解析结果
测试完成 详细结果:
Kunit Test Result[08:49:23] Testing complete. Ran 457 tests: passed: 445, skipped: 12
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check fail!
LAVA Check (sg2042)
result: Lava check done!
LAVA Check (spacemit-k1-bananapi-f3)
result: Lava check fail!
LAVA Check (lpi4a)
result: Lava check fail!
|
|
/check 开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26624573534 参数解析结果
测试完成 详细结果:
Kunit Test Result[07:39:33] Testing complete. Ran 457 tests: passed: 445, skipped: 12
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
|
/check 开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26635547609 参数解析结果
测试完成 详细结果:
Kunit Test Result[11:53:21] Testing complete. Ran 457 tests: passed: 445, skipped: 12
Kernel Build Result
Check Patch Result
|
|
该pr未在rebase合并窗口关闭前完成补丁修改,赶不上5月份的合并了,6月rebase后继续审阅。 |
mainline inclusion from mainline-7.0 commit 2fd0eba ("arch: Reserve map_shadow_stack() syscall number for all architectures") category: feature Link: RVCK-Project#255 -------------------------------- commit c35559f ("x86/shstk: Introduce map_shadow_stack syscall") recently added support for map_shadow_stack() but it is limited to x86 only for now. There is a possibility that other architectures (namely, arm64 and RISC-V), that are implementing equivalent support for shadow stacks, might need to add support for it. Independent of that, reserving arch-specific syscall numbers in the syscall tables of all architectures is good practice and would help avoid future conflicts. map_shadow_stack() is marked as a conditional syscall in sys_ni.c. Adding it to the syscall tables of other architectures is harmless and would return ENOSYS when exercised. Note, map_shadow_stack() was assigned #453 during the merge process since #452 was taken by fchmodat2(). For Powerpc, map it to sys_ni_syscall() as is the norm for Powerpc syscall tables. For Alpha, map_shadow_stack() takes up #563 as Alpha still diverges from the common syscall numbering system in the other architectures. Link: https://lore.kernel.org/lkml/20230515212255.GA562920@debug.ba.rivosinc.com/ Link: https://lore.kernel.org/lkml/b402b80b-a7c6-4ef0-b977-c0f5f582b78a@sirena.org.uk/ Signed-off-by: Sohil Mehta <sohil.mehta@intel.com> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-6.19 commit 818d78b ("riscv: signal: abstract header saving for setup_sigcontext") category: feature bugzilla: RVCK-Project#255 -------------------------------- The function save_v_state() served two purposes. First, it saved extension context into the signal stack. Then, it constructed the extension header if there was no fault. The second part is independent of the extension itself. As a result, we can pull that part out, so future extensions may reuse it. This patch adds arch_ext_list and makes setup_sigcontext() go through all possible extensions' save() callback. The callback returns a positive value indicating the size of the successfully saved extension. Then the kernel proceeds to construct the header for that extension. The kernel skips an extension if it does not exist, or if the saving fails for some reasons. The error code is propagated out on the later case. This patch does not introduce any functional changes. Signed-off-by: Andy Chiu <andybnac@gmail.com> Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-16-b55691eacf4f@rivosinc.com Signed-off-by: Paul Walmsley <pjw@kernel.org> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-7.0 commit 81723e3 ("random: vDSO: add missing c-getrandom-y in Makefile") category: feature Link: RVCK-Project#255 -------------------------------- Same as for the gettimeofday CVDSO implementation, add c-getrandom-y to ease the inclusion of lib/vdso/getrandom.c in architectures' VDSO builds. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-7.0 commit ee0d030 ("RISC-V: vDSO: Wire up getrandom() vDSO implementation") category: feature Link: RVCK-Project#255 -------------------------------- Hook up the generic vDSO implementation to the generic vDSO getrandom implementation by providing the required __arch_chacha20_blocks_nostack and getrandom_syscall implementations. Also wire up the selftests. The benchmark result: vdso: 25000000 times in 2.466341333 seconds libc: 25000000 times in 41.447720005 seconds syscall: 25000000 times in 41.043926672 seconds vdso: 25000000 x 256 times in 162.286219353 seconds libc: 25000000 x 256 times in 2953.855018685 seconds syscall: 25000000 x 256 times in 2796.268546000 seconds [ alex: - Fix dynamic relocation - Squash Nathan's fix https://lore.kernel.org/all/20250423-riscv-fix-compat_vdso-lld-v2-1-b7bbbc244501@kernel.org/ - Add comment from Loongarch ] Signed-off-by: Xi Ruoyao <xry111@xry111.site> Link: https://lore.kernel.org/r/20250411024600.16045-1-xry111@xry111.site Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-7.0 commit f955aa8 ("riscv: entry: Convert ret_from_fork() to C") category: feature Link: RVCK-Project#255 -------------------------------- Move the main section of ret_from_fork() to C to allow inlining of syscall_exit_to_user_mode(). Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/all/20250320-riscv_optimize_entry-v6-1-63e187e26041@rivosinc.com Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-7.0 commit 5b3d610 ("riscv: entry: Split ret_from_fork() into user and kernel") category: feature Link: RVCK-Project#255 -------------------------------- This function was unified into a single function in commit ab9164d ("riscv: entry: Consolidate ret_from_kernel_thread into ret_from_fork"). However that imposed a performance degradation. Partially reverting this commit to have ret_from_fork() split again, results in a 1% increase on the number of times fork is able to be called per second. Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/all/20250320-riscv_optimize_entry-v6-2-63e187e26041@rivosinc.com Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-7.0 commit ad14f7c ("riscv: hwprobe: do not produce frtace relocation") category: feature Link: RVCK-Project#255 -------------------------------- Such relocation causes crash of android linker similar to one described in commit e05d57d ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace"). Looks like this relocation is added by CONFIG_DYNAMIC_FTRACE which is disabled in the default android kernel. Before: readelf -rW arch/riscv/kernel/vdso/vdso.so: Relocation section '.rela.dyn' at offset 0xd00 contains 1 entry: Offset Info Type 0000000000000d20 0000000000000003 R_RISCV_RELATIVE objdump: 0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>: c86: 0001 nop c88: 0001 nop c8a: 0001 nop c8c: 0001 nop c8e: e211 bnez a2,c92 <__vdso_riscv_hwprobe... After: readelf -rW arch/riscv/kernel/vdso/vdso.so: There are no relocations in this file. objdump: 0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>: c86: e211 bnez a2,c8a <__vdso_riscv_hwprobe... c88: c6b9 beqz a3,cd6 <__vdso_riscv_hwprobe... c8a: e739 bnez a4,cd8 <__vdso_riscv_hwprobe... c8c: ffffd797 auipc a5,0xffffd Also disable SCS since it also should not be available in vdso. Fixes: aa5af0a ("RISC-V: Add hwprobe vDSO function and data") Signed-off-by: Roman Artemev <roman.artemev@syntacore.com> Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Guo Ren <guoren@kernel.org> Link: https://lore.kernel.org/r/20240313085843.17661-1-vladimir.isaev@syntacore.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion from mainline-7.0 commit 9a0ebe5 ("kbuild: use $(obj)/ instead of $(src)/ for common pattern rules") category: feature Link: RVCK-Project#255 -------------------------------- Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for checked-in source files. It is merely a convention without any functional difference. In fact, $(obj) and $(src) are exactly the same, as defined in scripts/Makefile.build: src := $(obj) Before changing the semantics of $(src) in the next commit, this commit replaces $(obj)/ with $(src)/ in pattern rules where the prerequisite might be a generated file. C, assembly, Rust, and DTS files are sometimes generated by tools, so they could be either generated files or real sources. The $(obj)/ prefix works for both cases with the help of VPATH. As mentioned above, $(obj) and $(src) are the same at this point, hence this commit has no functional change. I did not modify scripts/Makefile.userprogs because there is no use case where userspace C files are generated. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
2294edb to
f45374c
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26792655457 参数解析结果
测试完成 详细结果:
Kunit Test Result[01:32:51] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
|
CI kernel-build 连续失败,未进入编译阶段。guix time-machine 在 Docker 容器内重试 10 次均报错: 看起来是容器内 /tmp(tmpfs)与 Guix store 跨文件系统导致 rename(2) 返回 EXDEV。 麻烦帮忙看下 Runner 或 guix-kernel-cross-build:release 镜像是否有变更?谢谢! |
f45374c to
5b9e031
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26809448849 参数解析结果
测试完成 详细结果:
Kunit Test Result[09:02:27] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
|
|
/check 开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26859503502 参数解析结果
测试完成 详细结果:
Kunit Test Result[02:15:08] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
测试完成 详细结果:
Kunit Test Result[02:15:08] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26859503502 参数解析结果
测试完成 详细结果:
Kunit Test Result[13:28:04] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26809448849 参数解析结果
测试完成 详细结果:
Kunit Test Result[10:04:00] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
|
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26809448849 参数解析结果
测试完成 详细结果:
Kunit Test Result[02:35:25] Testing complete. Ran 482 tests: passed: 466, skipped: 16
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
|
@sterling-teng Please merge this pr |
Description
This PR backports the prerequisite patches required by RISC-V user-mode CFI.
It does not enable user CFI by itself, but prepares the syscall, signal, vDSO, entry, and kbuild dependencies for the follow-up CFI series.
Patch list
Link: #255