From: Yang Weijiang <weijiang.yang@intel.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: Babu Moger <Babu.Moger@amd.com>,
Yang Weijiang <weijiang.yang@intel.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Jim Mattson <jmattson@google.com>
Subject: Re: [Patch 4/6] kvm: svm: Enumerate XSAVES in guest CPUID when it is available to the guest
Date: Wed, 9 Oct 2019 09:42:26 +0800 [thread overview]
Message-ID: <20191009014226.GA27134@local-michael-cet-test> (raw)
In-Reply-To: <20191009004142.225377-4-aaronlewis@google.com>
On Tue, Oct 08, 2019 at 05:41:40PM -0700, Aaron Lewis wrote:
> Add the function guest_cpuid_set() to allow a bit in the guest cpuid to
> be set. This is complementary to the guest_cpuid_clear() function.
>
> Also, set the XSAVES bit in the guest cpuid if the host has the same bit
> set and guest has XSAVE bit set. This is to ensure that XSAVES will be
> enumerated in the guest CPUID if XSAVES can be used in the guest.
>
> Reviewed-by: Jim Mattson <jmattson@google.com>
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>
> ---
> arch/x86/kvm/cpuid.h | 9 +++++++++
> arch/x86/kvm/svm.c | 4 ++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
> index d78a61408243..420ceea02fd1 100644
> --- a/arch/x86/kvm/cpuid.h
> +++ b/arch/x86/kvm/cpuid.h
> @@ -113,6 +113,15 @@ static __always_inline void guest_cpuid_clear(struct kvm_vcpu *vcpu, unsigned x8
> *reg &= ~bit(x86_feature);
> }
>
> +static __always_inline void guest_cpuid_set(struct kvm_vcpu *vcpu, unsigned x86_feature)
> +{
> + int *reg;
> +
> + reg = guest_cpuid_get_register(vcpu, x86_feature);
> + if (reg)
> + *reg |= ~bit(x86_feature);
> +}
> +
Sounds like it's to set the bit, is it: *reg |= bit(x86_feature)?
> static inline bool guest_cpuid_is_amd(struct kvm_vcpu *vcpu)
> {
> struct kvm_cpuid_entry2 *best;
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 65223827c675..2522a467bbc0 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -5887,6 +5887,10 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> + if (guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
> + boot_cpu_has(X86_FEATURE_XSAVES))
> + guest_cpuid_set(vcpu, X86_FEATURE_XSAVES);
> +
> /* Update nrips enabled cache */
> svm->nrips_enabled = !!guest_cpuid_has(&svm->vcpu, X86_FEATURE_NRIPS);
>
> --
> 2.23.0.581.g78d2f28ef7-goog
next prev parent reply other threads:[~2019-10-09 1:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 0:41 [Patch 1/6] KVM: VMX: Remove unneeded check for X86_FEATURE_XSAVE Aaron Lewis
2019-10-09 0:41 ` [Patch 2/6] KVM: VMX: Use wrmsr for switching between guest and host IA32_XSS Aaron Lewis
2019-10-09 4:49 ` Yang Weijiang
2019-10-09 6:30 ` Paolo Bonzini
2019-10-09 12:34 ` Vitaly Kuznetsov
2019-10-09 6:31 ` Sebastian Andrzej Siewior
2019-10-09 0:41 ` [Patch 3/6] kvm: svm: Add support for XSAVES on AMD Aaron Lewis
2019-10-09 6:44 ` Sebastian Andrzej Siewior
2019-10-10 14:42 ` Aaron Lewis
2019-10-10 16:04 ` Paolo Bonzini
2019-10-09 7:01 ` Paolo Bonzini
2019-10-09 21:29 ` Jim Mattson
2019-10-09 21:40 ` Paolo Bonzini
2019-10-09 21:58 ` Jim Mattson
2019-10-09 22:49 ` Paolo Bonzini
2019-10-10 0:42 ` Kang, Luwei
2019-10-09 0:41 ` [Patch 4/6] kvm: svm: Enumerate XSAVES in guest CPUID when it is available to the guest Aaron Lewis
2019-10-09 1:42 ` Yang Weijiang [this message]
2019-10-09 6:32 ` Paolo Bonzini
2019-10-09 23:35 ` Jim Mattson
2019-10-09 0:41 ` [Patch 5/6] kvm: x86: Add IA32_XSS to the emulated_msrs list Aaron Lewis
2019-10-09 0:41 ` [Patch 6/6] kvm: tests: Add test to verify MSR_IA32_XSS Aaron Lewis
2019-10-09 6:30 ` Paolo Bonzini
2019-10-09 23:44 ` Jim Mattson
2019-10-10 16:01 ` 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=20191009014226.GA27134@local-michael-cet-test \
--to=weijiang.yang@intel.com \
--cc=Babu.Moger@amd.com \
--cc=aaronlewis@google.com \
--cc=bigeasy@linutronix.de \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.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