[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240828020718.46977-1-qiaozhe@iscas.ac.cn>
Date: Wed, 28 Aug 2024 10:07:18 +0800
From: Zhe Qiao <qiaozhe@...as.ac.cn>
To: paul.walmsley@...ive.com,
palmer@...belt.com,
aou@...s.berkeley.edu,
conor.dooley@...rochip.com,
samuel.holland@...ive.com,
evan@...osinc.com,
sunilvl@...tanamicro.com,
ajones@...tanamicro.com,
andy.chiu@...ive.com,
tglx@...utronix.de,
qiaozhe@...as.ac.cn
Cc: linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] riscv: Report error when repeatedly recording CPU hardware ID
If the same CPU hardware attributes exist, the boot is aborted.
Ensure the uniqueness of the CPU hardware ID recorded in the
__cpuid_to_hartid_map[] array.
Signed-off-by: Zhe Qiao <qiaozhe@...as.ac.cn>
---
V1 -> V2:
1. Change the error report to BUG().
2. Change the function name to is_cartid_duplicate().
3. Modify commit description.
---
arch/riscv/kernel/smpboot.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 0f8f1c95ac38..f29a6fd55aa8 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -118,6 +118,16 @@ static void __init acpi_parse_and_init_cpus(void)
#define acpi_parse_and_init_cpus(...) do { } while (0)
#endif
+static bool __init is_hartid_duplicate(unsigned int cpuid, u64 hart)
+{
+ unsigned int i;
+
+ for (i = 1; (i < cpuid) && (i < NR_CPUS); i++)
+ if (cpuid_to_hartid_map(i) == hart)
+ return true;
+ return false;
+}
+
static void __init of_parse_and_init_cpus(void)
{
struct device_node *dn;
@@ -131,6 +141,9 @@ static void __init of_parse_and_init_cpus(void)
if (rc < 0)
continue;
+ if (is_hartid_duplicate(cpuid, hart))
+ BUG_ON(1);
+
if (hart == cpuid_to_hartid_map(0)) {
BUG_ON(found_boot_cpu);
found_boot_cpu = 1;
--
2.43.0
Powered by blists - more mailing lists