From: Nicholas Piggin <npiggin@gmail.com>
To: opensbi@lists.infradead.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH 5/7] lib: sbi: Add pmp_is_enabled() helper
Date: Thu, 30 Apr 2026 14:55:23 +1000 [thread overview]
Message-ID: <20260430045528.420437-7-npiggin@gmail.com> (raw)
In-Reply-To: <20260430045528.420437-1-npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
include/sbi/sbi_pmp.h | 1 +
lib/sbi/riscv_asm.c | 6 +-----
lib/sbi/sbi_pmp.c | 9 +++++++++
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/sbi/sbi_pmp.h b/include/sbi/sbi_pmp.h
index 66a5cc75..bce62d22 100644
--- a/include/sbi/sbi_pmp.h
+++ b/include/sbi/sbi_pmp.h
@@ -14,6 +14,7 @@ struct pmp {
};
typedef struct pmp pmp_t;
+bool pmp_is_enabled(pmp_t *pmp);
int pmp_encode(pmp_t *pmp, unsigned long prot, unsigned long addr,
unsigned long log2len);
int pmp_decode(pmp_t *pmp, unsigned long *prot, unsigned long *addr,
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c
index 2fb0f585..c0ad4dbe 100644
--- a/lib/sbi/riscv_asm.c
+++ b/lib/sbi/riscv_asm.c
@@ -353,11 +353,7 @@ int is_pmp_entry_mapped(unsigned long entry)
if (hart_pmp_read(&pmp, entry) != SBI_OK)
return false;
- /* If address matching bits are non-zero, the entry is enable */
- if (pmp.cfg & PMP_A)
- return true;
-
- return false;
+ return pmp_is_enabled(&pmp);
}
int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
diff --git a/lib/sbi/sbi_pmp.c b/lib/sbi/sbi_pmp.c
index 91eab87f..75b18764 100644
--- a/lib/sbi/sbi_pmp.c
+++ b/lib/sbi/sbi_pmp.c
@@ -28,6 +28,15 @@ static unsigned long ctz(unsigned long x)
return ret;
}
+bool pmp_is_enabled(pmp_t *pmp)
+{
+ /* If address matching bits are non-zero, the entry is enable */
+ if (pmp->cfg & PMP_A)
+ return true;
+
+ return false;
+}
+
int pmp_encode(pmp_t *pmp, unsigned long prot, unsigned long addr,
unsigned long log2len)
{
--
2.53.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2026-04-30 4:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 4:55 [PATCH 0/7] Make PMP encoding usable for non-hart PMPs Nicholas Piggin
2026-04-30 4:55 ` [PATCH 1/7] lib: sbi: Introduce pmp_t type Nicholas Piggin
2026-04-30 4:55 ` [PATCH 2/7] lib: sbi: split PMP encoding and CSR access Nicholas Piggin
2026-04-30 4:55 ` [PATCH 3/7] lib: sbi: Move RISC-V PMP encoding functions to sbi_pmp.c Nicholas Piggin
2026-04-30 4:55 ` [PATCH 3/7] lib: sbi: Move non-HART PMP " Nicholas Piggin
2026-04-30 4:55 ` [PATCH 4/7] lib: sbi: Add PMP CSR read and write accessors Nicholas Piggin
2026-04-30 4:55 ` Nicholas Piggin [this message]
2026-04-30 4:55 ` [PATCH 6/7] lib: sbi: Add hart_ prefix to PMP functions Nicholas Piggin
2026-04-30 4:55 ` [PATCH 7/7] lib: sbi: Move hart PMP functions to sbi_hart_pmp.c Nicholas Piggin
2026-06-10 12:35 ` [PATCH 0/7] Make PMP encoding usable for non-hart PMPs Anup Patel
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=20260430045528.420437-7-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=opensbi@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox