From: Andreas Schwab <schwab@suse.de>
To: Laurent Vivier <laurent@vivier.eu>
Cc: Palmer Dabbelt <palmer@rivosinc.com>,
Robbin Ehn <rehn@rivosinc.com>,
Alistair Francis <alistair.francis@wdc.com>,
qemu-devel@nongnu.org
Subject: [PATCH] linux-user: fix handling of cpu mask in riscv_hwprobe syscall
Date: Tue, 04 Mar 2025 17:52:52 +0100 [thread overview]
Message-ID: <mvmo6yglouz.fsf@suse.de> (raw)
The third argument of the riscv_hwprobe syscall contains the size of the
cpu mask in bytes, not bits.
Signed-off-by: Andreas Schwab <schwab@suse.de>
---
linux-user/syscall.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a22a5df8cc..4cc1a31d0d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9120,16 +9120,16 @@ static void risc_hwprobe_fill_pairs(CPURISCVState *env,
static int cpu_set_valid(abi_long arg3, abi_long arg4)
{
- int ret, i, tmp;
+ int ret, i;
size_t host_mask_size, target_mask_size;
unsigned long *host_mask;
/*
* cpu_set_t represent CPU masks as bit masks of type unsigned long *.
- * arg3 contains the cpu count.
+ * arg3 contains the size of the cpu mask.
*/
- tmp = (8 * sizeof(abi_ulong));
- target_mask_size = ((arg3 + tmp - 1) / tmp) * sizeof(abi_ulong);
+ target_mask_size = (arg3 + (sizeof(abi_ulong) - 1)) &
+ ~(sizeof(abi_ulong) - 1);
host_mask_size = (target_mask_size + (sizeof(*host_mask) - 1)) &
~(sizeof(*host_mask) - 1);
--
2.48.1
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
next reply other threads:[~2025-03-04 16:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 16:52 Andreas Schwab [this message]
2025-03-10 23:10 ` [PATCH] linux-user: fix handling of cpu mask in riscv_hwprobe syscall Alistair Francis
2025-03-11 7:28 ` Robbin Ehn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mvmo6yglouz.fsf@suse.de \
--to=schwab@suse.de \
--cc=alistair.francis@wdc.com \
--cc=laurent@vivier.eu \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.org \
--cc=rehn@rivosinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.