Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp19355ybx; Mon, 4 Nov 2019 15:05:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwZXwmLnMULek8Blr1Y6EAO7TiPMbV0ubUCXjIBCSxBCZABtGTLta6gj2bNqzKt0OCaE2t1 X-Received: by 2002:aa7:c358:: with SMTP id j24mr33158481edr.147.1572908737881; Mon, 04 Nov 2019 15:05:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572908737; cv=none; d=google.com; s=arc-20160816; b=C2Zo0phBHtNbIMESJyIfoNuaFrA1mMmj0XxqSOL+psZqrRSfkvzgoQilq3kWs1IgKG CjBdaNT03RbFximXzqyaKwVgCWEZzZ/OKSv95eW/j1+lFjKkeQA9NoBO8zqlM2+zvEDw oG8o+OoReRP80BxFxw93AiZqfDYPXz48/+t7SVwCnsBz3V5XZHqEMV2ov64pkTJk8Ju3 wKtGvDdL13Jh57cpR34EYcY6s7Nrd7ikCHNkFcTlg//12jH2RZuwMNtCGZlCV5ZyXbMY 4+yri1dwMyazyplghbgsDOys1+v1jGSB+yLXzFGX/MPm0EsrnIP+hrinSvYUSypANRNN mIqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tktmbgMbA44XbKL0C1wWEcJpxBYyzYw3dy09GJTCB3c=; b=lu71uhRIEx1gdSgn88audGeQn0tWdheKdCUbkB5gAB+GqGyxZJ8p0xLlvnmCPUXOca kXQMz9kp1BLI+m5MhrbtJPpAPC0Y6LJSEZmJ5X8Qbfu4x1lpoOwqFnHRFoiulruIs2RI VhydudWt/xpZ/n0F9UMzWpkCWNwjR3gSAhdr+4sCBKkz4XFNIMWyBh2+Nr8la3YAzKzZ 6T8D5+fVTZ1rMz08KX5D6JkjzskL91jaSx6zG0tXjJslqFpwCPdJltFRoNqhw+dHsTq4 /HDnh72w296fQ22H9/manJKcYi/fOg+wF6/Le0WAiZ767lkqiVdXMRXYdRR8ZuqN1KlA +Fxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P0Ah3+a1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21si8388519edc.305.2019.11.04.15.05.14; Mon, 04 Nov 2019 15:05:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P0Ah3+a1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729988AbfKDXAL (ORCPT + 99 others); Mon, 4 Nov 2019 18:00:11 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:55418 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729194AbfKDXAL (ORCPT ); Mon, 4 Nov 2019 18:00:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572908409; 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=P0Ah3+a1on+Bc45a/ZIonkqN7f1Vv9eEMGYwwo5mG0LgAI/gIWO0XUbxuq/G6VLqkZ11/G WCRp/585uAr6HqV2ShVh+Thh+kswDUZ7m+OYJeo/HtGk7BfpcA046D/qC4aEbtaR/rj3Jm w8rNxjX5tWDgP4jIKwP/yshDKWaz8e0= 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 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: =3D=3D=3D The left side of the "||" ensures that, if KVM=3Dm, 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=3Dy CONFIG_KVM_INTEL=3Dy CONFIG_KVM_AMD=3Dy The right side of the "||" part is just for documentation, to avoid that a selected symbol does not satisfy its dependencies. =3D=3D=3D=3D 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 =20 =09 If unsure, say N. =20 +if KVM=3Dy + +choice +=09prompt "KVM built-in support" +=09help +=09 In order to build a kernel with support for both AMD and Intel +=09 CPUs, you need to set CONFIG_KVM=3Dm instead. + +config KVM_AMD_STATIC +=09select KVM_AMD +=09bool "AMD" + +config KVM_INTEL_STATIC +=09select KVM_INTEL +=09bool "Intel" + +endchoice + +endif + config KVM_INTEL -=09tristate "KVM for Intel processors support" -=09depends on KVM +=09tristate +=09prompt "KVM for Intel processors support" if KVM=3Dm +=09depends on (KVM=3Dm && m) || KVM_INTEL_STATIC =09# for perf_guest_get_msrs(): =09depends on CPU_SUP_INTEL =09---help--- @@ -72,8 +93,9 @@ config KVM_INTEL =09 will be called kvm-intel. =20 config KVM_AMD -=09tristate "KVM for AMD processors support" -=09depends on KVM +=09tristate +=09prompt "KVM for AMD processors support" if KVM=3Dm +=09depends on (KVM=3Dm && m) || KVM_AMD_STATIC =09---help--- =09 Provides support for KVM on AMD processors equipped with the AMD-V =09 (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=09=09=09+=3D x86.o mmu.o emulate.o i8259.o irq.o la= pic.o \ =09=09=09 i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o \ =09=09=09 hyperv.o page_track.o debugfs.o =20 -kvm-intel-y=09=09+=3D vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o= vmx/evmcs.o vmx/nested.o -kvm-amd-y=09=09+=3D svm.o pmu_amd.o +kvm-intel-y=09=09+=3D vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o= vmx/evmcs.o vmx/nested.o $(kvm-y) +kvm-amd-y=09=09+=3D svm.o pmu_amd.o $(kvm-y) =20 -obj-$(CONFIG_KVM)=09+=3D kvm.o obj-$(CONFIG_KVM_INTEL)=09+=3D kvm-intel.o obj-$(CONFIG_KVM_AMD)=09+=3D kvm-amd.o