[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2] linux-user/riscv: Add syscall riscv_hwprobe
From: |
Richard Henderson |
Subject: |
Re: [RFC v2] linux-user/riscv: Add syscall riscv_hwprobe |
Date: |
Fri, 2 Jun 2023 19:57:24 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
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~
Re: [RFC v2] linux-user/riscv: Add syscall riscv_hwprobe,
Richard Henderson <=