From: Zong Li <zong.li@sifive.com>
To: Alexander Richardson <Alexander.Richardson@cl.cam.ac.uk>
Cc: "open list:RISC-V" <qemu-riscv@nongnu.org>,
Sagar Karandikar <sagark@eecs.berkeley.edu>,
Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Alistair Francis <Alistair.Francis@wdc.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Bin Meng <bmeng.cn@gmail.com>
Subject: Re: [PATCH v3 3/3] target/riscv: Fix the translation of physical address
Date: Thu, 23 Jul 2020 11:20:36 +0800 [thread overview]
Message-ID: <CANXhq0rcvhGX95JkX08OpRWWZBNZyDgeShD35BvbcQax10PBOA@mail.gmail.com> (raw)
In-Reply-To: <CAEeofchMe3H35zmuyzbVMOWOKrYZwfEGT9UVRb4k8L18WwW8PQ@mail.gmail.com>
On Wed, Jul 22, 2020 at 5:08 PM Alexander Richardson
<Alexander.Richardson@cl.cam.ac.uk> wrote:
>
> On Tue, 21 Jul 2020 at 13:43, Zong Li <zong.li@sifive.com> wrote:
> >
> > The real physical address should add the 12 bits page offset. It also
> > causes the PMP wrong checking due to the minimum granularity of PMP is
> > 4 byte, but we always get the physical address which is 4KB alignment,
> > that means, we always use the start address of the page to check PMP for
> > all addresses which in the same page.
> >
> > Signed-off-by: Zong Li <zong.li@sifive.com>
> > ---
> > target/riscv/cpu_helper.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
> > index 75d2ae3434..08b069f0c9 100644
> > --- a/target/riscv/cpu_helper.c
> > +++ b/target/riscv/cpu_helper.c
> > @@ -543,7 +543,8 @@ restart:
> > /* for superpage mappings, make a fake leaf PTE for the TLB's
> > benefit. */
> > target_ulong vpn = addr >> PGSHIFT;
> > - *physical = (ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT;
> > + *physical = ((ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT) |
> > + (addr & ~TARGET_PAGE_MASK);
> >
> > /* set permissions on the TLB entry */
> > if ((pte & PTE_R) || ((pte & PTE_X) && mxr)) {
> > --
> > 2.27.0
>
> I made the same change for our CHERI fork a few months ago but forgot
> to send the patch upstream (despite marking the commit as a candidate
> for upstreaming). Sorry about the duplicated debugging work!
> (https://github.com/CTSRD-CHERI/qemu/commit/61c8e3f2c0fd4965ec3f316146d1751fae673c12)
No, problem.
prev parent reply other threads:[~2020-07-23 3:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 12:40 [PATCH v3 0/3] Fix some PMP implementation Zong Li
2020-07-21 12:40 ` [PATCH v3 1/3] target/riscv: Fix the range of pmpcfg of CSR funcion table Zong Li
2020-07-21 12:40 ` [PATCH v3 2/3] target/riscv/pmp.c: Fix the index offset on RV64 Zong Li
2020-07-22 4:57 ` Bin Meng
2020-07-23 3:19 ` Zong Li
2020-07-21 12:40 ` [PATCH v3 3/3] target/riscv: Fix the translation of physical address Zong Li
2020-07-22 9:08 ` Alexander Richardson
2020-07-23 3:20 ` Zong Li [this message]
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=CANXhq0rcvhGX95JkX08OpRWWZBNZyDgeShD35BvbcQax10PBOA@mail.gmail.com \
--to=zong.li@sifive.com \
--cc=Alexander.Richardson@cl.cam.ac.uk \
--cc=Alistair.Francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=palmer@dabbelt.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).