All of lore.kernel.org
 help / color / mirror / Atom feed
From: LIU Zhiwei <zhiwei_liu@c-sky.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: palmer@dabbelt.com, bin.meng@windriver.com,
	Alistair.Francis@wdc.com, LIU Zhiwei <zhiwei_liu@c-sky.com>
Subject: [PATCH v2 1/5] target/riscv: Check PMP rules num before propagation
Date: Mon, 22 Nov 2021 19:02:26 +0800	[thread overview]
Message-ID: <20211122110230.38783-2-zhiwei_liu@c-sky.com> (raw)
In-Reply-To: <20211122110230.38783-1-zhiwei_liu@c-sky.com>

When an address is in [0-4K) and no pmp rule configured, the tlb_size will
be set to 1.

This is caused by pmp_get_tlb_size return a value 1.

if (pmp_sa >= tlb_sa && pmp_ea <= tlb_ea) {
    return pmp_ea - pmp_sa + 1;
}

Here pmp_sa == 0 and pmp_ea == 0.

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 target/riscv/pmp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 54abf42583..190ff59fab 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -627,6 +627,10 @@ bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa,
     target_ulong val;
     target_ulong tlb_ea = (tlb_sa + TARGET_PAGE_SIZE - 1);
 
+    if (pmp_get_num_rules(env) == 0) {
+        return false;
+    }
+
     for (i = 0; i < MAX_RISCV_PMPS; i++) {
         val = pmp_get_tlb_size(env, i, tlb_sa, tlb_ea);
         if (val) {
-- 
2.25.1



WARNING: multiple messages have this Message-ID (diff)
From: LIU Zhiwei <zhiwei_liu@c-sky.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Alistair.Francis@wdc.com, palmer@dabbelt.com,
	bin.meng@windriver.com, LIU Zhiwei <zhiwei_liu@c-sky.com>
Subject: [PATCH v2 1/5] target/riscv: Check PMP rules num before propagation
Date: Mon, 22 Nov 2021 19:02:26 +0800	[thread overview]
Message-ID: <20211122110230.38783-2-zhiwei_liu@c-sky.com> (raw)
In-Reply-To: <20211122110230.38783-1-zhiwei_liu@c-sky.com>

When an address is in [0-4K) and no pmp rule configured, the tlb_size will
be set to 1.

This is caused by pmp_get_tlb_size return a value 1.

if (pmp_sa >= tlb_sa && pmp_ea <= tlb_ea) {
    return pmp_ea - pmp_sa + 1;
}

Here pmp_sa == 0 and pmp_ea == 0.

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 target/riscv/pmp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 54abf42583..190ff59fab 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -627,6 +627,10 @@ bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa,
     target_ulong val;
     target_ulong tlb_ea = (tlb_sa + TARGET_PAGE_SIZE - 1);
 
+    if (pmp_get_num_rules(env) == 0) {
+        return false;
+    }
+
     for (i = 0; i < MAX_RISCV_PMPS; i++) {
         val = pmp_get_tlb_size(env, i, tlb_sa, tlb_ea);
         if (val) {
-- 
2.25.1



  reply	other threads:[~2021-11-22 11:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 11:02 [PATCH v2 0/5] Check PMP rules num before propagation LIU Zhiwei
2021-11-22 11:02 ` LIU Zhiwei
2021-11-22 11:02 ` LIU Zhiwei [this message]
2021-11-22 11:02   ` [PATCH v2 1/5] target/riscv: " LIU Zhiwei
2021-11-23  6:17   ` Alistair Francis
2021-11-23  6:17     ` Alistair Francis
2021-11-22 11:02 ` [PATCH v2 2/5] target/riscv: Give a more generic size for tlb LIU Zhiwei
2021-11-22 11:02   ` LIU Zhiwei
2021-11-22 11:02 ` [PATCH v2 3/5] target/riscv: Discard return value for pmp_is_range_in_tlb LIU Zhiwei
2021-11-22 11:02   ` LIU Zhiwei
2021-11-22 11:02 ` [PATCH v2 4/5] target/riscv: Rename pmp_is_range_in_tlb LIU Zhiwei
2021-11-22 11:02   ` LIU Zhiwei
2021-11-22 11:02 ` [PATCH v2 5/5] target/riscv: Modify return and parameter type for pmp_adjust_tlb_size LIU Zhiwei
2021-11-22 11:02   ` LIU Zhiwei
2021-11-23  9:12 ` [PATCH v2 0/5] Check PMP rules num before propagation LIU Zhiwei
2021-11-23  9:12   ` LIU Zhiwei

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=20211122110230.38783-2-zhiwei_liu@c-sky.com \
    --to=zhiwei_liu@c-sky.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=palmer@dabbelt.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.