Skip to contentSkip to conversation

Work around supported cpuid ioctl() brokenness

PATCH Applied Mark McLoughlin 2 participants 2 messages May 12, 2009 – May 17, 2009 KVM

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Work around supported cpuid ioctl() brokenness

KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG when it runs out of entries. Detect this by always trying again with a bigger table if the ioctl() fills the table.

---
 kvm/libkvm/libkvm-x86.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kvm/libkvm/libkvm-x86.c +2 -0
index a2f6320..4f9539a 100644
@@ -575,6 +575,8 @@ static struct kvm_cpuid2 *try_get_cpuid(kvm_context_t kvm, int max)
 	r = ioctl(kvm->fd, KVM_GET_SUPPORTED_CPUID, cpuid);
 	if (r == -1)
 		r = -errno;
+	else if (r == 0 && cpuid->nent >= max)
+		r = -E2BIG;
 	if (r < 0) {
 		if (r == -E2BIG) {
 			free(cpuid);
Signature · 1 line
1.6.0.6
Applied
#1 lore raw
Quoted 4 lines · Mark McLoughlin

KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG when it runs out of entries. Detect this by always trying again with a bigger table if the ioctl() fills the table.

Applied, thanks.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.