From patchwork Wed Nov 6 11:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13864445 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18A591DF25D for ; Wed, 6 Nov 2024 11:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730893110; cv=none; b=aitwN6qcn9NZW6rgRj71Bw8VBA5s5UGIIs0RNQElyX1fE4JMv323Fx5HCi7UfY1p2pHux2MlJoIay9cl+H1fJt9+vdsj3pbPE2ZggTKUKxfXorAHKqemwadv/hr4lePk0Wnm148I//Sq2UIJiRk3q1BCtlf/Vt17x8xOAWNJez8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730893110; c=relaxed/simple; bh=+3N3tPmq9Enxzcre2jV43GQ8dmZ+Ady39InNYSJ5PNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PSYXk9ChrPr3MIRnc5M7TWZ4L9V19w12TZi2dq+Ns0XLmooIB4Bv+TKZ4sQ8igMaOYEqkOZfmogCxXhkDi60LXCHheWwnwibp4sl/S1aD4P+WQb9uFLB8VP1DAu5iqjxSz0PgsSDYtweg7jYgyWhpvMFYMC7b0H1oleoQTcvwYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DAvbv7zs; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DAvbv7zs" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1730893103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vrJKQYsqPwfe+UgIDxmj85EUMOBw0DGpaZVWjzi1Ymg=; b=DAvbv7zs/SfPNk1LVBFE5rQsOlzAM2Bk+0rhx8Az5ssH2roZPbYm6nFYOHhF69DqjkdbXI aiAf9LTeVb3O/P+Bn372MgeGFRTK+SoVpy371ifF9X0TKPIXy6YUnwGOtv+RFafcp+9kvC +NcFHtIvH0HG9DsYCG4Par8HRE1Ca9U= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: cade.richard@gmail.com, atishp@rivosinc.com, jamestiotio@gmail.com Subject: [kvm-unit-tests PATCH v2 1/3] riscv: Add sbi_send_ipi_broadcast Date: Wed, 6 Nov 2024 12:38:16 +0100 Message-ID: <20241106113814.42992-6-andrew.jones@linux.dev> In-Reply-To: <20241106113814.42992-5-andrew.jones@linux.dev> References: <20241106113814.42992-5-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Coming SBI IPI tests will use this, but as it could be useful for other tests too, add it to the library. Signed-off-by: Andrew Jones --- lib/riscv/asm/sbi.h | 1 + lib/riscv/sbi.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/riscv/asm/sbi.h b/lib/riscv/asm/sbi.h index 1319439b7118..102486c00de3 100644 --- a/lib/riscv/asm/sbi.h +++ b/lib/riscv/asm/sbi.h @@ -87,6 +87,7 @@ struct sbiret sbi_hart_get_status(unsigned long hartid); struct sbiret sbi_send_ipi(unsigned long hart_mask, unsigned long hart_mask_base); struct sbiret sbi_send_ipi_cpu(int cpu); struct sbiret sbi_send_ipi_cpumask(const cpumask_t *mask); +struct sbiret sbi_send_ipi_broadcast(void); struct sbiret sbi_set_timer(unsigned long stime_value); long sbi_probe(int ext); diff --git a/lib/riscv/sbi.c b/lib/riscv/sbi.c index f25bde169490..02dd338c1915 100644 --- a/lib/riscv/sbi.c +++ b/lib/riscv/sbi.c @@ -62,13 +62,18 @@ struct sbiret sbi_send_ipi_cpu(int cpu) return sbi_send_ipi(1UL, cpus[cpu].hartid); } +struct sbiret sbi_send_ipi_broadcast(void) +{ + return sbi_send_ipi(0, -1UL); +} + struct sbiret sbi_send_ipi_cpumask(const cpumask_t *mask) { struct sbiret ret; cpumask_t tmp; if (cpumask_full(mask)) - return sbi_send_ipi(0, -1UL); + return sbi_send_ipi_broadcast(); cpumask_copy(&tmp, mask); From patchwork Wed Nov 6 11:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13864446 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EA501DF268 for ; Wed, 6 Nov 2024 11:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730893110; cv=none; b=RFfngQwnwFbHJ/o+OW34DmtLgoLk6YSDg7KJ0vjsLZkEgBaTe1JimqrN4i498yMx5447g6kKSL1wH8zVyNHSL0ZeCZQInbVM1N9LENgzuVeobnzbcQGxCyBJ/nGj3hcP4DwN1MWy14b05AmiqvhvmIzHpAhc8e0gQrAv8Kb/N/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730893110; c=relaxed/simple; bh=lE9h260qN76Ms80BPwyPtMndX5EoEKYmNOxUrB9x+JA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3XcLjoRDBRy6LPqyHM6MMMCm2G7xImSCfqVWK9ZWrOtNzclbfZqCDQaIJW8F5az3KVfQj2GKPUCRR3JnG0Lj6nia/jf0au0Xn7Ny45BDyywE32PdF42Dh5qp6C+4xcOH6GMjEj+XhCch4g9rA2BnsLQ85LWk+N0/lsJUOB0MO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=h1pBx/cW; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="h1pBx/cW" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1730893106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CVQZ+vtAuPPUPtcf7+iSeuuM3vx7C5aQKk0deTKTf1A=; b=h1pBx/cWxI8zDs59SGTH3rj39p+Vz3S38Wq5RcGJHtpPUqZeaXxmpBBil0q8IJM1wFjxZq hi8EHCRLcUUCvbTFPPssI7gUJgcqiTeBBu8LRfKmfyDadJiDSgl/pFHINt/0zgg7WUfhol KOj6xI5Tht7mCTJzwPNIvNHF7kgt9CU= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: cade.richard@gmail.com, atishp@rivosinc.com, jamestiotio@gmail.com, Cade Richard Subject: [kvm-unit-tests PATCH v2 2/3] riscv: sbi: Add IPI extension tests Date: Wed, 6 Nov 2024 12:38:17 +0100 Message-ID: <20241106113814.42992-7-andrew.jones@linux.dev> In-Reply-To: <20241106113814.42992-5-andrew.jones@linux.dev> References: <20241106113814.42992-5-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT From: Cade Richard Ensure IPIs directed at single harts are received and also that all harts receive IPIs on broadcast. Also check for invalid param errors when the params result in hartids greater than the max. Signed-off-by: Cade Richard Co-developed-by: Andrew Jones Signed-off-by: Andrew Jones --- lib/cpumask.h | 13 ++++ riscv/sbi.c | 147 +++++++++++++++++++++++++++++++++++++++++++- riscv/unittests.cfg | 1 + 3 files changed, 159 insertions(+), 2 deletions(-) diff --git a/lib/cpumask.h b/lib/cpumask.h index 37d360786573..b4cd83a66a56 100644 --- a/lib/cpumask.h +++ b/lib/cpumask.h @@ -72,6 +72,19 @@ static inline bool cpumask_subset(const struct cpumask *src1, const struct cpuma return !lastmask || !((cpumask_bits(src1)[i] & ~cpumask_bits(src2)[i]) & lastmask); } +static inline bool cpumask_equal(const struct cpumask *src1, const struct cpumask *src2) +{ + unsigned long lastmask = BIT_MASK(nr_cpus) - 1; + int i; + + for (i = 0; i < BIT_WORD(nr_cpus); ++i) { + if (cpumask_bits(src1)[i] != cpumask_bits(src2)[i]) + return false; + } + + return !lastmask || (cpumask_bits(src1)[i] & lastmask) == (cpumask_bits(src2)[i] & lastmask); +} + static inline bool cpumask_empty(const cpumask_t *mask) { unsigned long lastmask = BIT_MASK(nr_cpus) - 1; diff --git a/riscv/sbi.c b/riscv/sbi.c index c081953c877c..cdf8d13cc9cf 100644 --- a/riscv/sbi.c +++ b/riscv/sbi.c @@ -6,11 +6,15 @@ */ #include #include +#include +#include +#include +#include +#include #include #include -#include #include -#include + #include #include #include @@ -46,6 +50,20 @@ static struct sbiret sbi_dbcn_write_byte(uint8_t byte) return sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE_BYTE, byte, 0, 0, 0, 0, 0); } +static int rand_online_cpu(prng_state *ps) +{ + int cpu, me = smp_processor_id(); + + for (;;) { + cpu = prng32(ps) % nr_cpus; + cpu = cpumask_next(cpu - 1, &cpu_present_mask); + if (cpu != nr_cpus && cpu != me && cpu_present(cpu)) + break; + } + + return cpu; +} + static void split_phys_addr(phys_addr_t paddr, unsigned long *hi, unsigned long *lo) { *lo = (unsigned long)paddr; @@ -286,6 +304,130 @@ static void check_time(void) report_prefix_popn(2); } +static bool ipi_received[NR_CPUS]; +static bool ipi_timeout[NR_CPUS]; +static cpumask_t ipi_done; + +static void ipi_timeout_handler(struct pt_regs *regs) +{ + timer_stop(); + ipi_timeout[smp_processor_id()] = true; +} + +static void ipi_irq_handler(struct pt_regs *regs) +{ + ipi_ack(); + ipi_received[smp_processor_id()] = true; +} + +static void ipi_hart_wait(void *data) +{ + unsigned long timeout = (unsigned long)data; + int me = smp_processor_id(); + + install_irq_handler(IRQ_S_SOFT, ipi_irq_handler); + install_irq_handler(IRQ_S_TIMER, ipi_timeout_handler); + local_ipi_enable(); + timer_irq_enable(); + local_irq_enable(); + + timer_start(timeout); + while (!READ_ONCE(ipi_received[me]) && !READ_ONCE(ipi_timeout[me])) + cpu_relax(); + local_irq_disable(); + timer_stop(); + local_ipi_disable(); + timer_irq_disable(); + + cpumask_set_cpu(me, &ipi_done); +} + +static void ipi_hart_check(cpumask_t *mask) +{ + int cpu; + + for_each_cpu(cpu, mask) { + if (ipi_timeout[cpu]) { + const char *rec = ipi_received[cpu] ? "but was still received" + : "and has still not been received"; + report_fail("ipi timed out on cpu%d %s", cpu, rec); + } + + ipi_timeout[cpu] = false; + ipi_received[cpu] = false; + } +} + +static void check_ipi(void) +{ + unsigned long d = getenv("SBI_IPI_TIMEOUT") ? strtol(getenv("SBI_IPI_TIMEOUT"), NULL, 0) : 200000; + int nr_cpus_present = cpumask_weight(&cpu_present_mask); + int me = smp_processor_id(); + unsigned long max_hartid = 0; + cpumask_t ipi_receivers; + static prng_state ps; + struct sbiret ret; + int cpu; + + ps = prng_init(0xDEADBEEF); + + report_prefix_push("ipi"); + + if (!sbi_probe(SBI_EXT_IPI)) { + report_skip("ipi extension not available"); + report_prefix_pop(); + return; + } + + if (nr_cpus_present < 2) { + report_skip("At least 2 cpus required"); + report_prefix_pop(); + return; + } + + report_prefix_push("random hart"); + cpumask_clear(&ipi_done); + cpumask_clear(&ipi_receivers); + cpu = rand_online_cpu(&ps); + cpumask_set_cpu(cpu, &ipi_receivers); + on_cpu_async(cpu, ipi_hart_wait, (void *)d); + ret = sbi_send_ipi_cpu(cpu); + report(ret.error == SBI_SUCCESS, "ipi returned success"); + while (!cpumask_equal(&ipi_done, &ipi_receivers)) + cpu_relax(); + ipi_hart_check(&ipi_receivers); + report_prefix_pop(); + + report_prefix_push("broadcast"); + cpumask_clear(&ipi_done); + cpumask_copy(&ipi_receivers, &cpu_present_mask); + cpumask_clear_cpu(me, &ipi_receivers); + on_cpumask_async(&ipi_receivers, ipi_hart_wait, (void *)d); + ret = sbi_send_ipi_broadcast(); + report(ret.error == SBI_SUCCESS, "ipi returned success"); + while (!cpumask_equal(&ipi_done, &ipi_receivers)) + cpu_relax(); + ipi_hart_check(&ipi_receivers); + report_prefix_pop(); + + report_prefix_push("invalid parameters"); + + for_each_present_cpu(cpu) { + if (cpus[cpu].hartid > max_hartid) + max_hartid = cpus[cpu].hartid; + } + + /* 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); + ret = sbi_send_ipi(1, max_hartid + 1); + report_kfail(true, ret.error == SBI_ERR_INVALID_PARAM, "hart_mask_base got expected error (%ld)", ret.error); + + report_prefix_pop(); + + report_prefix_pop(); +} + #define DBCN_WRITE_TEST_STRING "DBCN_WRITE_TEST_STRING\n" #define DBCN_WRITE_BYTE_TEST_BYTE ((u8)'a') @@ -437,6 +579,7 @@ int main(int argc, char **argv) report_prefix_push("sbi"); check_base(); check_time(); + check_ipi(); check_dbcn(); return report_summary(); diff --git a/riscv/unittests.cfg b/riscv/unittests.cfg index cbd36bf63e14..2eb760eca24e 100644 --- a/riscv/unittests.cfg +++ b/riscv/unittests.cfg @@ -16,4 +16,5 @@ groups = selftest # Set $FIRMWARE_OVERRIDE to /path/to/firmware to select the SBI implementation. [sbi] file = sbi.flat +smp = $MAX_SMP groups = sbi From patchwork Wed Nov 6 11:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13864447 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E3411DEFEB for ; Wed, 6 Nov 2024 11:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730893116; cv=none; b=Ohj+Wjo0s1YVaG2xdFuQ0yDENmJYY58pnlTOIli3UEETKOw/gXz6323QwtkyRmqhFDQJot1f8gUTSWGHeVo13ex/n/4fF0vOhvKqfe/UUrWtyhQIoBKzQrdWw9TsutxwgXxo00cXNLsxJDFs1GICF9WdXjDwACSWViO0hBwzfVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730893116; c=relaxed/simple; bh=DFNEoMtxV11E35T3a3MXNMORxXhvZwAf8/xDB0l1wr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BqhFEO7vbwMI6awulEYyHsPUP36agceuV0ah+y9tYfCh4lkSOtqiXLzF5FRWL5B18G/7Wkh6+D6ch6z+HcMQZbG3DaYIv8Sp1SxlxSJDTiqniSitOl3YRbqrlnSFWTOsJmvZ3SFYgPWXHGS9PszitDT7bAIMa7h/PcG6EoPVD/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=S7nJ8xmY; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="S7nJ8xmY" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1730893112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RPZ3SUBHEP/krVjbR2O6PIbvJJxePC2EroXXOKSSCDU=; b=S7nJ8xmYxMgu5etE4xqwe8IYMoEjgQUGtik2But4/mZBwT9zeFfIhTNGgwZTnBRhqKTjjZ nk6YDK4kJKrWGu+npE4tqPwPlDgsR6JfTzlgdrAKeiZXfD13o4+xZoFVexzx4gD9DOqLBr 4h0UpDGkf0INUPSYAwZwk7KvRsFbb0A= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: cade.richard@gmail.com, atishp@rivosinc.com, jamestiotio@gmail.com Subject: [kvm-unit-tests PATCH v2 3/3] riscv: sbi: Add two in hart_mask IPI test Date: Wed, 6 Nov 2024 12:38:18 +0100 Message-ID: <20241106113814.42992-8-andrew.jones@linux.dev> In-Reply-To: <20241106113814.42992-5-andrew.jones@linux.dev> References: <20241106113814.42992-5-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT We should ensure that when hart_mask has more than one hartid that both harts get IPIs with a single call of the IPI function. Signed-off-by: Andrew Jones --- riscv/sbi.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/riscv/sbi.c b/riscv/sbi.c index cdf8d13cc9cf..8ccdf42f902a 100644 --- a/riscv/sbi.c +++ b/riscv/sbi.c @@ -364,10 +364,11 @@ static void check_ipi(void) int nr_cpus_present = cpumask_weight(&cpu_present_mask); int me = smp_processor_id(); unsigned long max_hartid = 0; + unsigned long hartid1, hartid2; cpumask_t ipi_receivers; static prng_state ps; struct sbiret ret; - int cpu; + int cpu, cpu2; ps = prng_init(0xDEADBEEF); @@ -398,6 +399,42 @@ static void check_ipi(void) ipi_hart_check(&ipi_receivers); report_prefix_pop(); + report_prefix_push("two in hart_mask"); + + if (nr_cpus_present < 3) { + report_skip("3 cpus required"); + goto end_two; + } + + cpu = rand_online_cpu(&ps); + hartid1 = cpus[cpu].hartid; + hartid2 = 0; + for_each_present_cpu(cpu2) { + if (cpu2 == cpu || cpu2 == me) + continue; + hartid2 = cpus[cpu2].hartid; + if (__builtin_labs(hartid2 - hartid1) < BITS_PER_LONG) + break; + } + if (cpu2 == nr_cpus) { + report_skip("hartids are too sparse"); + goto end_two; + } + + cpumask_clear(&ipi_done); + cpumask_clear(&ipi_receivers); + cpumask_set_cpu(cpu, &ipi_receivers); + cpumask_set_cpu(cpu2, &ipi_receivers); + on_cpu_async(cpu, ipi_hart_wait, (void *)d); + on_cpu_async(cpu2, ipi_hart_wait, (void *)d); + ret = sbi_send_ipi((1UL << __builtin_labs(hartid2 - hartid1)) | 1UL, hartid1 < hartid2 ? hartid1 : hartid2); + report(ret.error == SBI_SUCCESS, "ipi returned success"); + while (!cpumask_equal(&ipi_done, &ipi_receivers)) + cpu_relax(); + ipi_hart_check(&ipi_receivers); +end_two: + report_prefix_pop(); + report_prefix_push("broadcast"); cpumask_clear(&ipi_done); cpumask_copy(&ipi_receivers, &cpu_present_mask);