From: Raj Vishwanathan <raj.vishwanathan@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v3] Check that hartid is within the SBI_HARTMASK_MAX_BITS
Date: Tue, 28 Jan 2025 13:33:30 -0800 [thread overview]
Message-ID: <20250128213330.1443268-1-Raj.Vishwanathan@gmail.com> (raw)
In-Reply-To: <20250115234607.410148-1-Raj.Vishwanathan@gmail.com>
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 <Raj.Vishwanathan@gmail.com>
--
Changes in V2:
Update: Make hart_count > SBI_HARTMASK_MAX_BITS a catastrophic failure.
Changes in V1:
Ignore if hart_count is more than SBI_HARTMASK_MAX_BITS.
---
lib/utils/fdt/fdt_domain.c | 2 +-
lib/utils/fdt/fdt_helper.c | 6 +++---
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 4bc7ed8..7d10d10 100644
--- a/lib/utils/fdt/fdt_domain.c
+++ b/lib/utils/fdt/fdt_domain.c
@@ -471,7 +471,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 cb350e5..4673921 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -1032,7 +1032,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) {
@@ -1097,7 +1097,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)
@@ -1153,7 +1153,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 c03ed88..027ec89 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;
--
2.43.0
next prev parent reply other threads:[~2025-01-28 21:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 23:08 [PATCH] Work with hartid equal to or greater than SBI_HARTMASK_MAX_BITS Chao-ying Fu
2025-01-10 0:42 ` Inochi Amaoto
2025-01-10 1:20 ` Chao-ying Fu
2025-01-10 0:57 ` Jessica Clarke
2025-01-10 1:36 ` Chao-ying Fu
2025-01-15 23:46 ` [PATCH v2] " Raj Vishwanathan
2025-01-16 1:01 ` Xiang W
2025-01-21 1:12 ` [PATCH v3] " Raj Vishwanathan
2025-01-21 3:29 ` Xiang W
2025-01-22 0:42 ` Raj Vishwanathan
2025-02-11 4:51 ` Anup Patel
2025-01-27 20:20 ` [PATCH v3] New configuration CONFIG_SBI_SCRATCH_ALLOC_ALIGNMENT Raj Vishwanathan
2025-01-28 4:36 ` Xiang W
2025-02-11 4:45 ` Anup Patel
2025-03-05 0:31 ` Raj Vishwanathan
2025-03-05 2:01 ` Samuel Holland
2025-03-09 14:44 ` [PATCH v4] Set the scratch allocation to alignment to cacheline size Raj Vishwanathan
2025-03-10 5:26 ` Xiang W
2025-03-13 17:53 ` Raj Vishwanathan
2025-03-14 1:31 ` Xiang W
2025-01-28 21:33 ` Raj Vishwanathan [this message]
2025-01-29 9:07 ` [PATCH v3] Check that hartid is within the SBI_HARTMASK_MAX_BITS Xiang W
2025-02-11 22:00 ` [PATCH v3] lib: utils:Check that hartid is valid Raj Vishwanathan
2025-02-12 4:01 ` Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250128213330.1443268-1-Raj.Vishwanathan@gmail.com \
--to=raj.vishwanathan@gmail.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.