-
Notifications
You must be signed in to change notification settings - Fork 24
Backport subject : 内核支持未对齐内存访问 #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rvck-6.6
Are you sure you want to change the base?
Conversation
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/21200083759 参数解析结果
测试完成 详细结果:RVCK result
Kunit Test Result[06:53:43] Testing complete. Ran 455 tests: passed: 443, skipped: 12 Kernel Build ResultKernel build succeeded: RVCK-Project/rvck/199/ b07c32ab664b80ebdb7b2d62e5692929 /srv/guix_result/dc1d184b6b147a64a775bcc49cd29d698eedc327/Image LAVA Checkargs:
result:Lava check done! lava log: https://lava.oerv.ac.cn/scheduler/job/1121 lava result count: [fail]: 173, [pass]: 1435, [skip]: 291 Check Patch Result
|
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/21389419343 参数解析结果
测试完成 详细结果:RVCK result
Kunit Test Result[08:13:46] Testing complete. Ran 455 tests: passed: 443, skipped: 12 Kernel Build ResultKernel build succeeded: RVCK-Project/rvck/199/ 0227f0e93954e63572bf14edb943f39e /srv/guix_result/e8b9ef1b3f08b0472278fe6b3443f2409926bceb/Image LAVA Checkargs:
result:Lava check done! lava log: https://lava.oerv.ac.cn/scheduler/job/1167 lava result count: [fail]: 175, [pass]: 1433, [skip]: 291 Check Patch Result
|
|
该PR已经完成,请老师评审,由于本PR与issues: 202代码有依赖且整体补丁较多,分两次提交,本次先提交前部分代码 |
好的,月末月初在rebase滚动分支,rebase后审阅。 |
6e7299d to
3fb06be
Compare
mainline inclusion from mainline-6.7-rc1 commit 7c83232 category: feature bugzilla: RVCK-Project#193 -------------------------------- Misalignment trap handling is only supported for M-mode and uses direct accesses to user memory. In S-mode, when handling usermode fault, this requires to use the get_user()/put_user() accessors. Implement load_u8(), store_u8() and get_insn() using these accessors for userspace and direct text access for kernel. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-3-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit 89c12fe category: feature bugzilla: RVCK-Project#193 -------------------------------- Add missing calls to account for misaligned fault event using perf_sw_event(). Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-4-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit 7c586a5 category: feature bugzilla: RVCK-Project#193 -------------------------------- This support is partially based of openSBI misaligned emulation floating point instruction support. It provides support for the existing floating point instructions (both for 32/64 bits as well as compressed ones). Since floating point registers are not part of the pt_regs struct, we need to modify them directly using some assembly. We also dirty the pt_regs status in case we modify them to be sure context switch will save FP state. With this support, Linux is on par with openSBI support. Signed-off-by: Clément Léger <cleger@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-5-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit bc38f61 category: feature bugzilla: RVCK-Project#193 -------------------------------- This sysctl tuning option allows the user to disable misaligned access handling globally on the system. This will also be used by misaligned detection code to temporarily disable misaligned access handling. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-6-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit 71c54b3 category: feature bugzilla: RVCK-Project#193 -------------------------------- hwprobe provides a way to report if misaligned access are emulated. In order to correctly populate that feature, we can check if it actually traps when doing a misaligned access. This can be checked using an exception table entry which will actually be used when a misaligned access is done from kernel mode. Signed-off-by: Clément Léger <cleger@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-8-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit 9f23a5d category: feature bugzilla: RVCK-Project#193 -------------------------------- Now that trap support is ready to handle misalignment errors in S-mode, allow the user to control the behavior of misaligned accesses using prctl(PR_SET_UNALIGN). Add an align_ctl flag in thread_struct which will be used to determine if we should SIGBUS the process or not on such fault. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20231004151405.521596-9-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit 6eb7a64 category: feature bugzilla: RVCK-Project#193 -------------------------------- This function shouldn't be __init, since it's called during hotplug. The warning says it well enough: WARNING: modpost: vmlinux: section mismatch in reference: check_unaligned_access_all_cpus+0x13a (section: .text) -> unaligned_emulation_finish (section: .init.text) Signed-off-by: Evan Green <evan@rivosinc.com> Fixes: 71c54b3 ("riscv: report misaligned accesses emulation to hwprobe") Link: https://lore.kernel.org/r/20231106231105.3141413-1-evan@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion from mainline-6.7-rc1 commit 55e0bf4 category: feature bugzilla: RVCK-Project#193 -------------------------------- Probing for misaligned access speed takes about 0.06 seconds. On a system with 64 cores, doing this in smp_callin() means it's done serially, extending boot time by 3.8 seconds. That's a lot of boot time. Instead of measuring each CPU serially, let's do the measurements on all CPUs in parallel. If we disable preemption on all CPUs, the jiffies stop ticking, so we can do this in stages of 1) everybody except core 0, then 2) core 0. The allocations are all done outside of on_each_cpu() to avoid calling alloc_pages() with interrupts disabled. For hotplugged CPUs that come in after the boot time measurement, register CPU hotplug callbacks, and do the measurement there. Interrupts are enabled in those callbacks, so they're fine to do alloc_pages() in. Reported-by: Jisheng Zhang <jszhang@kernel.org> Closes: https://lore.kernel.org/all/mhng-9359993d-6872-4134-83ce-c97debe1cf9a@palmer-ri-x1c9/T/#mae9b8f40016f9df428829d33360144dc5026bcbf Fixes: 584ea65 ("RISC-V: Probe for unaligned access speed") Signed-off-by: Evan Green <evan@rivosinc.com> Link: https://lore.kernel.org/r/20231106225855.3121724-1-evan@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/21596061406 参数解析结果
|
已经rebase了请老师继续评审, @sterling-teng CC: @fangyu0809 |
issue: #193
目前已backport L0社区系列补丁
https://lore.kernel.org/all/20231004151405.521596-1-cleger@rivosinc.com/
后续的内存对齐其它补丁下次PR提交
测试方法:
1、使用开源最新的opensbi
2、使用新的qemu
https://github.com/rivosinc/qemu/tree/dev/cleger/misaligned
3、启动tcg虚拟机
$ qemu-system-riscv64
-cpu rv64,trap-misaligned-access=true,v=true
-M virt
-m 1024M
-bios fw_dynamic.bin
-kernel Image
4、内核接管非对齐异常处理,临时添加内核测试代码(由于本PR与issues: 202代码有依赖,先提交前半部,这块处理在后面再提PR合入)
test.patch
5、运行测试用例
https://github.com/clementleger/unaligned_test