Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp34414pxb; Tue, 12 Jan 2021 19:11:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwa+5/KaYwqkdZ3tyqh38Lsv1oCvbwNtae76JD92c/02pWuIHp/8YvsReUriLDnFeKLN4iG X-Received: by 2002:a05:6402:2377:: with SMTP id a23mr118337eda.34.1610507481431; Tue, 12 Jan 2021 19:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610507481; cv=none; d=google.com; s=arc-20160816; b=dUbT9dZ+A0ZsKeAfZOZ+lJTBK5KvtrV3F33+Oc0pI7Eq4LEmV7gFF7h8YKHCf47zAA 1UghiQpTycZX6mLy8vkRUaK14OB3y3C+KuMSYA4FS7Rl0ELMXvAzLHbT+YwFlnl501lu NWzL002Nzc4h64bmn1SpEKxPAPXyzPa97CPc4zr5r8R8fy24/KYpW1nVJNsTJJAk2oVd 3fruEUPbjL380o4kd+NA0afmQv9MhJsnyLjYmv3H7v404PviISEj8+VGb/VN8/dmSZmj 2nvDkkLf4i1MvlTPUp6r/7Q/dRXJrUC+8+ktXuO+/f4gaLVBXCZF3RYvo2S8BE+28PGD nmpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=D94bTQz9Dscjb4392yuJLnozu8co+6TjlHWNTrMYHUs=; b=CiTwyJa4R1h39r3pzod6jOcQpwSvqlIgCjKee6T5R4fJq8ThH1MuYsA2S/LC3fUGok jnObXxESkJo+eZh1VkRaxg8tfv5sP3DPVFbWOX1ZF9PcdtFxHcST7WXt6bSBpT1+uUCE BWkR/Vy7jE4l+R6VRsaX7ByMchKv20cxdSqqdUGD18KTOWP3FoqLiXBSV8dC1fVNh3yw LYoqFw4T4qSaskwyQM1cEfUbhWHepMczNr+YNebNjldlH8dDjCPJ1AIp9tXU8BUMVJMC D+I8bckodyfLUzU7BZntNfZG2FDo4g0XxOlj8CCW45L7/VPoQK3y+udQQqTGNB5haJS7 mMKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=k2fC4CfR; 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 e25si328548edq.489.2021.01.12.19.10.57; Tue, 12 Jan 2021 19:11:21 -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=k2fC4CfR; 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 S2438319AbhALWS4 (ORCPT + 99 others); Tue, 12 Jan 2021 17:18:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404672AbhALWSz (ORCPT ); Tue, 12 Jan 2021 17:18:55 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA128C0617A3 for ; Tue, 12 Jan 2021 14:18:14 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id n7so133678pgg.2 for ; Tue, 12 Jan 2021 14:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=D94bTQz9Dscjb4392yuJLnozu8co+6TjlHWNTrMYHUs=; b=k2fC4CfRFE5cZ37SaYKA95nYdU+VpqUqDsjI5gAEa9XKBzDbJ1Z9d2qi0gbwvkGL4d eSZD5/+O8UbjZWTzVdOS/0NjZWx/5tC4zN7cc321WLZ0Y9jAP47bqBR2CsY3MS9u0ApS ior7i82v4r8gohZZMyAb42LLZw6tp3B11zMQVhL+cYYZ3BSdqopUuvb8XABFlF+jGRJU 2A7O0jlAm1Zd0Fd1KPMzRtFUBH3Lp3aDKVy0QfSTsrFxd/L35bIyO/7n5YtKx5OHZ2iI jVTh4nXuh5oP2LEf+gp8ZxVqmzxsbT3CBsILk2/UM8THWUs50NCErnu/zs57rzPO1MhE O/QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=D94bTQz9Dscjb4392yuJLnozu8co+6TjlHWNTrMYHUs=; b=ld+MnYOQ9mTES+x8A/LQH76mPCe3F+ywmpuUOro/r2KKZ7TAe7e+5ZfCJ94SskJMZI NWt5AJ4UX3N4lAkPYoJk81Y3mBKm9djex51SVcK4pUP4abHePTzQptxVarzf1stbrg/q OwwT2XZbPTxhHNTJHhIcf+rP7lQZkMfQ+yYfeU9G6ZhtTqIamQmM6zMR7t0yE4Wt2Gbr NxrxsACXFTkBUXvjgeQ8wn/VJwyIJsl6oGx3xU3eOwa6LAUFme7wgDosRWQzJcZt2vM6 LoSTi7G/tdDMsb6jddR2/EKRARs3bP4R07ti3BtRH2kPX1/AFKKarF2VEYe+yO0eXbvZ J2lQ== X-Gm-Message-State: AOAM530GBRQZFKtBIHiFOzhxUzMn9RxLcikunQbbWwo2vTmFcNqfOy4o ybL1SfYlEkMs0SpQo/+/ZR9+DQ== X-Received: by 2002:a63:4082:: with SMTP id n124mr1200591pga.340.1610489894074; Tue, 12 Jan 2021 14:18:14 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id 77sm122040pfv.16.2021.01.12.14.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 14:18:13 -0800 (PST) Date: Tue, 12 Jan 2021 14:18:06 -0800 From: Sean Christopherson To: Vitaly Kuznetsov Cc: Tom Lendacky , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Brijesh Singh , Paolo Bonzini , Dave Hansen , Andy Lutomirski , Peter Zijlstra Subject: Re: [PATCH 03/13] KVM: SVM: Move SEV module params/variables to sev.c Message-ID: References: <20210109004714.1341275-1-seanjc@google.com> <20210109004714.1341275-4-seanjc@google.com> <87sg7792l3.fsf@vitty.brq.redhat.com> <672e86f7-86c7-0377-c544-fe52c8d7c1b9@amd.com> <87k0sj8l77.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k0sj8l77.fsf@vitty.brq.redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021, Vitaly Kuznetsov wrote: > Tom Lendacky writes: > > > On 1/11/21 4:42 AM, Vitaly Kuznetsov wrote: > >> Sean Christopherson writes: > >> > >>> 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); > >> > >> Two stupid questions (and not really related to your patch) for > >> self-eduacation if I may: > >> > >> 1) Why do we rely on CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT (which > >> sound like it control the guest side of things) to set defaults here? > > > > I thought it was a review comment, but I'm not able to find it now. > > > > Brijesh probably remembers better than me. > > > >> > >> 2) It appears to be possible to do 'modprobe kvm_amd sev=0 sev_es=1' and > >> this looks like a bogus configuration, should we make an effort to > >> validate the correctness upon module load? > > > > This will still result in an overall sev=0 sev_es=0. Is the question just > > about issuing a message based on the initial values specified? > > > > Yes, as one may expect the result will be that SEV-ES guests work and > plain SEV don't. KVM doesn't issue messages when it overrides other module params due to disable requirements, e.g. ept=0 unrestricted_guest=1 is roughly equivalent. Not that what KVM currently does is right, but at least it's consistent. :-) And on the other hand, I think it's reasonable to expect that specifying only sev=0 is sufficient to disable both SEV and SEV-ES, e.g. to turn them off when they're enabled by default.