Re: [PATCH v3 32/40] KVM: x86: Move LLDT assembly wrappers into VMX
From: Sean Christopherson
Date: Mon Jun 01 2026 - 11:18:27 EST
On Sat, May 30, 2026, Yosry Ahmed wrote:
> On Fri, May 29, 2026 at 03:22:15PM -0700, Sean Christopherson wrote:
> > Move kvm_{load,read}_ldt() into vmx.c, as they are exclusively used by VMX
> > to save/restore host state, and have no business being globally visible.
>
> But they are generic helpers. I agree with mvoing them out of
> kvm_host.h, but maybe into another header?
No, absolutely not. The fact that KVM has to manually save, and conditionally
restore, LDT is a quirk of the VMX architecture. If it weren't for the fact that
VMX's segment_base() also needs to query the LDT, I would just open code the asm().
If it's a naming concern, I'll happily rename them to vmx_{load,store}_ldt().
Hmm, arch/x86/include/asm/desc.h provides {load,store}_ldt(), but load_ldt()
is only available for CONFIG_PARAVIRT_XXL=n builds, and both #define unnecessarily
constrain the output to memory. Those are both fixable, e.g. load_ldt() isn't
used _anywhere_ AFAICT, so burying it under CONFIG_PARAVIRT_XXL=n is just some
weird historical quirk, and I can't show_fault_oops() would care store_ldt() were
allowed to store to a register.
So after the dust settles, it probably makes sense to improve desc.h's versions
and then use those in KVM. But I don't want to do that in this series, because
it will be challenging enough to land all of this code movement without also
having to coordinate with the tip tree.