From: Amit Shah <amit@kernel.org>
To: Tom Lendacky <thomas.lendacky@amd.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
x86@kernel.org, linux-doc@vger.kernel.org
Cc: bp@alien8.de, tglx@linutronix.de, peterz@infradead.org,
jpoimboe@kernel.org, pawan.kumar.gupta@linux.intel.com,
corbet@lwn.net, mingo@redhat.com, dave.hansen@linux.intel.com,
hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com,
daniel.sneddon@linux.intel.com, kai.huang@intel.com,
sandipan.das@amd.com, boris.ostrovsky@oracle.com,
Babu.Moger@amd.com, david.kaplan@amd.com, dwmw@amazon.co.uk,
andrew.cooper3@citrix.com, amit.shah@amd.com
Subject: Re: [PATCH v5 1/1] x86: kvm: svm: set up ERAPS support for guests
Date: Wed, 28 May 2025 14:49:07 +0200 [thread overview]
Message-ID: <c4adbc456e702b6e04b160efb996212fe3ee9d04.camel@kernel.org> (raw)
In-Reply-To: <43bbb306-782b-401d-ac96-cc8ca550af7d@amd.com>
On Mon, 2025-05-19 at 16:22 -0500, Tom Lendacky wrote:
> On 5/15/25 10:26, Amit Shah wrote:
>
[...]
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index 571c906ffcbf..0cca1865826e 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -1187,6 +1187,9 @@ void kvm_set_cpu_caps(void)
> > F(SRSO_USER_KERNEL_NO),
> > );
> >
> > + if (tdp_enabled)
> > + kvm_cpu_cap_check_and_set(X86_FEATURE_ERAPS);
>
> Should this be moved to svm_set_cpu_caps() ? And there it can be
>
> if (npt_enabled)
> kvm_cpu_cap...
Yea, I don't mind moving that to svm-only code. Will do.
> > case 0x80000021:
> > - entry->ebx = entry->ecx = entry->edx = 0;
> > + entry->ecx = entry->edx = 0;
> > cpuid_entry_override(entry, CPUID_8000_0021_EAX);
> > + if (kvm_cpu_cap_has(X86_FEATURE_ERAPS))
> > + entry->ebx &= GENMASK(23, 16);
> > + else
> > + entry->ebx = 0;
> > +
>
> Extra blank line.
Hm, helps with visual separation of the if-else and the break. I
prefer to keep it, unless it breaks style guidelines.
> > break;
> > /* AMD Extended Performance Monitoring and Debug */
> > case 0x80000022: {
> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> > index a89c271a1951..a2b075ed4133 100644
> > --- a/arch/x86/kvm/svm/svm.c
> > +++ b/arch/x86/kvm/svm/svm.c
> > @@ -1363,6 +1363,9 @@ static void init_vmcb(struct kvm_vcpu *vcpu)
> > if (boot_cpu_has(X86_FEATURE_V_SPEC_CTRL))
> > set_msr_interception(vcpu, svm->msrpm,
> > MSR_IA32_SPEC_CTRL, 1, 1);
> >
> > + if (boot_cpu_has(X86_FEATURE_ERAPS) && npt_enabled)
>
> Should this be:
>
> if (kvm_cpu_cap_has(X86_FEATURE_ERAPS))
>
> ?
Indeed this is better. There was some case I wanted to cover
initially, but I don't think it needs to only depend on the host caps
in the current version at least.
[...]
> > +static inline void vmcb_set_flush_guest_rap(struct vmcb *vmcb)
> > +{
> > + vmcb->control.erap_ctl |= ERAP_CONTROL_FLUSH_RAP;
> > +}
> > +
> > +static inline void vmcb_clr_flush_guest_rap(struct vmcb *vmcb)
> > +{
> > + vmcb->control.erap_ctl &= ~ERAP_CONTROL_FLUSH_RAP;
> > +}
> > +
> > +static inline void vmcb_enable_extended_rap(struct vmcb *vmcb)
>
> s/extended/larger/ to match the bit name ?
I also prefer it with the "larger" name, but that is a confusing bit
name -- so after the last round of review, I renamed the accessor
functions to be "better", while leaving the bit defines match what the
CPU has.
I don't mind switching this back - anyone else have any other opinions?
>
> > +{
> > + vmcb->control.erap_ctl |= ERAP_CONTROL_ALLOW_LARGER_RAP;
> > +}
> > +
> > +static inline bool vmcb_is_extended_rap(struct vmcb *vmcb)
>
> s/is_extended/has_larger/
>
> Thanks,
> Tom
Thanks for the review!
Amit
next prev parent reply other threads:[~2025-05-28 12:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 15:26 [PATCH v5 0/1] KVM: Add support for the ERAPS feature Amit Shah
2025-05-15 15:26 ` [PATCH v5 1/1] x86: kvm: svm: set up ERAPS support for guests Amit Shah
2025-05-19 21:22 ` Tom Lendacky
2025-05-28 12:49 ` Amit Shah [this message]
2025-08-20 16:18 ` Sean Christopherson
2025-08-21 9:05 ` Amit Shah
2025-08-20 17:10 ` Sean Christopherson
2025-08-27 9:17 ` Amit Shah
2025-08-28 9:40 ` Amit Shah
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=c4adbc456e702b6e04b160efb996212fe3ee9d04.camel@kernel.org \
--to=amit@kernel.org \
--cc=Babu.Moger@amd.com \
--cc=amit.shah@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=daniel.sneddon@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=david.kaplan@amd.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=sandipan.das@amd.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/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).