@@ -799,6 +799,38 @@ int sbi_domain_root_add_memrange(unsigned long addr, unsigned long size,
return 0;
}
+static void domain_select_boot_harts(void)
+{
+ u32 dhart;
+ struct sbi_domain *dom;
+
+ sbi_domain_for_each(dom) {
+ u32 boot_hartindex = sbi_hartid_to_hartindex(dom->boot_hartid);
+ bool boot_assigned = false;
+
+ if (sbi_hartindex_valid(boot_hartindex)) {
+ spin_lock(&dom->assigned_harts_lock);
+ boot_assigned = sbi_hartmask_test_hartindex(
+ boot_hartindex, &dom->assigned_harts);
+ spin_unlock(&dom->assigned_harts_lock);
+ }
+
+ if (!boot_assigned) {
+ u32 new_hartid = -1U;
+
+ spin_lock(&dom->assigned_harts_lock);
+ sbi_hartmask_for_each_hartindex(dhart, &dom->assigned_harts) {
+ new_hartid = sbi_hartindex_to_hartid(dhart);
+ break;
+ }
+ spin_unlock(&dom->assigned_harts_lock);
+
+ if (new_hartid != -1U)
+ dom->boot_hartid = new_hartid;
+ }
+ }
+}
+
int sbi_domain_startup(struct sbi_scratch *scratch, u32 cold_hartid)
{
int rc;
@@ -873,6 +905,9 @@ int sbi_domain_finalize(struct sbi_scratch *scratch)
return rc;
}
+ /* Select stable boot HARTs before programming physical IRQ targets. */
+ domain_select_boot_harts();
+
/*
* Set the finalized flag so that the root domain
* regions can't be changed.