Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4492663rwb; Mon, 21 Nov 2022 08:12:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hEWU5Md3fFM/MT6G+lnaHfQstKuQLL0HSiNg2ytL8KD7swG1uH7pWgPflrc6mDpR/eKlI X-Received: by 2002:a17:907:6f05:b0:78d:6937:8e2 with SMTP id sy5-20020a1709076f0500b0078d693708e2mr10959117ejc.0.1669047139988; Mon, 21 Nov 2022 08:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669047139; cv=none; d=google.com; s=arc-20160816; b=Qb9BdLRXFjE8U9KkiJEeCC9ZSE0lpEKnZaTEA5wOo/AQEMQJpTWvmpaCfIT25tgFO2 1xdlB7CTsTE8JpHFPda+eFlfqvc2d9bjDGcSWDNXzYrJa83NMWe3IIw0YSA68RLuPBaD MrFH/nfHd5CP21P0muHC1xZLHOVhsR3+enSAv8/+9gJYqgnDoYK9/VjRe+O+wSYV6YGm 2TNbDST0nX+Nen2veh4wncrmsjQ7jnUQEqo0/A1MdGCbTgpkFcEq4pRMp7PgpAHtJI8O OF/yTK1upJEunq12oAN7cCm1E/G89n0JKZmgVFe8tyc99nRfaWbDYl6cZdzIwobS/hpl TkuQ== 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=nVucUSR5GH+aVD4prFamu5Vccjb3OajaJg/HmkV7Mj8=; b=pZKBIRLMSeRob2NYfQnxzRTdHRiw0HB/VQLqPgw+3lYCNy2erhxN4N+JhrMY+AW7HV /YrFYq2YmK4FGXERf6h2PVSGNw4yaazNPIL+Wa4/pguk91dBPjtUlg+su+3b3LRI5lUv 72DP7VHRswjM+Q6tgEZVCH17sNRUU/g3Arc4WHrbZjU3ITjXpEp6kkWV9auxq1647NhZ R2r0U71/QkJ+VznjSLBbKz+2DR4ipw4ieNdRKke1Kzi9m++koeXCoRHh6Te53MleqVRf IR3kwYtOrvR/XTSo7W6BmTZcrL4+GrQb44o1iALCwHIo3CIWNrqnjazKwmL1hniKf4gQ 0WEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=KbhkHJom; 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 en17-20020a056402529100b0045bfaaab6d1si8973125edb.48.2022.11.21.08.11.42; Mon, 21 Nov 2022 08:12:19 -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=KbhkHJom; 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 S230185AbiKUOsR (ORCPT + 91 others); Mon, 21 Nov 2022 09:48:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbiKUOq6 (ORCPT ); Mon, 21 Nov 2022 09:46:58 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D606D2884; Mon, 21 Nov 2022 06:41:09 -0800 (PST) Received: from zn.tnic (p200300ea9733e725329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e725: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 0AD131EC071C; Mon, 21 Nov 2022 15:40:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1669041620; 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=nVucUSR5GH+aVD4prFamu5Vccjb3OajaJg/HmkV7Mj8=; b=KbhkHJom/jPEXkOOB0ksRGlXRvaPN64pFM19VgqxWWS/I8T8+Wvwgb65IlH9gx86/7jqiy JMeYBafODuLLjQmbvBN9VY+Fm4p50pWQfE1HtbiXqRbjOj7xStksIebcL2vX3AjMPskz1K rnXFY9bEkIFAJlXDFQVDct0oZnFWDbU= Date: Mon, 21 Nov 2022 15:40:19 +0100 From: Borislav Petkov To: Michael Kelley Cc: hpa@zytor.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, 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@microsoft.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, dan.j.williams@intel.com, 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1668624097-14884-6-git-send-email-mikelley@microsoft.com> 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 Wed, Nov 16, 2022 at 10:41:28AM -0800, Michael Kelley wrote: > Current code in sme_postprocess_startup() decrypts the bss_decrypted > section when sme_me_mask is non-zero. But code in > mem_encrypt_free_decrytped_mem() re-encrypts the unused portion based ^^ letters flipped. > @@ -513,10 +513,14 @@ void __init mem_encrypt_free_decrypted_mem(void) > npages = (vaddr_end - vaddr) >> PAGE_SHIFT; > > /* > - * The unused memory range was mapped decrypted, change the encryption > - * attribute from decrypted to encrypted before freeing it. > + * If the unused memory range was mapped decrypted, change the encryption > + * attribute from decrypted to encrypted before freeing it. Base the > + * re-encryption on the same condition used for the decryption in > + * sme_postprocess_startup(). Higher level abstractions, such as > + * CC_ATTR_MEM_ENCRYPT, aren't necessarily equivalent in a Hyper-V VM > + * using vTOM, where sme_me_mask is always zero. Good, an example why one needs to pay attention here. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette