aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHimanshu Chauhan <hchauhan@ventanamicro.com>2023-07-12 10:04:33 +0530
committerAnup Patel <anup@brainfault.org>2023-07-13 12:42:09 +0530
commit5dd8db5b10fc03aeded76407aecb731a8a9f1cfa (patch)
treefd2babcf5a42a726cf0c0bc0532d89532ac2205e /include
parentf3fdd041acf5bfb9c261c1e8a909e9b0d78c03e8 (diff)
downloadopensbi-5dd8db5b10fc03aeded76407aecb731a8a9f1cfa.zip
opensbi-5dd8db5b10fc03aeded76407aecb731a8a9f1cfa.tar.gz
opensbi-5dd8db5b10fc03aeded76407aecb731a8a9f1cfa.tar.bz2
lib: sbi: Add support for Smepmp
- If Smepmp is enabled, the access flags of an entry are determined based on truth table defined in Smepmp. - First PMP entry (index 0) is reserved. - Existing boot PMP entries start from index 1. - Since enabling Smepmp revokes the access privileges of the M-mode software on S/U-mode region, first PMP entry is used to map/unmap the shared memory between M and S/U-mode. This allows a temporary access window for the M-mode software to read/write to S/U-mode memory region. Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/sbi_hart.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h
index 8b0e896..1b78343 100644
--- a/include/sbi/sbi_hart.h
+++ b/include/sbi/sbi_hart.h
@@ -45,6 +45,21 @@ enum sbi_hart_extensions {
SBI_HART_EXT_MAX,
};
+/*
+ * Smepmp enforces access boundaries between M-mode and
+ * S/U-mode. When it is enabled, the PMPs are programmed
+ * such that M-mode doesn't have access to S/U-mode memory.
+ *
+ * To give M-mode R/W access to the shared memory between M and
+ * S/U-mode, first entry is reserved. It is disabled at boot.
+ * When shared memory access is required, the physical address
+ * should be programmed into the first PMP entry with R/W
+ * permissions to the M-mode. Once the work is done, it should be
+ * unmapped. sbi_hart_map_saddr/sbi_hart_unmap_saddr function
+ * pair should be used to map/unmap the shared memory.
+ */
+#define SBI_SMEPMP_RESV_ENTRY 0
+
struct sbi_hart_features {
bool detected;
int priv_version;