From: Alistair Francis <alistair23@gmail.com> To: Jiangyifei <jiangyifei@huawei.com> Cc: "qemu-riscv@nongnu.org" <qemu-riscv@nongnu.org>, Zhanghailiang <zhang.zhanghailiang@huawei.com>, "sagark@eecs.berkeley.edu" <sagark@eecs.berkeley.edu>, "kbastian@mail.uni-paderborn.de" <kbastian@mail.uni-paderborn.de>, "Zhangxiaofeng \(F\)" <victor.zhangxiaofeng@huawei.com>, Richard Henderson <richard.henderson@linaro.org>, "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>, "Alistair.Francis@wdc.com" <Alistair.Francis@wdc.com>, yinyipeng <yinyipeng1@huawei.com>, "palmer@dabbelt.com" <palmer@dabbelt.com>, "Wubin \(H\)" <wu.wubin@huawei.com>, "dengkai \(A\)" <dengkai1@huawei.com> Subject: Re: [PATCH V3] target/riscv: raise exception to HS-mode at get_physical_address Date: Wed, 21 Oct 2020 12:59:54 -0700 [thread overview] Message-ID: <CAKmqyKMQ+Kood7dO=esi9J5eTVYZPPq2QiVzSgHfEHta_cpZ+g@mail.gmail.com> (raw) In-Reply-To: <cd12acc6aa7b4f1d84859f14200cf75d@huawei.com> On Wed, Oct 14, 2020 at 6:59 PM Jiangyifei <jiangyifei@huawei.com> wrote: > > > > -----Original Message----- > > From: Richard Henderson [mailto:richard.henderson@linaro.org] > > Sent: Thursday, October 15, 2020 4:22 AM > > To: Jiangyifei <jiangyifei@huawei.com>; qemu-devel@nongnu.org; > > qemu-riscv@nongnu.org > > Cc: palmer@dabbelt.com; Alistair.Francis@wdc.com; > > sagark@eecs.berkeley.edu; kbastian@mail.uni-paderborn.de; Zhangxiaofeng > > (F) <victor.zhangxiaofeng@huawei.com>; Wubin (H) <wu.wubin@huawei.com>; > > Zhanghailiang <zhang.zhanghailiang@huawei.com>; dengkai (A) > > <dengkai1@huawei.com>; yinyipeng <yinyipeng1@huawei.com> > > Subject: Re: [PATCH V3] target/riscv: raise exception to HS-mode at > > get_physical_address > > > > On 10/14/20 3:17 AM, Yifei Jiang wrote: > > > + if (fault_pte_addr) { > > > + *fault_pte_addr = (base + idx * ptesize) >> 2; > > > > The shift is wrong. It should be exactly like... > > > > We have tested in the VM migration. > > fault_pte_addr will eventually be assigned to htval register. > > Description of htval register according to the specification: > When a guest-page-fault trap is taken into HS-mode, htval is written with either zero > or the guest physical address that faulted, shifted right by 2 bits. Yep, I agree that the shift is correct, it's what we do when we set guest_phys_fault_addr in other places. It is a little confusing that we shift it in get_physical_address(), instead of when guest_phys_fault_addr is set. In this case you are setting guest_phys_fault_addr directly when calling get_physical_address(... &env->guest_phys_fault_addr ...). I have added this comment to make sure it's clear and applied it, I hope that's ok. diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 4ea9510c07..4652082df1 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -318,6 +318,7 @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv) * @addr: The virtual address to be translated * @fault_pte_addr: If not NULL, this will be set to fault pte address * when a error occurs on pte address translation. + * This will already be shifted to match htval. * @access_type: The type of MMU access * @mmu_idx: Indicates current privilege level * @first_stage: Are we in first stage translation? Alistair > > In addition, fault_pte_addr is named after env->guest_phys_fault_addr, which makes > sense in a sense. > > Yifei > > > > + } > > > + return TRANSLATE_G_STAGE_FAIL; > > > } > > > > > > pte_addr = vbase + idx * ptesize; > > > > ... this. > > > > > > r~
WARNING: multiple messages have this Message-ID (diff)
From: Alistair Francis <alistair23@gmail.com> To: Jiangyifei <jiangyifei@huawei.com> Cc: Richard Henderson <richard.henderson@linaro.org>, "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>, "qemu-riscv@nongnu.org" <qemu-riscv@nongnu.org>, Zhanghailiang <zhang.zhanghailiang@huawei.com>, "sagark@eecs.berkeley.edu" <sagark@eecs.berkeley.edu>, "kbastian@mail.uni-paderborn.de" <kbastian@mail.uni-paderborn.de>, "Zhangxiaofeng (F)" <victor.zhangxiaofeng@huawei.com>, "Alistair.Francis@wdc.com" <Alistair.Francis@wdc.com>, yinyipeng <yinyipeng1@huawei.com>, "palmer@dabbelt.com" <palmer@dabbelt.com>, "Wubin (H)" <wu.wubin@huawei.com>, "dengkai (A)" <dengkai1@huawei.com> Subject: Re: [PATCH V3] target/riscv: raise exception to HS-mode at get_physical_address Date: Wed, 21 Oct 2020 12:59:54 -0700 [thread overview] Message-ID: <CAKmqyKMQ+Kood7dO=esi9J5eTVYZPPq2QiVzSgHfEHta_cpZ+g@mail.gmail.com> (raw) In-Reply-To: <cd12acc6aa7b4f1d84859f14200cf75d@huawei.com> On Wed, Oct 14, 2020 at 6:59 PM Jiangyifei <jiangyifei@huawei.com> wrote: > > > > -----Original Message----- > > From: Richard Henderson [mailto:richard.henderson@linaro.org] > > Sent: Thursday, October 15, 2020 4:22 AM > > To: Jiangyifei <jiangyifei@huawei.com>; qemu-devel@nongnu.org; > > qemu-riscv@nongnu.org > > Cc: palmer@dabbelt.com; Alistair.Francis@wdc.com; > > sagark@eecs.berkeley.edu; kbastian@mail.uni-paderborn.de; Zhangxiaofeng > > (F) <victor.zhangxiaofeng@huawei.com>; Wubin (H) <wu.wubin@huawei.com>; > > Zhanghailiang <zhang.zhanghailiang@huawei.com>; dengkai (A) > > <dengkai1@huawei.com>; yinyipeng <yinyipeng1@huawei.com> > > Subject: Re: [PATCH V3] target/riscv: raise exception to HS-mode at > > get_physical_address > > > > On 10/14/20 3:17 AM, Yifei Jiang wrote: > > > + if (fault_pte_addr) { > > > + *fault_pte_addr = (base + idx * ptesize) >> 2; > > > > The shift is wrong. It should be exactly like... > > > > We have tested in the VM migration. > > fault_pte_addr will eventually be assigned to htval register. > > Description of htval register according to the specification: > When a guest-page-fault trap is taken into HS-mode, htval is written with either zero > or the guest physical address that faulted, shifted right by 2 bits. Yep, I agree that the shift is correct, it's what we do when we set guest_phys_fault_addr in other places. It is a little confusing that we shift it in get_physical_address(), instead of when guest_phys_fault_addr is set. In this case you are setting guest_phys_fault_addr directly when calling get_physical_address(... &env->guest_phys_fault_addr ...). I have added this comment to make sure it's clear and applied it, I hope that's ok. diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 4ea9510c07..4652082df1 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -318,6 +318,7 @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv) * @addr: The virtual address to be translated * @fault_pte_addr: If not NULL, this will be set to fault pte address * when a error occurs on pte address translation. + * This will already be shifted to match htval. * @access_type: The type of MMU access * @mmu_idx: Indicates current privilege level * @first_stage: Are we in first stage translation? Alistair > > In addition, fault_pte_addr is named after env->guest_phys_fault_addr, which makes > sense in a sense. > > Yifei > > > > + } > > > + return TRANSLATE_G_STAGE_FAIL; > > > } > > > > > > pte_addr = vbase + idx * ptesize; > > > > ... this. > > > > > > r~
next prev parent reply other threads:[~2020-10-21 20:12 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-14 10:17 [PATCH V3] target/riscv: raise exception to HS-mode at get_physical_address Yifei Jiang 2020-10-14 10:17 ` Yifei Jiang 2020-10-14 20:06 ` Alistair Francis 2020-10-14 20:06 ` Alistair Francis 2020-10-14 20:21 ` Richard Henderson 2020-10-14 20:21 ` Richard Henderson 2020-10-15 1:59 ` Jiangyifei 2020-10-15 1:59 ` Jiangyifei 2020-10-21 19:59 ` Alistair Francis [this message] 2020-10-21 19:59 ` 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='CAKmqyKMQ+Kood7dO=esi9J5eTVYZPPq2QiVzSgHfEHta_cpZ+g@mail.gmail.com' \ --to=alistair23@gmail.com \ --cc=Alistair.Francis@wdc.com \ --cc=dengkai1@huawei.com \ --cc=jiangyifei@huawei.com \ --cc=kbastian@mail.uni-paderborn.de \ --cc=palmer@dabbelt.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-riscv@nongnu.org \ --cc=richard.henderson@linaro.org \ --cc=sagark@eecs.berkeley.edu \ --cc=victor.zhangxiaofeng@huawei.com \ --cc=wu.wubin@huawei.com \ --cc=yinyipeng1@huawei.com \ --cc=zhang.zhanghailiang@huawei.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.