qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 02/15] arm/kvm: add accessors for storing host features into


From: Richard Henderson
Subject: Re: [PATCH 02/15] arm/kvm: add accessors for storing host features into idregs
Date: Fri, 7 Feb 2025 10:50:50 -0800
User-agent: Mozilla Thunderbird

On 2/7/25 03:02, Cornelia Huck wrote:
+/* read a 32b sysreg value and store it in the idregs */
+static int get_host_cpu_reg32(int fd, ARMHostCPUFeatures *ahcf, ARMSysRegs 
sysreg)
+{
+    int index = get_sysreg_idx(sysreg);
+    uint64_t *reg;
+    int ret;
+
+    if (index < 0) {
+        return -ERANGE;
+    }
+    reg = &ahcf->isar.idregs[index];
+    ret = read_sys_reg32(fd, (uint32_t *)reg, 
idregs_sysreg_to_kvm_reg(sysreg));
+    return ret;
+}
+
+/* read a 64b sysreg value and store it in the idregs */
+static int get_host_cpu_reg64(int fd, ARMHostCPUFeatures *ahcf, ARMSysRegs 
sysreg)
+{
+    int index = get_sysreg_idx(sysreg);

Why pass the ARMSysRegs value instead of the ARMIDRegisterIdx value?

You save yourself a linear search over the id_register_sysreg array, and you can't use this interface with a sysreg that doesn't have an index anyway -- ERANGE is a new failure mode.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]