mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH] KVM: x86: Avoid double RDPKRU when loading host/guest PKRU
Date: Thu,  9 Jan 2025 11:47:03 -0800	[thread overview]
Message-ID: <173645175967.888731.7554447818595629812.b4-ty@google.com> (raw)
In-Reply-To: <20241221011647.3747448-1-seanjc@google.com>

On Fri, 20 Dec 2024 17:16:47 -0800, Sean Christopherson wrote:
> Use the raw wrpkru() helper when loading the guest/host's PKRU on switch
> to/from guest context, as the write_pkru() wrapper incurs an unnecessary
> rdpkru().  In both paths, KVM is guaranteed to have performed RDPKRU since
> the last possible write, i.e. KVM has a fresh cache of the current value
> in hardware.
> 
> This effectively restores KVM's behavior to that of KVM prior to commit
> c806e88734b9 ("x86/pkeys: Provide *pkru() helpers"), which renamed the raw
> helper from __write_pkru() => wrpkru(), and turned __write_pkru() into a
> wrapper.  Commit 577ff465f5a6 ("x86/fpu: Only write PKRU if it is different
> from current") then added the extra RDPKRU to avoid an unnecessary WRPKRU,
> but completely missed that KVM already optimized away pointless writes.
> 
> [...]

Applied to kvm-x86 misc, thanks!

[1/1] KVM: x86: Avoid double RDPKRU when loading host/guest PKRU
      https://github.com/kvm-x86/linux/commit/4c20cd4cee92

--
https://github.com/kvm-x86/linux/tree/next

      reply	other threads:[~2025-01-09 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-21  1:16 Sean Christopherson
2025-01-09 19:47 ` Sean Christopherson [this message]

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=173645175967.888731.7554447818595629812.b4-ty@google.com \
    --to=seanjc@google.com \
    --cc=adrian.hunter@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®