[PATCH v2] lib: sbi: Fix behavior on platform without HART protection

Michal Simek michal.simek at amd.com
Wed Jan 7 08:04:56 PST 2026


The commit 42139bb9b7dc ("lib: sbi: Replace sbi_hart_pmp_xyz() and
sbi_hart_map/unmap_addr()") changed logic by calling
sbi_hart_protection_configure(). But when protection doesn't exist the
function is returning SBI_EINVAL.
But on systems without protection this is correct configuration that's why
do not hang when system don't have any HART protection.

Fixes: 42139bb9b7dc ("lib: sbi: Replace sbi_hart_pmp_xyz() and sbi_hart_map/unmap_addr()")
Signed-off-by: Michal Simek <michal.simek at amd.com>
---

Changes in v2:
- Also update
  sbi_hart_protection_map_range()/sbi_hart_protection_unmap_range()

 lib/sbi/sbi_hart_protection.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/sbi/sbi_hart_protection.c b/lib/sbi/sbi_hart_protection.c
index 306f5afbdaea..e10c856460a4 100644
--- a/lib/sbi/sbi_hart_protection.c
+++ b/lib/sbi/sbi_hart_protection.c
@@ -54,7 +54,7 @@ int sbi_hart_protection_configure(struct sbi_scratch *scratch)
 	struct sbi_hart_protection *hprot = sbi_hart_protection_best();
 
 	if (!hprot)
-		return SBI_EINVAL;
+		return 0;
 	if (!hprot->configure)
 		return SBI_ENOSYS;
 
@@ -76,7 +76,7 @@ int sbi_hart_protection_map_range(unsigned long base, unsigned long size)
 	struct sbi_hart_protection *hprot = sbi_hart_protection_best();
 
 	if (!hprot)
-		return SBI_EINVAL;
+		return 0;
 	if (!hprot->map_range)
 		return 0;
 
@@ -88,7 +88,7 @@ int sbi_hart_protection_unmap_range(unsigned long base, unsigned long size)
 	struct sbi_hart_protection *hprot = sbi_hart_protection_best();
 
 	if (!hprot)
-		return SBI_EINVAL;
+		return 0;
 	if (!hprot->unmap_range)
 		return 0;
 
-- 
2.43.0

base-commit: e7fa66c2160ec139de1853a00f669c09320a9256
branch: track



More information about the opensbi mailing list