Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp81026pxy; Wed, 21 Apr 2021 19:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxm6jrpsY0n86tsigk8CSk6lhnHs7MyHf6Jew7UKZAmxOX6U2ngWbVxlosDwVAVMFQuoHIo X-Received: by 2002:aa7:8512:0:b029:25a:b502:e1ad with SMTP id v18-20020aa785120000b029025ab502e1admr1090162pfn.22.1619057642799; Wed, 21 Apr 2021 19:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619057642; cv=none; d=google.com; s=arc-20160816; b=N3cvIqxXKH7Yz33ECEdQlWOyh1Zie2wEPoW714Mc8R0xe0ugDoecdzMbQRj6oTZBv0 Zlq398dmXR+zkVti54kTLAWjbWfuPgKXETfgKnbTI7YAwcg48ARfVnzLS4lVL2hRV2Hm TBmGnufKqAMzZnFLifEC5y/YAYBD80N4k4qZklghWV0Cea8vXrdWBSLIRqEnPrdgHc5O RFVBHe2UtnGoBz4rIO6KRkA9+NXJnwGkWaAWw2jA5Qmt4tlP/9VPjZ9i59QYU8Ng8Kmz qwft96m/hN5RSrP0i1O8EZsl0Dl+dt1/yUWXVZpPBQaMLbwhxM05uAkbX2vFNSpOVmj6 DlmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=M+EV17K09Jw3Z2+bqjVXisuWTECXp2lypwrOyx6edfg=; b=uHVH4jyF6kGtlVxe8vMwxQiPo3a1qCSOkf6+lE7Tkihz1D4H5Ctm401GatmMr1SvSt WZCadJbpZ1B3uc02++NG7swEdbN5/c/NZYNC9tSd1UCDWyfVjYM0+5sEIGXmE2Kr4Vrb CWHay+5AoUJEOdnDhwv5/U4T/8jE3vSzhlii+7RfLsj34szaOBM5foM0ZLShe6BgmK6J JDuy6AdCeL6YtGU6P55iLu25T1YNLp3C9kJ5DaYH5aQKTiFJZSjVDdfN+1jV/UN8KHZo yAvcJL75/bMpzdrkW/LXGJDynBUAnE6hZPkDcDc7nmoznTnVFwn26/ncJookXY3v9oMV hbrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WdjBYY71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t75si1383242pfc.174.2021.04.21.19.13.50; Wed, 21 Apr 2021 19:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WdjBYY71; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234235AbhDVCMg (ORCPT + 99 others); Wed, 21 Apr 2021 22:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234475AbhDVCMX (ORCPT ); Wed, 21 Apr 2021 22:12:23 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70CFC06174A for ; Wed, 21 Apr 2021 19:11:46 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id e65-20020a25e7440000b02904ecfeff1ed8so6818745ybh.19 for ; Wed, 21 Apr 2021 19:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=M+EV17K09Jw3Z2+bqjVXisuWTECXp2lypwrOyx6edfg=; b=WdjBYY714q1SkVGA3+8FJWIs7t1KO+Td1j8qqTAn2t8XbOY4FwT+cb3XDSglS/CmN3 /h1eIwTnx4MMBV2bpq08Ovt1fNSVKIMnzfVDOMYAJoiNZLBTnooWjA/iynUcYuPZ3nE6 2f+jOOGBYLanQ7YHhVNISUNniQ5QXERn5vEvCz0GEODVRwh3fReqBXWjT1PmwoQrIP6c /b31qsu+5OEQXl0HVKoY45f4Paur5Cfw1LvBxMcMza/PDZEjS1Ph162g7lZjfK8zlAdQ WCs/914EiqBCwBu4PU7d/rW+vDkl6cZ2Abnaj+shbydw0uf/azp7/Nvm1FAjBprdCYjM B6zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=M+EV17K09Jw3Z2+bqjVXisuWTECXp2lypwrOyx6edfg=; b=er4hh/qgv0QntCjHUNfMx+lnpzoZAI6XfVBt6A9dKNIovCi6tLgP7dO5ZdjCeGg25B pD3fDyIgf4LbBwU7Xwd24UJQHkYR+ze0zKwDyNVTu1IujNkDyhPN+vm/kdTdTNTAh+GZ TlHD0PQMDNJbOYxSyDokRZyJ/lKRg4vPmvPRLJzIH/2Pj7RqTN9mdpzV1J0jPhqy3gra 4J7WAuloE6/InAQIdhhTD7qXSiHPg41tsk/1tCosjsPcwkFJ65b/1f4BwmyvselvwJXq Dyn/XUZlVK+PkTMxNuMxpdfm3oHIkl5OnR6PFis44o7AG3gTlUlzTf5zrhs29GWUqIPM 57Qg== X-Gm-Message-State: AOAM5332uOCKPsS2Ik9Yvr8M9D3vxzW9DE1SDYRyh4iE9t52kuJfvkGM Fk7z/AXCfC2XU/baAJRShWDPMUjg6Wg= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:e012:374c:592:6194]) (user=seanjc job=sendgmr) by 2002:a25:3251:: with SMTP id y78mr1332201yby.455.1619057505890; Wed, 21 Apr 2021 19:11:45 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 21 Apr 2021 19:11:18 -0700 In-Reply-To: <20210422021125.3417167-1-seanjc@google.com> Message-Id: <20210422021125.3417167-9-seanjc@google.com> Mime-Version: 1.0 References: <20210422021125.3417167-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH v5 08/15] KVM: SVM: Condition sev_enabled and sev_es_enabled on CONFIG_KVM_AMD_SEV=y From: Sean Christopherson To: Paolo Bonzini , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Tom Lendacky , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define sev_enabled and sev_es_enabled as 'false' and explicitly #ifdef out all of sev_hardware_setup() if CONFIG_KVM_AMD_SEV=n. This kills three birds at once: - Makes sev_enabled and sev_es_enabled off by default if CONFIG_KVM_AMD_SEV=n. Previously, they could be on by default if CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y, regardless of KVM SEV support. - Hides the sev and sev_es modules params when CONFIG_KVM_AMD_SEV=n. - Resolves a false positive -Wnonnull in __sev_recycle_asids() that is currently masked by the equivalent IS_ENABLED(CONFIG_KVM_AMD_SEV) check in svm_sev_enabled(), which will be dropped in a future patch. Reviewed by: Tom Lendacky Reviewed-by: Brijesh Singh Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 9b6adc493cc8..2fe545102d12 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -28,6 +28,7 @@ #define __ex(x) __kvm_handle_fault_on_reboot(x) +#ifdef CONFIG_KVM_AMD_SEV /* enable/disable SEV support */ static bool sev_enabled = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); module_param_named(sev, sev_enabled, bool, 0444); @@ -35,6 +36,10 @@ module_param_named(sev, sev_enabled, bool, 0444); /* enable/disable SEV-ES support */ static bool sev_es_enabled = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); module_param_named(sev_es, sev_es_enabled, bool, 0444); +#else +#define sev_enabled false +#define sev_es_enabled false +#endif /* CONFIG_KVM_AMD_SEV */ static u8 sev_enc_bit; static int sev_flush_asids(void); @@ -1774,11 +1779,12 @@ void __init sev_set_cpu_caps(void) void __init sev_hardware_setup(void) { +#ifdef CONFIG_KVM_AMD_SEV unsigned int eax, ebx, ecx, edx; bool sev_es_supported = false; bool sev_supported = false; - if (!IS_ENABLED(CONFIG_KVM_AMD_SEV) || !sev_enabled || !npt_enabled) + if (!sev_enabled || !npt_enabled) goto out; /* Does the CPU support SEV? */ @@ -1834,6 +1840,7 @@ void __init sev_hardware_setup(void) out: sev_enabled = sev_supported; sev_es_enabled = sev_es_supported; +#endif } void sev_hardware_teardown(void) -- 2.31.1.498.g6c1eba8ee3d-goog