aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/riscv/kernel/sys_riscv.c
diff options
context:
space:
mode:
authorAndrew Jones <ajones@ventanamicro.com>2023-11-22 17:47:02 +0100
committerPalmer Dabbelt <palmer@rivosinc.com>2024-01-03 03:36:47 -0800
commit36d842d654beba970e74ff0f6016c93623b82d37 (patch)
treeb3e0f1a94f0ca29f7e83049b9e7bc3e14430824d /arch/riscv/kernel/sys_riscv.c
parentLinux 6.7-rc1 (diff)
downloadwireguard-linux-36d842d654beba970e74ff0f6016c93623b82d37.tar.xz
wireguard-linux-36d842d654beba970e74ff0f6016c93623b82d37.zip
RISC-V: hwprobe: Clarify cpus size parameter
The "count" parameter associated with the 'cpus' parameter of the hwprobe syscall is the size in bytes of 'cpus'. Naming it 'cpu_count' may mislead users (it did me) to think it's the number of CPUs that are or can be represented by 'cpus' instead. This is particularly easy (IMO) to get wrong since 'cpus' is documented to be defined by CPU_SET(3) and CPU_SET(3) also documents a CPU_COUNT() (the number of CPUs in set) macro. CPU_SET(3) refers to the size of cpu sets with 'setsize'. Adopt 'cpusetsize' for the hwprobe parameter and specifically state it is in bytes in Documentation/riscv/hwprobe.rst to clarify. Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20231122164700.127954-7-ajones@ventanamicro.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/kernel/sys_riscv.c')
-rw-r--r--arch/riscv/kernel/sys_riscv.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
index c712037dbe10..5e4deb1308b8 100644
--- a/arch/riscv/kernel/sys_riscv.c
+++ b/arch/riscv/kernel/sys_riscv.c
@@ -246,7 +246,7 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
}
static int do_riscv_hwprobe(struct riscv_hwprobe __user *pairs,
- size_t pair_count, size_t cpu_count,
+ size_t pair_count, size_t cpusetsize,
unsigned long __user *cpus_user,
unsigned int flags)
{
@@ -264,13 +264,13 @@ static int do_riscv_hwprobe(struct riscv_hwprobe __user *pairs,
* 0 as a shortcut to all online CPUs.
*/
cpumask_clear(&cpus);
- if (!cpu_count && !cpus_user) {
+ if (!cpusetsize && !cpus_user) {
cpumask_copy(&cpus, cpu_online_mask);
} else {
- if (cpu_count > cpumask_size())
- cpu_count = cpumask_size();
+ if (cpusetsize > cpumask_size())
+ cpusetsize = cpumask_size();
- ret = copy_from_user(&cpus, cpus_user, cpu_count);
+ ret = copy_from_user(&cpus, cpus_user, cpusetsize);
if (ret)
return -EFAULT;
@@ -347,10 +347,10 @@ arch_initcall_sync(init_hwprobe_vdso_data);
#endif /* CONFIG_MMU */
SYSCALL_DEFINE5(riscv_hwprobe, struct riscv_hwprobe __user *, pairs,
- size_t, pair_count, size_t, cpu_count, unsigned long __user *,
+ size_t, pair_count, size_t, cpusetsize, unsigned long __user *,
cpus, unsigned int, flags)
{
- return do_riscv_hwprobe(pairs, pair_count, cpu_count,
+ return do_riscv_hwprobe(pairs, pair_count, cpusetsize,
cpus, flags);
}