Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2459139rwb; Thu, 29 Sep 2022 10:24:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5a3hV/JKD72prN6AQZNna0xEwaKKp8OSMVwwoeOmls81P8m8VYbVglMR+20CZoorV4dDE9 X-Received: by 2002:a17:906:9bd3:b0:778:c8e0:fcee with SMTP id de19-20020a1709069bd300b00778c8e0fceemr3535966ejc.275.1664472295978; Thu, 29 Sep 2022 10:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664472295; cv=none; d=google.com; s=arc-20160816; b=lLZ1SJmp7E1cBb5gJCoguHBGyXOxL9mj7x40BwJd5CzEo/D8nATQCYyGKpJLTGcCuh l0f1DtWCzen8CagwRvQEbGbINeVmzqZUHXRU22oxGdV2BPoQl82UB6TihLVlGMOErK/f UNr4Vs2190nBBwuvUDYaoP6UuLmxyTWZFqFBley0YYCHPx7JebbS8Lq3qEOfPzbAeV1d y0fnmyxuGTzOVCGnwP1ZUyfU0HElCCYzpA+ETl95J+AzvluZtX5AakppQx5GfS0VFGBq b32Y0oAwbZBesfUkAod0XkwdIJqAWcMyipCNK7Zwasy7wWVTHsSx+DbBGV7rs+cTDfHc GEOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=FmyEedCC+EL9I+qlzq1lN9CZWGu+SVJgbuQF5LzXs9Y=; b=bIwGMH5N/Bc6gGbJHniIz64uAOaRPBXXvCDKp4ccSuK3PduN0P0+OALU3dKf6AHcUm OUx/YUjACOKy154f6I8wRKP45SgVrUAsBEKC5ErdUPoqMV3s4eS7x9SppnjhMRhfEMx8 vhG39JX1Gj8qGy5rMmrPETOij7bgvafgaSIg4AGnWf2YCHNJS1+6Xu5+gv5Cp8NM2qvW qkPi9eX9R2tS1r/qjkLD5y/QdCDmHzxGGLfV28F7Y0vYouVzeW74oRNmKMStEICvXfca Z5ZrLdyXSvAAfCab4qKZgkiszYUSY8Dvs6auICOXRk+sBGwyQNINF+zfbtw+CCyriY4+ iQuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mi2FbIpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020aa7ce95000000b004516e0b7f3dsi38096edv.503.2022.09.29.10.24.31; Thu, 29 Sep 2022 10:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mi2FbIpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235884AbiI2RUl (ORCPT + 99 others); Thu, 29 Sep 2022 13:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236063AbiI2RUY (ORCPT ); Thu, 29 Sep 2022 13:20:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C332D106522 for ; Thu, 29 Sep 2022 10:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664472022; 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; bh=FmyEedCC+EL9I+qlzq1lN9CZWGu+SVJgbuQF5LzXs9Y=; b=Mi2FbIpT7jonbdaMu7xwGbn+gyIpKun7gPlwZmpfjyDGhij7KERV06sz6CTUJS9BuoeoEf ErDEgynyUhzmM5A4apityxOPaGXSGbNO5qQpOw3s4sx5G1QjWsD3o1VuuUf0PqF+5PAcIz ptl4upJdoYe0yT9Q5WKb5Odp+xajqrc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-310-CXm2IjFmMIWbtSNBv4ONFA-1; Thu, 29 Sep 2022 13:20:17 -0400 X-MC-Unique: CXm2IjFmMIWbtSNBv4ONFA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A92C9857F90; Thu, 29 Sep 2022 17:20:16 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84B524221F; Thu, 29 Sep 2022 17:20:16 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, maciej.szmigiero@oracle.com Subject: [PATCH v2 0/8] KVM: x86: allow compiling out SMM support Date: Thu, 29 Sep 2022 13:20:08 -0400 Message-Id: <20220929172016.319443-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some users of KVM implement the UEFI variable store through a paravirtual device that does not require the "SMM lockbox" component of edk2; allow them to compile out system management mode, which is not a full implementation especially in how it interacts with nested virtualization. In order to limit the number and especially the size of the #ifdefs, the first 4 patches move most SMM code to a completely new file in arch/x86/kvm. Patch 5 is the main change to introduce the Kconfig symbol and key smm.c's compilation off it; patches 6-8 instead eliminate other bits of SMM code that remain outside smm.c, the last one being "optional" as it is a bit into diminishing returns land. Paolo Paolo Bonzini (8): KVM: x86: start moving SMM-related functions to new files KVM: x86: move SMM entry to a new file KVM: x86: move SMM exit to a new file KVM: x86: do not go through ctxt->ops when emulating rsm KVM: allow compiling out SMM support KVM: x86: compile out vendor-specific code if SMM is disabled KVM: x86: remove SMRAM address space if SMM is not supported KVM: x86: do not define KVM_REQ_SMI if SMM disabled arch/x86/include/asm/kvm-x86-ops.h | 2 + arch/x86/include/asm/kvm_host.h | 24 +- arch/x86/kvm/Kconfig | 11 + arch/x86/kvm/Makefile | 1 + arch/x86/kvm/emulate.c | 355 +---------- arch/x86/kvm/kvm_cache_regs.h | 5 - arch/x86/kvm/kvm_emulate.h | 47 +- arch/x86/kvm/lapic.c | 14 +- arch/x86/kvm/lapic.h | 7 +- arch/x86/kvm/mmu/mmu.c | 1 + arch/x86/kvm/smm.c | 573 ++++++++++++++++++ arch/x86/kvm/smm.h | 38 ++ arch/x86/kvm/svm/nested.c | 3 + arch/x86/kvm/svm/svm.c | 11 +- arch/x86/kvm/vmx/nested.c | 1 + arch/x86/kvm/vmx/vmx.c | 7 + arch/x86/kvm/x86.c | 353 +---------- tools/testing/selftests/kvm/x86_64/smm_test.c | 2 + 18 files changed, 737 insertions(+), 718 deletions(-) create mode 100644 arch/x86/kvm/smm.c create mode 100644 arch/x86/kvm/smm.h -- 2.31.1