Skip to content
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

initial version support for xuantie iommu #1

Conversation

up2u
Copy link

@up2u up2u commented Mar 18, 2022

Signed-off-by: maolijie lijie.mlj@alibaba-inc.com

Signed-off-by: maolijie <lijie.mlj@alibaba-inc.com>
@guoren83 guoren83 merged commit 9438e68 into XUANTIE-RV:linux-5.10.4-xuantie-iommu-v1 Mar 18, 2022
guoren83 pushed a commit that referenced this pull request Jan 30, 2024
We must check the return value of find_first_bit() before using the
return value as an index array since it happens to overflow the array
and then panic:

[  107.318430] Kernel BUG [#1]
[  107.319434] CPU: 3 PID: 1238 Comm: kill Tainted: G            E      6.6.0-rc6ubuntu-defconfig #2
[  107.319465] Hardware name: riscv-virtio,qemu (DT)
[  107.319551] epc : pmu_sbi_ovf_handler+0x3a4/0x3ae
[  107.319840]  ra : pmu_sbi_ovf_handler+0x52/0x3ae
[  107.319868] epc : ffffffff80a0a77c ra : ffffffff80a0a42a sp : ffffaf83fecda350
[  107.319884]  gp : ffffffff823961a8 tp : ffffaf8083db1dc0 t0 : ffffaf83fecda480
[  107.319899]  t1 : ffffffff80cafe62 t2 : 000000000000ff00 s0 : ffffaf83fecda520
[  107.319921]  s1 : ffffaf83fecda380 a0 : 00000018fca29df0 a1 : ffffffffffffffff
[  107.319936]  a2 : 0000000001073734 a3 : 0000000000000004 a4 : 0000000000000000
[  107.319951]  a5 : 0000000000000040 a6 : 000000001d1c8774 a7 : 0000000000504d55
[  107.319965]  s2 : ffffffff82451f10 s3 : ffffffff82724e70 s4 : 000000000000003f
[  107.319980]  s5 : 0000000000000011 s6 : ffffaf8083db27c0 s7 : 0000000000000000
[  107.319995]  s8 : 0000000000000001 s9 : 00007fffb45d6558 s10: 00007fffb45d81a0
[  107.320009]  s11: ffffaf7ffff60000 t3 : 0000000000000004 t4 : 0000000000000000
[  107.320023]  t5 : ffffaf7f80000000 t6 : ffffaf8000000000
[  107.320037] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[  107.320081] [<ffffffff80a0a77c>] pmu_sbi_ovf_handler+0x3a4/0x3ae
[  107.320112] [<ffffffff800b42d0>] handle_percpu_devid_irq+0x9e/0x1a0
[  107.320131] [<ffffffff800ad92c>] generic_handle_domain_irq+0x28/0x36
[  107.320148] [<ffffffff8065f9f8>] riscv_intc_irq+0x36/0x4e
[  107.320166] [<ffffffff80caf4a0>] handle_riscv_irq+0x54/0x86
[  107.320189] [<ffffffff80cb0036>] do_irq+0x64/0x96
[  107.320271] Code: 85a6 855e b097 ff7f 80e7 9220 b709 9002 4501 bbd9 (9002) 6097
[  107.320585] ---[ end trace 0000000000000000 ]---
[  107.320704] Kernel panic - not syncing: Fatal exception in interrupt
[  107.320775] SMP: stopping secondary CPUs
[  107.321219] Kernel Offset: 0x0 from 0xffffffff80000000
[  107.333051] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

Fixes: 4905ec2 ("RISC-V: Add sscofpmf extension support")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20231109082128.40777-1-alexghiti@rivosinc.com
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
guoren83 pushed a commit that referenced this pull request Feb 4, 2024
We must check the return value of find_first_bit() before using the
return value as an index array since it happens to overflow the array
and then panic:

[  107.318430] Kernel BUG [#1]
[  107.319434] CPU: 3 PID: 1238 Comm: kill Tainted: G            E      6.6.0-rc6ubuntu-defconfig #2
[  107.319465] Hardware name: riscv-virtio,qemu (DT)
[  107.319551] epc : pmu_sbi_ovf_handler+0x3a4/0x3ae
[  107.319840]  ra : pmu_sbi_ovf_handler+0x52/0x3ae
[  107.319868] epc : ffffffff80a0a77c ra : ffffffff80a0a42a sp : ffffaf83fecda350
[  107.319884]  gp : ffffffff823961a8 tp : ffffaf8083db1dc0 t0 : ffffaf83fecda480
[  107.319899]  t1 : ffffffff80cafe62 t2 : 000000000000ff00 s0 : ffffaf83fecda520
[  107.319921]  s1 : ffffaf83fecda380 a0 : 00000018fca29df0 a1 : ffffffffffffffff
[  107.319936]  a2 : 0000000001073734 a3 : 0000000000000004 a4 : 0000000000000000
[  107.319951]  a5 : 0000000000000040 a6 : 000000001d1c8774 a7 : 0000000000504d55
[  107.319965]  s2 : ffffffff82451f10 s3 : ffffffff82724e70 s4 : 000000000000003f
[  107.319980]  s5 : 0000000000000011 s6 : ffffaf8083db27c0 s7 : 0000000000000000
[  107.319995]  s8 : 0000000000000001 s9 : 00007fffb45d6558 s10: 00007fffb45d81a0
[  107.320009]  s11: ffffaf7ffff60000 t3 : 0000000000000004 t4 : 0000000000000000
[  107.320023]  t5 : ffffaf7f80000000 t6 : ffffaf8000000000
[  107.320037] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[  107.320081] [<ffffffff80a0a77c>] pmu_sbi_ovf_handler+0x3a4/0x3ae
[  107.320112] [<ffffffff800b42d0>] handle_percpu_devid_irq+0x9e/0x1a0
[  107.320131] [<ffffffff800ad92c>] generic_handle_domain_irq+0x28/0x36
[  107.320148] [<ffffffff8065f9f8>] riscv_intc_irq+0x36/0x4e
[  107.320166] [<ffffffff80caf4a0>] handle_riscv_irq+0x54/0x86
[  107.320189] [<ffffffff80cb0036>] do_irq+0x64/0x96
[  107.320271] Code: 85a6 855e b097 ff7f 80e7 9220 b709 9002 4501 bbd9 (9002) 6097
[  107.320585] ---[ end trace 0000000000000000 ]---
[  107.320704] Kernel panic - not syncing: Fatal exception in interrupt
[  107.320775] SMP: stopping secondary CPUs
[  107.321219] Kernel Offset: 0x0 from 0xffffffff80000000
[  107.333051] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

Fixes: 4905ec2 ("RISC-V: Add sscofpmf extension support")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20231109082128.40777-1-alexghiti@rivosinc.com
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
guoren83 added a commit that referenced this pull request Feb 6, 2024
The callee saved fp & ra are xlen size, not long size. This patch
corrects the layout for the struct stackframe.

echo c > /proc/sysrq-trigger

Before the patch:

sysrq: Trigger a crash
Kernel panic - not syncing: sysrq triggered crash
CPU: 0 PID: 102 Comm: sh Not tainted 6.3.0-rc1-00084-g9e2ba938797e-dirty #2
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
---[ end Kernel panic - not syncing: sysrq triggered crash ]---

After the patch:

sysrq: Trigger a crash
Kernel panic - not syncing: sysrq triggered crash
CPU: 0 PID: 102 Comm: sh Not tainted 6.3.0-rc1-00084-g9e2ba938797e-dirty #1
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
[<c00050c8>] dump_backtrace+0x1e/0x26
[<c086dcae>] show_stack+0x2e/0x3c
[<c0878e00>] dump_stack_lvl+0x40/0x5a
[<c0878e30>] dump_stack+0x16/0x1e
[<c086df7c>] panic+0x10c/0x2a8
[<c04f4c1e>] sysrq_reset_seq_param_set+0x0/0x76
[<c04f52cc>] __handle_sysrq+0x9c/0x19c
[<c04f5946>] write_sysrq_trigger+0x64/0x78
[<c020c7f6>] proc_reg_write+0x4a/0xa2
[<c01acf0a>] vfs_write+0xac/0x308
[<c01ad2b8>] ksys_write+0x62/0xda
[<c01ad33e>] sys_write+0xe/0x16
[<c0879860>] do_trap_ecall_u+0xd8/0xda
[<c00037de>] ret_from_exception+0x0/0x66
---[ end Kernel panic - not syncing: sysrq triggered crash ]---

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
guoren83 pushed a commit that referenced this pull request Feb 6, 2024
We must check the return value of find_first_bit() before using the
return value as an index array since it happens to overflow the array
and then panic:

[  107.318430] Kernel BUG [#1]
[  107.319434] CPU: 3 PID: 1238 Comm: kill Tainted: G            E      6.6.0-rc6ubuntu-defconfig #2
[  107.319465] Hardware name: riscv-virtio,qemu (DT)
[  107.319551] epc : pmu_sbi_ovf_handler+0x3a4/0x3ae
[  107.319840]  ra : pmu_sbi_ovf_handler+0x52/0x3ae
[  107.319868] epc : ffffffff80a0a77c ra : ffffffff80a0a42a sp : ffffaf83fecda350
[  107.319884]  gp : ffffffff823961a8 tp : ffffaf8083db1dc0 t0 : ffffaf83fecda480
[  107.319899]  t1 : ffffffff80cafe62 t2 : 000000000000ff00 s0 : ffffaf83fecda520
[  107.319921]  s1 : ffffaf83fecda380 a0 : 00000018fca29df0 a1 : ffffffffffffffff
[  107.319936]  a2 : 0000000001073734 a3 : 0000000000000004 a4 : 0000000000000000
[  107.319951]  a5 : 0000000000000040 a6 : 000000001d1c8774 a7 : 0000000000504d55
[  107.319965]  s2 : ffffffff82451f10 s3 : ffffffff82724e70 s4 : 000000000000003f
[  107.319980]  s5 : 0000000000000011 s6 : ffffaf8083db27c0 s7 : 0000000000000000
[  107.319995]  s8 : 0000000000000001 s9 : 00007fffb45d6558 s10: 00007fffb45d81a0
[  107.320009]  s11: ffffaf7ffff60000 t3 : 0000000000000004 t4 : 0000000000000000
[  107.320023]  t5 : ffffaf7f80000000 t6 : ffffaf8000000000
[  107.320037] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[  107.320081] [<ffffffff80a0a77c>] pmu_sbi_ovf_handler+0x3a4/0x3ae
[  107.320112] [<ffffffff800b42d0>] handle_percpu_devid_irq+0x9e/0x1a0
[  107.320131] [<ffffffff800ad92c>] generic_handle_domain_irq+0x28/0x36
[  107.320148] [<ffffffff8065f9f8>] riscv_intc_irq+0x36/0x4e
[  107.320166] [<ffffffff80caf4a0>] handle_riscv_irq+0x54/0x86
[  107.320189] [<ffffffff80cb0036>] do_irq+0x64/0x96
[  107.320271] Code: 85a6 855e b097 ff7f 80e7 9220 b709 9002 4501 bbd9 (9002) 6097
[  107.320585] ---[ end trace 0000000000000000 ]---
[  107.320704] Kernel panic - not syncing: Fatal exception in interrupt
[  107.320775] SMP: stopping secondary CPUs
[  107.321219] Kernel Offset: 0x0 from 0xffffffff80000000
[  107.333051] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

Fixes: 4905ec2 ("RISC-V: Add sscofpmf extension support")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20231109082128.40777-1-alexghiti@rivosinc.com
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
guoren83 added a commit that referenced this pull request Feb 6, 2024
This bug is come from faulting in PGD entries [1], rv32 ISA can't
solve it because of its satp design. This problem has been solved
in both s64ilp32 and s64lp64. Only s32ilp32 has the problem.

 clk: Disabling unused clocks
 dw-apb-uart 1900d000.serial: forbid DMA for kernel console
 Unable to handle kernel paging request at virtual address c0c00000
 Oops [#1]
 Modules linked in:
 CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.6.0 #7
 Hardware name: T-HEAD C9XX (DT)
 epc : __memset+0x58/0xf8
  ra : free_reserved_area+0x148/0x186
 epc : c08483c8 ra : c014e330 sp : c206ff00
  gp : c1cb8fe8 tp : c20f8000 t0 : c0c00000
  t1 : 5fc00000 t2 : 00000011 s0 : c206ff50
  s1 : 000000cc a0 : c0c00000 a1 : cccccccc
  a2 : 00001000 a3 : c0c01000 a4 : 00000000
  a5 : 000000ff a6 : 00000001 a7 : 52464e43
  s2 : c1017000 s3 : ffffffff s4 : 00000000
  s5 : ffffbfff s6 : c1cbb834 s7 : c1ce5e80
  s8 : c15f2220 s9 : c0c00000 s10: ff320000
  s11: 00000001 t3 : 0000000f t4 : e0000000
  t5 : 00000004 t6 : c2939011
 status: 00008120 badaddr: c0c00000 cause: 0000000f
 [<c08483c8>] __memset+0x58/0xf8
 [<c000416e>] free_initmem+0x74/0x82
 [<c0856bf6>] kernel_init+0x3a/0x106
 [<c00035ba>] ret_from_fork+0xa/0x1c
 Code: 0713 0807 82b3 40e2 0797 0000 8793 00c7 97ba 8782 (a023) 00b2
 ---[ end trace 0000000000000000 ]---
 Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

[1]: https://lore.kernel.org/lkml/20230529180023.289904-1-bjorn@kernel.org/
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
guoren83 pushed a commit that referenced this pull request Apr 7, 2024
…s in tail_call

This patch solves the 10 tail_call testing issues in test_bpf.
At this point, all tests of test_bpf in BPF_JIT mode have passed.
Here is the comparison between s64ilp32, s64lp64 and s32ilp32:

- s64lp64

```
...
test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed]
test_bpf: #0 Tail call leaf jited:1 188 PASS
test_bpf: #1 Tail call 2 jited:1 180 PASS
test_bpf: #2 Tail call 3 jited:1 203 PASS
test_bpf: #3 Tail call 4 jited:1 225 PASS
test_bpf: #4 Tail call load/store leaf jited:1 145 PASS
test_bpf: #5 Tail call load/store jited:1 195 PASS
test_bpf: #6 Tail call error path, max count reached jited:1 997 PASS
test_bpf: #7 Tail call count preserved across function calls jited:1 155563 PASS
test_bpf: #8 Tail call error path, NULL target jited:1 164 PASS
test_bpf: #9 Tail call error path, index out of range jited:1 136 PASS
test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
...
test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED
```

- s64ilp32

```
...
test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed]
test_bpf: #0 Tail call leaf jited:1 160 PASS
test_bpf: #1 Tail call 2 jited:1 221 PASS
test_bpf: #2 Tail call 3 jited:1 251 PASS
test_bpf: #3 Tail call 4 jited:1 275 PASS
test_bpf: #4 Tail call load/store leaf jited:1 198 PASS
test_bpf: #5 Tail call load/store jited:1 262 PASS
test_bpf: #6 Tail call error path, max count reached jited:1 1390 PASS
test_bpf: #7 Tail call count preserved across function calls jited:1 204492 PASS
test_bpf: #8 Tail call error path, NULL target jited:1 199 PASS
test_bpf: #9 Tail call error path, index out of range jited:1 168 PASS
test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
...
test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED
```

- s32ilp32

```
...
test_bpf: Summary: 1027 PASSED, 0 FAILED, [832/1015 JIT'ed]
test_bpf: #0 Tail call leaf jited:1 266 PASS
test_bpf: #1 Tail call 2 jited:1 409 PASS
test_bpf: #2 Tail call 3 jited:1 481 PASS
test_bpf: #3 Tail call 4 jited:1 537 PASS
test_bpf: #4 Tail call load/store leaf jited:1 325 PASS
test_bpf: #5 Tail call load/store jited:1 427 PASS
test_bpf: #6 Tail call error path, max count reached jited:1 3050 PASS
test_bpf: #7 Tail call count preserved across function calls jited:1 255522 PASS
test_bpf: #8 Tail call error path, NULL target jited:1 315 PASS
test_bpf: #9 Tail call error path, index out of range jited:1 280 PASS
test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
...
test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED
```

Actually, s64ilp32 and s64lp64 perform consistently, both in terms of the number
that can be executed by JIT and execution time. while, only 80% of cases in s32ilp32
can be executed by JIT, and the execution time is also longer under the same JIT
execution situation.

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
MarekPikula pushed a commit to MarekPikula/linux-thead-canmv that referenced this pull request Apr 10, 2024
The vendor mode is not always at config XUANTIE-RV#1, so it is necessary to
set the correct configuration number.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit c219894)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants