sbi_trap_redirect() does not clear SPELP when the interrupted context had no landing pad expected
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 67/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c
調査の方向性
Read lib/sbi/sbi_trap.c around the HS-mode lines 182–184 and VS-mode lines 227–229 cited in the report. Reproduce the issue with the supplied QEMU command and payload, comparing the illegal-instruction trap with ebreak. Update both paths so SPELP reflects the interrupted context’s ELP; done when both handlers return without the reported software-check exception.
索引モデルが issue の本文から書いたものです。
説明
Hi there,
At master (d0139edf), sbi_trap_redirect() only ever sets SPELP in the status register of the mode the trap is delivered to, lib/sbi/sbi_trap.c:182-184 and lib/sbi/sbi_trap.c:227-229:
/* If elp was set, set it back in mstatus */
if (elp)
regs->mstatus |= MSTATUS_SPELP;
An SPELP bit that is already 1 in sstatus or vsstatus therefore survives the trap entry. The Zicfilp rules make that bit a copy of the interrupted ELP: "When a trap is taken into privilege mode x, the xPELP is set to ELP and ELP is set to NO_LP_EXPECTED" (ISA manual, Zicfilp chapter, "Preserving Expected Landing Pad State on Traps"). A supervisor handler which returns with the sstatus it was entered with then sets ELP on SRET and takes a software-check exception for the instruction it returns to.
With qemu-system-riscv64 -M virt -cpu rv64,zicfilp=true -m 256M -nographic -bios fw_jump.bin -kernel <payload>, an S-mode payload which enables the FWFT LANDING_PAD feature and then runs
csrs sstatus, 1 << 23 /* SPELP = 1 */
csrr t2, mscratch /* illegal in S-mode, redirected by OpenSBI */
enters its stvec handler with sstatus = 0x8000000200806100 (SPELP = 1) and takes a software-check exception (scause 0x12, stval 0x2) when the handler returns. The same payload with an ebreak, which medeleg delegates to S-mode, enters the handler with sstatus = 0x8000000200006100 (SPELP = 0) and returns without a software-check exception. Expected is SPELP = 0 in both cases.
The first trap reported in #400 has the same signature (cause 0x12, tval 0x2) on a hart with landing pads enabled.
A possible fix is to clear SPELP before setting it from the ELP of the interrupted context, in the VS-mode path as well as the (H)S-mode path.
Thanks!
- 主要言語
- C
- スター
- 1.6k
- フォーク
- 734
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
riscv-software-src/opensbi のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
riscv-software-src/opensbi#425 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
riscv-software-src/opensbi#424 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
riscv-software-src/opensbi#439 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
riscv-software-src/opensbi#436 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
riscv-software-src/opensbi#435 ·
riscv-software-src/opensbi の issue をすべて見る
似ている issue
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
yugabyte/yugabyte-db#39462 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
libreswan/libreswan#3185 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
category:port-update
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信