Giter Club home page Giter Club logo

uintr's Introduction

uintr's People

Contributors

tkf2019 avatar

Stargazers

 avatar

uintr's Issues

用户态中断发送者状态表的内存申请问题

  1. 需要将内存pin到物理内存中,防止该页面被换出换入导致其起始物理地址被修改,同时也可以防止攻击者通过修改换出的页面篡改发送者状态表
  2. 需要分配4KB对齐的连续物理内存

建议代码可以修改为

uist = alloc_pages(GFP_HIGHUSER, 1);

关于用户态中断若干概念的命名问题

SenderVector

原始命名

在接收方创建文件描述符的时候,需要向其中传递一个值用于区分不同的发送方,这个值也会被记录到了发送者状态中。目前这个值被命名为了SenderVector,中文翻译的时候将其翻译为了中断向量。

建议命名

建议将这个值命名为为SenderIdentifier,中文命发送者标识。这个值主要是接收方用来区分不同的发送者的,将其命名为SenderIdentifier更容易明确其含义,同时也不会与中断向量相混淆。在S-mode下的中断处理中,中断向量(vector)实际上指代的时中断服务程序的首地址。

sbi_trap_error

环境

  • qemu 3f9a163171b31d8f31453c427ec83fb070a7a525
  • Linux d082314cafcae39c848885b022dc29b2ec93a009
  • ipc-bench 826e7460544be243d79dcc924fcdc6681a5f48ca

linux编译命令

bear make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- defconfig
bear make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j $(nproc)

qemu编译命令

../configure --target-list=riscv64-softmmu,riscv64-linux-user
make -j16

运行脚本

export HOST_PORT=4920;
export QEMU=/root/qemu/build/riscv64-softmmu/qemu-system-riscv64;
export KERNEL=/root/linux/arch/riscv/boot/Image;

$QEMU \
 -m 2G \
 -nographic \
 -machine virt \
 -kernel $KERNEL \
 -append "console=ttyS0 ro root=/dev/vda"   \
 -drive file=/root/rootfs.ext2,format=raw,id=hd0 \
 -device virtio-blk-device,drive=hd0    \
 -netdev user,id=net0,net=192.168.100.1/24,dhcpstart=192.168.100.128,hostfwd=tcp::${HOST_PORT}-:22 \
 -device virtio-net-device,netdev=net0 \
 -device virtio-rng-pci \
 -smp 4

复现步骤

在启动Linux内核之后,运行ipc-bench/build/source/uintrfd/uintrfd-uni

log

启动log(部分)

**** Running QEMU SSH on port 4920 ****
qemu-system-riscv64: SOCKET 0 BASE 0 COUNT 4

Realizing RISC-V CPU ...
RISC-V N implemented
Realizing RISC-V CPU ...
RISC-V N implemented
Realizing RISC-V CPU ...
RISC-V N implemented
Realizing RISC-V CPU ...
RISC-V N implemented
Create UINTC
qemu-system-riscv64: info: RISCV UINTC REALIZE: base_hartid=0x0 num_harts=0x4
qemu-system-riscv64: info: LOW 0x0 HIGH 0x4000
qemu-system-riscv64: info: FDT memory size 0x80000000


OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 4
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 276 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*,1*,2*,3*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x00000000bf000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcnsuh
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509
[    0.000000] Linux version 6.0.0-gd082314cafca (root@b664db5da1b1) (riscv64-unknown-linux-gnu-gcc (g) 12.2.0, GNU ld (GNU Binutils) 2.40.0.20230214) #1 SMP Thu May 4 04:34:18 UTC 2023

报错log

当执行ipc-bench/build/source/uintrfd/uintrfd-uni之后就会出现以下报错:

