Skip to content

Commit 2dce4b4

Browse files
committed
lib: sbi_ipi: Validate hartids against domain, not HSM state
Commit 37eaca4 ("lib: sbi_ipi: Return error for invalid hartids") added a weight check against the HSM-interruptible mask, which excludes harts in STOPPED state. This causes sbi_ipi_send_many() to return SBI_EINVAL when the kernel sends a remote fence (e.g. TLB shootdown) whose hmask includes a hart that was stopped by CPU hotplug: __sbi_rfence_v02_call: hbase = [0] hmask = [0x3] failed (error [-22]) Validate requested hartids against the domain's assigned hartmask instead. This still rejects truly invalid or cross-domain hartids, but allows HSM-STOPPED harts to be silently skipped — which is safe because a stopped hart will do a full local TLB flush on its next HSM start before re-entering S-mode. Fixes: 37eaca4 ("lib: sbi_ipi: Return error for invalid hartids") Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
1 parent 1c40deb commit 2dce4b4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/sbi/sbi_ipi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,24 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data)
128128

129129
if (hbase != -1UL) {
130130
struct sbi_hartmask tmp_mask = { 0 };
131+
struct sbi_hartmask domain_mask;
131132
int count = sbi_popcount(hmask);
132133

133134
for (i = hbase; hmask; i++, hmask >>= 1) {
134135
if (hmask & 1UL)
135136
sbi_hartmask_set_hartid(i, &tmp_mask);
136137
}
137138

138-
sbi_hartmask_and(&target_mask, &target_mask, &tmp_mask);
139+
/* Validate hartids against domain assignment, not HSM state */
140+
rc = sbi_domain_get_assigned_hartmask(dom, &domain_mask);
141+
if (rc)
142+
return rc;
139143

140-
if (sbi_hartmask_weight(&target_mask) != count)
144+
sbi_hartmask_and(&domain_mask, &domain_mask, &tmp_mask);
145+
if (sbi_hartmask_weight(&domain_mask) != count)
141146
return SBI_EINVAL;
147+
148+
sbi_hartmask_and(&target_mask, &target_mask, &tmp_mask);
142149
}
143150

144151
/* Send IPIs */

0 commit comments

Comments
 (0)