diff -Nru ipxe-1.0.0+git-20131111.c3d1e78/debian/changelog ipxe-1.0.0+git-20131111.c3d1e78/debian/changelog --- ipxe-1.0.0+git-20131111.c3d1e78/debian/changelog 2014-01-06 09:55:28.000000000 +0000 +++ ipxe-1.0.0+git-20131111.c3d1e78/debian/changelog 2015-01-14 16:27:17.000000000 +0000 @@ -1,3 +1,10 @@ +ipxe (1.0.0+git-20131111.c3d1e78-2ubuntu1.1) trusty-proposed; urgency=medium + + * Cherrypick 4 patches from upstream to fix specifying boot order. + (LP: #1409057) + + -- Serge Hallyn Wed, 14 Jan 2015 10:22:29 -0600 + ipxe (1.0.0+git-20131111.c3d1e78-2ubuntu1) trusty; urgency=low * Merge from Debian unstable. Remaining changes: diff -Nru ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/01-enable-infrastructure-to-specify-an-autoboot ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/01-enable-infrastructure-to-specify-an-autoboot --- ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/01-enable-infrastructure-to-specify-an-autoboot 1970-01-01 00:00:00.000000000 +0000 +++ ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/01-enable-infrastructure-to-specify-an-autoboot 2015-01-14 15:19:02.000000000 +0000 @@ -0,0 +1,124 @@ +commit 123bae9d939235a62e67d0cbfc66f3277bd81844 +Author: Alex Williamson +Date: Tue Feb 25 16:00:23 2014 -0700 + + [autoboot] Enable infrastructure to specify an autoboot device location + + iPXE will currently attempt to boot from every network device for + which it has a driver. Where a system has more than one network + device supported by iPXE, this renders BIOS IPL lists ineffective. + + Allow an autoboot device location to be specified. If such a location + is specified, then only devices matching that location will be used as + part of the automatic boot sequence. If no such location is + specified, then all devices will be used. + + Note that this does not affect the "autoboot" command, which will + continue to use all devices. + + Signed-off-by: Alex Williamson + Modified-by: Michael Brown + Signed-off-by: Michael Brown + +diff --git a/src/include/usr/autoboot.h b/src/include/usr/autoboot.h +index cfa4c41..f562b2b 100644 +--- a/src/include/usr/autoboot.h ++++ b/src/include/usr/autoboot.h +@@ -10,6 +10,7 @@ + FILE_LICENCE ( GPL2_OR_LATER ); + + #include ++#include + struct net_device; + struct uri; + struct settings; +@@ -25,12 +26,13 @@ enum uriboot_flags { + URIBOOT_NO_SAN_BOOT | \ + URIBOOT_NO_SAN_UNHOOK ) + ++extern struct device_description autoboot_device; ++ + extern int uriboot ( struct uri *filename, struct uri *root_path, int drive, + unsigned int flags ); + extern struct uri * + fetch_next_server_and_filename ( struct settings *settings ); + extern int netboot ( struct net_device *netdev ); +-extern int autoboot ( void ); + extern void ipxe ( struct net_device *netdev ); + + extern int pxe_menu_boot ( struct net_device *netdev ); +diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c +index 3a5fb04..c9012f2 100644 +--- a/src/usr/autoboot.c ++++ b/src/usr/autoboot.c +@@ -49,6 +49,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); + * + */ + ++/** Device location of preferred autoboot device */ ++struct device_description autoboot_device; ++ + /* Disambiguate the various error causes */ + #define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT ) + #define EINFO_ENOENT_BOOT \ +@@ -74,15 +77,6 @@ __weak int pxe_menu_boot ( struct net_device *netdev __unused ) { + } + + /** +- * Identify the boot network device +- * +- * @ret netdev Boot network device +- */ +-static struct net_device * find_boot_netdev ( void ) { +- return NULL; +-} +- +-/** + * Parse next-server and filename into a URI + * + * @v next_server Next-server address +@@ -428,21 +422,36 @@ int netboot ( struct net_device *netdev ) { + } + + /** ++ * Test if network device matches the autoboot device location ++ * ++ * @v netdev Network device ++ * @ret is_autoboot Network device matches the autoboot device location ++ */ ++static int is_autoboot_device ( struct net_device *netdev ) { ++ ++ return ( ( netdev->dev->desc.bus_type == autoboot_device.bus_type ) && ++ ( netdev->dev->desc.location == autoboot_device.location ) ); ++} ++ ++/** + * Boot the system + */ +-int autoboot ( void ) { +- struct net_device *boot_netdev; ++static int autoboot ( void ) { + struct net_device *netdev; + int rc = -ENODEV; + +- /* If we have an identifable boot device, try that first */ +- if ( ( boot_netdev = find_boot_netdev() ) ) +- rc = netboot ( boot_netdev ); +- +- /* If that fails, try booting from any of the other devices */ ++ /* Try booting from each network device. If we have a ++ * specified autoboot device location, then use only devices ++ * matching that location. ++ */ + for_each_netdev ( netdev ) { +- if ( netdev == boot_netdev ) ++ ++ /* Skip any non-matching devices, if applicable */ ++ if ( autoboot_device.bus_type && ++ ( ! is_autoboot_device ( netdev ) ) ) + continue; ++ ++ /* Attempt booting from this device */ + rc = netboot ( netdev ); + } + diff -Nru ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/02-allow-prefix-to-specify-a-pci-autoboot ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/02-allow-prefix-to-specify-a-pci-autoboot --- ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/02-allow-prefix-to-specify-a-pci-autoboot 1970-01-01 00:00:00.000000000 +0000 +++ ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/02-allow-prefix-to-specify-a-pci-autoboot 2015-01-14 15:21:29.000000000 +0000 @@ -0,0 +1,60 @@ +commit 90fc273b2b099df4a2c2ca06e1eaa7508e9734be +Author: Alex Williamson +Date: Tue Feb 25 16:00:39 2014 -0700 + + [prefix] Allow prefix to specify a PCI autoboot device location + + Signed-off-by: Alex Williamson + Modified-by: Michael Brown + Signed-off-by: Michael Brown + +diff --git a/src/arch/i386/core/pci_autoboot.c b/src/arch/i386/core/pci_autoboot.c +new file mode 100644 +index 0000000..bbb4027 +--- /dev/null ++++ b/src/arch/i386/core/pci_autoboot.c +@@ -0,0 +1,44 @@ ++/* ++ * Copyright (C) 2014 Red Hat Inc. ++ * Alex Williamson ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of the ++ * License, or any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ++ * 02110-1301, USA. ++ */ ++ ++FILE_LICENCE ( GPL2_OR_LATER ); ++ ++#include ++#include ++#include ++#include ++#include ++ ++uint16_t __bss16 ( autoboot_busdevfn ); ++#define autoboot_busdevfn __use_data16 ( autoboot_busdevfn ) ++ ++/** ++ * Initialise PCI autoboot device ++ */ ++static void pci_autoboot_init ( void ) { ++ ++ autoboot_device.bus_type = BUS_TYPE_PCI; ++ autoboot_device.location = autoboot_busdevfn; ++} ++ ++/** PCI autoboot device initialisation function */ ++struct init_fn pci_autoboot_init_fn __init_fn ( INIT_NORMAL ) = { ++ .initialise = pci_autoboot_init, ++}; diff -Nru ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/03-store-boot-bus-dev-fn-address-as-autoboot-device-location ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/03-store-boot-bus-dev-fn-address-as-autoboot-device-location --- ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/03-store-boot-bus-dev-fn-address-as-autoboot-device-location 1970-01-01 00:00:00.000000000 +0000 +++ ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/03-store-boot-bus-dev-fn-address-as-autoboot-device-location 2015-01-14 15:23:34.000000000 +0000 @@ -0,0 +1,44 @@ +commit c429bf0aa2428e6d12143285b29cbaf6a82f8d84 +Author: Alex Williamson +Date: Tue Feb 25 16:00:44 2014 -0700 + + [romprefix] Store boot bus:dev.fn address as autoboot device location + + Per the BIOS Boot Specification, the initialization phase of the ROM + is called with the PFA (PCI Function Address) in the %ax register. + The intention is that the ROM code will store that device address + somewhere and use it for booting from that device when the Boot Entry + Vector (BEV) is called. iPXE does store the PFA, but doesn't use it + to select the boot network device. This renders BIOS IPL lists fairly + ineffective. + + Fix by using the BBS-specified bus:dev.fn address as the autoboot + device location. + + Signed-off-by: Alex Williamson + Modified-by: Michael Brown + Signed-off-by: Michael Brown + +diff --git a/src/arch/i386/prefix/romprefix.S b/src/arch/i386/prefix/romprefix.S +index e061932..d606006 100644 +--- a/src/arch/i386/prefix/romprefix.S ++++ b/src/arch/i386/prefix/romprefix.S +@@ -738,7 +738,17 @@ exec: /* Set %ds = %cs */ + pushw $1f + lret + .section ".text16", "awx", @progbits +-1: /* Call main() */ ++1: ++ /* Retrieve PCI bus:dev.fn */ ++ movw init_pci_busdevfn, %cx ++ ++ /* Set up %ds for access to .data16 */ ++ movw %bx, %ds ++ ++ /* Store PCI bus:dev.fn */ ++ movw %cx, autoboot_busdevfn ++ ++ /* Call main() */ + pushl $main + pushw %cs + call prot_call diff -Nru ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/04-ignore-pci-autoboot-device-location-if-set-to-00 ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/04-ignore-pci-autoboot-device-location-if-set-to-00 --- ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/04-ignore-pci-autoboot-device-location-if-set-to-00 1970-01-01 00:00:00.000000000 +0000 +++ ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/bootorder/04-ignore-pci-autoboot-device-location-if-set-to-00 2015-01-14 15:12:30.000000000 +0000 @@ -0,0 +1,35 @@ +commit ff1e7fc72b138fe66de1452a311b7e871f33e201 +Author: Michael Brown +Date: Mon Mar 3 16:23:41 2014 +0000 + + [prefix] Ignore PCI autoboot device location if set to 00:00.0 + + qemu can load an option ROM which is not associated with a particular + PCI device using the "-option-rom" syntax. Under these circumstances, + we should ignore the PCI bus:dev.fn address that we expect to find in + %ax on entry to the initialisation vector. + + Fix by using the PCI bus:dev.fn address only if it is non-zero. Since + 00:00.0 will always be the host bridge, it can never be the address of + a network card. + + Reported-by: Alex Williamson + Signed-off-by: Michael Brown + +diff --git a/src/arch/i386/core/pci_autoboot.c b/src/arch/i386/core/pci_autoboot.c +index bbb4027..5e6197e 100644 +--- a/src/arch/i386/core/pci_autoboot.c ++++ b/src/arch/i386/core/pci_autoboot.c +@@ -34,8 +34,10 @@ uint16_t __bss16 ( autoboot_busdevfn ); + */ + static void pci_autoboot_init ( void ) { + +- autoboot_device.bus_type = BUS_TYPE_PCI; +- autoboot_device.location = autoboot_busdevfn; ++ if ( autoboot_busdevfn ) { ++ autoboot_device.bus_type = BUS_TYPE_PCI; ++ autoboot_device.location = autoboot_busdevfn; ++ } + } + + /** PCI autoboot device initialisation function */ diff -Nru ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/series ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/series --- ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/series 2014-01-06 09:48:23.000000000 +0000 +++ ipxe-1.0.0+git-20131111.c3d1e78/debian/patches/series 2015-01-14 16:22:21.000000000 +0000 @@ -1,3 +1,7 @@ rom-change-banner-timeout.diff enable-https.patch remove-libiberty.diff +bootorder/01-enable-infrastructure-to-specify-an-autoboot +bootorder/02-allow-prefix-to-specify-a-pci-autoboot +bootorder/03-store-boot-bus-dev-fn-address-as-autoboot-device-location +bootorder/04-ignore-pci-autoboot-device-location-if-set-to-00