Re: [PATCH v9 03/19] KVM: selftests: Expose functions to get default sregs values

From: Sean Christopherson
Date: Tue Aug 26 2025 - 10:17:15 EST


On Tue, Aug 26, 2025, Binbin Wu wrote:
> On 8/21/2025 12:28 PM, Sagi Shahar wrote:
> > TDX can't set sregs values directly using KVM_SET_SREGS. Expose the
> > default values of certain sregs used by TDX VMs so they can be set
> > manually.
> >
> > Signed-off-by: Sagi Shahar <sagis@xxxxxxxxxx>
> > ---
> > .../selftests/kvm/include/x86/processor.h | 6 +++
> > .../testing/selftests/kvm/lib/x86/processor.c | 41 +++++++++++++++----
> > 2 files changed, 40 insertions(+), 7 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h
> > index 2efb05c2f2fb..5c16507f9b2d 100644
> > --- a/tools/testing/selftests/kvm/include/x86/processor.h
> > +++ b/tools/testing/selftests/kvm/include/x86/processor.h
> > @@ -1026,6 +1026,12 @@ static inline struct kvm_cpuid2 *allocate_kvm_cpuid2(int nr_entries)
> > void vcpu_init_cpuid(struct kvm_vcpu *vcpu, const struct kvm_cpuid2 *cpuid);
> > +uint16_t kvm_get_default_idt_limit(void);
> > +uint16_t kvm_get_default_gdt_limit(void);
> > +uint64_t kvm_get_default_cr0(void);
> > +uint64_t kvm_get_default_cr4(void);
> > +uint64_t kvm_get_default_efer(void);
> Can these be defined in the header file as static inline?

Yes please. Performance isn't a concern, but as a developer, it's nice to not
have to bounce to a definition to find such simple information.