OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: sbi: Fix shift bug in sbi_system_reset
@ 2023-12-21  1:44 Xiang W
  2023-12-25  9:24 ` Anup Patel
  2023-12-27  5:46 ` Anup Patel
  0 siblings, 2 replies; 10+ messages in thread
From: Xiang W @ 2023-12-21  1:44 UTC (permalink / raw)
  To: opensbi

There is a problem with judging whether the current hart belongs to
hmask. If cur_hartid minus hbase is greater than BITS_PER_LONG, the
previous hmask will also have a bit cleared incorrectly, which will
cause some harts to lose ipi.

Signed-off-by: Xiang W <wxjstz@126.com>
---
 lib/sbi/sbi_system.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c
index d1fa349..e930272 100644
--- a/lib/sbi/sbi_system.c
+++ b/lib/sbi/sbi_system.c
@@ -72,7 +72,8 @@ void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason)
 
 	/* Send HALT IPI to every hart other than the current hart */
 	while (!sbi_hsm_hart_interruptible_mask(dom, hbase, &hmask)) {
-		if (hbase <= cur_hartid)
+		if ((hbase <= cur_hartid)
+			  && (cur_hartid < hbase + BITS_PER_LONG))
 			hmask &= ~(1UL << (cur_hartid - hbase));
 		if (hmask)
 			sbi_ipi_send_halt(hmask, hbase);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-27  5:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21  1:44 [PATCH] lib: sbi: Fix shift bug in sbi_system_reset Xiang W
2023-12-25  9:24 ` Anup Patel
2023-12-25  9:32   ` Xiang W
2023-12-25  9:48   ` Andreas Schwab
2023-12-25 16:09     ` Xiang W
2023-12-26 15:51     ` Anup Patel
2023-12-26 18:03       ` Samuel Holland
2023-12-27  1:54         ` Xiang W
2023-12-27  5:45           ` Anup Patel
2023-12-27  5:46 ` Anup Patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox