Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14669134rwb; Mon, 28 Nov 2022 03:52:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf7mXAebwFOlWe+5QHHZWv0jHw1UD/KT1oIxr7DCKdJk+nHCBZ43e3JPggPPc0n2Jh0VOJRb X-Received: by 2002:a05:6402:449b:b0:459:2b41:3922 with SMTP id er27-20020a056402449b00b004592b413922mr39248580edb.160.1669636358887; Mon, 28 Nov 2022 03:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669636358; cv=none; d=google.com; s=arc-20160816; b=EBwyo+bpEEn1/I5eIg1ZddBm21fuAuN18ooDe8i+iRUl6Sa/WoLrMdu18rqVSEar9E zIz1y8BMlNSDM3M1QUSNntxOmT+M9AMDEoiS/+O3/ozWnPjDU15VUJbRuwRBoXycrwbH wVwIXTwX3KlYXSrz7cT1RN+NvzhEof/uybD5n3755RxsDqunb0DpMd37rzFLxQfMHL9G WF2mERmrQisuakr3oTfXVAGkzA3Z+YD7VxdCJJvUo4WnEWeygvjp4zMMrYcXw93ebF6d tO+CdA4XuK3s3yhnj2dsmKkDkTRhHzdHtClwlC8rhhB5T4DgbH1Raw+x64b8er4CiSDl tXvg== 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=ZCCj7bcQc75acbwO7FOWk4dJlCrWMoBIyYNAusQQi2U=; b=urMnP2fUm6Qr+e7ULI3/b6rzgO/6ARNSoltfFu8kgtkFCYV0NM+pgvG0dMWrCpri6a z9xxD88Ywpv1lA93o634TDlBq6cmFn6CgD7ROh1GTlT9X0aHi73Ggov0zyIDaYzEVTXS w/u2GW23KFTETU7JUSsOB8texijdS2kyBYiyPl6V97RRr7TvdvypfxvkWf/u7IMS/KbY UH0yUc3fiTCREcuov6N9jRM0VzERSMYn3KdocOC7WqjMm9nq0iM+thHlbH1Yk1bXZJtl zb7Wxm5oR4RCVUXFUeabA+bABzppWrjC94KlXM5UPlGpnCs4N6rjPK50x4zlHcJLL95f EYFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=oAEzJbYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xe14-20020a170907318e00b0078d4b2754b5si10286959ejb.332.2022.11.28.03.52.18; Mon, 28 Nov 2022 03:52:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=oAEzJbYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbiK1Kux (ORCPT + 84 others); Mon, 28 Nov 2022 05:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbiK1Kuv (ORCPT ); Mon, 28 Nov 2022 05:50:51 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BF0BF9; Mon, 28 Nov 2022 02:50:50 -0800 (PST) Received: from zn.tnic (p200300ea9733e719329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e719:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4BBF71EC059E; Mon, 28 Nov 2022 11:50:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1669632649; 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:in-reply-to:in-reply-to: references:references; bh=ZCCj7bcQc75acbwO7FOWk4dJlCrWMoBIyYNAusQQi2U=; b=oAEzJbYg5od8O3kDuXXte3PxpqRhYKSbKUONg0mq2ROUkTDdzrKVonBJnEQ5T41YGSsGOe rIo1R8sUPfBlavzVlofbxLwQPbc7E4cGRNEl8iN2+/Tl/4mcYIfR+6Nj2qS2ynm1/KS7Hm w4HnHBDdjRCvLu/emxxA1vwYAVRcccA= Date: Mon, 28 Nov 2022 11:50:45 +0100 From: Borislav Petkov To: "Michael Kelley (LINUX)" Cc: Sathyanarayanan Kuppuswamy , "hpa@zytor.com" , KY Srinivasan , Haiyang Zhang , "wei.liu@kernel.org" , Dexuan Cui , "luto@kernel.org" , "peterz@infradead.org" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "lpieralisi@kernel.org" , "robh@kernel.org" , "kw@linux.com" , "bhelgaas@google.com" , "arnd@arndb.de" , "hch@infradead.org" , "m.szyprowski@samsung.com" , "robin.murphy@arm.com" , "thomas.lendacky@amd.com" , "brijesh.singh@amd.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "dave.hansen@linux.intel.com" , Tianyu Lan , "kirill.shutemov@linux.intel.com" , "ak@linux.intel.com" , "isaku.yamahata@intel.com" , "Williams, Dan J" , "jane.chu@oracle.com" , "seanjc@google.com" , "tony.luck@intel.com" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-arch@vger.kernel.org" , "iommu@lists.linux.dev" Subject: Re: [Patch v3 05/14] x86/mm: Handle decryption/re-encryption of bss_decrypted consistently Message-ID: References: <1668624097-14884-1-git-send-email-mikelley@microsoft.com> <1668624097-14884-6-git-send-email-mikelley@microsoft.com> <01d7c7cc-bd4e-ee9b-f5b2-73ea367e602f@linux.intel.com> <6b5129cf-6986-bbb1-7e60-37849fc383fc@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 22, 2022 at 05:59:04PM +0000, Michael Kelley (LINUX) wrote: > Right. But here's my point: With current code and an image built with > CONFIG_AMD_MEM_ENCRYPT=y and running as a TDX guest, > sme_postprocess_startup() will not decrypt the bss_decrypted section. > Then later mem_encrypt_free_decrypted_mem() will run, see that > CC_ATTR_MEM_ENCRYPT is true, and try to re-encrypt the memory. > In other words, a TDX guest would break in the same way as a Hyper-V > vTOM guest would break. This patch fixes the problem for both cases. I guess making the check more concrete by checking sme_me_mask directly along with a comment makes sense. We need to be very careful here not to fragment the code too much for all the different guest types. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette