From: Richard Henderson <richard.henderson@linaro.org>
To: Alistair Francis <alistair23@gmail.com>
Cc: "Alistair Francis" <alistair.francis@opensource.wdc.com>,
"open list:RISC-V" <qemu-riscv@nongnu.org>,
"David Hildenbrand" <david@redhat.com>,
"Bin Meng" <bin.meng@windriver.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Bin Meng" <bmeng.cn@gmail.com>,
"LIU Zhiwei" <zhiwei_liu@c-sky.com>
Subject: Re: [PATCH 0/2] RISC-V: Correctly generate store/amo faults
Date: Wed, 2 Feb 2022 11:37:10 +1100 [thread overview]
Message-ID: <2cb994f2-85e1-451f-c83c-a8403135cdc0@linaro.org> (raw)
In-Reply-To: <CAKmqyKNpefaQMZcW1CsKK22wKMRUxbkPjPAOumei+5NCQsLEVQ@mail.gmail.com>
On 2/1/22 15:40, Alistair Francis wrote:
>> Alistair, you're only changing the reporting of MMIO faults for which read permission is
>> missing. Importantly, the actual permission check is done elsewhere, and you aren't
>> changing that to perform a write access check. Also, you very much need to handle normal
>
> I'm a little confused with this part.
>
> Looking at tcg_gen_atomic_cmpxchg_i64() for example we either:
> 1. call tcg_gen_qemu_ld_i64() then tcg_gen_qemu_st_i64()
> 2. call table_cmpxchg[] which eventually calls atomic_mmu_lookup()
> 3. call tcg_gen_atomic_cmpxchg_i32() which is pretty much the same as
> the above two
>
> That means in both cases we end up performing a load or tlb_fill(..,
> MMU_DATA_LOAD, ..) operation as well as a store operation.
Yep...
> So we are already performing a write permission check...
... but we're doing so *after* the load.
Which means that for a completely unmapped page (as opposed to a read-only page) we will
generate a read fault, which generates RISCV_EXCP_LOAD_ACCESS_FAULT and *not*
RISCV_EXCP_STORE_AMO_ACCESS_FAULT.
So we need to check for write permission first, before performing the load.
> Can't we just do the check in the slow path? By the time we get to the
> fast path shouldn't we already have permissions?
No, the fast path performs the permissions check on one bit [rwx] depending on which tlb
comparator it loads.
> As in add a new INDEX_op_qemu_ld_write_perm_i32/i64, make edits to
> atomic_mmu_lookup() and all of the plumbing for those?
That's one possibility, sure.
r~
next prev parent reply other threads:[~2022-02-02 1:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 0:59 [PATCH 0/2] RISC-V: Correctly generate store/amo faults Alistair Francis
2022-01-24 0:59 ` [PATCH 1/2] accel: tcg: Allow forcing a store fault on read ops Alistair Francis
2022-01-24 0:59 ` [PATCH 2/2] targett/riscv: rva: Correctly generate a store/amo fault Alistair Francis
2022-01-24 5:38 ` LIU Zhiwei
2022-01-26 9:50 ` Weiwei Li
2022-01-24 5:17 ` [PATCH 0/2] RISC-V: Correctly generate store/amo faults LIU Zhiwei
2022-01-26 0:09 ` Richard Henderson
2022-02-01 4:40 ` Alistair Francis
2022-02-02 0:37 ` Richard Henderson [this message]
2022-02-04 7:36 ` Alistair Francis
2022-02-04 20:33 ` Richard Henderson
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=2cb994f2-85e1-451f-c83c-a8403135cdc0@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@opensource.wdc.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=bin.meng@windriver.com \
--cc=bmeng.cn@gmail.com \
--cc=david@redhat.com \
--cc=f4bug@amsat.org \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--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: 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).