[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/EFI: don't let the EDD disk counter wrap


  • To: Anandu Padinhare <Anandu.Padinhare@xxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 3 Dec 2026 09:30:32 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12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x>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 03 Dec 2026 08:42:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.