Skip to contentSkip to conversation

x86/amx: compatible with older kernel release

PATCH In review Yang Zhong 2 participants 2 messages Mar 18, 2022

lore
Share & tools
lore

Yang Zhong

author
#0 lore raw

PATCH 1/1 x86/amx: compatible with older kernel release

The AMX KVM introduced one new ARCH_GET_XCOMP_SUPP system attribute API to get host side supported_xcr0 and latest Qemu can decide if it can request dynamically enabled XSAVE features permission. But this implementation(19db68ca68) did not consider older kernel release. This patch can avoid to read this new KVM_GET_DEVICE_ATTR ioctl.

---
 target/i386/kvm/kvm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
target/i386/kvm/kvm.c +8 -8
index ef2c68a6f4..cda95e7ba6 100644
@@ -420,14 +420,14 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
         bool sys_attr = kvm_check_extension(s, KVM_CAP_SYS_ATTRIBUTES);
         if (!sys_attr) {
             warn_report("cannot get sys attribute capabilities %d", sys_attr);
-        }
-
-        int rc = kvm_ioctl(s, KVM_GET_DEVICE_ATTR, &attr);
-        if (rc == -1 && (errno == ENXIO || errno == EINVAL)) {
-            warn_report("KVM_GET_DEVICE_ATTR(0, KVM_X86_XCOMP_GUEST_SUPP) "
-                        "error: %d", rc);
-        }
-        ret = (reg == R_EAX) ? bitmask : bitmask >> 32;
+        } else {
+            int rc = kvm_ioctl(s, KVM_GET_DEVICE_ATTR, &attr);
+            if (rc == -1 && (errno == ENXIO || errno == EINVAL)) {
+                warn_report("KVM_GET_DEVICE_ATTR(0, KVM_X86_XCOMP_GUEST_SUPP) "
+                            "error: %d", rc);
+            }
+            ret = (reg == R_EAX) ? bitmask : bitmask >> 32;
+       }
     } else if (function == 0x80000001 && reg == R_ECX) {
         /*
          * It's safe to enable TOPOEXT even if it's not returned by
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Yang Zhong

The AMX KVM introduced one new ARCH_GET_XCOMP_SUPP system attribute API to get host side supported_xcr0 and latest Qemu can decide if it can request dynamically enabled XSAVE features permission. But this implementation(19db68ca68) did not consider older kernel release. This patch can avoid to read this new KVM_GET_DEVICE_ATTR ioctl.

---
 target/i386/kvm/kvm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Thank you.

Michal