* [PATCH] x86/amx: compatible with older kernel release
@ 2022-03-18 11:55 Yang Zhong
  2022-03-18 14:31 ` Michal Prívozník
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Zhong @ 2022-03-18 11:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: yang.zhong, pbonzini, pkrempa, mprivozn
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.
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
 target/i386/kvm/kvm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index ef2c68a6f4..cda95e7ba6 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -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
-- 
2.25.1
^ permalink raw reply related	[flat|nested] 2+ messages in thread
* Re: [PATCH] x86/amx: compatible with older kernel release
  2022-03-18 11:55 [PATCH] x86/amx: compatible with older kernel release Yang Zhong
@ 2022-03-18 14:31 ` Michal Prívozník
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Prívozník @ 2022-03-18 14:31 UTC (permalink / raw)
  To: Yang Zhong, qemu-devel; +Cc: pbonzini, pkrempa
On 3/18/22 12:55, Yang Zhong wrote:
> 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.
> 
> Signed-off-by: Yang Zhong <yang.zhong@intel.com>
> ---
>  target/i386/kvm/kvm.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
Tested-by: Michal Privoznik <mprivozn@redhat.com>
Thank you.
Michal
^ permalink raw reply	[flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-18 14:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-18 11:55 [PATCH] x86/amx: compatible with older kernel release Yang Zhong
2022-03-18 14:31 ` Michal Prívozník
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).