Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1403231pxv; Fri, 16 Jul 2021 08:36:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPwuZH2TbDCE+4hBwGGmpyfAIUqOaMDDARF0D4J6G+5xmETddapnhFU8hhoRx2VEwOLedj X-Received: by 2002:a17:906:a98e:: with SMTP id jr14mr12475720ejb.450.1626449810041; Fri, 16 Jul 2021 08:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626449810; cv=none; d=google.com; s=arc-20160816; b=oZ3D6WcWzmO9g+LMgrj2HztS+55pl4e4f/d/n6WBu4sqKL9wqmbmRfyqxSRUtGu/4E oORlH4KrV3BfqoBUQpjOsDBf94YCOxIji8mIkh4Moh2H5485EnKA3B7mSDSapah887Is EOHGLFkrfOmCWme2ckeV4PD+C5oMfOYzhnmxXOJM5aKE1csVmRphHLUxx4+b67jKf7BF gtVxAEoKSVfvllVjs47wYYfmKsCTOqcV0aKoIVkt3cAbXS11VHoDeZewgLQB04eJKR1K DBztSVFFzgigH7X4IGG7WyWkOF43kJ3G+LFYoqajM3ovVwvU3cIDKugRQuIUgKpdzpZ3 nnCQ== 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=0cTnZy2I4CZKY1bHPxJLKssBACveTIPG9X+4FMx1/uQ=; b=tK7Q2ZfRIxVp7Jx59jOJ71iNnWZkCVYy3i9uxsNSTiIyxmSx4OR3dvhC52Dd9+SfRd O5V9FCchCRvKY+UjJEkxd3y2SqycglN135aabek9vQ+eNyf8ykRLjl2clMyQ0qPiZ4FS sOHfoQFZgmAPERyP32btmShUUEAU/rE7HP5vUD+oEIaGdAsFAxfT44MbW6/AvF2or8Sj 3uNQkmFbAkSAh4c9UE67plZ/WRfb8pgBWhmc/gYE9gOju4ml7YIMQJr8JEP0AavWrRSr 5UKGmoGuRLWuJeJoBHiETiBAOP2EJIqT15nRT+I8S1yB7YxzxLGUiIj4GsvrhlBRzkOk 0aJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=afSs59IN; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 m18si12281777eds.403.2021.07.16.08.36.10; Fri, 16 Jul 2021 08:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=afSs59IN; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S240798AbhGPPiG (ORCPT + 99 others); Fri, 16 Jul 2021 11:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241008AbhGPPiG (ORCPT ); Fri, 16 Jul 2021 11:38:06 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228D0C061762 for ; Fri, 16 Jul 2021 08:35:11 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id g4-20020a17090ace84b029017554809f35so8981791pju.5 for ; Fri, 16 Jul 2021 08:35:11 -0700 (PDT) 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=0cTnZy2I4CZKY1bHPxJLKssBACveTIPG9X+4FMx1/uQ=; b=afSs59INL/oaaVSpQPeRtiIcJrpZwqHHpaDKcKMQGA6aWrOaBsFQgpUgROlc1OHvsr R8+DUt0nxbzW92N5jyf1GQnF/hr52cuxKwcH10Pr8I7RED3k1ryiX7DXdXuaA7APN6m4 XWPOS5SwXn7SL7HD5a2j5vD6dOKAEQY9m1vnGiABnDA5fHtdH2zr8Y5fdOgg0bb0iuku DojBvVx1otGchwtODy/S4//wZ2V3ziB+XpzqgAvJEq/hlGIebWzzQh0E5JJgub29thOP YmvVF0HsEbccSVc12R6sAKoXRNAtlV+kh3t3D5Xb8MzS29UsDlX4R1djNaCtt7Rgc/uW jh4Q== 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=0cTnZy2I4CZKY1bHPxJLKssBACveTIPG9X+4FMx1/uQ=; b=NQ/N7fs+T/unVJc0txsoYZY30oM8nRMJpruyGnhwGBpUCi9u5093nHo1yxL/JOkWT7 YP2376qzZJnfPld7yDYlPwAh2iZWpdwX0i7YF6OviF1pVkG9heYMI65MibMRp68ZHMJC lvXhmJvG0sVm2Aqx2XuEAlk9ERXcOxJH6N38mkzgJu/zlIBka7tj/b6kAp9NvLt02085 bim5D/YHe8AaoIJ/KIrB83FokrFFTfM/c5n3taDNgy05kPaBgnfnuLx6cNpPQKRLNbu6 qWCoF2F1r7i0RWHa+fMQgqXIdmxqL/nza+YMKhudFQ6EBGmjxjEQvo2cRPvohH7KhJJl /tEQ== X-Gm-Message-State: AOAM533rAatSuPguQ1jRa0lEzLVxUZJ1wAKkH8CWqG28KDRTtTUf+3Qw PoBfoPnoyUbePU3nTE2wAkBv9A== X-Received: by 2002:a17:902:ed82:b029:ef:48c8:128e with SMTP id e2-20020a170902ed82b02900ef48c8128emr8350696plj.72.1626449710421; Fri, 16 Jul 2021 08:35:10 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j21sm8548916pjz.26.2021.07.16.08.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 08:35:09 -0700 (PDT) Date: Fri, 16 Jul 2021 15:35:05 +0000 From: Sean Christopherson To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part2 RFC v4 15/40] crypto: ccp: Handle the legacy TMR allocation when SNP is enabled Message-ID: References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-16-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Jul 16, 2021, Brijesh Singh wrote: > > On 7/15/21 6:48 PM, Sean Christopherson wrote: > > On Wed, Jul 07, 2021, Brijesh Singh wrote: > >> @@ -1204,16 +1322,6 @@ void sev_pci_init(void) > >> sev_update_firmware(sev->dev) == 0) > >> sev_get_api_version(); > >> > >> - /* Obtain the TMR memory area for SEV-ES use */ > >> - tmr_page = alloc_pages(GFP_KERNEL, get_order(SEV_ES_TMR_SIZE)); > >> - if (tmr_page) { > >> - sev_es_tmr = page_address(tmr_page); > >> - } else { > >> - sev_es_tmr = NULL; > >> - dev_warn(sev->dev, > >> - "SEV: TMR allocation failed, SEV-ES support unavailable\n"); > >> - } > >> - > >> /* > >> * If boot CPU supports the SNP, then first attempt to initialize > >> * the SNP firmware. > >> @@ -1229,6 +1337,16 @@ void sev_pci_init(void) > >> } > >> } > >> > >> + /* Obtain the TMR memory area for SEV-ES use */ > >> + tmr_page = __snp_alloc_firmware_pages(GFP_KERNEL, get_order(sev_es_tmr_size), false); > >> + if (tmr_page) { > >> + sev_es_tmr = page_address(tmr_page); > >> + } else { > >> + sev_es_tmr = NULL; > >> + dev_warn(sev->dev, > >> + "SEV: TMR allocation failed, SEV-ES support unavailable\n"); > >> + } > > I think your patch ordering got a bit wonky. AFAICT, the chunk that added > > sev_snp_init() and friends in the previous patch 14 should have landed above > > the TMR allocation, i.e. the code movement here should be unnecessary. > > I was debating about it whether to include all the SNP supports in one > patch or divide it up. If I had included all legacy support new > requirement in the same patch which adds the SNP then it will be a big > patch. I had feeling that others may ask me to split it. It wasn't comment on the patch organization, rather that the code added in patch 14 appears to have landed in the wrong location within the code. The above diff shows that the TMR allocation is being moved around the SNP initialization code that was added in patch 14 (the immediately prior patch). Presumably the required order doesn't magically change just because the TMR is now being allocated as a 2mb blob, so either the code movement is unnecessary churn or the original location was wrong. In either case, landing the SNP initialization code above the TMR allocation in patch 14 would eliminate the above code movement.