From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: Jon Kohler <jon@nutanix.com>, Mingwei Zhang <mizhang@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Use cpu_feature_enabled() for PKU instead of #ifdef
Date: Fri, 2 Jun 2023 14:49:46 -0700 [thread overview]
Message-ID: <ZHpj+j5Cs1vOXgyP@google.com> (raw)
In-Reply-To: <CALMp9eTtkBL3Fb7Dq60go6CL+zGODNn0TTavr436Q-+=mpVFMA@mail.gmail.com>
On Fri, Jun 02, 2023, Jim Mattson wrote:
> On Fri, Jun 2, 2023 at 8:51 AM Jon Kohler <jon@nutanix.com> wrote:
> > > On Jun 1, 2023, at 9:05 PM, Sean Christopherson <seanjc@google.com> wrote:
> > > @@ -1032,15 +1030,13 @@ void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu)
> > > if (vcpu->arch.guest_state_protected)
> > > return;
> > >
> > > -#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
> > > - if (static_cpu_has(X86_FEATURE_PKU) &&
> > > + if (cpu_feature_enabled(X86_FEATURE_PKU) &&
> > > ((vcpu->arch.xcr0 & XFEATURE_MASK_PKRU) ||
> > > kvm_is_cr4_bit_set(vcpu, X86_CR4_PKE))) {
> > > vcpu->arch.pkru = rdpkru();
> > > if (vcpu->arch.pkru != vcpu->arch.host_pkru)
> > > write_pkru(vcpu->arch.host_pkru);
> > > }
> > > -#endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */
> > >
> > > if (kvm_is_cr4_bit_set(vcpu, X86_CR4_OSXSAVE)) {
> > >
> > >
> > > base-commit: a053a0e4a9f8c52f3acf8a9d2520c4bf39077a7e
> > > --
> > > 2.41.0.rc2.161.g9c6817b8e7-goog
> > >
> >
> > Thanks for the cleanup!
> >
> > Reviewed-by: Jon Kohler <jon@nutanix.com>
>
> +Mingwei Zhang
>
> As we move towards enabling PKRU on the host, due to some customer
> requests, I have to wonder if PKRU-disabled is the norm.
>
> In other words, is this a likely() or unlikely() optimization?
Neither? I don't see any reason to speculate on guest state. I'll bet dollars
to donuts that adding (un)likely() is negligible in terms of performance.
next prev parent reply other threads:[~2023-06-02 21:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 1:05 [PATCH] KVM: x86: Use cpu_feature_enabled() for PKU instead of #ifdef Sean Christopherson
2023-06-02 15:51 ` Jon Kohler
2023-06-02 18:30 ` Jim Mattson
2023-06-02 20:58 ` Mingwei Zhang
2023-06-02 21:49 ` Sean Christopherson [this message]
2023-06-07 0:53 ` Sean Christopherson
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=ZHpj+j5Cs1vOXgyP@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=jon@nutanix.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--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