KVM: X86: eliminate obsolete KVM_GET_CPUID2 ioctl
PATCH RESEND 1/1 KVM: X86: eliminate obsolete KVM_GET_CPUID2 ioctl
From: Miaohe Lin <[email protected]>
KVM_GET_CPUID2 ioctl is straight up broken and not used anywhere. Remove it directly.
--- arch/x86/kvm/cpuid.c | 20 -------------------- arch/x86/kvm/cpuid.h | 3 --- arch/x86/kvm/x86.c | 17 ----------------- include/uapi/linux/kvm.h | 1 - tools/include/uapi/linux/kvm.h | 1 - 5 files changed, 42 deletions(-)
arch/x86/kvm/cpuid.c +0 -20
@@ -261,26 +261,6 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,return r; } -int kvm_vcpu_ioctl_get_cpuid2 (struct kvm_vcpu *vcpu, -struct kvm_cpuid2 *cpuid, -struct kvm_cpuid_entry2 __user *entries) -{ -int r; - - r = -E2BIG ; -if (cpuid->nent < vcpu->arch.cpuid_nent) - goto out; - r = -EFAULT ; -if (copy_to_user (entries, &vcpu->arch.cpuid_entries, - vcpu->arch.cpuid_nent *sizeof (struct kvm_cpuid_entry2 ))) - goto out; -return 0 ; - -out: - cpuid->nent = vcpu->arch.cpuid_nent; -return r; -} - static __always_inline void cpuid_mask(u32 *word, int wordnum) {reverse_cpuid_check (wordnum);
arch/x86/kvm/cpuid.h +0 -3
@@ -19,9 +19,6 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,int kvm_vcpu_ioctl_set_cpuid2 (struct kvm_vcpu *vcpu,struct kvm_cpuid2 *cpuid,struct kvm_cpuid_entry2 __user *entries); -int kvm_vcpu_ioctl_get_cpuid2 (struct kvm_vcpu *vcpu, -struct kvm_cpuid2 *cpuid, -struct kvm_cpuid_entry2 __user *entries);bool kvm_cpuid (struct kvm_vcpu *vcpu,u32 *eax,u32 *ebx,u32 *ecx,u32 *edx,bool check_limit);
arch/x86/kvm/x86.c +0 -17
@@ -4286,23 +4286,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, cpuid_arg->entries);break ; } -case KVM_GET_CPUID2 : { -struct kvm_cpuid2 __user *cpuid_arg = argp; -struct kvm_cpuid2 cpuid; - - r = -EFAULT ; -if (copy_from_user (&cpuid, cpuid_arg,sizeof (cpuid))) - goto out; - r =kvm_vcpu_ioctl_get_cpuid2 (vcpu, &cpuid, - cpuid_arg->entries); -if (r) - goto out; - r = -EFAULT ; -if (copy_to_user (cpuid_arg, &cpuid,sizeof (cpuid))) - goto out; - r =0 ; -break ; - }case KVM_GET_MSRS : {int idx =srcu_read_lock (&vcpu->kvm->srcu); r =msr_io (vcpu, argp, do_get_msr,1 );
include/uapi/linux/kvm.h +0 -1
@@ -1380,7 +1380,6 @@ struct kvm_s390_ucas_mapping {#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) -#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)/* Available with KVM_CAP_VAPIC */ #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)/* Available with KVM_CAP_VAPIC */
tools/include/uapi/linux/kvm.h +0 -1
@@ -1379,7 +1379,6 @@ struct kvm_s390_ucas_mapping {#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) -#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)/* Available with KVM_CAP_VAPIC */ #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)/* Available with KVM_CAP_VAPIC */
Signature · 1 line
2.19.1
Quoted 3 lines · linmiaohe
From: Miaohe Lin <[email protected]>
KVM_GET_CPUID2ioctl is straight up broken
It may make sense to add the gory details from your previous patch where you were trying to fix it.
Quoted 90 lines
and not used anywhere. Remove it directly.
Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Miaohe Lin <[email protected]>--- arch/x86/kvm/cpuid.c | 20 -------------------- arch/x86/kvm/cpuid.h | 3 --- arch/x86/kvm/x86.c | 17 ----------------- include/uapi/linux/kvm.h | 1 - tools/include/uapi/linux/kvm.h | 1 - 5 files changed, 42 deletions(-)arch/x86/kvm/cpuid.c +0
-20@@ -261,26 +261,6 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,return r; } -int kvm_vcpu_ioctl_get_cpuid2 (struct kvm_vcpu *vcpu, -struct kvm_cpuid2 *cpuid, -struct kvm_cpuid_entry2 __user *entries) -{ -int r; - - r = -E2BIG ; -if (cpuid->nent < vcpu->arch.cpuid_nent) - goto out; - r = -EFAULT ; -if (copy_to_user (entries, &vcpu->arch.cpuid_entries, - vcpu->arch.cpuid_nent *sizeof (struct kvm_cpuid_entry2 ))) - goto out; -return 0 ; - -out: - cpuid->nent = vcpu->arch.cpuid_nent; -return r; -} - static __always_inline void cpuid_mask(u32 *word, int wordnum) {reverse_cpuid_check (wordnum);arch/x86/kvm/cpuid.h +0
-3@@ -19,9 +19,6 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,int kvm_vcpu_ioctl_set_cpuid2 (struct kvm_vcpu *vcpu,struct kvm_cpuid2 *cpuid,struct kvm_cpuid_entry2 __user *entries); -int kvm_vcpu_ioctl_get_cpuid2 (struct kvm_vcpu *vcpu, -struct kvm_cpuid2 *cpuid, -struct kvm_cpuid_entry2 __user *entries);bool kvm_cpuid (struct kvm_vcpu *vcpu,u32 *eax,u32 *ebx,u32 *ecx,u32 *edx,bool check_limit);arch/x86/kvm/x86.c +0
-17@@ -4286,23 +4286,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, cpuid_arg->entries);break ; } -case KVM_GET_CPUID2 : { -struct kvm_cpuid2 __user *cpuid_arg = argp; -struct kvm_cpuid2 cpuid; - - r = -EFAULT ; -if (copy_from_user (&cpuid, cpuid_arg,sizeof (cpuid))) - goto out; - r =kvm_vcpu_ioctl_get_cpuid2 (vcpu, &cpuid, - cpuid_arg->entries); -if (r) - goto out; - r = -EFAULT ; -if (copy_to_user (cpuid_arg, &cpuid,sizeof (cpuid))) - goto out; - r =0 ; -break ; - }case KVM_GET_MSRS : {int idx =srcu_read_lock (&vcpu->kvm->srcu); r =msr_io (vcpu, argp, do_get_msr,1 );include/uapi/linux/kvm.h +0
-0
include/uapi/linux/kvm.h struct kvm_s390_ucas_mapping { · line 1383
Quoted 4 lines
include/uapi/linux/kvm.h +0
-1@@ -1380,7 +1380,6 @@ struct kvm_s390_ucas_mapping {#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) -#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
Even if we decide to be strong and remove KVM_GET_CPUID2 completely, I'd suggest we leave a comment here saying that it was deprecated. Leaving the branch in case (returning the same -EINVAL as passing an unsupported IOCTL) may also make sense (with a 'deprecated' comment of course).
Quoted 15 lines
include/uapi/linux/kvm.h +0
-0/* Available with KVM_CAP_VAPIC */ #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)/* Available with KVM_CAP_VAPIC */ tools/include/uapi/linux/kvm.h +0
-1@@ -1379,7 +1379,6 @@ struct kvm_s390_ucas_mapping {#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) -#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)/* Available with KVM_CAP_VAPIC */ #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)/* Available with KVM_CAP_VAPIC */
Signature · 1 line
Vitaly