|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] x86/EFI: don't let the EDD disk counter wrap
On 03.12.2026 07:18, Anandu Padinhare wrote:
> efi_arch_edd() increments the u8 boot_edd_info_nr once per candidate
> disk, without bound. Disks past EDD_INFO_MAX are meant to be skipped by
> the "boot_edd_info_nr > EDD_INFO_MAX" checks in the device path
> handling, but with 256 or more disks the counter wraps to zero. For the
> 256th disk "info" and "params" then point at boot_edd_info[255], about
> 20KiB past the end of the array, while the checks pass, so its details
> are written there. With xen.efi that is currently the alternatives
> table, and Xen panics with "Unable to apply alternatives". Later disks
> overwrite the first entries. "edd=" can't avoid this, as it is ignored
> when booting via EFI.
>
> Saturate the counter at EDD_INFO_MAX + 1 instead.
>
> Fixes: 51f03ec421fb ("x86-64/EFI: construct EDD data from device path
> protocol information")
> Signed-off-by: Anandu Padinhare <Anandu.Padinhare@xxxxxxxxxxxxxx>
> ---
> Reproduced in QEMU/OVMF with 256 and 260 whole disks (NVMe namespaces):
> xen.efi panics; via GRUB/multiboot2 Xen boots, but Dom0 gets wrong EDD
> entries. With this patch both boot with the first 6 disks, and with 5,
> 15 and 255 disks Dom0's EDD data is unchanged.
>
> The only other use of the counter in the loop is the fake device number
> of MBR signatures, now 0x87 rather than 0x88 and up for the 8th and
> later disks. Neither matches an EDD entry, and Linux ignores it. If
> the old values should be kept, a separate disk counter can do that.
Why would that be? You can use the present counter, by ...
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -398,7 +398,9 @@ static void __init efi_arch_edd(void)
> params->bytes_per_sector = bio->Media->BlockSize;
> params->dpte_ptr = ~0;
> }
> - ++boot_edd_info_nr;
> + /* Don't wrap, or the checks below would stop skipping extra disks.
> */
> + if ( boot_edd_info_nr <= EDD_INFO_MAX )
> + ++boot_edd_info_nr;
... doing this differently. One possibility would be
if ( !++boot_edd_info_nr )
--boot_edd_info_nr;
That said, overall it may indeed be better to introduce a local variable,
and only store into boot_edd_info_nr at the end of the function. That'll
likely yield better generated code (even if in an __init function this
may not matter all this much).
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |