Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935445AbdIZEZv (ORCPT ); Tue, 26 Sep 2017 00:25:51 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:32820 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932698AbdIZEZt (ORCPT ); Tue, 26 Sep 2017 00:25:49 -0400 X-Google-Smtp-Source: AOwi7QA7HXcsznkKgeAO2coHJfB2J4ZbuhisAdwGc2G0K+2AlZlyQscy/1IWMYyzK8oI6mJWlkqNXg== From: Nick Desaulniers Cc: josh@joshtriplett.org, kay@vrfy.org, avi@redhat.com, Nick Desaulniers , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH] KVM: VMX: check match table Date: Mon, 25 Sep 2017 21:25:38 -0700 Message-Id: <20170926042540.10100-1-nick.desaulniers@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1640 Lines: 49 Fixes the warning: arch/x86/kvm/vmx.c:64:32: warning: variable 'vmx_cpu_id' is not needed and will not be emitted [-Wunneeded-internal-declaration]`` Other callers of MODULE_DEVICE_TABLE() seem to check their second argument during driver init with the x86_match_cpu() function, if their first argument to MODULE_DEVICE_TABLE() is x86cpu. The documentation for x86_match_cpu() seems to agree. Suggested-by: Josh Triplett Signed-off-by: Nick Desaulniers --- arch/x86/kernel/cpu/match.c | 2 +- arch/x86/kvm/vmx.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/match.c b/arch/x86/kernel/cpu/match.c index e42117d5f4d7..fb1aeafa5cc7 100644 --- a/arch/x86/kernel/cpu/match.c +++ b/arch/x86/kernel/cpu/match.c @@ -5,7 +5,7 @@ #include /** - * x86_match_cpu - match current CPU again an array of x86_cpu_ids + * x86_match_cpu - match current CPU against an array of x86_cpu_ids * @match: Pointer to array of x86_cpu_ids. Last entry terminated with * {}. * diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 6970249c09fc..e1a00b130935 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -12074,7 +12074,12 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { static int __init vmx_init(void) { - int r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), + int r; + + if (!x86_match_cpu(vmx_cpu_id)) + return -ENODEV; + + r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), __alignof__(struct vcpu_vmx), THIS_MODULE); if (r) return r; -- 2.11.0