From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Alistair Francis <alistair.francis@wdc.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: peter.maydell@linaro.org, palmer@sifive.com, alistair23@gmail.com
Subject: Re: [Qemu-devel] [PATCH v1 1/2] RISC-V: Handle bus errors in the page table walker
Date: Sat, 21 Sep 2019 11:09:40 +0200 [thread overview]
Message-ID: <b4647794-d9d1-fc47-a14c-71b5f91a2835@redhat.com> (raw)
In-Reply-To: <dfb8bc9fb7cad494d53f89774a3a4a5f3e478792.1568762497.git.alistair.francis@wdc.com>
On 9/18/19 1:22 AM, Alistair Francis wrote:
> From: Palmer Dabbelt <palmer@sifive.com>
>
> We directly access physical memory while walking the page tables on
> RISC-V, but while doing so we were using cpu_ld*() which does not report
> bus errors. This patch converts the page table walker over to use
> address_space_ld*(), which allows bus errors to be detected.
>
> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
> target/riscv/cpu_helper.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
> index 87dd6a6ece..c82e7ed52b 100644
> --- a/target/riscv/cpu_helper.c
> +++ b/target/riscv/cpu_helper.c
> @@ -169,7 +169,8 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical,
> /* NOTE: the env->pc value visible here will not be
> * correct, but the value visible to the exception handler
> * (riscv_cpu_do_interrupt) is correct */
> -
> + MemTxResult res;
> + MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
> int mode = mmu_idx;
>
> if (mode == PRV_M && access_type != MMU_INST_FETCH) {
> @@ -256,11 +257,16 @@ restart:
> 1 << MMU_DATA_LOAD, PRV_S)) {
> return TRANSLATE_PMP_FAIL;
> }
> +
> #if defined(TARGET_RISCV32)
> - target_ulong pte = ldl_phys(cs->as, pte_addr);
> + target_ulong pte = address_space_ldl(cs->as, pte_addr, attrs, &res);
> #elif defined(TARGET_RISCV64)
> - target_ulong pte = ldq_phys(cs->as, pte_addr);
> + target_ulong pte = address_space_ldq(cs->as, pte_addr, attrs, &res);
> #endif
> + if (res != MEMTX_OK) {
> + return TRANSLATE_FAIL;
> + }
> +
> hwaddr ppn = pte >> PTE_PPN_SHIFT;
>
> if (!(pte & PTE_V)) {
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
next prev parent reply other threads:[~2019-09-21 9:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-17 23:22 [Qemu-devel] [PATCH v1 0/2] RISC-V: Convert to do_transaction_failed hook Alistair Francis
2019-09-17 23:22 ` [Qemu-devel] [PATCH v1 1/2] RISC-V: Handle bus errors in the page table walker Alistair Francis
2019-09-21 9:09 ` Philippe Mathieu-Daudé [this message]
2019-09-17 23:23 ` [Qemu-devel] [PATCH v1 2/2] RISC-V: Implement cpu_do_transaction_failed Alistair Francis
2019-09-21 9:07 ` Philippe Mathieu-Daudé
2019-09-18 2:15 ` [Qemu-devel] [PATCH v1 0/2] RISC-V: Convert to do_transaction_failed hook Richard Henderson
2019-09-20 22:48 ` Palmer Dabbelt
2019-09-23 17:53 ` 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=b4647794-d9d1-fc47-a14c-71b5f91a2835@redhat.com \
--to=philmd@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=palmer@sifive.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).