From: Dayeol Lee <dayeol@berkeley.edu>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "open list:RISC-V TCG CPUs" <qemu-riscv@nongnu.org>,
Sagar Karandikar <sagark@eecs.berkeley.edu>,
Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
Palmer Dabbelt <palmer@sifive.com>,
qemu-devel@nongnu.org,
Alistair Francis <Alistair.Francis@wdc.com>
Subject: Re: [PATCH] target/riscv: PMP violation due to wrong size parameter
Date: Mon, 7 Oct 2019 10:19:18 -0700 [thread overview]
Message-ID: <CACjxMEsw+Deh176JLP2aF4Pdkb_s8MiPApwMON-_K6ed61-Zyw@mail.gmail.com> (raw)
In-Reply-To: <5583387c-5c5b-8890-999b-2ba4d75cd69d@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 1853 bytes --]
Thank you very much for the clarification!
I found tlb_set_page with size != TARGET_PAGE_SIZE makes the translation
way too slow; the Linux doesn't seem to boot.
If that's the only way to reduce PMP granularity to less than
TARGET_PAGE_SIZE,
Can we just set the PMP default granularity to TARGET_PAGE_SIZE as it did
before?
OR
Can we bypass the partial match violation when size is unknown? (check the
starting address only)
I think both of the options does not exactly match with the ISA
specification,
but given that size=0 always causes the problem, I want it to be fixed as
soon as possible.
Any thoughts would be appreciated!
On Mon, Oct 7, 2019, 6:00 AM Richard Henderson <richard.henderson@linaro.org>
wrote:
> On 10/6/19 10:28 PM, Dayeol Lee wrote:
> > riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation
> > using pmp_hart_has_privs().
> > However, the size passed from tlb_fill(), which is called by
> > get_page_addr_code(), is always a hard-coded value 0.
> > This causes a false PMP violation if the instruction presents on a
> > PMP boundary.
> >
> > In order to fix, simply correct the size to 4 if the access_type is
> > MMU_INST_FETCH.
>
> That's not correct.
>
> In general, size 0 means "unknown size". In this case, the one tlb lookup
> is
> going to be used by lots of instructions -- everything that fits on the
> page.
>
> If you want to support PMP on things that are not page boundaries, then you
> will also have to call tlb_set_page with size != TARGET_PAGE_SIZE.
>
> Fixing that will cause instructions within that page to be executed one at
> a
> time, which also means they will be tlb_fill'd one at a time, which means
> that
> you'll get the correct size value.
>
> Which will be 2 or 4, depending on whether the configuration supports the
> Compressed extension, and not just 4.
>
>
> r~
>
>
[-- Attachment #2: Type: text/html, Size: 2640 bytes --]
next prev parent reply other threads:[~2019-10-07 17:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 5:28 [PATCH] target/riscv: PMP violation due to wrong size parameter Dayeol Lee
2019-10-07 6:20 ` no-reply
2019-10-07 13:00 ` Richard Henderson
2019-10-07 17:19 ` Dayeol Lee [this message]
2019-10-07 18:25 ` Richard Henderson
2019-10-07 18:41 ` Dayeol Lee
2019-10-08 3:18 ` Richard Henderson
2019-10-11 23:14 Dayeol Lee
2019-10-12 2:37 ` Jonathan Behrens
2019-10-12 18:30 ` Dayeol Lee
2019-10-15 17:04 ` Dayeol Lee
2019-10-18 19:01 ` Palmer Dabbelt
2019-10-18 19:28 ` Dayeol Lee
2019-10-22 21:21 Dayeol Lee
2019-10-23 15:50 ` Palmer Dabbelt
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=CACjxMEsw+Deh176JLP2aF4Pdkb_s8MiPApwMON-_K6ed61-Zyw@mail.gmail.com \
--to=dayeol@berkeley.edu \
--cc=Alistair.Francis@wdc.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=palmer@sifive.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sagark@eecs.berkeley.edu \
/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).