From: Chao Gao <chao.gao@intel.com>
To: Binbin Wu <binbin.wu@linux.intel.com>
Cc: <seanjc@google.com>, <pbonzini@redhat.com>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Add a help to dedup loading guest/host XCR0 and XSS
Date: Fri, 7 Nov 2025 11:14:35 +0800 [thread overview]
Message-ID: <aQ1kG5u8GPdEwoEy@intel.com> (raw)
In-Reply-To: <20251106101138.2756175-1-binbin.wu@linux.intel.com>
s/help/helper in the subject.
On Thu, Nov 06, 2025 at 06:11:38PM +0800, Binbin Wu wrote:
>Add and use a helper, kvm_load_xfeatures(), to dedup the code that loads
>guest/host xfeatures by passing XCR0 and XSS values accordingly.
>
>No functional change intended.
>
>Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Chao Gao <chao.gao@intel.com>
<snip>
>@@ -11406,7 +11391,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
> vcpu->mode = OUTSIDE_GUEST_MODE;
> smp_wmb();
>
>- kvm_load_host_xfeatures(vcpu);
>+ kvm_load_xfeatures(vcpu, kvm_host.xcr0, kvm_host.xss);
Nit: given that xcr0/xss are either guest or host values, would it be slightly
better for this helper to accept a boolean (e.g., bool load_guest) to convey
that the API loads guest (or host) values rather than arbitrary xcr0/xss
values? like fpu_swap_kvm_fpstate().
static void kvm_load_xfeatures(struct kvm_vcpu *vcpu, bool load_guest)
{
u64 xcr0 = load_guest ? vcpu->arch.xcr0 : kvm_host.xcr0;
u64 xss = load_guest ? vcpu->arch.ia32_xss : kvm_host.xss;
if (vcpu->arch.guest_state_protected)
return;
> /*
> * Sync xfd before calling handle_exit_irqoff() which may
>
>base-commit: a996dd2a5e1ec54dcf7d7b93915ea3f97e14e68a
>prerequisite-patch-id: 9aafd634f0ab2033d7b032e227d356777469e046
>prerequisite-patch-id: 656ce1f5aa97c77a9cf6125713707a5007b2c7ba
>prerequisite-patch-id: d6328b8c0fdb8593bb534ab7378821edcf9f639d
>prerequisite-patch-id: c7f36d1cedc4ae6416223d2225460944629b3d4f
>--
>2.46.0
>
>
next prev parent reply other threads:[~2025-11-07 3:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 10:11 [PATCH] KVM: x86: Add a help to dedup loading guest/host XCR0 and XSS Binbin Wu
2025-11-07 3:14 ` Chao Gao [this message]
2025-11-07 4:21 ` Binbin Wu
2025-11-07 19:09 ` Sean Christopherson
2025-11-07 6:17 ` Xiaoyao Li
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=aQ1kG5u8GPdEwoEy@intel.com \
--to=chao.gao@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.