target/riscv: fix riscv_cpu_sirq_pending() mask
PATCH 1/1 target/riscv: fix riscv_cpu_sirq_pending() mask
We're filtering out (MIP_VSSIP | MIP_VSTIP | MIP_VSEIP) from S-mode pending interrupts without apparent reason. There's no special treatment for these ints as far as the spec goes, and this filtering is causing read_stopi() to miss those VS interrupts [1].
We shouldn't return delegated VS interrupts in S-mode though, so change the current mask with "~env->hideleg". Note that this is the same handling we're doing in riscv_cpu_mirq_pending() and env->mideleg.
[1] https://gitlab.com/qemu-project/qemu/-/issues/2820
--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/riscv/cpu_helper.c +1 -2
@@ -443,8 +443,7 @@ int riscv_cpu_mirq_pending(CPURISCVState *env)int riscv_cpu_sirq_pending (CPURISCVState *env) { -uint64_t irqs =riscv_cpu_all_pending (env) & env->mideleg & - ~(MIP_VSSIP |MIP_VSTIP |MIP_VSEIP ); +uint64_t irqs =riscv_cpu_all_pending (env) & env->mideleg & ~env->hideleg;uint64_t irqs_f = env->mvip & env->mvien & ~env->mideleg & env->sie; return riscv_cpu_pending_to_irq(env, IRQ_S_EXT, IPRIO_DEFAULT_S,
Signature · 1 line
2.51.0
Quoted 6 lines · Daniel Henrique Barboza
We're filtering out (
MIP_VSSIP|MIP_VSTIP|MIP_VSEIP) from S-mode pending interrupts without apparent reason. There's no special treatment for these ints as far as the spec goes, and this filtering is causingread_stopi()to miss those VS interrupts [1].
Quoted 8 lines
We shouldn't return delegated VS interrupts in S-mode though, so change the current mask with "~env->hideleg". Note that this is the same handling we're doing in
riscv_cpu_mirq_pending()andenv->mideleg.
Alistair
Quoted 22 lines
--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/cpu_helper.c +1
-3@@ -443,8 +443,7 @@ int riscv_cpu_mirq_pending(CPURISCVState *env)int riscv_cpu_sirq_pending (CPURISCVState *env) { -uint64_t irqs =riscv_cpu_all_pending (env) & env->mideleg & - ~(MIP_VSSIP |MIP_VSTIP |MIP_VSEIP ); +uint64_t irqs =riscv_cpu_all_pending (env) & env->mideleg & ~env->hideleg;uint64_t irqs_f = env->mvip & env->mvien & ~env->mideleg & env->sie; return riscv_cpu_pending_to_irq(env, IRQ_S_EXT, IPRIO_DEFAULT_S, --2.51.0
Alistair Francis
AppliedQuoted 6 lines · Daniel Henrique Barboza
We're filtering out (
MIP_VSSIP|MIP_VSTIP|MIP_VSEIP) from S-mode pending interrupts without apparent reason. There's no special treatment for these ints as far as the spec goes, and this filtering is causingread_stopi()to miss those VS interrupts [1].
Quoted 8 lines
We shouldn't return delegated VS interrupts in S-mode though, so change the current mask with "~env->hideleg". Note that this is the same handling we're doing in
riscv_cpu_mirq_pending()andenv->mideleg.
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 22 lines
--- target/riscv/cpu_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/cpu_helper.c +1
-3@@ -443,8 +443,7 @@ int riscv_cpu_mirq_pending(CPURISCVState *env)int riscv_cpu_sirq_pending (CPURISCVState *env) { -uint64_t irqs =riscv_cpu_all_pending (env) & env->mideleg & - ~(MIP_VSSIP |MIP_VSTIP |MIP_VSEIP ); +uint64_t irqs =riscv_cpu_all_pending (env) & env->mideleg & ~env->hideleg;uint64_t irqs_f = env->mvip & env->mvien & ~env->mideleg & env->sie; return riscv_cpu_pending_to_irq(env, IRQ_S_EXT, IPRIO_DEFAULT_S, --2.51.0