[PATCH 06/22] platform: generic: mips p8700: use detected PMP count
Vladimir Kondratiev
vladimir.kondratiev at mobileye.com
Wed Jan 14 01:21:02 PST 2026
When fixing up PMP regions, no need in #define for PMP region
count, we now have correct result by sbi_hart_pmp_count()
thanks to
56e93b4b91bf ("lib: sbi: fix number of PMP entries detection")
Fixing: ae3e994c30dd ("eq7: Prohibit accessing memory beyond DRAM")
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev at mobileye.com>
---
platform/generic/mips/p8700.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
index 1fb6ece3ab68..b4aef5fa7e36 100644
--- a/platform/generic/mips/p8700.c
+++ b/platform/generic/mips/p8700.c
@@ -21,7 +21,6 @@
extern void mips_warm_boot(void);
#define MMIO_BASE 0x00000000
#define MMIO_SIZE 0x80000000
-#define PMP_REGION_MAX (16)
static void mips_p8700_pmp_set(unsigned int n, unsigned long flags,
unsigned long prot, unsigned long addr,
@@ -144,15 +143,20 @@ static struct sbi_domain_memregion *find_last_memregion(const struct sbi_domain
static int mips_p8700_final_init(bool cold_boot)
{
+ struct sbi_scratch *scratch;
const struct sbi_domain *dom;
struct sbi_domain_memregion *reg;
const unsigned long end_of_dram = 0x1000000000LU;
- unsigned long gran = sbi_hart_pmp_log2gran(sbi_scratch_thishart_ptr());
+ unsigned long pmp_gran;
+ int pmp_count;
if (!cold_boot)
return 0;
sbi_hsm_set_device(&mips_hsm);
+ scratch = sbi_scratch_thishart_ptr();
+ pmp_gran = sbi_hart_pmp_log2gran(scratch);
+ pmp_count = sbi_hart_pmp_count(scratch);
/*
* sbi_domain_init adds last "all-inclusive" memory region
@@ -171,8 +175,8 @@ static int mips_p8700_final_init(bool cold_boot)
* SBI code don't let to disable PMP region, so configure it to
* some fake values. order should be valid or region won't be set.
*/
- for (++reg; reg < &dom->regions[PMP_REGION_MAX]; reg++) {
- reg->order = gran; // order should be not 0, this is minimum valid
+ for (++reg; reg < &dom->regions[pmp_count]; reg++) {
+ reg->order = pmp_gran; // order should be not 0, this is minimum valid
reg->base = 0;
reg->flags = SBI_DOMAIN_MEMREGION_MMIO; // disable cache & prefetch
}
--
2.43.0
More information about the opensbi
mailing list