diff options
| author | Raj Vishwanathan <[email protected]> | 2025-02-11 14:00:42 -0800 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2025-02-12 09:24:09 +0530 |
| commit | 5e90e54a1a53173128b264f4e22cfa5884f78526 (patch) | |
| tree | 833d3ae2f3eb32693779f33e7d0c0e1bccd6ccf5 | |
| parent | 4f12f8b02f669e7cd3286a543f2cb6308fe5a0fe (diff) | |
lib: utils:Check that hartid is valid
It is possible that hartid may not be sequential and it should not be validated
against SBI_HARTMASK_MAX_BITS. Instead we should check the index of the hartid,
hart index, against SBI_HARTMASK_MAX_BITS.
Signed-off-by: Raj Vishwanathan <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
| -rw-r--r-- | lib/utils/fdt/fdt_domain.c | 2 | ||||
| -rw-r--r-- | lib/utils/fdt/fdt_helper.c | 6 | ||||
| -rw-r--r-- | platform/generic/platform.c | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/utils/fdt/fdt_domain.c b/lib/utils/fdt/fdt_domain.c index d7efc56b..b2fa8633 100644 --- a/lib/utils/fdt/fdt_domain.c +++ b/lib/utils/fdt/fdt_domain.c @@ -473,7 +473,7 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) if (err) continue; - if (SBI_HARTMASK_MAX_BITS <= val32) + if (SBI_HARTMASK_MAX_BITS <= sbi_hartid_to_hartindex(val32)) continue; if (!fdt_node_is_enabled(fdt, cpu_offset)) diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index e92484cd..c997da27 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -1031,7 +1031,7 @@ int fdt_parse_aclint_node(const void *fdt, int nodeoffset, if (rc) continue; - if (SBI_HARTMASK_MAX_BITS <= hartid) + if (SBI_HARTMASK_MAX_BITS <= sbi_hartid_to_hartindex(hartid)) continue; if (match_hwirq == hwirq) { @@ -1096,7 +1096,7 @@ int fdt_parse_plmt_node(const void *fdt, int nodeoffset, unsigned long *plmt_bas if (rc) continue; - if (SBI_HARTMASK_MAX_BITS <= hartid) + if (SBI_HARTMASK_MAX_BITS <= sbi_hartid_to_hartindex(hartid)) continue; if (hwirq == IRQ_M_TIMER) @@ -1152,7 +1152,7 @@ int fdt_parse_plicsw_node(const void *fdt, int nodeoffset, unsigned long *plicsw if (rc) continue; - if (SBI_HARTMASK_MAX_BITS <= hartid) + if (SBI_HARTMASK_MAX_BITS <= sbi_hartid_to_hartindex(hartid)) continue; if (hwirq == IRQ_M_SOFT) diff --git a/platform/generic/platform.c b/platform/generic/platform.c index c03ed88e..027ec89a 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -200,8 +200,8 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1, if (rc) continue; - if (SBI_HARTMASK_MAX_BITS <= hartid) - continue; + if (SBI_HARTMASK_MAX_BITS <= hart_count) + break; if (!fdt_node_is_enabled(fdt, cpu_offset)) continue; |
