From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH 1/2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right Date: Thu, 17 Nov 2011 12:18:44 +0200 Message-ID: <1321525125-28966-1-git-send-email-levinsasha928@gmail.com> Cc: Sasha Levin , Avi Kivity , Marcelo Tosatti To: kvm@vger.kernel.org Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:43980 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756394Ab1KQKVq (ORCPT ); Thu, 17 Nov 2011 05:21:46 -0500 Received: by wyh11 with SMTP id 11so1746386wyh.19 for ; Thu, 17 Nov 2011 02:21:45 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: If we pass just enough entries to KVM_GET_SUPPORTED_CPUID, we would still fail with -E2BIG due to wrong comparisons. Cc: Avi Kivity Cc: Marcelo Tosatti Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9eff4af..460c49b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2664,7 +2664,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, do_cpuid_ent(&cpuid_entries[nent], func, 0, &nent, cpuid->nent); r = -E2BIG; - if (nent >= cpuid->nent) + if (nent > cpuid->nent) goto out_free; do_cpuid_ent(&cpuid_entries[nent], 0x80000000, 0, &nent, cpuid->nent); @@ -2676,7 +2676,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, r = -E2BIG; - if (nent >= cpuid->nent) + if (nent > cpuid->nent) goto out_free; /* Add support for Centaur's CPUID instruction. */ @@ -2685,7 +2685,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, &nent, cpuid->nent); r = -E2BIG; - if (nent >= cpuid->nent) + if (nent > cpuid->nent) goto out_free; limit = cpuid_entries[nent - 1].eax; @@ -2695,7 +2695,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, &nent, cpuid->nent); r = -E2BIG; - if (nent >= cpuid->nent) + if (nent > cpuid->nent) goto out_free; } @@ -2703,14 +2703,14 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, cpuid->nent); r = -E2BIG; - if (nent >= cpuid->nent) + if (nent > cpuid->nent) goto out_free; do_cpuid_ent(&cpuid_entries[nent], KVM_CPUID_FEATURES, 0, &nent, cpuid->nent); r = -E2BIG; - if (nent >= cpuid->nent) + if (nent > cpuid->nent) goto out_free; r = -EFAULT; -- 1.7.8.rc1