On 6/2/23 02:41, Robbin Ehn wrote:
+struct riscv_hwprobe { + int64_t key; + uint64_t value; +};
This needs to use abi_llong and abi_ullong, as the guest may not have the same alignment requirements as the host.
+ case RISCV_HWPROBE_KEY_MVENDORID: + pair->value = cfg->mvendorid; + break;
You must use __get_user and __put_user to handle host vs guest endianness. All over.
+ case RISCV_HWPROBE_KEY_CPUPERF_0: + pair->value = RISCV_HWPROBE_MISALIGNED_UNKNOWN;
Is that really what you want to expose here? FAST is always going to be true, in that handling the unaligned access in the host is going to be faster than in the emulated guest.
+ default: + pair->key = -1; + break;
Misalignment.
+#if defined(TARGET_RISCV) + case TARGET_NR_riscv_hwprobe: + { + struct riscv_hwprobe *host_pairs; + + /* flags must be 0 */ + if (arg5 != 0) { + return -TARGET_EINVAL; + } + + /* check cpu_set */ + if (arg3 != 0) { + int ccpu; + size_t cpu_setsize = CPU_ALLOC_SIZE(arg3); + cpu_set_t *host_cpus = lock_user(VERIFY_READ, arg4, + cpu_setsize, 0); + if (!host_cpus) { + return -TARGET_EFAULT; + } + ccpu = CPU_COUNT_S(cpu_setsize, host_cpus);
Where does CPU_ALLOC_SIZE and CPU_COUNT_S come from?
+ unlock_user(host_cpus, arg4, cpu_setsize); + /* no selected cpu */ + if (ccpu == 0) { + return -TARGET_EINVAL; + }
I suppose you're just looking to see that the set is not empty? r~