From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 337A1941B5E for ; Wed, 15 Jan 2025 18:53:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=SDzqZQD7n4luRzgyEwpHj+lSaZ4vvPPG0wybR20Moio=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:From:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240830; t=1736967189; v=1; x=1737226388; b=WxtOCYsVcJ24dVB2tn/XV2VAlBmKllx/QeKDfyiDgYNatDfzdOETaIQX9bvS67EggwWcFwrI e8TnxMCwGiVAMNdVeeJrp6fCNklmQh4cyqtOLOSJ7nqtpUTOFNz1ZDbwK1DbeUrom0OdWJHV+z2 urq6DnlXIfeM0h/0uRGoIo2sh3yLau0LBoFPGXB0wK3kdaTlXk6qG/SBw9n8U5QQEVyzv3vETst FQ3n1iMS/Dl4vvZEl9YykjyoApKMPR2C/2aVW5YPgWhxNw17g85m4RN1q7YWKLyUw7ncZrK2Eah WzLLHO+UgEcO/xDLJEFKLPYCKMtN0Urff2qtZwDuTDOoQ== X-Received: by 127.0.0.2 with SMTP id AiYAYY7687511xaLG1UqyBM2; Wed, 15 Jan 2025 10:53:08 -0800 X-Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.groups.io with SMTP id smtpd.web10.21991.1736524205529691102 for ; Fri, 10 Jan 2025 07:50:05 -0800 X-Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so1986079f8f.0 for ; Fri, 10 Jan 2025 07:50:05 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVCnSdNB23ddLmVrUzRWK053tWMWix5XuROl6pY4jD6UwEjRpKy7BmOp+8xMOP/2l43Z/wrgg==@edk2.groups.io X-Gm-Message-State: eMfWMDX1iWaVolb3jZN0mEQ9x7686176AA= X-Gm-Gg: ASbGncsgunYwr0NeR4QzkOnO4ZSx5igTKJS2FfvKadjLFziz8wAkoGJp30gC7OkT3IX +CckmMggQdvEKWycgHK+uT24+nTK8Rl7vQObPEH2b+8fxh+cVhtUGvxuqLP9Sg5HirkfitR/YS6 9VL/irjkdm4CwrUjlI7sFBd+YdzBovz6sXBivhEzsBb16x7+f+1mBIQSUaEO6YWhbiV5dy/ZFOS 6gsQOY6N1v/QUIKmznHYtwdb4MJ/rus27otzIjKk3PXXwewHJ4GKrWohNqbWRwaWZvQhrq89zQL UxnLxPfxQfRzSNeV4XcLRMtLSZ/AtRg+i1WaH10dpN4Sw0RGmw== X-Google-Smtp-Source: AGHT+IG99ba+3EjbnJDKEadpRExVV0uXfnt4rvpxoh7E9vujPX4RITwsVLvUeQ3NSOG9KobH9SAa/A== X-Received: by 2002:a5d:598e:0:b0:38a:8b56:f6c with SMTP id ffacd0b85a97d-38a8b56119emr6950772f8f.14.1736524203663; Fri, 10 Jan 2025 07:50:03 -0800 (PST) X-Received: from ?IPV6:2a02:6b67:d752:5f00:c46:86ac:45ea:7590? ([2a02:6b67:d752:5f00:c46:86ac:45ea:7590]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c1dc6sm4864460f8f.96.2025.01.10.07.50.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2025 07:50:03 -0800 (PST) Message-ID: Date: Fri, 10 Jan 2025 15:50:02 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [RFC 2/2] efi/memattr: add efi_mem_attr_table as a reserved region in 820_table_firmware From: "Usama Arif via groups.io" To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, devel@edk2.groups.io, kexec@lists.infradead.org, hannes@cmpxchg.org, dyoung@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, leitao@debian.org, gourry@gourry.net, kernel-team@meta.com References: <20250108215957.3437660-1-usamaarif642@gmail.com> <20250108215957.3437660-3-usamaarif642@gmail.com> In-Reply-To: Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 15 Jan 2025 10:52:53 -0800 Resent-From: usamaarif642@gmail.com Reply-To: devel@edk2.groups.io,usamaarif642@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=WxtOCYsV; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io On 10/01/2025 14:31, Usama Arif wrote: >=20 >=20 > On 10/01/2025 07:32, Ard Biesheuvel wrote: >> On Thu, 9 Jan 2025 at 17:32, Usama Arif wrote: >>> >>> >>> >>> On 09/01/2025 16:15, Ard Biesheuvel wrote: >=20 >>> I think in the end whoevers' responsibility it is, the easiest path for= ward >>> seems to be in kernel? (and not firmware or libstub) >>> >> >> Agreed. But as I pointed out in the other thread, the memory >> attributes table only augments the memory map with permission >> information, and can be disregarded, and given how badly we mangle the >> memory map on x86, maybe this is the right choice here. >> >>>> >>>>> The next ideal place would be in libstub. However, it looks like >>>>> InstallMemoryAttributesTable [2] is not available as a boot service >>>>> call option [3], [4], and install_configuration_table does not >>>>> seem to work as a valid substitute. >>>>> >>>> >>>> To do what, exactly? >>>> >>> >>> To change the memory type from System RAM to either reserved or >>> something more appropriate, i.e. any type that is not touched by >>> kexec or any other userspace. >>> >>> Basically the example code I attached at the end of the cover letter in >>> https://lore.kernel.org/all/20250108215957.3437660-1-usamaarif642@gmail= .com/ >>> It could be EFI_ACPI_RECLAIM_MEMORY or EFI_RESERVED_TYPE, both of which= aren't >>> touched by kexec. >>> >> >> This is a kexec problem (on x86 only) so let's fix it there. >=20 >=20 > I don't believe we can accurately tell if we are booting from a cold boot= or kexec. > There is bootloader_type available for x86, but not sure if we should rel= y on > that. I think a way forward would be to move it behind a Kconfig option, = something like > below, which defaults to n for x86. Anyone who needs it can enable it. Wh= at do you think? >=20 Or we can do something like below? diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.= c index d131781e2d7b..4add694b18d0 100644 --- a/drivers/firmware/efi/memattr.c +++ b/drivers/firmware/efi/memattr.c @@ -24,6 +24,15 @@ int __init efi_memattr_init(void) efi_memory_attributes_table_t *tbl; unsigned long size; =20 +#ifdef CONFIG_X86_64 + /* + * On x86_64, do not initialize memory attributes table + * if booting from kexec + */ + if (bootloader_type >> 4 =3D=3D 0xd) + return 0; +#endif + if (efi_mem_attr_table =3D=3D EFI_INVALID_TABLE_ADDR) return 0; -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#121014): https://edk2.groups.io/g/devel/message/121014 Mute This Topic: https://groups.io/mt/110518541/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-