1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright 2023 Rivos, Inc
6 #include <linux/types.h>
7 #include <vdso/datapage.h>
8 #include <vdso/helpers.h>
10 extern int riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count,
11 size_t cpu_count, unsigned long *cpus,
14 /* Add a prototype to avoid -Wmissing-prototypes warning. */
15 int __vdso_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count,
16 size_t cpu_count, unsigned long *cpus,
19 int __vdso_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count,
20 size_t cpu_count, unsigned long *cpus,
23 const struct vdso_data *vd = __arch_get_vdso_data();
24 const struct arch_vdso_data *avd = &vd->arch_data;
25 bool all_cpus = !cpu_count && !cpus;
26 struct riscv_hwprobe *p = pairs;
27 struct riscv_hwprobe *end = pairs + pair_count;
30 * Defer to the syscall for exotic requests. The vdso has answers
31 * stashed away only for the "all cpus" case. If all CPUs are
32 * homogeneous, then this function can handle requests for arbitrary
35 if ((flags != 0) || (!all_cpus && !avd->homogeneous_cpus))
36 return riscv_hwprobe(pairs, pair_count, cpu_count, cpus, flags);
38 /* This is something we can handle, fill out the pairs. */
40 if (riscv_hwprobe_key_is_valid(p->key)) {
41 p->value = avd->all_cpu_hwprobe_values[p->key];