diff options
| author | Andrew Jones <ajones@ventanamicro.com> | 2025-03-14 17:30:24 +0100 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2025-04-14 15:29:36 +0530 |
| commit | 37eaca4ab33d8a392a30fd69d87d5a4886ce03b7 (patch) | |
| tree | 099a9432ab2d5151367fc1a0e59bb6b6e2c254f5 /lib | |
| parent | a6e5f8878c1201a307236d8355db68075591c9db (diff) | |
| download | opensbi-37eaca4ab33d8a392a30fd69d87d5a4886ce03b7.zip opensbi-37eaca4ab33d8a392a30fd69d87d5a4886ce03b7.tar.gz opensbi-37eaca4ab33d8a392a30fd69d87d5a4886ce03b7.tar.bz2 | |
lib: sbi_ipi: Return error for invalid hartids
sbi_send_ipi() should return SBI_ERR_INVALID_PARAM if even one hartid
constructed from hart_mask_base and hart_mask, is not valid.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20250314163021.154530-6-ajones@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbi/sbi_ipi.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 52898d3..2de459b 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -116,6 +116,11 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); + if (hmask == 0 && hbase != -1UL) { + /* Nothing to do, but it's not an error either. */ + return 0; + } + /* Find the target harts */ rc = sbi_hsm_hart_interruptible_mask(dom, &target_mask); if (rc) @@ -123,6 +128,7 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) if (hbase != -1UL) { struct sbi_hartmask tmp_mask = { 0 }; + int count = sbi_popcount(hmask); for (i = hbase; hmask; i++, hmask >>= 1) { if (hmask & 1UL) @@ -130,6 +136,9 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) } sbi_hartmask_and(&target_mask, &target_mask, &tmp_mask); + + if (sbi_hartmask_weight(&target_mask) != count) + return SBI_EINVAL; } /* Send IPIs */ |
