qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yang Zhong <yang.zhong@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: yang.zhong@intel.com, kevin.tian@intel.com, seanjc@google.com,
	jing2.liu@linux.intel.com, qemu-devel@nongnu.org,
	wei.w.wang@intel.com, guang.zeng@intel.com
Subject: Re: [RFC PATCH 3/7] x86: Grant AMX permission for guest
Date: Fri, 21 Jan 2022 15:21:47 +0800	[thread overview]
Message-ID: <20220121072147.GD29921@yangzhon-Virtual> (raw)
In-Reply-To: <0ad4f708-f338-0742-dc69-af08e908cff5@redhat.com>

On Tue, Jan 18, 2022 at 02:06:55PM +0100, Paolo Bonzini wrote:
> Sorry, hit send on the wrong window.  This is the only patch that
> will require a bit more work.
> 
> On 1/18/22 13:52, Paolo Bonzini wrote:
> >>@@ -124,6 +150,8 @@ void x86_cpus_init(X86MachineState *x86ms,
> >>int default_cpu_version)
> >>      MachineState *ms = MACHINE(x86ms);
> >>      MachineClass *mc = MACHINE_GET_CLASS(x86ms);
> >>+    /* Request AMX pemission for guest */
> >>+    x86_xsave_req_perm();
> >>      x86_cpu_set_default_version(default_cpu_version);
> >
> >This should be done before creating a CPU with support for state
> >component 18.  It happens in kvm_init_vcpu, with the following
> >call stack:
> >
> >     kvm_init_vcpu
> >     kvm_vcpu_thread_fn
> >     kvm_start_vcpu_thread
> >     qemu_init_vcpu
> >     x86_cpu_realizefn
> >
> >The issue however is that this has to be done before
> >KVM_GET_SUPPORTED_CPUID and KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2).
> >
> >For the former, you can assume that anything returned by
> >ARCH_GET_XCOMP_GUEST_PERM will be returned by
> >KVM_GET_SUPPORTED_CPUID in CPUID[0xD].EDX:EAX, so you can:
> >
> >- add it to kvm_arch_get_supported_cpuid
> 
> ... together with the other special cases (otherwise
> x86_cpu_get_supported_feature_word complains that XTILEDATA is not
> available)
> 
> - change kvm_cpu_xsave_init to use host_cpuid instead of
> kvm_arch_get_supported_cpuid.
> 
> - call ARCH_REQ_XCOMP_GUEST_PERM from
> x86_cpu_enable_xsave_components, with a conditional like
> 
>     if (kvm_enabled()) {
>         kvm_request_xsave_components(cpu, mask);
>     }
> 
> KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) is actually not a problem; the
> ioctl is only called from kvm_arch_init_vcpu and therefore after
> x86_cpu_enable_xsave_components.
>
  
  Paolo, thanks too much for those detailed steps!
  I have completed the new patch according to those steps, and work well.

  Since this is only big change patch, the next version will be removed RFC.

  Thanks!
  Yang  
  
 
> Thanks,
> 
> Paolo


  reply	other threads:[~2022-01-21  9:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  9:31 [RFC PATCH 0/7] AMX support in Qemu Yang Zhong
2022-01-07  9:31 ` [RFC PATCH 1/7] x86: Fix the 64-byte boundary enumeration for extended state Yang Zhong
2022-01-10  8:20   ` Tian, Kevin
2022-01-11  2:22     ` Yang Zhong
2022-01-18 12:37       ` Paolo Bonzini
2022-01-21  7:14         ` Yang Zhong
2022-01-07  9:31 ` [RFC PATCH 2/7] x86: Add AMX XTILECFG and XTILEDATA components Yang Zhong
2022-01-10  8:23   ` Tian, Kevin
2022-01-11  2:32     ` Yang Zhong
2022-01-18 12:39     ` Paolo Bonzini
2022-01-21  7:15       ` Yang Zhong
2022-01-07  9:31 ` [RFC PATCH 3/7] x86: Grant AMX permission for guest Yang Zhong
2022-01-10  8:36   ` Tian, Kevin
2022-01-11  6:46     ` Yang Zhong
2022-01-18 12:52   ` Paolo Bonzini
2022-01-18 13:06     ` Paolo Bonzini
2022-01-21  7:21       ` Yang Zhong [this message]
2022-01-07  9:31 ` [RFC PATCH 4/7] x86: Add XFD faulting bit for state components Yang Zhong
2022-01-10  8:38   ` Tian, Kevin
2022-01-11  5:32     ` Yang Zhong
2022-01-18 12:52   ` Paolo Bonzini
2022-01-21  7:18     ` Yang Zhong
2022-01-07  9:31 ` [RFC PATCH 5/7] x86: Add AMX CPUIDs enumeration Yang Zhong
2022-01-07  9:31 ` [RFC PATCH 6/7] x86: Use new XSAVE ioctls handling Yang Zhong
2022-01-10  8:40   ` Tian, Kevin
2022-01-10  9:47     ` Zeng Guang
2022-01-11  2:30       ` Tian, Kevin
2022-01-11  4:29         ` Zeng Guang
2022-01-12  2:51         ` Zeng Guang
2022-01-12  4:34           ` Wang, Wei W
2022-01-07  9:31 ` [RFC PATCH 7/7] x86: Support XFD and AMX xsave data migration Yang Zhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220121072147.GD29921@yangzhon-Virtual \
    --to=yang.zhong@intel.com \
    --cc=guang.zeng@intel.com \
    --cc=jing2.liu@linux.intel.com \
    --cc=kevin.tian@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seanjc@google.com \
    --cc=wei.w.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).