Re: [PATCH v4 03/30] KVM: x86: Rename __{g,s}et_sregs2() => kvm_x86_vcpu_ioctl_{g,s}et_sregs2()
From: Binbin Wu
Date: Mon Jun 15 2026 - 01:13:42 EST
On 6/13/2026 8:03 AM, Sean Christopherson wrote:
> Rename the KVM_{G,S}ET_SREGS2 helpers in anticipation of moving them out of
> x86.c (while leaving the ioctl dispatch behind). Having globally visible
> APIs named __{g,s}et_sregs2() would be "fine", but ugly, given that
> __{g,s}et_sregs() will NOT be globally visible. As a bonus, this makes it
> a bit more obvious that the helpers implement newer versions of
> kvm_arch_vcpu_ioctl_set_sregs().
>
> No functional change intended.
>
> Cc: Yosry Ahmed <yosry@xxxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
> arch/x86/kvm/x86.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 0f48cd630c32..0fa8a9e3b8b2 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -133,8 +133,10 @@ static void __kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags);
> static void store_regs(struct kvm_vcpu *vcpu);
> static int sync_regs(struct kvm_vcpu *vcpu);
>
> -static int __set_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2);
> -static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2);
> +static int kvm_x86_vcpu_ioctl_set_sregs2(struct kvm_vcpu *vcpu,
> + struct kvm_sregs2 *sregs2);
> +static void kvm_x86_vcpu_ioctl_get_sregs2(struct kvm_vcpu *vcpu,
> + struct kvm_sregs2 *sregs2);
>
Existing code uses the pattern kvm_vcpu_ioctl_x86_xxx, is it better to
align the pattern?
> static DEFINE_MUTEX(vendor_module_lock);
> static void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
> @@ -6623,7 +6625,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
> r = -ENOMEM;
> if (!u.sregs2)
> goto out;
> - __get_sregs2(vcpu, u.sregs2);
> + kvm_x86_vcpu_ioctl_get_sregs2(vcpu, u.sregs2);
> r = -EFAULT;
> if (copy_to_user(argp, u.sregs2, sizeof(struct kvm_sregs2)))
> goto out;
> @@ -6642,7 +6644,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
> u.sregs2 = NULL;
> goto out;
> }
> - r = __set_sregs2(vcpu, u.sregs2);
> + r = kvm_x86_vcpu_ioctl_set_sregs2(vcpu, u.sregs2);
> break;
> }
> case KVM_HAS_DEVICE_ATTR:
> @@ -12210,7 +12212,8 @@ static void __get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
> (unsigned long *)sregs->interrupt_bitmap);
> }
>
> -static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2)
> +static void kvm_x86_vcpu_ioctl_get_sregs2(struct kvm_vcpu *vcpu,
> + struct kvm_sregs2 *sregs2)
> {
> int i;
>
> @@ -12480,7 +12483,8 @@ static int __set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
> return 0;
> }
>
> -static int __set_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2)
> +static int kvm_x86_vcpu_ioctl_set_sregs2(struct kvm_vcpu *vcpu,
> + struct kvm_sregs2 *sregs2)
> {
> int mmu_reset_needed = 0;
> bool valid_pdptrs = sregs2->flags & KVM_SREGS2_FLAGS_PDPTRS_VALID;