From: Paolo Bonzini <pbonzini@redhat.com>
To: Yang Zhong <yang.zhong@intel.com>
Cc: 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: [PATCH 3/7] x86: Grant AMX permission for guest
Date: Fri, 28 Jan 2022 12:09:30 +0100 [thread overview]
Message-ID: <bbcb6166-5c5f-bd61-887d-935713bb7bd2@redhat.com> (raw)
In-Reply-To: <20220127134520.GA8954@yangzhon-Virtual>
On 1/27/22 14:45, Yang Zhong wrote:
>
> Thanks Paolo, from your below KVM changes:
> https://lore.kernel.org/kvm/20220126152210.3044876-3-pbonzini@redhat.com/T/#m7bf9a03c47c29d21deb78604bc290a45aa5e98f5
>
> So the changes in kvm_arch_get_supported_cpuid() like below?
> + } else if (function == 0xd && index == 0 && reg == R_EAX) {
&& (reg == R_EAX || reg == R_EDX)
> + struct kvm_device_attr attr = {
> + .group = 0,
> + .attr = KVM_X86_XCOMP_GUEST_SUPP,
> + .addr = (unsigned long) &bitmask
> + };
> +
> + kvm_fd = open_kvm_dev_path_or_exit();
> + rc = ioctl(kvm_fd, KVM_GET_DEVICE_ATTR, &attr);
Yes, you need to check if it fails though (and in that case do not
assign). The file descriptor is already there in QEMU, so you can use
kvm_ioctl.
> + ret = bitmask;
To support R_EDX as well:
ret = (reg == R_EAX) ? bitmask : bitmask >> 32;
> So in the kvm_request_xsave_components(), we can do below steps?
>
> + /* Check supported_xr0 firstly */
> + rc = kvm_arch_get_supported_cpuid(s, 0xd, 0, R_EAX);
> + if (!(rc & XFEATURE_XTILE_MASK)) {
rc = kvm_arch_get_supported_cpuid(s, 0xd, 0,
(xdata_bit < 32 ? R_EAX : R_EDX));
if (!(rc & BIT(xdata_bit & 31)) {
...
}
Also please use warn_report and don't exit. With e.g. "-cpu
foo,amx,xfd,enforce" you should not reach this code at all if the host
lacks AMX.
Thanks,
Paolo
> + error_report("host xcr0 can't support AMX xdata and rc=0x%lx", rc);
> + exit(EXIT_FAILURE);
> + }
>
> + /* request amx permission */
> + syscall(ARCH_REQ_XCOMP_GUEST_PERM, xdata_bit);
>
>
> + /* check amx permission */
> + syscall(ARCH_GET_XCOMP_GUEST_PERM);
next prev parent reply other threads:[~2022-01-28 11:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 7:55 [PATCH 0/7] AMX support in Qemu Yang Zhong
2022-01-24 7:55 ` [PATCH 1/7] x86: Fix the 64-byte boundary enumeration for extended state Yang Zhong
2022-01-24 7:55 ` [PATCH 2/7] x86: Add AMX XTILECFG and XTILEDATA components Yang Zhong
2022-01-24 7:55 ` [PATCH 3/7] x86: Grant AMX permission for guest Yang Zhong
2022-01-24 10:16 ` Paolo Bonzini
2022-01-27 13:45 ` Yang Zhong
2022-01-28 11:09 ` Paolo Bonzini [this message]
2022-01-24 7:55 ` [PATCH 4/7] x86: Add XFD faulting bit for state components Yang Zhong
2022-01-24 7:55 ` [PATCH 5/7] x86: Add AMX CPUIDs enumeration Yang Zhong
2022-01-24 10:13 ` Paolo Bonzini
2022-01-27 13:46 ` Yang Zhong
2022-01-24 7:55 ` [PATCH 6/7] x86: add support for KVM_CAP_XSAVE2 and AMX state migration Yang Zhong
2022-01-24 10:15 ` Paolo Bonzini
2022-01-27 13:47 ` Yang Zhong
2022-01-24 7:55 ` [PATCH 7/7] x86: Support XFD and AMX xsave data migration Yang Zhong
2022-01-24 10:17 ` [PATCH 0/7] AMX support in Qemu Paolo Bonzini
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=bbcb6166-5c5f-bd61-887d-935713bb7bd2@redhat.com \
--to=pbonzini@redhat.com \
--cc=guang.zeng@intel.com \
--cc=jing2.liu@linux.intel.com \
--cc=kevin.tian@intel.com \
--cc=qemu-devel@nongnu.org \
--cc=seanjc@google.com \
--cc=wei.w.wang@intel.com \
--cc=yang.zhong@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).