On Thu, 9 Jan 2025 at 17:32, Usama Arif <usamaarif642@xxxxxxxxx> wrote: > > > > On 09/01/2025 16:15, Ard Biesheuvel wrote: > > On Wed, 8 Jan 2025 at 23:00, Usama Arif <usamaarif642@xxxxxxxxx> 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@xxxxxxxxx/ > 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.