From: Richard Henderson <richard.henderson@linaro.org>
To: Dayeol Lee <dayeol@berkeley.edu>
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 23:18:45 -0400 [thread overview]
Message-ID: <4cfde72b-9a31-a6c5-a7af-a3418a750f3a@linaro.org> (raw)
In-Reply-To: <CACjxMEtPRxTQdOYFL97G7aYXC6KTBuGY2avf1bPJLYGEpURh=Q@mail.gmail.com>
On 10/7/19 11:41 AM, Dayeol Lee wrote:
> if pmp_hart_has_privs() gets addr=0x2000 and size=0,
> pmp_hart_has_privs() will ALWAYS return false because the code assumes size > 0.
> It checks if (addr) and (addr + size - 1) are within the PMP range for each PMP
> entry.
You certainly could do
if (size == 0) {
size = -(addr | TARGET_PAGE_MASK);
}
to assume that all bytes from addr to the end of the page are accessed. That
would avoid changing too much of the rest of the logic.
That said, this code will continue to not work for mis-aligned boundaries.
r~
> (addr + size - 1) is supposed to be the last byte address of the memory access,
> but it ends up with (addr - 1) if size = 0.
> Thus, pmp_hart_has_privs() returns false as (addr - 1) = 0x1fff is within the
> range, and addr = 0x2000 is out of the range (partial match violation).
next prev parent reply other threads:[~2019-10-08 3:19 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
2019-10-07 18:25 ` Richard Henderson
2019-10-07 18:41 ` Dayeol Lee
2019-10-08 3:18 ` Richard Henderson [this message]
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=4cfde72b-9a31-a6c5-a7af-a3418a750f3a@linaro.org \
--to=richard.henderson@linaro.org \
--cc=Alistair.Francis@wdc.com \
--cc=dayeol@berkeley.edu \
--cc=kbastian@mail.uni-paderborn.de \
--cc=palmer@sifive.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.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).