Re: [PATCH] kvm: x86: Update KVM_GET_CPUID2 to return valid entry count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Date:   Mon, 10 Apr 2023 08:47:05 -0700
From:   Sean Christopherson <seanjc@xxxxxxxxxx>
> Capitalize KVM please, i.e. "KVM: x86:".

Will fix. Thanks!

> I think we should break from the (IMO) somewhat funky KVM ioctl() pattern of
> 
> 	r = <errno>
> 	if (try something and it fails)
> 		goto out;
> 
> and instead set "r" in the error paths.  That avoids the need for a scratch "nent",
> and IMO makes this much more straightforward.
> 
> 	int r = 0;
> 
> 	if (cpuid->nent < vcpu->arch.cpuid_nent)
> 		r = -E2BIG;
> 	else if (copy_to_user(entries, vcpu->arch.cpuid_entries,
> 			      vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
> 		r = -EFAULT;
> 
> 	/*
> 	 * Update "nent" even on failure, e.g. so that userspace can fix an
> 	 * -E2BIG issue by allocating a larger array.
> 	 */
> 	cpuid->nent = vcpu->arch.cpuid_nent;
> 	return r;

Looks better to me! Will fix this too!.

Best regards,
Takahiro Itazuri




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux