Skip to content

Commit 74434f2

Browse files
michalsimekavpatel
authored andcommitted
lib: sbi: Fix behavior on platform without HART protection
The commit 42139bb ("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: 42139bb ("lib: sbi: Replace sbi_hart_pmp_xyz() and sbi_hart_map/unmap_addr()") Signed-off-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/bb8641e5f82654e3989537cea85f165f67a7044e.1767801896.git.michal.simek@amd.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent 65fac65 commit 74434f2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/sbi/sbi_hart_protection.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int sbi_hart_protection_configure(struct sbi_scratch *scratch)
5454
struct sbi_hart_protection *hprot = sbi_hart_protection_best();
5555

5656
if (!hprot)
57-
return SBI_EINVAL;
57+
return 0;
5858
if (!hprot->configure)
5959
return SBI_ENOSYS;
6060

@@ -75,9 +75,7 @@ int sbi_hart_protection_map_range(unsigned long base, unsigned long size)
7575
{
7676
struct sbi_hart_protection *hprot = sbi_hart_protection_best();
7777

78-
if (!hprot)
79-
return SBI_EINVAL;
80-
if (!hprot->map_range)
78+
if (!hprot || !hprot->map_range)
8179
return 0;
8280

8381
return hprot->map_range(sbi_scratch_thishart_ptr(), base, size);
@@ -87,9 +85,7 @@ int sbi_hart_protection_unmap_range(unsigned long base, unsigned long size)
8785
{
8886
struct sbi_hart_protection *hprot = sbi_hart_protection_best();
8987

90-
if (!hprot)
91-
return SBI_EINVAL;
92-
if (!hprot->unmap_range)
88+
if (!hprot || !hprot->unmap_range)
9389
return 0;
9490

9591
return hprot->unmap_range(sbi_scratch_thishart_ptr(), base, size);

0 commit comments

Comments
 (0)