Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp715250pxb; Fri, 8 Jan 2021 16:51:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQ1XYIj4V8FfGe7RHQ3IRubGSMbuFXuLh0Njk5tPrJonPh9TRPiz9MLT/mtD7IXxnOoF8Q X-Received: by 2002:a17:906:3899:: with SMTP id q25mr4161796ejd.173.1610153483614; Fri, 08 Jan 2021 16:51:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610153483; cv=none; d=google.com; s=arc-20160816; b=FnfolQTR3TR+BQUaS53Aeg8g8LKBhRiSRMibX/1CuLD3Ns8/FtOzplkW776lG/25Zu OKrohBZSUVUO1pcSxzI7OdVItlOBj2Av58GpX8vE66C4si24SSHPEN/nOGgymRyQm4JA A35NTwM47yFMwP6InjKcMPZ7/vf8WSEdSCxQFiY1dmoNbYX/2554z6BNgCHAdZ7KpvxR xvyrSN393CxOcGUafzdFeMb48+1qs3ttmAFTqgGvBQ9jA3E/lI09GQJibz8Nj6G2y8eM kNyYDexigbudgYZYPFioPOLMPKL/lLGrwkFGQU7ypkFg4WlHJGfxjlkOTQ8FUGOITxWA e1vw== 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:sender:dkim-signature; bh=Yn6K+Al6keU4qwvbVZAct8COFyc60/5tuafg8uWsv9s=; b=KWIPX9S9RF/a8xLQkkPeYSbKrSgoqK88aa9FJgC5Th8jRf4AgmhQNASaqbynFTuUCE lc0RHbZNK+P1/kuWo7+hvoSFVBg81UNwV6z6nwy64/nEbcFJtHwrNpCt+9EyqtJLg0hp mvvhoa4l6KmrR6L9X0uJ3p3TuKabg+F2j3z6puHjU/zISYYl3S/97hNRo0lc+0nnGCg1 QCEm0doWSLPkqjvHe9pYlQmPrqM41x58KQmMXzyjbn3KosYQlvZVOpUqj+Zx/QNY1S+D x8cGWtz1w8tSRMjC7pxxNcL6jFduXIosOANJdq1wwY9YCspaPOWW5IkKn5J5Fj39vdUT 9+8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bbeQTlQl; 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 gs18si4441547ejb.435.2021.01.08.16.51.00; Fri, 08 Jan 2021 16:51:23 -0800 (PST) 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=bbeQTlQl; 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 S1726589AbhAIAs5 (ORCPT + 99 others); Fri, 8 Jan 2021 19:48:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbhAIAs4 (ORCPT ); Fri, 8 Jan 2021 19:48:56 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33742C0613ED for ; Fri, 8 Jan 2021 16:47:43 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id k7so17298347ybm.13 for ; Fri, 08 Jan 2021 16:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=Yn6K+Al6keU4qwvbVZAct8COFyc60/5tuafg8uWsv9s=; b=bbeQTlQl3egG62Ts6ELH5KNNB1jDgXjcJJ90vMoAdtAKoeEiqM2CZMAQB5H6m9v8Vu 5m9u58NKIAKLJSRavQpaV8lEz5bYnHTlqyXzGbHJvzD508hT9ojxxTZqEFOSLGaBNy+r QQBpoZY6+8wxikOg3TfgNPg97eayvDZchKJHk0okuKRdxJjdQRVaq3PnCIpGSk77mFHg IaPE51sBvZKJFGwCt6IUs3chaUWzkpILtYdB9fEx3eVTtxIHVfcLZzcw/gUxtggklfgv 3X6oWAK31B4kFg9gihTEFgIJUBwWrbvBrOsJfASBMJ4izzb4iVmB3/zVCxzvJ2gjHE4D pxzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=Yn6K+Al6keU4qwvbVZAct8COFyc60/5tuafg8uWsv9s=; b=TaH0pBKTKdYYhyS2ojta8CJrCcxfIj+mERvXoMu+kkWm2C8etL8bRqeZX4CKNwgzF+ 7H+8iBrGCC4j9HQdphaConZ3RcyTu6o4ns+W+w9R0PzKq3ok1MdkmR+ySmXLzJPS4Hpg vYQ59rrqxq8qJYtK2EXh/5QywTiHfzEsAV33YqHKXtItaKTNzyqxd6QMMDqv5vjvtto0 BI2SltDGA+q2tcmLtPpPEk9L0aFNjk3EfHojoXr47pygdOt1+L1tF8NCNEpOknCbGD4z +tLNZL8/blkeRFMg3G6F7P73ak/l3W6aJHgNoKDATDxlLjwFY0zN0qoZHdUixOnMsJXu aczw== X-Gm-Message-State: AOAM5314QO81iLJmyD6jZurWI4msO67ry9KvWJjJ8R/SdsQqnzHRfTwb nf85IlttStKW9Y7Vi6kL3gFow4cvlN4= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) (user=seanjc job=sendgmr) by 2002:a5b:b49:: with SMTP id b9mr8648623ybr.310.1610153262395; Fri, 08 Jan 2021 16:47:42 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Jan 2021 16:47:04 -0800 In-Reply-To: <20210109004714.1341275-1-seanjc@google.com> Message-Id: <20210109004714.1341275-4-seanjc@google.com> Mime-Version: 1.0 References: <20210109004714.1341275-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 03/13] KVM: SVM: Move SEV module params/variables to sev.c 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, Tom Lendacky , Borislav Petkov , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unconditionally invoke sev_hardware_setup() when configuring SVM and handle clearing the module params/variable 'sev' and 'sev_es' in sev_hardware_setup(). This allows making said variables static within sev.c and reduces the odds of a collision with guest code, e.g. the guest side of things has already laid claim to 'sev_enabled'. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 11 +++++++++++ arch/x86/kvm/svm/svm.c | 15 +-------------- arch/x86/kvm/svm/svm.h | 2 -- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 0eeb6e1b803d..8ba93b8fa435 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -27,6 +27,14 @@ #define __ex(x) __kvm_handle_fault_on_reboot(x) +/* enable/disable SEV support */ +static int sev = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); +module_param(sev, int, 0444); + +/* enable/disable SEV-ES support */ +static int sev_es = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); +module_param(sev_es, int, 0444); + static u8 sev_enc_bit; static int sev_flush_asids(void); static DECLARE_RWSEM(sev_deactivate_lock); @@ -1249,6 +1257,9 @@ void __init sev_hardware_setup(void) bool sev_es_supported = false; bool sev_supported = false; + if (!IS_ENABLED(CONFIG_KVM_AMD_SEV) || !sev) + goto out; + /* Does the CPU support SEV? */ if (!boot_cpu_has(X86_FEATURE_SEV)) goto out; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ccf52c5531fb..f89f702b2a58 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -189,14 +189,6 @@ module_param(vls, int, 0444); static int vgif = true; module_param(vgif, int, 0444); -/* enable/disable SEV support */ -int sev = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); -module_param(sev, int, 0444); - -/* enable/disable SEV-ES support */ -int sev_es = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); -module_param(sev_es, int, 0444); - bool __read_mostly dump_invalid_vmcb; module_param(dump_invalid_vmcb, bool, 0644); @@ -976,12 +968,7 @@ static __init int svm_hardware_setup(void) kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE); } - if (IS_ENABLED(CONFIG_KVM_AMD_SEV) && sev) { - sev_hardware_setup(); - } else { - sev = false; - sev_es = false; - } + sev_hardware_setup(); svm_adjust_mmio_mask(); diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 0fe874ae5498..8e169835f52a 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -408,8 +408,6 @@ static inline bool gif_set(struct vcpu_svm *svm) #define MSR_CR3_LONG_MBZ_MASK 0xfff0000000000000U #define MSR_INVALID 0xffffffffU -extern int sev; -extern int sev_es; extern bool dump_invalid_vmcb; u32 svm_msrpm_offset(u32 msr); -- 2.30.0.284.gd98b1dd5eaa7-goog