[   22.231738] [CPU 2] uintr: [sys_uintr_register_receiver        ]: receiver=150 entry=0
[   22.232458] [CPU 2] uintr: [__do_sys_uintr_create_fd           ]: receiver=150 uvec=1 uintrfd=3
[   22.240406] [CPU 3] uintr: [__do_sys_uintr_register_sender     ]: sender=151 entry=0 va=ff60000002679000
sbi_trap_error: hart2: unhandled external interrupt (error -2)
sbi_trap_error: hart2: mcause=0x0000000000000000 mtval=0x0000000000000000
sbi_trap_error: hart2: mtval2=0x0000000000000000 mtinst=0x0000000000000000
sbi_trap_error: hart2: mepc=0xffffffff80003254 mstatus=0x0000000a00004820
sbi_trap_error: hart2: ra=0x000000000001155c sp=0x00ffffffe2584f10
sbi_trap_error: hart2: gp=0x0000000000013800 tp=0x00ffffffb16927b0
sbi_trap_error: hart2: s0=0x00ffffffe2586a68 s1=0x0000000000000003
sbi_trap_error: hart2: a0=0x00ffffffe2585008 a1=0x000000000001144c
sbi_trap_error: hart2: a2=0x0000000000000000 a3=0x00000000000003e8
sbi_trap_error: hart2: a4=0x0000000000013194 a5=0x0000000000000000
sbi_trap_error: hart2: a6=0x00ffffffb1691220 a7=0x0000000000000087
sbi_trap_error: hart2: s2=0x0000000000000000 s3=0x0000000000012e08
sbi_trap_error: hart2: s4=0x0000000000011330 s5=0x00ffffffe2586c38
sbi_trap_error: hart2: s6=0x0000000000012e08 s7=0x00ffffffb18af208
sbi_trap_error: hart2: s8=0x00aaaaaad04a2b50 s9=0x00aaaaaad04a52e0
sbi_trap_error: hart2: s10=0x00aaaaaad04c2d70 s11=0x0000000000000000
sbi_trap_error: hart2: t0=0x00ffffffb1698748 t1=0x00000000007ff9c0
sbi_trap_error: hart2: t2=0x0000000000013200 t3=0x00ffffffb0e91000
sbi_trap_error: hart2: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart2: t6=0x0000000000000040
[   43.246466] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[   43.247341] rcu:     2-...0: (7 ticks this GP) idle=76ec/1/0x4000000000000000 softirq=811/813 fqs=2190
[   43.248345]  (detected by 3, t=5252 jiffies, g=277, q=1 ncpus=4)
[   43.250026] Task dump for CPU 2:
[   43.250892] task:uintrfd-uni     state:R  running task     stack:    0 pid:  150 ppid:   148 flags:0x00000008
[   43.254067] Call Trace:
[   62.442548] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 39s!
[   62.444695] Showing busy workqueues and worker pools:
[   62.446623] workqueue mm_percpu_wq: flags=0x8
[   62.447899]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[   62.448146]     pending: vmstat_update
[   93.162365] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 70s!
[   93.164279] Showing busy workqueues and worker pools:
[   93.165639] workqueue mm_percpu_wq: flags=0x8
[   93.167847]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[   93.167973]     pending: vmstat_update
[  106.274358] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[  106.275680] rcu:     2-...0: (7 ticks this GP) idle=76ec/1/0x4000000000000000 softirq=811/813 fqs=8741
[  106.277365]  (detected by 0, t=21009 jiffies, g=277, q=1 ncpus=4)
[  106.279312] Task dump for CPU 2:
[  106.280567] task:uintrfd-uni     state:R  running task     stack:    0 pid:  150 ppid:   148 flags:0x00000008
[  106.283772] Call Trace:
[  123.882364] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 101s!
[  123.883121] Showing busy workqueues and worker pools:
[  123.883523] workqueue mm_percpu_wq: flags=0x8
[  123.883919]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  123.883975]     pending: vmstat_update
[  154.602425] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 131s!
[  154.604324] Showing busy workqueues and worker pools:
[  154.605762] workqueue mm_percpu_wq: flags=0x8
[  154.607248]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  154.607572]     pending: vmstat_update
[  169.294291] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[  169.295677] rcu:     2-...0: (7 ticks this GP) idle=76ec/1/0x4000000000000000 softirq=811/813 fqs=15276
[  169.297707]  (detected by 0, t=36764 jiffies, g=277, q=1 ncpus=4)
[  169.299730] Task dump for CPU 2:
[  169.301040] task:uintrfd-uni     state:R  running task     stack:    0 pid:  150 ppid:   148 flags:0x00000008
[  169.303649] Call Trace:
[  185.322429] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 162s!
[  185.323435] Showing busy workqueues and worker pools:
[  185.324594] workqueue mm_percpu_wq: flags=0x8
[  185.325572]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  185.325700]     pending: vmstat_update
[  216.042505] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 193s!
[  216.044065] Showing busy workqueues and worker pools:
[  216.045019] workqueue mm_percpu_wq: flags=0x8
[  216.046161]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  216.046771]     pending: vmstat_update
[  232.314513] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[  232.315617] rcu:     2-...0: (7 ticks this GP) idle=76ec/1/0x4000000000000000 softirq=811/813 fqs=21800
[  232.317664]  (detected by 0, t=52519 jiffies, g=277, q=1 ncpus=4)
[  232.319839] Task dump for CPU 2:
[  232.320931] task:uintrfd-uni     state:R  running task     stack:    0 pid:  150 ppid:   148 flags:0x00000008
[  232.324038] Call Trace:
[  246.762364] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 223s!
[  246.763385] Showing busy workqueues and worker pools:
[  246.764443] workqueue mm_percpu_wq: flags=0x8
[  246.765748]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  246.765824]     pending: vmstat_update
[  277.482721] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 254s!
[  277.484853] Showing busy workqueues and worker pools:
[  277.486125] workqueue mm_percpu_wq: flags=0x8
[  277.487902]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  277.488109]     pending: vmstat_update
[  295.334312] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[  295.335528] rcu:     2-...0: (7 ticks this GP) idle=76ec/1/0x4000000000000000 softirq=811/813 fqs=28360
[  295.337417]  (detected by 0, t=68274 jiffies, g=277, q=1 ncpus=4)
[  295.338995] Task dump for CPU 2:
[  295.339951] task:uintrfd-uni     state:R  running task     stack:    0 pid:  150 ppid:   148 flags:0x00000008
[  295.341344] Call Trace:
[  308.202568] BUG: workqueue lockup - pool cpus=2 node=0 flags=0x0 nice=0 stuck for 285s!
[  308.204124] Showing busy workqueues and worker pools:
[  308.206077] workqueue mm_percpu_wq: flags=0x8
[  308.207360]   pwq 4: cpus=2 node=0 flags=0x0 nice=0 active=1/256 refcnt=2
[  308.207455]     pending: vmstat_update

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.