Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp888380pxb; Wed, 27 Oct 2021 14:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9DULQ7f1J3dOCr3EJ9X2irbtpsKWzKeyRo7hgfnUBlazIunjjjU7kXrx6sRBoX99Fe/2I X-Received: by 2002:a05:6402:268a:: with SMTP id w10mr449947edd.351.1635370256007; Wed, 27 Oct 2021 14:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370256; cv=none; d=google.com; s=arc-20160816; b=Fw2ZK7Cy6ouL05VgKhlPUSrJoygd8frzFecD0vfbfdvGZVML/IE/Tae39gqXzN7dEJ /bBoYXhSjI1A9m+VEUPGdx5HjKaSeF3JmVNz5B8m65qSG/HciVNweatvLpjU6HkyJTXT 6a9Bf7W8mI+HM1dFrYzDe8Fyw+ztPmMvA5VntTr3cLnRiyzzIukgHA3+xH6j4+qn4JwD o4KSQLe96VDQKMRzCfjl6K67r7IWDaE6LSJ922RK5hQm60264AP34hRluSQQHyGJKiIZ fHBgs7YvbFrS/Yc97yg9OFsLS5AxY/iyB5be9+m8HR/QMbLrryefteMSS6Z8Qexdikk7 XweA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=d/hO+irUkRPAzOGdj54F3ss4yD7w6tan9uDNj2qHGIU=; b=qLf1pXqKjaFJBC6/Hxx1zKYle8IdakdtvAPlbBkcJAq4aToY3O4047jMZc2nq195GI 4cDrPtH9GLC88EzCT+eAjVnbtNTIp/vLz07Z3RN1MzkpoUo8kxYGzNNUGpgXq8pBe0vE GUSlLN8njeyOfbC/KS4jxYp9grW0oU164oxLhlq/wVnRM/R76WWzFte22vvbXrhcNSaZ boRxmxAi26YACMA4BrW6xzVrdaywLInRkFv+edu+bwLqTgdazkCZNdf3gRZDtMMATX66 iU1H2qB99q7KHSz80KEgR6vq7rWK5n2AmyDff7hwfGjK5/DfZ/xZKakjYhnGtB2OOsiN wtvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LnZpW/y7"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z19si1750563edd.610.2021.10.27.14.30.32; Wed, 27 Oct 2021 14:30:55 -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=@kernel.org header.s=k20201202 header.b="LnZpW/y7"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242701AbhJ0PRY (ORCPT + 97 others); Wed, 27 Oct 2021 11:17:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:35280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242685AbhJ0PRN (ORCPT ); Wed, 27 Oct 2021 11:17:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BCA2760FBF; Wed, 27 Oct 2021 15:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635347687; bh=d/hO+irUkRPAzOGdj54F3ss4yD7w6tan9uDNj2qHGIU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LnZpW/y7ZHNV2FSyWuS7JHO3QFfij5w3RLDLVKOON6tOCd+MufZc0b5YfFwuM1wqc BPKnxbmuopGdep3xmltXh/wM80r6X5rMipCh2dA+RUB9BswkVAREurb8ulMtNpbZCo 1s7QTdjiNabd2gKYl7KNwwZHJF6smwDEBNCBg8TSbJMjK1oxwQCvPyxoxVZVrgQihl IPVzlcD9hyv7MxpCllAxpD7m/gCAQrq6eGdkQ6V9tQ0YNL3+KnFMpjJtZ/VsT23tIS +cOTOzMnXI4OUIDIygDLmAAgCHmXFgYW4CXqvFQbDub/DgUxNkE5fgeFtLynpowwGJ x1Ac2xpTBlvcw== Received: by mail-oi1-f172.google.com with SMTP id q124so3881744oig.3; Wed, 27 Oct 2021 08:14:47 -0700 (PDT) X-Gm-Message-State: AOAM531knRuUH23akYraNx7d5zD3nII8z4+SpMrk1zST3AbsurZKIC5J 0peZJQFb414LVcA2+J3fj4Bje0YM9PkFakJ14mE= X-Received: by 2002:a05:6808:1805:: with SMTP id bh5mr3986936oib.47.1635347687082; Wed, 27 Oct 2021 08:14:47 -0700 (PDT) MIME-Version: 1.0 References: <8afff0c64feb6b96db36112cb865243f4ae280ca.1634922135.git.thomas.lendacky@amd.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 27 Oct 2021 17:14:35 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] x86/sme: Explicitly map new EFI memmap table as encrypted To: Tom Lendacky Cc: linux-efi , platform-driver-x86@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , Matt Fleming , "# 3.4.x" , Linux Kernel Mailing List , X86 ML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Oct 2021 at 17:11, Tom Lendacky wrote: > > On 10/22/21 12:02 PM, Tom Lendacky wrote: > > Reserving memory using efi_mem_reserve() calls into the x86 > > efi_arch_mem_reserve() function. This function will insert a new EFI > > memory descriptor into the EFI memory map representing the area of > > memory to be reserved and marking it as EFI runtime memory. > > > > As part of adding this new entry, a new EFI memory map is allocated and > > mapped. The mapping is where a problem can occur. This new EFI memory map > > is mapped using early_memremap(). If the allocated memory comes from an > > area that is marked as EFI_BOOT_SERVICES_DATA memory in the current EFI > > memory map, then it will be mapped unencrypted (see memremap_is_efi_data() > > and the call to efi_mem_type()). > > > > However, during replacement of the old EFI memory map with the new EFI > > memory map, efi_mem_type() is disabled, resulting in the new EFI memory > > map always being mapped encrypted in efi.memmap. This will cause a kernel > > crash later in the boot. > > > > Since it is known that the new EFI memory map will always be mapped > > encrypted when efi_memmap_install() is called, explicitly map the new EFI > > memory map as encrypted (using early_memremap_prot()) when inserting the > > new memory map entry. > > > > Cc: # 4.14.x > > Fixes: 8f716c9b5feb ("x86/mm: Add support to access boot related data in the clear") > > Acked-by: Ard Biesheuvel > > Signed-off-by: Tom Lendacky > > Ard, are you going to take this through the EFI tree or does it need to go > through another tree? > I could take it, but since it will ultimately go through -tip anyway, perhaps better if they just take it directly? (This will change after the next -rc1 though) Boris?