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 920C6AC0CA2 for ; Fri, 10 Jan 2025 07:34:56 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ikIdB6sdQzzVn+eTSYyb/h5EXaqxzWymyXvU5sFkac0=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240830; t=1736494496; v=1; x=1736753694; b=F7MLU0oDQ9f9wcGZRJmhxExNOdHRtTXyUJ6FEWhW8XQM54zgX/d4MeG7+LI7PeUW9OgmEqF7 Iylbf8dpCEstOdHcaBaHKVW2mqfHcnpj0B3Zs6t5ekNKZza2p5RPAaj8JgwlSm/lg8GoaEtRDml 7KtRs2ARH6jiFuJjOJW1x4PxyVveLY+7w210u98bvQgJrX2/POZBsJyxN6Ltmv6S9AgBOMCIXdP 1A2XEuAOnifc2FsLubc6bRXHKFvgzqcm7aVRKYAWd1K5cBmMEoNalh5MzT/uInLVi87+hSBa/OC /6e6/rgSj/gBBFBzAo+3iBKHADKPNK8eoRKKy1KYEBkeQ== X-Received: by 127.0.0.2 with SMTP id IUYLYY7687511x0Cf1f12Psd; Thu, 09 Jan 2025 23:34:54 -0800 X-Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by mx.groups.io with SMTP id smtpd.web11.13710.1736494494065456380 for ; Thu, 09 Jan 2025 23:34:54 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 77A1EA41A15 for ; Fri, 10 Jan 2025 07:33:04 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A23FDC4CEDF for ; Fri, 10 Jan 2025 07:34:52 +0000 (UTC) X-Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5401c52000dso1804494e87.3 for ; Thu, 09 Jan 2025 23:34:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXAYm9HEc0l4glp0TDiYs/I9USJ+hMQzOH8mbVzYUiLDS7y4yOb+imrqC27QrjDAyUzd5H99A==@edk2.groups.io X-Gm-Message-State: HQz2JYulIheiP041vHA96NOCx7686176AA= X-Google-Smtp-Source: AGHT+IHcf2xM9VvsYkjaloDENOtP+ZvDGKm/5QwUX3w3+EsHJCn4Dx75mqct7KEITe06bcj8EHmwCzJigOu+TQuR7FA= X-Received: by 2002:ac2:4e08:0:b0:540:2ff1:309d with SMTP id 2adb3069b0e04-542845c56cfmr3059582e87.34.1736494490953; Thu, 09 Jan 2025 23:34:50 -0800 (PST) MIME-Version: 1.0 References: <20250108215957.3437660-1-usamaarif642@gmail.com> <20250108215957.3437660-3-usamaarif642@gmail.com> In-Reply-To: From: "Ard Biesheuvel via groups.io" Date: Fri, 10 Jan 2025 08:32:08 +0100 X-Gmail-Original-Message-ID: X-Gm-Features: AbW1kvad1Ep7ZJNKHY5SzNw-aw7vA2PCxxRZNUDwL7taXhAPV5dXJQCNTI_QuUA Message-ID: Subject: Re: [edk2-devel] [RFC 2/2] efi/memattr: add efi_mem_attr_table as a reserved region in 820_table_firmware To: Usama Arif 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 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: Thu, 09 Jan 2025 23:34:54 -0800 Resent-From: ardb@kernel.org Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=F7MLU0oD; 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 Thu, 9 Jan 2025 at 17:32, Usama Arif wrote: > > > > On 09/01/2025 16:15, Ard Biesheuvel wrote: > > On Wed, 8 Jan 2025 at 23:00, Usama Arif wrote: > >> > >> When this area is not reserved, it comes up as usable in > >> /sys/firmware/memmap. This means that kexec, which uses that memmap > >> to find usable memory regions, can select the region where > >> efi_mem_attr_table is and overwrite it and relocate_kernel. > >> > >> Since the patch in [1] was merged, all boots after kexec > >> are producing the warning that it introduced. > >> > >> Having a fix in firmware can be difficult to get through. > > > > I don't follow. I don't think there is anything wrong with the > > firmware here. Could you elaborate? > > > > So the problem is, kexec sees this memory as System RAM, and decides > it can be used to place an image here. > > I guess the question is (and I actually don't know the answer here), > whose responsibility is it to mark this region as reserved so that > its not touched by anyone else. I would have thought it should be > firmware? > No, it is the OS. The firmware only reserves regions that are needed for its own correct operation at runtime. For informational tables such as this one, it is up to the OS whether it wants to reserve it and keep it in place, consume it and release the memory, or ignore it altogether. > Maybe its not the firmwares' job to mark it as reserved, but just pass > it to kernel and the kernel is supposed to make sure it gets reserved > in a proper way, even across kexecs. > Indeed. > I think in the end whoevers' responsibility it is, the easiest path forward > 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. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120978): https://edk2.groups.io/g/devel/message/120978 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] -=-=-=-=-=-=-=-=-=-=-=-