From patchwork Mon Nov 4 22:59:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Arcangeli X-Patchwork-Id: 11226741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 985071747 for ; Mon, 4 Nov 2019 23:01:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77A77214D9 for ; Mon, 4 Nov 2019 23:01:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PSddy8ZY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730037AbfKDXAN (ORCPT ); Mon, 4 Nov 2019 18:00:13 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45959 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729194AbfKDXAM (ORCPT ); Mon, 4 Nov 2019 18:00:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572908411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tktmbgMbA44XbKL0C1wWEcJpxBYyzYw3dy09GJTCB3c=; b=PSddy8ZYP+HimJ1X3wd/oKMDnkjtie2fCftkQYUOcLvtJ2mnGgMgz5LD+gebNr2hyt4ipQ xMl2H6Hcw1BWxAwsbnSBMMVrpXmOdcj1ZJ3/MBzXYfPAICerzayqerPFyxim7yUjNqcAiE jp01MnofLUpy2qhCEfGD5+z32FttK30= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-8Y_kaONzMEuyO5vOv_3xzg-1; Mon, 04 Nov 2019 18:00:08 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44F0E1800DFB; Mon, 4 Nov 2019 23:00:07 +0000 (UTC) Received: from mail (ovpn-121-157.rdu2.redhat.com [10.10.121.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0E1B1001B34; Mon, 4 Nov 2019 23:00:02 +0000 (UTC) From: Andrea Arcangeli To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paolo Bonzini , Vitaly Kuznetsov , Sean Christopherson Subject: [PATCH 01/13] KVM: monolithic: x86: remove kvm.ko Date: Mon, 4 Nov 2019 17:59:49 -0500 Message-Id: <20191104230001.27774-2-aarcange@redhat.com> In-Reply-To: <20191104230001.27774-1-aarcange@redhat.com> References: <20191104230001.27774-1-aarcange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 8Y_kaONzMEuyO5vOv_3xzg-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is the first commit of a patch series that aims to replace the modular kvm.ko kernel module with a monolithic kvm-intel/kvm-amd model. This change has the only possible cons of wasting some disk space in /lib/modules/. The pros are that it saves CPUS and some minor iTLB and RAM which are more scarse resources than disk space. The pointer to function virtual template model cannot provide any runtime benefit because kvm-intel and kvm-amd can't be loaded at the same time. This removes kvm.ko and it links and duplicates all kvm.ko objects to both kvm-amd and kvm-intel. Linking both vmx and svm into the kernel at the same time isn't possible anymore or the kvm_x86/kvm_x86_pmu external function names would collide. Explanation of Kbuild from Paolo Bonzini follows: === The left side of the "||" ensures that, if KVM=m, you can only choose module build for both KVM_INTEL and KVM_AMD. Having just "depends on KVM" would allow a pre-existing .config to choose the now-invalid combination CONFIG_KVM=y CONFIG_KVM_INTEL=y CONFIG_KVM_AMD=y The right side of the "||" part is just for documentation, to avoid that a selected symbol does not satisfy its dependencies. ==== Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/Kconfig | 30 ++++++++++++++++++++++++++---- arch/x86/kvm/Makefile | 5 ++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 840e12583b85..0d6e8809e359 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -59,9 +59,30 @@ config KVM If unsure, say N. +if KVM=y + +choice + prompt "KVM built-in support" + help + In order to build a kernel with support for both AMD and Intel + CPUs, you need to set CONFIG_KVM=m instead. + +config KVM_AMD_STATIC + select KVM_AMD + bool "AMD" + +config KVM_INTEL_STATIC + select KVM_INTEL + bool "Intel" + +endchoice + +endif + config KVM_INTEL - tristate "KVM for Intel processors support" - depends on KVM + tristate + prompt "KVM for Intel processors support" if KVM=m + depends on (KVM=m && m) || KVM_INTEL_STATIC # for perf_guest_get_msrs(): depends on CPU_SUP_INTEL ---help--- @@ -72,8 +93,9 @@ config KVM_INTEL will be called kvm-intel. config KVM_AMD - tristate "KVM for AMD processors support" - depends on KVM + tristate + prompt "KVM for AMD processors support" if KVM=m + depends on (KVM=m && m) || KVM_AMD_STATIC ---help--- Provides support for KVM on AMD processors equipped with the AMD-V (SVM) extensions. diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 31ecf7a76d5a..68b81f381369 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -12,9 +12,8 @@ kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o \ hyperv.o page_track.o debugfs.o -kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o vmx/evmcs.o vmx/nested.o -kvm-amd-y += svm.o pmu_amd.o +kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o vmx/evmcs.o vmx/nested.o $(kvm-y) +kvm-amd-y += svm.o pmu_amd.o $(kvm-y) -obj-$(CONFIG_KVM) += kvm.o obj-$(CONFIG_KVM_INTEL) += kvm-intel.o obj-$(CONFIG_KVM_AMD) += kvm-amd.o