Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp408750pxy; Thu, 22 Apr 2021 05:07:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzChnSnFsl9ccQFK6ybkLdQPu0fhk+FqcEYeaIyqMpgXA2im0DuTBs8vjl4JotuEp1eiXX7 X-Received: by 2002:a17:906:3e89:: with SMTP id a9mr2892388ejj.405.1619093252689; Thu, 22 Apr 2021 05:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619093252; cv=none; d=google.com; s=arc-20160816; b=w+DEHFpDvSzyURVQFCC/BzdMnqc0sGSPbT46G8//mD18Yz1iyz6PVJKanSzzqeleql tjRDq9a/ag5uGhgKo6NVUip1Rmkcgv8eiZ5JN47TAiu9D3q2Ts7YNLE8ksFhubap+CQf fUHNaSD9QHUr70rcqJOaFH9lRC3qEPBspNDchdoP/LPDxU0Df+4xiagQLT7aZUYz9bgC zqgvqam4UOC5mLLQA+/ZlnlR046FCIhiPjM3uG4qPjivgmbWSEzasd+j6hR+GhadQr5k P+qAKHIep1mLnrObHEtZMjeJAnD733joOq33DvGbjrZ2W+VUjRa3JA1D/ksJzFmOBMJM Euzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=c+A0xZ5eON9gs40KcP02cAVAi5lehO7xjvA952SuU50=; b=w7TiHpj9101erkC81rnmEaLr2cD8twacmZaPZU5b5Z+z9VVHJuQf0V30inNDTVIm9V iNywCha17+0/nV7RfMs8MgjRt0hYN/18i73kgYZmvzy1W5vzRgto8uLblOFfgPGTUDDY jrI86h69d1H6mzneoo2njC2YzBItBirGLBVbtwzGMPCvZbSM+2NNBkDEcfV8kkA/0M9s Uh1nqEvSICfqEP3aCA6L3xEfAkKRiSAJyn4o4wjBKb5pSz7Jn5tKtcbjj/Cry8g5ZAJT UVg5R7EkyufIYUv3pu2Rea8jFN8CH5wKD9yTW8zJ6+BozlnL0vzGIVQtBFfpIwt+BtdC 3gFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hfbyeY0y; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si2103065edd.61.2021.04.22.05.07.08; Thu, 22 Apr 2021 05:07:32 -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=@redhat.com header.s=mimecast20190719 header.b=hfbyeY0y; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236148AbhDVMGk (ORCPT + 99 others); Thu, 22 Apr 2021 08:06:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35901 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236152AbhDVMGg (ORCPT ); Thu, 22 Apr 2021 08:06:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619093161; 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=c+A0xZ5eON9gs40KcP02cAVAi5lehO7xjvA952SuU50=; b=hfbyeY0y5NvYe2aOAChe4rNAuffis4dyvCiMGrX8yVsOZ7pHCEwmtXcxMfKVDEzk9A5AEF fVtNOT7iWHdUoXQWxVUuoGPQBdxXYKU+2J+jKsoDTrFaPtLTL+swCZTMGJAExeJPB9BrF5 u2xo+9TDKdPf4xoHwanW3vZOFGbHkN0= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-qLUcPzZQMhiqprCnC6ZAMw-1; Thu, 22 Apr 2021 08:05:50 -0400 X-MC-Unique: qLUcPzZQMhiqprCnC6ZAMw-1 Received: by mail-ej1-f70.google.com with SMTP id ji8-20020a1709079808b029037c921a9ea0so7100825ejc.9 for ; Thu, 22 Apr 2021 05:05:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c+A0xZ5eON9gs40KcP02cAVAi5lehO7xjvA952SuU50=; b=abwXYr1bi4K6i78VibulvI/U5N4unKVqCEbL4Eqjlc0czRhF0ke29bw9Vy1Softfxo j97KF8SJOGC+fDg+07BOR7rm/XFfi1SEwS4N9dqav2muhyUCaKwOb7DR6/OLx70M/12N 0NCojdPuaI97Kuvd90u1+i6npOQ5oU9+wKoLfH7vQzu8JNK9uyRPzoPuk+NJuF7SGYCA JPe+luLiIxTf/uUku5T68wANsHdzMfP3BUFl3F64R9X5xcZGH4KCB2caH2Xvq6RuwMx6 4toCP8maM4Tf3nMXtfcDoD2IS2V9YF/aX/PEHEHWFKSHCnHoNRI7TV5t7razh8PzzaV4 JnfQ== X-Gm-Message-State: AOAM533Hl7gF+IabOlw94OBNj6enMYN/Q3n3VwgGMEomCApkoul+4sNi u+S2ubu4NPsTnSCL553APLGgttwIhR1B/j0l1EFZdDfVFjP+4h8nJHK2BzGm9y8cJHwJt7DStk9 lf5SuJjtUzRmtQr62M86eFHfh X-Received: by 2002:a05:6402:518f:: with SMTP id q15mr3555967edd.150.1619093148984; Thu, 22 Apr 2021 05:05:48 -0700 (PDT) X-Received: by 2002:a05:6402:518f:: with SMTP id q15mr3555957edd.150.1619093148838; Thu, 22 Apr 2021 05:05:48 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n13sm1745261ejx.27.2021.04.22.05.05.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Apr 2021 05:05:47 -0700 (PDT) Subject: Re: [PATCH v5 06/15] x86/sev: Drop redundant and potentially misleading 'sev_enabled' To: Sean Christopherson , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Borislav Petkov Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Brijesh Singh References: <20210422021125.3417167-1-seanjc@google.com> <20210422021125.3417167-7-seanjc@google.com> From: Paolo Bonzini Message-ID: <8f1fa7e0-b940-6d1d-1a74-11014901fc0d@redhat.com> Date: Thu, 22 Apr 2021 14:05:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210422021125.3417167-7-seanjc@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/04/21 04:11, Sean Christopherson wrote: > Drop the sev_enabled flag and switch its one user over to sev_active(). > sev_enabled was made redundant with the introduction of sev_status in > commit b57de6cd1639 ("x86/sev-es: Add SEV-ES Feature Detection"). > sev_enabled and sev_active() are guaranteed to be equivalent, as each is > true iff 'sev_status & MSR_AMD64_SEV_ENABLED' is true, and are only ever > written in tandem (ignoring compressed boot's version of sev_status). > > Removing sev_enabled avoids confusion over whether it refers to the guest > or the host, and will also allow KVM to usurp "sev_enabled" for its own > purposes. > > No functional change intended. > > Reviewed-by: Tom Lendacky > Reviewed-by: Brijesh Singh > Signed-off-by: Sean Christopherson Boris or another x86 maintainer, can you ack this small patch? We would like to use sev_enabled as a static variable in KVM. Paolo > --- > arch/x86/include/asm/mem_encrypt.h | 1 - > arch/x86/mm/mem_encrypt.c | 12 +++++------- > arch/x86/mm/mem_encrypt_identity.c | 1 - > 3 files changed, 5 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h > index 31c4df123aa0..9c80c68d75b5 100644 > --- a/arch/x86/include/asm/mem_encrypt.h > +++ b/arch/x86/include/asm/mem_encrypt.h > @@ -20,7 +20,6 @@ > > extern u64 sme_me_mask; > extern u64 sev_status; > -extern bool sev_enabled; > > void sme_encrypt_execute(unsigned long encrypted_kernel_vaddr, > unsigned long decrypted_kernel_vaddr, > diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c > index 4b01f7dbaf30..be384d8d0543 100644 > --- a/arch/x86/mm/mem_encrypt.c > +++ b/arch/x86/mm/mem_encrypt.c > @@ -44,8 +44,6 @@ EXPORT_SYMBOL(sme_me_mask); > DEFINE_STATIC_KEY_FALSE(sev_enable_key); > EXPORT_SYMBOL_GPL(sev_enable_key); > > -bool sev_enabled __section(".data"); > - > /* Buffer used for early in-place encryption by BSP, no locking needed */ > static char sme_early_buffer[PAGE_SIZE] __initdata __aligned(PAGE_SIZE); > > @@ -373,15 +371,15 @@ int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size) > * up under SME the trampoline area cannot be encrypted, whereas under SEV > * the trampoline area must be encrypted. > */ > -bool sme_active(void) > -{ > - return sme_me_mask && !sev_enabled; > -} > - > bool sev_active(void) > { > return sev_status & MSR_AMD64_SEV_ENABLED; > } > + > +bool sme_active(void) > +{ > + return sme_me_mask && !sev_active(); > +} > EXPORT_SYMBOL_GPL(sev_active); > > /* Needs to be called from non-instrumentable code */ > diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c > index 6c5eb6f3f14f..0c2759b7f03a 100644 > --- a/arch/x86/mm/mem_encrypt_identity.c > +++ b/arch/x86/mm/mem_encrypt_identity.c > @@ -545,7 +545,6 @@ void __init sme_enable(struct boot_params *bp) > > /* SEV state cannot be controlled by a command line option */ > sme_me_mask = me_mask; > - sev_enabled = true; > physical_mask &= ~sme_me_mask; > return; > } >