From: Jose Martins <josemartins90@gmail.com> To: LIU Zhiwei <zhiwei_liu@c-sky.com> Cc: "open list:RISC-V TCG CPUs" <qemu-riscv@nongnu.org>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com> Subject: Re: [PATCH v3] target/riscv: fix VS interrupts forwarding to HS Date: Wed, 26 May 2021 12:50:32 +0100 [thread overview] Message-ID: <CAC41xo3XAWZrqtFxiLDQ+H4fr=FVkWmZfe8P+PaTx-MPU_fpfw@mail.gmail.com> (raw) In-Reply-To: <94455d68-c088-5875-d115-acd95829406e@c-sky.com> Hello Zhiwei, thank you for reviewing the patch. I'll split the patch in a series as you suggest. But first can you help me understand what the problems are with riscv_cpu_local_irq_pending? > I think there are two errors in riscv_cpu_local_irq_pending. > > 1) VS interrupts can't be forwarded to hs-mode rightly . It has > nothing to do with delegate or not in hideleg. The reason is that > VS interrupts are always discarded when V=0 in > riscv_cpu_local_irq_pending. I don't see why this is the case. The way I see it, VS interrupts are only discarded for V=0 *iff* they are delegated in mideleg/hideleg. I actually tested it and I see the correct forwarding of vs-mode interrupts to hs-mode. I tested it by running in hs-mode with all the needed interrupt enables set, the interrupts not delegated in hideleg, and forcing the trigger of the interrupt by writing hvip. But maybe there are some corner cases I'm not taking into account. Can you explain this further? Maybe walk me through an example of when this issue might occur. > 2) Use MSTATUS_SIE in mstatus_hs to select pending_hs_irqs. I don't think you need to go through mstatus_hs to get the correct sie state. My logic behind this is: env->mstatus will have the vs-level sie if V=1 and hs-level sie if V=0. Due to the short-circuiting property of the logic operators the sie variable will only have an effect on hsie if V=0 and on vsie if V=1. So the value of sie is only used in the correct context. Again, please correct me if I'm wrong. I might be missing something. Best, José
WARNING: multiple messages have this Message-ID (diff)
From: Jose Martins <josemartins90@gmail.com> To: LIU Zhiwei <zhiwei_liu@c-sky.com> Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>, "open list:RISC-V TCG CPUs" <qemu-riscv@nongnu.org>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com> Subject: Re: [PATCH v3] target/riscv: fix VS interrupts forwarding to HS Date: Wed, 26 May 2021 12:50:32 +0100 [thread overview] Message-ID: <CAC41xo3XAWZrqtFxiLDQ+H4fr=FVkWmZfe8P+PaTx-MPU_fpfw@mail.gmail.com> (raw) In-Reply-To: <94455d68-c088-5875-d115-acd95829406e@c-sky.com> Hello Zhiwei, thank you for reviewing the patch. I'll split the patch in a series as you suggest. But first can you help me understand what the problems are with riscv_cpu_local_irq_pending? > I think there are two errors in riscv_cpu_local_irq_pending. > > 1) VS interrupts can't be forwarded to hs-mode rightly . It has > nothing to do with delegate or not in hideleg. The reason is that > VS interrupts are always discarded when V=0 in > riscv_cpu_local_irq_pending. I don't see why this is the case. The way I see it, VS interrupts are only discarded for V=0 *iff* they are delegated in mideleg/hideleg. I actually tested it and I see the correct forwarding of vs-mode interrupts to hs-mode. I tested it by running in hs-mode with all the needed interrupt enables set, the interrupts not delegated in hideleg, and forcing the trigger of the interrupt by writing hvip. But maybe there are some corner cases I'm not taking into account. Can you explain this further? Maybe walk me through an example of when this issue might occur. > 2) Use MSTATUS_SIE in mstatus_hs to select pending_hs_irqs. I don't think you need to go through mstatus_hs to get the correct sie state. My logic behind this is: env->mstatus will have the vs-level sie if V=1 and hs-level sie if V=0. Due to the short-circuiting property of the logic operators the sie variable will only have an effect on hsie if V=0 and on vsie if V=1. So the value of sie is only used in the correct context. Again, please correct me if I'm wrong. I might be missing something. Best, José
next prev parent reply other threads:[~2021-05-26 11:51 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-22 15:44 [PATCH v3] target/riscv: fix VS interrupts forwarding to HS Jose Martins 2021-05-22 15:44 ` Jose Martins 2021-05-26 7:02 ` LIU Zhiwei 2021-05-26 7:02 ` LIU Zhiwei 2021-05-26 11:50 ` Jose Martins [this message] 2021-05-26 11:50 ` Jose Martins 2021-05-27 8:40 ` LIU Zhiwei 2021-05-27 8:40 ` LIU Zhiwei 2021-05-27 22:34 ` Alistair Francis 2021-05-27 22:34 ` Alistair Francis 2021-05-28 0:36 ` LIU Zhiwei 2021-05-28 0:36 ` LIU Zhiwei 2021-06-02 19:14 ` Jose Martins 2021-06-02 19:14 ` Jose Martins 2021-10-17 20:30 ` Jose Martins 2021-10-17 20:30 ` Jose Martins 2021-10-18 1:13 ` Alistair Francis 2021-10-18 1:13 ` Alistair Francis 2021-10-25 9:47 ` Jose Martins 2021-10-25 9:47 ` Jose Martins 2021-10-26 6:57 ` Alistair Francis 2021-10-26 6:57 ` Alistair Francis
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAC41xo3XAWZrqtFxiLDQ+H4fr=FVkWmZfe8P+PaTx-MPU_fpfw@mail.gmail.com' \ --to=josemartins90@gmail.com \ --cc=Alistair.Francis@wdc.com \ --cc=kbastian@mail.uni-paderborn.de \ --cc=palmer@dabbelt.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-riscv@nongnu.org \ --cc=sagark@eecs.berkeley.edu \ --cc=zhiwei_liu@c-sky.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.