[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <173645175967.888731.7554447818595629812.b4-ty@google.com>
Date: Thu, 9 Jan 2025 11:47:03 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH] KVM: x86: Avoid double RDPKRU when loading host/guest PKRU
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
Powered by blists - more mailing lists