kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Like Xu <like.xu.linux@gmail.com>
Cc: Jing Liu <jing2.liu@intel.com>,
	Sean Christopherson <seanjc@google.com>,
	Jim Mattson <jmattson@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86/cpuid: Clear XFD for component i if the base feature is missing
Date: Mon, 17 Jan 2022 18:31:58 +0100	[thread overview]
Message-ID: <301d4800-5eab-6e21-e8c1-2f87789fc4b9@redhat.com> (raw)
In-Reply-To: <20220117074531.76925-1-likexu@tencent.com>

On 1/17/22 08:45, Like Xu wrote:
> From: Like Xu <likexu@tencent.com>
> 
> According to Intel extended feature disable (XFD) spec, the sub-function i
> (i > 1) of CPUID function 0DH enumerates "details for state component i.
> ECX[2] enumerates support for XFD support for this state component."
> 
> If KVM does not report F(XFD) feature (e.g. due to CONFIG_X86_64),
> then the corresponding XFD support for any state component i
> should also be removed. Translate this dependency into KVM terms.
> 
> Fixes: 690a757d610e ("kvm: x86: Add CPUID support for Intel AMX")
> Signed-off-by: Like Xu <likexu@tencent.com>
> ---
>   arch/x86/kvm/cpuid.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index c55e57b30e81..e96efef4f048 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -886,6 +886,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
>   				--array->nent;
>   				continue;
>   			}
> +
> +			if (!kvm_cpu_cap_has(X86_FEATURE_XFD))
> +				entry->ecx &= ~BIT_ULL(2);
>   			entry->edx = 0;
>   		}
>   		break;

Generally this is something that is left to userspace.  Apart from the 
usecase of "call KVM_GET_SUPPORTED_CPUID and pass it to KVM_SET_CPUID2", 
userspace should know what any changed bits mean.

Paolo


  reply	other threads:[~2022-01-17 17:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  7:45 [PATCH] KVM: x86/cpuid: Clear XFD for component i if the base feature is missing Like Xu
2022-01-17 17:31 ` Paolo Bonzini [this message]
2022-01-18  6:43   ` Like Xu
2022-01-18  8:42     ` 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=301d4800-5eab-6e21-e8c1-2f87789fc4b9@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jing2.liu@intel.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=like.xu.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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).