From: Sean Christopherson <seanjc@google.com>
To: "Xin Li (Intel)" <xin@zytor.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
hpa@zytor.com, chao.gao@intel.com
Subject: Re: [PATCH v2 2/4] KVM: VMX: Handle the immediate form of MSR instructions
Date: Tue, 5 Aug 2025 13:03:24 -0700 [thread overview]
Message-ID: <aJJjjGWFL-Ju2Efw@google.com> (raw)
In-Reply-To: <20250802001520.3142577-3-xin@zytor.com>
On Fri, Aug 01, 2025, Xin Li (Intel) wrote:
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index f19a76d3ca0e..c5d0082cf0a5 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -978,6 +978,7 @@ struct kvm_vcpu_arch {
> unsigned long guest_debug_dr7;
> u64 msr_platform_info;
> u64 msr_misc_features_enables;
> + u32 cui_rdmsr_imm_reg;
This should be an "int", mostly because that's how KVM tracks it throughout the
various accessors, but also because it'd let us use "-1" for an "invalid" value,
e.g. if we ever want to add sanity checks to the completion callback (I don't
think that's worth doing).
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index aa157fe5b7b3..c112595dfff9 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6003,6 +6003,23 @@ static int handle_notify(struct kvm_vcpu *vcpu)
> return 1;
> }
>
> +static int vmx_get_msr_imm_reg(void)
It's a bit silly, but I think it's worth passing in the @vcpu here. E.g. if we
ever want to support caching the vmcs.VMX_INSTRUCTION_INFO. And because it costs
literally nothing (barring a truly stupid compiler).
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index a1c49bc681c4..fe12aae7089c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1968,6 +1968,13 @@ static void complete_userspace_rdmsr(struct kvm_vcpu *vcpu)
> }
> }
>
> +static void complete_userspace_rdmsr_imm(struct kvm_vcpu *vcpu)
No need for this helper, the few lines can be open coded in complete_fast_rdmsr_imm().
> +{
> + if (!vcpu->run->msr.error)
> + kvm_register_write(vcpu, vcpu->arch.cui_rdmsr_imm_reg,
> + vcpu->run->msr.data);
> +}
> +
next prev parent reply other threads:[~2025-08-05 20:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-02 0:15 [PATCH v2 0/4] KVM: VMX: Handle the immediate form of MSR instructions Xin Li (Intel)
2025-08-02 0:15 ` [PATCH v2 1/4] x86/cpufeatures: Add a CPU feature bit for MSR immediate form instructions Xin Li (Intel)
2025-08-02 0:15 ` [PATCH v2 2/4] KVM: VMX: Handle the immediate form of MSR instructions Xin Li (Intel)
2025-08-05 20:03 ` Sean Christopherson [this message]
2025-08-06 15:59 ` Xin Li
2025-08-02 0:15 ` [PATCH v2 3/4] KVM: VMX: Support the immediate form WRMSRNS in fastpath Xin Li (Intel)
2025-08-02 0:15 ` [PATCH v2 4/4] KVM: x86: Advertise support for the immediate form of MSR instructions Xin Li (Intel)
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=aJJjjGWFL-Ju2Efw@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xin@zytor.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;
as well as URLs for NNTP newsgroup(s).