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

Anup Patel anup at brainfault.org
Wed Jan 7 09:02:23 PST 2026


On Wed, Jan 7, 2026 at 9:35 PM Michal Simek <michal.simek at amd.com> wrote:
>
> 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>

LGTM.

Reviewed-by: Anup Patel <anup at brainfault.org>

Since this patch also fixes OpenSBI running on QEMU virt
machine with rva23s64 and rva22s64 CPU types, I think
we should have an incremental v1.8.1 release.

Regards,
Anup


> ---
>
> 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
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list