Skip to contentSkip to conversation

riscv: sbi: Add no target ipi test

PATCH In review Andrew Jones 1 participant 3 messages Mar 17, 2025 – Mar 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: sbi: Add no target ipi test

While an hmask of zero without an hbase of -1 (which would mean broadcast) is pointless, since nothing is targeted, the spec doesn't say it should return an error. Maybe it should? Anyway, for now, just confirm that it "works".

---
 riscv/sbi.c | 4 ++++
 1 file changed, 4 insertions(+)
riscv/sbi.c +4 -0
index 219f7187acf3..16d918d00848 100644
@@ -507,6 +507,10 @@ end_two:
 			max_hartid = cpus[cpu].hartid;
 	}
 
+	/* Test no targets */
+	ret = sbi_send_ipi(0, 0);
+	sbiret_report_error(&ret, SBI_SUCCESS, "no targets");
+
 	/* Try the next higher hartid than the max */
 	ret = sbi_send_ipi(2, max_hartid);
 	report_kfail(true, ret.error == SBI_ERR_INVALID_PARAM, "hart_mask got expected error (%ld)", ret.error);
Signature · 7 lines
2.48.1


-- 
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv
#1 lore raw
Quoted 28 lines · Andrew Jones

While an hmask of zero without an hbase of -1 (which would mean broadcast) is pointless, since nothing is targeted, the spec doesn't say it should return an error. Maybe it should? Anyway, for now, just confirm that it "works".

---
 riscv/sbi.c | 4 ++++
 1 file changed, 4 insertions(+)
riscv/sbi.c +4 -0
index 219f7187acf3..16d918d00848 100644
@@ -507,6 +507,10 @@ end_two:
 			max_hartid = cpus[cpu].hartid;
 	}
 
+	/* Test no targets */
+	ret = sbi_send_ipi(0, 0);
+	sbiret_report_error(&ret, SBI_SUCCESS, "no targets");
+
 	/* Try the next higher hartid than the max */
 	ret = sbi_send_ipi(2, max_hartid);
 	report_kfail(true, ret.error == SBI_ERR_INVALID_PARAM, "hart_mask got expected error (%ld)", ret.error);
Signature · 1 line
2.48.1

Applied to riscv/sbi[1] with the test below added too just to make sure that a nonzero hbase with a zero hmask doesn't break things.

Thanks,
drew

	ret = sbi_send_ipi(0, 1);
	sbiret_report_error(&ret, SBI_SUCCESS, "no targets, hart_mask_base is 1");

[1] https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/riscv/sbi

Signature · 3 lines
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv
#2 lore raw
In reply to Andrew Jones
Quoted 10 lines · Andrew Jones

While an hmask of zero without an hbase of -1 (which would mean broadcast) is pointless, since nothing is targeted, the spec doesn't say it should return an error. Maybe it should? Anyway, for now, just confirm that it "works".

---
 riscv/sbi.c | 4 ++++
 1 file changed, 4 insertions(+)

Merged.

Thanks,
drew

Signature · 3 lines
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv