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

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


On Wed, Jan 7, 2026 at 8:20 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.
>

Please add a Fixes tag here.

> Signed-off-by: Michal Simek <michal.simek at amd.com>
> ---
>
>  lib/sbi/sbi_hart_protection.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_hart_protection.c b/lib/sbi/sbi_hart_protection.c
> index 306f5afbdaea..43e65a38cfcc 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;

In addition to sbi_hart_protection_configure(), the
sbi_hart_protection_map_range() and
sbi_hart_protection_unmap_range() functions
must also return 0 instead of SBI_EINVAL because
callers of these functions don't check whether
hart protection mechanism is available or not.

>         if (!hprot->configure)
>                 return SBI_ENOSYS;
>
> --
> 2.43.0
>
> base-commit: e7fa66c2160ec139de1853a00f669c09320a9256
> branch: track
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

Regards,
Anup



More information about the opensbi mailing list