From 27ecc36c0bef804d12dbf8c29684c8e8159c8e47 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 15 Apr 2024 14:28:38 +0100 Subject: [efi] Do not attempt to download autoexec.ipxe without a valid base URI If we do not have a current working URI (after applying the EFI device path settings and any cached DHCP settings), then an attempt to download autoexec.ipxe will fail since there is no base URI from which to resolve the full autoexec.ipxe URI. Avoid this potentially confusing error message by attempting the download only if we have successfully obtained a current working URI. Signed-off-by: Michael Brown --- src/interface/efi/efi_autoexec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efi_autoexec.c b/src/interface/efi/efi_autoexec.c index d9ad3b990..44b8b645b 100644 --- a/src/interface/efi/efi_autoexec.c +++ b/src/interface/efi/efi_autoexec.c @@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -111,6 +112,14 @@ static int efi_autoexec_network ( EFI_HANDLE handle, struct image **image ) { goto err_create; } + /* Do nothing unless we have a usable current working URI */ + if ( ! cwuri ) { + DBGC ( device, "EFI %s has no current working URI\n", + efi_handle_name ( device ) ); + rc = -ENOTTY; + goto err_cwuri; + } + /* Open network device */ if ( ( rc = netdev_open ( netdev ) ) != 0 ) { DBGC ( device, "EFI %s could not open net device: %s\n", @@ -130,6 +139,7 @@ static int efi_autoexec_network ( EFI_HANDLE handle, struct image **image ) { sync ( EFI_AUTOEXEC_TIMEOUT ); err_open: + err_cwuri: mnptemp_destroy ( netdev ); err_create: return rc; -- cgit v1.2.3-55-g7522 From cb95b5b378b1a61d10770965d82dba535b6be242 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 16 Apr 2024 14:19:01 +0100 Subject: [efi] Veto the Dhcp6Dxe driver on all platforms The reference implementation of Dhcp6Dxe in EDK2 has a fatal flaw: the code in EfiDhcp6Stop() will poll the network in a tight loop until either a response is received or a timer tick (at TPL_CALLBACK) occurs. When EfiDhcp6Stop() is called at TPL_CALLBACK or higher, this will result in an endless loop and an apparently frozen system. Since this is the reference implementation of Dhcp6Dxe, it is likely that almost all platforms have the same problem. Fix by vetoing the broken driver. If the upstream driver is ever fixed and a new version number issued, then we could plausibly test against the version number exposed via the driver binding protocol. Signed-off-by: Michael Brown --- src/interface/efi/efi_veto.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index a3b60d65f..37aa9a379 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -494,6 +494,32 @@ efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, return 1; } +/** + * Veto Dhcp6Dxe driver + * + * @v binding Driver binding protocol + * @v loaded Loaded image protocol + * @v wtf Component name protocol, if present + * @v manufacturer Manufacturer name, if present + * @v name Driver name, if present + * @ret vetoed Driver is to be vetoed + */ +static int efi_veto_dhcp6 ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, + EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, + EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, + const char *manufacturer __unused, + const CHAR16 *name ) { + static const CHAR16 dhcp6[] = L"DHCP6 Protocol Driver"; + + /* Check driver name */ + if ( ! name ) + return 0; + if ( memcmp ( name, dhcp6, sizeof ( dhcp6 ) ) != 0 ) + return 0; + + return 1; +} + /** Driver vetoes */ static struct efi_veto_candidate efi_vetoes[] = { { @@ -508,6 +534,10 @@ static struct efi_veto_candidate efi_vetoes[] = { .name = "VMware UefiPxeBc", .veto = efi_veto_vmware_uefipxebc, }, + { + .name = "Dhcp6", + .veto = efi_veto_dhcp6, + }, }; /** -- cgit v1.2.3-55-g7522 From 60d682409ed77cadf4ac3942c256c0fad00d2103 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 31 Jul 2024 16:20:37 +0100 Subject: [smbios] Avoid reading beyond end of constructed SMBIOS setting Signed-off-by: Michael Brown --- src/interface/smbios/smbios_settings.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/interface') diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index ec31b43f2..ca3f2fe2f 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -130,6 +130,13 @@ static int smbios_fetch ( struct settings *settings __unused, return rc; } + /* Limit length */ + if ( tag_offset > sizeof ( buf ) ) { + tag_len = 0; + } else if ( ( tag_offset + tag_len ) > sizeof ( buf ) ) { + tag_len = ( sizeof ( buf ) - tag_offset ); + } + /* Mangle UUIDs if necessary. iPXE treats UUIDs as * being in network byte order (big-endian). SMBIOS * specification version 2.6 states that UUIDs are -- cgit v1.2.3-55-g7522 From c117e6a4811efa057dc70426d58a8dab75245862 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 31 Jul 2024 16:26:48 +0100 Subject: [smbios] Allow reading an entire SMBIOS data structure as a setting The general syntax for SMBIOS settings: smbios/... is currently extended such that a of zero indicates that the byte at contains a string index, and an of zero indicates that the contains a literal string index. Since the byte at offset zero can never contain a string index, and a literal string index can never have a zero value, the combination of both and being zero is currently invalid and will always return "not found". Extend the syntax such that the combination of both and being zero may be used to read the entire data structure. Signed-off-by: Michael Brown --- src/interface/smbios/smbios_settings.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/interface') diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index ca3f2fe2f..095c35d37 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -117,8 +117,16 @@ static int smbios_fetch ( struct settings *settings __unused, * contains a string index. An of * zero indicates that the contains a literal * string index. + * + * Since the byte at offset zero can never contain a + * string index, and a literal string index can never + * be zero, the combination of both and + * being zero indicates that the entire + * structure is to be read. */ - if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { + if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { + tag_len = sizeof ( buf ); + } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { index = ( ( tag_offset == 0 ) ? tag_len : buf[tag_offset] ); if ( ( rc = read_smbios_string ( &structure, index, -- cgit v1.2.3-55-g7522 From 7c82ff0b6b12437bfc25d01d52308fc6fe2e1311 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 15 Aug 2024 08:46:41 +0100 Subject: [pci] Separate permission to probe buses from bus:dev.fn range discovery The UEFI device model requires us to not probe the PCI bus directly, but instead to wait to be offered the opportunity to drive devices via our driver service binding handle. We currently inhibit PCI bus probing by having pci_discover() return an empty range when using the EFI PCI I/O API. This has the unwanted side effect that scanning the bus manually using the "pciscan" command will also fail to discover any devices. Separate out the concept of being allowed to probe PCI buses from the mechanism for discovering PCI bus:dev.fn address ranges, so that this limitation may be removed. Signed-off-by: Michael Brown --- src/arch/x86/core/pcidirect.c | 1 + src/arch/x86/include/ipxe/pcibios.h | 10 ++++++++++ src/arch/x86/include/ipxe/pcicloud.h | 10 ++++++++++ src/arch/x86/include/ipxe/pcidirect.h | 10 ++++++++++ src/arch/x86/interface/pcbios/pcibios.c | 1 + src/arch/x86/interface/pcbios/pcicloud.c | 1 + src/drivers/bus/ecam.c | 1 + src/drivers/bus/pci.c | 4 ++++ src/include/ipxe/ecam.h | 10 ++++++++++ src/include/ipxe/efi/efi_pci_api.h | 10 ++++++++++ src/include/ipxe/linux/linux_pci.h | 10 ++++++++++ src/include/ipxe/pci_io.h | 7 +++++++ src/interface/efi/efi_pci.c | 1 + src/interface/linux/linux_pci.c | 1 + 14 files changed, 77 insertions(+) (limited to 'src/interface') diff --git a/src/arch/x86/core/pcidirect.c b/src/arch/x86/core/pcidirect.c index f4659a1ac..90d4623b3 100644 --- a/src/arch/x86/core/pcidirect.c +++ b/src/arch/x86/core/pcidirect.c @@ -45,6 +45,7 @@ void pcidirect_prepare ( struct pci_device *pci, int where ) { PCIDIRECT_CONFIG_ADDRESS ); } +PROVIDE_PCIAPI_INLINE ( direct, pci_can_probe ); PROVIDE_PCIAPI_INLINE ( direct, pci_discover ); PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_word ); diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index 3caea1cfe..ef9585654 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -32,6 +32,16 @@ extern int pcibios_read ( struct pci_device *pci, uint32_t command, extern int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( pcbios, pci_can_probe ) ( void ) { + return 1; +} + /** * Read byte from PCI configuration space via PCI BIOS * diff --git a/src/arch/x86/include/ipxe/pcicloud.h b/src/arch/x86/include/ipxe/pcicloud.h index 52268908c..1feef56cb 100644 --- a/src/arch/x86/include/ipxe/pcicloud.h +++ b/src/arch/x86/include/ipxe/pcicloud.h @@ -15,4 +15,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define PCIAPI_PREFIX_cloud __cloud_ #endif +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( cloud, pci_can_probe ) ( void ) { + return 1; +} + #endif /* _IPXE_PCICLOUD_H */ diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index 98c6a2bbb..999b52763 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -25,6 +25,16 @@ struct pci_device; extern void pcidirect_prepare ( struct pci_device *pci, int where ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( direct, pci_can_probe ) ( void ) { + return 1; +} + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/arch/x86/interface/pcbios/pcibios.c b/src/arch/x86/interface/pcbios/pcibios.c index 7b7a769e3..ebe40ba7d 100644 --- a/src/arch/x86/interface/pcbios/pcibios.c +++ b/src/arch/x86/interface/pcbios/pcibios.c @@ -120,6 +120,7 @@ int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ){ return ( status >> 8 ); } +PROVIDE_PCIAPI_INLINE ( pcbios, pci_can_probe ); PROVIDE_PCIAPI ( pcbios, pci_discover, pcibios_discover ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_word ); diff --git a/src/arch/x86/interface/pcbios/pcicloud.c b/src/arch/x86/interface/pcbios/pcicloud.c index 98ba38b31..f7d4a2da1 100644 --- a/src/arch/x86/interface/pcbios/pcicloud.c +++ b/src/arch/x86/interface/pcbios/pcicloud.c @@ -148,6 +148,7 @@ static void * pcicloud_ioremap ( struct pci_device *pci, return pcicloud->pci_ioremap ( pci, bus_addr, len ); } +PROVIDE_PCIAPI_INLINE ( cloud, pci_can_probe ); PROVIDE_PCIAPI ( cloud, pci_discover, pcicloud_discover ); PROVIDE_PCIAPI ( cloud, pci_read_config_byte, pcicloud_read_config_byte ); PROVIDE_PCIAPI ( cloud, pci_read_config_word, pcicloud_read_config_word ); diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 5e3debddd..cde5952b8 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -276,6 +276,7 @@ int ecam_write ( struct pci_device *pci, unsigned int location, return 0; } +PROVIDE_PCIAPI_INLINE ( ecam, pci_can_probe ); PROVIDE_PCIAPI ( ecam, pci_discover, ecam_discover ); PROVIDE_PCIAPI_INLINE ( ecam, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( ecam, pci_read_config_word ); diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 92b389641..05c9a5c26 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -361,6 +361,10 @@ static int pcibus_probe ( struct root_device *rootdev ) { uint32_t busdevfn = 0; int rc; + /* Skip automatic probing if prohibited */ + if ( ! pci_can_probe() ) + return 0; + do { /* Allocate struct pci_device */ if ( ! pci ) diff --git a/src/include/ipxe/ecam.h b/src/include/ipxe/ecam.h index ff08aee5a..f656083f7 100644 --- a/src/include/ipxe/ecam.h +++ b/src/include/ipxe/ecam.h @@ -54,6 +54,16 @@ struct ecam_mapping { int rc; }; +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( ecam, pci_can_probe ) ( void ) { + return 1; +} + extern struct pci_api ecam_api; #endif /* _IPXE_ECAM_H */ diff --git a/src/include/ipxe/efi/efi_pci_api.h b/src/include/ipxe/efi/efi_pci_api.h index cf5e1d020..0c4c1b72c 100644 --- a/src/include/ipxe/efi/efi_pci_api.h +++ b/src/include/ipxe/efi/efi_pci_api.h @@ -32,6 +32,16 @@ extern int efipci_read ( struct pci_device *pci, unsigned long location, extern int efipci_write ( struct pci_device *pci, unsigned long location, unsigned long value ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( efi, pci_can_probe ) ( void ) { + return 0; +} + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/include/ipxe/linux/linux_pci.h b/src/include/ipxe/linux/linux_pci.h index ec6ff8b1c..2b19e13c3 100644 --- a/src/include/ipxe/linux/linux_pci.h +++ b/src/include/ipxe/linux/linux_pci.h @@ -22,6 +22,16 @@ extern int linux_pci_read ( struct pci_device *pci, unsigned long where, extern int linux_pci_write ( struct pci_device *pci, unsigned long where, unsigned long value, size_t len ); +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +static inline __always_inline int +PCIAPI_INLINE ( linux, pci_can_probe ) ( void ) { + return 1; +} + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 4c035b18b..322fdbb24 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -66,6 +66,13 @@ struct pci_range { /* Include all architecture-dependent I/O API headers */ #include +/** + * Check if PCI bus probing is allowed + * + * @ret ok Bus probing is allowed + */ +int pci_can_probe ( void ); + /** * Find next PCI bus:dev.fn address range in system * diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index e2eeeb344..61071d8a4 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -362,6 +362,7 @@ void * efipci_ioremap ( struct pci_device *pci, unsigned long bus_addr, return ioremap ( bus_addr, len ); } +PROVIDE_PCIAPI_INLINE ( efi, pci_can_probe ); PROVIDE_PCIAPI_INLINE ( efi, pci_discover ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_word ); diff --git a/src/interface/linux/linux_pci.c b/src/interface/linux/linux_pci.c index 300844737..a3a0828c1 100644 --- a/src/interface/linux/linux_pci.c +++ b/src/interface/linux/linux_pci.c @@ -188,6 +188,7 @@ int linux_pci_write ( struct pci_device *pci, unsigned long where, return rc; } +PROVIDE_PCIAPI_INLINE ( linux, pci_can_probe ); PROVIDE_PCIAPI_INLINE ( linux, pci_discover ); PROVIDE_PCIAPI_INLINE ( linux, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( linux, pci_read_config_word ); -- cgit v1.2.3-55-g7522 From 950f6b5861d8d6b247b37e4e1401d26d8f908ee8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 14 Aug 2024 23:40:50 +0100 Subject: [efi] Allow discovery of PCI bus:dev.fn address ranges Generalise the logic for identifying the matching PCI root bridge I/O protocol to allow for identifying the closest matching PCI bus:dev.fn address range, and use this to provide PCI address range discovery (while continuing to inhibit automatic PCI bus probing). This allows the "pciscan" command to work as expected under UEFI. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi_pci_api.h | 14 --- src/interface/efi/efi_pci.c | 240 +++++++++++++++++++++++++++---------- 2 files changed, 176 insertions(+), 78 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi_pci_api.h b/src/include/ipxe/efi/efi_pci_api.h index 0c4c1b72c..9aca02f65 100644 --- a/src/include/ipxe/efi/efi_pci_api.h +++ b/src/include/ipxe/efi/efi_pci_api.h @@ -42,20 +42,6 @@ PCIAPI_INLINE ( efi, pci_can_probe ) ( void ) { return 0; } -/** - * Find next PCI bus:dev.fn address range in system - * - * @v busdevfn Starting PCI bus:dev.fn address - * @v range PCI bus:dev.fn address range to fill in - */ -static inline __always_inline void -PCIAPI_INLINE ( efi, pci_discover ) ( uint32_t busdevfn __unused, - struct pci_range *range ) { - - /* EFI does not want us to scan the PCI bus ourselves */ - range->count = 0; -} - /** * Read byte from PCI configuration space via EFI * diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 61071d8a4..8d4e08567 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -63,91 +63,139 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /** - * Check for a matching PCI root bridge I/O protocol + * Find closest bus:dev.fn address range within a root bridge * - * @v pci PCI device + * @v pci Starting PCI device * @v handle EFI PCI root bridge handle - * @v root EFI PCI root bridge I/O protocol + * @v range PCI bus:dev.fn address range to fill in * @ret rc Return status code */ -static int efipci_root_match ( struct pci_device *pci, EFI_HANDLE handle, - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root ) { +static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, + struct pci_range *range ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + union { + void *interface; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; + } root; union { union acpi_resource *res; void *raw; - } u; - unsigned int segment = PCI_SEG ( pci->busdevfn ); - unsigned int bus = PCI_BUS ( pci->busdevfn ); - unsigned int start; - unsigned int end; + } acpi; + uint32_t best = 0; + uint32_t start; + uint32_t count; + uint32_t index; unsigned int tag; EFI_STATUS efirc; int rc; - /* Check segment number */ - if ( root->SegmentNumber != segment ) - return -ENOENT; + /* Return empty range on error */ + range->start = 0; + range->count = 0; + + /* Open root bridge I/O protocol */ + if ( ( efirc = bs->OpenProtocol ( handle, + &efi_pci_root_bridge_io_protocol_guid, + &root.interface, efi_image_handle, handle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", + PCI_ARGS ( pci ), efi_handle_name ( handle ), + strerror ( rc ) ); + goto err_open; + } /* Get ACPI resource descriptors */ - if ( ( efirc = root->Configuration ( root, &u.raw ) ) != 0 ) { + if ( ( efirc = root.root->Configuration ( root.root, + &acpi.raw ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( pci, "EFIPCI " PCI_FMT " cannot get configuration for " "%s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); - return rc; + goto err_config; } - /* Assume success if no bus number range descriptors are found */ - rc = 0; - /* Parse resource descriptors */ - for ( ; ( ( tag = acpi_resource_tag ( u.res ) ) != ACPI_END_RESOURCE ) ; - u.res = acpi_resource_next ( u.res ) ) { + for ( ; ( ( tag = acpi_resource_tag ( acpi.res ) ) != + ACPI_END_RESOURCE ) ; + acpi.res = acpi_resource_next ( acpi.res ) ) { /* Ignore anything other than a bus number range descriptor */ if ( tag != ACPI_QWORD_ADDRESS_SPACE_RESOURCE ) continue; - if ( u.res->qword.type != ACPI_ADDRESS_TYPE_BUS ) + if ( acpi.res->qword.type != ACPI_ADDRESS_TYPE_BUS ) continue; - /* Check for a matching bus number */ - start = le64_to_cpu ( u.res->qword.min ); - end = ( start + le64_to_cpu ( u.res->qword.len ) ); - if ( ( bus >= start ) && ( bus < end ) ) - return 0; + /* Get range for this descriptor */ + start = PCI_BUSDEVFN ( root.root->SegmentNumber, + le64_to_cpu ( acpi.res->qword.min ), + 0, 0 ); + count = PCI_BUSDEVFN ( 0, le64_to_cpu ( acpi.res->qword.len ), + 0, 0 ); + DBGC2 ( pci, "EFIPCI " PCI_FMT " found %04x:[%02x-%02x] via " + "%s\n", PCI_ARGS ( pci ), root.root->SegmentNumber, + PCI_BUS ( start ), PCI_BUS ( start + count - 1 ), + efi_handle_name ( handle ) ); + + /* Check for a matching or new closest range */ + index = ( pci->busdevfn - start ); + if ( ( index < count ) || ( index > best ) ) { + range->start = start; + range->count = count; + best = index; + } - /* We have seen at least one non-matching range - * descriptor, so assume failure unless we find a - * subsequent match. - */ - rc = -ENOENT; + /* Stop if this range contains the target bus:dev.fn address */ + if ( index < count ) + break; + } + + /* If no range descriptors were seen, assume that the root + * bridge has a single bus. + */ + if ( ! range->count ) { + range->start = PCI_BUSDEVFN ( root.root->SegmentNumber, + 0, 0, 0 ); + range->count = PCI_BUSDEVFN ( 0, 1, 0, 0 ); } + /* Success */ + rc = 0; + + err_config: + bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid, + efi_image_handle, handle ); + err_open: return rc; } /** - * Open EFI PCI root bridge I/O protocol + * Find closest bus:dev.fn address range within any root bridge * - * @v pci PCI device - * @ret handle EFI PCI root bridge handle - * @ret root EFI PCI root bridge I/O protocol, or NULL if not found + * @v pci Starting PCI device + * @v range PCI bus:dev.fn address range to fill in + * @v handle PCI root bridge I/O handle to fill in * @ret rc Return status code */ -static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { +static int efipci_discover_any ( struct pci_device *pci, + struct pci_range *range, + EFI_HANDLE *handle ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + uint32_t best = 0; + uint32_t index; + struct pci_range tmp; EFI_HANDLE *handles; UINTN num_handles; - union { - void *interface; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; - } u; - EFI_STATUS efirc; UINTN i; + EFI_STATUS efirc; int rc; - /* Enumerate all handles */ + /* Return an empty range and no handle on error */ + range->start = 0; + range->count = 0; + *handle = NULL; + + /* Enumerate all root bridge I/O protocol handles */ if ( ( efirc = bs->LocateHandleBuffer ( ByProtocol, &efi_pci_root_bridge_io_protocol_guid, NULL, &num_handles, &handles ) ) != 0 ) { @@ -157,37 +205,101 @@ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, goto err_locate; } - /* Look for matching root bridge I/O protocol */ + /* Iterate over all root bridge I/O protocols */ for ( i = 0 ; i < num_handles ; i++ ) { - *handle = handles[i]; - if ( ( efirc = bs->OpenProtocol ( *handle, - &efi_pci_root_bridge_io_protocol_guid, - &u.interface, efi_image_handle, *handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); - DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", - PCI_ARGS ( pci ), efi_handle_name ( *handle ), - strerror ( rc ) ); + + /* Get matching or closest range for this root bridge */ + if ( ( rc = efipci_discover_one ( pci, handles[i], + &tmp ) ) != 0 ) continue; + + /* Check for a matching or new closest range */ + index = ( pci->busdevfn - tmp.start ); + if ( ( index < tmp.count ) || ( index > best ) ) { + range->start = tmp.start; + range->count = tmp.count; + best = index; } - if ( efipci_root_match ( pci, *handle, u.root ) == 0 ) { - *root = u.root; - bs->FreePool ( handles ); - return 0; + + /* Stop if this range contains the target bus:dev.fn address */ + if ( index < tmp.count ) { + *handle = handles[i]; + break; } - bs->CloseProtocol ( *handle, - &efi_pci_root_bridge_io_protocol_guid, - efi_image_handle, *handle ); } - DBGC ( pci, "EFIPCI " PCI_FMT " found no root bridge\n", - PCI_ARGS ( pci ) ); - rc = -ENOENT; + /* Check for a range containing the target bus:dev.fn address */ + if ( ! *handle ) { + rc = -ENOENT; + goto err_range; + } + + /* Success */ + rc = 0; + + err_range: bs->FreePool ( handles ); err_locate: return rc; } +/** + * Find next PCI bus:dev.fn address range in system + * + * @v busdevfn Starting PCI bus:dev.fn address + * @v range PCI bus:dev.fn address range to fill in + */ +static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { + struct pci_device pci; + EFI_HANDLE handle; + + /* Find range */ + memset ( &pci, 0, sizeof ( pci ) ); + pci_init ( &pci, busdevfn ); + efipci_discover_any ( &pci, range, &handle ); +} + +/** + * Open EFI PCI root bridge I/O protocol + * + * @v pci PCI device + * @ret handle EFI PCI root bridge handle + * @ret root EFI PCI root bridge I/O protocol, or NULL if not found + * @ret rc Return status code + */ +static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + struct pci_range tmp; + union { + void *interface; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; + } u; + EFI_STATUS efirc; + int rc; + + /* Find matching root bridge I/O protocol handle */ + if ( ( rc = efipci_discover_any ( pci, &tmp, handle ) ) != 0 ) + return rc; + + /* (Re)open PCI root bridge I/O protocol */ + if ( ( efirc = bs->OpenProtocol ( *handle, + &efi_pci_root_bridge_io_protocol_guid, + &u.interface, efi_image_handle, *handle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", + PCI_ARGS ( pci ), efi_handle_name ( *handle ), + strerror ( rc ) ); + return rc; + } + + /* Return opened protocol */ + *root = u.root; + + return 0; +} + /** * Close EFI PCI root bridge I/O protocol * @@ -363,7 +475,7 @@ void * efipci_ioremap ( struct pci_device *pci, unsigned long bus_addr, } PROVIDE_PCIAPI_INLINE ( efi, pci_can_probe ); -PROVIDE_PCIAPI_INLINE ( efi, pci_discover ); +PROVIDE_PCIAPI ( efi, pci_discover, efipci_discover ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_byte ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_word ); PROVIDE_PCIAPI_INLINE ( efi, pci_read_config_dword ); -- cgit v1.2.3-55-g7522 From c85ad1246890cf3c0c5f2ac6de06ab046ddd0043 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 13 Sep 2024 14:26:34 +0100 Subject: [efi] Centralise definition of efi_cpu_nap() Define a cpu_halt() function which is architecture-specific but platform-independent, and merge the multiple architecture-specific implementations of the EFI cpu_nap() function into a single central efi_cpu_nap() that uses cpu_halt() if applicable. Signed-off-by: Michael Brown --- src/arch/arm/include/bits/nap.h | 10 +++- src/arch/arm/include/ipxe/efi/efiarm_nap.h | 18 ------- src/arch/arm/interface/efi/efiarm_nap.c | 57 ---------------------- src/arch/loong64/include/bits/nap.h | 8 ++- src/arch/loong64/include/ipxe/efi/efiloong64_nap.h | 18 ------- src/arch/loong64/interface/efi/efiloong64_nap.c | 57 ---------------------- src/arch/x86/include/bits/nap.h | 11 ++++- src/arch/x86/include/ipxe/efi/efix86_nap.h | 18 ------- src/arch/x86/interface/efi/efix86_nap.c | 57 ---------------------- src/config/defaults/efi.h | 4 +- src/include/ipxe/efi/efi_nap.h | 18 +++++++ src/include/ipxe/nap.h | 7 +++ src/interface/efi/efi_nap.c | 57 ++++++++++++++++++++++ 13 files changed, 107 insertions(+), 233 deletions(-) delete mode 100644 src/arch/arm/include/ipxe/efi/efiarm_nap.h delete mode 100644 src/arch/arm/interface/efi/efiarm_nap.c delete mode 100644 src/arch/loong64/include/ipxe/efi/efiloong64_nap.h delete mode 100644 src/arch/loong64/interface/efi/efiloong64_nap.c delete mode 100644 src/arch/x86/include/ipxe/efi/efix86_nap.h delete mode 100644 src/arch/x86/interface/efi/efix86_nap.c create mode 100644 src/include/ipxe/efi/efi_nap.h create mode 100644 src/interface/efi/efi_nap.c (limited to 'src/interface') diff --git a/src/arch/arm/include/bits/nap.h b/src/arch/arm/include/bits/nap.h index e30a7146b..dbdf37166 100644 --- a/src/arch/arm/include/bits/nap.h +++ b/src/arch/arm/include/bits/nap.h @@ -9,6 +9,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#include +/** + * Sleep until next CPU interrupt + * + */ +static inline __attribute__ (( always_inline )) void cpu_halt ( void ) { + __asm__ __volatile__ ( "wfi" ); +} -#endif /* _BITS_MAP_H */ +#endif /* _BITS_NAP_H */ diff --git a/src/arch/arm/include/ipxe/efi/efiarm_nap.h b/src/arch/arm/include/ipxe/efi/efiarm_nap.h deleted file mode 100644 index dcbdd3e20..000000000 --- a/src/arch/arm/include/ipxe/efi/efiarm_nap.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _IPXE_EFIARM_NAP_H -#define _IPXE_EFIARM_NAP_H - -/** @file - * - * EFI CPU sleeping - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#ifdef NAP_EFIARM -#define NAP_PREFIX_efiarm -#else -#define NAP_PREFIX_efiarm __efiarm_ -#endif - -#endif /* _IPXE_EFIARM_NAP_H */ diff --git a/src/arch/arm/interface/efi/efiarm_nap.c b/src/arch/arm/interface/efi/efiarm_nap.c deleted file mode 100644 index fba7a5d82..000000000 --- a/src/arch/arm/interface/efi/efiarm_nap.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2016 Michael Brown . - * - * 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. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include - -/** @file - * - * iPXE CPU sleeping API for EFI - * - */ - -/** - * Sleep until next interrupt - * - */ -static void efiarm_cpu_nap ( void ) { - /* - * I can't find any EFI API that allows us to put the CPU to - * sleep. The CpuSleep() function is defined in CpuLib.h, but - * isn't part of any exposed protocol so we have no way to - * call it. - * - * The EFI shell doesn't seem to bother sleeping the CPU; it - * just sits there idly burning power. - * - * If a shutdown is in progess, there may be nothing to - * generate an interrupt since the timer is disabled in the - * first step of ExitBootServices(). - */ - if ( ! efi_shutdown_in_progress ) - __asm__ __volatile__ ( "wfi" ); -} - -PROVIDE_NAP ( efiarm, cpu_nap, efiarm_cpu_nap ); diff --git a/src/arch/loong64/include/bits/nap.h b/src/arch/loong64/include/bits/nap.h index 2deba3558..d904db537 100644 --- a/src/arch/loong64/include/bits/nap.h +++ b/src/arch/loong64/include/bits/nap.h @@ -9,6 +9,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#include +/** + * Sleep until next CPU interrupt + * + */ +static inline __attribute__ (( always_inline )) void cpu_halt ( void ) { + __asm__ __volatile__ ( "idle 0" ); +} #endif /* _BITS_NAP_H */ diff --git a/src/arch/loong64/include/ipxe/efi/efiloong64_nap.h b/src/arch/loong64/include/ipxe/efi/efiloong64_nap.h deleted file mode 100644 index 5c0d38636..000000000 --- a/src/arch/loong64/include/ipxe/efi/efiloong64_nap.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _IPXE_EFILOONG64_NAP_H -#define _IPXE_EFILOONG64_NAP_H - -/** @file - * - * EFI CPU sleeping - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#ifdef NAP_EFILOONG64 -#define NAP_PREFIX_efiloong64 -#else -#define NAP_PREFIX_efiloong64 __efiloong64_ -#endif - -#endif /* _IPXE_EFILOONG64_NAP_H */ diff --git a/src/arch/loong64/interface/efi/efiloong64_nap.c b/src/arch/loong64/interface/efi/efiloong64_nap.c deleted file mode 100644 index 0a7609783..000000000 --- a/src/arch/loong64/interface/efi/efiloong64_nap.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023, Xiaotian Wu - * - * 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. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include - -/** @file - * - * iPXE CPU sleeping API for EFI - * - */ - -/** - * Sleep until next interrupt - * - */ -static void efiloong64_cpu_nap ( void ) { - /* - * I can't find any EFI API that allows us to put the CPU to - * sleep. The CpuSleep() function is defined in CpuLib.h, but - * isn't part of any exposed protocol so we have no way to - * call it. - * - * The EFI shell doesn't seem to bother sleeping the CPU; it - * just sits there idly burning power. - * - * If a shutdown is in progess, there may be nothing to - * generate an interrupt since the timer is disabled in the - * first step of ExitBootServices(). - */ - if ( ! efi_shutdown_in_progress ) - __asm__ __volatile__ ( "idle 0" ); -} - -PROVIDE_NAP ( efiloong64, cpu_nap, efiloong64_cpu_nap ); diff --git a/src/arch/x86/include/bits/nap.h b/src/arch/x86/include/bits/nap.h index 7103b94c0..b7dea736d 100644 --- a/src/arch/x86/include/bits/nap.h +++ b/src/arch/x86/include/bits/nap.h @@ -10,6 +10,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include -#endif /* _BITS_MAP_H */ +/** + * Sleep until next CPU interrupt + * + */ +static inline __attribute__ (( always_inline )) void cpu_halt ( void ) { + __asm__ __volatile__ ( "hlt" ); +} + +#endif /* _BITS_NAP_H */ diff --git a/src/arch/x86/include/ipxe/efi/efix86_nap.h b/src/arch/x86/include/ipxe/efi/efix86_nap.h deleted file mode 100644 index 1a391c9b6..000000000 --- a/src/arch/x86/include/ipxe/efi/efix86_nap.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _IPXE_EFIX86_NAP_H -#define _IPXE_EFIX86_NAP_H - -/** @file - * - * EFI CPU sleeping - * - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#ifdef NAP_EFIX86 -#define NAP_PREFIX_efix86 -#else -#define NAP_PREFIX_efix86 __efix86_ -#endif - -#endif /* _IPXE_EFIX86_NAP_H */ diff --git a/src/arch/x86/interface/efi/efix86_nap.c b/src/arch/x86/interface/efi/efix86_nap.c deleted file mode 100644 index 296876b85..000000000 --- a/src/arch/x86/interface/efi/efix86_nap.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2008 Michael Brown . - * - * 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. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include - -/** @file - * - * iPXE CPU sleeping API for EFI - * - */ - -/** - * Sleep until next interrupt - * - */ -static void efix86_cpu_nap ( void ) { - /* - * I can't find any EFI API that allows us to put the CPU to - * sleep. The CpuSleep() function is defined in CpuLib.h, but - * isn't part of any exposed protocol so we have no way to - * call it. - * - * The EFI shell doesn't seem to bother sleeping the CPU; it - * just sits there idly burning power. - * - * If a shutdown is in progess, there may be nothing to - * generate an interrupt since the timer is disabled in the - * first step of ExitBootServices(). - */ - if ( ! efi_shutdown_in_progress ) - __asm__ __volatile__ ( "hlt" ); -} - -PROVIDE_NAP ( efix86, cpu_nap, efix86_cpu_nap ); diff --git a/src/config/defaults/efi.h b/src/config/defaults/efi.h index b62ddb46a..178b448cb 100644 --- a/src/config/defaults/efi.h +++ b/src/config/defaults/efi.h @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ACPI_EFI #define FDT_EFI #define MPAPI_EFI +#define NAP_EFI #define NET_PROTO_IPV6 /* IPv6 protocol */ #define NET_PROTO_LLDP /* Link Layer Discovery protocol */ @@ -53,7 +54,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #if defined ( __i386__ ) || defined ( __x86_64__ ) #define IOAPI_X86 -#define NAP_EFIX86 #define ENTROPY_RDRAND #define CPUID_CMD /* x86 CPU feature detection command */ #define UNSAFE_STD /* Avoid setting direction flag */ @@ -61,7 +61,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #if defined ( __arm__ ) || defined ( __aarch64__ ) #define IOAPI_ARM -#define NAP_EFIARM #endif #if defined ( __aarch64__ ) @@ -70,7 +69,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #if defined ( __loongarch__ ) #define IOAPI_LOONG64 -#define NAP_EFILOONG64 #endif #endif /* CONFIG_DEFAULTS_EFI_H */ diff --git a/src/include/ipxe/efi/efi_nap.h b/src/include/ipxe/efi/efi_nap.h new file mode 100644 index 000000000..1ffb05569 --- /dev/null +++ b/src/include/ipxe/efi/efi_nap.h @@ -0,0 +1,18 @@ +#ifndef _IPXE_EFI_NAP_H +#define _IPXE_EFI_NAP_H + +/** @file + * + * CPU sleeping + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#ifdef NAP_EFI +#define NAP_PREFIX_efi +#else +#define NAP_PREFIX_efi __efi_ +#endif + +#endif /* _IPXE_EFI_NAP_H */ diff --git a/src/include/ipxe/nap.h b/src/include/ipxe/nap.h index f4de778c4..8d5d8e3df 100644 --- a/src/include/ipxe/nap.h +++ b/src/include/ipxe/nap.h @@ -43,6 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* Include all architecture-independent I/O API headers */ #include +#include #include /* Include all architecture-dependent I/O API headers */ @@ -52,6 +53,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * Sleep until next CPU interrupt * */ +void cpu_halt ( void ); + +/** + * Sleep with interrupts enabled until next CPU interrupt + * + */ void cpu_nap ( void ); #endif /* _IPXE_NAP_H */ diff --git a/src/interface/efi/efi_nap.c b/src/interface/efi/efi_nap.c new file mode 100644 index 000000000..2bb47627f --- /dev/null +++ b/src/interface/efi/efi_nap.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008 Michael Brown . + * + * 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include + +/** @file + * + * iPXE CPU sleeping API for EFI + * + */ + +/** + * Sleep until next interrupt + * + */ +static void efi_cpu_nap ( void ) { + /* + * I can't find any EFI API that allows us to put the CPU to + * sleep. The CpuSleep() function is defined in CpuLib.h, but + * isn't part of any exposed protocol so we have no way to + * call it. + * + * The EFI shell doesn't seem to bother sleeping the CPU; it + * just sits there idly burning power. + * + * If a shutdown is in progess, there may be nothing to + * generate an interrupt since the timer is disabled in the + * first step of ExitBootServices(). + */ + if ( ! efi_shutdown_in_progress ) + cpu_halt(); +} + +PROVIDE_NAP ( efi, cpu_nap, efi_cpu_nap ); -- cgit v1.2.3-55-g7522 From 670810bed841678e6303719bb123edad9857f320 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 15 Sep 2024 02:01:46 +0100 Subject: [efi] Use standard va_args macros instead of VA_START() etc The EDK2 header macros VA_START(), VA_ARG() etc produce build errors on some CPU architectures (notably on 32-bit RISC-V, which is not yet supported by EDK2). Fix by using the standard variable argument list macros. Signed-off-by: Michael Brown --- src/interface/efi/efi_wrap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 5d5d2caee..c2fab6647 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -1059,7 +1059,7 @@ efi_install_multiple_protocol_interfaces_wrapper ( EFI_HANDLE *handle, ... ) { void *retaddr = __builtin_return_address ( 0 ); EFI_GUID *protocol[ MAX_WRAP_MULTI + 1 ]; VOID *interface[MAX_WRAP_MULTI]; - VA_LIST ap; + va_list ap; unsigned int i; EFI_STATUS efirc; @@ -1067,20 +1067,20 @@ efi_install_multiple_protocol_interfaces_wrapper ( EFI_HANDLE *handle, ... ) { efi_handle_name ( *handle ) ); memset ( protocol, 0, sizeof ( protocol ) ); memset ( interface, 0, sizeof ( interface ) ); - VA_START ( ap, handle ); - for ( i = 0 ; ( protocol[i] = VA_ARG ( ap, EFI_GUID * ) ) ; i++ ) { + va_start ( ap, handle ); + for ( i = 0 ; ( protocol[i] = va_arg ( ap, EFI_GUID * ) ) ; i++ ) { if ( i == MAX_WRAP_MULTI ) { - VA_END ( ap ); + va_end ( ap ); efirc = EFI_OUT_OF_RESOURCES; DBGC ( colour, " ) = %s " "-> %p\n", efi_status ( efirc ), retaddr ); return efirc; } - interface[i] = VA_ARG ( ap, VOID * ); + interface[i] = va_arg ( ap, VOID * ); DBGC ( colour, ", %s, %p", efi_guid_ntoa ( protocol[i] ), interface[i] ); } - VA_END ( ap ); + va_end ( ap ); DBGC ( colour, " ) " ); efirc = bs->InstallMultipleProtocolInterfaces ( handle, protocol[0], interface[0], protocol[1], interface[1], @@ -1109,7 +1109,7 @@ efi_uninstall_multiple_protocol_interfaces_wrapper ( EFI_HANDLE handle, ... ) { void *retaddr = __builtin_return_address ( 0 ); EFI_GUID *protocol[ MAX_WRAP_MULTI + 1 ]; VOID *interface[MAX_WRAP_MULTI]; - VA_LIST ap; + va_list ap; unsigned int i; EFI_STATUS efirc; @@ -1117,20 +1117,20 @@ efi_uninstall_multiple_protocol_interfaces_wrapper ( EFI_HANDLE handle, ... ) { efi_handle_name ( handle ) ); memset ( protocol, 0, sizeof ( protocol ) ); memset ( interface, 0, sizeof ( interface ) ); - VA_START ( ap, handle ); - for ( i = 0 ; ( protocol[i] = VA_ARG ( ap, EFI_GUID * ) ) ; i++ ) { + va_start ( ap, handle ); + for ( i = 0 ; ( protocol[i] = va_arg ( ap, EFI_GUID * ) ) ; i++ ) { if ( i == MAX_WRAP_MULTI ) { - VA_END ( ap ); + va_end ( ap ); efirc = EFI_OUT_OF_RESOURCES; DBGC ( colour, " ) = %s " "-> %p\n", efi_status ( efirc ), retaddr ); return efirc; } - interface[i] = VA_ARG ( ap, VOID * ); + interface[i] = va_arg ( ap, VOID * ); DBGC ( colour, ", %s, %p", efi_guid_ntoa ( protocol[i] ), interface[i] ); } - VA_END ( ap ); + va_end ( ap ); DBGC ( colour, " ) " ); efirc = bs->UninstallMultipleProtocolInterfaces ( handle, protocol[0], interface[0], protocol[1], interface[1], -- cgit v1.2.3-55-g7522 From abfa7c3ab1323967c38b11d4732b2d27ecf2f094 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 25 Oct 2024 14:21:27 +0100 Subject: [uaccess] Rename UACCESS_EFI to UACCESS_FLAT Running with flat physical addressing is a fairly common early boot environment. Rename UACCESS_EFI to UACCESS_FLAT so that this code may be reused in non-UEFI boot environments that also use flat physical addressing. Signed-off-by: Michael Brown --- src/config/defaults/efi.h | 2 +- src/core/uaccess.c | 44 ++++++++++++++++ src/include/ipxe/efi/efi_uaccess.h | 103 ------------------------------------- src/include/ipxe/uaccess.h | 76 ++++++++++++++++++++++++++- src/interface/efi/efi_uaccess.c | 44 ---------------- 5 files changed, 120 insertions(+), 149 deletions(-) create mode 100644 src/core/uaccess.c delete mode 100644 src/include/ipxe/efi/efi_uaccess.h delete mode 100644 src/interface/efi/efi_uaccess.c (limited to 'src/interface') diff --git a/src/config/defaults/efi.h b/src/config/defaults/efi.h index b32381de6..607f94c14 100644 --- a/src/config/defaults/efi.h +++ b/src/config/defaults/efi.h @@ -9,7 +9,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#define UACCESS_EFI +#define UACCESS_FLAT #define IOMAP_VIRT #define PCIAPI_EFI #define DMAAPI_OP diff --git a/src/core/uaccess.c b/src/core/uaccess.c new file mode 100644 index 000000000..d3a9ca17d --- /dev/null +++ b/src/core/uaccess.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Michael Brown . + * + * 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** @file + * + * iPXE user access API + * + */ + +/* Flat address space user access API */ +PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); +PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); +PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); +PROVIDE_UACCESS_INLINE ( flat, user_to_virt ); +PROVIDE_UACCESS_INLINE ( flat, userptr_add ); +PROVIDE_UACCESS_INLINE ( flat, memcpy_user ); +PROVIDE_UACCESS_INLINE ( flat, memmove_user ); +PROVIDE_UACCESS_INLINE ( flat, memset_user ); +PROVIDE_UACCESS_INLINE ( flat, strlen_user ); +PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/include/ipxe/efi/efi_uaccess.h b/src/include/ipxe/efi/efi_uaccess.h deleted file mode 100644 index 3cc750405..000000000 --- a/src/include/ipxe/efi/efi_uaccess.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef _IPXE_EFI_UACCESS_H -#define _IPXE_EFI_UACCESS_H - -/** @file - * - * iPXE user access API for EFI - * - * EFI runs with flat physical addressing, so the various mappings - * between virtual addresses, I/O addresses and bus addresses are all - * no-ops. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#ifdef UACCESS_EFI -#define UACCESS_PREFIX_efi -#else -#define UACCESS_PREFIX_efi __efi_ -#endif - -/** - * Convert physical address to user pointer - * - * @v phys_addr Physical address - * @ret userptr User pointer - */ -static inline __always_inline userptr_t -UACCESS_INLINE ( efi, phys_to_user ) ( unsigned long phys_addr ) { - return phys_addr; -} - -/** - * Convert user buffer to physical address - * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address - */ -static inline __always_inline unsigned long -UACCESS_INLINE ( efi, user_to_phys ) ( userptr_t userptr, off_t offset ) { - return ( userptr + offset ); -} - -static inline __always_inline userptr_t -UACCESS_INLINE ( efi, virt_to_user ) ( volatile const void *addr ) { - return trivial_virt_to_user ( addr ); -} - -static inline __always_inline void * -UACCESS_INLINE ( efi, user_to_virt ) ( userptr_t userptr, off_t offset ) { - return trivial_user_to_virt ( userptr, offset ); -} - -static inline __always_inline userptr_t -UACCESS_INLINE ( efi, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( efi, userptr_sub ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_sub ( userptr, subtrahend ); -} - -static inline __always_inline void -UACCESS_INLINE ( efi, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( efi, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( efi, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( efi, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( efi, memchr_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - return trivial_memchr_user ( buffer, offset, c, len ); -} - -#endif /* _IPXE_EFI_UACCESS_H */ diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index a3f78566a..b71361cab 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -26,6 +26,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#ifdef UACCESS_FLAT +#define UACCESS_PREFIX_flat +#else +#define UACCESS_PREFIX_flat __flat_ +#endif + /** * A pointer to a user buffer * @@ -216,8 +222,76 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) { #define PROVIDE_UACCESS_INLINE( _subsys, _api_func ) \ PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) +static inline __always_inline userptr_t +UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) { + return phys_addr; +} + +static inline __always_inline unsigned long +UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) { + return ( userptr + offset ); +} + +static inline __always_inline userptr_t +UACCESS_INLINE ( flat, virt_to_user ) ( volatile const void *addr ) { + return trivial_virt_to_user ( addr ); +} + +static inline __always_inline void * +UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) { + return trivial_user_to_virt ( userptr, offset ); +} + +static inline __always_inline userptr_t +UACCESS_INLINE ( flat, userptr_add ) ( userptr_t userptr, off_t offset ) { + return trivial_userptr_add ( userptr, offset ); +} + +static inline __always_inline off_t +UACCESS_INLINE ( flat, userptr_sub ) ( userptr_t userptr, + userptr_t subtrahend ) { + return trivial_userptr_sub ( userptr, subtrahend ); +} + +static inline __always_inline void +UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off, + userptr_t src, off_t src_off, + size_t len ) { + trivial_memcpy_user ( dest, dest_off, src, src_off, len ); +} + +static inline __always_inline void +UACCESS_INLINE ( flat, memmove_user ) ( userptr_t dest, off_t dest_off, + userptr_t src, off_t src_off, + size_t len ) { + trivial_memmove_user ( dest, dest_off, src, src_off, len ); +} + +static inline __always_inline int +UACCESS_INLINE ( flat, memcmp_user ) ( userptr_t first, off_t first_off, + userptr_t second, off_t second_off, + size_t len ) { + return trivial_memcmp_user ( first, first_off, second, second_off, len); +} + +static inline __always_inline void +UACCESS_INLINE ( flat, memset_user ) ( userptr_t buffer, off_t offset, + int c, size_t len ) { + trivial_memset_user ( buffer, offset, c, len ); +} + +static inline __always_inline size_t +UACCESS_INLINE ( flat, strlen_user ) ( userptr_t buffer, off_t offset ) { + return trivial_strlen_user ( buffer, offset ); +} + +static inline __always_inline off_t +UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, + int c, size_t len ) { + return trivial_memchr_user ( buffer, offset, c, len ); +} + /* Include all architecture-independent user access API headers */ -#include #include /* Include all architecture-dependent user access API headers */ diff --git a/src/interface/efi/efi_uaccess.c b/src/interface/efi/efi_uaccess.c deleted file mode 100644 index e058be66b..000000000 --- a/src/interface/efi/efi_uaccess.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008 Michael Brown . - * - * 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. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include - -/** @file - * - * iPXE user access API for EFI - * - */ - -PROVIDE_UACCESS_INLINE ( efi, phys_to_user ); -PROVIDE_UACCESS_INLINE ( efi, user_to_phys ); -PROVIDE_UACCESS_INLINE ( efi, virt_to_user ); -PROVIDE_UACCESS_INLINE ( efi, user_to_virt ); -PROVIDE_UACCESS_INLINE ( efi, userptr_add ); -PROVIDE_UACCESS_INLINE ( efi, memcpy_user ); -PROVIDE_UACCESS_INLINE ( efi, memmove_user ); -PROVIDE_UACCESS_INLINE ( efi, memset_user ); -PROVIDE_UACCESS_INLINE ( efi, strlen_user ); -PROVIDE_UACCESS_INLINE ( efi, memchr_user ); -- cgit v1.2.3-55-g7522 From e9a23a5b394f40c1525c40416105eaaa1787f749 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Nov 2024 14:21:16 +0000 Subject: [efi] Ensure local drives are connected when attempting a SAN boot UEFI systems may choose not to connect drivers for local disk drives when the boot policy is set to attempt a network boot. This may cause the "sanboot" command to be unable to boot from a local drive, since the relevant block device and filesystem drivers may not have been connected. Fix by ensuring that all available drivers are connected before attempting to boot from an EFI block device. Reported-by: Andrew Cottrell Tested-by: Andrew Cottrell Signed-off-by: Michael Brown --- src/interface/efi/efi_block.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 2f0187a0a..6296953c5 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -990,6 +990,9 @@ static int efi_block_boot ( unsigned int drive, EFI_STATUS efirc; int rc; + /* Ensure that any local drives are connected */ + efi_driver_reconnect_all(); + /* Release SNP devices */ efi_snp_release(); -- cgit v1.2.3-55-g7522 From c0cbe7c2e69185bad65344914e757fe1844ee962 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 17 Dec 2024 13:51:40 +0000 Subject: [efi] Add EFI_TCG2_PROTOCOL header and GUID definition Signed-off-by: Michael Brown --- src/include/ipxe/efi/Protocol/Tcg2Protocol.h | 337 +++++++++++++++++++++++++++ src/include/ipxe/efi/efi.h | 1 + src/interface/efi/efi_debug.c | 2 + src/interface/efi/efi_guid.c | 5 + 4 files changed, 345 insertions(+) create mode 100644 src/include/ipxe/efi/Protocol/Tcg2Protocol.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Protocol/Tcg2Protocol.h b/src/include/ipxe/efi/Protocol/Tcg2Protocol.h new file mode 100644 index 000000000..e6c2a728e --- /dev/null +++ b/src/include/ipxe/efi/Protocol/Tcg2Protocol.h @@ -0,0 +1,337 @@ +/** @file + TPM2 Protocol as defined in TCG PC Client Platform EFI Protocol Specification Family "2.0". + See http://trustedcomputinggroup.org for the latest specification + +Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __TCG2_PROTOCOL_H__ +#define __TCG2_PROTOCOL_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#include +#include + +#define EFI_TCG2_PROTOCOL_GUID \ + {0x607f766c, 0x7455, 0x42be, { 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f }} + +typedef struct tdEFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL; + +typedef struct tdEFI_TCG2_VERSION { + UINT8 Major; + UINT8 Minor; +} EFI_TCG2_VERSION; + +typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP; +typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT; +typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP; + +#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x00000001 +#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 + +typedef struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY { + // + // Allocated size of the structure + // + UINT8 Size; + // + // Version of the EFI_TCG2_BOOT_SERVICE_CAPABILITY structure itself. + // For this version of the protocol, the Major version shall be set to 1 + // and the Minor version shall be set to 1. + // + EFI_TCG2_VERSION StructureVersion; + // + // Version of the EFI TCG2 protocol. + // For this version of the protocol, the Major version shall be set to 1 + // and the Minor version shall be set to 1. + // + EFI_TCG2_VERSION ProtocolVersion; + // + // Supported hash algorithms (this bitmap is determined by the supported PCR + // banks in the TPM and the hashing algorithms supported by the firmware) + // + EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap; + // + // Bitmap of supported event log formats + // + EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs; + // + // False = TPM not present + // + BOOLEAN TPMPresentFlag; + // + // Max size (in bytes) of a command that can be sent to the TPM + // + UINT16 MaxCommandSize; + // + // Max size (in bytes) of a response that can be provided by the TPM + // + UINT16 MaxResponseSize; + // + // 4-byte Vendor ID + // (see TCG Vendor ID registry, Section "TPM Capabilities Vendor ID") + // + UINT32 ManufacturerID; + // + // Maximum number of PCR banks (hashing algorithms) supported. + // No granularity is provided to support a specific set of algorithms. + // Minimum value is 1. + // + UINT32 NumberOfPCRBanks; + // + // A bitmap of currently active PCR banks (hashing algorithms). + // This is a subset of the supported hashing algorithms reported in HashAlgorithmBitMap. + // NumberOfPcrBanks defines the number of bits that are set. + // + EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks; +} EFI_TCG2_BOOT_SERVICE_CAPABILITY; + +#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001 +#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002 +#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004 +#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008 +#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010 + +// +// This bit is shall be set when an event shall be extended but not logged. +// +#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001 +// +// This bit shall be set when the intent is to measure a PE/COFF image. +// +#define PE_COFF_IMAGE 0x0000000000000010 + +#define MAX_PCR_INDEX 23 + +#pragma pack(1) + +#define EFI_TCG2_EVENT_HEADER_VERSION 1 + +typedef struct { + // + // Size of the event header itself (sizeof(EFI_TCG2_EVENT_HEADER)). + // + UINT32 HeaderSize; + // + // Header version. For this version of this specification, the value shall be 1. + // + UINT16 HeaderVersion; + // + // Index of the PCR that shall be extended (0 - 23). + // + TCG_PCRINDEX PCRIndex; + // + // Type of the event that shall be extended (and optionally logged). + // + TCG_EVENTTYPE EventType; +} EFI_TCG2_EVENT_HEADER; + +typedef struct tdEFI_TCG2_EVENT { + // + // Total size of the event including the Size component, the header and the Event data. + // + UINT32 Size; + EFI_TCG2_EVENT_HEADER Header; + UINT8 Event[1]; +} EFI_TCG2_EVENT; + +#pragma pack() + +/** + The EFI_TCG2_PROTOCOL GetCapability function call provides protocol + capability information and state information. + + @param[in] This Indicates the calling context + @param[in, out] ProtocolCapability The caller allocates memory for a EFI_TCG2_BOOT_SERVICE_CAPABILITY + structure and sets the size field to the size of the structure allocated. + The callee fills in the fields with the EFI protocol capability information + and the current EFI TCG2 state information up to the number of fields which + fit within the size of the structure passed in. + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_DEVICE_ERROR The command was unsuccessful. + The ProtocolCapability variable will not be populated. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. + The ProtocolCapability variable will not be populated. + @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response. + It will be partially populated (required Size field will be set). +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_GET_CAPABILITY)( + IN EFI_TCG2_PROTOCOL *This, + IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability + ); + +/** + The EFI_TCG2_PROTOCOL Get Event Log function call allows a caller to + retrieve the address of a given event log and its last entry. + + @param[in] This Indicates the calling context + @param[in] EventLogFormat The type of the event log for which the information is requested. + @param[out] EventLogLocation A pointer to the memory address of the event log. + @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the + address of the start of the last entry in the event log in memory. + @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would + have exceeded the area allocated for events, this value is set to TRUE. + Otherwise, the value will be FALSE and the Event Log will be complete. + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect + (e.g. asking for an event log whose format is not supported). +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_GET_EVENT_LOG)( + IN EFI_TCG2_PROTOCOL *This, + IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat, + OUT EFI_PHYSICAL_ADDRESS *EventLogLocation, + OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry, + OUT BOOLEAN *EventLogTruncated + ); + +/** + The EFI_TCG2_PROTOCOL HashLogExtendEvent function call provides callers with + an opportunity to extend and optionally log events without requiring + knowledge of actual TPM commands. + The extend operation will occur even if this function cannot create an event + log entry (e.g. due to the event log being full). + + @param[in] This Indicates the calling context + @param[in] Flags Bitmap providing additional information. + @param[in] DataToHash Physical address of the start of the data buffer to be hashed. + @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash. + @param[in] EfiTcgEvent Pointer to data buffer containing information about the event. + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_DEVICE_ERROR The command was unsuccessful. + @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. + @retval EFI_UNSUPPORTED The PE/COFF image type is not supported. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_HASH_LOG_EXTEND_EVENT)( + IN EFI_TCG2_PROTOCOL *This, + IN UINT64 Flags, + IN EFI_PHYSICAL_ADDRESS DataToHash, + IN UINT64 DataToHashLen, + IN EFI_TCG2_EVENT *EfiTcgEvent + ); + +/** + This service enables the sending of commands to the TPM. + + @param[in] This Indicates the calling context + @param[in] InputParameterBlockSize Size of the TPM input parameter block. + @param[in] InputParameterBlock Pointer to the TPM input parameter block. + @param[in] OutputParameterBlockSize Size of the TPM output parameter block. + @param[in] OutputParameterBlock Pointer to the TPM output parameter block. + + @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received. + @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. + @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_SUBMIT_COMMAND)( + IN EFI_TCG2_PROTOCOL *This, + IN UINT32 InputParameterBlockSize, + IN UINT8 *InputParameterBlock, + IN UINT32 OutputParameterBlockSize, + IN UINT8 *OutputParameterBlock + ); + +/** + This service returns the currently active PCR banks. + + @param[in] This Indicates the calling context + @param[out] ActivePcrBanks Pointer to the variable receiving the bitmap of currently active PCR banks. + + @retval EFI_SUCCESS The bitmap of active PCR banks was stored in the ActivePcrBanks parameter. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS)( + IN EFI_TCG2_PROTOCOL *This, + OUT UINT32 *ActivePcrBanks + ); + +/** + This service sets the currently active PCR banks. + + @param[in] This Indicates the calling context + @param[in] ActivePcrBanks Bitmap of the requested active PCR banks. At least one bit SHALL be set. + + @retval EFI_SUCCESS The bitmap in ActivePcrBank parameter is already active. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS)( + IN EFI_TCG2_PROTOCOL *This, + IN UINT32 ActivePcrBanks + ); + +/** + This service retrieves the result of a previous invocation of SetActivePcrBanks. + + @param[in] This Indicates the calling context + @param[out] OperationPresent Non-zero value to indicate a SetActivePcrBank operation was invoked during the last boot. + @param[out] Response The response from the SetActivePcrBank request. + + @retval EFI_SUCCESS The result value could be returned. + @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS)( + IN EFI_TCG2_PROTOCOL *This, + OUT UINT32 *OperationPresent, + OUT UINT32 *Response + ); + +struct tdEFI_TCG2_PROTOCOL { + EFI_TCG2_GET_CAPABILITY GetCapability; + EFI_TCG2_GET_EVENT_LOG GetEventLog; + EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; + EFI_TCG2_SUBMIT_COMMAND SubmitCommand; + EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks; + EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks; + EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks; +}; + +extern EFI_GUID gEfiTcg2ProtocolGuid; + +// +// Log entries after Get Event Log service +// + +#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \ + {0x1e2ed096, 0x30e2, 0x4254, { 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25 }} + +extern EFI_GUID gEfiTcg2FinalEventsTableGuid; + +typedef struct tdEFI_TCG2_FINAL_EVENTS_TABLE { + // + // The version of this structure. + // + UINT64 Version; + // + // Number of events recorded after invocation of GetEventLog API + // + UINT64 NumberOfEvents; + // + // List of events of type TCG_PCR_EVENT2. + // + // TCG_PCR_EVENT2 Event[1]; +} EFI_TCG2_FINAL_EVENTS_TABLE; + +#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1 + +#endif diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 2137b824d..843c79e2e 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -228,6 +228,7 @@ extern EFI_GUID efi_simple_text_input_protocol_guid; extern EFI_GUID efi_simple_text_input_ex_protocol_guid; extern EFI_GUID efi_simple_text_output_protocol_guid; extern EFI_GUID efi_tcg_protocol_guid; +extern EFI_GUID efi_tcg2_protocol_guid; extern EFI_GUID efi_tcp4_protocol_guid; extern EFI_GUID efi_tcp4_service_binding_protocol_guid; extern EFI_GUID efi_tcp6_protocol_guid; diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 52efebe5f..895a712bd 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -209,6 +209,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "SimpleTextOutput" }, { &efi_tcg_protocol_guid, "Tcg" }, + { &efi_tcg2_protocol_guid, + "Tcg2" }, { &efi_tcp4_protocol_guid, "Tcp4" }, { &efi_tcp4_service_binding_protocol_guid, diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index f841448f1..16c1a5738 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -70,6 +70,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -326,6 +327,10 @@ EFI_GUID efi_simple_text_output_protocol_guid EFI_GUID efi_tcg_protocol_guid = EFI_TCG_PROTOCOL_GUID; +/** TCG2 protocol GUID */ +EFI_GUID efi_tcg2_protocol_guid + = EFI_TCG2_PROTOCOL_GUID; + /** TCPv4 protocol GUID */ EFI_GUID efi_tcp4_protocol_guid = EFI_TCP4_PROTOCOL_GUID; -- cgit v1.2.3-55-g7522 From b35300fc67cc050ce3f709a88a4437153d85e0ee Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 17 Feb 2025 13:11:28 +0000 Subject: [efi] Increase download timeout for autoexec.ipxe In almost all cases, the download timeout for autoexec.ipxe is irrelevant: the operation will either succeed or fail relatively quickly (e.g. due to a nonexistent file). The overall download timeout exists only to ensure that an unattended or headless system will not wait indefinitely in the case of a degenerate network response (e.g. an HTTP server that returns an endless trickle of data using chunked transfer encoding without ever reaching the end of the file). The current download timeout is too short if PeerDist content encoding is enabled, since the overall download will abort before the first peer discovery attempt has completed, and without allowing sufficient time for an origin server range request. The single timeout value is currently used for both the download timeout and the sync timeout. The latter timeout exists only to allow network communication to be gracefully quiesced before removing the temporary MNP network device, and may safely be shortened without affecting functionality. Fix by increasing the download timeout from two seconds to 30 seconds, and defining a separate one-second timeout for the sync operation. Reported-by: Michael Niehaus Signed-off-by: Michael Brown --- src/interface/efi/efi_autoexec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_autoexec.c b/src/interface/efi/efi_autoexec.c index 44b8b645b..73ba5df33 100644 --- a/src/interface/efi/efi_autoexec.c +++ b/src/interface/efi/efi_autoexec.c @@ -43,7 +43,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /** Timeout for autoexec script downloads */ -#define EFI_AUTOEXEC_TIMEOUT ( 2 * TICKS_PER_SEC ) +#define EFI_AUTOEXEC_TIMEOUT ( 30 * TICKS_PER_SEC ) + +/** Timeout for autoexec pending operation completion */ +#define EFI_AUTOEXEC_SYNC_TIMEOUT ( 1 * TICKS_PER_SEC ) /** Autoexec script image name */ #define EFI_AUTOEXEC_NAME "autoexec.ipxe" @@ -136,7 +139,7 @@ static int efi_autoexec_network ( EFI_HANDLE handle, struct image **image ) { } /* Ensure network exchanges have completed */ - sync ( EFI_AUTOEXEC_TIMEOUT ); + sync ( EFI_AUTOEXEC_SYNC_TIMEOUT ); err_open: err_cwuri: -- cgit v1.2.3-55-g7522 From 12ea8c40741786ea33c866d131d510ae70897728 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Feb 2025 14:04:06 +0000 Subject: [cpio] Allow for construction of parent directories as needed iPXE allows individual raw files to be automatically wrapped with suitable CPIO headers and injected into the magic initrd image as exposed to a booted Linux kernel. This feature is currently limited to placing files within directories that already exist in the initrd filesystem. Remove this limitation by adding the ability for iPXE to construct CPIO headers for parent directories as needed, under control of the "mkdir=" command-line argument. For example: initrd config.ign /usr/share/oem/config.ign mkdir=1 will create CPIO headers for the "/usr/share/oem" directory as well as for the "/usr/share/oem/config.ign" file itself. This simplifies the process of booting operating systems such as Flatcar Linux, which otherwise require the single "config.ign" file to be manually wrapped up as a CPIO archive solely in order to create the relevant parent directory entries. The value may be used to control the number of parent directory entries that are created. For example, "mkdir=2" would cause up to two parent directories to be created (i.e. "/usr/share" and "/usr/share/oem" in the above example). A negative value such as "mkdir=-1" may be used to create all parent directories up to the root of the tree. Do not create any parent directory entries by default, since doing so would potentially cause the modes and ownership information for existing directories to be overwritten. Signed-off-by: Michael Brown --- src/arch/x86/image/bzimage.c | 37 +++++++----- src/core/cpio.c | 135 +++++++++++++++++++++++++++++++++---------- src/include/ipxe/cpio.h | 25 +++++++- src/interface/efi/efi_file.c | 16 ++--- 4 files changed, 161 insertions(+), 52 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index 2c776147d..d2534bdad 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -353,24 +353,35 @@ static size_t bzimage_load_initrd ( struct image *image, const char *filename = cpio_name ( initrd ); struct cpio_header cpio; size_t offset; + size_t cpio_len; size_t pad_len; + size_t len; + unsigned int i; /* Skip hidden images */ if ( initrd->flags & IMAGE_HIDDEN ) return 0; - /* Create cpio header for non-prebuilt images */ - offset = cpio_header ( initrd, &cpio ); + /* Determine length of cpio headers for non-prebuilt images */ + len = 0; + for ( i = 0 ; ( cpio_len = cpio_header ( initrd, i, &cpio ) ) ; i++ ) + len += ( cpio_len + cpio_pad_len ( cpio_len ) ); - /* Copy in initrd image body (and cpio header if applicable) */ + /* Copy in initrd image body and construct any cpio headers */ if ( address ) { - memmove_user ( address, offset, initrd->data, 0, initrd->len ); - if ( offset ) { - memset_user ( address, 0, 0, offset ); - copy_to_user ( address, 0, &cpio, sizeof ( cpio ) ); - copy_to_user ( address, sizeof ( cpio ), filename, - cpio_name_len ( initrd ) ); + memmove_user ( address, len, initrd->data, 0, initrd->len ); + memset_user ( address, 0, 0, len ); + offset = 0; + for ( i = 0 ; ( cpio_len = cpio_header ( initrd, i, &cpio ) ) ; + i++ ) { + copy_to_user ( address, offset, &cpio, + sizeof ( cpio ) ); + copy_to_user ( address, ( offset + sizeof ( cpio ) ), + filename, + ( cpio_len - sizeof ( cpio ) ) ); + offset += ( cpio_len + cpio_pad_len ( cpio_len ) ); } + assert ( offset == len ); DBGC ( image, "bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)" "%s%s\n", image, initrd, user_to_phys ( address, 0 ), user_to_phys ( address, offset ), @@ -379,14 +390,14 @@ static size_t bzimage_load_initrd ( struct image *image, DBGC2_MD5A ( image, user_to_phys ( address, offset ), user_to_virt ( address, offset ), initrd->len ); } - offset += initrd->len; + len += initrd->len; /* Zero-pad to next INITRD_ALIGN boundary */ - pad_len = ( ( -offset ) & ( INITRD_ALIGN - 1 ) ); + pad_len = ( ( -len ) & ( INITRD_ALIGN - 1 ) ); if ( address ) - memset_user ( address, offset, 0, pad_len ); + memset_user ( address, len, 0, pad_len ); - return offset; + return len; } /** diff --git a/src/core/cpio.c b/src/core/cpio.c index 4b607e260..4a7061960 100644 --- a/src/core/cpio.c +++ b/src/core/cpio.c @@ -34,13 +34,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +/** CPIO default file mode */ +#define CPIO_DEFAULT_MODE 0644 + +/** CPIO directory mode */ +#define CPIO_DEFAULT_DIR_MODE 0755 + /** * Set field within a CPIO header * * @v field Field within CPIO header * @v value Value to set */ -void cpio_set_field ( char *field, unsigned long value ) { +static void cpio_set_field ( char *field, unsigned long value ) { char buf[9]; snprintf ( buf, sizeof ( buf ), "%08lx", value ); @@ -48,23 +54,49 @@ void cpio_set_field ( char *field, unsigned long value ) { } /** - * Get CPIO image filename + * Get maximum number of CPIO headers (i.e. number of path components) * * @v image Image - * @ret len CPIO filename length (0 for no filename) + * @ret max Maximum number of CPIO headers */ -size_t cpio_name_len ( struct image *image ) { +static unsigned int cpio_max ( struct image *image ) { const char *name = cpio_name ( image ); - char *sep; - size_t len; + unsigned int max = 0; + char c; /* Check for existence of CPIO filename */ if ( ! name ) return 0; - /* Locate separator (if any) */ - sep = strchr ( name, ' ' ); - len = ( sep ? ( ( size_t ) ( sep - name ) ) : strlen ( name ) ); + /* Count number of path separators */ + while ( ( ( c = *(name++) ) ) && ( c != ' ' ) ) { + if ( c == '/' ) + max++; + } + + return max; +} + +/** + * Get CPIO image filename + * + * @v image Image + * @v depth Path depth + * @ret len Filename length + */ +static size_t cpio_name_len ( struct image *image, unsigned int depth ) { + const char *name = cpio_name ( image ); + size_t len; + char c; + + /* Sanity check */ + assert ( name != NULL ); + + /* Calculate length up to specified path depth */ + for ( len = 0 ; ( ( ( c = name[len] ) ) && ( c != ' ' ) ) ; len++ ) { + if ( ( c == '/' ) && ( depth-- == 0 ) ) + break; + } return len; } @@ -73,55 +105,100 @@ size_t cpio_name_len ( struct image *image ) { * Parse CPIO image parameters * * @v image Image - * @v cpio CPIO header to fill in + * @v mode Mode to fill in + * @v count Number of CPIO headers to fill in */ -static void cpio_parse_cmdline ( struct image *image, - struct cpio_header *cpio ) { +static void cpio_parse_cmdline ( struct image *image, unsigned int *mode, + unsigned int *count ) { const char *arg; char *end; - unsigned int mode; - /* Look for "mode=" */ + /* Set default values */ + *mode = CPIO_DEFAULT_MODE; + *count = 1; + + /* Parse "mode=...", if present */ if ( ( arg = image_argument ( image, "mode=" ) ) ) { - mode = strtoul ( arg, &end, 8 /* Octal for file mode */ ); + *mode = strtoul ( arg, &end, 8 /* Octal for file mode */ ); if ( *end && ( *end != ' ' ) ) { DBGC ( image, "CPIO %p strange \"mode=\" " "terminator '%c'\n", image, *end ); } - cpio_set_field ( cpio->c_mode, ( 0100000 | mode ) ); } + + /* Parse "mkdir=...", if present */ + if ( ( arg = image_argument ( image, "mkdir=" ) ) ) { + *count += strtoul ( arg, &end, 10 ); + if ( *end && ( *end != ' ' ) ) { + DBGC ( image, "CPIO %p strange \"mkdir=\" " + "terminator '%c'\n", image, *end ); + } + } + + /* Allow "mkdir=-1" to request creation of full directory tree */ + if ( ! *count ) + *count = -1U; } /** * Construct CPIO header for image, if applicable * * @v image Image + * @v index CPIO header index * @v cpio CPIO header to fill in - * @ret len Length of magic CPIO header (including filename) + * @ret len Length of CPIO header (including name, excluding NUL) */ -size_t cpio_header ( struct image *image, struct cpio_header *cpio ) { +size_t cpio_header ( struct image *image, unsigned int index, + struct cpio_header *cpio ) { + const char *name = cpio_name ( image ); + unsigned int mode; + unsigned int count; + unsigned int max; + unsigned int depth; + unsigned int i; size_t name_len; size_t len; - /* Get filename length */ - name_len = cpio_name_len ( image ); + /* Parse command line arguments */ + cpio_parse_cmdline ( image, &mode, &count ); - /* Images with no filename are assumed to already be CPIO archives */ - if ( ! name_len ) + /* Determine number of CPIO headers to be constructed */ + max = cpio_max ( image ); + if ( count > max ) + count = max; + + /* Determine path depth of this CPIO header */ + if ( index >= count ) return 0; + depth = ( max - count + index + 1 ); + + /* Get filename length */ + name_len = cpio_name_len ( image, depth ); + + /* Calculate mode and length */ + if ( depth < max ) { + /* Directory */ + mode = ( CPIO_MODE_DIR | CPIO_DEFAULT_DIR_MODE ); + len = 0; + } else { + /* File */ + mode |= CPIO_MODE_FILE; + len = image->len; + } /* Construct CPIO header */ memset ( cpio, '0', sizeof ( *cpio ) ); memcpy ( cpio->c_magic, CPIO_MAGIC, sizeof ( cpio->c_magic ) ); - cpio_set_field ( cpio->c_mode, 0100644 ); + cpio_set_field ( cpio->c_mode, mode ); cpio_set_field ( cpio->c_nlink, 1 ); - cpio_set_field ( cpio->c_filesize, image->len ); + cpio_set_field ( cpio->c_filesize, len ); cpio_set_field ( cpio->c_namesize, ( name_len + 1 /* NUL */ ) ); - cpio_parse_cmdline ( image, cpio ); + DBGC ( image, "CPIO %s %d/%d \"", image->name, depth, max ); + for ( i = 0 ; i < name_len ; i++ ) + DBGC ( image, "%c", name[i] ); + DBGC ( image, "\"\n" ); + DBGC2_HDA ( image, 0, cpio, sizeof ( *cpio ) ); /* Calculate total length */ - len = ( ( sizeof ( *cpio ) + name_len + 1 /* NUL */ + CPIO_ALIGN - 1 ) - & ~( CPIO_ALIGN - 1 ) ); - - return len; + return ( sizeof ( *cpio ) + name_len ); } diff --git a/src/include/ipxe/cpio.h b/src/include/ipxe/cpio.h index 9c5e22d5a..c45c12b11 100644 --- a/src/include/ipxe/cpio.h +++ b/src/include/ipxe/cpio.h @@ -9,6 +9,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include /** A CPIO archive header @@ -50,6 +51,12 @@ struct cpio_header { /** CPIO magic */ #define CPIO_MAGIC "070701" +/** CPIO type for regular files */ +#define CPIO_MODE_FILE 0100000 + +/** CPIO type for directories */ +#define CPIO_MODE_DIR 0040000 + /** CPIO header length alignment */ #define CPIO_ALIGN 4 @@ -67,8 +74,20 @@ cpio_name ( struct image *image ) { return image->cmdline; } -extern void cpio_set_field ( char *field, unsigned long value ); -extern size_t cpio_name_len ( struct image *image ); -extern size_t cpio_header ( struct image *image, struct cpio_header *cpio ); +/** + * Get CPIO header zero-padding length + * + * @v len Length of CPIO header (including name, excluding NUL) + * @ret pad_len Padding length + */ +static inline __attribute__ (( always_inline )) size_t +cpio_pad_len ( size_t len ) { + + /* Pad by at least one byte (for name's terminating NUL) */ + return ( CPIO_ALIGN - ( len % CPIO_ALIGN ) ); +} + +extern size_t cpio_header ( struct image *image, unsigned int index, + struct cpio_header *cpio ); #endif /* _IPXE_CPIO_H */ diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 2ae3a0cb4..e10c2ec4e 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -245,6 +245,7 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) { size_t cpio_len; size_t name_len; size_t len; + unsigned int i; /* Read from file */ len = 0; @@ -263,15 +264,16 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) { } len += efi_file_read_chunk ( reader, UNULL, pad_len ); - /* Read CPIO header, if applicable */ - cpio_len = cpio_header ( image, &cpio ); - if ( cpio_len ) { - name = cpio_name ( image ); - name_len = cpio_name_len ( image ); - pad_len = ( cpio_len - sizeof ( cpio ) - name_len ); + /* Read CPIO header(s), if applicable */ + name = cpio_name ( image ); + for ( i = 0 ; ( cpio_len = cpio_header ( image, i, &cpio ) ); + i++ ) { + name_len = ( cpio_len - sizeof ( cpio ) ); + pad_len = cpio_pad_len ( cpio_len ); DBGC ( file, "EFIFILE %s [%#08zx,%#08zx) %s header\n", efi_file_name ( file ), reader->pos, - ( reader->pos + cpio_len ), image->name ); + ( reader->pos + cpio_len + pad_len ), + image->name ); len += efi_file_read_chunk ( reader, virt_to_user ( &cpio ), sizeof ( cpio ) ); -- cgit v1.2.3-55-g7522 From 8706ae36d3bbfaee3ac0e79555f68ac43e1da1af Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 10 Mar 2025 11:20:15 +0000 Subject: [efi] Add EFI_SIGNATURE_LIST header and GUID definitions Signed-off-by: Michael Brown --- src/include/ipxe/efi/Guid/GlobalVariable.h | 194 ++++++++++++ src/include/ipxe/efi/Guid/ImageAuthentication.h | 387 ++++++++++++++++++++++++ src/include/ipxe/efi/Protocol/Hash.h | 171 +++++++++++ src/include/ipxe/efi/efi.h | 1 + src/interface/efi/efi_debug.c | 2 + src/interface/efi/efi_guid.c | 4 + 6 files changed, 759 insertions(+) create mode 100644 src/include/ipxe/efi/Guid/GlobalVariable.h create mode 100644 src/include/ipxe/efi/Guid/ImageAuthentication.h create mode 100644 src/include/ipxe/efi/Protocol/Hash.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Guid/GlobalVariable.h b/src/include/ipxe/efi/Guid/GlobalVariable.h new file mode 100644 index 000000000..e8f4e0d2b --- /dev/null +++ b/src/include/ipxe/efi/Guid/GlobalVariable.h @@ -0,0 +1,194 @@ +/** @file + GUID for EFI (NVRAM) Variables. + + Copyright (c) 2006 - 2024, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + GUID defined in UEFI 2.1 +**/ + +#ifndef __GLOBAL_VARIABLE_GUID_H__ +#define __GLOBAL_VARIABLE_GUID_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#define EFI_GLOBAL_VARIABLE \ + { \ + 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C } \ + } + +extern EFI_GUID gEfiGlobalVariableGuid; + +// +// Follow UEFI 2.4 spec: +// To prevent name collisions with possible future globally defined variables, +// other internal firmware data variables that are not defined here must be +// saved with a unique VendorGuid other than EFI_GLOBAL_VARIABLE or +// any other GUID defined by the UEFI Specification. Implementations must +// only permit the creation of variables with a UEFI Specification-defined +// VendorGuid when these variables are documented in the UEFI Specification. +// +// Note: except the globally defined variables defined below, the spec also defines +// L"Boot####" - A boot load option. +// L"Driver####" - A driver load option. +// L"SysPrep####" - A System Prep application load option. +// L"Key####" - Describes hot key relationship with a Boot#### load option. +// The attribute for them is NV+BS+RT, #### is a printed hex value, and no 0x or h +// is included in the hex value. They can not be expressed as a #define like other globally +// defined variables, it is because we can not list the Boot0000, Boot0001, etc one by one. +// + +/// +/// The language codes that the firmware supports. This value is deprecated. +/// Its attribute is BS+RT. +/// +#define EFI_LANG_CODES_VARIABLE_NAME L"LangCodes" +/// +/// The language code that the system is configured for. This value is deprecated. +/// Its attribute is NV+BS+RT. +/// +#define EFI_LANG_VARIABLE_NAME L"Lang" +/// +/// The firmware's boot managers timeout, in seconds, before initiating the default boot selection. +/// Its attribute is NV+BS+RT. +/// +#define EFI_TIME_OUT_VARIABLE_NAME L"Timeout" +/// +/// The language codes that the firmware supports. +/// Its attribute is BS+RT. +/// +#define EFI_PLATFORM_LANG_CODES_VARIABLE_NAME L"PlatformLangCodes" +/// +/// The language code that the system is configured for. +/// Its attribute is NV+BS+RT. +/// +#define EFI_PLATFORM_LANG_VARIABLE_NAME L"PlatformLang" +/// +/// The device path of the default input/output/error output console. +/// Its attribute is NV+BS+RT. +/// +#define EFI_CON_IN_VARIABLE_NAME L"ConIn" +#define EFI_CON_OUT_VARIABLE_NAME L"ConOut" +#define EFI_ERR_OUT_VARIABLE_NAME L"ErrOut" +/// +/// The device path of all possible input/output/error output devices. +/// Its attribute is BS+RT. +/// +#define EFI_CON_IN_DEV_VARIABLE_NAME L"ConInDev" +#define EFI_CON_OUT_DEV_VARIABLE_NAME L"ConOutDev" +#define EFI_ERR_OUT_DEV_VARIABLE_NAME L"ErrOutDev" +/// +/// The ordered boot option load list. +/// Its attribute is NV+BS+RT. +/// +#define EFI_BOOT_ORDER_VARIABLE_NAME L"BootOrder" +/// +/// The boot option for the next boot only. +/// Its attribute is NV+BS+RT. +/// +#define EFI_BOOT_NEXT_VARIABLE_NAME L"BootNext" +/// +/// The boot option that was selected for the current boot. +/// Its attribute is BS+RT. +/// +#define EFI_BOOT_CURRENT_VARIABLE_NAME L"BootCurrent" +/// +/// The types of boot options supported by the boot manager. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_BOOT_OPTION_SUPPORT_VARIABLE_NAME L"BootOptionSupport" +/// +/// The ordered driver load option list. +/// Its attribute is NV+BS+RT. +/// +#define EFI_DRIVER_ORDER_VARIABLE_NAME L"DriverOrder" +/// +/// The ordered System Prep Application load option list. +/// Its attribute is NV+BS+RT. +/// +#define EFI_SYS_PREP_ORDER_VARIABLE_NAME L"SysPrepOrder" +/// +/// Identifies the level of hardware error record persistence +/// support implemented by the platform. This variable is +/// only modified by firmware and is read-only to the OS. +/// Its attribute is NV+BS+RT. +/// +#define EFI_HW_ERR_REC_SUPPORT_VARIABLE_NAME L"HwErrRecSupport" +/// +/// Whether the system is operating in setup mode (1) or not (0). +/// All other values are reserved. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_SETUP_MODE_NAME L"SetupMode" +/// +/// The Key Exchange Key Signature Database. +/// Its attribute is NV+BS+RT+AT. +/// +#define EFI_KEY_EXCHANGE_KEY_NAME L"KEK" +/// +/// The public Platform Key. +/// Its attribute is NV+BS+RT+AT. +/// +#define EFI_PLATFORM_KEY_NAME L"PK" +/// +/// Array of GUIDs representing the type of signatures supported +/// by the platform firmware. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_SIGNATURE_SUPPORT_NAME L"SignatureSupport" +/// +/// Whether the platform firmware is operating in Secure boot mode (1) or not (0). +/// All other values are reserved. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_SECURE_BOOT_MODE_NAME L"SecureBoot" +/// +/// The OEM's default Key Exchange Key Signature Database. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_KEK_DEFAULT_VARIABLE_NAME L"KEKDefault" +/// +/// The OEM's default public Platform Key. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_PK_DEFAULT_VARIABLE_NAME L"PKDefault" +/// +/// The OEM's default secure boot signature store. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_DB_DEFAULT_VARIABLE_NAME L"dbDefault" +/// +/// The OEM's default secure boot blacklist signature store. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_DBX_DEFAULT_VARIABLE_NAME L"dbxDefault" +/// +/// The OEM's default secure boot timestamp signature store. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_DBT_DEFAULT_VARIABLE_NAME L"dbtDefault" +/// +/// Allows the firmware to indicate supported features and actions to the OS. +/// Its attribute is BS+RT. +/// +#define EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME L"OsIndicationsSupported" +/// +/// Allows the OS to request the firmware to enable certain features and to take certain actions. +/// Its attribute is NV+BS+RT. +/// +#define EFI_OS_INDICATIONS_VARIABLE_NAME L"OsIndications" +/// +/// Whether the system is configured to use only vendor provided +/// keys or not. Should be treated as read-only. +/// Its attribute is BS+RT. +/// +#define EFI_VENDOR_KEYS_VARIABLE_NAME L"VendorKeys" + +/// +/// Whether the platform firmware is operating in device authentication boot mode (1) or not (0). +/// The content is UINT8. +/// +#define EFI_DEVICE_AUTH_BOOT_MODE_NAME L"devAuthBoot" + +#endif diff --git a/src/include/ipxe/efi/Guid/ImageAuthentication.h b/src/include/ipxe/efi/Guid/ImageAuthentication.h new file mode 100644 index 000000000..9af0b41af --- /dev/null +++ b/src/include/ipxe/efi/Guid/ImageAuthentication.h @@ -0,0 +1,387 @@ +/** @file + Image signature database are defined for the signed image validation. + + Copyright (c) 2009 - 2024, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + GUIDs defined in UEFI 2.5 spec. +**/ + +#ifndef __IMAGE_AUTHTICATION_H__ +#define __IMAGE_AUTHTICATION_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#include +#include + +#define EFI_IMAGE_SECURITY_DATABASE_GUID \ + { \ + 0xd719b2cb, 0x3d3a, 0x4596, { 0xa3, 0xbc, 0xda, 0xd0, 0xe, 0x67, 0x65, 0x6f } \ + } + +/// +/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID +/// for the authorized signature database. +/// +#define EFI_IMAGE_SECURITY_DATABASE L"db" +/// +/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID +/// for the forbidden signature database. +/// +#define EFI_IMAGE_SECURITY_DATABASE1 L"dbx" +/// +/// Variable name with guid EFI_IMAGE_SECURITY_DATABASE_GUID +/// for the timestamp signature database. +/// +#define EFI_IMAGE_SECURITY_DATABASE2 L"dbt" + +#define SECURE_BOOT_MODE_ENABLE 1 +#define SECURE_BOOT_MODE_DISABLE 0 + +#define SETUP_MODE 1 +#define USER_MODE 0 + +#define DEVICE_AUTH_BOOT_MODE_ENABLE 1 +#define DEVICE_AUTH_BOOT_MODE_DISABLE 0 + +// *********************************************************************** +// Signature Database +// *********************************************************************** +/// +/// The format of a signature database. +/// +#pragma pack(1) + +typedef struct { + /// + /// An identifier which identifies the agent which added the signature to the list. + /// + EFI_GUID SignatureOwner; + /// + /// The format of the signature is defined by the SignatureType. + /// + UINT8 SignatureData[1]; +} EFI_SIGNATURE_DATA; + +typedef struct { + /// + /// Type of the signature. GUID signature types are defined in below. + /// + EFI_GUID SignatureType; + /// + /// Total size of the signature list, including this header. + /// + UINT32 SignatureListSize; + /// + /// Size of the signature header which precedes the array of signatures. + /// + UINT32 SignatureHeaderSize; + /// + /// Size of each signature. + /// + UINT32 SignatureSize; + /// + /// Header before the array of signatures. The format of this header is specified + /// by the SignatureType. + /// UINT8 SignatureHeader[SignatureHeaderSize]; + /// + /// An array of signatures. Each signature is SignatureSize bytes in length. + /// EFI_SIGNATURE_DATA Signatures[][SignatureSize]; + /// +} EFI_SIGNATURE_LIST; + +typedef struct { + /// + /// The SHA256 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SHA256_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SHA256; + +typedef struct { + /// + /// The SHA384 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SHA384_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SHA384; + +typedef struct { + /// + /// The SHA512 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SHA512_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SHA512; + +typedef UINT8 EFI_SM3_HASH[32]; + +typedef struct { + /// + /// The SM3 hash of an X.509 certificate's To-Be-Signed contents. + /// + EFI_SM3_HASH ToBeSignedHash; + /// + /// The time that the certificate shall be considered to be revoked. + /// + EFI_TIME TimeOfRevocation; +} EFI_CERT_X509_SM3; + +#pragma pack() + +/// +/// This identifies a signature containing a SHA-256 hash. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) + +/// 32 bytes. +/// +#define EFI_CERT_SHA256_GUID \ + { \ + 0xc1c41626, 0x504c, 0x4092, {0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28} \ + } + +/// +/// This identifies a signature containing an RSA-2048 key. The key (only the modulus +/// since the public key exponent is known to be 0x10001) shall be stored in big-endian +/// order. +/// The SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size +/// of SignatureOwner component) + 256 bytes. +/// +#define EFI_CERT_RSA2048_GUID \ + { \ + 0x3c5766e8, 0x269c, 0x4e34, {0xaa, 0x14, 0xed, 0x77, 0x6e, 0x85, 0xb3, 0xb6} \ + } + +/// +/// This identifies a signature containing a RSA-2048 signature of a SHA-256 hash. The +/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of +/// SignatureOwner component) + 256 bytes. +/// +#define EFI_CERT_RSA2048_SHA256_GUID \ + { \ + 0xe2b36190, 0x879b, 0x4a3d, {0xad, 0x8d, 0xf2, 0xe7, 0xbb, 0xa3, 0x27, 0x84} \ + } + +/// +/// This identifies a signature containing a SHA-1 hash. The SignatureSize shall always +/// be 16 (size of SignatureOwner component) + 20 bytes. +/// +#define EFI_CERT_SHA1_GUID \ + { \ + 0x826ca512, 0xcf10, 0x4ac9, {0xb1, 0x87, 0xbe, 0x1, 0x49, 0x66, 0x31, 0xbd} \ + } + +/// +/// This identifies a signature containing a SM3 hash. The SignatureSize shall always +/// be 16 (size of SignatureOwner component) + 32 bytes. +/// +#define EFI_CERT_SM3_GUID \ + { \ + 0x57347f87, 0x7a9b, 0x403a, { 0xb9, 0x3c, 0xdc, 0x4a, 0xfb, 0x7a, 0xe, 0xbc } \ + } + +/// +/// TThis identifies a signature containing a RSA-2048 signature of a SHA-1 hash. The +/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of +/// SignatureOwner component) + 256 bytes. +/// +#define EFI_CERT_RSA2048_SHA1_GUID \ + { \ + 0x67f8444f, 0x8743, 0x48f1, {0xa3, 0x28, 0x1e, 0xaa, 0xb8, 0x73, 0x60, 0x80} \ + } + +/// +/// This identifies a signature based on an X.509 certificate. If the signature is an X.509 +/// certificate then verification of the signature of an image should validate the public +/// key certificate in the image using certificate path verification, up to this X.509 +/// certificate as a trusted root. The SignatureHeader size shall always be 0. The +/// SignatureSize may vary but shall always be 16 (size of the SignatureOwner component) + +/// the size of the certificate itself. +/// Note: This means that each certificate will normally be in a separate EFI_SIGNATURE_LIST. +/// +#define EFI_CERT_X509_GUID \ + { \ + 0xa5c059a1, 0x94e4, 0x4aa7, {0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72} \ + } + +/// +/// This identifies a signature containing the SM3 hash of an X.509 certificate's To-Be-Signed +/// contents, and a time of revocation. The SignatureHeader size shall always be 0. The +/// SignatureSize shall always be 16 (size of the SignatureOwner component) + 32 bytes for +/// an EFI_CERT_X509_SM3 structure. If the TimeOfRevocation is non-zero, the certificate should +/// be considered to be revoked from that time and onwards, and otherwise the certificate shall +/// be considered to always be revoked. +/// +#define EFI_CERT_X509_SM3_GUID \ + { \ + 0x60d807e5, 0x10b4, 0x49a9, {0x93, 0x31, 0xe4, 0x4, 0x37, 0x88, 0x8d, 0x37 } \ + } + +/// +/// This identifies a signature containing a SHA-224 hash. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) + +/// 28 bytes. +/// +#define EFI_CERT_SHA224_GUID \ + { \ + 0xb6e5233, 0xa65c, 0x44c9, {0x94, 0x7, 0xd9, 0xab, 0x83, 0xbf, 0xc8, 0xbd} \ + } + +/// +/// This identifies a signature containing a SHA-384 hash. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) + +/// 48 bytes. +/// +#define EFI_CERT_SHA384_GUID \ + { \ + 0xff3e5307, 0x9fd0, 0x48c9, {0x85, 0xf1, 0x8a, 0xd5, 0x6c, 0x70, 0x1e, 0x1} \ + } + +/// +/// This identifies a signature containing a SHA-512 hash. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) + +/// 64 bytes. +/// +#define EFI_CERT_SHA512_GUID \ + { \ + 0x93e0fae, 0xa6c4, 0x4f50, {0x9f, 0x1b, 0xd4, 0x1e, 0x2b, 0x89, 0xc1, 0x9a} \ + } + +/// +/// This identifies a signature containing the SHA256 hash of an X.509 certificate's +/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component) +/// + 48 bytes for an EFI_CERT_X509_SHA256 structure. If the TimeOfRevocation is non-zero, +/// the certificate should be considered to be revoked from that time and onwards, and +/// otherwise the certificate shall be considered to always be revoked. +/// +#define EFI_CERT_X509_SHA256_GUID \ + { \ + 0x3bd2a492, 0x96c0, 0x4079, {0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed } \ + } + +/// +/// This identifies a signature containing the SHA384 hash of an X.509 certificate's +/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component) +/// + 64 bytes for an EFI_CERT_X509_SHA384 structure. If the TimeOfRevocation is non-zero, +/// the certificate should be considered to be revoked from that time and onwards, and +/// otherwise the certificate shall be considered to always be revoked. +/// +#define EFI_CERT_X509_SHA384_GUID \ + { \ + 0x7076876e, 0x80c2, 0x4ee6, {0xaa, 0xd2, 0x28, 0xb3, 0x49, 0xa6, 0x86, 0x5b } \ + } + +/// +/// This identifies a signature containing the SHA512 hash of an X.509 certificate's +/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall +/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component) +/// + 80 bytes for an EFI_CERT_X509_SHA512 structure. If the TimeOfRevocation is non-zero, +/// the certificate should be considered to be revoked from that time and onwards, and +/// otherwise the certificate shall be considered to always be revoked. +/// +#define EFI_CERT_X509_SHA512_GUID \ + { \ + 0x446dbf63, 0x2502, 0x4cda, {0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d } \ + } + +/// +/// This identifies a signature containing a DER-encoded PKCS #7 version 1.5 [RFC2315] +/// SignedData value. +/// +#define EFI_CERT_TYPE_PKCS7_GUID \ + { \ + 0x4aafd29d, 0x68df, 0x49ee, {0x8a, 0xa9, 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7} \ + } + +// *********************************************************************** +// Image Execution Information Table Definition +// *********************************************************************** +typedef UINT32 EFI_IMAGE_EXECUTION_ACTION; + +#define EFI_IMAGE_EXECUTION_AUTHENTICATION 0x00000007 +#define EFI_IMAGE_EXECUTION_AUTH_UNTESTED 0x00000000 +#define EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED 0x00000001 +#define EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED 0x00000002 +#define EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND 0x00000003 +#define EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND 0x00000004 +#define EFI_IMAGE_EXECUTION_POLICY_FAILED 0x00000005 +#define EFI_IMAGE_EXECUTION_INITIALIZED 0x00000008 + +// +// EFI_IMAGE_EXECUTION_INFO is added to EFI System Configuration Table +// and assigned the GUID EFI_IMAGE_SECURITY_DATABASE_GUID. +// +typedef struct { + /// + /// Describes the action taken by the firmware regarding this image. + /// + EFI_IMAGE_EXECUTION_ACTION Action; + /// + /// Size of all of the entire structure. + /// + UINT32 InfoSize; + /// + /// If this image was a UEFI device driver (for option ROM, for example) this is the + /// null-terminated, user-friendly name for the device. If the image was for an application, + /// then this is the name of the application. If this cannot be determined, then a simple + /// NULL character should be put in this position. + /// CHAR16 Name[]; + /// + + /// + /// For device drivers, this is the device path of the device for which this device driver + /// was intended. In some cases, the driver itself may be stored as part of the system + /// firmware, but this field should record the device's path, not the firmware path. For + /// applications, this is the device path of the application. If this cannot be determined, + /// a simple end-of-path device node should be put in this position. + /// EFI_DEVICE_PATH_PROTOCOL DevicePath; + /// + + /// + /// Zero or more image signatures. If the image contained no signatures, + /// then this field is empty. + /// EFI_SIGNATURE_LIST Signature; + /// +} EFI_IMAGE_EXECUTION_INFO; + +typedef struct { + /// + /// Number of EFI_IMAGE_EXECUTION_INFO structures. + /// + UINTN NumberOfImages; + /// + /// Number of image instances of EFI_IMAGE_EXECUTION_INFO structures. + /// + // EFI_IMAGE_EXECUTION_INFO InformationInfo[] +} EFI_IMAGE_EXECUTION_INFO_TABLE; + +extern EFI_GUID gEfiImageSecurityDatabaseGuid; +extern EFI_GUID gEfiCertSha256Guid; +extern EFI_GUID gEfiCertRsa2048Guid; +extern EFI_GUID gEfiCertRsa2048Sha256Guid; +extern EFI_GUID gEfiCertSha1Guid; +extern EFI_GUID gEfiCertRsa2048Sha1Guid; +extern EFI_GUID gEfiCertX509Guid; +extern EFI_GUID gEfiCertSha224Guid; +extern EFI_GUID gEfiCertSha384Guid; +extern EFI_GUID gEfiCertSha512Guid; +extern EFI_GUID gEfiCertX509Sha256Guid; +extern EFI_GUID gEfiCertX509Sha384Guid; +extern EFI_GUID gEfiCertX509Sha512Guid; +extern EFI_GUID gEfiCertPkcs7Guid; +extern EFI_GUID gEfiCertSm3Guid; +extern EFI_GUID gEfiCertX509Sm3Guid; + +#endif diff --git a/src/include/ipxe/efi/Protocol/Hash.h b/src/include/ipxe/efi/Protocol/Hash.h new file mode 100644 index 000000000..ac6dcd193 --- /dev/null +++ b/src/include/ipxe/efi/Protocol/Hash.h @@ -0,0 +1,171 @@ +/** @file + EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0. + EFI_HASH_PROTOCOL as defined in UEFI 2.0. + The EFI Hash Service Binding Protocol is used to locate hashing services support + provided by a driver and to create and destroy instances of the EFI Hash Protocol + so that a multiple drivers can use the underlying hashing services. + +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __EFI_HASH_PROTOCOL_H__ +#define __EFI_HASH_PROTOCOL_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#define EFI_HASH_SERVICE_BINDING_PROTOCOL_GUID \ + { \ + 0x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \ + } + +#define EFI_HASH_PROTOCOL_GUID \ + { \ + 0xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \ + } + +#define EFI_HASH_ALGORITHM_SHA1_GUID \ + { \ + 0x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \ + } + +#define EFI_HASH_ALGORITHM_SHA224_GUID \ + { \ + 0x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \ + } + +#define EFI_HASH_ALGORITHM_SHA256_GUID \ + { \ + 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \ + } + +#define EFI_HASH_ALGORITHM_SHA384_GUID \ + { \ + 0xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \ + } + +#define EFI_HASH_ALGORITHM_SHA512_GUID \ + { \ + 0xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \ + } + +#define EFI_HASH_ALGORTIHM_MD5_GUID \ + { \ + 0xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \ + } + +#define EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID \ + { \ + 0x24c5dc2f, 0x53e2, 0x40ca, {0x9e, 0xd6, 0xa5, 0xd9, 0xa4, 0x9f, 0x46, 0x3b } \ + } + +#define EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID \ + { \ + 0x8628752a, 0x6cb7, 0x4814, {0x96, 0xfc, 0x24, 0xa8, 0x15, 0xac, 0x22, 0x26 } \ + } + +// +// Note: Use of the following algorithms with EFI_HASH_PROTOCOL is deprecated. +// EFI_HASH_ALGORITHM_SHA1_GUID +// EFI_HASH_ALGORITHM_SHA224_GUID +// EFI_HASH_ALGORITHM_SHA256_GUID +// EFI_HASH_ALGORITHM_SHA384_GUID +// EFI_HASH_ALGORITHM_SHA512_GUID +// EFI_HASH_ALGORTIHM_MD5_GUID +// + +typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL; + +typedef UINT8 EFI_MD5_HASH[16]; +typedef UINT8 EFI_SHA1_HASH[20]; +typedef UINT8 EFI_SHA224_HASH[28]; +typedef UINT8 EFI_SHA256_HASH[32]; +typedef UINT8 EFI_SHA384_HASH[48]; +typedef UINT8 EFI_SHA512_HASH[64]; + +typedef union { + EFI_MD5_HASH *Md5Hash; + EFI_SHA1_HASH *Sha1Hash; + EFI_SHA224_HASH *Sha224Hash; + EFI_SHA256_HASH *Sha256Hash; + EFI_SHA384_HASH *Sha384Hash; + EFI_SHA512_HASH *Sha512Hash; +} EFI_HASH_OUTPUT; + +/** + Returns the size of the hash which results from a specific algorithm. + + @param[in] This Points to this instance of EFI_HASH_PROTOCOL. + @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. + @param[out] HashSize Holds the returned size of the algorithm's hash. + + @retval EFI_SUCCESS Hash size returned successfully. + @retval EFI_INVALID_PARAMETER HashSize is NULL or HashAlgorithm is NULL. + @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported + by this driver. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HASH_GET_HASH_SIZE)( + IN CONST EFI_HASH_PROTOCOL *This, + IN CONST EFI_GUID *HashAlgorithm, + OUT UINTN *HashSize + ); + +/** + Creates a hash for the specified message text. + + @param[in] This Points to this instance of EFI_HASH_PROTOCOL. + @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. + @param[in] Extend Specifies whether to create a new hash (FALSE) or extend the specified + existing hash (TRUE). + @param[in] Message Points to the start of the message. + @param[in] MessageSize The size of Message, in bytes. + @param[in,out] Hash On input, if Extend is TRUE, then this parameter holds a pointer + to a pointer to an array containing the hash to extend. If Extend + is FALSE, then this parameter holds a pointer to a pointer to a + caller-allocated array that will receive the result of the hash + computation. On output (regardless of the value of Extend), the + array will contain the result of the hash computation. + + @retval EFI_SUCCESS Hash returned successfully. + @retval EFI_INVALID_PARAMETER Message or Hash, HashAlgorithm is NULL or MessageSize is 0. + MessageSize is not an integer multiple of block size. + @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this + driver. Or, Extend is TRUE, and the algorithm doesn't support extending the hash. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HASH_HASH)( + IN CONST EFI_HASH_PROTOCOL *This, + IN CONST EFI_GUID *HashAlgorithm, + IN BOOLEAN Extend, + IN CONST UINT8 *Message, + IN UINT64 MessageSize, + IN OUT EFI_HASH_OUTPUT *Hash + ); + +/// +/// This protocol allows creating a hash of an arbitrary message digest +/// using one or more hash algorithms. +/// +struct _EFI_HASH_PROTOCOL { + EFI_HASH_GET_HASH_SIZE GetHashSize; + EFI_HASH_HASH Hash; +}; + +extern EFI_GUID gEfiHashServiceBindingProtocolGuid; +extern EFI_GUID gEfiHashProtocolGuid; +extern EFI_GUID gEfiHashAlgorithmSha1Guid; +extern EFI_GUID gEfiHashAlgorithmSha224Guid; +extern EFI_GUID gEfiHashAlgorithmSha256Guid; +extern EFI_GUID gEfiHashAlgorithmSha384Guid; +extern EFI_GUID gEfiHashAlgorithmSha512Guid; +extern EFI_GUID gEfiHashAlgorithmMD5Guid; +extern EFI_GUID gEfiHashAlgorithmSha1NoPadGuid; +extern EFI_GUID gEfiHashAlgorithmSha256NoPadGuid; + +#endif diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 843c79e2e..ef492849e 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -245,6 +245,7 @@ extern EFI_GUID efi_usb2_hc_protocol_guid; extern EFI_GUID efi_usb_io_protocol_guid; extern EFI_GUID efi_vlan_config_protocol_guid; +extern EFI_GUID efi_cert_x509_guid; extern EFI_GUID efi_file_info_id; extern EFI_GUID efi_file_system_info_id; diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 895a712bd..81c442179 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -103,6 +103,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "BlockIo2" }, { &efi_bus_specific_driver_override_protocol_guid, "BusSpecificDriverOverride" }, + { &efi_cert_x509_guid, + "CertX509" }, { &efi_component_name_protocol_guid, "ComponentName" }, { &efi_component_name2_protocol_guid, diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 16c1a5738..bd45d05b9 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -83,6 +83,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include /** @file * @@ -391,6 +392,9 @@ EFI_GUID efi_usb_io_protocol_guid EFI_GUID efi_vlan_config_protocol_guid = EFI_VLAN_CONFIG_PROTOCOL_GUID; +/** X.509 certificate GUID */ +EFI_GUID efi_cert_x509_guid = EFI_CERT_X509_GUID; + /** File information GUID */ EFI_GUID efi_file_info_id = EFI_FILE_INFO_ID; -- cgit v1.2.3-55-g7522 From 011c778f06fbfa315f8749f39df016d8865422c6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Mar 2025 11:52:37 +0000 Subject: [efi] Allow efi_guid_ntoa() to be used in non-EFI builds The debug message transcription of well-known EFI GUIDs does not require any EFI boot services calls. Move this code from efi_debug.c to efi_guid.c, to allow it to be linked in to non-EFI builds. We continue to rely on linker garbage collection to ensure that the code is omitted completely from any non-debug builds. Signed-off-by: Michael Brown --- src/interface/efi/efi_debug.c | 236 ------------------------------------------ src/interface/efi/efi_guid.c | 236 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+), 236 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 81c442179..030c6a93e 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -31,9 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include -#include #include -#include #include #include #include @@ -47,240 +45,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt; EFI_REQUEST_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt ); -/** HttpBootDxe module GUID */ -static EFI_GUID efi_http_boot_dxe_guid = { - 0xecebcb00, 0xd9c8, 0x11e4, - { 0xaf, 0x3d, 0x8c, 0xdc, 0xd4, 0x26, 0xc9, 0x73 } -}; - -/** IScsiDxe module GUID */ -static EFI_GUID efi_iscsi_dxe_guid = { - 0x86cddf93, 0x4872, 0x4597, - { 0x8a, 0xf9, 0xa3, 0x5a, 0xe4, 0xd3, 0x72, 0x5f } -}; - -/** Old IScsi4Dxe module GUID */ -static EFI_GUID efi_iscsi4_dxe_guid = { - 0x4579b72d, 0x7ec4, 0x4dd4, - { 0x84, 0x86, 0x08, 0x3c, 0x86, 0xb1, 0x82, 0xa7 } -}; - -/** UefiPxeBcDxe module GUID */ -static EFI_GUID efi_uefi_pxe_bc_dxe_guid = { - 0xb95e9fda, 0x26de, 0x48d2, - { 0x88, 0x07, 0x1f, 0x91, 0x07, 0xac, 0x5e, 0x3a } -}; - -/** VlanConfigDxe module GUID */ -static EFI_GUID efi_vlan_config_dxe_guid = { - 0xe4f61863, 0xfe2c, 0x4b56, - { 0xa8, 0xf4, 0x08, 0x51, 0x9b, 0xc4, 0x39, 0xdf } -}; - -/** A well-known GUID */ -struct efi_well_known_guid { - /** GUID */ - EFI_GUID *guid; - /** Name */ - const char *name; -}; - -/** Well-known GUIDs */ -static struct efi_well_known_guid efi_well_known_guids[] = { - { &efi_absolute_pointer_protocol_guid, - "AbsolutePointer" }, - { &efi_acpi_table_protocol_guid, - "AcpiTable" }, - { &efi_apple_net_boot_protocol_guid, - "AppleNetBoot" }, - { &efi_arp_protocol_guid, - "Arp" }, - { &efi_arp_service_binding_protocol_guid, - "ArpSb" }, - { &efi_block_io_protocol_guid, - "BlockIo" }, - { &efi_block_io2_protocol_guid, - "BlockIo2" }, - { &efi_bus_specific_driver_override_protocol_guid, - "BusSpecificDriverOverride" }, - { &efi_cert_x509_guid, - "CertX509" }, - { &efi_component_name_protocol_guid, - "ComponentName" }, - { &efi_component_name2_protocol_guid, - "ComponentName2" }, - { &efi_console_control_protocol_guid, - "ConsoleControl" }, - { &efi_device_path_protocol_guid, - "DevicePath" }, - { &efi_driver_binding_protocol_guid, - "DriverBinding" }, - { &efi_dhcp4_protocol_guid, - "Dhcp4" }, - { &efi_dhcp4_service_binding_protocol_guid, - "Dhcp4Sb" }, - { &efi_dhcp6_protocol_guid, - "Dhcp6" }, - { &efi_dhcp6_service_binding_protocol_guid, - "Dhcp6Sb" }, - { &efi_disk_io_protocol_guid, - "DiskIo" }, - { &efi_dns4_protocol_guid, - "Dns4" }, - { &efi_dns4_service_binding_protocol_guid, - "Dns4Sb" }, - { &efi_dns6_protocol_guid, - "Dns6" }, - { &efi_dns6_service_binding_protocol_guid, - "Dns6Sb" }, - { &efi_graphics_output_protocol_guid, - "GraphicsOutput" }, - { &efi_hii_config_access_protocol_guid, - "HiiConfigAccess" }, - { &efi_hii_font_protocol_guid, - "HiiFont" }, - { &efi_http_boot_dxe_guid, - "HttpBootDxe" }, - { &efi_http_protocol_guid, - "Http" }, - { &efi_http_service_binding_protocol_guid, - "HttpSb" }, - { &efi_ip4_protocol_guid, - "Ip4" }, - { &efi_ip4_config_protocol_guid, - "Ip4Config" }, - { &efi_ip4_config2_protocol_guid, - "Ip4Config2" }, - { &efi_ip4_service_binding_protocol_guid, - "Ip4Sb" }, - { &efi_ip6_protocol_guid, - "Ip6" }, - { &efi_ip6_config_protocol_guid, - "Ip6Config" }, - { &efi_ip6_service_binding_protocol_guid, - "Ip6Sb" }, - { &efi_iscsi_dxe_guid, - "IScsiDxe" }, - { &efi_iscsi4_dxe_guid, - "IScsi4Dxe" }, - { &efi_load_file_protocol_guid, - "LoadFile" }, - { &efi_load_file2_protocol_guid, - "LoadFile2" }, - { &efi_loaded_image_protocol_guid, - "LoadedImage" }, - { &efi_loaded_image_device_path_protocol_guid, - "LoadedImageDevicePath"}, - { &efi_managed_network_protocol_guid, - "ManagedNetwork" }, - { &efi_managed_network_service_binding_protocol_guid, - "ManagedNetworkSb" }, - { &efi_mtftp4_protocol_guid, - "Mtftp4" }, - { &efi_mtftp4_service_binding_protocol_guid, - "Mtftp4Sb" }, - { &efi_mtftp6_protocol_guid, - "Mtftp6" }, - { &efi_mtftp6_service_binding_protocol_guid, - "Mtftp6Sb" }, - { &efi_nii_protocol_guid, - "Nii" }, - { &efi_nii31_protocol_guid, - "Nii31" }, - { &efi_pci_io_protocol_guid, - "PciIo" }, - { &efi_pci_root_bridge_io_protocol_guid, - "PciRootBridgeIo" }, - { &efi_pxe_base_code_protocol_guid, - "PxeBaseCode" }, - { &efi_serial_io_protocol_guid, - "SerialIo" }, - { &efi_shim_lock_protocol_guid, - "ShimLock" }, - { &efi_simple_file_system_protocol_guid, - "SimpleFileSystem" }, - { &efi_simple_network_protocol_guid, - "SimpleNetwork" }, - { &efi_simple_pointer_protocol_guid, - "SimplePointer" }, - { &efi_simple_text_input_protocol_guid, - "SimpleTextInput" }, - { &efi_simple_text_input_ex_protocol_guid, - "SimpleTextInputEx" }, - { &efi_simple_text_output_protocol_guid, - "SimpleTextOutput" }, - { &efi_tcg_protocol_guid, - "Tcg" }, - { &efi_tcg2_protocol_guid, - "Tcg2" }, - { &efi_tcp4_protocol_guid, - "Tcp4" }, - { &efi_tcp4_service_binding_protocol_guid, - "Tcp4Sb" }, - { &efi_tcp6_protocol_guid, - "Tcp6" }, - { &efi_tcp6_service_binding_protocol_guid, - "Tcp6Sb" }, - { &efi_tree_protocol_guid, - "TrEE" }, - { &efi_udp4_protocol_guid, - "Udp4" }, - { &efi_udp4_service_binding_protocol_guid, - "Udp4Sb" }, - { &efi_udp6_protocol_guid, - "Udp6" }, - { &efi_udp6_service_binding_protocol_guid, - "Udp6Sb" }, - { &efi_uefi_pxe_bc_dxe_guid, - "UefiPxeBcDxe" }, - { &efi_uga_draw_protocol_guid, - "UgaDraw" }, - { &efi_unicode_collation_protocol_guid, - "UnicodeCollation" }, - { &efi_usb_hc_protocol_guid, - "UsbHc" }, - { &efi_usb2_hc_protocol_guid, - "Usb2Hc" }, - { &efi_usb_io_protocol_guid, - "UsbIo" }, - { &efi_vlan_config_protocol_guid, - "VlanConfig" }, - { &efi_vlan_config_dxe_guid, - "VlanConfigDxe" }, -}; - -/** - * Convert GUID to a printable string - * - * @v guid GUID - * @ret string Printable string - */ -const __attribute__ (( pure )) char * efi_guid_ntoa ( CONST EFI_GUID *guid ) { - union { - union uuid uuid; - EFI_GUID guid; - } u; - unsigned int i; - - /* Sanity check */ - if ( ! guid ) - return NULL; - - /* Check for a match against well-known GUIDs */ - for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) / - sizeof ( efi_well_known_guids[0] ) ) ; i++ ) { - if ( memcmp ( guid, efi_well_known_guids[i].guid, - sizeof ( *guid ) ) == 0 ) { - return efi_well_known_guids[i].name; - } - } - - /* Convert GUID to standard endianness */ - memcpy ( &u.guid, guid, sizeof ( u.guid ) ); - uuid_mangle ( &u.uuid ); - return uuid_ntoa ( &u.uuid ); -} - /** * Name locate search type * diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index bd45d05b9..bd35b94cc 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -23,6 +23,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include +#include #include #include #include @@ -400,3 +402,237 @@ EFI_GUID efi_file_info_id = EFI_FILE_INFO_ID; /** File system information GUID */ EFI_GUID efi_file_system_info_id = EFI_FILE_SYSTEM_INFO_ID; + +/** HttpBootDxe module GUID */ +static EFI_GUID efi_http_boot_dxe_guid = { + 0xecebcb00, 0xd9c8, 0x11e4, + { 0xaf, 0x3d, 0x8c, 0xdc, 0xd4, 0x26, 0xc9, 0x73 } +}; + +/** IScsiDxe module GUID */ +static EFI_GUID efi_iscsi_dxe_guid = { + 0x86cddf93, 0x4872, 0x4597, + { 0x8a, 0xf9, 0xa3, 0x5a, 0xe4, 0xd3, 0x72, 0x5f } +}; + +/** Old IScsi4Dxe module GUID */ +static EFI_GUID efi_iscsi4_dxe_guid = { + 0x4579b72d, 0x7ec4, 0x4dd4, + { 0x84, 0x86, 0x08, 0x3c, 0x86, 0xb1, 0x82, 0xa7 } +}; + +/** UefiPxeBcDxe module GUID */ +static EFI_GUID efi_uefi_pxe_bc_dxe_guid = { + 0xb95e9fda, 0x26de, 0x48d2, + { 0x88, 0x07, 0x1f, 0x91, 0x07, 0xac, 0x5e, 0x3a } +}; + +/** VlanConfigDxe module GUID */ +static EFI_GUID efi_vlan_config_dxe_guid = { + 0xe4f61863, 0xfe2c, 0x4b56, + { 0xa8, 0xf4, 0x08, 0x51, 0x9b, 0xc4, 0x39, 0xdf } +}; + +/** A well-known GUID */ +struct efi_well_known_guid { + /** GUID */ + EFI_GUID *guid; + /** Name */ + const char *name; +}; + +/** Well-known GUIDs */ +static struct efi_well_known_guid efi_well_known_guids[] = { + { &efi_absolute_pointer_protocol_guid, + "AbsolutePointer" }, + { &efi_acpi_table_protocol_guid, + "AcpiTable" }, + { &efi_apple_net_boot_protocol_guid, + "AppleNetBoot" }, + { &efi_arp_protocol_guid, + "Arp" }, + { &efi_arp_service_binding_protocol_guid, + "ArpSb" }, + { &efi_block_io_protocol_guid, + "BlockIo" }, + { &efi_block_io2_protocol_guid, + "BlockIo2" }, + { &efi_bus_specific_driver_override_protocol_guid, + "BusSpecificDriverOverride" }, + { &efi_cert_x509_guid, + "CertX509" }, + { &efi_component_name_protocol_guid, + "ComponentName" }, + { &efi_component_name2_protocol_guid, + "ComponentName2" }, + { &efi_console_control_protocol_guid, + "ConsoleControl" }, + { &efi_device_path_protocol_guid, + "DevicePath" }, + { &efi_driver_binding_protocol_guid, + "DriverBinding" }, + { &efi_dhcp4_protocol_guid, + "Dhcp4" }, + { &efi_dhcp4_service_binding_protocol_guid, + "Dhcp4Sb" }, + { &efi_dhcp6_protocol_guid, + "Dhcp6" }, + { &efi_dhcp6_service_binding_protocol_guid, + "Dhcp6Sb" }, + { &efi_disk_io_protocol_guid, + "DiskIo" }, + { &efi_dns4_protocol_guid, + "Dns4" }, + { &efi_dns4_service_binding_protocol_guid, + "Dns4Sb" }, + { &efi_dns6_protocol_guid, + "Dns6" }, + { &efi_dns6_service_binding_protocol_guid, + "Dns6Sb" }, + { &efi_graphics_output_protocol_guid, + "GraphicsOutput" }, + { &efi_hii_config_access_protocol_guid, + "HiiConfigAccess" }, + { &efi_hii_font_protocol_guid, + "HiiFont" }, + { &efi_http_boot_dxe_guid, + "HttpBootDxe" }, + { &efi_http_protocol_guid, + "Http" }, + { &efi_http_service_binding_protocol_guid, + "HttpSb" }, + { &efi_ip4_protocol_guid, + "Ip4" }, + { &efi_ip4_config_protocol_guid, + "Ip4Config" }, + { &efi_ip4_config2_protocol_guid, + "Ip4Config2" }, + { &efi_ip4_service_binding_protocol_guid, + "Ip4Sb" }, + { &efi_ip6_protocol_guid, + "Ip6" }, + { &efi_ip6_config_protocol_guid, + "Ip6Config" }, + { &efi_ip6_service_binding_protocol_guid, + "Ip6Sb" }, + { &efi_iscsi_dxe_guid, + "IScsiDxe" }, + { &efi_iscsi4_dxe_guid, + "IScsi4Dxe" }, + { &efi_load_file_protocol_guid, + "LoadFile" }, + { &efi_load_file2_protocol_guid, + "LoadFile2" }, + { &efi_loaded_image_protocol_guid, + "LoadedImage" }, + { &efi_loaded_image_device_path_protocol_guid, + "LoadedImageDevicePath"}, + { &efi_managed_network_protocol_guid, + "ManagedNetwork" }, + { &efi_managed_network_service_binding_protocol_guid, + "ManagedNetworkSb" }, + { &efi_mtftp4_protocol_guid, + "Mtftp4" }, + { &efi_mtftp4_service_binding_protocol_guid, + "Mtftp4Sb" }, + { &efi_mtftp6_protocol_guid, + "Mtftp6" }, + { &efi_mtftp6_service_binding_protocol_guid, + "Mtftp6Sb" }, + { &efi_nii_protocol_guid, + "Nii" }, + { &efi_nii31_protocol_guid, + "Nii31" }, + { &efi_pci_io_protocol_guid, + "PciIo" }, + { &efi_pci_root_bridge_io_protocol_guid, + "PciRootBridgeIo" }, + { &efi_pxe_base_code_protocol_guid, + "PxeBaseCode" }, + { &efi_serial_io_protocol_guid, + "SerialIo" }, + { &efi_shim_lock_protocol_guid, + "ShimLock" }, + { &efi_simple_file_system_protocol_guid, + "SimpleFileSystem" }, + { &efi_simple_network_protocol_guid, + "SimpleNetwork" }, + { &efi_simple_pointer_protocol_guid, + "SimplePointer" }, + { &efi_simple_text_input_protocol_guid, + "SimpleTextInput" }, + { &efi_simple_text_input_ex_protocol_guid, + "SimpleTextInputEx" }, + { &efi_simple_text_output_protocol_guid, + "SimpleTextOutput" }, + { &efi_tcg_protocol_guid, + "Tcg" }, + { &efi_tcg2_protocol_guid, + "Tcg2" }, + { &efi_tcp4_protocol_guid, + "Tcp4" }, + { &efi_tcp4_service_binding_protocol_guid, + "Tcp4Sb" }, + { &efi_tcp6_protocol_guid, + "Tcp6" }, + { &efi_tcp6_service_binding_protocol_guid, + "Tcp6Sb" }, + { &efi_tree_protocol_guid, + "TrEE" }, + { &efi_udp4_protocol_guid, + "Udp4" }, + { &efi_udp4_service_binding_protocol_guid, + "Udp4Sb" }, + { &efi_udp6_protocol_guid, + "Udp6" }, + { &efi_udp6_service_binding_protocol_guid, + "Udp6Sb" }, + { &efi_uefi_pxe_bc_dxe_guid, + "UefiPxeBcDxe" }, + { &efi_uga_draw_protocol_guid, + "UgaDraw" }, + { &efi_unicode_collation_protocol_guid, + "UnicodeCollation" }, + { &efi_usb_hc_protocol_guid, + "UsbHc" }, + { &efi_usb2_hc_protocol_guid, + "Usb2Hc" }, + { &efi_usb_io_protocol_guid, + "UsbIo" }, + { &efi_vlan_config_protocol_guid, + "VlanConfig" }, + { &efi_vlan_config_dxe_guid, + "VlanConfigDxe" }, +}; + +/** + * Convert GUID to a printable string + * + * @v guid GUID + * @ret string Printable string + */ +const __attribute__ (( pure )) char * efi_guid_ntoa ( CONST EFI_GUID *guid ) { + union { + union uuid uuid; + EFI_GUID guid; + } u; + unsigned int i; + + /* Sanity check */ + if ( ! guid ) + return NULL; + + /* Check for a match against well-known GUIDs */ + for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) / + sizeof ( efi_well_known_guids[0] ) ) ; i++ ) { + if ( memcmp ( guid, efi_well_known_guids[i].guid, + sizeof ( *guid ) ) == 0 ) { + return efi_well_known_guids[i].name; + } + } + + /* Convert GUID to standard endianness */ + memcpy ( &u.guid, guid, sizeof ( u.guid ) ); + uuid_mangle ( &u.uuid ); + return uuid_ntoa ( &u.uuid ); +} -- cgit v1.2.3-55-g7522 From 2a901a33dffb0b8cf25d54312a73e39db7d15f33 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 13 Mar 2025 13:56:27 +0000 Subject: [efi] Add EFI_GLOBAL_VARIABLE as a well-known GUID Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 1 + src/interface/efi/efi_guid.c | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index ef492849e..862a38e5c 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -248,6 +248,7 @@ extern EFI_GUID efi_vlan_config_protocol_guid; extern EFI_GUID efi_cert_x509_guid; extern EFI_GUID efi_file_info_id; extern EFI_GUID efi_file_system_info_id; +extern EFI_GUID efi_global_variable; extern EFI_HANDLE efi_image_handle; extern EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image; diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index bd35b94cc..ae78c068e 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -85,6 +85,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** @file @@ -403,6 +404,9 @@ EFI_GUID efi_file_info_id = EFI_FILE_INFO_ID; /** File system information GUID */ EFI_GUID efi_file_system_info_id = EFI_FILE_SYSTEM_INFO_ID; +/** Global variable GUID */ +EFI_GUID efi_global_variable = EFI_GLOBAL_VARIABLE; + /** HttpBootDxe module GUID */ static EFI_GUID efi_http_boot_dxe_guid = { 0xecebcb00, 0xd9c8, 0x11e4, @@ -489,6 +493,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Dns6" }, { &efi_dns6_service_binding_protocol_guid, "Dns6Sb" }, + { &efi_global_variable, + "GlobalVar" }, { &efi_graphics_output_protocol_guid, "GraphicsOutput" }, { &efi_hii_config_access_protocol_guid, -- cgit v1.2.3-55-g7522 From aa49ce5b1dce3dfbf97bf67ef95524e4710c99f5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 13 Mar 2025 13:40:16 +0000 Subject: [efi] Add TLS authentication header and GUID definitions Add the TlsAuthentication.h header from EDK2's NetworkPkg, along with a GUID definition for EFI_TLS_CA_CERTIFICATE_GUID. It is unclear whether or not the TlsCaCertificate variable is intended to be a UEFI standard. Its presence in NetworkPkg (rather than MdePkg) suggests not, but the choice of EFI_TLS_CA_CERTIFICATE_GUID (rather than e.g. EDKII_TLS_CA_CERTIFICATE_GUID) suggests that it is intended to be included in future versions of the standard. Signed-off-by: Michael Brown --- src/include/ipxe/efi/Guid/TlsAuthentication.h | 25 +++++++++++++++++++++++++ src/include/ipxe/efi/efi.h | 1 + src/include/ipxe/efi/import.pl | 3 ++- src/interface/efi/efi_guid.c | 6 ++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/include/ipxe/efi/Guid/TlsAuthentication.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Guid/TlsAuthentication.h b/src/include/ipxe/efi/Guid/TlsAuthentication.h new file mode 100644 index 000000000..f1e1b4f40 --- /dev/null +++ b/src/include/ipxe/efi/Guid/TlsAuthentication.h @@ -0,0 +1,25 @@ +/** @file + This file defines TlsCaCertificate variable. + +Copyright (c) 2016, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __TLS_AUTHENTICATION_H__ +#define __TLS_AUTHENTICATION_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +// Private variable for CA Certificate configuration +// +#define EFI_TLS_CA_CERTIFICATE_GUID \ + { \ + 0xfd2340D0, 0x3dab, 0x4349, { 0xa6, 0xc7, 0x3b, 0x4f, 0x12, 0xb4, 0x8e, 0xae } \ + } + +#define EFI_TLS_CA_CERTIFICATE_VARIABLE L"TlsCaCertificate" + +extern EFI_GUID gEfiTlsCaCertificateGuid; + +#endif diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 862a38e5c..486c6070e 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -249,6 +249,7 @@ extern EFI_GUID efi_cert_x509_guid; extern EFI_GUID efi_file_info_id; extern EFI_GUID efi_file_system_info_id; extern EFI_GUID efi_global_variable; +extern EFI_GUID efi_tls_ca_certificate_guid; extern EFI_HANDLE efi_image_handle; extern EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image; diff --git a/src/include/ipxe/efi/import.pl b/src/include/ipxe/efi/import.pl index 0a7669f43..346d45e5f 100755 --- a/src/include/ipxe/efi/import.pl +++ b/src/include/ipxe/efi/import.pl @@ -118,7 +118,8 @@ pod2usage ( 1 ) unless @ARGV == 1; my $edktop = shift; # Identify edk import directories -my $edkdirs = [ "MdePkg/Include", "MdeModulePkg/Include" ]; +my $edkdirs = [ "MdePkg/Include", "MdeModulePkg/Include", + "NetworkPkg/Include" ]; foreach my $edkdir ( @$edkdirs ) { die "Directory \"$edktop\" does not appear to contain the EFI EDK2 " ."(missing \"$edkdir\")\n" unless -d catdir ( $edktop, $edkdir ); diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index ae78c068e..9d9c9ef91 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -87,6 +87,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include /** @file * @@ -407,6 +408,9 @@ EFI_GUID efi_file_system_info_id = EFI_FILE_SYSTEM_INFO_ID; /** Global variable GUID */ EFI_GUID efi_global_variable = EFI_GLOBAL_VARIABLE; +/** TLS CA certificate variable GUID */ +EFI_GUID efi_tls_ca_certificate_guid = EFI_TLS_CA_CERTIFICATE_GUID; + /** HttpBootDxe module GUID */ static EFI_GUID efi_http_boot_dxe_guid = { 0xecebcb00, 0xd9c8, 0x11e4, @@ -583,6 +587,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Tcp6" }, { &efi_tcp6_service_binding_protocol_guid, "Tcp6Sb" }, + { &efi_tls_ca_certificate_guid, + "TlsCaCert" }, { &efi_tree_protocol_guid, "TrEE" }, { &efi_udp4_protocol_guid, -- cgit v1.2.3-55-g7522 From ddc2d928d25e3c87ba6153b96446113d59221b94 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 13 Mar 2025 14:04:26 +0000 Subject: [efi] Accept and trust CA certificates in the TlsCaCertificates variable UEFI's built-in HTTPS boot mechanism requires the trusted CA certificates to be provided via the TlsCaCertificates variable. (There is no equivalent of the iPXE cross-signing mechanism, so it is not possible for UEFI to automatically use public CA certificates.) Users who have configured UEFI HTTPS boot to use a custom root of trust (e.g. a private CA certificate) may find it useful to have iPXE automatically pick up and use this same root of trust, so that iPXE can seamlessly fetch files via HTTPS from the same servers that were trusted by UEFI HTTPS boot, in addition to servers that iPXE can validate through other means such as cross-signed certificates. Parse the TlsCaCertificates variable at startup, add any certificates to the certificate store, and mark these certificates as trusted. There are no access restrictions on modifying the TlsCaCertificates variable: anybody with access to write UEFI variables is permitted to change the root of trust. The UEFI security model assumes that anyone with access to run code prior to ExitBootServices() or with access to modify UEFI variables from within a loaded operating system is supposed to be able to change the system's root of trust for TLS. Any certificates parsed from TlsCaCertificates will show up in the output of "certstat", and may be discarded using "certfree" if unwanted. Support for parsing TlsCaCertificates is enabled by default in EFI builds, but may be disabled in config/general.h if needed. As with the ${trust} setting, the contents of the TlsCaCertificates variable will be ignored if iPXE has been compiled with an explicit root of trust by specifying TRUST=... on the build command line. Signed-off-by: Michael Brown --- src/config/config_certs.c | 36 ++++++++ src/config/defaults/efi.h | 2 + src/config/general.h | 6 ++ src/crypto/certstore.c | 6 ++ src/crypto/rootcert.c | 3 + src/crypto/x509.c | 6 +- src/include/ipxe/errfile.h | 1 + src/include/ipxe/rootcert.h | 1 + src/include/ipxe/x509.h | 3 + src/interface/efi/efi_cacert.c | 200 +++++++++++++++++++++++++++++++++++++++++ 10 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 src/config/config_certs.c create mode 100644 src/interface/efi/efi_cacert.c (limited to 'src/interface') diff --git a/src/config/config_certs.c b/src/config/config_certs.c new file mode 100644 index 000000000..a325d132c --- /dev/null +++ b/src/config/config_certs.c @@ -0,0 +1,36 @@ +/* + * 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 (at your option) 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** @file + * + * Certificate source configuration + * + */ + +PROVIDE_REQUIRING_SYMBOL(); + +#ifdef CERTS_EFI +REQUIRE_OBJECT ( efi_cacert ); +#endif diff --git a/src/config/defaults/efi.h b/src/config/defaults/efi.h index d9814eab5..a0e52e7a7 100644 --- a/src/config/defaults/efi.h +++ b/src/config/defaults/efi.h @@ -53,6 +53,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define EFI_SETTINGS /* EFI variable settings */ +#define CERTS_EFI /* EFI certificate sources */ + #if defined ( __i386__ ) || defined ( __x86_64__ ) #define IOAPI_X86 #define ENTROPY_RDRAND diff --git a/src/config/general.h b/src/config/general.h index c40e4fdae..7ac77bfe6 100644 --- a/src/config/general.h +++ b/src/config/general.h @@ -174,6 +174,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define SHIM_CMD /* EFI shim command (or dummy command) */ //#define USB_CMD /* USB commands */ +/* + * Certificate sources + * + */ +//#undef CERTS_EFI /* EFI certificate sources */ + /* * ROM-specific options * diff --git a/src/crypto/certstore.c b/src/crypto/certstore.c index 31797c4cd..86f67a0af 100644 --- a/src/crypto/certstore.c +++ b/src/crypto/certstore.c @@ -266,3 +266,9 @@ static int certstore_apply_settings ( void ) { struct settings_applicator certstore_applicator __settings_applicator = { .apply = certstore_apply_settings, }; + +/* Drag in objects via certificate store */ +REQUIRING_SYMBOL ( certstore ); + +/* Drag in alternative certificate sources */ +REQUIRE_OBJECT ( config_certs ); diff --git a/src/crypto/rootcert.c b/src/crypto/rootcert.c index 0835ff071..e2b817c57 100644 --- a/src/crypto/rootcert.c +++ b/src/crypto/rootcert.c @@ -58,6 +58,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 0xed, 0x1a, #endif +/** Flag indicating if root of trust may be overridden at runtime */ +const int allow_trust_override = ALLOW_TRUST_OVERRIDE; + /** Root certificate fingerprints */ static const uint8_t fingerprints[] = { TRUSTED }; diff --git a/src/crypto/x509.c b/src/crypto/x509.c index 4101c8094..acb27411a 100644 --- a/src/crypto/x509.c +++ b/src/crypto/x509.c @@ -1323,9 +1323,9 @@ int x509_is_valid ( struct x509_certificate *cert, struct x509_root *root ) { * @v issuer Issuing X.509 certificate (or NULL) * @v root Root certificate list */ -static void x509_set_valid ( struct x509_certificate *cert, - struct x509_certificate *issuer, - struct x509_root *root ) { +void x509_set_valid ( struct x509_certificate *cert, + struct x509_certificate *issuer, + struct x509_root *root ) { unsigned int max_path_remaining; /* Sanity checks */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 15bb31b0e..c704dd44d 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -428,6 +428,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_usb_cmd ( ERRFILE_OTHER | 0x00640000 ) #define ERRFILE_usb_settings ( ERRFILE_OTHER | 0x00650000 ) #define ERRFILE_weierstrass ( ERRFILE_OTHER | 0x00660000 ) +#define ERRFILE_efi_cacert ( ERRFILE_OTHER | 0x00670000 ) /** @} */ diff --git a/src/include/ipxe/rootcert.h b/src/include/ipxe/rootcert.h index d4be2e1bc..d1a69723d 100644 --- a/src/include/ipxe/rootcert.h +++ b/src/include/ipxe/rootcert.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +extern const int allow_trust_override; extern struct x509_root root_certificates; #endif /* _IPXE_ROOTCERT_H */ diff --git a/src/include/ipxe/x509.h b/src/include/ipxe/x509.h index e71cee8a3..e8cd0f303 100644 --- a/src/include/ipxe/x509.h +++ b/src/include/ipxe/x509.h @@ -421,6 +421,9 @@ extern int x509_certificate ( const void *data, size_t len, struct x509_certificate **cert ); extern int x509_is_valid ( struct x509_certificate *cert, struct x509_root *root ); +extern void x509_set_valid ( struct x509_certificate *cert, + struct x509_certificate *issuer, + struct x509_root *root ); extern int x509_validate ( struct x509_certificate *cert, struct x509_certificate *issuer, time_t time, struct x509_root *root ); diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c new file mode 100644 index 000000000..5cc268b0e --- /dev/null +++ b/src/interface/efi/efi_cacert.c @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * EFI CA certificates + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** List of EFI CA certificates */ +static struct x509_chain efi_cacerts = { + .refcnt = REF_INIT ( ref_no_free ), + .links = LIST_HEAD_INIT ( efi_cacerts.links ), +}; + +/** + * Retrieve EFI CA certificate + * + * @v data TlsCaCertificate variable data + * @v len Length of TlsCaCertificate + * @v offset Offset within data + * @v next Next offset, or negative error + */ +static int efi_cacert ( void *data, size_t len, size_t offset ) { + struct asn1_cursor *cursor; + struct x509_certificate *cert; + int next; + int rc; + + /* Extract ASN.1 object */ + next = efisig_asn1 ( virt_to_user ( data ), len, offset, &cursor ); + if ( next < 0 ) { + rc = next; + DBGC ( &efi_cacerts, "EFICA could not parse at +%#zx: %s\n", + offset, strerror ( rc ) ); + goto err_asn1; + } + + /* Append to list of EFI CA certificates */ + if ( ( rc = x509_append_raw ( &efi_cacerts, cursor->data, + cursor->len ) ) != 0 ) { + DBGC ( &efi_cacerts, "EFICA could not append at +%#zx: %s\n", + offset, strerror ( rc ) ); + goto err_append; + } + cert = x509_last ( &efi_cacerts ); + DBGC ( &efi_cacerts, "EFICA found certificate %s\n", + x509_name ( cert ) ); + + /* Mark certificate as valid (i.e. trusted) if permitted */ + if ( allow_trust_override ) { + DBGC ( &efi_cacerts, "EFICA trusting certificate %s\n", + x509_name ( cert ) ); + x509_set_valid ( cert, NULL, &root_certificates ); + } + + /* Free ASN.1 object */ + free ( cursor ); + + return next; + + err_append: + free ( cursor ); + err_asn1: + return rc; +} + +/** + * Retrieve all EFI CA certificates + * + * @ret rc Return status code + */ +static int efi_cacert_all ( void ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + EFI_GUID *guid = &efi_tls_ca_certificate_guid; + static CHAR16 *wname = EFI_TLS_CA_CERTIFICATE_VARIABLE; + int offset = 0; + UINT32 attrs; + UINTN size; + void *data; + EFI_STATUS efirc; + int rc; + + /* Get variable length */ + size = 0; + if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size, + NULL ) ) != EFI_BUFFER_TOO_SMALL ) { + rc = -EEFI ( efirc ); + DBGC ( &efi_cacerts, "EFICA could not get %ls size: %s\n", + wname, strerror ( rc ) ); + goto err_len; + } + + /* Allocate temporary buffer */ + data = malloc ( size ); + if ( ! data ) { + rc = -ENOMEM; + goto err_alloc; + } + + /* Read variable */ + if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size, + data ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( &efi_cacerts, "EFICA could not read %ls: %s\n", + wname, strerror ( rc ) ); + goto err_get; + } + + /* Parse certificates */ + while ( ( ( size_t ) offset ) < size ) { + offset = efi_cacert ( data, size, offset ); + if ( offset < 0 ) { + rc = offset; + goto err_cacert; + } + } + + /* Success */ + rc = 0; + + err_cacert: + err_get: + free ( data ); + err_alloc: + err_len: + return rc; +} + +/** + * Initialise EFI CA certificates + * + */ +static void efi_cacert_init ( void ) { + int rc; + + /* Initialise all certificates */ + if ( ( rc = efi_cacert_all() ) != 0 ) { + DBGC ( &efi_cacert, "EFICA could not initialise: %s\n", + strerror ( rc ) ); + /* Nothing we can do at this point */ + return; + } +} + +/** EFI CA certificates initialisation function */ +struct init_fn efi_cacert_init_fn __init_fn ( INIT_LATE ) = { + .initialise = efi_cacert_init, +}; + +/** + * Discard any EFI CA certificates + * + */ +static void efi_cacert_shutdown ( int booting __unused ) { + + /* Drop our references to the certificates */ + DBGC ( &efi_cacert, "EFICA discarding certificates\n" ); + x509_truncate ( &efi_cacerts, NULL ); + assert ( list_empty ( &efi_cacerts.links ) ); +} + +/** EFI CA certificates shutdown function */ +struct startup_fn efi_cacert_shutdown_fn __startup_fn ( STARTUP_NORMAL ) = { + .name = "efi_cacert", + .shutdown = efi_cacert_shutdown, +}; -- cgit v1.2.3-55-g7522 From 8ea8411f0d4b5260f91054b904115224714edf25 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 18 Mar 2025 12:49:19 +0000 Subject: [efi] Add EFI_RNG_PROTOCOL_GUID as a well-known GUID Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 1 + src/interface/efi/efi_guid.c | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 486c6070e..41e1aa945 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -219,6 +219,7 @@ extern EFI_GUID efi_nii31_protocol_guid; extern EFI_GUID efi_pci_io_protocol_guid; extern EFI_GUID efi_pci_root_bridge_io_protocol_guid; extern EFI_GUID efi_pxe_base_code_protocol_guid; +extern EFI_GUID efi_rng_protocol_guid; extern EFI_GUID efi_serial_io_protocol_guid; extern EFI_GUID efi_shim_lock_protocol_guid; extern EFI_GUID efi_simple_file_system_protocol_guid; diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 9d9c9ef91..191ce5094 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -63,6 +63,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -296,6 +297,10 @@ EFI_GUID efi_pci_root_bridge_io_protocol_guid EFI_GUID efi_pxe_base_code_protocol_guid = EFI_PXE_BASE_CODE_PROTOCOL_GUID; +/** Random number generator protocol GUID */ +EFI_GUID efi_rng_protocol_guid + = EFI_RNG_PROTOCOL_GUID; + /** Serial I/O protocol GUID */ EFI_GUID efi_serial_io_protocol_guid = EFI_SERIAL_IO_PROTOCOL_GUID; @@ -559,6 +564,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "PciRootBridgeIo" }, { &efi_pxe_base_code_protocol_guid, "PxeBaseCode" }, + { &efi_rng_protocol_guid, + "Rng" }, { &efi_serial_io_protocol_guid, "SerialIo" }, { &efi_shim_lock_protocol_guid, -- cgit v1.2.3-55-g7522 From 6e4196baff241434d07b74e244fff3d469218f77 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 18 Mar 2025 13:50:11 +0000 Subject: [efi] Prescroll the display after a failed wrapped ExitBootServices() call On some systems (observed with an HP Elitebook 840 G10), writing console output that happens to cause the display to scroll will modify the system memory map. This causes builds with DEBUG=efi_wrap to typically fail to boot, since the debug output from the wrapped ExitBootServices() call itself is sufficient to change the memory map and therefore cause ExitBootServices() to fail due to an invalid memory map key. Work around these UEFI firmware bugs by prescrolling the display after a failed ExitBootServices() attempt, in order to minimise the chance that further scrolling will happen during the subsequent attempt. Signed-off-by: Michael Brown --- src/interface/efi/efi_wrap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index c2fab6647..cbec48a00 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -40,6 +40,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Colour for debug messages */ #define colour &efi_systab +/** Number of lines to prescroll when needed */ +#define EFI_WRAP_PRESCROLL 16 + /** * Convert EFI status code to text * @@ -195,6 +198,38 @@ static const char * efi_timer_delay ( EFI_TIMER_DELAY type ) { } } +/** + * Pre-scroll display to create space for output lines + * + * @v lines Number of lines required + * @ret efirc EFI status code + */ +static int efi_prescroll ( unsigned int lines ) { + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut; + UINTN columns; + UINTN rows; + UINTN space; + EFI_STATUS efirc; + + /* Get number of rows and columns */ + if ( ( efirc = conout->QueryMode ( conout, conout->Mode->Mode, + &columns, &rows ) ) != 0 ) + return efirc; + + /* Calculate available space */ + space = ( rows - conout->Mode->CursorRow - 1 ); + + /* Scroll to create space */ + while ( space++ < lines ) + conout->OutputString ( conout, L"\n" ); + + /* Move cursor to start of space */ + conout->SetCursorPosition ( conout, 0, + ( conout->Mode->CursorRow - lines ) ); + + return 0; +} + /** * Dump information about a loaded image * @@ -783,6 +818,15 @@ efi_exit_boot_services_wrapper ( EFI_HANDLE image_handle, UINTN map_key ) { if ( efirc != 0 ) { DBGC ( colour, "ExitBootServices ( ... ) = %s -> %p\n", efi_status ( efirc ), retaddr ); + /* On some systems, scrolling the output will cause + * the system memory map to change (and so cause + * ExitBootServices() to fail). + * + * After the first failed attempt, prescroll the + * screen to maximise the chance of the subsequent + * attempt succeeding. + */ + efi_prescroll ( EFI_WRAP_PRESCROLL ); } return efirc; } -- cgit v1.2.3-55-g7522 From 37ea181d8b007120bfd70629c6fdffc30145e310 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 18 Mar 2025 16:13:55 +0000 Subject: [efi] Ignore path separator characters in virtual filenames The virtual filesystem that we provide to expose downloaded images will erroneously interpret filenames with redundant path separators such as ".\filename" as an attempt to open the directory, rather than an attempt to open "filename". This shows up most obviously when chainloading from one iPXE into another iPXE, when the inner iPXE may end up attempting to open ".\autoexec.ipxe" from the outer iPXE's virtual filesystem. (The erroneously opened file will have a zero length and will therefore be ignored, but is still confusing.) Fix by discarding any dot or backslash characters after a potential initial backslash. This is very liberal and will accept some syntactically invalid paths, but this is acceptable since our virtual filesystem does not implement directories anyway. Signed-off-by: Michael Brown --- src/interface/efi/efi_file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index e10c2ec4e..48fccdbe1 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -388,8 +388,12 @@ efi_file_open ( EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new, name++; } + /* Strip redundant path separator characters */ + while ( ( *name == '\\' ) || ( *name == '.' ) ) + name++; + /* Allow root directory itself to be opened */ - if ( ( name[0] == '\0' ) || ( name[0] == '.' ) ) + if ( ! *name ) return efi_file_open_fixed ( &efi_file_root, wname, new ); /* Fail unless opening from the root */ -- cgit v1.2.3-55-g7522 From f68c8b09e39f1837ea6344f465d62e4b2c62a1c9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 19 Mar 2025 16:20:27 +0000 Subject: [efi] Fix debug wrappers for CloseEvent() and CheckEvent() The debug wrappers for CloseEvent() and CheckEvent() are currently both calling SignalEvent() instead (presumably due to copy-paste errors). Astonishingly, this has generally not prevented a successful boot in the (very rare) case that DEBUG=efi_wrap is enabled. Fix the wrappers to call the intended functions. Signed-off-by: Michael Brown --- src/interface/efi/efi_wrap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index cbec48a00..252bc2624 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -513,7 +513,7 @@ efi_close_event_wrapper ( EFI_EVENT event ) { EFI_STATUS efirc; DBGC ( colour, "CloseEvent ( %p ) ", event ); - efirc = bs->SignalEvent ( event ); + efirc = bs->CloseEvent ( event ); DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); return efirc; } @@ -528,7 +528,7 @@ efi_check_event_wrapper ( EFI_EVENT event ) { EFI_STATUS efirc; DBGCP ( colour, "CheckEvent ( %p ) ", event ); - efirc = bs->SignalEvent ( event ); + efirc = bs->CheckEvent ( event ); DBGCP ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); return efirc; } -- cgit v1.2.3-55-g7522 From 1a602c92ac865762a96125081fc9173b95aa50a0 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 20 Mar 2025 12:25:26 +0000 Subject: [efi] Allow wrapping the global boot services table in situ When DEBUG=efi_wrap is enabled, we construct a patched copy of the boot services table and patch the global system table to point to this copy. This ensures that any subsequently loaded EFI binaries will call our wrappers. Previously loaded EFI binaries will typically have cached the boot services table pointer (in the gBS variable used by EDK2 code), and therefore will not pick up the updated pointer and so will not call our wrappers. In most cases, this is what we want to happen: we are interested in tracing the calls issued by the newly loaded binary and we do not want to be distracted by the high volume of boot services calls issued by existing UEFI drivers. In some circumstances (such as when a badly behaved OEM driver is causing the system to lock up during the ExitBootServices() call), it can be very useful to be able to patch the global boot services table in situ, so that we can trace calls issued by existing drivers. Restructure the wrapping code to allow wrapping to be enabled or disabled at any time, and to allow for patching the global boot services table in situ. Signed-off-by: Michael Brown --- src/image/efi_image.c | 3 +- src/include/ipxe/efi/efi_wrap.h | 7 +- src/interface/efi/efi_wrap.c | 186 ++++++++++++++++++++++++++-------------- 3 files changed, 130 insertions(+), 66 deletions(-) (limited to 'src/interface') diff --git a/src/image/efi_image.c b/src/image/efi_image.c index 104753a85..d2171e7de 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -268,7 +268,7 @@ static int efi_image_exec ( struct image *image ) { efi_snp_release(); /* Wrap calls made by the loaded image (for debugging) */ - efi_wrap ( handle ); + efi_wrap_image ( handle ); /* Reset console since image will probably use it */ console_reset(); @@ -291,6 +291,7 @@ static int efi_image_exec ( struct image *image ) { rc = 0; err_start_image: + efi_unwrap(); efi_snp_claim(); err_open_protocol: /* If there was no error, then the image must have been diff --git a/src/include/ipxe/efi/efi_wrap.h b/src/include/ipxe/efi/efi_wrap.h index 2747a9e33..d1e970bde 100644 --- a/src/include/ipxe/efi/efi_wrap.h +++ b/src/include/ipxe/efi/efi_wrap.h @@ -10,7 +10,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -extern EFI_BOOT_SERVICES * efi_wrap_bs ( void ); -extern void efi_wrap ( EFI_HANDLE handle ); +extern void efi_wrap_bs ( EFI_BOOT_SERVICES *wrapped ); +extern void efi_wrap_systab ( int global ); +extern void efi_unwrap ( void ); + +extern void efi_wrap_image ( EFI_HANDLE handle ); #endif /* _IPXE_EFI_WRAP_H */ diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 252bc2624..8891f464b 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -43,6 +43,18 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Number of lines to prescroll when needed */ #define EFI_WRAP_PRESCROLL 16 +/** Public EFI system table pointer */ +static EFI_SYSTEM_TABLE *efi_systab_pub; + +/** Private EFI system table used while wrapping is active */ +static EFI_SYSTEM_TABLE efi_systab_priv; + +/** Original EFI boot services table pointer */ +static EFI_BOOT_SERVICES *efi_bs_orig; + +/** Backup of original EFI boot services table */ +static EFI_BOOT_SERVICES efi_bs_copy; + /** * Convert EFI status code to text * @@ -1217,93 +1229,141 @@ efi_create_event_ex_wrapper ( UINT32 type, EFI_TPL notify_tpl, } /** - * Build boot services table wrapper + * Wrap a boot services table * - * @ret bs Wrapped boot services table + * @v wrapper Boot services table to wrap */ -EFI_BOOT_SERVICES * efi_wrap_bs ( void ) { - static EFI_BOOT_SERVICES efi_bs_wrapper; +void efi_wrap_bs ( EFI_BOOT_SERVICES *wrapper ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + /* Do nothing unless debugging is enabled */ + if ( ! DBG_LOG ) + return; + /* Build boot services table wrapper */ - memcpy ( &efi_bs_wrapper, bs, sizeof ( efi_bs_wrapper ) ); - efi_bs_wrapper.RaiseTPL = efi_raise_tpl_wrapper; - efi_bs_wrapper.RestoreTPL = efi_restore_tpl_wrapper; - efi_bs_wrapper.AllocatePages = efi_allocate_pages_wrapper; - efi_bs_wrapper.FreePages = efi_free_pages_wrapper; - efi_bs_wrapper.GetMemoryMap = efi_get_memory_map_wrapper; - efi_bs_wrapper.AllocatePool = efi_allocate_pool_wrapper; - efi_bs_wrapper.FreePool = efi_free_pool_wrapper; - efi_bs_wrapper.CreateEvent = efi_create_event_wrapper; - efi_bs_wrapper.SetTimer = efi_set_timer_wrapper; - efi_bs_wrapper.WaitForEvent = efi_wait_for_event_wrapper; - efi_bs_wrapper.SignalEvent = efi_signal_event_wrapper; - efi_bs_wrapper.CloseEvent = efi_close_event_wrapper; - efi_bs_wrapper.CheckEvent = efi_check_event_wrapper; - efi_bs_wrapper.InstallProtocolInterface + memcpy ( wrapper, bs, sizeof ( *wrapper ) ); + wrapper->RaiseTPL = efi_raise_tpl_wrapper; + wrapper->RestoreTPL = efi_restore_tpl_wrapper; + wrapper->AllocatePages = efi_allocate_pages_wrapper; + wrapper->FreePages = efi_free_pages_wrapper; + wrapper->GetMemoryMap = efi_get_memory_map_wrapper; + wrapper->AllocatePool = efi_allocate_pool_wrapper; + wrapper->FreePool = efi_free_pool_wrapper; + wrapper->CreateEvent = efi_create_event_wrapper; + wrapper->SetTimer = efi_set_timer_wrapper; + wrapper->WaitForEvent = efi_wait_for_event_wrapper; + wrapper->SignalEvent = efi_signal_event_wrapper; + wrapper->CloseEvent = efi_close_event_wrapper; + wrapper->CheckEvent = efi_check_event_wrapper; + wrapper->InstallProtocolInterface = efi_install_protocol_interface_wrapper; - efi_bs_wrapper.ReinstallProtocolInterface + wrapper->ReinstallProtocolInterface = efi_reinstall_protocol_interface_wrapper; - efi_bs_wrapper.UninstallProtocolInterface + wrapper->UninstallProtocolInterface = efi_uninstall_protocol_interface_wrapper; - efi_bs_wrapper.HandleProtocol = efi_handle_protocol_wrapper; - efi_bs_wrapper.RegisterProtocolNotify - = efi_register_protocol_notify_wrapper; - efi_bs_wrapper.LocateHandle = efi_locate_handle_wrapper; - efi_bs_wrapper.LocateDevicePath = efi_locate_device_path_wrapper; - efi_bs_wrapper.InstallConfigurationTable + wrapper->HandleProtocol = efi_handle_protocol_wrapper; + wrapper->RegisterProtocolNotify = efi_register_protocol_notify_wrapper; + wrapper->LocateHandle = efi_locate_handle_wrapper; + wrapper->LocateDevicePath = efi_locate_device_path_wrapper; + wrapper->InstallConfigurationTable = efi_install_configuration_table_wrapper; - efi_bs_wrapper.LoadImage = efi_load_image_wrapper; - efi_bs_wrapper.StartImage = efi_start_image_wrapper; - efi_bs_wrapper.Exit = efi_exit_wrapper; - efi_bs_wrapper.UnloadImage = efi_unload_image_wrapper; - efi_bs_wrapper.ExitBootServices = efi_exit_boot_services_wrapper; - efi_bs_wrapper.GetNextMonotonicCount - = efi_get_next_monotonic_count_wrapper; - efi_bs_wrapper.Stall = efi_stall_wrapper; - efi_bs_wrapper.SetWatchdogTimer = efi_set_watchdog_timer_wrapper; - efi_bs_wrapper.ConnectController - = efi_connect_controller_wrapper; - efi_bs_wrapper.DisconnectController - = efi_disconnect_controller_wrapper; - efi_bs_wrapper.OpenProtocol = efi_open_protocol_wrapper; - efi_bs_wrapper.CloseProtocol = efi_close_protocol_wrapper; - efi_bs_wrapper.OpenProtocolInformation + wrapper->LoadImage = efi_load_image_wrapper; + wrapper->StartImage = efi_start_image_wrapper; + wrapper->Exit = efi_exit_wrapper; + wrapper->UnloadImage = efi_unload_image_wrapper; + wrapper->ExitBootServices = efi_exit_boot_services_wrapper; + wrapper->GetNextMonotonicCount = efi_get_next_monotonic_count_wrapper; + wrapper->Stall = efi_stall_wrapper; + wrapper->SetWatchdogTimer = efi_set_watchdog_timer_wrapper; + wrapper->ConnectController = efi_connect_controller_wrapper; + wrapper->DisconnectController = efi_disconnect_controller_wrapper; + wrapper->OpenProtocol = efi_open_protocol_wrapper; + wrapper->CloseProtocol = efi_close_protocol_wrapper; + wrapper->OpenProtocolInformation = efi_open_protocol_information_wrapper; - efi_bs_wrapper.ProtocolsPerHandle - = efi_protocols_per_handle_wrapper; - efi_bs_wrapper.LocateHandleBuffer - = efi_locate_handle_buffer_wrapper; - efi_bs_wrapper.LocateProtocol = efi_locate_protocol_wrapper; - efi_bs_wrapper.InstallMultipleProtocolInterfaces + wrapper->ProtocolsPerHandle = efi_protocols_per_handle_wrapper; + wrapper->LocateHandleBuffer = efi_locate_handle_buffer_wrapper; + wrapper->LocateProtocol = efi_locate_protocol_wrapper; + wrapper->InstallMultipleProtocolInterfaces = efi_install_multiple_protocol_interfaces_wrapper; - efi_bs_wrapper.UninstallMultipleProtocolInterfaces + wrapper->UninstallMultipleProtocolInterfaces = efi_uninstall_multiple_protocol_interfaces_wrapper; - efi_bs_wrapper.CreateEventEx = efi_create_event_ex_wrapper; - - return &efi_bs_wrapper; + wrapper->CreateEventEx = efi_create_event_ex_wrapper; } /** - * Wrap the calls made by a loaded image + * Wrap the public EFI system table * - * @v handle Image handle + * @v global Patch global boot services table in-place */ -void efi_wrap ( EFI_HANDLE handle ) { - static EFI_SYSTEM_TABLE efi_systab_copy; +void efi_wrap_systab ( int global ) { + static EFI_BOOT_SERVICES local; + EFI_BOOT_SERVICES *wrapper; /* Do nothing unless debugging is enabled */ if ( ! DBG_LOG ) return; - /* Construct modified system table */ - if ( efi_systab != &efi_systab_copy ) { - memcpy ( &efi_systab_copy, efi_systab, - sizeof ( efi_systab_copy ) ); - efi_systab->BootServices = efi_wrap_bs(); - efi_systab = &efi_systab_copy; + /* Preserve original system and boot services tables */ + if ( ! efi_systab_pub ) { + efi_systab_pub = efi_systab; + efi_bs_orig = efi_systab_pub->BootServices; + memcpy ( &efi_bs_copy, efi_bs_orig, sizeof ( efi_bs_copy ) ); } + /* Construct and use private system table */ + if ( efi_systab != &efi_systab_priv ) { + memcpy ( &efi_systab_priv, efi_systab_pub, + sizeof ( efi_systab_priv ) ); + efi_systab_priv.BootServices = &efi_bs_copy; + efi_systab = &efi_systab_priv; + } + + /* Wrap global or local boot services table as applicable */ + wrapper = ( global ? efi_bs_orig : &local ); + efi_wrap_bs ( wrapper ); + efi_systab_pub->BootServices = wrapper; + DBGC ( colour, "WRAP installed %s wrappers\n", + ( global ? "global" : "local" ) ); +} + +/** + * Remove boot services table wrapper + * + */ +void efi_unwrap ( void ) { + + /* Do nothing unless debugging is enabled */ + if ( ! DBG_LOG ) + return; + + /* Do nothing if wrapping was never enabled */ + if ( ! efi_systab_pub ) + return; + + /* Restore original system and boot services tables */ + memcpy ( efi_bs_orig, &efi_bs_copy, sizeof ( *efi_bs_orig ) ); + efi_systab_pub->BootServices = efi_bs_orig; + + /* Switch back to using public system table */ + efi_systab = efi_systab_pub; + DBGC ( colour, "WRAP uninstalled wrappers\n" ); +} + +/** + * Wrap calls made by a newly loaded image + * + * @v handle Image handle + */ +void efi_wrap_image ( EFI_HANDLE handle ) { + + /* Do nothing unless debugging is enabled */ + if ( ! DBG_LOG ) + return; + /* Dump image information */ efi_dump_image ( handle ); + + /* Patch public system table */ + efi_wrap_systab ( 0 ); } -- cgit v1.2.3-55-g7522 From 7cda3dbf94936f265ab017841d0236bb62f51efa Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 20 Mar 2025 14:18:02 +0000 Subject: [efi] Attempt to retrieve driver name from image handle for debug messages Not all drivers will install the driver binding protocol on the image handle. Accommodate these drivers by attempting to retrieve the driver name via the component name protocol(s) located on the driver binding's ImageHandle, as well as on the driver handle itself. Signed-off-by: Michael Brown --- src/interface/efi/efi_debug.c | 91 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 030c6a93e..1b778805e 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include @@ -320,6 +321,90 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) { return name; } +/** + * Get driver binding name + * + * @v binding Driver binding protocol + * @ret name Driver name, or NULL + */ +static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + union { + EFI_COMPONENT_NAME_PROTOCOL *name; + void *interface; + } u; + EFI_HANDLE image; + const char *name; + EFI_STATUS efirc; + + /* Sanity check */ + if ( ! binding ) { + DBG ( "[NULL DriverBinding]" ); + return NULL; + } + + /* Try to open component name protocol on image handle */ + image = binding->ImageHandle; + if ( ( efirc = bs->OpenProtocol ( image, + &efi_component_name_protocol_guid, + &u.interface, efi_image_handle, image, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){ + DBG ( "[DriverBinding no ComponentName]" ); + return NULL; + } + + /* Try to get name from component name protocol */ + name = efi_driver_name ( u.name ); + + /* Close component name protocol */ + bs->CloseProtocol ( image, &efi_component_name_protocol_guid, + efi_image_handle, image ); + + return name; +} + +/** + * Get driver binding name + * + * @v binding Driver binding protocol + * @ret name Driver name, or NULL + */ +static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE image; + union { + EFI_COMPONENT_NAME2_PROTOCOL *name2; + void *interface; + } u; + const char *name; + EFI_STATUS efirc; + + /* Sanity check */ + if ( ! binding ) { + DBG ( "[NULL DriverBinding]" ); + return NULL; + } + + /* Try to open component name protocol on image handle */ + image = binding->ImageHandle; + if ( ( efirc = bs->OpenProtocol ( image, + &efi_component_name2_protocol_guid, + &u.interface, efi_image_handle, image, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){ + DBG ( "[DriverBinding no ComponentName2]" ); + return NULL; + } + + /* Try to get name from component name protocol */ + name = efi_driver_name2 ( u.name2 ); + + /* Close component name protocol */ + bs->CloseProtocol ( image, &efi_component_name2_protocol_guid, + efi_image_handle, image ); + + return name; +} + /** * Get PE/COFF debug filename * @@ -547,6 +632,12 @@ static struct efi_handle_name_type efi_handle_name_types[] = { /* Driver name (via obsolete original ComponentName protocol) */ EFI_HANDLE_NAME_TYPE ( &efi_component_name_protocol_guid, efi_driver_name ), + /* Driver name (for driver binding handles) */ + EFI_HANDLE_NAME_TYPE ( &efi_driver_binding_protocol_guid, + efi_binding_name2 ), + /* Driver name (via obsolete original ComponentName protocol) */ + EFI_HANDLE_NAME_TYPE ( &efi_driver_binding_protocol_guid, + efi_binding_name ), /* PE/COFF debug filename (for image handles) */ EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid, efi_pecoff_debug_name ), -- cgit v1.2.3-55-g7522 From 5d64469a9e6aa6126643cfb33355441496c84c3a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 20 Mar 2025 14:20:57 +0000 Subject: [efi] Prefer driver name to device path for debug messages The driver name is usually more informative for debug messages than the device path from which a driver was loaded. Try using the various mechanisms for obtaining a driver name before trying the device path. Signed-off-by: Michael Brown --- src/interface/efi/efi_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 1b778805e..9e28067de 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -623,9 +623,6 @@ struct efi_handle_name_type { /** EFI handle name types */ static struct efi_handle_name_type efi_handle_name_types[] = { - /* Device path */ - EFI_HANDLE_NAME_TYPE ( &efi_device_path_protocol_guid, - efi_devpath_text ), /* Driver name (for driver image handles) */ EFI_HANDLE_NAME_TYPE ( &efi_component_name2_protocol_guid, efi_driver_name2 ), @@ -650,6 +647,9 @@ static struct efi_handle_name_type efi_handle_name_types[] = { /* Handle's loaded image file path (for image handles) */ EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid, efi_loaded_image_filepath_name ), + /* Device path */ + EFI_HANDLE_NAME_TYPE ( &efi_device_path_protocol_guid, + efi_devpath_text ), /* Our standard input file handle */ EFI_HANDLE_NAME_TYPE ( &efi_simple_text_input_protocol_guid, efi_conin_name ), -- cgit v1.2.3-55-g7522 From be5bf0aa7a0d76d8426a04c88d1ec6e7c5293ff1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 20 Mar 2025 14:30:34 +0000 Subject: [efi] Show image address range in veto debug messages When hunting down a misbehaving OEM driver to add it to the veto list, it can be very useful to know the address ranges used by each driver. Add this information to the verbose debug messages. Signed-off-by: Michael Brown --- src/interface/efi/efi_veto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 37aa9a379..1b2332041 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -569,9 +569,6 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, EFI_STATUS efirc; int rc; - DBGC2 ( &efi_vetoes, "EFIVETO checking %s\n", - efi_handle_name ( driver ) ); - /* Mark as not vetoed */ memset ( veto, 0, sizeof ( *veto ) ); @@ -621,6 +618,9 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, } /* Check vetoes */ + DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n", + efi_handle_name ( driver ), loaded.loaded->ImageBase, + ( loaded.loaded->ImageBase + loaded.loaded->ImageSize ) ); for ( i = 0 ; i < ( sizeof ( efi_vetoes ) / sizeof ( efi_vetoes[0] ) ) ; i++ ) { if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded, -- cgit v1.2.3-55-g7522 From 756e3907fdca0a9b4fe18a618eb35895d0208b86 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 20 Mar 2025 14:35:11 +0000 Subject: [efi] Get veto candidate driver name from image handle Allow for drivers that do not install the driver binding protocol on the image handle by opening the component name protocol on the driver binding's ImageHandle rather than on the driver handle itself. Signed-off-by: Michael Brown --- src/interface/efi/efi_veto.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 1b2332041..4cf4e846d 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -598,10 +598,10 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, goto err_loaded; } - /* Open component name protocol, if present*/ + /* Open component name protocol, if present */ if ( ( efirc = bs->OpenProtocol ( - driver, &efi_component_name_protocol_guid, - &wtf.interface, efi_image_handle, driver, + image, &efi_component_name_protocol_guid, + &wtf.interface, efi_image_handle, image, EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { /* Ignore failure; is not required to be present */ wtf.interface = NULL; @@ -641,8 +641,8 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Close protocols */ if ( wtf.wtf ) { - bs->CloseProtocol ( driver, &efi_component_name_protocol_guid, - efi_image_handle, driver ); + bs->CloseProtocol ( image, &efi_component_name_protocol_guid, + efi_image_handle, image ); } bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid, efi_image_handle, image ); -- cgit v1.2.3-55-g7522 From 02ecb23d106fe849899597b79f9db03a5d4673d9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 20 Mar 2025 14:38:20 +0000 Subject: [efi] Get veto candidate driver name via either component name protocol Attempt to get the veto candidate driver name from both the current and obsolete versions of the component name protocol. Signed-off-by: Michael Brown --- src/interface/efi/efi_veto.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 4cf4e846d..17bbf7af4 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** @file @@ -46,14 +47,12 @@ struct efi_veto_candidate { * * @v binding Driver binding protocol * @v loaded Loaded image protocol - * @v wtf Component name protocol, if present * @v manufacturer Manufacturer name, if present - * @v name Driver name (in "eng" language), if present + * @v name Driver name, if present * @ret vetoed Driver is to be vetoed */ int ( * veto ) ( EFI_DRIVER_BINDING_PROTOCOL *binding, EFI_LOADED_IMAGE_PROTOCOL *loaded, - EFI_COMPONENT_NAME_PROTOCOL *wtf, const char *manufacturer, const CHAR16 *name ); }; @@ -394,7 +393,6 @@ static int efi_veto_driver ( struct efi_veto *veto ) { * * @v binding Driver binding protocol * @v loaded Loaded image protocol - * @v wtf Component name protocol, if present * @v manufacturer Manufacturer name, if present * @v name Driver name, if present * @ret vetoed Driver is to be vetoed @@ -402,7 +400,6 @@ static int efi_veto_driver ( struct efi_veto *veto ) { static int efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, - EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name ) { static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver"; static const char *dell = "Dell Inc."; @@ -427,7 +424,6 @@ efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, * * @v binding Driver binding protocol * @v loaded Loaded image protocol - * @v wtf Component name protocol, if present * @v manufacturer Manufacturer name, if present * @v name Driver name, if present * @ret vetoed Driver is to be vetoed @@ -435,7 +431,6 @@ efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, static int efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, - EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name ) { static const CHAR16 xhci[] = L"Usb Xhci Driver"; static const char *hp = "HP"; @@ -468,7 +463,6 @@ efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, * * @v binding Driver binding protocol * @v loaded Loaded image protocol - * @v wtf Component name protocol, if present * @v manufacturer Manufacturer name, if present * @v name Driver name, if present * @ret vetoed Driver is to be vetoed @@ -476,7 +470,6 @@ efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, static int efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, - EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer, const CHAR16 *name ) { static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver"; static const char *vmware = "VMware, Inc."; @@ -499,14 +492,12 @@ efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, * * @v binding Driver binding protocol * @v loaded Loaded image protocol - * @v wtf Component name protocol, if present * @v manufacturer Manufacturer name, if present * @v name Driver name, if present * @ret vetoed Driver is to be vetoed */ static int efi_veto_dhcp6 ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, - EFI_COMPONENT_NAME_PROTOCOL *wtf __unused, const char *manufacturer __unused, const CHAR16 *name ) { static const CHAR16 dhcp6[] = L"DHCP6 Protocol Driver"; @@ -559,6 +550,10 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, EFI_LOADED_IMAGE_PROTOCOL *loaded; void *interface; } loaded; + union { + EFI_COMPONENT_NAME2_PROTOCOL *wtf2; + void *interface; + } wtf2; union { EFI_COMPONENT_NAME_PROTOCOL *wtf; void *interface; @@ -599,6 +594,15 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, } /* Open component name protocol, if present */ + if ( ( efirc = bs->OpenProtocol ( + image, &efi_component_name2_protocol_guid, + &wtf2.interface, efi_image_handle, image, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + /* Ignore failure; is not required to be present */ + wtf2.interface = NULL; + } + + /* Open obsolete component name protocol, if present */ if ( ( efirc = bs->OpenProtocol ( image, &efi_component_name_protocol_guid, &wtf.interface, efi_image_handle, image, @@ -608,9 +612,12 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, } /* Get driver name, if available */ - if ( wtf.wtf && - ( ( efirc = wtf.wtf->GetDriverName ( wtf.wtf, "eng", - &name ) == 0 ) ) ) { + if ( ( wtf2.wtf2 && + ( ( efirc = wtf2.wtf2->GetDriverName ( wtf2.wtf2, "en", + &name ) == 0 ) ) ) || + ( wtf.wtf && + ( ( efirc = wtf.wtf->GetDriverName ( wtf.wtf, "eng", + &name ) == 0 ) ) ) ) { /* Driver has a name */ } else { /* Ignore failure; name is not required to be present */ @@ -624,7 +631,7 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, for ( i = 0 ; i < ( sizeof ( efi_vetoes ) / sizeof ( efi_vetoes[0] ) ) ; i++ ) { if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded, - wtf.wtf, manufacturer, name ) ) { + manufacturer, name ) ) { DBGC ( driver, "EFIVETO %s is vetoed (%s)\n", efi_handle_name ( driver ), efi_vetoes[i].name ); @@ -644,6 +651,10 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, bs->CloseProtocol ( image, &efi_component_name_protocol_guid, efi_image_handle, image ); } + if ( wtf2.wtf2 ) { + bs->CloseProtocol ( image, &efi_component_name2_protocol_guid, + efi_image_handle, image ); + } bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid, efi_image_handle, image ); err_loaded: -- cgit v1.2.3-55-g7522 From 8249bbc098319621f6a0db56f7be4bb2873811eb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 21 Mar 2025 16:58:03 +0000 Subject: [efi] Use driver name only from driver binding handles in debug messages Some non-driver handles may have an installed component name protocol. In particular, iPXE itself installs these protocols on its SNP device handles, to simplify the process of delegating GetControllerName() from our single-instance driver binding protocol to whatever child controllers the relevant EFI driver may have installed. For non-driver handles, the device path is more useful as debugging information than the driver name. Limit the use of the component name protocols to handles with a driver binding protocol installed, so that we will end up using the device path for non-driver handles such as the SNP device. Continue to prefer the driver name to the device path for handles with a driver binding protocol installed, since these will generally map to things we are likely to conceptualise as drivers rather than as devices. Note that we deliberately do not use GetControllerName() to attempt to get a human-readable name for a controller handle. In the normal course of events, iPXE is likely to disconnect at least some existing drivers from their controller handles. This would cause the name obtained via GetControllerName() to change. By using the device path instead, we ensure that the debug message name remains the same even when the driver controlling the handle is changed. Signed-off-by: Michael Brown --- src/interface/efi/efi_debug.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 9e28067de..6f71949fb 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -623,12 +623,6 @@ struct efi_handle_name_type { /** EFI handle name types */ static struct efi_handle_name_type efi_handle_name_types[] = { - /* Driver name (for driver image handles) */ - EFI_HANDLE_NAME_TYPE ( &efi_component_name2_protocol_guid, - efi_driver_name2 ), - /* Driver name (via obsolete original ComponentName protocol) */ - EFI_HANDLE_NAME_TYPE ( &efi_component_name_protocol_guid, - efi_driver_name ), /* Driver name (for driver binding handles) */ EFI_HANDLE_NAME_TYPE ( &efi_driver_binding_protocol_guid, efi_binding_name2 ), -- cgit v1.2.3-55-g7522 From 331bbf50755bb0ba5405dfd8e4350cfc3684bc09 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 18:22:00 +0000 Subject: [efi] Remove spurious close of SNP device parent's device path Commit e727f57 ("[efi] Include a copy of the device path within struct efi_device") neglected to delete the closure of the parent's device path from the success code path in efi_snp_probe(). Reduce confusion by removing this (harmless) additional close. Signed-off-by: Michael Brown --- src/interface/efi/efi_snp.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 8443be997..d977802fd 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -1958,10 +1958,6 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { /* Add to list of SNP devices */ list_add ( &snpdev->list, &efi_snp_devices ); - /* Close device path */ - bs->CloseProtocol ( efidev->device, &efi_device_path_protocol_guid, - efi_image_handle, efidev->device ); - DBGC ( snpdev, "SNPDEV %p installed for %s as device %s\n", snpdev, netdev->name, efi_handle_name ( snpdev->handle ) ); return 0; -- cgit v1.2.3-55-g7522 From 3283885326e3646d2f949ed9ce91cb99e7e3e3c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 19:37:21 +0000 Subject: [efi] Avoid function name near-collision We currently have both efipci_info() and efi_pci_info() serving different but related purposes. Rename the latter to reduce confusion. Signed-off-by: Michael Brown --- src/interface/efi/efi_utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 53f82bfe4..6ceba20e6 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -170,8 +170,8 @@ void efi_child_del ( EFI_HANDLE parent, EFI_HANDLE child ) { * @v dev Generic device to fill in * @ret rc Return status code */ -static int efi_pci_info ( EFI_HANDLE device, const char *prefix, - struct device *dev ) { +static int efi_device_info_pci ( EFI_HANDLE device, const char *prefix, + struct device *dev ) { EFI_HANDLE pci_device; struct efi_pci_device efipci; int rc; @@ -211,7 +211,7 @@ void efi_device_info ( EFI_HANDLE device, const char *prefix, int rc; /* Try getting underlying PCI device information */ - if ( ( rc = efi_pci_info ( device, prefix, dev ) ) == 0 ) + if ( ( rc = efi_device_info_pci ( device, prefix, dev ) ) == 0 ) return; /* If we cannot get any underlying device information, fall -- cgit v1.2.3-55-g7522 From 48d1680127a13b2dcc3abae9bb839a6ce0f9912a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Mar 2025 11:11:44 +0000 Subject: [efi] Remove the efipci_open() and efipci_close() wrappers In preparation for formalising the way that EFI protocols are opened across the codebase, remove the efipci_open() wrapper. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi_pci.h | 3 -- src/interface/efi/efi_bofm.c | 23 ++++++++++++--- src/interface/efi/efi_pci.c | 67 +++++++++++++++--------------------------- 3 files changed, 42 insertions(+), 51 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi_pci.h b/src/include/ipxe/efi/efi_pci.h index 2ea1a8f0e..f8d1e3e40 100644 --- a/src/include/ipxe/efi/efi_pci.h +++ b/src/include/ipxe/efi/efi_pci.h @@ -25,9 +25,6 @@ struct efi_pci_device { EFI_PCI_IO_PROTOCOL *io; }; -extern int efipci_open ( EFI_HANDLE device, UINT32 attributes, - struct efi_pci_device *efipci ); -extern void efipci_close ( EFI_HANDLE device ); extern int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ); #endif /* _IPXE_EFI_PCI_H */ diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 15f3837cc..1be68bf8b 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -228,14 +228,27 @@ static int efi_bofm_start ( struct efi_device *efidev ) { struct efi_pci_device efipci; IBM_BOFM_TABLE *bofmtab; IBM_BOFM_TABLE *bofmtab2; + void *pci_io; int bofmrc; EFI_STATUS efirc; int rc; - /* Open PCI device, if possible */ - if ( ( rc = efipci_open ( device, EFI_OPEN_PROTOCOL_GET_PROTOCOL, - &efipci ) ) != 0 ) + /* Get PCI device information */ + if ( ( rc = efipci_info ( device, &efipci ) ) != 0 ) { + DBGC ( device, "EFIBOFM %s cannot get PCI information: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + goto err_info; + } + + /* Open PCI I/O protocol */ + if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, + &pci_io, efi_image_handle, device, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ + rc = -EEFI ( efirc ); + DBGC ( device, "EFIBOFM %s cannot open PCI device: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); goto err_open; + } /* Locate BOFM protocol */ if ( ( efirc = bs->LocateProtocol ( &bofm1_protocol_guid, NULL, @@ -313,8 +326,10 @@ static int efi_bofm_start ( struct efi_device *efidev ) { err_set_status: err_locate_bofm: - efipci_close ( device ); + bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, + efi_image_handle, device ); err_open: + err_info: return rc; } diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 8d4e08567..d55cbe86c 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -771,15 +771,13 @@ static struct dma_operations efipci_dma_operations = { */ /** - * Open EFI PCI device + * Get EFI PCI device information * * @v device EFI device handle - * @v attributes Protocol opening attributes * @v efipci EFI PCI device to fill in * @ret rc Return status code */ -int efipci_open ( EFI_HANDLE device, UINT32 attributes, - struct efi_pci_device *efipci ) { +int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_PCI_IO_PROTOCOL *pci_io; @@ -792,8 +790,9 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes, /* See if device is a PCI device */ if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io.interface, efi_image_handle, - device, attributes ) ) != 0 ) { + &pci_io.interface, + efi_image_handle, device, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ rc = -EEFI_PCI ( efirc ); DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -850,39 +849,6 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes, return rc; } -/** - * Close EFI PCI device - * - * @v device EFI device handle - */ -void efipci_close ( EFI_HANDLE device ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); -} - -/** - * Get EFI PCI device information - * - * @v device EFI device handle - * @v efipci EFI PCI device to fill in - * @ret rc Return status code - */ -int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { - int rc; - - /* Open PCI device, if possible */ - if ( ( rc = efipci_open ( device, EFI_OPEN_PROTOCOL_GET_PROTOCOL, - efipci ) ) != 0 ) - return rc; - - /* Close PCI device */ - efipci_close ( device ); - - return 0; -} - /****************************************************************************** * * EFI PCI driver @@ -936,8 +902,11 @@ static int efipci_supported ( EFI_HANDLE device ) { * @ret rc Return status code */ static int efipci_start ( struct efi_device *efidev ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; struct efi_pci_device *efipci; + void *pci_io; + EFI_STATUS efirc; int rc; /* Allocate PCI device */ @@ -947,10 +916,16 @@ static int efipci_start ( struct efi_device *efidev ) { goto err_alloc; } + /* Get PCI device information */ + if ( ( rc = efipci_info ( device, efipci ) ) != 0 ) + goto err_info; + /* Open PCI device */ - if ( ( rc = efipci_open ( device, ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE ), - efipci ) ) != 0 ) { + if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, + &pci_io, efi_image_handle, device, + ( EFI_OPEN_PROTOCOL_BY_DRIVER | + EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ + rc = -EEFI_PCI ( efirc ); DBGC ( device, "EFIPCI %s could not open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_pci_io_protocol_guid ); @@ -985,8 +960,10 @@ static int efipci_start ( struct efi_device *efidev ) { err_probe: list_del ( &efipci->pci.dev.siblings ); err_find_driver: - efipci_close ( device ); + bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, + efi_image_handle, device ); err_open: + err_info: free ( efipci ); err_alloc: return rc; @@ -999,13 +976,15 @@ static int efipci_start ( struct efi_device *efidev ) { */ static void efipci_stop ( struct efi_device *efidev ) { struct efi_pci_device *efipci = efidev_get_drvdata ( efidev ); + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; pci_remove ( &efipci->pci ); list_del ( &efipci->pci.dev.siblings ); assert ( efipci->pci.dma.mapped == 0 ); assert ( efipci->pci.dma.allocated == 0 ); - efipci_close ( device ); + bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, + efi_image_handle, device ); free ( efipci ); } -- cgit v1.2.3-55-g7522 From 358db15612c019abcf6d4db6ba297ba91df7ed6e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 17:21:36 +0000 Subject: [efi] Create safe wrappers for OpenProtocol() and CloseProtocol() The UEFI model for opening and closing protocols is broken by design and cannot be repaired. Calling OpenProtocol() to obtain a protocol interface pointer does not, in general, provide any guarantees about the lifetime of that pointer. It is theoretically possible that the pointer has already become invalid by the time that OpenProtocol() returns the pointer to its caller. (This can happen when a USB device is physically removed, for example.) Various UEFI design flaws make it occasionally necessary to hold on to a protocol interface pointer despite the total lack of guarantees that the pointer will remain valid. The UEFI driver model overloads the semantics of OpenProtocol() to accommodate the use cases of recording a driver attachment (which is modelled as opening a protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes) and recording the existence of a related child controller (which is modelled as opening a protocol with EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER attributes). The parameters defined for CloseProtocol() are not sufficient to allow the implementation to precisely identify the matching call to OpenProtocol(). While the UEFI model appears to allow for matched open and close pairs, this is merely an illusion. Calling CloseProtocol() will delete *all* matching records in the protocol open information tables. Since the parameters defined for CloseProtocol() do not include the attributes passed to OpenProtocol(), this means that a matched open/close pair using EFI_OPEN_PROTOCOL_GET_PROTOCOL can inadvertently end up deleting the record that defines a driver attachment or the existence of a child controller. This in turn can cause some very unexpected side effects, such as allowing other UEFI drivers to start controlling hardware to which iPXE believes it has exclusive access. This rarely ends well. To prevent this kind of inadvertent deletion, we establish a convention for four different types of protocol opening: - ephemeral opens: always opened with ControllerHandle = NULL - unsafe opens: always opened with ControllerHandle = AgentHandle - by-driver opens: always opened with ControllerHandle = Handle - by-child opens: always opened with ControllerHandle != Handle This convention ensures that the four types of open never overlap within the set of parameters defined for CloseProtocol(), and so a close of one type cannot inadvertently delete the record corresponding to a different type. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 12 ++ src/include/ipxe/errfile.h | 1 + src/interface/efi/efi_open.c | 358 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+) create mode 100644 src/interface/efi/efi_open.c (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 41e1aa945..6126d3b87 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -389,5 +389,17 @@ extern EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab ); extern void efi_raise_tpl ( struct efi_saved_tpl *tpl ); extern void efi_restore_tpl ( struct efi_saved_tpl *tpl ); +extern int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); +extern int efi_open_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); +extern void efi_close_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol ); +extern int efi_open_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); +extern void efi_close_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol ); +extern int efi_open_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child, void **interface ); +extern void efi_close_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child ); #endif /* _IPXE_EFI_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index c704dd44d..51b458d56 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -84,6 +84,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_efi_mp ( ERRFILE_CORE | 0x002c0000 ) #define ERRFILE_efi_service ( ERRFILE_CORE | 0x002d0000 ) #define ERRFILE_null_smbios ( ERRFILE_CORE | 0x002e0000 ) +#define ERRFILE_efi_open ( ERRFILE_CORE | 0x002f0000 ) #define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 ) #define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 ) diff --git a/src/interface/efi/efi_open.c b/src/interface/efi/efi_open.c new file mode 100644 index 000000000..c85c027e1 --- /dev/null +++ b/src/interface/efi/efi_open.c @@ -0,0 +1,358 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * EFI protocol opening and closing + * + * The UEFI model for opening and closing protocols is broken by + * design and cannot be repaired. + * + * Calling OpenProtocol() to obtain a protocol interface pointer does + * not, in general, provide any guarantees about the lifetime of that + * pointer. It is theoretically possible that the pointer has already + * become invalid by the time that OpenProtocol() returns the pointer + * to its caller. (This can happen when a USB device is physically + * removed, for example.) + * + * Various UEFI design flaws make it occasionally necessary to hold on + * to a protocol interface pointer despite the total lack of + * guarantees that the pointer will remain valid. + * + * The UEFI driver model overloads the semantics of OpenProtocol() to + * accommodate the use cases of recording a driver attachment (which + * is modelled as opening a protocol with EFI_OPEN_PROTOCOL_BY_DRIVER + * attributes) and recording the existence of a related child + * controller (which is modelled as opening a protocol with + * EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER attributes). + * + * The parameters defined for CloseProtocol() are not sufficient to + * allow the implementation to precisely identify the matching call to + * OpenProtocol(). While the UEFI model appears to allow for matched + * open and close pairs, this is merely an illusion. Calling + * CloseProtocol() will delete *all* matching records in the protocol + * open information tables. + * + * Since the parameters defined for CloseProtocol() do not include the + * attributes passed to OpenProtocol(), this means that a matched + * open/close pair using EFI_OPEN_PROTOCOL_GET_PROTOCOL can + * inadvertently end up deleting the record that defines a driver + * attachment or the existence of a child controller. This in turn + * can cause some very unexpected side effects, such as allowing other + * UEFI drivers to start controlling hardware to which iPXE believes + * it has exclusive access. This rarely ends well. + * + * To prevent this kind of inadvertent deletion, we establish a + * convention for four different types of protocol opening: + * + * - ephemeral opens: always opened with ControllerHandle = NULL + * + * - unsafe opens: always opened with ControllerHandle = AgentHandle + * + * - by-driver opens: always opened with ControllerHandle = Handle + * + * - by-child opens: always opened with ControllerHandle != Handle + * + * This convention ensures that the four types of open never overlap + * within the set of parameters defined for CloseProtocol(), and so a + * close of one type cannot inadvertently delete the record + * corresponding to a different type. + */ + +#include +#include +#include + +/** + * Open (or test) protocol for ephemeral use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in (or NULL to test) + * @ret rc Return status code + */ +int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, void **interface ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + unsigned int attributes; + EFI_STATUS efirc; + int rc; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + + /* Open protocol + * + * We set ControllerHandle to NULL to avoid collisions with + * other open types. + */ + controller = NULL; + attributes = ( interface ? EFI_OPEN_PROTOCOL_GET_PROTOCOL : + EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); + if ( ( efirc = bs->OpenProtocol ( handle, protocol, interface, agent, + controller, attributes ) ) != 0 ) { + rc = -EEFI ( efirc ); + if ( interface ) + *interface = NULL; + return rc; + } + + /* Close protocol immediately + * + * While it may seem prima facie unsafe to use a protocol + * after closing it, UEFI doesn't actually give us any safety + * even while the protocol is nominally open. Opening a + * protocol with EFI_OPEN_PROTOCOL_GET_PROTOCOL attributes + * does not in any way ensure that the interface pointer + * remains valid: there are no locks or notifications + * associated with these "opens". + * + * The only way to obtain a (partially) guaranteed persistent + * interface pointer is to open the protocol with the + * EFI_OPEN_PROTOCOL_BY_DRIVER attributes. This is not + * possible in the general case, since UEFI permits only a + * single image at a time to have the protocol opened with + * these attributes. + * + * We can therefore obtain at best an ephemeral interface + * pointer: one that is guaranteed to remain valid only for as + * long as we do not relinquish the thread of control. + * + * (Since UEFI permits calls to UninstallProtocolInterface() + * at levels up to and including TPL_NOTIFY, this means that + * we technically cannot rely on the pointer remaining valid + * unless the caller is itself running at TPL_NOTIFY. This is + * clearly impractical, and large portions of the EDK2 + * codebase presume that using EFI_OPEN_PROTOCOL_GET_PROTOCOL + * is safe at lower TPLs.) + * + * Closing is not strictly necessary for protocols opened + * ephemerally (i.e. using EFI_OPEN_PROTOCOL_GET_PROTOCOL or + * EFI_OPEN_PROTOCOL_TEST_PROTOCOL), but avoids polluting the + * protocol open information tables with stale data. + * + * Closing immediately also simplifies the callers' code + * paths, since they do not need to worry about closing the + * protocol. + * + * The overall effect is equivalent to using HandleProtocol(), + * but without the associated pollution of the protocol open + * information tables, and with improved traceability. + */ + bs->CloseProtocol ( handle, protocol, agent, controller ); + + return 0; +} + +/** + * Open protocol for unsafe persistent use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +int efi_open_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + unsigned int attributes; + EFI_STATUS efirc; + int rc; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + assert ( interface != NULL ); + + /* Open protocol + * + * We set ControllerHandle equal to AgentHandle to avoid + * collisions with other open types. + */ + controller = agent; + attributes = EFI_OPEN_PROTOCOL_GET_PROTOCOL; + if ( ( efirc = bs->OpenProtocol ( handle, protocol, interface, agent, + controller, attributes ) ) != 0 ) { + rc = -EEFI ( efirc ); + *interface = NULL; + return rc; + } + + return 0; +} + +/** + * Close protocol opened for unsafe persistent use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v child Child controller handle + */ +void efi_close_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + + /* Close protocol */ + controller = agent; + bs->CloseProtocol ( handle, protocol, agent, controller ); +} + +/** + * Open protocol for persistent use by a driver + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +int efi_open_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + unsigned int attributes; + EFI_STATUS efirc; + int rc; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + assert ( interface != NULL ); + + /* Open protocol + * + * We set ControllerHandle equal to Handle to avoid collisions + * with other open types. + */ + controller = handle; + attributes = ( EFI_OPEN_PROTOCOL_BY_DRIVER | + EFI_OPEN_PROTOCOL_EXCLUSIVE ); + if ( ( efirc = bs->OpenProtocol ( handle, protocol, interface, agent, + controller, attributes ) ) != 0 ) { + rc = -EEFI ( efirc ); + *interface = NULL; + return rc; + } + + return 0; +} + +/** + * Close protocol opened for persistent use by a driver + * + * @v handle EFI handle + * @v protocol Protocol GUID + */ +void efi_close_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + + /* Close protocol */ + controller = handle; + bs->CloseProtocol ( handle, protocol, agent, controller ); +} + +/** + * Open protocol for persistent use by a child controller + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v child Child controller handle + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +int efi_open_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child, void **interface ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + unsigned int attributes; + EFI_STATUS efirc; + int rc; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + assert ( child != NULL ); + assert ( interface != NULL ); + + /* Open protocol + * + * We set ControllerHandle to a non-NULL value distinct from + * both Handle and AgentHandle to avoid collisions with other + * open types. + */ + controller = child; + assert ( controller != handle ); + assert ( controller != agent ); + attributes = EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER; + if ( ( efirc = bs->OpenProtocol ( handle, protocol, interface, agent, + controller, attributes ) ) != 0 ) { + rc = -EEFI ( efirc ); + *interface = NULL; + return rc; + } + + return 0; +} + +/** + * Close protocol opened for persistent use by a child controller + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v child Child controller handle + */ +void efi_close_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE agent = efi_image_handle; + EFI_HANDLE controller; + + /* Sanity checks */ + assert ( handle != NULL ); + assert ( protocol != NULL ); + assert ( child != NULL ); + + /* Close protocol */ + controller = child; + assert ( controller != handle ); + assert ( controller != agent ); + bs->CloseProtocol ( handle, protocol, agent, controller ); +} -- cgit v1.2.3-55-g7522 From 4561a03766de0d68870680e8bc40b9865d99f1e1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 17:49:39 +0000 Subject: [efi] Use efi_open_by_child() for all by-child protocol opens Signed-off-by: Michael Brown --- src/interface/efi/efi_utils.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 6ceba20e6..928d8e53a 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -120,19 +120,12 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, * @ret rc Return status code */ int efi_child_add ( EFI_HANDLE parent, EFI_HANDLE child ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; void *devpath; - EFI_STATUS efirc; int rc; /* Re-open the device path protocol */ - if ( ( efirc = bs->OpenProtocol ( parent, - &efi_device_path_protocol_guid, - &devpath, - efi_image_handle, child, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_child ( parent, &efi_device_path_protocol_guid, + child, &devpath ) ) != 0 ) { DBGC ( parent, "EFIDEV %s could not add child", efi_handle_name ( parent ) ); DBGC ( parent, " %s: %s\n", @@ -154,10 +147,8 @@ int efi_child_add ( EFI_HANDLE parent, EFI_HANDLE child ) { * @v child EFI child device handle */ void efi_child_del ( EFI_HANDLE parent, EFI_HANDLE child ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - bs->CloseProtocol ( parent, &efi_device_path_protocol_guid, - efi_image_handle, child ); + efi_close_by_child ( parent, &efi_device_path_protocol_guid, child ); DBGC2 ( parent, "EFIDEV %s removed child", efi_handle_name ( parent ) ); DBGC2 ( parent, " %s\n", efi_handle_name ( child ) ); } -- cgit v1.2.3-55-g7522 From 9dd30f11f74722a43ed590df9f525e038d155283 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 18:06:15 +0000 Subject: [efi] Use efi_open_by_driver() for all by-driver protocol opens Signed-off-by: Michael Brown --- src/drivers/net/efi/mnpnet.c | 20 +++++++------------- src/drivers/net/efi/nii.c | 16 ++++------------ src/drivers/net/efi/snpnet.c | 17 +++++------------ src/drivers/usb/usbio.c | 31 ++++++++----------------------- src/interface/efi/efi_file.c | 13 ++++--------- src/interface/efi/efi_pci.c | 18 +++++------------- src/interface/efi/efi_snp.c | 30 ++++++++++-------------------- 7 files changed, 43 insertions(+), 102 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/mnpnet.c b/src/drivers/net/efi/mnpnet.c index eb4b129c7..ead8691ff 100644 --- a/src/drivers/net/efi/mnpnet.c +++ b/src/drivers/net/efi/mnpnet.c @@ -367,7 +367,6 @@ static struct net_device_operations mnpnet_operations = { * @ret rc Return status code */ int mnpnet_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; EFI_SIMPLE_NETWORK_MODE mode; @@ -408,13 +407,9 @@ int mnpnet_start ( struct efi_device *efidev ) { } /* Open MNP protocol */ - if ( ( efirc = bs->OpenProtocol ( efidev->child, - &efi_managed_network_protocol_guid, - &u.interface, efi_image_handle, - efidev->child, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( efidev->child, + &efi_managed_network_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( mnp, "MNP %s could not open MNP protocol: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; @@ -464,8 +459,8 @@ int mnpnet_start ( struct efi_device *efidev ) { err_ll_addr_len: err_hw_addr_len: err_mode: - bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid, - efi_image_handle, efidev->child ); + efi_close_by_driver ( efidev->child, + &efi_managed_network_protocol_guid ); err_open: efi_service_del ( device, binding, efidev->child ); err_service: @@ -482,7 +477,6 @@ int mnpnet_start ( struct efi_device *efidev ) { * @v efidev EFI device */ void mnpnet_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; struct net_device *netdev = efidev_get_drvdata ( efidev ); struct mnp_nic *mnp = netdev->priv; @@ -491,8 +485,8 @@ void mnpnet_stop ( struct efi_device *efidev ) { unregister_netdev ( netdev ); /* Close MNP protocol */ - bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid, - efi_image_handle, efidev->child ); + efi_close_by_driver ( efidev->child, + &efi_managed_network_protocol_guid ); /* Remove MNP child (unless whole system shutdown is in progress) */ if ( ! efi_shutdown_in_progress ) diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 16e9e10df..18b292e56 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -1270,12 +1270,10 @@ static struct net_device_operations nii_operations = { * @ret rc Return status code */ int nii_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; struct net_device *netdev; struct nii_nic *nii; void *interface; - EFI_STATUS efirc; int rc; /* Allocate and initialise structure */ @@ -1300,11 +1298,8 @@ int nii_start ( struct efi_device *efidev ) { netdev->dev = &nii->dev; /* Open NII protocol */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_nii31_protocol_guid, - &interface, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( device, &efi_nii31_protocol_guid, + &interface ) ) != 0 ) { DBGC ( nii, "NII %s cannot open NII protocol: %s\n", nii->dev.name, strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_nii31_protocol_guid ); @@ -1373,8 +1368,7 @@ int nii_start ( struct efi_device *efidev ) { err_pci_open: err_hw_undi: err_no_undi: - bs->CloseProtocol ( device, &efi_nii31_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_nii31_protocol_guid ); err_open_protocol: list_del ( &nii->dev.siblings ); netdev_nullify ( netdev ); @@ -1389,7 +1383,6 @@ int nii_start ( struct efi_device *efidev ) { * @v efidev EFI device */ void nii_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct net_device *netdev = efidev_get_drvdata ( efidev ); struct nii_nic *nii = netdev->priv; EFI_HANDLE device = efidev->device; @@ -1404,8 +1397,7 @@ void nii_stop ( struct efi_device *efidev ) { nii_pci_close ( nii ); /* Close NII protocol */ - bs->CloseProtocol ( device, &efi_nii31_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_nii31_protocol_guid ); /* Free network device */ list_del ( &nii->dev.siblings ); diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 6ce731d78..fb071d8d3 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -539,7 +539,6 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { * @ret rc Return status code */ int snpnet_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; EFI_SIMPLE_NETWORK_MODE *mode; struct net_device *netdev; @@ -549,12 +548,9 @@ int snpnet_start ( struct efi_device *efidev ) { int rc; /* Open SNP protocol */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_simple_network_protocol_guid, - &interface, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( device, + &efi_simple_network_protocol_guid, + &interface ) ) != 0 ) { DBGC ( device, "SNP %s cannot open SNP protocol: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, @@ -644,8 +640,7 @@ int snpnet_start ( struct efi_device *efidev ) { netdev_nullify ( netdev ); netdev_put ( netdev ); err_alloc: - bs->CloseProtocol ( device, &efi_simple_network_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_simple_network_protocol_guid ); err_open_protocol: return rc; } @@ -656,7 +651,6 @@ int snpnet_start ( struct efi_device *efidev ) { * @v efidev EFI device */ void snpnet_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct net_device *netdev = efidev_get_drvdata ( efidev ); struct snp_nic *snp = netdev->priv; EFI_HANDLE device = efidev->device; @@ -681,6 +675,5 @@ void snpnet_stop ( struct efi_device *efidev ) { netdev_put ( netdev ); /* Close SNP protocol */ - bs->CloseProtocol ( device, &efi_simple_network_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_simple_network_protocol_guid ); } diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index 278b43cd3..c5f245fc3 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -229,13 +229,9 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { } /* Open USB I/O protocol on this handle */ - if ( ( efirc = bs->OpenProtocol ( intf->handle, - &efi_usb_io_protocol_guid, - &u.interface, efi_image_handle, - intf->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( intf->handle, + &efi_usb_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open ", efi_handle_name ( handle ) ); DBGC ( usbio, "%s: %s\n", @@ -259,7 +255,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { * @v interface Interface number */ static void usbio_close ( struct usbio_device *usbio, unsigned int interface ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct usbio_interface *intf = &usbio->interface[interface]; /* Sanity checks */ @@ -274,8 +269,7 @@ static void usbio_close ( struct usbio_device *usbio, unsigned int interface ) { return; /* Close USB I/O protocol */ - bs->CloseProtocol ( intf->handle, &efi_usb_io_protocol_guid, - efi_image_handle, intf->handle ); + efi_close_by_driver ( intf->handle, &efi_usb_io_protocol_guid ); } /****************************************************************************** @@ -1608,7 +1602,6 @@ static int usbio_interfaces ( struct usbio_device *usbio ) { * @ret rc Return status code */ static int usbio_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE handle = efidev->device; struct usbio_device *usbio; struct usb_port *port; @@ -1616,7 +1609,6 @@ static int usbio_start ( struct efi_device *efidev ) { void *interface; EFI_USB_IO_PROTOCOL *io; } u; - EFI_STATUS efirc; int rc; /* Allocate and initialise structure */ @@ -1630,12 +1622,8 @@ static int usbio_start ( struct efi_device *efidev ) { INIT_LIST_HEAD ( &usbio->endpoints ); /* Open USB I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid, - &u.interface, efi_image_handle, - handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( handle, &efi_usb_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open USB I/O protocol: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); DBGC_EFI_OPENERS ( usbio, handle, &efi_usb_io_protocol_guid ); @@ -1692,8 +1680,7 @@ static int usbio_start ( struct efi_device *efidev ) { free ( usbio->config ); err_config: list_del ( &usbio->dev.siblings ); - bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_usb_io_protocol_guid ); err_open_usbio: free ( usbio ); err_alloc: @@ -1706,7 +1693,6 @@ static int usbio_start ( struct efi_device *efidev ) { * @v efidev EFI device */ static void usbio_stop ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE handle = efidev->device; struct usbio_device *usbio = efidev_get_drvdata ( efidev ); @@ -1716,8 +1702,7 @@ static void usbio_stop ( struct efi_device *efidev ) { free ( usbio->path ); free ( usbio->config ); list_del ( &usbio->dev.siblings ); - bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_usb_io_protocol_guid ); free ( usbio ); } diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 48fccdbe1..f31f2fe3b 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -1169,11 +1169,8 @@ int efi_file_install ( EFI_HANDLE handle ) { * of calls to our DRIVER_STOP method when starting the EFI * shell. I have no idea why this is. */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_disk_io_protocol_guid, - &diskio.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_BY_DRIVER ) ) != 0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( handle, &efi_disk_io_protocol_guid, + &diskio.interface ) ) != 0 ) { DBGC ( handle, "Could not open disk I/O protocol: %s\n", strerror ( rc ) ); DBGC_EFI_OPENERS ( handle, handle, &efi_disk_io_protocol_guid ); @@ -1199,8 +1196,7 @@ int efi_file_install ( EFI_HANDLE handle ) { efi_file_path_uninstall ( &efi_file_initrd ); err_initrd_install: err_initrd_claim: - bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_disk_io_protocol_guid ); err_open: bs->UninstallMultipleProtocolInterfaces ( handle, @@ -1228,8 +1224,7 @@ void efi_file_uninstall ( EFI_HANDLE handle ) { efi_file_path_uninstall ( &efi_file_initrd ); /* Close our own disk I/O protocol */ - bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_disk_io_protocol_guid ); /* We must install the file system protocol first, since * otherwise the EDK2 code will attempt to helpfully uninstall diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index d55cbe86c..b53a88d66 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -902,11 +902,9 @@ static int efipci_supported ( EFI_HANDLE device ) { * @ret rc Return status code */ static int efipci_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; struct efi_pci_device *efipci; void *pci_io; - EFI_STATUS efirc; int rc; /* Allocate PCI device */ @@ -920,12 +918,9 @@ static int efipci_start ( struct efi_device *efidev ) { if ( ( rc = efipci_info ( device, efipci ) ) != 0 ) goto err_info; - /* Open PCI device */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI_PCI ( efirc ); + /* Open PCI I/O protocol */ + if ( ( rc = efi_open_by_driver ( device, &efi_pci_io_protocol_guid, + &pci_io ) ) != 0 ) { DBGC ( device, "EFIPCI %s could not open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_pci_io_protocol_guid ); @@ -960,8 +955,7 @@ static int efipci_start ( struct efi_device *efidev ) { err_probe: list_del ( &efipci->pci.dev.siblings ); err_find_driver: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_pci_io_protocol_guid ); err_open: err_info: free ( efipci ); @@ -976,15 +970,13 @@ static int efipci_start ( struct efi_device *efidev ) { */ static void efipci_stop ( struct efi_device *efidev ) { struct efi_pci_device *efipci = efidev_get_drvdata ( efidev ); - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; pci_remove ( &efipci->pci ); list_del ( &efipci->pci.dev.siblings ); assert ( efipci->pci.dma.mapped == 0 ); assert ( efipci->pci.dma.allocated == 0 ); - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_pci_io_protocol_guid ); free ( efipci ); } diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index d977802fd..b9706d5ab 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -1916,22 +1916,16 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { * instances to prevent SnpDxe from attempting to bind to * them. */ - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii; } - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii31_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii31_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII31 protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii31; @@ -1967,11 +1961,9 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { leak |= efi_snp_hii_uninstall ( snpdev ); efi_child_del ( efidev->device, snpdev->handle ); err_efi_child_add: - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); err_open_nii31: - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); err_open_nii: if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, @@ -2060,10 +2052,8 @@ static void efi_snp_remove ( struct net_device *netdev, void *priv __unused ) { if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); efi_child_del ( snpdev->efidev->device, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); if ( ( ! efi_shutdown_in_progress ) && ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, -- cgit v1.2.3-55-g7522 From 5a5e2a1dae525aecf97dffde2236b74710735c8d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 19:38:14 +0000 Subject: [efi] Use efi_open_unsafe() for all explicitly unsafe protocol opens Signed-off-by: Michael Brown --- src/drivers/net/efi/nii.c | 21 ++++++++++----------- src/interface/efi/efi_bofm.c | 9 +++------ src/interface/efi/efi_console.c | 11 +++-------- src/interface/efi/efi_init.c | 15 +++++++++------ 4 files changed, 25 insertions(+), 31 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 18b292e56..126584eff 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -230,12 +230,14 @@ static int nii_pci_open ( struct nii_nic *nii ) { } nii->pci_device = pci_device; - /* Open PCI I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( pci_device, &efi_pci_io_protocol_guid, - &pci_io.interface, efi_image_handle, - device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + /* Open PCI I/O protocol + * + * We cannot open this safely as a by-driver open, since doing + * so would disconnect the underlying NII driver. We must + * therefore use an unsafe open. + */ + if ( ( rc = efi_open_unsafe ( pci_device, &efi_pci_io_protocol_guid, + &pci_io.interface ) ) != 0 ) { DBGC ( nii, "NII %s could not open PCI I/O protocol: %s\n", nii->dev.name, strerror ( rc ) ); goto err_open; @@ -280,8 +282,7 @@ static int nii_pci_open ( struct nii_nic *nii ) { return 0; err_get_bar_attributes: - bs->CloseProtocol ( pci_device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_unsafe ( pci_device, &efi_pci_io_protocol_guid ); err_open: err_locate: return rc; @@ -294,7 +295,6 @@ static int nii_pci_open ( struct nii_nic *nii ) { * @ret rc Return status code */ static void nii_pci_close ( struct nii_nic *nii ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct nii_mapping *map; struct nii_mapping *tmp; @@ -308,8 +308,7 @@ static void nii_pci_close ( struct nii_nic *nii ) { } /* Close protocols */ - bs->CloseProtocol ( nii->pci_device, &efi_pci_io_protocol_guid, - efi_image_handle, nii->efidev->device ); + efi_close_unsafe ( nii->pci_device, &efi_pci_io_protocol_guid ); } /** diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 1be68bf8b..6d97ff445 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -241,10 +241,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) { } /* Open PCI I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io, efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_unsafe ( device, &efi_pci_io_protocol_guid, + &pci_io ) ) != 0 ) { DBGC ( device, "EFIBOFM %s cannot open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; @@ -326,8 +324,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) { err_set_status: err_locate_bofm: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_unsafe ( device, &efi_pci_io_protocol_guid ); err_open: err_info: return rc; diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 04bbd9e0c..41c4dcf2c 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -415,13 +415,11 @@ struct console_driver efi_console __console_driver = { * */ static void efi_console_init ( void ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_CONSOLE_CONTROL_SCREEN_MODE mode; union { void *interface; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *wtf; } u; - EFI_STATUS efirc; int rc; /* On some older EFI 1.10 implementations, we must use the @@ -441,15 +439,12 @@ static void efi_console_init ( void ) { * apparently the expected behaviour for all UEFI * applications. Don't ask. */ - if ( ( efirc = bs->OpenProtocol ( efi_systab->ConsoleInHandle, - &efi_simple_text_input_ex_protocol_guid, - &u.interface, efi_image_handle, - efi_systab->ConsoleInHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) == 0 ) { + if ( ( rc = efi_open_unsafe ( efi_systab->ConsoleInHandle, + &efi_simple_text_input_ex_protocol_guid, + &u.interface ) ) == 0 ) { efi_conin_ex = u.wtf; DBG ( "EFI using SimpleTextInputEx\n" ); } else { - rc = -EEFI ( efirc ); DBG ( "EFI has no SimpleTextInputEx: %s\n", strerror ( rc ) ); } } diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index d3c5042d7..a45ee66a4 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -241,14 +241,17 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, } } - /* Get loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( image_handle, - &efi_loaded_image_protocol_guid, - &loaded_image, image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + /* Get loaded image protocol + * + * We assume that our loaded image protocol will not be + * uninstalled while our image code is still running. + */ + if ( ( rc = efi_open_unsafe ( image_handle, + &efi_loaded_image_protocol_guid, + &loaded_image ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image protocol: %s", strerror ( rc ) ); + efirc = EFIRC ( rc ); goto err_no_loaded_image; } efi_loaded_image = loaded_image; -- cgit v1.2.3-55-g7522 From bac318743905e55ce424104cafbc8418e0672a80 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 19:11:13 +0000 Subject: [efi] Use efi_open() for all ephemeral protocol opens Signed-off-by: Michael Brown --- src/drivers/net/efi/snpnet.c | 8 +--- src/drivers/net/efi/snponly.c | 33 ++++----------- src/drivers/usb/usbio.c | 68 +++++++----------------------- src/image/efi_image.c | 7 +--- src/interface/efi/efi_autoboot.c | 14 +------ src/interface/efi/efi_block.c | 67 +++++++----------------------- src/interface/efi/efi_cachedhcp.c | 33 ++++----------- src/interface/efi/efi_debug.c | 50 ++++++---------------- src/interface/efi/efi_driver.c | 27 ++++-------- src/interface/efi/efi_init.c | 9 ++-- src/interface/efi/efi_local.c | 22 +++------- src/interface/efi/efi_pci.c | 87 +++++++++------------------------------ src/interface/efi/efi_service.c | 36 ++++------------ src/interface/efi/efi_shim.c | 21 +++------- src/interface/efi/efi_utils.c | 13 +----- src/interface/efi/efi_veto.c | 64 ++++++---------------------- src/interface/efi/efi_wrap.c | 13 +----- 17 files changed, 130 insertions(+), 442 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index fb071d8d3..93ed8cd95 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -493,9 +493,7 @@ static struct net_device_operations snpnet_operations = { * @ret rc Return status code */ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE parent; - EFI_STATUS efirc; int rc; /* Check that this is not a device we are providing ourselves */ @@ -506,13 +504,11 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { } /* Test for presence of protocol */ - if ( ( efirc = bs->OpenProtocol ( device, protocol, - NULL, efi_image_handle, device, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){ + if ( ( rc = efi_open ( device, protocol, NULL ) ) != 0 ) { DBGCP ( device, "HANDLE %s is not a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); - return -EEFI ( efirc ); + return rc; } /* Check that there are no instances of this protocol further diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 2ae63fc06..80ddfe00d 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -86,13 +86,11 @@ static struct chained_protocol chained_mnp = { * @v chained Chainloaded protocol */ static void chained_locate ( struct chained_protocol *chained ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efi_loaded_image->DeviceHandle; EFI_HANDLE handle; void *match = NULL; void *interface; unsigned int skip; - EFI_STATUS efirc; int rc; /* Identify target device handle */ @@ -111,11 +109,8 @@ static void chained_locate ( struct chained_protocol *chained ) { } /* Get protocol instance */ - if ( ( efirc = bs->OpenProtocol ( - handle, chained->protocol, &interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL )) != 0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, chained->protocol, + &interface ) ) != 0 ) { DBGC ( device, "CHAINED %s could not open %s on ", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); @@ -123,8 +118,6 @@ static void chained_locate ( struct chained_protocol *chained ) { efi_handle_name ( handle ), strerror ( rc ) ); break; } - bs->CloseProtocol ( handle, chained->protocol, - efi_image_handle, handle ); /* Stop if we reach a non-matching protocol instance */ if ( match && ( match != interface ) ) { @@ -154,20 +147,16 @@ static void chained_locate ( struct chained_protocol *chained ) { */ static int chained_supported ( EFI_HANDLE device, struct chained_protocol *chained ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; void *interface; - EFI_STATUS efirc; int rc; /* Get protocol */ - if ( ( efirc = bs->OpenProtocol ( device, chained->protocol, &interface, - efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, chained->protocol, + &interface ) ) != 0 ) { DBGCP ( device, "CHAINED %s is not a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); - goto err_open_protocol; + return rc; } /* Ignore non-matching handles */ @@ -175,21 +164,13 @@ static int chained_supported ( EFI_HANDLE device, DBGC2 ( device, "CHAINED %s is not the chainloaded %s\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); - rc = -ENOTTY; - goto err_no_match; + return -ENOTTY; } - /* Success */ - rc = 0; DBGC ( device, "CHAINED %s is the chainloaded %s\n", efi_handle_name ( device ), efi_guid_ntoa ( chained->protocol ) ); - - err_no_match: - bs->CloseProtocol ( device, chained->protocol, efi_image_handle, - device ); - err_open_protocol: - return rc; + return 0; } /** diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index c5f245fc3..db3beff21 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1291,7 +1291,6 @@ static struct usb_host_operations usbio_operations = { * @ret rc Return status code */ static int usbio_supported ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_USB_DEVICE_DESCRIPTOR device; EFI_USB_INTERFACE_DESCRIPTOR interface; struct usb_function_descriptor desc; @@ -1305,14 +1304,11 @@ static int usbio_supported ( EFI_HANDLE handle ) { int rc; /* Get protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid, - &usb.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_usb_io_protocol_guid, + &usb.interface ) ) != 0 ) { DBGCP ( handle, "USB %s is not a USB device\n", efi_handle_name ( handle ) ); - goto err_open_protocol; + return rc; } /* Get device descriptor */ @@ -1321,7 +1317,7 @@ static int usbio_supported ( EFI_HANDLE handle ) { rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get device descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_get_device_descriptor; + return rc; } memset ( &desc, 0, sizeof ( desc ) ); desc.vendor = device.IdVendor; @@ -1333,7 +1329,7 @@ static int usbio_supported ( EFI_HANDLE handle ) { rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get interface descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_get_interface_descriptor; + return rc; } desc.class.class.class = interface.InterfaceClass; desc.class.class.subclass = interface.InterfaceSubClass; @@ -1341,21 +1337,10 @@ static int usbio_supported ( EFI_HANDLE handle ) { /* Look for a driver for this interface */ driver = usb_find_driver ( &desc, &id ); - if ( ! driver ) { - rc = -ENOTSUP; - goto err_unsupported; - } - - /* Success */ - rc = 0; + if ( ! driver ) + return -ENOTSUP; - err_unsupported: - err_get_interface_descriptor: - err_get_device_descriptor: - bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid, - efi_image_handle, handle ); - err_open_protocol: - return rc; + return 0; } /** @@ -1471,7 +1456,6 @@ static int usbio_config ( struct usbio_device *usbio ) { * @ret rc Return status code */ static int usbio_path ( struct usbio_device *usbio ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE handle = usbio->handle; EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; @@ -1481,19 +1465,14 @@ static int usbio_path ( struct usbio_device *usbio ) { EFI_DEVICE_PATH_PROTOCOL *path; } u; size_t len; - EFI_STATUS efirc; int rc; /* Open device path protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_device_path_protocol_guid, - &u.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open device path protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open_protocol; + return rc; } path = u.interface; @@ -1502,8 +1481,7 @@ static int usbio_path ( struct usbio_device *usbio ) { if ( len < sizeof ( *usbpath ) ) { DBGC ( usbio, "USBIO %s underlength device path\n", efi_handle_name ( handle ) ); - rc = -EINVAL; - goto err_underlength; + return -EINVAL; } usbpath = ( ( ( void * ) path ) + len - sizeof ( *usbpath ) ); if ( ! ( ( usbpath->Header.Type == MESSAGING_DEVICE_PATH ) && @@ -1511,34 +1489,18 @@ static int usbio_path ( struct usbio_device *usbio ) { DBGC ( usbio, "USBIO %s not a USB device path: ", efi_handle_name ( handle ) ); DBGC ( usbio, "%s\n", efi_devpath_text ( path ) ); - rc = -EINVAL; - goto err_non_usb; + return -EINVAL; } /* Allocate copy of device path */ usbio->path = malloc ( len + sizeof ( *end ) ); - if ( ! usbio->path ) { - rc = -ENOMEM; - goto err_alloc; - } + if ( ! usbio->path ) + return -ENOMEM; memcpy ( usbio->path, path, ( len + sizeof ( *end ) ) ); usbio->usbpath = ( ( ( void * ) usbio->path ) + len - sizeof ( *usbpath ) ); - /* Close protocol */ - bs->CloseProtocol ( handle, &efi_device_path_protocol_guid, - efi_image_handle, handle ); - return 0; - - free ( usbio->path ); - err_alloc: - err_non_usb: - err_underlength: - bs->CloseProtocol ( handle, &efi_device_path_protocol_guid, - efi_image_handle, handle ); - err_open_protocol: - return rc; } /** diff --git a/src/image/efi_image.c b/src/image/efi_image.c index d2171e7de..ae9255ce5 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -234,12 +234,9 @@ static int efi_image_exec ( struct image *image ) { } /* Get the loaded image protocol for the newly loaded image */ - efirc = bs->OpenProtocol ( handle, &efi_loaded_image_protocol_guid, - &loaded.interface, efi_image_handle, - NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - if ( efirc ) { + if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, + &loaded.interface ) ) != 0 ) { /* Should never happen */ - rc = -EEFI ( efirc ); goto err_open_protocol; } diff --git a/src/interface/efi/efi_autoboot.c b/src/interface/efi/efi_autoboot.c index a103c2f19..528b84f1e 100644 --- a/src/interface/efi/efi_autoboot.c +++ b/src/interface/efi/efi_autoboot.c @@ -48,23 +48,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_set_autoboot_ll_addr ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_SIMPLE_NETWORK_PROTOCOL *snp; void *interface; } snp; EFI_SIMPLE_NETWORK_MODE *mode; - EFI_STATUS efirc; unsigned int vlan; int rc; /* Look for an SNP instance on the image's device handle */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_simple_network_protocol_guid, - &snp.interface, efi_image_handle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid, + &snp.interface ) ) != 0 ) { DBGC ( device, "EFI %s has no SNP instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; @@ -90,9 +84,5 @@ int efi_set_autoboot_ll_addr ( EFI_HANDLE device, efi_handle_name ( device ), vlan ); } - /* Close protocol */ - bs->CloseProtocol ( device, &efi_simple_network_protocol_guid, - efi_image_handle, NULL ); - return 0; } diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 6296953c5..34b73c265 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -518,8 +518,6 @@ static int efi_block_describe ( void ) { */ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, EFI_FILE_PROTOCOL **root ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_simple_file_system_protocol_guid; union { EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; void *interface; @@ -528,13 +526,11 @@ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, int rc; /* Open filesystem protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_simple_file_system_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s filesystem: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open; + return rc; } /* Open root volume */ @@ -542,16 +538,10 @@ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, rc = -EEFI ( efirc ); DBGC ( drive, "EFIBLK %#02x could not open %s root: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); - goto err_volume; + return rc; } - /* Success */ - rc = 0; - - err_volume: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); - err_open: - return rc; + return 0; } /** @@ -674,22 +664,17 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, EFI_DEVICE_PATH_PROTOCOL *path, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_device_path_protocol_guid; union { EFI_DEVICE_PATH_PROTOCOL *path; void *interface; } u; EFI_FILE *root; union uuid guid; - EFI_STATUS efirc; int rc; /* Identify device path */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s device path: " "%s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); @@ -758,7 +743,6 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, err_wrong_guid: err_no_guid: err_not_child: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); err_open: return rc; } @@ -776,7 +760,6 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_device_path_protocol_guid; union { EFI_DEVICE_PATH_PROTOCOL *path; void *interface; @@ -791,10 +774,8 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, efi_block_connect ( drive, handle ); /* Identify device path */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open device path: %s\n", drive, strerror ( rc ) ); goto err_open; @@ -824,7 +805,6 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, bs->FreePool ( handles ); err_locate: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); err_open: return rc; } @@ -921,52 +901,37 @@ static int efi_block_exec ( unsigned int drive, * equivalent functionality to BIOS drive numbers. */ static int efi_block_local ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_GUID *protocol = &efi_block_io_protocol_guid; struct san_device *sandev; struct efi_block_data *block; union { EFI_BLOCK_IO_PROTOCOL *blockio; void *interface; } u; - EFI_STATUS efirc; int rc; /* Check if handle belongs to a SAN device */ for_each_sandev ( sandev ) { block = sandev->priv; - if ( handle == block->handle ) { - rc = -ENOTTY; - goto err_sandev; - } + if ( handle == block->handle ) + return -ENOTTY; } /* Open block I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, protocol, &u.interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_block_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( handle, "EFIBLK %s could not open block I/O: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open; + return rc; } /* Do not assign drive numbers for partitions */ if ( u.blockio->Media->LogicalPartition ) { - rc = -ENOTTY; DBGC2 ( handle, "EFLBLK %s is a partition\n", efi_handle_name ( handle ) ); - goto err_partition; + return -ENOTTY; } - /* Success */ - rc = 0; - - err_partition: - bs->CloseProtocol ( handle, protocol, efi_image_handle, handle ); - err_open: - err_sandev: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index b9e49cf48..68671d7c6 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -46,38 +46,31 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_cachedhcp_record ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; unsigned int vlan; union { EFI_PXE_BASE_CODE_PROTOCOL *pxe; void *interface; } pxe; EFI_PXE_BASE_CODE_MODE *mode; - EFI_STATUS efirc; int rc; /* Get VLAN tag, if any */ vlan = efi_path_vlan ( path ); /* Look for a PXE base code instance on the image's device handle */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_pxe_base_code_protocol_guid, - &pxe.interface, efi_image_handle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_pxe_base_code_protocol_guid, + &pxe.interface ) ) != 0 ) { DBGC ( device, "EFI %s has no PXE base code instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_open; + return rc; } /* Do not attempt to cache IPv6 packets */ mode = pxe.pxe->Mode; if ( mode->UsingIpv6 ) { - rc = -ENOTSUP; DBGC ( device, "EFI %s has IPv6 PXE base code\n", efi_handle_name ( device ) ); - goto err_ipv6; + return -ENOTSUP; } /* Record DHCPACK, if present */ @@ -87,7 +80,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, sizeof ( mode->DhcpAck ) ) ) != 0 ) ) { DBGC ( device, "EFI %s could not record DHCPACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_dhcpack; + return rc; } /* Record ProxyDHCPOFFER, if present */ @@ -97,7 +90,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, sizeof ( mode->ProxyOffer ) ) ) != 0)){ DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_proxydhcp; + return rc; } /* Record PxeBSACK, if present */ @@ -107,18 +100,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device, sizeof ( mode->PxeReply ) ) ) != 0)){ DBGC ( device, "EFI %s could not record PXEBSACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_pxebs; + return rc; } - /* Success */ - rc = 0; - - err_pxebs: - err_proxydhcp: - err_dhcpack: - err_ipv6: - bs->CloseProtocol ( device, &efi_pxe_base_code_protocol_guid, - efi_image_handle, NULL ); - err_open: - return rc; + return 0; } diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 6f71949fb..ef650d989 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -328,14 +328,12 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) { * @ret name Driver name, or NULL */ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_COMPONENT_NAME_PROTOCOL *name; void *interface; } u; EFI_HANDLE image; - const char *name; - EFI_STATUS efirc; + int rc; /* Sanity check */ if ( ! binding ) { @@ -345,22 +343,14 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { /* Try to open component name protocol on image handle */ image = binding->ImageHandle; - if ( ( efirc = bs->OpenProtocol ( image, - &efi_component_name_protocol_guid, - &u.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){ + if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, + &u.interface ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName]" ); return NULL; } /* Try to get name from component name protocol */ - name = efi_driver_name ( u.name ); - - /* Close component name protocol */ - bs->CloseProtocol ( image, &efi_component_name_protocol_guid, - efi_image_handle, image ); - - return name; + return efi_driver_name ( u.name ); } /** @@ -370,14 +360,12 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { * @ret name Driver name, or NULL */ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE image; union { EFI_COMPONENT_NAME2_PROTOCOL *name2; void *interface; } u; - const char *name; - EFI_STATUS efirc; + int rc; /* Sanity check */ if ( ! binding ) { @@ -387,22 +375,14 @@ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ /* Try to open component name protocol on image handle */ image = binding->ImageHandle; - if ( ( efirc = bs->OpenProtocol ( image, - &efi_component_name2_protocol_guid, - &u.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){ + if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, + &u.interface ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName2]" ); return NULL; } /* Try to get name from component name protocol */ - name = efi_driver_name2 ( u.name2 ); - - /* Close component name protocol */ - bs->CloseProtocol ( image, &efi_component_name2_protocol_guid, - efi_image_handle, image ); - - return name; + return efi_driver_name2 ( u.name2 ); } /** @@ -669,6 +649,7 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) { void *interface; const char *name; EFI_STATUS efirc; + int rc; /* Fail immediately for NULL handles */ if ( ! handle ) @@ -681,10 +662,8 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) { DBG2 ( "<%d", i ); /* Try to open the applicable protocol */ - efirc = bs->OpenProtocol ( handle, type->protocol, &interface, - efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - if ( efirc != 0 ) { + if ( ( rc = efi_open ( handle, type->protocol, + &interface ) ) != 0 ) { DBG2 ( ">" ); continue; } @@ -692,12 +671,7 @@ const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) { /* Try to get name from this protocol */ DBG2 ( "-" ); name = type->name ( interface ); - DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) ); - - /* Close protocol */ - bs->CloseProtocol ( handle, type->protocol, - efi_image_handle, handle ); - DBG2 ( ">" ); + DBG2 ( "%c>", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) ); /* Use this name, if possible */ if ( name && name[0] ) diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index fd9be5f51..d143249ca 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -68,7 +68,6 @@ static int efi_driver_disconnecting; * @ret efidev EFI device, or NULL on error */ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct efi_device *efidev = NULL; union { EFI_DEVICE_PATH_PROTOCOL *path; @@ -76,26 +75,21 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { } path; EFI_DEVICE_PATH_PROTOCOL *path_end; size_t path_len; - EFI_STATUS efirc; int rc; /* Open device path */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_device_path_protocol_guid, - &path.interface, efi_image_handle, - device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, + &path.interface ) ) != 0 ) { DBGC ( device, "EFIDRV %s could not open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_open_path; + return NULL; } path_len = ( efi_path_len ( path.path ) + sizeof ( *path_end ) ); /* Allocate and initialise structure */ efidev = zalloc ( sizeof ( *efidev ) + path_len ); if ( ! efidev ) - goto err_alloc; + return NULL; efidev->device = device; efidev->dev.desc.bus_type = BUS_TYPE_EFI; efidev->path = ( ( ( void * ) efidev ) + sizeof ( *efidev ) ); @@ -103,10 +97,6 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { INIT_LIST_HEAD ( &efidev->dev.children ); list_add ( &efidev->dev.siblings, &efi_devices ); - err_alloc: - bs->CloseProtocol ( device, &efi_device_path_protocol_guid, - efi_image_handle, device ); - err_open_path: return efidev; } @@ -375,21 +365,18 @@ static EFI_STATUS EFIAPI efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, EFI_HANDLE device, EFI_HANDLE child, CHAR8 *language, CHAR16 **controller_name ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_COMPONENT_NAME2_PROTOCOL *name2; void *interface; } name2; - EFI_STATUS efirc; + int rc; /* Delegate to the EFI_COMPONENT_NAME2_PROTOCOL instance * installed on child handle, if present. */ if ( ( child != NULL ) && - ( ( efirc = bs->OpenProtocol ( - child, &efi_component_name2_protocol_guid, - &name2.interface, NULL, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) == 0 ) ) { + ( ( rc = efi_open ( child, &efi_component_name2_protocol_guid, + &name2.interface ) ) == 0 ) ) { return name2.name2->GetControllerName ( name2.name2, device, child, language, controller_name ); diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index a45ee66a4..03506ec5c 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -263,13 +263,12 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, efi_cmdline_len = efi_loaded_image->LoadOptionsSize; /* Get loaded image's device handle's device path */ - if ( ( efirc = bs->OpenProtocol ( efi_loaded_image->DeviceHandle, - &efi_device_path_protocol_guid, - &device_path, image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( efi_loaded_image->DeviceHandle, + &efi_device_path_protocol_guid, + &device_path ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image's device path: " "%s", strerror ( rc ) ); + efirc = EFIRC ( rc ); goto err_no_device_path; } diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c index ec6d93a1d..80cfb5a22 100644 --- a/src/interface/efi/efi_local.c +++ b/src/interface/efi/efi_local.c @@ -208,7 +208,6 @@ static int efi_local_check_volume_name ( struct efi_local *local, */ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, EFI_FILE_PROTOCOL **root ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { void *interface; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; @@ -217,15 +216,11 @@ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, int rc; /* Open file system protocol */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_simple_file_system_protocol_guid, - &u.interface, efi_image_handle, - device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_simple_file_system_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( local, "LOCAL %p could not open filesystem on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); - goto err_filesystem; + return rc; } /* Open root directory */ @@ -233,17 +228,10 @@ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, rc = -EEFI ( efirc ); DBGC ( local, "LOCAL %p could not open volume on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); - goto err_volume; + return rc; } - /* Success */ - rc = 0; - - err_volume: - bs->CloseProtocol ( device, &efi_simple_file_system_protocol_guid, - efi_image_handle, device ); - err_filesystem: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index b53a88d66..003fa2f4a 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -72,7 +72,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, struct pci_range *range ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { void *interface; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; @@ -94,15 +93,12 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, range->count = 0; /* Open root bridge I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_pci_root_bridge_io_protocol_guid, - &root.interface, efi_image_handle, handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_pci_root_bridge_io_protocol_guid, + &root.interface ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); - goto err_open; + return rc; } /* Get ACPI resource descriptors */ @@ -112,7 +108,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, DBGC ( pci, "EFIPCI " PCI_FMT " cannot get configuration for " "%s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); - goto err_config; + return rc; } /* Parse resource descriptors */ @@ -159,14 +155,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, range->count = PCI_BUSDEVFN ( 0, 1, 0, 0 ); } - /* Success */ - rc = 0; - - err_config: - bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid, - efi_image_handle, handle ); - err_open: - return rc; + return 0; } /** @@ -260,7 +249,7 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { } /** - * Open EFI PCI root bridge I/O protocol + * Open EFI PCI root bridge I/O protocol for ephemeral use * * @v pci PCI device * @ret handle EFI PCI root bridge handle @@ -269,25 +258,20 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { */ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct pci_range tmp; union { void *interface; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; } u; - EFI_STATUS efirc; int rc; /* Find matching root bridge I/O protocol handle */ if ( ( rc = efipci_discover_any ( pci, &tmp, handle ) ) != 0 ) return rc; - /* (Re)open PCI root bridge I/O protocol */ - if ( ( efirc = bs->OpenProtocol ( *handle, - &efi_pci_root_bridge_io_protocol_guid, - &u.interface, efi_image_handle, *handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + /* Open PCI root bridge I/O protocol */ + if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( *handle ), strerror ( rc ) ); @@ -300,19 +284,6 @@ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, return 0; } -/** - * Close EFI PCI root bridge I/O protocol - * - * @v handle EFI PCI root bridge handle - */ -static void efipci_root_close ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - - /* Close protocol */ - bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid, - efi_image_handle, handle ); -} - /** * Calculate EFI PCI configuration space address * @@ -346,7 +317,7 @@ int efipci_read ( struct pci_device *pci, unsigned long location, /* Open root bridge */ if ( ( rc = efipci_root_open ( pci, &handle, &root ) ) != 0 ) - goto err_root; + return rc; /* Read from configuration space */ if ( ( efirc = root->Pci.Read ( root, EFIPCI_WIDTH ( location ), @@ -356,13 +327,10 @@ int efipci_read ( struct pci_device *pci, unsigned long location, DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx " "failed: %s\n", PCI_ARGS ( pci ), EFIPCI_OFFSET ( location ), strerror ( rc ) ); - goto err_read; + return rc; } - err_read: - efipci_root_close ( handle ); - err_root: - return rc; + return 0; } /** @@ -382,7 +350,7 @@ int efipci_write ( struct pci_device *pci, unsigned long location, /* Open root bridge */ if ( ( rc = efipci_root_open ( pci, &handle, &root ) ) != 0 ) - goto err_root; + return rc; /* Read from configuration space */ if ( ( efirc = root->Pci.Write ( root, EFIPCI_WIDTH ( location ), @@ -392,13 +360,10 @@ int efipci_write ( struct pci_device *pci, unsigned long location, DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx " "failed: %s\n", PCI_ARGS ( pci ), EFIPCI_OFFSET ( location ), strerror ( rc ) ); - goto err_write; + return rc; } - err_write: - efipci_root_close ( handle ); - err_root: - return rc; + return 0; } /** @@ -469,7 +434,6 @@ void * efipci_ioremap ( struct pci_device *pci, unsigned long bus_addr, } err_config: - efipci_root_close ( handle ); err_root: return ioremap ( bus_addr, len ); } @@ -778,7 +742,6 @@ static struct dma_operations efipci_dma_operations = { * @ret rc Return status code */ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_PCI_IO_PROTOCOL *pci_io; void *interface; @@ -789,14 +752,11 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { int rc; /* See if device is a PCI device */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io.interface, - efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI_PCI ( efirc ); + if ( ( rc = efi_open ( device, &efi_pci_io_protocol_guid, + &pci_io.interface ) ) != 0 ) { DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_open_protocol; + return rc; } efipci->io = pci_io.pci_io; @@ -807,7 +767,7 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { rc = -EEFI ( efirc ); DBGC ( device, "EFIPCI %s could not get PCI location: %s\n", efi_handle_name ( device ), strerror ( rc ) ); - goto err_get_location; + return rc; } busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn ); pci_init ( &efipci->pci, busdevfn ); @@ -836,17 +796,10 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI " "configuration: %s\n", PCI_ARGS ( &efipci->pci ), strerror ( rc ) ); - goto err_pci_read_config; + return rc; } return 0; - - err_pci_read_config: - err_get_location: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); - err_open_protocol: - return rc; } /****************************************************************************** diff --git a/src/interface/efi/efi_service.c b/src/interface/efi/efi_service.c index d4129c0d9..de7353652 100644 --- a/src/interface/efi/efi_service.c +++ b/src/interface/efi/efi_service.c @@ -45,7 +45,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE *handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_SERVICE_BINDING_PROTOCOL *sb; void *interface; @@ -54,14 +53,11 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, int rc; /* Open service binding protocol */ - if ( ( efirc = bs->OpenProtocol ( service, binding, &u.interface, - efi_image_handle, service, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); - goto err_open; + return rc; } /* Create child handle */ @@ -70,19 +66,13 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, DBGC ( service, "EFISVC %s could not create %s child: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); - goto err_create; + return rc; } - /* Success */ - rc = 0; DBGC ( service, "EFISVC %s created %s child ", efi_handle_name ( service ), efi_guid_ntoa ( binding ) ); DBGC ( service, "%s\n", efi_handle_name ( *handle ) ); - - err_create: - bs->CloseProtocol ( service, binding, efi_image_handle, service ); - err_open: - return rc; + return 0; } /** @@ -95,7 +85,6 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, */ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_SERVICE_BINDING_PROTOCOL *sb; void *interface; @@ -108,14 +97,11 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, DBGC ( service, "%s\n", efi_handle_name ( handle ) ); /* Open service binding protocol */ - if ( ( efirc = bs->OpenProtocol ( service, binding, &u.interface, - efi_image_handle, service, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); - goto err_open; + return rc; } /* Destroy child handle */ @@ -125,14 +111,8 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, efi_handle_name ( service ), efi_guid_ntoa ( binding ) ); DBGC ( service, "%s: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); - goto err_destroy; + return rc; } - /* Success */ - rc = 0; - - err_destroy: - bs->CloseProtocol ( service, binding, efi_image_handle, service ); - err_open: - return rc; + return 0; } diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index d5419512d..02bd0791f 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -272,7 +272,6 @@ static EFIAPI EFI_STATUS efi_shim_get_memory_map ( UINTN *len, * @ret rc Return status code */ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_PXE_BASE_CODE_PROTOCOL *pxe; void *interface; @@ -281,14 +280,11 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { int rc; /* Locate PXE base code */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_pxe_base_code_protocol_guid, - &u.interface, efi_image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_pxe_base_code_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( &efi_shim, "SHIM could not open PXE base code: %s\n", strerror ( rc ) ); - goto err_no_base; + return rc; } /* Stop PXE base code */ @@ -296,18 +292,11 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { rc = -EEFI ( efirc ); DBGC ( &efi_shim, "SHIM could not stop PXE base code: %s\n", strerror ( rc ) ); - goto err_stop; + return rc; } - /* Success */ - rc = 0; DBGC ( &efi_shim, "SHIM stopped PXE base code\n" ); - - err_stop: - bs->CloseProtocol ( handle, &efi_pxe_base_code_protocol_guid, - efi_image_handle, NULL ); - err_no_base: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 928d8e53a..4f081b67f 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -56,12 +56,8 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, int rc; /* Get device path */ - if ( ( efirc = bs->OpenProtocol ( device, - &efi_device_path_protocol_guid, - &u.interface, - efi_image_handle, device, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, + &u.interface ) ) != 0 ) { DBGC ( device, "EFIDEV %s cannot open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open_device_path; @@ -100,14 +96,9 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, efi_path_terminate ( end ); } - /* Success */ - rc = 0; - err_locate_protocol: free ( path ); err_alloc_path: - bs->CloseProtocol ( device, &efi_device_path_protocol_guid, - efi_image_handle, device ); err_open_device_path: return rc; } diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 17bbf7af4..637eee016 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -161,21 +161,14 @@ static int efi_veto_uninstall ( struct efi_veto *veto ) { int rc; /* Open driver binding protocol */ - if ( ( efirc = bs->OpenProtocol ( - driver, &efi_driver_binding_protocol_guid, - &binding.interface, efi_image_handle, driver, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, + &binding.interface ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); return rc; } - /* Close driver binding protocol */ - bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid, - efi_image_handle, driver ); - /* Uninstall driver binding protocol */ if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( driver, &efi_driver_binding_protocol_guid, @@ -541,7 +534,6 @@ static struct efi_veto_candidate efi_vetoes[] = { */ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_DRIVER_BINDING_PROTOCOL *binding; void *interface; @@ -568,47 +560,35 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, memset ( veto, 0, sizeof ( *veto ) ); /* Open driver binding protocol */ - if ( ( efirc = bs->OpenProtocol ( - driver, &efi_driver_binding_protocol_guid, - &binding.interface, efi_image_handle, driver, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, + &binding.interface ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); - goto err_binding; + return rc; } image = binding.binding->ImageHandle; /* Open loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( - image, &efi_loaded_image_protocol_guid, - &loaded.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( image, &efi_loaded_image_protocol_guid, + &loaded.interface ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open", efi_handle_name ( driver ) ); DBGC ( driver, " %s loaded image protocol: %s\n", efi_handle_name ( image ), strerror ( rc ) ); - goto err_loaded; + return rc; } /* Open component name protocol, if present */ - if ( ( efirc = bs->OpenProtocol ( - image, &efi_component_name2_protocol_guid, - &wtf2.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, + &wtf2.interface ) ) != 0 ) { /* Ignore failure; is not required to be present */ - wtf2.interface = NULL; } /* Open obsolete component name protocol, if present */ - if ( ( efirc = bs->OpenProtocol ( - image, &efi_component_name_protocol_guid, - &wtf.interface, efi_image_handle, image, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { + if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, + &wtf.interface ) ) != 0 ) { /* Ignore failure; is not required to be present */ - wtf.interface = NULL; } /* Get driver name, if available */ @@ -643,25 +623,7 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, } } - /* Success */ - rc = 0; - - /* Close protocols */ - if ( wtf.wtf ) { - bs->CloseProtocol ( image, &efi_component_name_protocol_guid, - efi_image_handle, image ); - } - if ( wtf2.wtf2 ) { - bs->CloseProtocol ( image, &efi_component_name2_protocol_guid, - efi_image_handle, image ); - } - bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid, - efi_image_handle, image ); - err_loaded: - bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid, - efi_image_handle, driver ); - err_binding: - return rc; + return 0; } /** diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 8891f464b..1cc37f3e3 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -248,20 +248,15 @@ static int efi_prescroll ( unsigned int lines ) { * @v handle Image handle */ static void efi_dump_image ( EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; union { EFI_LOADED_IMAGE_PROTOCOL *image; void *intf; } loaded; - EFI_STATUS efirc; int rc; /* Open loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( handle, - &efi_loaded_image_protocol_guid, - &loaded.intf, efi_image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, + &loaded.intf ) ) != 0 ) { DBGC ( colour, "WRAP %s could not get loaded image protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); return; @@ -277,10 +272,6 @@ static void efi_dump_image ( EFI_HANDLE handle ) { DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle )); DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) ); DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) ); - - /* Close loaded image protocol */ - bs->CloseProtocol ( handle, &efi_loaded_image_protocol_guid, - efi_image_handle, NULL ); } /** -- cgit v1.2.3-55-g7522 From 37897fbd401b9773f3d8a338564eff67b124e2f7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Mar 2025 14:22:54 +0000 Subject: [efi] Eliminate uses of HandleProtocol() It is now simpler to use efi_open() than to use HandleProtocol() to obtain an ephemeral protocol instance. Remove all remaining uses of HandleProtocol() to simplify the code. Signed-off-by: Michael Brown --- src/interface/efi/efi_debug.c | 6 +----- src/interface/efi/efi_file.c | 6 ++---- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index ef650d989..fd4997ccc 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -162,15 +162,11 @@ void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol ) { * @v protocol Protocol GUID */ void dbg_efi_protocol ( EFI_HANDLE handle, EFI_GUID *protocol ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; VOID *interface; - EFI_STATUS efirc; int rc; /* Get protocol instance */ - if ( ( efirc = bs->HandleProtocol ( handle, protocol, - &interface ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, protocol, &interface ) ) != 0 ) { printf ( "HANDLE %s could not identify %s: %s\n", efi_handle_name ( handle ), efi_guid_ntoa ( protocol ), strerror ( rc ) ); diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index f31f2fe3b..d8b9f819c 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -1000,10 +1000,8 @@ static int efi_file_path_claim ( struct efi_file_path *file ) { } /* Locate device path protocol on this handle */ - if ( ( ( efirc = bs->HandleProtocol ( handle, - &efi_device_path_protocol_guid, - &old ) ) != 0 ) ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, + &old ) != 0 ) ) { DBGC ( file, "EFIFILE %s could not locate %s: %s\n", efi_file_name ( &file->file ), efi_devpath_text ( file->path ), strerror ( rc ) ); -- cgit v1.2.3-55-g7522 From 32a9408217810498deeeae3d2564ab15468c9c39 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Mar 2025 14:24:47 +0000 Subject: [efi] Allow use of typed pointers for efi_open() et al Provide wrapper macros to allow efi_open() and related functions to accept a pointer to any pointer type as the "interface" argument, in order to allow a substantial amount of type adjustment boilerplate to be removed. Signed-off-by: Michael Brown --- src/drivers/net/efi/mnpnet.c | 7 +--- src/drivers/net/efi/nii.c | 11 +---- src/drivers/net/efi/snpnet.c | 4 +- src/drivers/usb/usbio.c | 34 ++++----------- src/image/efi_image.c | 25 +++++------ src/include/ipxe/efi/efi.h | 87 +++++++++++++++++++++++++++++++++++---- src/interface/efi/efi_autoboot.c | 9 ++-- src/interface/efi/efi_block.c | 40 ++++++------------ src/interface/efi/efi_bofm.c | 3 +- src/interface/efi/efi_cachedhcp.c | 9 ++-- src/interface/efi/efi_console.c | 7 +--- src/interface/efi/efi_debug.c | 18 +++----- src/interface/efi/efi_driver.c | 23 ++++------- src/interface/efi/efi_file.c | 11 ++--- src/interface/efi/efi_init.c | 6 +-- src/interface/efi/efi_local.c | 9 ++-- src/interface/efi/efi_open.c | 15 +++---- src/interface/efi/efi_pci.c | 58 +++++++++----------------- src/interface/efi/efi_service.c | 18 +++----- src/interface/efi/efi_shim.c | 9 ++-- src/interface/efi/efi_utils.c | 13 +++--- src/interface/efi/efi_veto.c | 61 ++++++++++----------------- src/interface/efi/efi_wrap.c | 15 +++---- 23 files changed, 215 insertions(+), 277 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/mnpnet.c b/src/drivers/net/efi/mnpnet.c index ead8691ff..902eb91f3 100644 --- a/src/drivers/net/efi/mnpnet.c +++ b/src/drivers/net/efi/mnpnet.c @@ -370,10 +370,6 @@ int mnpnet_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid; EFI_SIMPLE_NETWORK_MODE mode; - union { - EFI_MANAGED_NETWORK_PROTOCOL *mnp; - void *interface; - } u; struct net_device *netdev; struct mnp_nic *mnp; EFI_STATUS efirc; @@ -409,12 +405,11 @@ int mnpnet_start ( struct efi_device *efidev ) { /* Open MNP protocol */ if ( ( rc = efi_open_by_driver ( efidev->child, &efi_managed_network_protocol_guid, - &u.interface ) ) != 0 ) { + &mnp->mnp ) ) != 0 ) { DBGC ( mnp, "MNP %s could not open MNP protocol: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; } - mnp->mnp = u.mnp; /* Get configuration */ efirc = mnp->mnp->GetModeData ( mnp->mnp, NULL, &mode ); diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 126584eff..81f1838a4 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -209,10 +209,6 @@ static int nii_pci_open ( struct nii_nic *nii ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = nii->efidev->device; EFI_HANDLE pci_device; - union { - EFI_PCI_IO_PROTOCOL *pci_io; - void *interface; - } pci_io; union { EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *acpi; void *resource; @@ -237,12 +233,11 @@ static int nii_pci_open ( struct nii_nic *nii ) { * therefore use an unsafe open. */ if ( ( rc = efi_open_unsafe ( pci_device, &efi_pci_io_protocol_guid, - &pci_io.interface ) ) != 0 ) { + &nii->pci_io ) ) != 0 ) { DBGC ( nii, "NII %s could not open PCI I/O protocol: %s\n", nii->dev.name, strerror ( rc ) ); goto err_open; } - nii->pci_io = pci_io.pci_io; /* Identify memory and I/O BARs */ nii->mem_bar = PCI_MAX_BAR; @@ -1272,7 +1267,6 @@ int nii_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; struct net_device *netdev; struct nii_nic *nii; - void *interface; int rc; /* Allocate and initialise structure */ @@ -1298,13 +1292,12 @@ int nii_start ( struct efi_device *efidev ) { /* Open NII protocol */ if ( ( rc = efi_open_by_driver ( device, &efi_nii31_protocol_guid, - &interface ) ) != 0 ) { + &nii->nii ) ) != 0 ) { DBGC ( nii, "NII %s cannot open NII protocol: %s\n", nii->dev.name, strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_nii31_protocol_guid ); goto err_open_protocol; } - nii->nii = interface; /* Locate UNDI and entry point */ nii->undi = ( ( void * ) ( intptr_t ) nii->nii->Id ); diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 93ed8cd95..c8e2f2f68 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -504,7 +504,7 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { } /* Test for presence of protocol */ - if ( ( rc = efi_open ( device, protocol, NULL ) ) != 0 ) { + if ( ( rc = efi_test ( device, protocol ) ) != 0 ) { DBGCP ( device, "HANDLE %s is not a %s device\n", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); @@ -536,10 +536,10 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { */ int snpnet_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; + EFI_SIMPLE_NETWORK_PROTOCOL *interface; EFI_SIMPLE_NETWORK_MODE *mode; struct net_device *netdev; struct snp_nic *snp; - void *interface; EFI_STATUS efirc; int rc; diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index db3beff21..73151c536 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -187,10 +187,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; USB_DEVICE_PATH *usbpath; - union { - void *interface; - EFI_USB_IO_PROTOCOL *io; - } u; EFI_STATUS efirc; int rc; @@ -231,7 +227,7 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { /* Open USB I/O protocol on this handle */ if ( ( rc = efi_open_by_driver ( intf->handle, &efi_usb_io_protocol_guid, - &u.interface ) ) != 0 ) { + &intf->io ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open ", efi_handle_name ( handle ) ); DBGC ( usbio, "%s: %s\n", @@ -240,7 +236,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) { &efi_usb_io_protocol_guid ); return rc; } - intf->io = u.io; /* Increment usage count */ intf->count++; @@ -1296,24 +1291,20 @@ static int usbio_supported ( EFI_HANDLE handle ) { struct usb_function_descriptor desc; struct usb_driver *driver; struct usb_device_id *id; - union { - void *interface; - EFI_USB_IO_PROTOCOL *io; - } usb; + EFI_USB_IO_PROTOCOL *io; EFI_STATUS efirc; int rc; /* Get protocol */ if ( ( rc = efi_open ( handle, &efi_usb_io_protocol_guid, - &usb.interface ) ) != 0 ) { + &io ) ) != 0 ) { DBGCP ( handle, "USB %s is not a USB device\n", efi_handle_name ( handle ) ); return rc; } /* Get device descriptor */ - if ( ( efirc = usb.io->UsbGetDeviceDescriptor ( usb.io, - &device ) ) != 0 ) { + if ( ( efirc = io->UsbGetDeviceDescriptor ( io, &device ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get device descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); @@ -1324,8 +1315,7 @@ static int usbio_supported ( EFI_HANDLE handle ) { desc.product = device.IdProduct; /* Get interface descriptor */ - if ( ( efirc = usb.io->UsbGetInterfaceDescriptor ( usb.io, - &interface ) ) !=0){ + if ( ( efirc = io->UsbGetInterfaceDescriptor ( io, &interface ) ) != 0){ rc = -EEFI ( efirc ); DBGC ( handle, "USB %s could not get interface descriptor: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); @@ -1460,21 +1450,16 @@ static int usbio_path ( struct usbio_device *usbio ) { EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; USB_DEVICE_PATH *usbpath; - union { - void *interface; - EFI_DEVICE_PATH_PROTOCOL *path; - } u; size_t len; int rc; /* Open device path protocol */ if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + &path ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open device path protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); return rc; } - path = u.interface; /* Locate end of device path and sanity check */ len = efi_path_len ( path ); @@ -1567,10 +1552,6 @@ static int usbio_start ( struct efi_device *efidev ) { EFI_HANDLE handle = efidev->device; struct usbio_device *usbio; struct usb_port *port; - union { - void *interface; - EFI_USB_IO_PROTOCOL *io; - } u; int rc; /* Allocate and initialise structure */ @@ -1585,13 +1566,12 @@ static int usbio_start ( struct efi_device *efidev ) { /* Open USB I/O protocol */ if ( ( rc = efi_open_by_driver ( handle, &efi_usb_io_protocol_guid, - &u.interface ) ) != 0 ) { + &usbio->io ) ) != 0 ) { DBGC ( usbio, "USBIO %s cannot open USB I/O protocol: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); DBGC_EFI_OPENERS ( usbio, handle, &efi_usb_io_protocol_guid ); goto err_open_usbio; } - usbio->io = u.io; /* Describe generic device */ efi_device_info ( handle, "USB", &usbio->dev ); diff --git a/src/image/efi_image.c b/src/image/efi_image.c index ae9255ce5..82101d484 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -132,10 +132,7 @@ static int efi_image_exec ( struct image *image ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct efi_snp_device *snpdev; EFI_DEVICE_PATH_PROTOCOL *path; - union { - EFI_LOADED_IMAGE_PROTOCOL *image; - void *interface; - } loaded; + EFI_LOADED_IMAGE_PROTOCOL *loaded; struct image *shim; struct image *exec; EFI_HANDLE handle; @@ -235,30 +232,30 @@ static int efi_image_exec ( struct image *image ) { /* Get the loaded image protocol for the newly loaded image */ if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, - &loaded.interface ) ) != 0 ) { + &loaded ) ) != 0 ) { /* Should never happen */ goto err_open_protocol; } /* Some EFI 1.10 implementations seem not to fill in DeviceHandle */ - if ( loaded.image->DeviceHandle == NULL ) { + if ( loaded->DeviceHandle == NULL ) { DBGC ( image, "EFIIMAGE %s filling in missing DeviceHandle\n", image->name ); - loaded.image->DeviceHandle = snpdev->handle; + loaded->DeviceHandle = snpdev->handle; } /* Sanity checks */ - assert ( loaded.image->ParentHandle == efi_image_handle ); - assert ( loaded.image->DeviceHandle == snpdev->handle ); - assert ( loaded.image->LoadOptionsSize == 0 ); - assert ( loaded.image->LoadOptions == NULL ); + assert ( loaded->ParentHandle == efi_image_handle ); + assert ( loaded->DeviceHandle == snpdev->handle ); + assert ( loaded->LoadOptionsSize == 0 ); + assert ( loaded->LoadOptions == NULL ); /* Record image code type */ - type = loaded.image->ImageCodeType; + type = loaded->ImageCodeType; /* Set command line */ - loaded.image->LoadOptions = cmdline; - loaded.image->LoadOptionsSize = + loaded->LoadOptions = cmdline; + loaded->LoadOptionsSize = ( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) ); /* Release network devices for use via SNP */ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 6126d3b87..5fae87731 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -389,17 +389,88 @@ extern EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab ); extern void efi_raise_tpl ( struct efi_saved_tpl *tpl ); extern void efi_restore_tpl ( struct efi_saved_tpl *tpl ); -extern int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ); -extern int efi_open_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ); +extern int efi_open_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); +extern int efi_open_unsafe_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); extern void efi_close_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol ); -extern int efi_open_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ); +extern int efi_open_by_driver_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ); extern void efi_close_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol ); -extern int efi_open_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, - EFI_HANDLE child, void **interface ); +extern int efi_open_by_child_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child, void **interface ); extern void efi_close_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, EFI_HANDLE child ); +/** + * Test protocol existence + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @ret rc Return status code + */ +#define efi_test( handle, protocol ) \ + efi_open_untyped ( (handle), (protocol), NULL ) + +/** + * Open protocol for ephemeral use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open( handle, protocol, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_untyped ( (handle), (protocol), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + +/** + * Open protocol for unsafe persistent use + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open_unsafe( handle, protocol, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_unsafe_untyped ( (handle), (protocol), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + +/** + * Open protocol for persistent use by a driver + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open_by_driver( handle, protocol, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_by_driver_untyped ( (handle), (protocol), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + +/** + * Open protocol for persistent use by a child controller + * + * @v handle EFI handle + * @v protocol Protocol GUID + * @v child Child controller handle + * @v interface Protocol interface pointer to fill in + * @ret rc Return status code + */ +#define efi_open_by_child( handle, protocol, child, interface ) ( { \ + typeof ( *(interface) ) check_ptr_ptr = NULL; \ + efi_open_by_child_untyped ( (handle), (protocol), (child), \ + ( ( void ) check_ptr_ptr, \ + ( void ** ) (interface) ) ); \ + } ) + #endif /* _IPXE_EFI_H */ diff --git a/src/interface/efi/efi_autoboot.c b/src/interface/efi/efi_autoboot.c index 528b84f1e..e52c857d8 100644 --- a/src/interface/efi/efi_autoboot.c +++ b/src/interface/efi/efi_autoboot.c @@ -48,24 +48,21 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_set_autoboot_ll_addr ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { - union { - EFI_SIMPLE_NETWORK_PROTOCOL *snp; - void *interface; - } snp; + EFI_SIMPLE_NETWORK_PROTOCOL *snp; EFI_SIMPLE_NETWORK_MODE *mode; unsigned int vlan; int rc; /* Look for an SNP instance on the image's device handle */ if ( ( rc = efi_open ( device, &efi_simple_network_protocol_guid, - &snp.interface ) ) != 0 ) { + &snp ) ) != 0 ) { DBGC ( device, "EFI %s has no SNP instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; } /* Record autoboot device */ - mode = snp.snp->Mode; + mode = snp->Mode; vlan = efi_path_vlan ( path ); set_autoboot_ll_addr ( &mode->CurrentAddress, mode->HwAddressSize, vlan ); diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 34b73c265..5165bd804 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -518,23 +518,20 @@ static int efi_block_describe ( void ) { */ static int efi_block_root ( unsigned int drive, EFI_HANDLE handle, EFI_FILE_PROTOCOL **root ) { - union { - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; - void *interface; - } u; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; EFI_STATUS efirc; int rc; /* Open filesystem protocol */ if ( ( rc = efi_open ( handle, &efi_simple_file_system_protocol_guid, - &u.interface ) ) != 0 ) { + &fs ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s filesystem: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); return rc; } /* Open root volume */ - if ( ( efirc = u.fs->OpenVolume ( u.fs, root ) ) != 0 ) { + if ( ( efirc = fs->OpenVolume ( fs, root ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( drive, "EFIBLK %#02x could not open %s root: %s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); @@ -664,26 +661,21 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, EFI_DEVICE_PATH_PROTOCOL *path, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } u; EFI_FILE *root; union uuid guid; int rc; /* Identify device path */ if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + fspath ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open %s device path: " "%s\n", drive, efi_handle_name ( handle ), strerror ( rc ) ); goto err_open; } - *fspath = u.path; /* Check if filesystem is a child of this block device */ - if ( memcmp ( u.path, path, efi_path_len ( path ) ) != 0 ) { + if ( memcmp ( *fspath, path, efi_path_len ( path ) ) != 0 ) { /* Not a child device */ rc = -ENOTTY; DBGC2 ( drive, "EFIBLK %#02x is not parent of %s\n", @@ -691,11 +683,11 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle, goto err_not_child; } DBGC ( drive, "EFIBLK %#02x contains filesystem %s\n", - drive, efi_devpath_text ( u.path ) ); + drive, efi_devpath_text ( *fspath ) ); /* Check if filesystem matches GUID, if applicable */ if ( config->uuid ) { - if ( ( rc = efi_path_guid ( u.path, &guid ) ) != 0 ) { + if ( ( rc = efi_path_guid ( *fspath, &guid ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not determine GUID: " "%s\n", drive, strerror ( rc ) ); goto err_no_guid; @@ -760,10 +752,7 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } u; + EFI_DEVICE_PATH_PROTOCOL *path; EFI_HANDLE *handles; UINTN count; unsigned int i; @@ -775,7 +764,7 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, /* Identify device path */ if ( ( rc = efi_open ( handle, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + &path ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not open device path: %s\n", drive, strerror ( rc ) ); goto err_open; @@ -796,7 +785,7 @@ static int efi_block_scan ( unsigned int drive, EFI_HANDLE handle, for ( i = 0 ; i < count ; i++ ) { /* Check for a matching filesystem */ - if ( ( rc = efi_block_match ( drive, handles[i], u.path, + if ( ( rc = efi_block_match ( drive, handles[i], path, config, fspath ) ) != 0 ) continue; @@ -903,10 +892,7 @@ static int efi_block_exec ( unsigned int drive, static int efi_block_local ( EFI_HANDLE handle ) { struct san_device *sandev; struct efi_block_data *block; - union { - EFI_BLOCK_IO_PROTOCOL *blockio; - void *interface; - } u; + EFI_BLOCK_IO_PROTOCOL *blockio; int rc; /* Check if handle belongs to a SAN device */ @@ -918,14 +904,14 @@ static int efi_block_local ( EFI_HANDLE handle ) { /* Open block I/O protocol */ if ( ( rc = efi_open ( handle, &efi_block_io_protocol_guid, - &u.interface ) ) != 0 ) { + &blockio ) ) != 0 ) { DBGC ( handle, "EFIBLK %s could not open block I/O: %s\n", efi_handle_name ( handle ), strerror ( rc ) ); return rc; } /* Do not assign drive numbers for partitions */ - if ( u.blockio->Media->LogicalPartition ) { + if ( blockio->Media->LogicalPartition ) { DBGC2 ( handle, "EFLBLK %s is a partition\n", efi_handle_name ( handle ) ); return -ENOTTY; diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 6d97ff445..b64770d8a 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -228,7 +228,6 @@ static int efi_bofm_start ( struct efi_device *efidev ) { struct efi_pci_device efipci; IBM_BOFM_TABLE *bofmtab; IBM_BOFM_TABLE *bofmtab2; - void *pci_io; int bofmrc; EFI_STATUS efirc; int rc; @@ -242,7 +241,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) { /* Open PCI I/O protocol */ if ( ( rc = efi_open_unsafe ( device, &efi_pci_io_protocol_guid, - &pci_io ) ) != 0 ) { + &efipci.io ) ) != 0 ) { DBGC ( device, "EFIBOFM %s cannot open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open; diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index 68671d7c6..eb41a8e43 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -47,10 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); int efi_cachedhcp_record ( EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path ) { unsigned int vlan; - union { - EFI_PXE_BASE_CODE_PROTOCOL *pxe; - void *interface; - } pxe; + EFI_PXE_BASE_CODE_PROTOCOL *pxe; EFI_PXE_BASE_CODE_MODE *mode; int rc; @@ -59,14 +56,14 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Look for a PXE base code instance on the image's device handle */ if ( ( rc = efi_open ( device, &efi_pxe_base_code_protocol_guid, - &pxe.interface ) ) != 0 ) { + &pxe ) ) != 0 ) { DBGC ( device, "EFI %s has no PXE base code instance: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; } /* Do not attempt to cache IPv6 packets */ - mode = pxe.pxe->Mode; + mode = pxe->Mode; if ( mode->UsingIpv6 ) { DBGC ( device, "EFI %s has IPv6 PXE base code\n", efi_handle_name ( device ) ); diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 41c4dcf2c..9fc3c65c0 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -416,10 +416,6 @@ struct console_driver efi_console __console_driver = { */ static void efi_console_init ( void ) { EFI_CONSOLE_CONTROL_SCREEN_MODE mode; - union { - void *interface; - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *wtf; - } u; int rc; /* On some older EFI 1.10 implementations, we must use the @@ -441,8 +437,7 @@ static void efi_console_init ( void ) { */ if ( ( rc = efi_open_unsafe ( efi_systab->ConsoleInHandle, &efi_simple_text_input_ex_protocol_guid, - &u.interface ) ) == 0 ) { - efi_conin_ex = u.wtf; + &efi_conin_ex ) ) == 0 ) { DBG ( "EFI using SimpleTextInputEx\n" ); } else { DBG ( "EFI has no SimpleTextInputEx: %s\n", strerror ( rc ) ); diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index fd4997ccc..026adc25e 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -324,10 +324,7 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) { * @ret name Driver name, or NULL */ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { - union { - EFI_COMPONENT_NAME_PROTOCOL *name; - void *interface; - } u; + EFI_COMPONENT_NAME_PROTOCOL *name; EFI_HANDLE image; int rc; @@ -340,13 +337,13 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { /* Try to open component name protocol on image handle */ image = binding->ImageHandle; if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, - &u.interface ) ) != 0 ) { + &name ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName]" ); return NULL; } /* Try to get name from component name protocol */ - return efi_driver_name ( u.name ); + return efi_driver_name ( name ); } /** @@ -357,10 +354,7 @@ static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) { */ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ EFI_HANDLE image; - union { - EFI_COMPONENT_NAME2_PROTOCOL *name2; - void *interface; - } u; + EFI_COMPONENT_NAME2_PROTOCOL *name2; int rc; /* Sanity check */ @@ -372,13 +366,13 @@ static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){ /* Try to open component name protocol on image handle */ image = binding->ImageHandle; if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, - &u.interface ) ) != 0 ) { + &name2 ) ) != 0 ) { DBG ( "[DriverBinding no ComponentName2]" ); return NULL; } /* Try to get name from component name protocol */ - return efi_driver_name2 ( u.name2 ); + return efi_driver_name2 ( name2 ); } /** diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index d143249ca..56918deba 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -69,22 +69,19 @@ static int efi_driver_disconnecting; */ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { struct efi_device *efidev = NULL; - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } path; + EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *path_end; size_t path_len; int rc; /* Open device path */ if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, - &path.interface ) ) != 0 ) { + &path ) ) != 0 ) { DBGC ( device, "EFIDRV %s could not open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return NULL; } - path_len = ( efi_path_len ( path.path ) + sizeof ( *path_end ) ); + path_len = ( efi_path_len ( path ) + sizeof ( *path_end ) ); /* Allocate and initialise structure */ efidev = zalloc ( sizeof ( *efidev ) + path_len ); @@ -93,7 +90,7 @@ struct efi_device * efidev_alloc ( EFI_HANDLE device ) { efidev->device = device; efidev->dev.desc.bus_type = BUS_TYPE_EFI; efidev->path = ( ( ( void * ) efidev ) + sizeof ( *efidev ) ); - memcpy ( efidev->path, path.path, path_len ); + memcpy ( efidev->path, path, path_len ); INIT_LIST_HEAD ( &efidev->dev.children ); list_add ( &efidev->dev.siblings, &efi_devices ); @@ -365,10 +362,7 @@ static EFI_STATUS EFIAPI efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, EFI_HANDLE device, EFI_HANDLE child, CHAR8 *language, CHAR16 **controller_name ) { - union { - EFI_COMPONENT_NAME2_PROTOCOL *name2; - void *interface; - } name2; + EFI_COMPONENT_NAME2_PROTOCOL *name2; int rc; /* Delegate to the EFI_COMPONENT_NAME2_PROTOCOL instance @@ -376,10 +370,9 @@ efi_driver_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *wtf __unused, */ if ( ( child != NULL ) && ( ( rc = efi_open ( child, &efi_component_name2_protocol_guid, - &name2.interface ) ) == 0 ) ) { - return name2.name2->GetControllerName ( name2.name2, device, - child, language, - controller_name ); + &name2 ) ) == 0 ) ) { + return name2->GetControllerName ( name2, device, child, + language, controller_name ); } /* Otherwise, let EFI use the default Device Path Name */ diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index d8b9f819c..b7b97aee7 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -982,9 +982,9 @@ static EFI_DISK_IO_PROTOCOL efi_disk_io_protocol = { */ static int efi_file_path_claim ( struct efi_file_path *file ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_DEVICE_PATH_PROTOCOL *old; EFI_DEVICE_PATH_PROTOCOL *end; EFI_HANDLE handle; - VOID *old; EFI_STATUS efirc; int rc; @@ -1116,10 +1116,7 @@ static void efi_file_path_uninstall ( struct efi_file_path *file ) { */ int efi_file_install ( EFI_HANDLE handle ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - union { - EFI_DISK_IO_PROTOCOL *diskio; - void *interface; - } diskio; + EFI_DISK_IO_PROTOCOL *diskio; struct image *image; EFI_STATUS efirc; int rc; @@ -1168,13 +1165,13 @@ int efi_file_install ( EFI_HANDLE handle ) { * shell. I have no idea why this is. */ if ( ( rc = efi_open_by_driver ( handle, &efi_disk_io_protocol_guid, - &diskio.interface ) ) != 0 ) { + &diskio ) ) != 0 ) { DBGC ( handle, "Could not open disk I/O protocol: %s\n", strerror ( rc ) ); DBGC_EFI_OPENERS ( handle, handle, &efi_disk_io_protocol_guid ); goto err_open; } - assert ( diskio.diskio == &efi_disk_io_protocol ); + assert ( diskio == &efi_disk_io_protocol ); /* Claim Linux initrd fixed device path */ if ( ( rc = efi_file_path_claim ( &efi_file_initrd ) ) != 0 ) diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 03506ec5c..1ba144ee7 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -173,8 +173,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_BOOT_SERVICES *bs; struct efi_protocol *prot; struct efi_config_table *tab; - void *loaded_image; - void *device_path; + EFI_DEVICE_PATH_PROTOCOL *device_path; void *device_path_copy; size_t device_path_len; EFI_STATUS efirc; @@ -248,13 +247,12 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, */ if ( ( rc = efi_open_unsafe ( image_handle, &efi_loaded_image_protocol_guid, - &loaded_image ) ) != 0 ) { + &efi_loaded_image ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image protocol: %s", strerror ( rc ) ); efirc = EFIRC ( rc ); goto err_no_loaded_image; } - efi_loaded_image = loaded_image; DBGC ( systab, "EFI image base address %p\n", efi_loaded_image->ImageBase ); diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c index 80cfb5a22..4564470fc 100644 --- a/src/interface/efi/efi_local.c +++ b/src/interface/efi/efi_local.c @@ -208,23 +208,20 @@ static int efi_local_check_volume_name ( struct efi_local *local, */ static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device, EFI_FILE_PROTOCOL **root ) { - union { - void *interface; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; - } u; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; EFI_STATUS efirc; int rc; /* Open file system protocol */ if ( ( rc = efi_open ( device, &efi_simple_file_system_protocol_guid, - &u.interface ) ) != 0 ) { + &fs ) ) != 0 ) { DBGC ( local, "LOCAL %p could not open filesystem on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); return rc; } /* Open root directory */ - if ( ( efirc = u.fs->OpenVolume ( u.fs, root ) ) != 0 ) { + if ( ( efirc = fs->OpenVolume ( fs, root ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( local, "LOCAL %p could not open volume on %s: %s\n", local, efi_handle_name ( device ), strerror ( rc ) ); diff --git a/src/interface/efi/efi_open.c b/src/interface/efi/efi_open.c index c85c027e1..8f8af4ea0 100644 --- a/src/interface/efi/efi_open.c +++ b/src/interface/efi/efi_open.c @@ -93,7 +93,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v interface Protocol interface pointer to fill in (or NULL to test) * @ret rc Return status code */ -int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, void **interface ) { +int efi_open_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; @@ -176,8 +177,8 @@ int efi_open ( EFI_HANDLE handle, EFI_GUID *protocol, void **interface ) { * @v interface Protocol interface pointer to fill in * @ret rc Return status code */ -int efi_open_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ) { +int efi_open_unsafe_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; @@ -236,8 +237,8 @@ void efi_close_unsafe ( EFI_HANDLE handle, EFI_GUID *protocol ) { * @v interface Protocol interface pointer to fill in * @ret rc Return status code */ -int efi_open_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol, - void **interface ) { +int efi_open_by_driver_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; @@ -297,8 +298,8 @@ void efi_close_by_driver ( EFI_HANDLE handle, EFI_GUID *protocol ) { * @v interface Protocol interface pointer to fill in * @ret rc Return status code */ -int efi_open_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, - EFI_HANDLE child, void **interface ) { +int efi_open_by_child_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, + EFI_HANDLE child, void **interface ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE agent = efi_image_handle; EFI_HANDLE controller; diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 003fa2f4a..0662302d2 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -72,10 +72,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, struct pci_range *range ) { - union { - void *interface; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; - } root; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; union { union acpi_resource *res; void *raw; @@ -94,7 +91,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, /* Open root bridge I/O protocol */ if ( ( rc = efi_open ( handle, &efi_pci_root_bridge_io_protocol_guid, - &root.interface ) ) != 0 ) { + &root ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( handle ), strerror ( rc ) ); @@ -102,8 +99,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, } /* Get ACPI resource descriptors */ - if ( ( efirc = root.root->Configuration ( root.root, - &acpi.raw ) ) != 0 ) { + if ( ( efirc = root->Configuration ( root, &acpi.raw ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( pci, "EFIPCI " PCI_FMT " cannot get configuration for " "%s: %s\n", PCI_ARGS ( pci ), @@ -123,13 +119,13 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, continue; /* Get range for this descriptor */ - start = PCI_BUSDEVFN ( root.root->SegmentNumber, + start = PCI_BUSDEVFN ( root->SegmentNumber, le64_to_cpu ( acpi.res->qword.min ), 0, 0 ); count = PCI_BUSDEVFN ( 0, le64_to_cpu ( acpi.res->qword.len ), 0, 0 ); DBGC2 ( pci, "EFIPCI " PCI_FMT " found %04x:[%02x-%02x] via " - "%s\n", PCI_ARGS ( pci ), root.root->SegmentNumber, + "%s\n", PCI_ARGS ( pci ), root->SegmentNumber, PCI_BUS ( start ), PCI_BUS ( start + count - 1 ), efi_handle_name ( handle ) ); @@ -150,8 +146,7 @@ static int efipci_discover_one ( struct pci_device *pci, EFI_HANDLE handle, * bridge has a single bus. */ if ( ! range->count ) { - range->start = PCI_BUSDEVFN ( root.root->SegmentNumber, - 0, 0, 0 ); + range->start = PCI_BUSDEVFN ( root->SegmentNumber, 0, 0, 0 ); range->count = PCI_BUSDEVFN ( 0, 1, 0, 0 ); } @@ -259,10 +254,6 @@ static void efipci_discover ( uint32_t busdevfn, struct pci_range *range ) { static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) { struct pci_range tmp; - union { - void *interface; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root; - } u; int rc; /* Find matching root bridge I/O protocol handle */ @@ -271,16 +262,13 @@ static int efipci_root_open ( struct pci_device *pci, EFI_HANDLE *handle, /* Open PCI root bridge I/O protocol */ if ( ( rc = efi_open ( *handle, &efi_pci_root_bridge_io_protocol_guid, - &u.interface ) ) != 0 ) { + root ) ) != 0 ) { DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n", PCI_ARGS ( pci ), efi_handle_name ( *handle ), strerror ( rc ) ); return rc; } - /* Return opened protocol */ - *root = u.root; - return 0; } @@ -742,10 +730,7 @@ static struct dma_operations efipci_dma_operations = { * @ret rc Return status code */ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { - union { - EFI_PCI_IO_PROTOCOL *pci_io; - void *interface; - } pci_io; + EFI_PCI_IO_PROTOCOL *pci_io; UINTN pci_segment, pci_bus, pci_dev, pci_fn; unsigned int busdevfn; EFI_STATUS efirc; @@ -753,17 +738,16 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { /* See if device is a PCI device */ if ( ( rc = efi_open ( device, &efi_pci_io_protocol_guid, - &pci_io.interface ) ) != 0 ) { + &pci_io ) ) != 0 ) { DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; } - efipci->io = pci_io.pci_io; + efipci->io = pci_io; /* Get PCI bus:dev.fn address */ - if ( ( efirc = pci_io.pci_io->GetLocation ( pci_io.pci_io, &pci_segment, - &pci_bus, &pci_dev, - &pci_fn ) ) != 0 ) { + if ( ( efirc = pci_io->GetLocation ( pci_io, &pci_segment, &pci_bus, + &pci_dev, &pci_fn ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( device, "EFIPCI %s could not get PCI location: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -781,15 +765,12 @@ int efipci_info ( EFI_HANDLE device, struct efi_pci_device *efipci ) { * support I/O cycles). Work around any such platforms by * enabling bits individually and simply ignoring any errors. */ - pci_io.pci_io->Attributes ( pci_io.pci_io, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_IO, NULL ); - pci_io.pci_io->Attributes ( pci_io.pci_io, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_MEMORY, NULL ); - pci_io.pci_io->Attributes ( pci_io.pci_io, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL ); + pci_io->Attributes ( pci_io, EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_IO, NULL ); + pci_io->Attributes ( pci_io, EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_MEMORY, NULL ); + pci_io->Attributes ( pci_io, EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL ); /* Populate PCI device */ if ( ( rc = pci_read_config ( &efipci->pci ) ) != 0 ) { @@ -857,7 +838,6 @@ static int efipci_supported ( EFI_HANDLE device ) { static int efipci_start ( struct efi_device *efidev ) { EFI_HANDLE device = efidev->device; struct efi_pci_device *efipci; - void *pci_io; int rc; /* Allocate PCI device */ @@ -873,7 +853,7 @@ static int efipci_start ( struct efi_device *efidev ) { /* Open PCI I/O protocol */ if ( ( rc = efi_open_by_driver ( device, &efi_pci_io_protocol_guid, - &pci_io ) ) != 0 ) { + &efipci->io ) ) != 0 ) { DBGC ( device, "EFIPCI %s could not open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_pci_io_protocol_guid ); diff --git a/src/interface/efi/efi_service.c b/src/interface/efi/efi_service.c index de7353652..f10733b24 100644 --- a/src/interface/efi/efi_service.c +++ b/src/interface/efi/efi_service.c @@ -45,15 +45,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE *handle ) { - union { - EFI_SERVICE_BINDING_PROTOCOL *sb; - void *interface; - } u; + EFI_SERVICE_BINDING_PROTOCOL *sb; EFI_STATUS efirc; int rc; /* Open service binding protocol */ - if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { + if ( ( rc = efi_open ( service, binding, &sb ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); @@ -61,7 +58,7 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, } /* Create child handle */ - if ( ( efirc = u.sb->CreateChild ( u.sb, handle ) ) != 0 ) { + if ( ( efirc = sb->CreateChild ( sb, handle ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( service, "EFISVC %s could not create %s child: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), @@ -85,10 +82,7 @@ int efi_service_add ( EFI_HANDLE service, EFI_GUID *binding, */ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, EFI_HANDLE handle ) { - union { - EFI_SERVICE_BINDING_PROTOCOL *sb; - void *interface; - } u; + EFI_SERVICE_BINDING_PROTOCOL *sb; EFI_STATUS efirc; int rc; @@ -97,7 +91,7 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, DBGC ( service, "%s\n", efi_handle_name ( handle ) ); /* Open service binding protocol */ - if ( ( rc = efi_open ( service, binding, &u.interface ) ) != 0 ) { + if ( ( rc = efi_open ( service, binding, &sb ) ) != 0 ) { DBGC ( service, "EFISVC %s cannot open %s binding: %s\n", efi_handle_name ( service ), efi_guid_ntoa ( binding ), strerror ( rc ) ); @@ -105,7 +99,7 @@ int efi_service_del ( EFI_HANDLE service, EFI_GUID *binding, } /* Destroy child handle */ - if ( ( efirc = u.sb->DestroyChild ( u.sb, handle ) ) != 0 ) { + if ( ( efirc = sb->DestroyChild ( sb, handle ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( service, "EFISVC %s could not destroy %s child ", efi_handle_name ( service ), efi_guid_ntoa ( binding ) ); diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index 02bd0791f..4bb6df79f 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -272,23 +272,20 @@ static EFIAPI EFI_STATUS efi_shim_get_memory_map ( UINTN *len, * @ret rc Return status code */ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) { - union { - EFI_PXE_BASE_CODE_PROTOCOL *pxe; - void *interface; - } u; + EFI_PXE_BASE_CODE_PROTOCOL *pxe; EFI_STATUS efirc; int rc; /* Locate PXE base code */ if ( ( rc = efi_open ( handle, &efi_pxe_base_code_protocol_guid, - &u.interface ) ) != 0 ) { + &pxe ) ) != 0 ) { DBGC ( &efi_shim, "SHIM could not open PXE base code: %s\n", strerror ( rc ) ); return rc; } /* Stop PXE base code */ - if ( ( efirc = u.pxe->Stop ( u.pxe ) ) != 0 ) { + if ( ( efirc = pxe->Stop ( pxe ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( &efi_shim, "SHIM could not stop PXE base code: %s\n", strerror ( rc ) ); diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 4f081b67f..51da06172 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -45,10 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, EFI_HANDLE *parent, unsigned int skip ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - union { - EFI_DEVICE_PATH_PROTOCOL *path; - void *interface; - } u; + EFI_DEVICE_PATH_PROTOCOL *devpath; EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; size_t len; @@ -57,20 +54,20 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, /* Get device path */ if ( ( rc = efi_open ( device, &efi_device_path_protocol_guid, - &u.interface ) ) != 0 ) { + &devpath ) ) != 0 ) { DBGC ( device, "EFIDEV %s cannot open device path: %s\n", efi_handle_name ( device ), strerror ( rc ) ); goto err_open_device_path; } /* Create modifiable copy of device path */ - len = ( efi_path_len ( u.path ) + sizeof ( EFI_DEVICE_PATH_PROTOCOL )); + len = ( efi_path_len ( devpath ) + sizeof ( *end ) ); path = malloc ( len ); if ( ! path ) { rc = -ENOMEM; goto err_alloc_path; } - memcpy ( path, u.path, len ); + memcpy ( path, devpath, len ); /* Locate parent device(s) */ while ( 1 ) { @@ -111,7 +108,7 @@ int efi_locate_device ( EFI_HANDLE device, EFI_GUID *protocol, * @ret rc Return status code */ int efi_child_add ( EFI_HANDLE parent, EFI_HANDLE child ) { - void *devpath; + EFI_DEVICE_PATH_PROTOCOL *devpath; int rc; /* Re-open the device path protocol */ diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 637eee016..3f9c9940e 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -153,16 +153,13 @@ static int efi_veto_disconnect ( struct efi_veto *veto ) { static int efi_veto_uninstall ( struct efi_veto *veto ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE driver = veto->driver; - union { - EFI_DRIVER_BINDING_PROTOCOL *binding; - void *interface; - } binding; + EFI_DRIVER_BINDING_PROTOCOL *binding; EFI_STATUS efirc; int rc; /* Open driver binding protocol */ if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, - &binding.interface ) ) != 0 ) { + &binding ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); @@ -172,7 +169,7 @@ static int efi_veto_uninstall ( struct efi_veto *veto ) { /* Uninstall driver binding protocol */ if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( driver, &efi_driver_binding_protocol_guid, - binding.binding, NULL ) ) != 0 ) { + binding, NULL ) ) != 0 ) { rc = -EEFI ( efirc ); DBGC ( driver, "EFIVETO %s could not uninstall driver " "binding protocol: %s\n", @@ -534,22 +531,10 @@ static struct efi_veto_candidate efi_vetoes[] = { */ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto ) { - union { - EFI_DRIVER_BINDING_PROTOCOL *binding; - void *interface; - } binding; - union { - EFI_LOADED_IMAGE_PROTOCOL *loaded; - void *interface; - } loaded; - union { - EFI_COMPONENT_NAME2_PROTOCOL *wtf2; - void *interface; - } wtf2; - union { - EFI_COMPONENT_NAME_PROTOCOL *wtf; - void *interface; - } wtf; + EFI_DRIVER_BINDING_PROTOCOL *binding; + EFI_LOADED_IMAGE_PROTOCOL *loaded; + EFI_COMPONENT_NAME2_PROTOCOL *wtf2; + EFI_COMPONENT_NAME_PROTOCOL *wtf; CHAR16 *name; unsigned int i; EFI_HANDLE image; @@ -561,17 +546,17 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Open driver binding protocol */ if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid, - &binding.interface ) ) != 0 ) { + &binding ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open driver binding " "protocol: %s\n", efi_handle_name ( driver ), strerror ( rc ) ); return rc; } - image = binding.binding->ImageHandle; + image = binding->ImageHandle; /* Open loaded image protocol */ if ( ( rc = efi_open ( image, &efi_loaded_image_protocol_guid, - &loaded.interface ) ) != 0 ) { + &loaded ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not open", efi_handle_name ( driver ) ); DBGC ( driver, " %s loaded image protocol: %s\n", @@ -581,23 +566,21 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Open component name protocol, if present */ if ( ( rc = efi_open ( image, &efi_component_name2_protocol_guid, - &wtf2.interface ) ) != 0 ) { + &wtf2 ) ) != 0 ) { /* Ignore failure; is not required to be present */ } /* Open obsolete component name protocol, if present */ if ( ( rc = efi_open ( image, &efi_component_name_protocol_guid, - &wtf.interface ) ) != 0 ) { + &wtf ) ) != 0 ) { /* Ignore failure; is not required to be present */ } /* Get driver name, if available */ - if ( ( wtf2.wtf2 && - ( ( efirc = wtf2.wtf2->GetDriverName ( wtf2.wtf2, "en", - &name ) == 0 ) ) ) || - ( wtf.wtf && - ( ( efirc = wtf.wtf->GetDriverName ( wtf.wtf, "eng", - &name ) == 0 ) ) ) ) { + if ( ( wtf2 && ( ( efirc = wtf2->GetDriverName ( wtf2, "en", + &name ) == 0 ) ) ) || + ( wtf && ( ( efirc = wtf->GetDriverName ( wtf, "eng", + &name ) == 0 ) ) ) ) { /* Driver has a name */ } else { /* Ignore failure; name is not required to be present */ @@ -606,19 +589,19 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer, /* Check vetoes */ DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n", - efi_handle_name ( driver ), loaded.loaded->ImageBase, - ( loaded.loaded->ImageBase + loaded.loaded->ImageSize ) ); + efi_handle_name ( driver ), loaded->ImageBase, + ( loaded->ImageBase + loaded->ImageSize ) ); for ( i = 0 ; i < ( sizeof ( efi_vetoes ) / sizeof ( efi_vetoes[0] ) ) ; i++ ) { - if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded, - manufacturer, name ) ) { + if ( efi_vetoes[i].veto ( binding, loaded, manufacturer, + name ) ) { DBGC ( driver, "EFIVETO %s is vetoed (%s)\n", efi_handle_name ( driver ), efi_vetoes[i].name ); veto->driver = driver; - veto->binding = binding.binding; + veto->binding = binding; veto->image = image; - veto->loaded = loaded.loaded; + veto->loaded = loaded; break; } } diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 1cc37f3e3..a806a7c60 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -248,15 +248,12 @@ static int efi_prescroll ( unsigned int lines ) { * @v handle Image handle */ static void efi_dump_image ( EFI_HANDLE handle ) { - union { - EFI_LOADED_IMAGE_PROTOCOL *image; - void *intf; - } loaded; + EFI_LOADED_IMAGE_PROTOCOL *loaded; int rc; /* Open loaded image protocol */ if ( ( rc = efi_open ( handle, &efi_loaded_image_protocol_guid, - &loaded.intf ) ) != 0 ) { + &loaded ) ) != 0 ) { DBGC ( colour, "WRAP %s could not get loaded image protocol: " "%s\n", efi_handle_name ( handle ), strerror ( rc ) ); return; @@ -264,14 +261,14 @@ static void efi_dump_image ( EFI_HANDLE handle ) { /* Dump image information */ DBGC ( colour, "WRAP %s at base %p has protocols:\n", - efi_handle_name ( handle ), loaded.image->ImageBase ); + efi_handle_name ( handle ), loaded->ImageBase ); DBGC_EFI_PROTOCOLS ( colour, handle ); DBGC ( colour, "WRAP %s parent", efi_handle_name ( handle ) ); - DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->ParentHandle )); + DBGC ( colour, " %s\n", efi_handle_name ( loaded->ParentHandle ) ); DBGC ( colour, "WRAP %s device", efi_handle_name ( handle ) ); - DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle )); + DBGC ( colour, " %s\n", efi_handle_name ( loaded->DeviceHandle ) ); DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) ); - DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) ); + DBGC ( colour, " %s\n", efi_devpath_text ( loaded->FilePath ) ); } /** -- cgit v1.2.3-55-g7522 From ec8c5a5fbb5b32e20cbd7ad61af49704355a6f05 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 27 Mar 2025 12:48:05 +0000 Subject: [efi] Add ACPI and SMBIOS tables as well-known GUIDs Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 5 +++++ src/interface/efi/efi_guid.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 5fae87731..9b1928ee3 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -246,6 +246,11 @@ extern EFI_GUID efi_usb2_hc_protocol_guid; extern EFI_GUID efi_usb_io_protocol_guid; extern EFI_GUID efi_vlan_config_protocol_guid; +extern EFI_GUID efi_acpi_10_table_guid; +extern EFI_GUID efi_acpi_20_table_guid; +extern EFI_GUID efi_smbios_table_guid; +extern EFI_GUID efi_smbios2_table_guid; + extern EFI_GUID efi_cert_x509_guid; extern EFI_GUID efi_file_info_id; extern EFI_GUID efi_file_system_info_id; diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 191ce5094..5a37ec477 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -84,10 +84,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include #include +#include #include /** @file @@ -401,6 +403,22 @@ EFI_GUID efi_usb_io_protocol_guid EFI_GUID efi_vlan_config_protocol_guid = EFI_VLAN_CONFIG_PROTOCOL_GUID; +/** ACPI 1.0 table GUID */ +EFI_GUID efi_acpi_10_table_guid + = ACPI_10_TABLE_GUID; + +/** ACPI 2.0 table GUID */ +EFI_GUID efi_acpi_20_table_guid + = EFI_ACPI_20_TABLE_GUID; + +/** SMBIOS table GUID */ +EFI_GUID efi_smbios_table_guid + = SMBIOS_TABLE_GUID; + +/** SMBIOS3 table GUID */ +EFI_GUID efi_smbios3_table_guid + = SMBIOS3_TABLE_GUID; + /** X.509 certificate GUID */ EFI_GUID efi_cert_x509_guid = EFI_CERT_X509_GUID; @@ -458,6 +476,10 @@ struct efi_well_known_guid { static struct efi_well_known_guid efi_well_known_guids[] = { { &efi_absolute_pointer_protocol_guid, "AbsolutePointer" }, + { &efi_acpi_10_table_guid, + "Acpi10" }, + { &efi_acpi_20_table_guid, + "Acpi20" }, { &efi_acpi_table_protocol_guid, "AcpiTable" }, { &efi_apple_net_boot_protocol_guid, @@ -582,6 +604,10 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "SimpleTextInputEx" }, { &efi_simple_text_output_protocol_guid, "SimpleTextOutput" }, + { &efi_smbios_table_guid, + "Smbios" }, + { &efi_smbios3_table_guid, + "Smbios3" }, { &efi_tcg_protocol_guid, "Tcg" }, { &efi_tcg2_protocol_guid, -- cgit v1.2.3-55-g7522 From f0caf90a7285ba2676a5800821ae512848057924 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 27 Mar 2025 12:49:58 +0000 Subject: [efi] Add flattened device tree header and GUID definitions Signed-off-by: Michael Brown --- src/include/ipxe/efi/Guid/Fdt.h | 24 ++++++++++++++++++++++++ src/include/ipxe/efi/efi.h | 1 + src/include/ipxe/efi/import.pl | 4 ++-- src/interface/efi/efi_fdt.c | 9 +++------ src/interface/efi/efi_guid.c | 7 +++++++ 5 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/include/ipxe/efi/Guid/Fdt.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Guid/Fdt.h b/src/include/ipxe/efi/Guid/Fdt.h new file mode 100644 index 000000000..f668d0e63 --- /dev/null +++ b/src/include/ipxe/efi/Guid/Fdt.h @@ -0,0 +1,24 @@ +/** @file +* +* Copyright (c) 2013-2014, ARM Limited. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#ifndef __FDT_H__ +#define __FDT_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#define FDT_TABLE_GUID \ + { 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } } + +extern EFI_GUID gFdtTableGuid; + +#define FDT_VARIABLE_GUID \ + { 0x25a4fd4a, 0x9703, 0x4ba9, { 0xa1, 0x90, 0xb7, 0xc8, 0x4e, 0xfb, 0x3e, 0x57 } } + +extern EFI_GUID gFdtVariableGuid; + +#endif /* __FDT_H__ */ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 9b1928ee3..8347d8249 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -248,6 +248,7 @@ extern EFI_GUID efi_vlan_config_protocol_guid; extern EFI_GUID efi_acpi_10_table_guid; extern EFI_GUID efi_acpi_20_table_guid; +extern EFI_GUID efi_fdt_table_guid; extern EFI_GUID efi_smbios_table_guid; extern EFI_GUID efi_smbios2_table_guid; diff --git a/src/include/ipxe/efi/import.pl b/src/include/ipxe/efi/import.pl index 346d45e5f..75c200de0 100755 --- a/src/include/ipxe/efi/import.pl +++ b/src/include/ipxe/efi/import.pl @@ -71,7 +71,7 @@ sub try_import_file { push @dependencies, $2; } # Check for BSD licence statement - if ( /^\s*SPDX-License-Identifier: BSD-2-Clause-Patent$/ ) { + if ( /\s*SPDX-License-Identifier: BSD-2-Clause-Patent$/ ) { die "Licence detected after header guard\n" if $guard; $licence = "BSD2_PATENT"; } @@ -119,7 +119,7 @@ my $edktop = shift; # Identify edk import directories my $edkdirs = [ "MdePkg/Include", "MdeModulePkg/Include", - "NetworkPkg/Include" ]; + "NetworkPkg/Include", "EmbeddedPkg/Include" ]; foreach my $edkdir ( @$edkdirs ) { die "Directory \"$edktop\" does not appear to contain the EFI EDK2 " ."(missing \"$edkdir\")\n" unless -d catdir ( $edktop, $edkdir ); diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index cd3f109df..dd9f4cf18 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -25,8 +25,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include +#include +#include /** @file * @@ -34,13 +35,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ -#define DEVICE_TREE_TABLE_GUID \ - { 0xb1b621d5, 0xf19c, 0x41a5, \ - { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } } - /** EFI Flattened Device Tree configuration table */ static struct fdt_header *efi_fdt; -EFI_USE_TABLE ( DEVICE_TREE_TABLE, &efi_fdt, 0 ); +EFI_USE_TABLE ( FDT_TABLE, &efi_fdt, 0 ); /** * Initialise EFI Flattened Device Tree diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 5a37ec477..1b16dd1b7 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -85,6 +85,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -411,6 +412,10 @@ EFI_GUID efi_acpi_10_table_guid EFI_GUID efi_acpi_20_table_guid = EFI_ACPI_20_TABLE_GUID; +/** FDT table GUID */ +EFI_GUID efi_fdt_table_guid + = FDT_TABLE_GUID; + /** SMBIOS table GUID */ EFI_GUID efi_smbios_table_guid = SMBIOS_TABLE_GUID; @@ -524,6 +529,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Dns6" }, { &efi_dns6_service_binding_protocol_guid, "Dns6Sb" }, + { &efi_fdt_table_guid, + "Fdt" }, { &efi_global_variable, "GlobalVar" }, { &efi_graphics_output_protocol_guid, -- cgit v1.2.3-55-g7522 From 98f86b4d0ab9c9c86825922156df7217e6df2045 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 27 Mar 2025 14:45:12 +0000 Subject: [efi] Add support for installing EFI configuration tables Add the ability to install and uninstall arbitrary EFI configuration tables. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi_table.h | 37 ++++++++ src/include/ipxe/errfile.h | 1 + src/interface/efi/efi_init.c | 19 +---- src/interface/efi/efi_table.c | 178 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 217 insertions(+), 18 deletions(-) create mode 100644 src/include/ipxe/efi/efi_table.h create mode 100644 src/interface/efi/efi_table.c (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi_table.h b/src/include/ipxe/efi/efi_table.h new file mode 100644 index 000000000..9a41d8723 --- /dev/null +++ b/src/include/ipxe/efi/efi_table.h @@ -0,0 +1,37 @@ +#ifndef _IPXE_EFI_TABLE_H +#define _IPXE_EFI_TABLE_H + +/** @file + * + * EFI configuration tables + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +/** An installable EFI configuration table type */ +struct efi_table { + /** Table GUID */ + EFI_GUID *guid; + /** + * Determine length of table + * + * @v data Configuration table data (presumed valid) + * @ret len Length of table + * + * EFI does not record the length of installed configuration + * tables. Consumers must understand the specific type of + * table in order to be able to determine its length from the + * contents. + */ + size_t ( * len ) ( const void *data ); +}; + +extern void * efi_find_table ( EFI_GUID *guid ); +extern int efi_install_table ( struct efi_table *table, const void *data, + void **backup ); +extern int efi_uninstall_table ( struct efi_table *table, void **backup ); + +#endif /* _IPXE_EFI_TABLE_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 51b458d56..a64104a22 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -85,6 +85,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_efi_service ( ERRFILE_CORE | 0x002d0000 ) #define ERRFILE_null_smbios ( ERRFILE_CORE | 0x002e0000 ) #define ERRFILE_efi_open ( ERRFILE_CORE | 0x002f0000 ) +#define ERRFILE_efi_table ( ERRFILE_CORE | 0x00300000 ) #define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 ) #define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 ) diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 1ba144ee7..69aea0d50 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include #include #include @@ -103,24 +104,6 @@ static EFIAPI void efi_shutdown_hook ( EFI_EVENT event __unused, shutdown_boot(); } -/** - * Look up EFI configuration table - * - * @v guid Configuration table GUID - * @ret table Configuration table, or NULL - */ -static void * efi_find_table ( EFI_GUID *guid ) { - unsigned int i; - - for ( i = 0 ; i < efi_systab->NumberOfTableEntries ; i++ ) { - if ( memcmp ( &efi_systab->ConfigurationTable[i].VendorGuid, - guid, sizeof ( *guid ) ) == 0 ) - return efi_systab->ConfigurationTable[i].VendorTable; - } - - return NULL; -} - /** * Construct a stack cookie value * diff --git a/src/interface/efi/efi_table.c b/src/interface/efi/efi_table.c new file mode 100644 index 000000000..3c3f35a4b --- /dev/null +++ b/src/interface/efi/efi_table.c @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include + +/** @file + * + * EFI configuration tables + * + */ + +/** + * Look up EFI configuration table + * + * @v guid Configuration table GUID + * @ret table Configuration table, or NULL + */ +void * efi_find_table ( EFI_GUID *guid ) { + void *table; + unsigned int i; + + /* Scan for installed table */ + for ( i = 0 ; i < efi_systab->NumberOfTableEntries ; i++ ) { + if ( memcmp ( &efi_systab->ConfigurationTable[i].VendorGuid, + guid, sizeof ( *guid ) ) == 0 ) { + table = efi_systab->ConfigurationTable[i].VendorTable; + DBGC ( guid, "EFITAB %s is at %p\n", + efi_guid_ntoa ( guid ), table ); + return table; + } + } + + return NULL; +} + +/** + * Install EFI configuration table + * + * @v table Configuration table type + * @v data Configuration table data, or NULL to uninstall + * @v backup Table backup, or NULL to not back up old table + * @ret rc Return status code + */ +int efi_install_table ( struct efi_table *table, const void *data, + void **backup ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_GUID *guid = table->guid; + void *copy; + void *new; + void *old; + size_t old_len; + size_t new_len; + EFI_STATUS efirc; + int rc; + + /* Get currently installed table, if any */ + old = efi_find_table ( guid ); + old_len = ( old ? table->len ( old ) : 0 ); + + /* Create backup copy, if applicable */ + if ( old_len && backup ) { + if ( ( efirc = bs->AllocatePool ( EfiBootServicesData, old_len, + © ) ) != 0 ) { + rc = -EEFI ( efirc ); + goto err_backup; + } + memcpy ( copy, old, old_len ); + DBGC ( table, "EFITAB %s %p+%#zx backed up\n", + efi_guid_ntoa ( guid ), old, old_len ); + } else { + copy = NULL; + } + + /* Create installable runtime services data copy, if applicable */ + new_len = ( data ? table->len ( data ) : 0 ); + if ( new_len ) { + if ( ( efirc = bs->AllocatePool ( EfiRuntimeServicesData, + new_len, &new ) ) != 0 ) { + rc = -EEFI ( efirc ); + goto err_allocate; + } + memcpy ( new, data, new_len ); + } else { + new = NULL; + } + + /* (Un)install configuration table, if applicable */ + if ( new || old ) { + if ( ( efirc = bs->InstallConfigurationTable ( guid, + new ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( table, "EFITAB %s could not install: %s\n", + efi_guid_ntoa ( guid ), strerror ( rc ) ); + goto err_install; + } + if ( old ) { + DBGC ( table, "EFITAB %s %p+%#zx uninstalled\n", + efi_guid_ntoa ( guid ), old, old_len ); + } + if ( new ) { + DBGC ( table, "EFITAB %s %p+%#zx installed\n", + efi_guid_ntoa ( guid ), new, new_len ); + } + } + + /* Record backup copy, if applicable */ + if ( backup ) { + if ( *backup ) + bs->FreePool ( *backup ); + *backup = copy; + } + + /* Sanity check */ + assert ( efi_find_table ( guid ) == new ); + + return 0; + + err_install: + if ( new ) + bs->FreePool ( new ); + err_allocate: + if ( copy ) + bs->FreePool ( copy ); + err_backup: + return rc; +} + +/** + * Uninstall EFI configuration table + * + * @v table Configuration table type + * @v backup Table backup (or NULL to not restore old table) + * @ret rc Return status code + */ +int efi_uninstall_table ( struct efi_table *table, void **backup ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + void *old; + int rc; + + /* Uninstall or reinstall as applicable */ + old = ( backup ? *backup : NULL ); + if ( ( rc = efi_install_table ( table, old, NULL ) ) != 0 ) + return rc; + + /* Free backup copy, if applicable */ + if ( backup && *backup ) { + bs->FreePool ( *backup ); + *backup = NULL; + } + + return 0; +} -- cgit v1.2.3-55-g7522 From 2399c7998072f47a7f599ddd4d318bbc14adf39d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 28 Mar 2025 12:42:30 +0000 Subject: [fdt] Allow for the existence of multiple device trees When running on a platform that uses FDT as its hardware description mechanism, we are likely to have multiple device tree structures. At a minimum, there will be the device tree passed to us from the previous boot stage (e.g. OpenSBI), and the device tree that we construct to be passed to the booted operating system. Update the internal FDT API to include an FDT pointer in all function parameter lists. Signed-off-by: Michael Brown --- src/arch/riscv/core/hart.c | 4 +- src/arch/riscv/core/zicntr.c | 4 +- src/arch/riscv/prefix/sbiprefix.S | 5 +- src/core/fdt.c | 186 +++++++++++++++++++------------------- src/drivers/net/smscusb.c | 6 +- src/include/ipxe/fdt.h | 20 ++-- src/interface/efi/efi_fdt.c | 6 +- 7 files changed, 121 insertions(+), 110 deletions(-) (limited to 'src/interface') diff --git a/src/arch/riscv/core/hart.c b/src/arch/riscv/core/hart.c index c4f2bd0a5..d9cfb4e5d 100644 --- a/src/arch/riscv/core/hart.c +++ b/src/arch/riscv/core/hart.c @@ -55,7 +55,7 @@ static int hart_node ( unsigned int *offset ) { snprintf ( path, sizeof ( path ), "/cpus/cpu@%lx", boot_hart ); /* Find node */ - if ( ( rc = fdt_path ( path, offset ) ) != 0 ) { + if ( ( rc = fdt_path ( &sysfdt, path, offset ) ) != 0 ) { DBGC ( colour, "HART could not find %s: %s\n", path, strerror ( rc ) ); return rc; @@ -81,7 +81,7 @@ int hart_supported ( const char *ext ) { return rc; /* Get ISA description */ - isa = fdt_string ( offset, "riscv,isa" ); + isa = fdt_string ( &sysfdt, offset, "riscv,isa" ); if ( ! isa ) { DBGC ( colour, "HART could not identify ISA\n" ); return -ENOENT; diff --git a/src/arch/riscv/core/zicntr.c b/src/arch/riscv/core/zicntr.c index 826f31a68..7ea9f96ad 100644 --- a/src/arch/riscv/core/zicntr.c +++ b/src/arch/riscv/core/zicntr.c @@ -152,8 +152,8 @@ static int zicntr_probe ( void ) { } /* Get timer frequency */ - if ( ( ( rc = fdt_path ( "/cpus", &offset ) ) != 0 ) || - ( ( rc = fdt_u64 ( offset, "timebase-frequency", + if ( ( ( rc = fdt_path ( &sysfdt, "/cpus", &offset ) ) != 0 ) || + ( ( rc = fdt_u64 ( &sysfdt, offset, "timebase-frequency", &u.freq ) ) != 0 ) ) { DBGC ( colour, "ZICNTR could not determine frequency: %s\n", strerror ( rc ) ); diff --git a/src/arch/riscv/prefix/sbiprefix.S b/src/arch/riscv/prefix/sbiprefix.S index 0de001951..a39d37cb1 100644 --- a/src/arch/riscv/prefix/sbiprefix.S +++ b/src/arch/riscv/prefix/sbiprefix.S @@ -121,8 +121,9 @@ _sbi_start: STOREN s0, (t0) /* Register device tree */ - mv a0, s1 - call register_fdt + la a0, sysfdt + mv a1, s1 + call fdt_parse /* Call main program */ progress "\n\n" diff --git a/src/core/fdt.c b/src/core/fdt.c index ad83ed69a..e2ce055eb 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -38,7 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /** The system flattened device tree (if present) */ -static struct fdt fdt; +struct fdt sysfdt; /** The downloaded flattened device tree tag */ struct image_tag fdt_image __image_tag = { @@ -63,24 +63,16 @@ struct fdt_descriptor { size_t len; }; -/** - * Check if device tree exists - * - * @v has_fdt Device tree exists - */ -static inline __attribute__ (( always_inline )) int fdt_exists ( void ) { - - return ( fdt.hdr != NULL ); -} - /** * Traverse device tree * + * @v fdt Device tree * @v pos Position within device tree * @v desc Lexical descriptor to fill in * @ret rc Return status code */ -static int fdt_traverse ( struct fdt_cursor *pos, +static int fdt_traverse ( struct fdt *fdt, + struct fdt_cursor *pos, struct fdt_descriptor *desc ) { const fdt_token_t *token; const void *data; @@ -90,17 +82,17 @@ static int fdt_traverse ( struct fdt_cursor *pos, size_t len; /* Sanity checks */ - assert ( pos->offset < fdt.len ); + assert ( pos->offset < fdt->len ); assert ( ( pos->offset & ( FDT_STRUCTURE_ALIGN - 1 ) ) == 0 ); /* Clear descriptor */ memset ( desc, 0, sizeof ( *desc ) ); /* Locate token and calculate remaining space */ - token = ( fdt.raw + fdt.structure + pos->offset ); - remaining = ( fdt.len - pos->offset ); + token = ( fdt->raw + fdt->structure + pos->offset ); + remaining = ( fdt->len - pos->offset ); if ( remaining < sizeof ( *token ) ) { - DBGC ( &fdt, "FDT truncated tree at +%#04x\n", pos->offset ); + DBGC ( fdt, "FDT truncated tree at +%#04x\n", pos->offset ); return -EINVAL; } remaining -= sizeof ( *token ); @@ -116,7 +108,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, desc->name = data; len = ( strnlen ( desc->name, remaining ) + 1 /* NUL */ ); if ( remaining < len ) { - DBGC ( &fdt, "FDT unterminated node name at +%#04x\n", + DBGC ( fdt, "FDT unterminated node name at +%#04x\n", pos->offset ); return -EINVAL; } @@ -127,7 +119,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, /* End of node */ if ( pos->depth < 0 ) { - DBGC ( &fdt, "FDT spurious node end at +%#04x\n", + DBGC ( fdt, "FDT spurious node end at +%#04x\n", pos->offset ); return -EINVAL; } @@ -143,7 +135,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, /* Property */ prop = data; if ( remaining < sizeof ( *prop ) ) { - DBGC ( &fdt, "FDT truncated property at +%#04x\n", + DBGC ( fdt, "FDT truncated property at +%#04x\n", pos->offset ); return -EINVAL; } @@ -151,17 +143,17 @@ static int fdt_traverse ( struct fdt_cursor *pos, desc->len = be32_to_cpu ( prop->len ); len = ( sizeof ( *prop ) + desc->len ); if ( remaining < len ) { - DBGC ( &fdt, "FDT overlength property at +%#04x\n", + DBGC ( fdt, "FDT overlength property at +%#04x\n", pos->offset ); return -EINVAL; } name_off = be32_to_cpu ( prop->name_off ); - if ( name_off > fdt.strings_len ) { - DBGC ( &fdt, "FDT property name outside strings " + if ( name_off > fdt->strings_len ) { + DBGC ( fdt, "FDT property name outside strings " "block at +%#04x\n", pos->offset ); return -EINVAL; } - desc->name = ( fdt.raw + fdt.strings + name_off ); + desc->name = ( fdt->raw + fdt->strings + name_off ); break; case cpu_to_be32 ( FDT_NOP ): @@ -172,7 +164,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, default: /* Unrecognised or unexpected token */ - DBGC ( &fdt, "FDT unexpected token %#08x at +%#04x\n", + DBGC ( fdt, "FDT unexpected token %#08x at +%#04x\n", be32_to_cpu ( *token ), pos->offset ); return -EINVAL; } @@ -183,7 +175,7 @@ static int fdt_traverse ( struct fdt_cursor *pos, pos->offset += ( sizeof ( *token ) + len ); /* Sanity checks */ - assert ( pos->offset <= fdt.len ); + assert ( pos->offset <= fdt->len ); return 0; } @@ -191,12 +183,13 @@ static int fdt_traverse ( struct fdt_cursor *pos, /** * Find child node * + * @v fdt Device tree * @v offset Starting node offset * @v name Node name * @v child Child node offset to fill in * @ret rc Return status code */ -static int fdt_child ( unsigned int offset, const char *name, +static int fdt_child ( struct fdt *fdt, unsigned int offset, const char *name, unsigned int *child ) { struct fdt_cursor pos; struct fdt_descriptor desc; @@ -217,18 +210,18 @@ static int fdt_child ( unsigned int offset, const char *name, *child = pos.offset; /* Traverse tree */ - if ( ( rc = fdt_traverse ( &pos, &desc ) ) != 0 ) { - DBGC ( &fdt, "FDT +%#04x has no child node \"%s\": " + if ( ( rc = fdt_traverse ( fdt, &pos, &desc ) ) != 0 ) { + DBGC ( fdt, "FDT +%#04x has no child node \"%s\": " "%s\n", orig_offset, name, strerror ( rc ) ); return rc; } /* Check for matching immediate child node */ if ( ( pos.depth == 1 ) && desc.name && ( ! desc.data ) ) { - DBGC2 ( &fdt, "FDT +%#04x has child node \"%s\"\n", + DBGC2 ( fdt, "FDT +%#04x has child node \"%s\"\n", orig_offset, desc.name ); if ( strcmp ( name, desc.name ) == 0 ) { - DBGC2 ( &fdt, "FDT +%#04x found child node " + DBGC2 ( fdt, "FDT +%#04x found child node " "\"%s\" at +%#04x\n", orig_offset, desc.name, *child ); return 0; @@ -240,11 +233,12 @@ static int fdt_child ( unsigned int offset, const char *name, /** * Find node by path * + * @v fdt Device tree * @v path Node path * @v offset Offset to fill in * @ret rc Return status code */ -int fdt_path ( const char *path, unsigned int *offset ) { +int fdt_path ( struct fdt *fdt, const char *path, unsigned int *offset ) { char *tmp = ( ( char * ) path ); char *del; int rc; @@ -265,7 +259,7 @@ int fdt_path ( const char *path, unsigned int *offset ) { *del = '\0'; /* Find child and restore delimiter */ - rc = fdt_child ( *offset, tmp, offset ); + rc = fdt_child ( fdt, *offset, tmp, offset ); if ( del ) *del = '/'; if ( rc != 0 ) @@ -276,32 +270,33 @@ int fdt_path ( const char *path, unsigned int *offset ) { tmp++; } - DBGC2 ( &fdt, "FDT found path \"%s\" at +%#04x\n", path, *offset ); + DBGC2 ( fdt, "FDT found path \"%s\" at +%#04x\n", path, *offset ); return 0; } /** * Find node by alias * + * @v fdt Device tree * @v name Alias name * @v offset Offset to fill in * @ret rc Return status code */ -int fdt_alias ( const char *name, unsigned int *offset ) { +int fdt_alias ( struct fdt *fdt, const char *name, unsigned int *offset ) { const char *alias; int rc; /* Locate "/aliases" node */ - if ( ( rc = fdt_child ( 0, "aliases", offset ) ) != 0 ) + if ( ( rc = fdt_child ( fdt, 0, "aliases", offset ) ) != 0 ) return rc; /* Locate alias property */ - if ( ( alias = fdt_string ( *offset, name ) ) == NULL ) + if ( ( alias = fdt_string ( fdt, *offset, name ) ) == NULL ) return -ENOENT; - DBGC ( &fdt, "FDT alias \"%s\" is \"%s\"\n", name, alias ); + DBGC ( fdt, "FDT alias \"%s\" is \"%s\"\n", name, alias ); /* Locate aliased node */ - if ( ( rc = fdt_path ( alias, offset ) ) != 0 ) + if ( ( rc = fdt_path ( fdt, alias, offset ) ) != 0 ) return rc; return 0; @@ -310,13 +305,14 @@ int fdt_alias ( const char *name, unsigned int *offset ) { /** * Find property * + * @v fdt Device tree * @v offset Starting node offset * @v name Property name * @v desc Lexical descriptor to fill in * @ret rc Return status code */ -static int fdt_property ( unsigned int offset, const char *name, - struct fdt_descriptor *desc ) { +static int fdt_property ( struct fdt *fdt, unsigned int offset, + const char *name, struct fdt_descriptor *desc ) { struct fdt_cursor pos; int rc; @@ -328,20 +324,20 @@ static int fdt_property ( unsigned int offset, const char *name, while ( 1 ) { /* Traverse tree */ - if ( ( rc = fdt_traverse ( &pos, desc ) ) != 0 ) { - DBGC ( &fdt, "FDT +%#04x has no property \"%s\": %s\n", + if ( ( rc = fdt_traverse ( fdt, &pos, desc ) ) != 0 ) { + DBGC ( fdt, "FDT +%#04x has no property \"%s\": %s\n", offset, name, strerror ( rc ) ); return rc; } /* Check for matching immediate child property */ if ( ( pos.depth == 0 ) && desc->data ) { - DBGC2 ( &fdt, "FDT +%#04x has property \"%s\" len " + DBGC2 ( fdt, "FDT +%#04x has property \"%s\" len " "%#zx\n", offset, desc->name, desc->len ); if ( strcmp ( name, desc->name ) == 0 ) { - DBGC2 ( &fdt, "FDT +%#04x found property " + DBGC2 ( fdt, "FDT +%#04x found property " "\"%s\"\n", offset, desc->name ); - DBGC2_HDA ( &fdt, 0, desc->data, desc->len ); + DBGC2_HDA ( fdt, 0, desc->data, desc->len ); return 0; } } @@ -351,21 +347,23 @@ static int fdt_property ( unsigned int offset, const char *name, /** * Find string property * + * @v fdt Device tree * @v offset Starting node offset * @v name Property name * @ret string String property, or NULL on error */ -const char * fdt_string ( unsigned int offset, const char *name ) { +const char * fdt_string ( struct fdt *fdt, unsigned int offset, + const char *name ) { struct fdt_descriptor desc; int rc; /* Find property */ - if ( ( rc = fdt_property ( offset, name, &desc ) ) != 0 ) + if ( ( rc = fdt_property ( fdt, offset, name, &desc ) ) != 0 ) return NULL; /* Check NUL termination */ if ( strnlen ( desc.data, desc.len ) == desc.len ) { - DBGC ( &fdt, "FDT unterminated string property \"%s\"\n", + DBGC ( fdt, "FDT unterminated string property \"%s\"\n", name ); return NULL; } @@ -376,12 +374,14 @@ const char * fdt_string ( unsigned int offset, const char *name ) { /** * Find integer property * + * @v fdt Device tree * @v offset Starting node offset * @v name Property name * @v value Integer value to fill in * @ret rc Return status code */ -int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ) { +int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, + uint64_t *value ) { struct fdt_descriptor desc; const uint8_t *data; size_t remaining; @@ -391,12 +391,12 @@ int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ) { *value = 0; /* Find property */ - if ( ( rc = fdt_property ( offset, name, &desc ) ) != 0 ) + if ( ( rc = fdt_property ( fdt, offset, name, &desc ) ) != 0 ) return rc; /* Check range */ if ( desc.len > sizeof ( *value ) ) { - DBGC ( &fdt, "FDT oversized integer property \"%s\"\n", name ); + DBGC ( fdt, "FDT oversized integer property \"%s\"\n", name ); return -ERANGE; } @@ -414,18 +414,21 @@ int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ) { /** * Get MAC address from property * + * @v fdt Device tree * @v offset Starting node offset * @v netdev Network device * @ret rc Return status code */ -int fdt_mac ( unsigned int offset, struct net_device *netdev ) { +int fdt_mac ( struct fdt *fdt, unsigned int offset, + struct net_device *netdev ) { struct fdt_descriptor desc; size_t len; int rc; /* Find applicable MAC address property */ - if ( ( ( rc = fdt_property ( offset, "mac-address", &desc ) ) != 0 ) && - ( ( rc = fdt_property ( offset, "local-mac-address", + if ( ( ( rc = fdt_property ( fdt, offset, "mac-address", + &desc ) ) != 0 ) && + ( ( rc = fdt_property ( fdt, offset, "local-mac-address", &desc ) ) != 0 ) ) { return rc; } @@ -433,9 +436,9 @@ int fdt_mac ( unsigned int offset, struct net_device *netdev ) { /* Check length */ len = netdev->ll_protocol->hw_addr_len; if ( len != desc.len ) { - DBGC ( &fdt, "FDT malformed MAC address \"%s\":\n", + DBGC ( fdt, "FDT malformed MAC address \"%s\":\n", desc.name ); - DBGC_HDA ( &fdt, 0, desc.data, desc.len ); + DBGC_HDA ( fdt, 0, desc.data, desc.len ); return -ERANGE; } @@ -446,85 +449,86 @@ int fdt_mac ( unsigned int offset, struct net_device *netdev ) { } /** - * Register device tree + * Parse device tree * - * @v fdt Device tree header + * @v fdt Device tree + * @v hdr Device tree header * @ret rc Return status code */ -int register_fdt ( const struct fdt_header *hdr ) { +int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr ) { const uint8_t *end; /* Record device tree location */ - fdt.hdr = hdr; - fdt.len = be32_to_cpu ( hdr->totalsize ); - DBGC ( &fdt, "FDT version %d at %p+%#04zx\n", - be32_to_cpu ( hdr->version ), fdt.hdr, fdt.len ); + fdt->hdr = hdr; + fdt->len = be32_to_cpu ( hdr->totalsize ); + DBGC ( fdt, "FDT version %d at %p+%#04zx\n", + be32_to_cpu ( hdr->version ), fdt->hdr, fdt->len ); /* Check signature */ if ( hdr->magic != cpu_to_be32 ( FDT_MAGIC ) ) { - DBGC ( &fdt, "FDT has invalid magic value %#08x\n", + DBGC ( fdt, "FDT has invalid magic value %#08x\n", be32_to_cpu ( hdr->magic ) ); goto err; } /* Check version */ if ( hdr->last_comp_version != cpu_to_be32 ( FDT_VERSION ) ) { - DBGC ( &fdt, "FDT unsupported version %d\n", + DBGC ( fdt, "FDT unsupported version %d\n", be32_to_cpu ( hdr->last_comp_version ) ); goto err; } /* Record structure block location */ - fdt.structure = be32_to_cpu ( hdr->off_dt_struct ); - fdt.structure_len = be32_to_cpu ( hdr->size_dt_struct ); - DBGC ( &fdt, "FDT structure block at +[%#04x,%#04zx)\n", - fdt.structure, ( fdt.structure + fdt.structure_len ) ); - if ( ( fdt.structure > fdt.len ) || - ( fdt.structure_len > ( fdt.len - fdt.structure ) ) ) { - DBGC ( &fdt, "FDT structure block exceeds table\n" ); + fdt->structure = be32_to_cpu ( hdr->off_dt_struct ); + fdt->structure_len = be32_to_cpu ( hdr->size_dt_struct ); + DBGC ( fdt, "FDT structure block at +[%#04x,%#04zx)\n", + fdt->structure, ( fdt->structure + fdt->structure_len ) ); + if ( ( fdt->structure > fdt->len ) || + ( fdt->structure_len > ( fdt->len - fdt->structure ) ) ) { + DBGC ( fdt, "FDT structure block exceeds table\n" ); goto err; } - if ( ( fdt.structure | fdt.structure_len ) & + if ( ( fdt->structure | fdt->structure_len ) & ( FDT_STRUCTURE_ALIGN - 1 ) ) { - DBGC ( &fdt, "FDT structure block is misaligned\n" ); + DBGC ( fdt, "FDT structure block is misaligned\n" ); goto err; } /* Record strings block location */ - fdt.strings = be32_to_cpu ( hdr->off_dt_strings ); - fdt.strings_len = be32_to_cpu ( hdr->size_dt_strings ); - DBGC ( &fdt, "FDT strings block at +[%#04x,%#04zx)\n", - fdt.strings, ( fdt.strings + fdt.strings_len ) ); - if ( ( fdt.strings > fdt.len ) || - ( fdt.strings_len > ( fdt.len - fdt.strings ) ) ) { - DBGC ( &fdt, "FDT strings block exceeds table\n" ); + fdt->strings = be32_to_cpu ( hdr->off_dt_strings ); + fdt->strings_len = be32_to_cpu ( hdr->size_dt_strings ); + DBGC ( fdt, "FDT strings block at +[%#04x,%#04zx)\n", + fdt->strings, ( fdt->strings + fdt->strings_len ) ); + if ( ( fdt->strings > fdt->len ) || + ( fdt->strings_len > ( fdt->len - fdt->strings ) ) ) { + DBGC ( fdt, "FDT strings block exceeds table\n" ); goto err; } /* Shrink strings block to ensure NUL termination safety */ - end = ( fdt.raw + fdt.strings + fdt.strings_len ); - for ( ; fdt.strings_len ; fdt.strings_len-- ) { + end = ( fdt->raw + fdt->strings + fdt->strings_len ); + for ( ; fdt->strings_len ; fdt->strings_len-- ) { if ( *(--end) == '\0' ) break; } - if ( fdt.strings_len != be32_to_cpu ( hdr->size_dt_strings ) ) { - DBGC ( &fdt, "FDT strings block shrunk to +[%#04x,%#04zx)\n", - fdt.strings, ( fdt.strings + fdt.strings_len ) ); + if ( fdt->strings_len != be32_to_cpu ( hdr->size_dt_strings ) ) { + DBGC ( fdt, "FDT strings block shrunk to +[%#04x,%#04zx)\n", + fdt->strings, ( fdt->strings + fdt->strings_len ) ); } /* Print model name (for debugging) */ - DBGC ( &fdt, "FDT model is \"%s\"\n", fdt_string ( 0, "model" ) ); + DBGC ( fdt, "FDT model is \"%s\"\n", fdt_string ( fdt, 0, "model" ) ); return 0; err: - DBGC_HDA ( &fdt, 0, hdr, sizeof ( *hdr ) ); - fdt.hdr = NULL; + DBGC_HDA ( fdt, 0, hdr, sizeof ( *hdr ) ); + memset ( fdt, 0, sizeof ( *fdt ) ); return -EINVAL; } -/* Drag in objects via register_fdt */ -REQUIRING_SYMBOL ( register_fdt ); +/* Drag in objects via fdt_traverse() */ +REQUIRING_SYMBOL ( fdt_traverse ); /* Drag in device tree configuration */ REQUIRE_OBJECT ( config_fdt ); diff --git a/src/drivers/net/smscusb.c b/src/drivers/net/smscusb.c index c639c58c1..93007e386 100644 --- a/src/drivers/net/smscusb.c +++ b/src/drivers/net/smscusb.c @@ -459,13 +459,13 @@ int smscusb_fdt_fetch_mac ( struct smscusb_device *smscusb ) { int rc; /* Look for "ethernet[0]" alias */ - if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) && - ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) { + if ( ( rc = fdt_alias ( &sysfdt, "ethernet", &offset ) != 0 ) && + ( rc = fdt_alias ( &sysfdt, "ethernet0", &offset ) != 0 ) ) { return rc; } /* Fetch MAC address */ - if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 ) + if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) return rc; DBGC ( smscusb, "SMSCUSB %p using FDT MAC %s\n", diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index 995975ed8..04201ce9b 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -95,12 +95,18 @@ struct fdt { }; extern struct image_tag fdt_image __image_tag; - -extern int fdt_path ( const char *path, unsigned int *offset ); -extern int fdt_alias ( const char *name, unsigned int *offset ); -extern const char * fdt_string ( unsigned int offset, const char *name ); -extern int fdt_u64 ( unsigned int offset, const char *name, uint64_t *value ); -extern int fdt_mac ( unsigned int offset, struct net_device *netdev ); -extern int register_fdt ( const struct fdt_header *hdr ); +extern struct fdt sysfdt; + +extern int fdt_path ( struct fdt *fdt, const char *path, + unsigned int *offset ); +extern int fdt_alias ( struct fdt *fdt, const char *name, + unsigned int *offset ); +extern const char * fdt_string ( struct fdt *fdt, unsigned int offset, + const char *name ); +extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, + uint64_t *value ); +extern int fdt_mac ( struct fdt *fdt, unsigned int offset, + struct net_device *netdev ); +extern int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr ); #endif /* _IPXE_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index dd9f4cf18..f81e6ad63 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -53,9 +53,9 @@ static void efi_fdt_init ( void ) { } DBGC ( &efi_fdt, "EFIFDT configuration table at %p\n", efi_fdt ); - /* Register device tree */ - if ( ( rc = register_fdt ( efi_fdt ) ) != 0 ) { - DBGC ( &efi_fdt, "EFIFDT could not register: %s\n", + /* Parse as system device tree */ + if ( ( rc = fdt_parse ( &sysfdt, efi_fdt ) ) != 0 ) { + DBGC ( &efi_fdt, "EFIFDT could not parse: %s\n", strerror ( rc ) ); return; } -- cgit v1.2.3-55-g7522 From 3860313dd59af568de28f048bccfb644e20ba3b0 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 28 Mar 2025 14:08:18 +0000 Subject: [fdt] Allow for parsing device trees where the length is known in advance Allow for parsing device trees where an external factor (such as a downloaded image length) determines the maximum length, which must be validated against the length within the device tree header. Signed-off-by: Michael Brown --- src/arch/riscv/prefix/sbiprefix.S | 1 + src/core/fdt.c | 18 ++++++++++++++++-- src/include/ipxe/fdt.h | 3 ++- src/interface/efi/efi_fdt.c | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/interface') diff --git a/src/arch/riscv/prefix/sbiprefix.S b/src/arch/riscv/prefix/sbiprefix.S index a39d37cb1..e8ef40b6d 100644 --- a/src/arch/riscv/prefix/sbiprefix.S +++ b/src/arch/riscv/prefix/sbiprefix.S @@ -123,6 +123,7 @@ _sbi_start: /* Register device tree */ la a0, sysfdt mv a1, s1 + li a2, -1 call fdt_parse /* Call main program */ diff --git a/src/core/fdt.c b/src/core/fdt.c index e2ce055eb..9c2880c84 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -82,7 +82,7 @@ static int fdt_traverse ( struct fdt *fdt, size_t len; /* Sanity checks */ - assert ( pos->offset < fdt->len ); + assert ( pos->offset <= fdt->len ); assert ( ( pos->offset & ( FDT_STRUCTURE_ALIGN - 1 ) ) == 0 ); /* Clear descriptor */ @@ -453,14 +453,28 @@ int fdt_mac ( struct fdt *fdt, unsigned int offset, * * @v fdt Device tree * @v hdr Device tree header + * @v max_len Maximum device tree length * @ret rc Return status code */ -int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr ) { +int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr, + size_t max_len ) { const uint8_t *end; + /* Sanity check */ + if ( sizeof ( fdt ) > max_len ) { + DBGC ( fdt, "FDT length %#zx too short for header\n", + max_len ); + goto err; + } + /* Record device tree location */ fdt->hdr = hdr; fdt->len = be32_to_cpu ( hdr->totalsize ); + if ( fdt->len > max_len ) { + DBGC ( fdt, "FDT has invalid length %#zx / %#zx\n", + fdt->len, max_len ); + goto err; + } DBGC ( fdt, "FDT version %d at %p+%#04zx\n", be32_to_cpu ( hdr->version ), fdt->hdr, fdt->len ); diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index 04201ce9b..70dc01790 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -107,6 +107,7 @@ extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, uint64_t *value ); extern int fdt_mac ( struct fdt *fdt, unsigned int offset, struct net_device *netdev ); -extern int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr ); +extern int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr, + size_t max_len ); #endif /* _IPXE_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index f81e6ad63..e207f7e6d 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -54,7 +54,7 @@ static void efi_fdt_init ( void ) { DBGC ( &efi_fdt, "EFIFDT configuration table at %p\n", efi_fdt ); /* Parse as system device tree */ - if ( ( rc = fdt_parse ( &sysfdt, efi_fdt ) ) != 0 ) { + if ( ( rc = fdt_parse ( &sysfdt, efi_fdt, -1UL ) ) != 0 ) { DBGC ( &efi_fdt, "EFIFDT could not parse: %s\n", strerror ( rc ) ); return; -- cgit v1.2.3-55-g7522 From 666929e311190b4df0b70d1d8e46c802cba7af97 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 28 Mar 2025 14:10:55 +0000 Subject: [efi] Create a copy of the system flattened device tree, if present EFI configuration tables may be freed at any time, and there is no way to be notified when the table becomes invalidated. Create a copy of the system flattened device tree (if present), so that we do not risk being left with an invalid pointer. Signed-off-by: Michael Brown --- src/core/fdt.c | 3 +-- src/include/ipxe/fdt.h | 6 +++--- src/interface/efi/efi_fdt.c | 11 +++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/interface') diff --git a/src/core/fdt.c b/src/core/fdt.c index 9c2880c84..4fd2b76bf 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -456,8 +456,7 @@ int fdt_mac ( struct fdt *fdt, unsigned int offset, * @v max_len Maximum device tree length * @ret rc Return status code */ -int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr, - size_t max_len ) { +int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ) { const uint8_t *end; /* Sanity check */ diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index 70dc01790..2799e0d07 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -78,9 +78,9 @@ struct fdt { /** Tree data */ union { /** Tree header */ - const struct fdt_header *hdr; + struct fdt_header *hdr; /** Raw data */ - const void *raw; + void *raw; }; /** Length of tree */ size_t len; @@ -107,7 +107,7 @@ extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name, uint64_t *value ); extern int fdt_mac ( struct fdt *fdt, unsigned int offset, struct net_device *netdev ); -extern int fdt_parse ( struct fdt *fdt, const struct fdt_header *hdr, +extern int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ); #endif /* _IPXE_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index e207f7e6d..71b788ae7 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -44,6 +44,8 @@ EFI_USE_TABLE ( FDT_TABLE, &efi_fdt, 0 ); * */ static void efi_fdt_init ( void ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_STATUS efirc; int rc; /* Do nothing if no configuration table is present */ @@ -59,6 +61,15 @@ static void efi_fdt_init ( void ) { strerror ( rc ) ); return; } + + /* Create copy, since table may be removed at any time */ + if ( ( efirc = bs->AllocatePool ( EfiBootServicesData, sysfdt.len, + &sysfdt.raw ) ) != 0 ) { + DBGC ( &efi_fdt, "EFIFDT could not create copy\n" ); + sysfdt.len = 0; + return; + } + memcpy ( sysfdt.raw, efi_fdt, sysfdt.len ); } /** EFI Flattened Device Tree initialisation function */ -- cgit v1.2.3-55-g7522 From b20f506a7217ce18f08ec007467365f9e118c445 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 28 Mar 2025 14:20:44 +0000 Subject: [efi] Install a device tree for the booted OS, if available If we have a device tree available (e.g. because the user has explicitly downloaded a device tree using the "fdt" command), then provide it to the booted operating system as an EFI configuration table. Since x86 does not typically use device trees, we create weak symbols for efi_fdt_install() and efi_fdt_uninstall() to avoid dragging FDT support into all x86 UEFI binaries. Signed-off-by: Michael Brown --- src/image/efi_image.c | 28 +++++++++++++++ src/include/ipxe/efi/efi_fdt.h | 17 +++++++++ src/interface/efi/efi_fdt.c | 82 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 src/include/ipxe/efi/efi_fdt.h (limited to 'src/interface') diff --git a/src/image/efi_image.c b/src/image/efi_image.c index 82101d484..9261036da 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include #include #include @@ -122,6 +123,24 @@ static wchar_t * efi_image_cmdline ( struct image *image ) { return cmdline; } +/** + * Install EFI Flattened Device Tree table (when no FDT support is present) + * + * @ret rc Return status code + */ +__weak int efi_fdt_install ( void ) { + return 0; +} + +/** + * Uninstall EFI Flattened Device Tree table (when no FDT support is present) + * + * @ret rc Return status code + */ +__weak int efi_fdt_uninstall ( void ) { + return 0; +} + /** * Execute EFI image * @@ -187,6 +206,13 @@ static int efi_image_exec ( struct image *image ) { goto err_download_install; } + /* Install Flattened Device Tree table */ + if ( ( rc = efi_fdt_install() ) != 0 ) { + DBGC ( image, "EFIIMAGE %s could not install FDT: %s\n", + image->name, strerror ( rc ) ); + goto err_fdt_install; + } + /* Create device path for image */ path = efi_image_path ( exec, snpdev->path ); if ( ! path ) { @@ -313,6 +339,8 @@ static int efi_image_exec ( struct image *image ) { err_cmdline: free ( path ); err_image_path: + efi_fdt_uninstall(); + err_fdt_install: efi_download_uninstall ( snpdev->handle ); err_download_install: efi_pxe_uninstall ( snpdev->handle ); diff --git a/src/include/ipxe/efi/efi_fdt.h b/src/include/ipxe/efi/efi_fdt.h new file mode 100644 index 000000000..a9b7eac8b --- /dev/null +++ b/src/include/ipxe/efi/efi_fdt.h @@ -0,0 +1,17 @@ +#ifndef _IPXE_EFI_FDT_H +#define _IPXE_EFI_FDT_H + +/** @file + * + * EFI Flattened Device Tree + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include + +extern int efi_fdt_install ( void ); +extern int efi_fdt_uninstall ( void ); + +#endif /* _IPXE_EFI_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 71b788ae7..4a10236a0 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -24,9 +24,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include +#include +#include #include /** @file @@ -76,3 +79,82 @@ static void efi_fdt_init ( void ) { struct init_fn efi_fdt_init_fn __init_fn ( INIT_EARLY ) = { .initialise = efi_fdt_init, }; + +/** + * Determine length of EFI Flattened Device Tree + * + * @v data Configuration table data (presumed valid) + * @ret len Length of table + */ +static size_t efi_fdt_len ( const void *data ) { + const struct fdt_header *hdr = data; + + return be32_to_cpu ( hdr->totalsize ); +} + +/** EFI Flattened Device Tree table type */ +static struct efi_table efi_fdt_table = { + .guid = &efi_fdt_table_guid, + .len = efi_fdt_len, +}; + +/** EFI Flattened Device Tree table backup */ +static void *efi_fdt_backup; + +/** EFI Flattened Device Tree installed table */ +static struct fdt_header *efi_fdt_installed; + +/** + * Install EFI Flattened Device Tree table + * + * @ret rc Return status code + */ +int efi_fdt_install ( void ) { + int rc; + + /* Create device tree */ + if ( ( rc = fdt_create ( &efi_fdt_installed ) ) != 0 ) { + DBGC ( &efi_fdt, "EFI_FDT could not install: %s\n", + strerror ( rc ) ); + goto err_create; + } + + /* Install table */ + if ( ( rc = efi_install_table ( &efi_fdt_table, efi_fdt_installed, + &efi_fdt_backup ) ) != 0 ) { + DBGC ( &efi_fdt, "EFIFDT could not install: %s\n", + strerror ( rc ) ); + goto err_install; + } + + return 0; + + efi_uninstall_table ( &efi_fdt_table, &efi_fdt_backup ); + err_install: + fdt_remove ( efi_fdt_installed ); + err_create: + return rc; +} + +/** + * Uninstall EFI Flattened Device Tree table + * + * @ret rc Return status code + */ +int efi_fdt_uninstall ( void ) { + int rc; + + /* Uninstall table */ + if ( ( rc = efi_uninstall_table ( &efi_fdt_table, + &efi_fdt_backup ) ) != 0 ) { + DBGC ( &efi_fdt, "EFIFDT could not %sinstall: %s\n", + ( efi_fdt_backup ? "re" : "un" ), strerror ( rc ) ); + /* Leak memory: there is nothing else we can do */ + return rc; + } + + /* Remove table */ + fdt_remove ( efi_fdt_installed ); + + return 0; +} -- cgit v1.2.3-55-g7522 From 7adce3a13e74600ad0a356048c22649e77f86e12 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 28 Mar 2025 21:01:42 +0000 Subject: [efi] Add various well-known GUIDs encountered in WiFi boot Signed-off-by: Michael Brown --- src/include/ipxe/efi/Protocol/AdapterInformation.h | 257 ++++++++++++ src/include/ipxe/efi/Protocol/EapConfiguration.h | 155 +++++++ src/include/ipxe/efi/Protocol/Supplicant.h | 460 +++++++++++++++++++++ src/include/ipxe/efi/Protocol/WiFi2.h | 409 ++++++++++++++++++ src/include/ipxe/efi/efi.h | 4 + src/interface/efi/efi_guid.c | 36 ++ 6 files changed, 1321 insertions(+) create mode 100644 src/include/ipxe/efi/Protocol/AdapterInformation.h create mode 100644 src/include/ipxe/efi/Protocol/EapConfiguration.h create mode 100644 src/include/ipxe/efi/Protocol/Supplicant.h create mode 100644 src/include/ipxe/efi/Protocol/WiFi2.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Protocol/AdapterInformation.h b/src/include/ipxe/efi/Protocol/AdapterInformation.h new file mode 100644 index 000000000..ca7940729 --- /dev/null +++ b/src/include/ipxe/efi/Protocol/AdapterInformation.h @@ -0,0 +1,257 @@ +/** @file + EFI Adapter Information Protocol definition. + The EFI Adapter Information Protocol is used to dynamically and quickly discover + or set device information for an adapter. + + Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.4 + +**/ + +#ifndef __EFI_ADAPTER_INFORMATION_PROTOCOL_H__ +#define __EFI_ADAPTER_INFORMATION_PROTOCOL_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#define EFI_ADAPTER_INFORMATION_PROTOCOL_GUID \ + { \ + 0xE5DD1403, 0xD622, 0xC24E, {0x84, 0x88, 0xC7, 0x1B, 0x17, 0xF5, 0xE8, 0x02 } \ + } + +#define EFI_ADAPTER_INFO_MEDIA_STATE_GUID \ + { \ + 0xD7C74207, 0xA831, 0x4A26, {0xB1, 0xF5, 0xD1, 0x93, 0x06, 0x5C, 0xE8, 0xB6 } \ + } + +#define EFI_ADAPTER_INFO_NETWORK_BOOT_GUID \ + { \ + 0x1FBD2960, 0x4130, 0x41E5, {0x94, 0xAC, 0xD2, 0xCF, 0x03, 0x7F, 0xB3, 0x7C } \ + } + +#define EFI_ADAPTER_INFO_SAN_MAC_ADDRESS_GUID \ + { \ + 0x114da5ef, 0x2cf1, 0x4e12, {0x9b, 0xbb, 0xc4, 0x70, 0xb5, 0x52, 0x5, 0xd9 } \ + } + +#define EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT_GUID \ + { \ + 0x4bd56be3, 0x4975, 0x4d8a, {0xa0, 0xad, 0xc4, 0x91, 0x20, 0x4b, 0x5d, 0x4d} \ + } + +#define EFI_ADAPTER_INFO_MEDIA_TYPE_GUID \ + { \ + 0x8484472f, 0x71ec, 0x411a, { 0xb3, 0x9c, 0x62, 0xcd, 0x94, 0xd9, 0x91, 0x6e } \ + } + +typedef struct _EFI_ADAPTER_INFORMATION_PROTOCOL EFI_ADAPTER_INFORMATION_PROTOCOL; + +/// +/// EFI_ADAPTER_INFO_MEDIA_STATE +/// +typedef struct { + /// + /// Returns the current media state status. MediaState can have any of the following values: + /// EFI_SUCCESS: There is media attached to the network adapter. EFI_NOT_READY: This detects a bounced state. + /// There was media attached to the network adapter, but it was removed and reattached. EFI_NO_MEDIA: There is + /// not any media attached to the network. + /// + EFI_STATUS MediaState; +} EFI_ADAPTER_INFO_MEDIA_STATE; + +/// +/// EFI_ADAPTER_INFO_MEDIA_TYPE +/// +typedef struct { + /// + /// Indicates the current media type. MediaType can have any of the following values: + /// 1: Ethernet Network Adapter + /// 2: Ethernet Wireless Network Adapter + /// 3~255: Reserved + /// + UINT8 MediaType; +} EFI_ADAPTER_INFO_MEDIA_TYPE; + +/// +/// EFI_ADAPTER_INFO_NETWORK_BOOT +/// +typedef struct { + /// + /// TRUE if the adapter supports booting from iSCSI IPv4 targets. + /// + BOOLEAN iScsiIpv4BootCapablity; + /// + /// TRUE if the adapter supports booting from iSCSI IPv6 targets. + /// + BOOLEAN iScsiIpv6BootCapablity; + /// + /// TRUE if the adapter supports booting from FCoE targets. + /// + BOOLEAN FCoeBootCapablity; + /// + /// TRUE if the adapter supports an offload engine (such as TCP + /// Offload Engine (TOE)) for its iSCSI or FCoE boot operations. + /// + BOOLEAN OffloadCapability; + /// + /// TRUE if the adapter supports multipath I/O (MPIO) for its iSCSI + /// boot operations. + /// + BOOLEAN iScsiMpioCapability; + /// + /// TRUE if the adapter is currently configured to boot from iSCSI + /// IPv4 targets. + /// + BOOLEAN iScsiIpv4Boot; + /// + /// TRUE if the adapter is currently configured to boot from iSCSI + /// IPv6 targets. + /// + BOOLEAN iScsiIpv6Boot; + /// + /// TRUE if the adapter is currently configured to boot from FCoE targets. + /// + BOOLEAN FCoeBoot; +} EFI_ADAPTER_INFO_NETWORK_BOOT; + +/// +/// EFI_ADAPTER_INFO_SAN_MAC_ADDRESS +/// +typedef struct { + /// + /// Returns the SAN MAC address for the adapter.For adapters that support today's 802.3 ethernet + /// networking and Fibre-Channel Over Ethernet (FCOE), this conveys the FCOE SAN MAC address from the adapter. + /// + EFI_MAC_ADDRESS SanMacAddress; +} EFI_ADAPTER_INFO_SAN_MAC_ADDRESS; + +/// +/// EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT +/// +typedef struct { + /// + /// Returns capability of UNDI to support IPv6 traffic. + /// + BOOLEAN Ipv6Support; +} EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT; + +/** + Returns the current state information for the adapter. + + This function returns information of type InformationType from the adapter. + If an adapter does not support the requested informational type, then + EFI_UNSUPPORTED is returned. If an adapter does not contain Information for + the requested InformationType, it fills InformationBlockSize with 0 and + returns EFI_NOT_FOUND. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance. + @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock. + @param[out] InforamtionBlock The service returns a pointer to the buffer with the InformationBlock + structure which contains details about the data specific to InformationType. + @param[out] InforamtionBlockSize The driver returns the size of the InformationBlock in bytes. + + @retval EFI_SUCCESS The InformationType information was retrieved. + @retval EFI_UNSUPPORTED The InformationType is not known. + @retval EFI_NOT_FOUND Information is not available for the requested information type. + @retval EFI_DEVICE_ERROR The device reported an error. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InformationBlock is NULL. + @retval EFI_INVALID_PARAMETER InformationBlockSize is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_ADAPTER_INFO_GET_INFO)( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + IN EFI_GUID *InformationType, + OUT VOID **InformationBlock, + OUT UINTN *InformationBlockSize + ); + +/** + Sets state information for an adapter. + + This function sends information of type InformationType for an adapter. + If an adapter does not support the requested information type, then EFI_UNSUPPORTED + is returned. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance. + @param[in] InformationType A pointer to an EFI_GUID that defines the contents of InformationBlock. + @param[in] InforamtionBlock A pointer to the InformationBlock structure which contains details + about the data specific to InformationType. + @param[in] InforamtionBlockSize The size of the InformationBlock in bytes. + + @retval EFI_SUCCESS The information was received and interpreted successfully. + @retval EFI_UNSUPPORTED The InformationType is not known. + @retval EFI_DEVICE_ERROR The device reported an error. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InformationBlock is NULL. + @retval EFI_WRITE_PROTECTED The InformationType cannot be modified using EFI_ADAPTER_INFO_SET_INFO(). + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_ADAPTER_INFO_SET_INFO)( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + IN EFI_GUID *InformationType, + IN VOID *InformationBlock, + IN UINTN InformationBlockSize + ); + +/** + Get a list of supported information types for this instance of the protocol. + + This function returns a list of InformationType GUIDs that are supported on an + adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list is returned + in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer is returned in + InfoTypesBufferCount. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMATION_PROTOCOL instance. + @param[out] InfoTypesBuffer A pointer to the array of InformationType GUIDs that are supported + by This. + @param[out] InfoTypesBufferCount A pointer to the number of GUIDs present in InfoTypesBuffer. + + @retval EFI_SUCCESS The list of information type GUIDs that are supported on this adapter was + returned in InfoTypesBuffer. The number of information type GUIDs was + returned in InfoTypesBufferCount. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL. + @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL. + @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_ADAPTER_INFO_GET_SUPPORTED_TYPES)( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + OUT EFI_GUID **InfoTypesBuffer, + OUT UINTN *InfoTypesBufferCount + ); + +/// +/// EFI_ADAPTER_INFORMATION_PROTOCOL +/// The protocol for adapter provides the following services. +/// - Gets device state information from adapter. +/// - Sets device information for adapter. +/// - Gets a list of supported information types for this instance of the protocol. +/// +struct _EFI_ADAPTER_INFORMATION_PROTOCOL { + EFI_ADAPTER_INFO_GET_INFO GetInformation; + EFI_ADAPTER_INFO_SET_INFO SetInformation; + EFI_ADAPTER_INFO_GET_SUPPORTED_TYPES GetSupportedTypes; +}; + +extern EFI_GUID gEfiAdapterInformationProtocolGuid; + +extern EFI_GUID gEfiAdapterInfoMediaStateGuid; + +extern EFI_GUID gEfiAdapterInfoNetworkBootGuid; + +extern EFI_GUID gEfiAdapterInfoSanMacAddressGuid; + +extern EFI_GUID gEfiAdapterInfoUndiIpv6SupportGuid; + +#endif diff --git a/src/include/ipxe/efi/Protocol/EapConfiguration.h b/src/include/ipxe/efi/Protocol/EapConfiguration.h new file mode 100644 index 000000000..406e56d71 --- /dev/null +++ b/src/include/ipxe/efi/Protocol/EapConfiguration.h @@ -0,0 +1,155 @@ +/** @file + This file defines the EFI EAP Configuration protocol. + + Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.5 + +**/ + +#ifndef __EFI_EAP_CONFIGURATION_PROTOCOL_H__ +#define __EFI_EAP_CONFIGURATION_PROTOCOL_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +/// +/// EFI EAP Configuration protocol provides a way to set and get EAP configuration. +/// +#define EFI_EAP_CONFIGURATION_PROTOCOL_GUID \ + { \ + 0xe5b58dbb, 0x7688, 0x44b4, {0x97, 0xbf, 0x5f, 0x1d, 0x4b, 0x7c, 0xc8, 0xdb } \ + } + +typedef struct _EFI_EAP_CONFIGURATION_PROTOCOL EFI_EAP_CONFIGURATION_PROTOCOL; + +/// +/// Make sure it not conflict with any real EapTypeXXX +/// +#define EFI_EAP_TYPE_ATTRIBUTE 0 + +typedef enum { + /// + /// EFI_EAP_TYPE_ATTRIBUTE + /// + EfiEapConfigEapAuthMethod, + EfiEapConfigEapSupportedAuthMethod, + /// + /// EapTypeIdentity + /// + EfiEapConfigIdentityString, + /// + /// EapTypeEAPTLS/EapTypePEAP + /// + EfiEapConfigEapTlsCACert, + EfiEapConfigEapTlsClientCert, + EfiEapConfigEapTlsClientPrivateKeyFile, + EfiEapConfigEapTlsClientPrivateKeyFilePassword, // ASCII format, Volatile + EfiEapConfigEapTlsCipherSuite, + EfiEapConfigEapTlsSupportedCipherSuite, + /// + /// EapTypeMSChapV2 + /// + EfiEapConfigEapMSChapV2Password, // UNICODE format, Volatile + /// + /// EapTypePEAP + /// + EfiEapConfigEap2ndAuthMethod, + /// + /// More... + /// +} EFI_EAP_CONFIG_DATA_TYPE; + +/// +/// EFI_EAP_TYPE +/// +typedef UINT8 EFI_EAP_TYPE; +#define EFI_EAP_TYPE_ATTRIBUTE 0 +#define EFI_EAP_TYPE_IDENTITY 1 +#define EFI_EAP_TYPE_NOTIFICATION 2 +#define EFI_EAP_TYPE_NAK 3 +#define EFI_EAP_TYPE_MD5CHALLENGE 4 +#define EFI_EAP_TYPE_OTP 5 +#define EFI_EAP_TYPE_GTC 6 +#define EFI_EAP_TYPE_EAPTLS 13 +#define EFI_EAP_TYPE_EAPSIM 18 +#define EFI_EAP_TYPE_TTLS 21 +#define EFI_EAP_TYPE_PEAP 25 +#define EFI_EAP_TYPE_MSCHAPV2 26 +#define EFI_EAP_TYPE_EAP_EXTENSION 33 + +/** + Set EAP configuration data. + + The SetData() function sets EAP configuration to non-volatile storage or volatile + storage. + + @param[in] This Pointer to the EFI_EAP_CONFIGURATION_PROTOCOL instance. + @param[in] EapType EAP type. + @param[in] DataType Configuration data type. + @param[in] Data Pointer to configuration data. + @param[in] DataSize Total size of configuration data. + + @retval EFI_SUCCESS The EAP configuration data is set successfully. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + Data is NULL. + DataSize is 0. + @retval EFI_UNSUPPORTED The EapType or DataType is unsupported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_EAP_CONFIGURATION_SET_DATA)( + IN EFI_EAP_CONFIGURATION_PROTOCOL *This, + IN EFI_EAP_TYPE EapType, + IN EFI_EAP_CONFIG_DATA_TYPE DataType, + IN VOID *Data, + IN UINTN DataSize + ); + +/** + Get EAP configuration data. + + The GetData() function gets EAP configuration. + + @param[in] This Pointer to the EFI_EAP_CONFIGURATION_PROTOCOL instance. + @param[in] EapType EAP type. + @param[in] DataType Configuration data type. + @param[in, out] Data Pointer to configuration data. + @param[in, out] DataSize Total size of configuration data. On input, it means + the size of Data buffer. On output, it means the size + of copied Data buffer if EFI_SUCCESS, and means the + size of desired Data buffer if EFI_BUFFER_TOO_SMALL. + + @retval EFI_SUCCESS The EAP configuration data is got successfully. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + Data is NULL. + DataSize is NULL. + @retval EFI_UNSUPPORTED The EapType or DataType is unsupported. + @retval EFI_NOT_FOUND The EAP configuration data is not found. + @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold the buffer. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_EAP_CONFIGURATION_GET_DATA)( + IN EFI_EAP_CONFIGURATION_PROTOCOL *This, + IN EFI_EAP_TYPE EapType, + IN EFI_EAP_CONFIG_DATA_TYPE DataType, + IN OUT VOID *Data, + IN OUT UINTN *DataSize + ); + +/// +/// The EFI_EAP_CONFIGURATION_PROTOCOL +/// is designed to provide a way to set and get EAP configuration, such as Certificate, +/// private key file. +/// +struct _EFI_EAP_CONFIGURATION_PROTOCOL { + EFI_EAP_CONFIGURATION_SET_DATA SetData; + EFI_EAP_CONFIGURATION_GET_DATA GetData; +}; + +extern EFI_GUID gEfiEapConfigurationProtocolGuid; + +#endif diff --git a/src/include/ipxe/efi/Protocol/Supplicant.h b/src/include/ipxe/efi/Protocol/Supplicant.h new file mode 100644 index 000000000..8b3d75361 --- /dev/null +++ b/src/include/ipxe/efi/Protocol/Supplicant.h @@ -0,0 +1,460 @@ +/** @file + This file defines the EFI Supplicant Protocol. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.6 + +**/ + +#ifndef __EFI_SUPPLICANT_PROTOCOL_H__ +#define __EFI_SUPPLICANT_PROTOCOL_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#include + +/// +/// The EFI Supplicant Service Binding Protocol is used to locate EFI +/// Supplicant Protocol drivers to create and destroy child of the driver to +/// communicate with other host using Supplicant protocol. +/// +#define EFI_SUPPLICANT_SERVICE_BINDING_PROTOCOL_GUID \ + { \ + 0x45bcd98e, 0x59ad, 0x4174, { 0x95, 0x46, 0x34, 0x4a, 0x7, 0x48, 0x58, 0x98 } \ + } + +/// +/// The EFI Supplicant protocol provides services to process authentication and +/// data encryption/decryption for security management. +/// +#define EFI_SUPPLICANT_PROTOCOL_GUID \ + { \ + 0x54fcc43e, 0xaa89, 0x4333, { 0x9a, 0x85, 0xcd, 0xea, 0x24, 0x5, 0x1e, 0x9e } \ + } + +typedef struct _EFI_SUPPLICANT_PROTOCOL EFI_SUPPLICANT_PROTOCOL; + +/// +/// EFI_SUPPLICANT_CRYPT_MODE +/// +typedef enum { + // + // Encrypt data provided in the fragment buffers. + // + EfiSupplicantEncrypt, + // + // Decrypt data provided in the fragment buffers. + // + EfiSupplicantDecrypt, +} EFI_SUPPLICANT_CRYPT_MODE; + +/// +/// EFI_SUPPLICANT_DATA_TYPE +/// +typedef enum { + // + // Session Configuration + // + + // + // Current authentication type in use. The corresponding Data is of type + // EFI_80211_AKM_SUITE_SELECTOR. + // + EfiSupplicant80211AKMSuite, + // + // Group data encryption type in use. The corresponding Data is of type + // EFI_SUPPLICANT_CIPHER_SUITE_SELECTOR. + // + EfiSupplicant80211GroupDataCipherSuite, + // + // Pairwise encryption type in use. The corresponding Data is of type + // EFI_80211_CIPHER_SUITE_SELECTOR. + // + EfiSupplicant80211PairwiseCipherSuite, + // + // PSK password. The corresponding Data is a NULL-terminated ASCII string. + // + EfiSupplicant80211PskPassword, + // + // Target SSID name. The corresponding Data is of type EFI_80211_SSID. + // + EfiSupplicant80211TargetSSIDName, + // + // Station MAC address. The corresponding Data is of type + // EFI_80211_MAC_ADDRESS. + // + EfiSupplicant80211StationMac, + // + // Target SSID MAC address. The corresponding Data is 6 bytes MAC address. + // + EfiSupplicant80211TargetSSIDMac, + + // + // Session Information + // + + // + // 802.11 PTK. The corresponding Data is of type EFI_SUPPLICANT_KEY. + // + EfiSupplicant80211PTK, + // + // 802.11 GTK. The corresponding Data is of type EFI_SUPPLICANT_GTK_LIST. + // + EfiSupplicant80211GTK, + // + // Supplicant state. The corresponding Data is + // EFI_EAPOL_SUPPLICANT_PAE_STATE. + // + EfiSupplicantState, + // + // 802.11 link state. The corresponding Data is EFI_80211_LINK_STATE. + // + EfiSupplicant80211LinkState, + // + // Flag indicates key is refreshed. The corresponding Data is + // EFI_SUPPLICANT_KEY_REFRESH. + // + EfiSupplicantKeyRefresh, + + // + // Session Configuration + // + + // + // Supported authentication types. The corresponding Data is of type + // EFI_80211_AKM_SUITE_SELECTOR. + // + EfiSupplicant80211SupportedAKMSuites, + // + // Supported software encryption types provided by supplicant driver. The + // corresponding Data is of type EFI_80211_CIPHER_SUITE_SELECTOR. + // + EfiSupplicant80211SupportedSoftwareCipherSuites, + // + // Supported hardware encryption types provided by wireless UNDI driver. The + // corresponding Data is of type EFI_80211_CIPHER_SUITE_SELECTOR. + // + EfiSupplicant80211SupportedHardwareCipherSuites, + + // + // Session Information + // + + // + // 802.11 Integrity GTK. The corresponding Data is of type + // EFI_SUPPLICANT_GTK_LIST. + // + EfiSupplicant80211IGTK, + // + // 802.11 PMK. The corresponding Data is 32 bytes pairwise master key. + // + EfiSupplicant80211PMK, + EfiSupplicantDataTypeMaximum +} EFI_SUPPLICANT_DATA_TYPE; + +/// +/// EFI_80211_LINK_STATE +/// +typedef enum { + // + // Indicates initial start state, unauthenticated, unassociated. + // + Ieee80211UnauthenticatedUnassociated, + // + // Indicates authenticated, unassociated. + // + Ieee80211AuthenticatedUnassociated, + // + // Indicates authenticated and associated, but pending RSN authentication. + // + Ieee80211PendingRSNAuthentication, + // + // Indicates authenticated and associated. + // + Ieee80211AuthenticatedAssociated +} EFI_80211_LINK_STATE; + +/// +/// EFI_SUPPLICANT_KEY_TYPE (IEEE Std 802.11 Section 6.3.19.1.2) +/// +typedef enum { + Group, + Pairwise, + PeerKey, + IGTK +} EFI_SUPPLICANT_KEY_TYPE; + +/// +/// EFI_SUPPLICANT_KEY_DIRECTION (IEEE Std 802.11 Section 6.3.19.1.2) +/// +typedef enum { + // + // Indicates that the keys are being installed for the receive direction. + // + Receive, + // + // Indicates that the keys are being installed for the transmit direction. + // + Transmit, + // + // Indicates that the keys are being installed for both the receive and + // transmit directions. + // + Both +} EFI_SUPPLICANT_KEY_DIRECTION; + +/// +/// EFI_SUPPLICANT_KEY_REFRESH +/// +typedef struct { + // + // If TRUE, indicates GTK is just refreshed after a successful call to + // EFI_SUPPLICANT_PROTOCOL.BuildResponsePacket(). + // + BOOLEAN GTKRefresh; +} EFI_SUPPLICANT_KEY_REFRESH; + +#define EFI_MAX_KEY_LEN 64 + +/// +/// EFI_SUPPLICANT_KEY +/// +typedef struct { + // + // The key value. + // + UINT8 Key[EFI_MAX_KEY_LEN]; + // + // Length in bytes of the Key. Should be up to EFI_MAX_KEY_LEN. + // + UINT8 KeyLen; + // + // The key identifier. + // + UINT8 KeyId; + // + // Defines whether this key is a group key, pairwise key, PeerKey, or + // Integrity Group. + // + EFI_SUPPLICANT_KEY_TYPE KeyType; + // + // The value is set according to the KeyType. + // + EFI_80211_MAC_ADDRESS Addr; + // + // The Receive Sequence Count value. + // + UINT8 Rsc[8]; + // + // Length in bytes of the Rsc. Should be up to 8. + // + UINT8 RscLen; + // + // Indicates whether the key is configured by the Authenticator or + // Supplicant. The value true indicates Authenticator. + // + BOOLEAN IsAuthenticator; + // + // The cipher suite required for this association. + // + EFI_80211_SUITE_SELECTOR CipherSuite; + // + // Indicates the direction for which the keys are to be installed. + // + EFI_SUPPLICANT_KEY_DIRECTION Direction; +} EFI_SUPPLICANT_KEY; + +/// +/// EFI_SUPPLICANT_GTK_LIST +/// +typedef struct { + // + // Indicates the number of GTKs that are contained in GTKList. + // + UINT8 GTKCount; + // + // A variable-length array of GTKs of type EFI_SUPPLICANT_KEY. The number of + // entries is specified by GTKCount. + // + EFI_SUPPLICANT_KEY GTKList[1]; +} EFI_SUPPLICANT_GTK_LIST; + +/// +/// EFI_SUPPLICANT_FRAGMENT_DATA +/// +typedef struct { + // + // Length of data buffer in the fragment. + // + UINT32 FragmentLength; + // + // Pointer to the data buffer in the fragment. + // + VOID *FragmentBuffer; +} EFI_SUPPLICANT_FRAGMENT_DATA; + +/** + BuildResponsePacket() is called during STA and AP authentication is in + progress. Supplicant derives the PTK or session keys depend on type of + authentication is being employed. + + @param[in] This Pointer to the EFI_SUPPLICANT_PROTOCOL + instance. + @param[in] RequestBuffer Pointer to the most recently received EAPOL + packet. NULL means the supplicant need + initiate the EAP authentication session and + send EAPOL-Start message. + @param[in] RequestBufferSize + Packet size in bytes for the most recently + received EAPOL packet. 0 is only valid when + RequestBuffer is NULL. + @param[out] Buffer Pointer to the buffer to hold the built + packet. + @param[in, out] BufferSize Pointer to the buffer size in bytes. On + input, it is the buffer size provided by the + caller. On output, it is the buffer size in + fact needed to contain the packet. + + @retval EFI_SUCCESS The required EAPOL packet is built + successfully. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + RequestBuffer is NULL, but RequestSize is + NOT 0. + RequestBufferSize is 0. + Buffer is NULL, but RequestBuffer is NOT 0. + BufferSize is NULL. + @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response + packet. + @retval EFI_NOT_READY Current EAPOL session state is NOT ready to + build ResponsePacket. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SUPPLICANT_BUILD_RESPONSE_PACKET)( + IN EFI_SUPPLICANT_PROTOCOL *This, + IN UINT8 *RequestBuffer OPTIONAL, + IN UINTN RequestBufferSize OPTIONAL, + OUT UINT8 *Buffer, + IN OUT UINTN *BufferSize + ); + +/** + ProcessPacket() is called to Supplicant driver to encrypt or decrypt the data + depending type of authentication type. + + @param[in] This Pointer to the EFI_SUPPLICANT_PROTOCOL + instance. + @param[in, out] FragmentTable Pointer to a list of fragment. The caller + will take responsible to handle the original + FragmentTable while it may be reallocated in + Supplicant driver. + @param[in] FragmentCount Number of fragment. + @param[in] CryptMode Crypt mode. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + FragmentTable is NULL. + FragmentCount is NULL. + CryptMode is invalid. + @retval EFI_NOT_READY Current supplicant state is NOT Authenticated. + @retval EFI_ABORTED Something wrong decryption the message. + @retval EFI_UNSUPPORTED This API is not supported. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SUPPLICANT_PROCESS_PACKET)( + IN EFI_SUPPLICANT_PROTOCOL *This, + IN OUT EFI_SUPPLICANT_FRAGMENT_DATA **FragmentTable, + IN UINT32 *FragmentCount, + IN EFI_SUPPLICANT_CRYPT_MODE CryptMode + ); + +/** + Set Supplicant configuration data. + + @param[in] This Pointer to the EFI_SUPPLICANT_PROTOCOL + instance. + @param[in] DataType The type of data. + @param[in] Data Pointer to the buffer to hold the data. + @param[in] DataSize Pointer to the buffer size in bytes. + + @retval EFI_SUCCESS The Supplicant configuration data is set + successfully. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + Data is NULL. + DataSize is 0. + @retval EFI_UNSUPPORTED The DataType is unsupported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SUPPLICANT_SET_DATA)( + IN EFI_SUPPLICANT_PROTOCOL *This, + IN EFI_SUPPLICANT_DATA_TYPE DataType, + IN VOID *Data, + IN UINTN DataSize + ); + +/** + Get Supplicant configuration data. + + @param[in] This Pointer to the EFI_SUPPLICANT_PROTOCOL + instance. + @param[in] DataType The type of data. + @param[out] Data Pointer to the buffer to hold the data. + Ignored if DataSize is 0. + @param[in, out] DataSize Pointer to the buffer size in bytes. On + input, it is the buffer size provided by the + caller. On output, it is the buffer size in + fact needed to contain the packet. + + @retval EFI_SUCCESS The Supplicant configuration data is got + successfully. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + This is NULL. + DataSize is NULL. + Data is NULL if *DataSize is not zero. + @retval EFI_UNSUPPORTED The DataType is unsupported. + @retval EFI_NOT_FOUND The Supplicant configuration data is not + found. + @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the + specified configuration data and the required + size is returned in DataSize. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SUPPLICANT_GET_DATA)( + IN EFI_SUPPLICANT_PROTOCOL *This, + IN EFI_SUPPLICANT_DATA_TYPE DataType, + OUT UINT8 *Data OPTIONAL, + IN OUT UINTN *DataSize + ); + +/// +/// The EFI_SUPPLICANT_PROTOCOL is designed to provide unified place for WIFI +/// and EAP security management. Both PSK authentication and 802.1X EAP +/// authentication can be managed via this protocol and driver or application +/// as a consumer can only focus on about packet transmitting or receiving. +/// +struct _EFI_SUPPLICANT_PROTOCOL { + EFI_SUPPLICANT_BUILD_RESPONSE_PACKET BuildResponsePacket; + EFI_SUPPLICANT_PROCESS_PACKET ProcessPacket; + EFI_SUPPLICANT_SET_DATA SetData; + EFI_SUPPLICANT_GET_DATA GetData; +}; + +extern EFI_GUID gEfiSupplicantServiceBindingProtocolGuid; +extern EFI_GUID gEfiSupplicantProtocolGuid; + +#endif diff --git a/src/include/ipxe/efi/Protocol/WiFi2.h b/src/include/ipxe/efi/Protocol/WiFi2.h new file mode 100644 index 000000000..1d9bc5f2e --- /dev/null +++ b/src/include/ipxe/efi/Protocol/WiFi2.h @@ -0,0 +1,409 @@ +/** @file + This file defines the EFI Wireless MAC Connection II Protocol. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.6 + +**/ + +#ifndef __EFI_WIFI2_PROTOCOL_H__ +#define __EFI_WIFI2_PROTOCOL_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#define EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL_GUID \ + { \ + 0x1b0fb9bf, 0x699d, 0x4fdd, { 0xa7, 0xc3, 0x25, 0x46, 0x68, 0x1b, 0xf6, 0x3b } \ + } + +typedef struct _EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL; + +/// +/// EFI_80211_BSS_TYPE +/// +typedef enum { + IeeeInfrastructureBSS, + IeeeIndependentBSS, + IeeeMeshBSS, + IeeeAnyBss +} EFI_80211_BSS_TYPE; + +/// +/// EFI_80211_CONNECT_NETWORK_RESULT_CODE +/// +typedef enum { + // + // The connection establishment operation finished successfully. + // + ConnectSuccess, + // + // The connection was refused by the Network. + // + ConnectRefused, + // + // The connection establishment operation failed (i.e, Network is not + // detected). + // + ConnectFailed, + // + // The connection establishment operation was terminated on timeout. + // + ConnectFailureTimeout, + // + // The connection establishment operation failed on other reason. + // + ConnectFailedReasonUnspecified +} EFI_80211_CONNECT_NETWORK_RESULT_CODE; + +/// +/// EFI_80211_MAC_ADDRESS +/// +typedef struct { + UINT8 Addr[6]; +} EFI_80211_MAC_ADDRESS; + +#define EFI_MAX_SSID_LEN 32 + +/// +/// EFI_80211_SSID +/// +typedef struct { + // + // Length in bytes of the SSId. If zero, ignore SSId field. + // + UINT8 SSIdLen; + // + // Specifies the service set identifier. + // + UINT8 SSId[EFI_MAX_SSID_LEN]; +} EFI_80211_SSID; + +/// +/// EFI_80211_GET_NETWORKS_DATA +/// +typedef struct { + // + // The number of EFI_80211_SSID in SSIDList. If zero, SSIDList should be + // ignored. + // + UINT32 NumOfSSID; + // + // The SSIDList is a pointer to an array of EFI_80211_SSID instances. The + // number of entries is specified by NumOfSSID. The array should only include + // SSIDs of hidden networks. It is suggested that the caller inputs less than + // 10 elements in the SSIDList. It is the caller's responsibility to free + // this buffer. + // + EFI_80211_SSID SSIDList[1]; +} EFI_80211_GET_NETWORKS_DATA; + +/// +/// EFI_80211_SUITE_SELECTOR +/// +typedef struct { + // + // Organization Unique Identifier, as defined in IEEE 802.11 standard, + // usually set to 00-0F-AC. + // + UINT8 Oui[3]; + // + // Suites types, as defined in IEEE 802.11 standard. + // + UINT8 SuiteType; +} EFI_80211_SUITE_SELECTOR; + +/// +/// EFI_80211_AKM_SUITE_SELECTOR +/// +typedef struct { + // + // Indicates the number of AKM suite selectors that are contained in + // AKMSuiteList. If zero, the AKMSuiteList is ignored. + // + UINT16 AKMSuiteCount; + // + // A variable-length array of AKM suites, as defined in IEEE 802.11 standard, + // Table 8-101. The number of entries is specified by AKMSuiteCount. + // + EFI_80211_SUITE_SELECTOR AKMSuiteList[1]; +} EFI_80211_AKM_SUITE_SELECTOR; + +/// +/// EFI_80211_CIPHER_SUITE_SELECTOR +/// +typedef struct { + // + // Indicates the number of cipher suites that are contained in + // CipherSuiteList. If zero, the CipherSuiteList is ignored. + // + UINT16 CipherSuiteCount; + // + // A variable-length array of cipher suites, as defined in IEEE 802.11 + // standard, Table 8-99. The number of entries is specified by + // CipherSuiteCount. + // + EFI_80211_SUITE_SELECTOR CipherSuiteList[1]; +} EFI_80211_CIPHER_SUITE_SELECTOR; + +/// +/// EFI_80211_NETWORK +/// +typedef struct { + // + // Specifies the type of the BSS. + // + EFI_80211_BSS_TYPE BSSType; + // + // Specifies the SSID of the BSS. + // + EFI_80211_SSID SSId; + // + // Pointer to the AKM suites supported in the wireless network. + // + EFI_80211_AKM_SUITE_SELECTOR *AKMSuite; + // + // Pointer to the cipher suites supported in the wireless network. + // + EFI_80211_CIPHER_SUITE_SELECTOR *CipherSuite; +} EFI_80211_NETWORK; + +/// +/// EFI_80211_NETWORK_DESCRIPTION +/// +typedef struct { + // + // Specifies the found wireless network. + // + EFI_80211_NETWORK Network; + // + // Indicates the network quality as a value between 0 to 100, where 100 + // indicates the highest network quality. + // + UINT8 NetworkQuality; +} EFI_80211_NETWORK_DESCRIPTION; + +/// +/// EFI_80211_GET_NETWORKS_RESULT +/// +typedef struct { + // + // The number of EFI_80211_NETWORK_DESCRIPTION in NetworkDesc. If zero, + // NetworkDesc should be ignored. + // + UINT8 NumOfNetworkDesc; + // + // The NetworkDesc is a pointer to an array of EFI_80211_NETWORK_DESCRIPTION + // instances. It is caller's responsibility to free this buffer. + // + EFI_80211_NETWORK_DESCRIPTION NetworkDesc[1]; +} EFI_80211_GET_NETWORKS_RESULT; + +/// +/// EFI_80211_GET_NETWORKS_TOKEN +/// +typedef struct { + // + // If the status code returned by GetNetworks() is EFI_SUCCESS, then this + // Event will be signaled after the Status field is updated by the EFI + // Wireless MAC Connection Protocol II driver. The type of Event must be + // EFI_NOTIFY_SIGNAL. + // + EFI_EVENT Event; + // + // Will be set to one of the following values: + // EFI_SUCCESS: The operation completed successfully. + // EFI_NOT_FOUND: Failed to find available wireless networks. + // EFI_DEVICE_ERROR: An unexpected network or system error occurred. + // EFI_ACCESS_DENIED: The operation is not completed due to some underlying + // hardware or software state. + // EFI_NOT_READY: The operation is started but not yet completed. + // + EFI_STATUS Status; + // + // Pointer to the input data for getting networks. + // + EFI_80211_GET_NETWORKS_DATA *Data; + // + // Indicates the scan result. It is caller's responsibility to free this + // buffer. + // + EFI_80211_GET_NETWORKS_RESULT *Result; +} EFI_80211_GET_NETWORKS_TOKEN; + +/// +/// EFI_80211_CONNECT_NETWORK_DATA +/// +typedef struct { + // + // Specifies the wireless network to connect to. + // + EFI_80211_NETWORK *Network; + // + // Specifies a time limit in seconds that is optionally present, after which + // the connection establishment procedure is terminated by the UNDI driver. + // This is an optional parameter and may be 0. Values of 5 seconds or higher + // are recommended. + // + UINT32 FailureTimeout; +} EFI_80211_CONNECT_NETWORK_DATA; + +/// +/// EFI_80211_CONNECT_NETWORK_TOKEN +/// +typedef struct { + // + // If the status code returned by ConnectNetwork() is EFI_SUCCESS, then this + // Event will be signaled after the Status field is updated by the EFI + // Wireless MAC Connection Protocol II driver. The type of Event must be + // EFI_NOTIFY_SIGNAL. + // + EFI_EVENT Event; + // + // Will be set to one of the following values: + // EFI_SUCCESS: The operation completed successfully. + // EFI_DEVICE_ERROR: An unexpected network or system error occurred. + // EFI_ACCESS_DENIED: The operation is not completed due to some underlying + // hardware or software state. + // EFI_NOT_READY: The operation is started but not yet completed. + // + EFI_STATUS Status; + // + // Pointer to the connection data. + // + EFI_80211_CONNECT_NETWORK_DATA *Data; + // + // Indicates the connection state. + // + EFI_80211_CONNECT_NETWORK_RESULT_CODE ResultCode; +} EFI_80211_CONNECT_NETWORK_TOKEN; + +/// +/// EFI_80211_DISCONNECT_NETWORK_TOKEN +/// +typedef struct { + // + // If the status code returned by DisconnectNetwork() is EFI_SUCCESS, then + // this Event will be signaled after the Status field is updated by the EFI + // Wireless MAC Connection Protocol II driver. The type of Event must be + // EFI_NOTIFY_SIGNAL. + // + EFI_EVENT Event; + // + // Will be set to one of the following values: + // EFI_SUCCESS: The operation completed successfully + // EFI_DEVICE_ERROR: An unexpected network or system error occurred. + // EFI_ACCESS_DENIED: The operation is not completed due to some underlying + // hardware or software state. + // + EFI_STATUS Status; +} EFI_80211_DISCONNECT_NETWORK_TOKEN; + +/** + Request a survey of potential wireless networks that administrator can later + elect to try to join. + + @param[in] This Pointer to the + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL + instance. + @param[in] Token Pointer to the token for getting wireless + network. + + @retval EFI_SUCCESS The operation started, and an event will + eventually be raised for the caller. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + This is NULL. + Token is NULL. + @retval EFI_UNSUPPORTED One or more of the input parameters is not + supported by this implementation. + @retval EFI_ALREADY_STARTED The operation of getting wireless network is + already started. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be + allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_WIRELESS_MAC_CONNECTION_II_GET_NETWORKS)( + IN EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *This, + IN EFI_80211_GET_NETWORKS_TOKEN *Token + ); + +/** + Connect a wireless network specified by a particular SSID, BSS type and + Security type. + + @param[in] This Pointer to the + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL + instance. + @param[in] Token Pointer to the token for connecting wireless + network. + + @retval EFI_SUCCESS The operation started successfully. Results + will be notified eventually. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + This is NULL. + Token is NULL. + @retval EFI_UNSUPPORTED One or more of the input parameters are not + supported by this implementation. + @retval EFI_ALREADY_STARTED The connection process is already started. + @retval EFI_NOT_FOUND The specified wireless network is not found. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be + allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_WIRELESS_MAC_CONNECTION_II_CONNECT_NETWORK)( + IN EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *This, + IN EFI_80211_CONNECT_NETWORK_TOKEN *Token + ); + +/** + Request a disconnection with current connected wireless network. + + @param[in] This Pointer to the + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL + instance. + @param[in] Token Pointer to the token for disconnecting + wireless network. + + @retval EFI_SUCCESS The operation started successfully. Results + will be notified eventually. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is + TRUE: + This is NULL. + Token is NULL. + @retval EFI_UNSUPPORTED One or more of the input parameters are not + supported by this implementation. + @retval EFI_NOT_FOUND Not connected to a wireless network. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be + allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_WIRELESS_MAC_CONNECTION_II_DISCONNECT_NETWORK)( + IN EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *This, + IN EFI_80211_DISCONNECT_NETWORK_TOKEN *Token + ); + +/// +/// The EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL provides network management +/// service interfaces for 802.11 network stack. It is used by network +/// applications (and drivers) to establish wireless connection with a wireless +/// network. +/// +struct _EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL { + EFI_WIRELESS_MAC_CONNECTION_II_GET_NETWORKS GetNetworks; + EFI_WIRELESS_MAC_CONNECTION_II_CONNECT_NETWORK ConnectNetwork; + EFI_WIRELESS_MAC_CONNECTION_II_DISCONNECT_NETWORK DisconnectNetwork; +}; + +extern EFI_GUID gEfiWiFi2ProtocolGuid; + +#endif diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 8347d8249..29c292f36 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -172,6 +172,7 @@ struct efi_config_table { extern EFI_GUID efi_absolute_pointer_protocol_guid; extern EFI_GUID efi_acpi_table_protocol_guid; +extern EFI_GUID efi_adapter_information_protocol_guid; extern EFI_GUID efi_apple_net_boot_protocol_guid; extern EFI_GUID efi_arp_protocol_guid; extern EFI_GUID efi_arp_service_binding_protocol_guid; @@ -192,6 +193,7 @@ extern EFI_GUID efi_dns4_service_binding_protocol_guid; extern EFI_GUID efi_dns6_protocol_guid; extern EFI_GUID efi_dns6_service_binding_protocol_guid; extern EFI_GUID efi_driver_binding_protocol_guid; +extern EFI_GUID efi_eap_configuration_protocol_guid; extern EFI_GUID efi_graphics_output_protocol_guid; extern EFI_GUID efi_hii_config_access_protocol_guid; extern EFI_GUID efi_hii_font_protocol_guid; @@ -228,6 +230,7 @@ extern EFI_GUID efi_simple_pointer_protocol_guid; extern EFI_GUID efi_simple_text_input_protocol_guid; extern EFI_GUID efi_simple_text_input_ex_protocol_guid; extern EFI_GUID efi_simple_text_output_protocol_guid; +extern EFI_GUID efi_supplicant_protocol_guid; extern EFI_GUID efi_tcg_protocol_guid; extern EFI_GUID efi_tcg2_protocol_guid; extern EFI_GUID efi_tcp4_protocol_guid; @@ -245,6 +248,7 @@ extern EFI_GUID efi_usb_hc_protocol_guid; extern EFI_GUID efi_usb2_hc_protocol_guid; extern EFI_GUID efi_usb_io_protocol_guid; extern EFI_GUID efi_vlan_config_protocol_guid; +extern EFI_GUID efi_wifi2_protocol_guid; extern EFI_GUID efi_acpi_10_table_guid; extern EFI_GUID efi_acpi_20_table_guid; diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 1b16dd1b7..84c517443 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -72,6 +74,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -84,6 +87,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -112,6 +116,10 @@ EFI_GUID efi_absolute_pointer_protocol_guid EFI_GUID efi_acpi_table_protocol_guid = EFI_ACPI_TABLE_PROTOCOL_GUID; +/** Adapter information protocol GUID */ +EFI_GUID efi_adapter_information_protocol_guid + = EFI_ADAPTER_INFORMATION_PROTOCOL_GUID; + /** Apple NetBoot protocol GUID */ EFI_GUID efi_apple_net_boot_protocol_guid = EFI_APPLE_NET_BOOT_PROTOCOL_GUID; @@ -192,6 +200,10 @@ EFI_GUID efi_dns6_service_binding_protocol_guid EFI_GUID efi_driver_binding_protocol_guid = EFI_DRIVER_BINDING_PROTOCOL_GUID; +/** EAP configuration protocol GUID */ +EFI_GUID efi_eap_configuration_protocol_guid + = EFI_EAP_CONFIGURATION_PROTOCOL_GUID; + /** Graphics output protocol GUID */ EFI_GUID efi_graphics_output_protocol_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; @@ -336,6 +348,10 @@ EFI_GUID efi_simple_text_input_ex_protocol_guid EFI_GUID efi_simple_text_output_protocol_guid = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID; +/** Supplicant protocol GUID */ +EFI_GUID efi_supplicant_protocol_guid + = EFI_SUPPLICANT_PROTOCOL_GUID; + /** TCG protocol GUID */ EFI_GUID efi_tcg_protocol_guid = EFI_TCG_PROTOCOL_GUID; @@ -404,6 +420,10 @@ EFI_GUID efi_usb_io_protocol_guid EFI_GUID efi_vlan_config_protocol_guid = EFI_VLAN_CONFIG_PROTOCOL_GUID; +/** WiFi 2 protocol GUID */ +EFI_GUID efi_wifi2_protocol_guid + = EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL_GUID; + /** ACPI 1.0 table GUID */ EFI_GUID efi_acpi_10_table_guid = ACPI_10_TABLE_GUID; @@ -469,6 +489,12 @@ static EFI_GUID efi_vlan_config_dxe_guid = { { 0xa8, 0xf4, 0x08, 0x51, 0x9b, 0xc4, 0x39, 0xdf } }; +/** WiFiConnectionMgrDxe module GUID */ +static EFI_GUID efi_wifi_connection_mgr_dxe_guid = { + 0x99b7c019, 0x4789, 0x4829, + { 0xa7, 0xbd, 0x0d, 0x4b, 0xaa, 0x62, 0x28, 0x72 } +}; + /** A well-known GUID */ struct efi_well_known_guid { /** GUID */ @@ -487,6 +513,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Acpi20" }, { &efi_acpi_table_protocol_guid, "AcpiTable" }, + { &efi_adapter_information_protocol_guid, + "AdapterInfo" }, { &efi_apple_net_boot_protocol_guid, "AppleNetBoot" }, { &efi_arp_protocol_guid, @@ -529,6 +557,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Dns6" }, { &efi_dns6_service_binding_protocol_guid, "Dns6Sb" }, + { &efi_eap_configuration_protocol_guid, + "EapConfig" }, { &efi_fdt_table_guid, "Fdt" }, { &efi_global_variable, @@ -615,6 +645,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Smbios" }, { &efi_smbios3_table_guid, "Smbios3" }, + { &efi_supplicant_protocol_guid, + "Supplicant" }, { &efi_tcg_protocol_guid, "Tcg" }, { &efi_tcg2_protocol_guid, @@ -655,6 +687,10 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "VlanConfig" }, { &efi_vlan_config_dxe_guid, "VlanConfigDxe" }, + { &efi_wifi2_protocol_guid, + "Wifi2" }, + { &efi_wifi_connection_mgr_dxe_guid, + "WiFiConnectionMgrDxe" }, }; /** -- cgit v1.2.3-55-g7522 From ea5762d9d0ebe61bf58f7b8c019bf06c14a693d8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 18:41:01 +0000 Subject: [efi] Return success from Stop() if driver is already stopped Return success if asked to stop driving a device that we are not currently driving. This avoids propagating spurious errors to an external caller of DisconnectController(). Signed-off-by: Michael Brown --- src/interface/efi/efi_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 56918deba..5e8d253f0 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -307,7 +307,7 @@ efi_driver_stop ( EFI_DRIVER_BINDING_PROTOCOL *driver __unused, if ( ! efidev ) { DBGCP ( device, "EFIDRV %s is not started\n", efi_handle_name ( device ) ); - return EFI_DEVICE_ERROR; + return 0; } /* Raise TPL */ -- cgit v1.2.3-55-g7522 From be33224754e3e03b11a95a320db08c0cdf047013 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 15:11:57 +0000 Subject: [efi] Show all drivers claiming support for a handle in debug messages UEFI assumes in several places that an image installs only a single driver binding protocol instance, and that this is installed on the image handle itself. We therefore provide a single driver binding protocol instance, which delegates to the various internal drivers (for EFI_PCI_IO_PROTOCOL, EFI_USB_IO_PROTOCOL, etc) as appropriate. The debug messages produced by our Supported() method can end up slightly misleading, since they will report only the first internal driver that claims support for a device. In the common case of the all-drivers build, there may be multiple drivers that claim support for the same handle: for example, the PCI, NII, SNP, and MNP drivers are all likely to initially find the protocols that they need on the same device handle. Report all internal drivers that claim support for a device, to avoid confusing debug messages. Signed-off-by: Michael Brown --- src/interface/efi/efi_driver.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 5e8d253f0..9f2f08846 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -167,6 +167,7 @@ static EFI_STATUS EFIAPI efi_driver_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver __unused, EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *child ) { struct efi_driver *efidrv; + unsigned int count; int rc; DBGCP ( device, "EFIDRV %s DRIVER_SUPPORTED", @@ -182,18 +183,24 @@ efi_driver_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver __unused, return EFI_ALREADY_STARTED; } - /* Look for a driver claiming to support this device */ + /* Count drivers claiming to support this device */ + count = 0; for_each_table_entry ( efidrv, EFI_DRIVERS ) { if ( ( rc = efidrv->supported ( device ) ) == 0 ) { DBGC ( device, "EFIDRV %s has driver \"%s\"\n", efi_handle_name ( device ), efidrv->name ); - return 0; + count++; } } - DBGCP ( device, "EFIDRV %s has no driver\n", - efi_handle_name ( device ) ); - return EFI_UNSUPPORTED; + /* Check that we have at least one driver */ + if ( ! count ) { + DBGCP ( device, "EFIDRV %s has no driver\n", + efi_handle_name ( device ) ); + return EFI_UNSUPPORTED; + } + + return 0; } /** -- cgit v1.2.3-55-g7522 From 7737fec5c63077aa8407f559dea0e3666d9abf70 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 15:28:19 +0000 Subject: [efi] Define an attachment priority order for EFI drivers Define an ordering for internal EFI drivers on the basis of how close the driver is to the hardware, and attempt to start drivers in this order. Signed-off-by: Michael Brown --- src/drivers/net/efi/mnp.c | 2 +- src/drivers/net/efi/snp.c | 4 ++-- src/drivers/net/efi/snponly.c | 6 +++--- src/drivers/usb/usbio.c | 2 +- src/include/ipxe/efi/efi_driver.h | 6 ++++-- src/interface/efi/efi_pci.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/mnp.c b/src/drivers/net/efi/mnp.c index 33218fb10..3c839d968 100644 --- a/src/drivers/net/efi/mnp.c +++ b/src/drivers/net/efi/mnp.c @@ -48,7 +48,7 @@ static int mnp_supported ( EFI_HANDLE device ) { } /** EFI MNP driver */ -struct efi_driver mnp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver mnp_driver __efi_driver ( EFI_DRIVER_MNP ) = { .name = "MNP", .supported = mnp_supported, .start = mnpnet_start, diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index cac8b38e2..58b5ad546 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -57,7 +57,7 @@ static int nii_supported ( EFI_HANDLE device ) { } /** EFI SNP driver */ -struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNP", .supported = snp_supported, .start = snpnet_start, @@ -65,7 +65,7 @@ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { }; /** EFI NII driver */ -struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NII", .supported = nii_supported, .start = nii_start, diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 80ddfe00d..e40451885 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -207,7 +207,7 @@ static int mnponly_supported ( EFI_HANDLE device ) { } /** EFI SNP chainloading-device-only driver */ -struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNPONLY", .supported = snponly_supported, .start = snpnet_start, @@ -215,7 +215,7 @@ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { }; /** EFI NII chainloading-device-only driver */ -struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NIIONLY", .supported = niionly_supported, .start = nii_start, @@ -223,7 +223,7 @@ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { }; /** EFI MNP chainloading-device-only driver */ -struct efi_driver mnponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver mnponly_driver __efi_driver ( EFI_DRIVER_MNP ) = { .name = "MNPONLY", .supported = mnponly_supported, .start = mnpnet_start, diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index 73151c536..e4dca7e87 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1649,7 +1649,7 @@ static void usbio_stop ( struct efi_device *efidev ) { } /** EFI USB I/O driver */ -struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "USBIO", .supported = usbio_supported, .start = usbio_start, diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 7b64e1e0b..e07bfd49d 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -62,8 +62,10 @@ struct efi_driver { #define __efi_driver( order ) __table_entry ( EFI_DRIVERS, order ) #define EFI_DRIVER_EARLY 01 /**< Early drivers */ -#define EFI_DRIVER_NORMAL 02 /**< Normal drivers */ -#define EFI_DRIVER_LATE 03 /**< Late drivers */ +#define EFI_DRIVER_HARDWARE 02 /**< Hardware drivers */ +#define EFI_DRIVER_NII 03 /**< NII protocol drivers */ +#define EFI_DRIVER_SNP 04 /**< SNP protocol drivers */ +#define EFI_DRIVER_MNP 05 /**< MNP protocol drivers */ /** * Set EFI driver-private data diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 0662302d2..6bdc2d575 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -914,7 +914,7 @@ static void efipci_stop ( struct efi_device *efidev ) { } /** EFI PCI driver */ -struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_NORMAL ) = { +struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "PCI", .supported = efipci_supported, .start = efipci_start, -- cgit v1.2.3-55-g7522 From 4bcaa3d380d2110445ac6501bf382d81a2ea49d0 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 14:57:16 +0000 Subject: [efi] Disconnect existing drivers on a per-protocol basis UEFI does not provide a direct method to disconnect the existing driver of a specific protocol from a handle. We currently use DisconnectController() to remove all drivers from a handle that we want to drive ourselves, and then rely on recursion in the call to ConnectController() to reconnect any drivers that did not need to be disconnected in the first place. Experience shows that OEMs tend not to ever test the disconnection code paths in their UEFI drivers, and it is common to find drivers that refuse to disconnect, fail to close opened handles, fail to function correctly after reconnection, or lock up the entire system. Implement a more selective form of disconnection, in which we use OpenProtocolInformation() to identify the driver associated with a specific protocol, and then disconnect only that driver. Perform disconnections in reverse order of attachment priority, since this is the order likely to minimise the number of cascaded implicit disconnections. This allows our MNP driver to avoid performing any disconnections at all, since it does not require exclusive access to the MNP protocol. It also avoids performing unnecessary disconnections and reconnections of unrelated drivers such as the "UEFI WiFi Connection Manager" that attaches to wireless network interfaces in order to manage wireless network associations. Signed-off-by: Michael Brown --- src/drivers/net/efi/snp.c | 2 + src/drivers/net/efi/snponly.c | 2 + src/drivers/usb/usbio.c | 1 + src/include/ipxe/efi/efi_driver.h | 2 + src/interface/efi/efi_driver.c | 85 +++++++++++++++++++++++++++++++++++---- src/interface/efi/efi_pci.c | 1 + 6 files changed, 86 insertions(+), 7 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index 58b5ad546..7c4123677 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -59,6 +59,7 @@ static int nii_supported ( EFI_HANDLE device ) { /** EFI SNP driver */ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNP", + .exclude = &efi_simple_network_protocol_guid, .supported = snp_supported, .start = snpnet_start, .stop = snpnet_stop, @@ -67,6 +68,7 @@ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII driver */ struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NII", + .exclude = &efi_nii31_protocol_guid, .supported = nii_supported, .start = nii_start, .stop = nii_stop, diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index e40451885..267572e34 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -209,6 +209,7 @@ static int mnponly_supported ( EFI_HANDLE device ) { /** EFI SNP chainloading-device-only driver */ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNPONLY", + .exclude = &efi_simple_network_protocol_guid, .supported = snponly_supported, .start = snpnet_start, .stop = snpnet_stop, @@ -217,6 +218,7 @@ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII chainloading-device-only driver */ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NIIONLY", + .exclude = &efi_nii31_protocol_guid, .supported = niionly_supported, .start = nii_start, .stop = nii_stop, diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index e4dca7e87..991b290ad 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1651,6 +1651,7 @@ static void usbio_stop ( struct efi_device *efidev ) { /** EFI USB I/O driver */ struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "USBIO", + .exclude = &efi_usb_io_protocol_guid, .supported = usbio_supported, .start = usbio_start, .stop = usbio_stop, diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index e07bfd49d..4c2148919 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -33,6 +33,8 @@ struct efi_device { struct efi_driver { /** Name */ const char *name; + /** Protocol to which exclusive access is required, if any */ + EFI_GUID *exclude; /** * Check if driver supports device * diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 9f2f08846..8c5e00bfb 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -441,6 +441,68 @@ void efi_driver_uninstall ( void ) { &efi_component_name2_protocol_guid, &efi_wtf, NULL ); } +/** + * Try to disconnect an existing EFI driver + * + * @v device EFI device + * @v protocol Protocol GUID + * @ret rc Return status code + */ +static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener; + EFI_HANDLE driver; + UINTN count; + unsigned int i; + EFI_STATUS efirc; + int rc; + + /* Retrieve list of openers */ + if ( ( efirc = bs->OpenProtocolInformation ( device, protocol, &openers, + &count ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( device, "EFIDRV %s could not list %s openers: %s\n", + efi_handle_name ( device ), efi_guid_ntoa ( protocol ), + strerror ( rc ) ); + goto err_list; + } + + /* Identify BY_DRIVER opener */ + driver = NULL; + for ( i = 0 ; i < count ; i++ ) { + opener = &openers[i]; + if ( opener->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER ) { + driver = opener->AgentHandle; + break; + } + } + + /* Try to disconnect driver */ + if ( driver ) { + DBGC ( device, "EFIDRV %s disconnecting %s driver ", + efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); + DBGC ( device, "%s\n", efi_handle_name ( driver ) ); + if ( ( efirc = bs->DisconnectController ( device, driver, + NULL ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( device, "EFIDRV %s could not disconnect ", + efi_handle_name ( device ) ); + DBGC ( device, "%s: %s\n", + efi_handle_name ( driver ), strerror ( rc ) ); + goto err_disconnect; + } + } + + /* Success */ + rc = 0; + + err_disconnect: + bs->FreePool ( openers ); + err_list: + return rc; +} + /** * Try to connect EFI driver * @@ -451,6 +513,8 @@ static int efi_driver_connect ( EFI_HANDLE device ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE drivers[2] = { efi_driver_binding.DriverBindingHandle, NULL }; + struct efi_driver *efidrv; + EFI_GUID *exclude; EFI_STATUS efirc; int rc; @@ -468,13 +532,20 @@ static int efi_driver_connect ( EFI_HANDLE device ) { DBGC ( device, "EFIDRV %s disconnecting existing drivers\n", efi_handle_name ( device ) ); efi_driver_disconnecting = 1; - if ( ( efirc = bs->DisconnectController ( device, NULL, - NULL ) ) != 0 ) { - rc = -EEFI ( efirc ); - DBGC ( device, "EFIDRV %s could not disconnect existing " - "drivers: %s\n", efi_handle_name ( device ), - strerror ( rc ) ); - /* Ignore the error and attempt to connect our drivers */ + for_each_table_entry_reverse ( efidrv, EFI_DRIVERS ) { + exclude = efidrv->exclude; + if ( ! exclude ) + continue; + if ( ( rc = efidrv->supported ( device ) ) != 0 ) + continue; + DBGC ( device, "EFIDRV %s disconnecting %s drivers\n", + efi_handle_name ( device ), efi_guid_ntoa ( exclude ) ); + if ( ( rc = efi_driver_exclude ( device, exclude ) ) != 0 ) { + DBGC ( device, "EFIDRV %s could not disconnect %s " + "drivers: %s\n", efi_handle_name ( device ), + efi_guid_ntoa ( exclude ), strerror ( rc ) ); + /* Ignore the error and attempt to connect anyway */ + } } efi_driver_disconnecting = 0; DBGC2 ( device, "EFIDRV %s after disconnecting:\n", diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 6bdc2d575..f98794c27 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -916,6 +916,7 @@ static void efipci_stop ( struct efi_device *efidev ) { /** EFI PCI driver */ struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "PCI", + .exclude = &efi_pci_io_protocol_guid, .supported = efipci_supported, .start = efipci_start, .stop = efipci_stop, -- cgit v1.2.3-55-g7522 From 18dbd05ed59aeb47357e51393888748d1a5e835f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 22:03:32 +0000 Subject: [efi] Check correct return value from efi_pxe_find() Signed-off-by: Michael Brown --- src/interface/efi/efi_pxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_pxe.c b/src/interface/efi/efi_pxe.c index 843ebb5e7..732ccdcdf 100644 --- a/src/interface/efi/efi_pxe.c +++ b/src/interface/efi/efi_pxe.c @@ -1679,7 +1679,7 @@ void efi_pxe_uninstall ( EFI_HANDLE handle ) { /* Locate PXE base code */ pxe = efi_pxe_find ( handle ); - if ( ! handle ) { + if ( ! pxe ) { DBG ( "PXE could not find base code for %s\n", efi_handle_name ( handle ) ); return; -- cgit v1.2.3-55-g7522 From 7e64e9b6703e6dd363c063d545a5fe63bbc70011 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 1 Apr 2025 16:53:02 +0100 Subject: [fdt] Populate boot arguments in constructed device tree When creating a device tree to pass to a booted operating system, ensure that the "chosen" node exists, and populate the "bootargs" property with the image command line. Signed-off-by: Michael Brown --- src/core/fdt.c | 423 ++++++++++++++++++++++++++++++++++++++++- src/image/efi_image.c | 5 +- src/include/ipxe/efi/efi_fdt.h | 2 +- src/include/ipxe/fdt.h | 12 +- src/interface/efi/efi_fdt.c | 5 +- 5 files changed, 433 insertions(+), 14 deletions(-) (limited to 'src/interface') diff --git a/src/core/fdt.c b/src/core/fdt.c index 1664ec7b2..298cc439a 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -46,6 +46,9 @@ struct image_tag fdt_image __image_tag = { .name = "FDT", }; +/** Amount of free space to add whenever we have to reallocate a tree */ +#define FDT_INSERT_PAD 1024 + /** A position within a device tree */ struct fdt_cursor { /** Offset within structure block */ @@ -56,6 +59,8 @@ struct fdt_cursor { /** A lexical descriptor */ struct fdt_descriptor { + /** Offset within structure block */ + unsigned int offset; /** Node or property name (if applicable) */ const char *name; /** Property data (if applicable) */ @@ -86,8 +91,9 @@ static int fdt_traverse ( struct fdt *fdt, assert ( pos->offset <= fdt->len ); assert ( ( pos->offset & ( FDT_STRUCTURE_ALIGN - 1 ) ) == 0 ); - /* Clear descriptor */ + /* Initialise descriptor */ memset ( desc, 0, sizeof ( *desc ) ); + desc->offset = pos->offset; /* Locate token and calculate remaining space */ token = ( fdt->raw + fdt->structure + pos->offset ); @@ -212,8 +218,8 @@ static int fdt_child ( struct fdt *fdt, unsigned int offset, const char *name, /* Traverse tree */ if ( ( rc = fdt_traverse ( fdt, &pos, &desc ) ) != 0 ) { - DBGC ( fdt, "FDT +%#04x has no child node \"%s\": " - "%s\n", orig_offset, name, strerror ( rc ) ); + DBGC2 ( fdt, "FDT +%#04x has no child node \"%s\": " + "%s\n", orig_offset, name, strerror ( rc ) ); return rc; } @@ -231,6 +237,50 @@ static int fdt_child ( struct fdt *fdt, unsigned int offset, const char *name, } } +/** + * Find end of node + * + * @v fdt Device tree + * @v offset Starting node offset + * @v end End of node offset to fill in + * @ret rc Return status code + */ +static int fdt_end ( struct fdt *fdt, unsigned int offset, + unsigned int *end ) { + struct fdt_cursor pos; + struct fdt_descriptor desc; + unsigned int orig_offset; + int rc; + + /* Record original offset (for debugging) */ + orig_offset = offset; + + /* Initialise cursor */ + pos.offset = offset; + pos.depth = 0; + + /* Find child node */ + while ( 1 ) { + + /* Record current offset */ + *end = pos.offset; + + /* Traverse tree */ + if ( ( rc = fdt_traverse ( fdt, &pos, &desc ) ) != 0 ) { + DBGC ( fdt, "FDT +%#04x has malformed node: %s\n", + orig_offset, strerror ( rc ) ); + return rc; + } + + /* Check for end of current node */ + if ( pos.depth == 0 ) { + DBGC2 ( fdt, "FDT +%#04x has end at +%#04x\n", + orig_offset, *end ); + return 0; + } + } +} + /** * Find node by path * @@ -326,8 +376,8 @@ static int fdt_property ( struct fdt *fdt, unsigned int offset, /* Traverse tree */ if ( ( rc = fdt_traverse ( fdt, &pos, desc ) ) != 0 ) { - DBGC ( fdt, "FDT +%#04x has no property \"%s\": %s\n", - offset, name, strerror ( rc ) ); + DBGC2 ( fdt, "FDT +%#04x has no property \"%s\": %s\n", + offset, name, strerror ( rc ) ); return rc; } @@ -459,6 +509,7 @@ int fdt_mac ( struct fdt *fdt, unsigned int offset, */ int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ) { const uint8_t *nul; + unsigned int chosen; size_t end; /* Sanity check */ @@ -553,8 +604,15 @@ int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ) { fdt->used, fdt->len ); } - /* Print model name (for debugging) */ - DBGC ( fdt, "FDT model is \"%s\"\n", fdt_string ( fdt, 0, "model" ) ); + /* Print model name and boot arguments (for debugging) */ + if ( DBG_LOG ) { + DBGC ( fdt, "FDT model is \"%s\"\n", + fdt_string ( fdt, 0, "model" ) ); + if ( fdt_child ( fdt, 0, "chosen", &chosen ) == 0 ) { + DBGC ( fdt, "FDT boot arguments \"%s\"\n", + fdt_string ( fdt, chosen, "bootargs" ) ); + } + } return 0; @@ -586,13 +644,356 @@ static int fdt_parse_image ( struct fdt *fdt, struct image *image ) { return 0; } +/** + * Insert empty space + * + * @v fdt Device tree + * @v offset Offset at which to insert space + * @v len Length to insert (must be a multiple of FDT_MAX_ALIGN) + * @ret rc Return status code + */ +static int fdt_insert ( struct fdt *fdt, unsigned int offset, size_t len ) { + size_t free; + size_t new; + int rc; + + /* Sanity checks */ + assert ( offset <= fdt->used ); + assert ( fdt->used <= fdt->len ); + assert ( ( len % FDT_MAX_ALIGN ) == 0 ); + + /* Reallocate tree if necessary */ + free = ( fdt->len - fdt->used ); + if ( free < len ) { + if ( ! fdt->realloc ) { + DBGC ( fdt, "FDT is not reallocatable\n" ); + return -ENOTSUP; + } + new = ( fdt->len + ( len - free ) + FDT_INSERT_PAD ); + if ( ( rc = fdt->realloc ( fdt, new ) ) != 0 ) + return rc; + } + assert ( ( fdt->used + len ) <= fdt->len ); + + /* Insert empty space */ + memmove ( ( fdt->raw + offset + len ), ( fdt->raw + offset ), + ( fdt->used - offset ) ); + memset ( ( fdt->raw + offset ), 0, len ); + fdt->used += len; + + /* Update offsets + * + * We assume that we never need to legitimately insert data at + * the start of a block, and therefore can unambiguously + * determine which block offsets need to be updated. + * + * It is the caller's responsibility to update the length (and + * contents) of the block into which it has inserted space. + */ + if ( fdt->structure >= offset ) { + fdt->structure += len; + fdt->hdr->off_dt_struct = cpu_to_be32 ( fdt->structure ); + DBGC ( fdt, "FDT structure block now at +[%#04x,%#04zx)\n", + fdt->structure, + ( fdt->structure + fdt->structure_len ) ); + } + if ( fdt->strings >= offset ) { + fdt->strings += len; + fdt->hdr->off_dt_strings = cpu_to_be32 ( fdt->strings ); + DBGC ( fdt, "FDT strings block now at +[%#04x,%#04zx)\n", + fdt->strings, ( fdt->strings + fdt->strings_len ) ); + } + if ( fdt->reservations >= offset ) { + fdt->reservations += len; + fdt->hdr->off_mem_rsvmap = cpu_to_be32 ( fdt->reservations ); + DBGC ( fdt, "FDT memory reservations now at +[%#04x,...)\n", + fdt->reservations ); + } + + return 0; +} + +/** + * Fill space in structure block with FDT_NOP + * + * @v fdt Device tree + * @v offset Starting offset + * @v len Length (must be a multiple of FDT_STRUCTURE_ALIGN) + */ +static void fdt_nop ( struct fdt *fdt, unsigned int offset, size_t len ) { + fdt_token_t *token; + unsigned int count; + + /* Sanity check */ + assert ( ( len % FDT_STRUCTURE_ALIGN ) == 0 ); + + /* Fill with FDT_NOP */ + token = ( fdt->raw + fdt->structure + offset ); + count = ( len / sizeof ( *token ) ); + while ( count-- ) + *(token++) = cpu_to_be32 ( FDT_NOP ); +} + +/** + * Insert FDT_NOP padded space in structure block + * + * @v fdt Device tree + * @v offset Offset at which to insert space + * @v len Minimal length to insert + * @ret rc Return status code + */ +static int fdt_insert_nop ( struct fdt *fdt, unsigned int offset, + size_t len ) { + int rc; + + /* Sanity check */ + assert ( ( offset % FDT_STRUCTURE_ALIGN ) == 0 ); + + /* Round up inserted length to maximal alignment */ + len = ( ( len + FDT_MAX_ALIGN - 1 ) & ~( FDT_MAX_ALIGN - 1 ) ); + + /* Insert empty space in structure block */ + if ( ( rc = fdt_insert ( fdt, ( fdt->structure + offset ), + len ) ) != 0 ) + return rc; + + /* Fill with NOPs */ + fdt_nop ( fdt, offset, len ); + + /* Update structure block size */ + fdt->structure_len += len; + fdt->hdr->size_dt_struct = cpu_to_be32 ( fdt->structure_len ); + DBGC ( fdt, "FDT structure block now at +[%#04x,%#04zx)\n", + fdt->structure, ( fdt->structure + fdt->structure_len ) ); + + return 0; +} + +/** + * Insert string in strings block + * + * @v fdt Device tree + * @v string String + * @v offset String offset to fill in + * @ret rc Return status code + */ +static int fdt_insert_string ( struct fdt *fdt, const char *string, + unsigned int *offset ) { + size_t len = ( strlen ( string ) + 1 /* NUL */ ); + int rc; + + /* Round up inserted length to maximal alignment */ + len = ( ( len + FDT_MAX_ALIGN - 1 ) & ~( FDT_MAX_ALIGN - 1 ) ); + + /* Insert space at end of strings block */ + if ( ( rc = fdt_insert ( fdt, ( fdt->strings + fdt->strings_len ), + len ) ) != 0 ) + return rc; + + /* Append string to strings block */ + *offset = fdt->strings_len; + strcpy ( ( fdt->raw + fdt->strings + *offset ), string ); + + /* Update strings block size */ + fdt->strings_len += len; + fdt->hdr->size_dt_strings = cpu_to_be32 ( fdt->strings_len ); + DBGC ( fdt, "FDT strings block now at +[%#04x,%#04zx)\n", + fdt->strings, ( fdt->strings + fdt->strings_len ) ); + + return 0; +} + +/** + * Ensure child node exists + * + * @v fdt Device tree + * @v offset Starting node offset + * @v name New node name + * @v child Child node offset to fill in + * @ret rc Return status code + */ +static int fdt_ensure_child ( struct fdt *fdt, unsigned int offset, + const char *name, unsigned int *child ) { + size_t name_len = ( strlen ( name ) + 1 /* NUL */ ); + fdt_token_t *token; + size_t len; + int rc; + + /* Find existing child node, if any */ + if ( ( rc = fdt_child ( fdt, offset, name, child ) ) == 0 ) + return 0; + + /* Find end of parent node */ + if ( ( rc = fdt_end ( fdt, offset, child ) ) != 0 ) + return rc; + + /* Insert space for child node (with maximal alignment) */ + len = ( sizeof ( fdt_token_t ) /* BEGIN_NODE */ + name_len + + sizeof ( fdt_token_t ) /* END_NODE */ ); + if ( ( rc = fdt_insert_nop ( fdt, *child, len ) ) != 0 ) + return rc; + + /* Construct node */ + token = ( fdt->raw + fdt->structure + *child ); + *(token++) = cpu_to_be32 ( FDT_BEGIN_NODE ); + memcpy ( token, name, name_len ); + name_len = ( ( name_len + FDT_STRUCTURE_ALIGN - 1 ) & + ~( FDT_STRUCTURE_ALIGN - 1 ) ); + token = ( ( ( void * ) token ) + name_len ); + *(token++) = cpu_to_be32 ( FDT_END_NODE ); + DBGC2 ( fdt, "FDT +%#04x created child \"%s\" at +%#04x\n", + offset, name, *child ); + + return 0; +} + +/** + * Ensure property exists with specified value + * + * @v fdt Device tree + * @v offset Starting node offset + * @v name Property name + * @v data Property data + * @v len Length of property data + * @ret rc Return status code + */ +static int fdt_ensure_property ( struct fdt *fdt, unsigned int offset, + const char *name, const void *data, + size_t len ) { + struct fdt_descriptor desc; + struct fdt_cursor pos; + struct { + fdt_token_t token; + struct fdt_prop prop; + uint8_t data[0]; + } __attribute__ (( packed )) *hdr; + unsigned int string; + size_t erase; + size_t insert; + int rc; + + /* Find and reuse existing property, if any */ + if ( ( rc = fdt_property ( fdt, offset, name, &desc ) ) == 0 ) { + + /* Reuse existing name */ + pos.offset = desc.offset; + hdr = ( fdt->raw + fdt->structure + pos.offset ); + string = be32_to_cpu ( hdr->prop.name_off ); + + /* Erase existing property */ + erase = ( sizeof ( *hdr ) + desc.len ); + erase = ( ( erase + FDT_STRUCTURE_ALIGN - 1 ) & + ~( FDT_STRUCTURE_ALIGN - 1 ) ); + fdt_nop ( fdt, pos.offset, erase ); + DBGC2 ( fdt, "FDT +%#04x erased property \"%s\"\n", + offset, name ); + + /* Calculate insertion position and length */ + insert = ( ( desc.len < len ) ? ( len - desc.len ) : 0 ); + + } else { + + /* Create name */ + if ( ( rc = fdt_insert_string ( fdt, name, &string ) ) != 0 ) + return rc; + + /* Enter node */ + pos.offset = offset; + pos.depth = 0; + if ( ( rc = fdt_traverse ( fdt, &pos, &desc ) ) != 0 ) + return rc; + assert ( pos.depth == 1 ); + + /* Calculate insertion length */ + insert = ( sizeof ( *hdr ) + len ); + } + + /* Insert space */ + if ( ( rc = fdt_insert_nop ( fdt, pos.offset, insert ) ) != 0 ) + return rc; + + /* Construct property */ + hdr = ( fdt->raw + fdt->structure + pos.offset ); + hdr->token = cpu_to_be32 ( FDT_PROP ); + hdr->prop.len = cpu_to_be32 ( len ); + hdr->prop.name_off = cpu_to_be32 ( string ); + memset ( hdr->data, 0, ( ( len + FDT_STRUCTURE_ALIGN - 1 ) & + ~( FDT_STRUCTURE_ALIGN - 1 ) ) ); + memcpy ( hdr->data, data, len ); + DBGC2 ( fdt, "FDT +%#04x created property \"%s\"\n", offset, name ); + DBGC2_HDA ( fdt, 0, hdr->data, len ); + + return 0; +} + +/** + * Reallocate device tree via urealloc() + * + * @v fdt Device tree + * @v len New total length + * @ret rc Return status code + */ +static int fdt_urealloc ( struct fdt *fdt, size_t len ) { + void *new; + + /* Sanity check */ + assert ( len >= fdt->used ); + + /* Attempt reallocation */ + new = user_to_virt ( urealloc ( virt_to_user ( fdt->raw ), len ), 0 ); + if ( ! new ) { + DBGC ( fdt, "FDT could not reallocate from +%#04zx to " + "+%#04zx\n", fdt->len, len ); + return -ENOMEM; + } + DBGC ( fdt, "FDT reallocated from +%#04zx to +%#04zx\n", + fdt->len, len ); + + /* Update device tree */ + fdt->raw = new; + fdt->len = len; + fdt->hdr->totalsize = cpu_to_be32 ( len ); + + return 0; +} + +/** + * Populate device tree with boot arguments + * + * @v fdt Device tree + * @v cmdline Command line, or NULL + * @ret rc Return status code + */ +static int fdt_bootargs ( struct fdt *fdt, const char *cmdline ) { + unsigned int chosen; + size_t len; + int rc; + + /* Ensure "chosen" node exists */ + if ( ( rc = fdt_ensure_child ( fdt, 0, "chosen", &chosen ) ) != 0 ) + return rc; + + /* Use empty command line if none specified */ + if ( ! cmdline ) + cmdline = ""; + + /* Ensure "bootargs" property exists */ + len = ( strlen ( cmdline ) + 1 /* NUL */ ); + if ( ( rc = fdt_ensure_property ( fdt, chosen, "bootargs", cmdline, + len ) ) != 0 ) + return rc; + + return 0; +} + /** * Create device tree * * @v hdr Device tree header to fill in (may be set to NULL) + * @v cmdline Command line, or NULL * @ret rc Return status code */ -int fdt_create ( struct fdt_header **hdr ) { +int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { struct image *image; struct fdt fdt; void *copy; @@ -620,11 +1021,17 @@ int fdt_create ( struct fdt_header **hdr ) { } memcpy ( copy, fdt.raw, fdt.len ); fdt.raw = copy; + fdt.realloc = fdt_urealloc; + + /* Populate boot arguments */ + if ( ( rc = fdt_bootargs ( &fdt, cmdline ) ) != 0 ) + goto err_bootargs; no_fdt: *hdr = fdt.raw; return 0; + err_bootargs: ufree ( virt_to_user ( fdt.raw ) ); err_alloc: err_image: diff --git a/src/image/efi_image.c b/src/image/efi_image.c index 273f8e8fd..c87196487 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -126,9 +126,10 @@ static wchar_t * efi_image_cmdline ( struct image *image ) { /** * Install EFI Flattened Device Tree table (when no FDT support is present) * + * @v cmdline Command line, or NULL * @ret rc Return status code */ -__weak int efi_fdt_install ( void ) { +__weak int efi_fdt_install ( const char *cmdline __unused ) { return 0; } @@ -209,7 +210,7 @@ static int efi_image_exec ( struct image *image ) { } /* Install Flattened Device Tree table */ - if ( ( rc = efi_fdt_install() ) != 0 ) { + if ( ( rc = efi_fdt_install ( image->cmdline ) ) != 0 ) { DBGC ( image, "EFIIMAGE %s could not install FDT: %s\n", image->name, strerror ( rc ) ); goto err_fdt_install; diff --git a/src/include/ipxe/efi/efi_fdt.h b/src/include/ipxe/efi/efi_fdt.h index a9b7eac8b..d18676d7e 100644 --- a/src/include/ipxe/efi/efi_fdt.h +++ b/src/include/ipxe/efi/efi_fdt.h @@ -11,7 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -extern int efi_fdt_install ( void ); +extern int efi_fdt_install ( const char *cmdline ); extern int efi_fdt_uninstall ( void ); #endif /* _IPXE_EFI_FDT_H */ diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index 0c2137f2b..7eec5cd88 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -73,6 +73,9 @@ struct fdt_prop { /** Alignment of structure block */ #define FDT_STRUCTURE_ALIGN ( sizeof ( fdt_token_t ) ) +/** Maximum alignment of any block */ +#define FDT_MAX_ALIGN 8 + /** A device tree */ struct fdt { /** Tree data */ @@ -96,6 +99,13 @@ struct fdt { size_t strings_len; /** Offset to memory reservation block */ unsigned int reservations; + /** Reallocate device tree + * + * @v fdt Device tree + * @v len New length + * @ret rc Return status code + */ + int ( * realloc ) ( struct fdt *fdt, size_t len ); }; extern struct image_tag fdt_image __image_tag; @@ -113,7 +123,7 @@ extern int fdt_mac ( struct fdt *fdt, unsigned int offset, struct net_device *netdev ); extern int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ); -extern int fdt_create ( struct fdt_header **hdr ); +extern int fdt_create ( struct fdt_header **hdr, const char *cmdline ); extern void fdt_remove ( struct fdt_header *hdr ); #endif /* _IPXE_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 4a10236a0..1e0d4b8b7 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -107,13 +107,14 @@ static struct fdt_header *efi_fdt_installed; /** * Install EFI Flattened Device Tree table * + * @v cmdline Command line, or NULL * @ret rc Return status code */ -int efi_fdt_install ( void ) { +int efi_fdt_install ( const char *cmdline ) { int rc; /* Create device tree */ - if ( ( rc = fdt_create ( &efi_fdt_installed ) ) != 0 ) { + if ( ( rc = fdt_create ( &efi_fdt_installed, cmdline ) ) != 0 ) { DBGC ( &efi_fdt, "EFI_FDT could not install: %s\n", strerror ( rc ) ); goto err_create; -- cgit v1.2.3-55-g7522 From c88ebf2ac6291f396112b813e6ac71cff4732a34 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 16 Apr 2025 21:26:45 +0100 Subject: [efi] Allow for custom methods for disconnecting existing drivers Allow for greater control over the process used to disconnect existing drivers from a device handle, by converting the "exclude" field from a simple protocol GUID to a per-driver method. Signed-off-by: Michael Brown --- src/drivers/net/efi/nii.c | 20 ++++++++++++++++++++ src/drivers/net/efi/nii.h | 1 + src/drivers/net/efi/snp.c | 4 ++-- src/drivers/net/efi/snpnet.c | 20 ++++++++++++++++++++ src/drivers/net/efi/snpnet.h | 1 + src/drivers/net/efi/snponly.c | 4 ++-- src/drivers/usb/usbio.c | 22 +++++++++++++++++++++- src/include/ipxe/efi/efi_driver.h | 10 ++++++++-- src/interface/efi/efi_driver.c | 16 +++++++--------- src/interface/efi/efi_pci.c | 22 +++++++++++++++++++++- 10 files changed, 103 insertions(+), 17 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 81f1838a4..6381fb2dd 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -1257,6 +1257,26 @@ static struct net_device_operations nii_operations = { .poll = nii_poll, }; +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +int nii_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_nii31_protocol_guid; + int rc; + + /* Exclude existing NII protocol drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "NII %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * diff --git a/src/drivers/net/efi/nii.h b/src/drivers/net/efi/nii.h index c10be9db5..df7ab7dbe 100644 --- a/src/drivers/net/efi/nii.h +++ b/src/drivers/net/efi/nii.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); struct efi_device; +extern int nii_exclude ( EFI_HANDLE device ); extern int nii_start ( struct efi_device *efidev ); extern void nii_stop ( struct efi_device *efidev ); diff --git a/src/drivers/net/efi/snp.c b/src/drivers/net/efi/snp.c index 7c4123677..2e0d9df3a 100644 --- a/src/drivers/net/efi/snp.c +++ b/src/drivers/net/efi/snp.c @@ -59,8 +59,8 @@ static int nii_supported ( EFI_HANDLE device ) { /** EFI SNP driver */ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNP", - .exclude = &efi_simple_network_protocol_guid, .supported = snp_supported, + .exclude = snpnet_exclude, .start = snpnet_start, .stop = snpnet_stop, }; @@ -68,8 +68,8 @@ struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII driver */ struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NII", - .exclude = &efi_nii31_protocol_guid, .supported = nii_supported, + .exclude = nii_exclude, .start = nii_start, .stop = nii_stop, }; diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index c8e2f2f68..c4062a5a7 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -528,6 +528,26 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) { return 0; } +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +int snpnet_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_simple_network_protocol_guid; + int rc; + + /* Exclude existing SNP drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "SNP %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * diff --git a/src/drivers/net/efi/snpnet.h b/src/drivers/net/efi/snpnet.h index 4699c7892..d3602a589 100644 --- a/src/drivers/net/efi/snpnet.h +++ b/src/drivers/net/efi/snpnet.h @@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct efi_device; extern int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ); +extern int snpnet_exclude ( EFI_HANDLE device ); extern int snpnet_start ( struct efi_device *efidev ); extern void snpnet_stop ( struct efi_device *efidev ); diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 267572e34..88c74ed42 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -209,8 +209,8 @@ static int mnponly_supported ( EFI_HANDLE device ) { /** EFI SNP chainloading-device-only driver */ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { .name = "SNPONLY", - .exclude = &efi_simple_network_protocol_guid, .supported = snponly_supported, + .exclude = snpnet_exclude, .start = snpnet_start, .stop = snpnet_stop, }; @@ -218,8 +218,8 @@ struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_SNP ) = { /** EFI NII chainloading-device-only driver */ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NII ) = { .name = "NIIONLY", - .exclude = &efi_nii31_protocol_guid, .supported = niionly_supported, + .exclude = nii_exclude, .start = nii_start, .stop = nii_stop, }; diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c index 991b290ad..97860a281 100644 --- a/src/drivers/usb/usbio.c +++ b/src/drivers/usb/usbio.c @@ -1542,6 +1542,26 @@ static int usbio_interfaces ( struct usbio_device *usbio ) { return rc; } +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +static int usbio_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_usb_io_protocol_guid; + int rc; + + /* Exclude existing USB I/O protocol drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "USBIO %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * @@ -1651,8 +1671,8 @@ static void usbio_stop ( struct efi_device *efidev ) { /** EFI USB I/O driver */ struct efi_driver usbio_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "USBIO", - .exclude = &efi_usb_io_protocol_guid, .supported = usbio_supported, + .exclude = usbio_exclude, .start = usbio_start, .stop = usbio_stop, }; diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 4c2148919..5ab2d011a 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -33,8 +33,13 @@ struct efi_device { struct efi_driver { /** Name */ const char *name; - /** Protocol to which exclusive access is required, if any */ - EFI_GUID *exclude; + /** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ + int ( * exclude ) ( EFI_HANDLE device ); /** * Check if driver supports device * @@ -95,6 +100,7 @@ extern void efidev_free ( struct efi_device *efidev ); extern struct efi_device * efidev_parent ( struct device *dev ); extern int efi_driver_install ( void ); extern void efi_driver_uninstall ( void ); +extern int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ); extern int efi_driver_connect_all ( void ); extern void efi_driver_disconnect_all ( void ); extern void efi_driver_reconnect_all ( void ); diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 8c5e00bfb..ce1db228d 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -448,7 +448,7 @@ void efi_driver_uninstall ( void ) { * @v protocol Protocol GUID * @ret rc Return status code */ -static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { +int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers; EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener; @@ -479,6 +479,8 @@ static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { } /* Try to disconnect driver */ + DBGC ( device, "EFIDRV %s disconnecting %s drivers\n", + efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); if ( driver ) { DBGC ( device, "EFIDRV %s disconnecting %s driver ", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); @@ -514,7 +516,6 @@ static int efi_driver_connect ( EFI_HANDLE device ) { EFI_HANDLE drivers[2] = { efi_driver_binding.DriverBindingHandle, NULL }; struct efi_driver *efidrv; - EFI_GUID *exclude; EFI_STATUS efirc; int rc; @@ -533,17 +534,14 @@ static int efi_driver_connect ( EFI_HANDLE device ) { efi_handle_name ( device ) ); efi_driver_disconnecting = 1; for_each_table_entry_reverse ( efidrv, EFI_DRIVERS ) { - exclude = efidrv->exclude; - if ( ! exclude ) + if ( ! efidrv->exclude ) continue; if ( ( rc = efidrv->supported ( device ) ) != 0 ) continue; - DBGC ( device, "EFIDRV %s disconnecting %s drivers\n", - efi_handle_name ( device ), efi_guid_ntoa ( exclude ) ); - if ( ( rc = efi_driver_exclude ( device, exclude ) ) != 0 ) { - DBGC ( device, "EFIDRV %s could not disconnect %s " + if ( ( rc = efidrv->exclude ( device ) ) != 0 ) { + DBGC ( device, "EFIDRV %s could not disconnect " "drivers: %s\n", efi_handle_name ( device ), - efi_guid_ntoa ( exclude ), strerror ( rc ) ); + strerror ( rc ) ); /* Ignore the error and attempt to connect anyway */ } } diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index f98794c27..dd11dd342 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -829,6 +829,26 @@ static int efipci_supported ( EFI_HANDLE device ) { return 0; } +/** + * Exclude existing drivers + * + * @v device EFI device handle + * @ret rc Return status code + */ +static int efipci_exclude ( EFI_HANDLE device ) { + EFI_GUID *protocol = &efi_pci_io_protocol_guid; + int rc; + + /* Exclude existing PCI I/O protocol drivers */ + if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) { + DBGC ( device, "EFIPCI %s could not exclude drivers: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + /** * Attach driver to device * @@ -916,8 +936,8 @@ static void efipci_stop ( struct efi_device *efidev ) { /** EFI PCI driver */ struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = { .name = "PCI", - .exclude = &efi_pci_io_protocol_guid, .supported = efipci_supported, + .exclude = efipci_exclude, .start = efipci_start, .stop = efipci_stop, }; -- cgit v1.2.3-55-g7522 From 71174e19d8c93dc99221c5fe32db6a78c6a7ffb3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 20 Apr 2025 13:39:32 +0100 Subject: [uaccess] Add explicit casts to and from userptr_t where needed Allow for the possibility of userptr_t becoming a pointer type by adding explicit casts where necessary. Signed-off-by: Michael Brown --- src/arch/x86/include/librm.h | 6 +++--- src/arch/x86/interface/pcbios/memtop_umalloc.c | 2 +- src/drivers/infiniband/golan.c | 2 +- src/include/ipxe/linux/linux_uaccess.h | 4 ++-- src/include/ipxe/uaccess.h | 4 ++-- src/interface/efi/efi_umalloc.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index c664bff2c..23ca4650f 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -96,10 +96,10 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) { * identity-mapped. */ if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) - return phys_addr; + return ( ( userptr_t ) phys_addr ); /* In a 32-bit build, subtract virt_offset */ - return ( phys_addr - virt_offset ); + return ( ( userptr_t ) ( phys_addr - virt_offset ) ); } /** @@ -111,7 +111,7 @@ UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) { */ static inline __always_inline unsigned long UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) { - unsigned long addr = ( userptr + offset ); + unsigned long addr = ( ( unsigned long ) ( userptr + offset ) ); /* In a 64-bit build, any virtual address in the low 4GB is * directly usable as a physical address, since the low 4GB is diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 1d3f40a1c..1cc3aff91 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -45,7 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define EM_ALIGN ( 4 * 1024 ) /** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ~UNULL ) +#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) ) /** An external memory block */ struct external_memory { diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index 68a7c4f5d..81fc6c0f0 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -487,7 +487,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages next_page_addr += GOLAN_PAGE_SIZE ) { addr = next_page_addr; if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) { - DBGC (golan ,"Addr not Page alligned [%lx %lx]\n", user_to_phys(addr, 0), addr); + DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0)); } mailbox->mblock.data[j] = USR_2_BE64_BUS(addr); } diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index b29aa14bd..1e31afd9c 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -43,7 +43,7 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) { * virtual address will suffice for the purpose of determining * alignment. */ - return ( userptr + offset ); + return ( ( unsigned long ) ( userptr + offset ) ); } /** @@ -56,7 +56,7 @@ static inline __always_inline userptr_t UACCESS_INLINE ( linux, phys_to_user ) ( physaddr_t phys_addr ) { /* For symmetry with the stub user_to_phys() */ - return phys_addr; + return ( ( userptr_t ) phys_addr ); } static inline __always_inline userptr_t diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 2575faca5..d8c57adeb 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -224,12 +224,12 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) { static inline __always_inline userptr_t UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) { - return phys_addr; + return ( ( userptr_t ) phys_addr ); } static inline __always_inline unsigned long UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) { - return ( userptr + offset ); + return ( ( unsigned long ) ( userptr + offset ) ); } static inline __always_inline userptr_t diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index e3f1dacc2..175ae367e 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -36,7 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ~UNULL ) +#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) ) /** * Reallocate external memory -- cgit v1.2.3-55-g7522 From ef038491858cb51f8aa17b1f6e50444d2e627413 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 20 Apr 2025 18:45:55 +0100 Subject: [uaccess] Remove redundant userptr_add() and userptr_diff() The userptr_add() and userptr_diff() functions are now just straightforward wrappers around addition and subtraction. Remove these redundant wrappers. Signed-off-by: Michael Brown --- src/arch/x86/image/bzimage.c | 12 +++--- src/arch/x86/image/initrd.c | 25 ++++++------ src/arch/x86/image/nbi.c | 4 +- src/arch/x86/include/librm.h | 11 ------ src/arch/x86/interface/pcbios/memtop_umalloc.c | 10 ++--- src/arch/x86/transitions/librm_mgmt.c | 1 - src/core/sanboot.c | 2 +- src/core/uaccess.c | 1 - src/drivers/net/gve.c | 2 +- src/image/gzip.c | 2 +- src/include/ipxe/linux/linux_uaccess.h | 11 ------ src/include/ipxe/uaccess.h | 53 -------------------------- src/interface/linux/linux_uaccess.c | 1 - 13 files changed, 27 insertions(+), 108 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index b4a78cdfc..d00b9f155 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -431,7 +431,7 @@ static int bzimage_check_initrds ( struct image *image, } /* Calculate lowest usable address */ - bottom = userptr_add ( bzimg->pm_kernel, bzimg->pm_sz ); + bottom = ( bzimg->pm_kernel + bzimg->pm_sz ); /* Check that total length fits within space available for * reshuffling. This is a conservative check, since CPIO @@ -471,14 +471,12 @@ static void bzimage_load_initrds ( struct image *image, size_t len; /* Reshuffle initrds into desired order */ - initrd_reshuffle ( userptr_add ( bzimg->pm_kernel, bzimg->pm_sz ) ); + initrd_reshuffle ( bzimg->pm_kernel + bzimg->pm_sz ); /* Find highest initrd */ for_each_image ( initrd ) { - if ( ( highest == NULL ) || - ( userptr_diff ( initrd->data, highest->data ) > 0 ) ) { + if ( ( highest == NULL ) || ( initrd->data > highest->data ) ) highest = initrd; - } } /* Do nothing if there are no initrds */ @@ -486,7 +484,7 @@ static void bzimage_load_initrds ( struct image *image, return; /* Find highest usable address */ - top = userptr_add ( highest->data, bzimage_align ( highest->len ) ); + top = ( highest->data + bzimage_align ( highest->len ) ); if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) { top = phys_to_user ( ( bzimg->mem_limit + 1 ) & ~( INITRD_ALIGN - 1 ) ); @@ -509,7 +507,7 @@ static void bzimage_load_initrds ( struct image *image, } /* Load initrd at this address */ - dest = userptr_add ( top, -offset ); + dest = ( top - offset ); len = bzimage_load_initrd ( image, initrd, dest ); /* Record initrd location */ diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index c0a56b7f6..e32e40341 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -61,10 +61,9 @@ static userptr_t initrd_squash_high ( userptr_t top ) { /* Find the highest image not yet in its final position */ highest = NULL; for_each_image ( initrd ) { - if ( ( userptr_diff ( initrd->data, current ) < 0 ) && + if ( ( initrd->data < current ) && ( ( highest == NULL ) || - ( userptr_diff ( initrd->data, - highest->data ) > 0 ) ) ) { + ( initrd->data > highest->data ) ) ) { highest = initrd; } } @@ -74,7 +73,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) { /* Move this image to its final position */ len = ( ( highest->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - current = userptr_add ( current, -len ); + current -= len; DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", highest->name, user_to_phys ( highest->data, 0 ), @@ -87,10 +86,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) { /* Copy any remaining initrds (e.g. embedded images) to the region */ for_each_image ( initrd ) { - if ( userptr_diff ( initrd->data, top ) >= 0 ) { + if ( initrd->data >= top ) { len = ( ( initrd->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - current = userptr_add ( current, -len ); + current -= len; DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", initrd->name, user_to_phys ( initrd->data, 0 ), @@ -149,7 +148,7 @@ static void initrd_swap ( struct image *low, struct image *high, /* Adjust data pointers */ high->data = low->data; - low->data = userptr_add ( low->data, len ); + low->data += len; } /** @@ -171,7 +170,7 @@ static int initrd_swap_any ( userptr_t free, size_t free_len ) { /* Calculate location of adjacent image (if any) */ padded_len = ( ( low->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - adjacent = userptr_add ( low->data, padded_len ); + adjacent = ( low->data + padded_len ); /* Search for adjacent image */ for_each_image ( high ) { @@ -235,7 +234,7 @@ void initrd_reshuffle ( userptr_t bottom ) { /* Calculate limits of available space for initrds */ top = initrd_top; - if ( userptr_diff ( initrd_bottom, bottom ) > 0 ) + if ( initrd_bottom > bottom ) bottom = initrd_bottom; /* Debug */ @@ -248,7 +247,7 @@ void initrd_reshuffle ( userptr_t bottom ) { /* Calculate available free space */ free = bottom; - free_len = userptr_diff ( used, free ); + free_len = ( used - free ); /* Bubble-sort initrds into desired order */ while ( initrd_swap_any ( free, free_len ) ) {} @@ -270,9 +269,9 @@ int initrd_reshuffle_check ( size_t len, userptr_t bottom ) { /* Calculate limits of available space for initrds */ top = initrd_top; - if ( userptr_diff ( initrd_bottom, bottom ) > 0 ) + if ( initrd_bottom > bottom ) bottom = initrd_bottom; - available = userptr_diff ( top, bottom ); + available = ( top - bottom ); /* Allow for a sensible minimum amount of free space */ len += INITRD_MIN_FREE_LEN; @@ -296,7 +295,7 @@ static void initrd_startup ( void ) { * can safely reuse when rearranging). */ len = largest_memblock ( &initrd_bottom ); - initrd_top = userptr_add ( initrd_bottom, len ); + initrd_top = ( initrd_bottom + len ); } /** initrd startup function */ diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index b691bee20..2f0d3164a 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -184,10 +184,10 @@ static int nbi_process_segments ( struct image *image, dest = phys_to_user ( sh.loadaddr ); break; case NBI_LOADADDR_AFTER: - dest = userptr_add ( dest, memsz + sh.loadaddr ); + dest = ( dest + memsz + sh.loadaddr ); break; case NBI_LOADADDR_BEFORE: - dest = userptr_add ( dest, -sh.loadaddr ); + dest = ( dest - sh.loadaddr ); break; case NBI_LOADADDR_END: /* Not correct according to the spec, but diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 23ca4650f..c0d910287 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -137,17 +137,6 @@ UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( librm, userptr_diff ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_diff ( userptr, subtrahend ); -} - static inline __always_inline void UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 1cc3aff91..e76b3df93 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -122,7 +122,7 @@ static void init_eheap ( void ) { userptr_t base; heap_size = largest_memblock ( &base ); - bottom = top = userptr_add ( base, heap_size ); + bottom = top = ( base + heap_size ); DBG ( "External heap grows downwards from %lx (size %zx)\n", user_to_phys ( top, 0 ), heap_size ); } @@ -144,7 +144,7 @@ static void ecollect_free ( void ) { DBG ( "EXTMEM freeing [%lx,%lx)\n", user_to_phys ( bottom, 0 ), user_to_phys ( bottom, extmem.size ) ); len = ( extmem.size + sizeof ( extmem ) ); - bottom = userptr_add ( bottom, len ); + bottom += len; heap_size += len; } } @@ -179,7 +179,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { DBG ( "EXTMEM out of space\n" ); return UNULL; } - ptr = bottom = userptr_add ( bottom, -sizeof ( extmem ) ); + ptr = bottom = ( bottom - sizeof ( extmem ) ); heap_size -= sizeof ( extmem ); DBG ( "EXTMEM allocating [%lx,%lx)\n", user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) ); @@ -190,10 +190,10 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { /* Expand/shrink block if possible */ if ( ptr == bottom ) { /* Update block */ - new = userptr_add ( ptr, - ( new_size - extmem.size ) ); + new = ( ptr - ( new_size - extmem.size ) ); align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) ); new_size += align; - new = userptr_add ( new, -align ); + new -= align; if ( new_size > ( heap_size + extmem.size ) ) { DBG ( "EXTMEM out of space\n" ); return UNULL; diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index b3820589c..ec31fceb1 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -432,7 +432,6 @@ PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_virt ); -PROVIDE_UACCESS_INLINE ( librm, userptr_add ); PROVIDE_UACCESS_INLINE ( librm, memcpy_user ); PROVIDE_UACCESS_INLINE ( librm, memmove_user ); PROVIDE_UACCESS_INLINE ( librm, memset_user ); diff --git a/src/core/sanboot.c b/src/core/sanboot.c index e49a3f92d..4facf86b8 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -625,7 +625,7 @@ static int sandev_rw ( struct san_device *sandev, uint64_t lba, /* Move to next fragment */ frag_len = ( sandev->capacity.blksize * params.rw.count ); - params.rw.buffer = userptr_add ( params.rw.buffer, frag_len ); + params.rw.buffer += frag_len; params.rw.lba += params.rw.count; remaining -= params.rw.count; } diff --git a/src/core/uaccess.c b/src/core/uaccess.c index d3a9ca17d..ad17a58ab 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -36,7 +36,6 @@ PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_virt ); -PROVIDE_UACCESS_INLINE ( flat, userptr_add ); PROVIDE_UACCESS_INLINE ( flat, memcpy_user ); PROVIDE_UACCESS_INLINE ( flat, memmove_user ); PROVIDE_UACCESS_INLINE ( flat, memset_user ); diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index efc38dd21..805feee3d 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -807,7 +807,7 @@ static inline __attribute__ (( always_inline )) userptr_t gve_buffer ( struct gve_queue *queue, unsigned int index ) { /* Pages are currently allocated as a single contiguous block */ - return userptr_add ( queue->qpl.data, gve_address ( queue, index ) ); + return ( queue->qpl.data + gve_address ( queue, index ) ); } /** diff --git a/src/image/gzip.c b/src/image/gzip.c index 98376e113..116d912d7 100644 --- a/src/image/gzip.c +++ b/src/image/gzip.c @@ -111,7 +111,7 @@ static int gzip_extract ( struct image *image, struct image *extracted ) { } /* Initialise input chunk */ - deflate_chunk_init ( &in, userptr_add ( image->data, offset ), 0, len ); + deflate_chunk_init ( &in, ( image->data + offset ), 0, len ); /* Presize extracted image */ if ( ( rc = image_set_len ( extracted, diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 1e31afd9c..790c75123 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -69,17 +69,6 @@ UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( linux, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( linux, userptr_diff ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_diff ( userptr, subtrahend ); -} - static inline __always_inline void UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 1790e4066..93dc60d62 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -65,30 +65,6 @@ trivial_user_to_virt ( userptr_t userptr, off_t offset ) { return ( ( void * ) userptr + offset ); } -/** - * Add offset to user pointer - * - * @v userptr User pointer - * @v offset Offset - * @ret userptr New pointer value - */ -static inline __always_inline userptr_t -trivial_userptr_add ( userptr_t userptr, off_t offset ) { - return ( userptr + offset ); -} - -/** - * Subtract user pointers - * - * @v userptr User pointer - * @v subtrahend User pointer to be subtracted - * @ret offset Offset - */ -static inline __always_inline off_t -trivial_userptr_diff ( userptr_t userptr, userptr_t subtrahend ) { - return ( userptr - subtrahend ); -} - /** * Copy data between user buffers * @@ -231,17 +207,6 @@ UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( flat, userptr_add ) ( userptr_t userptr, off_t offset ) { - return trivial_userptr_add ( userptr, offset ); -} - -static inline __always_inline off_t -UACCESS_INLINE ( flat, userptr_diff ) ( userptr_t userptr, - userptr_t subtrahend ) { - return trivial_userptr_diff ( userptr, subtrahend ); -} - static inline __always_inline void UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, @@ -322,24 +287,6 @@ userptr_t virt_to_user ( volatile const void *addr ); */ void * user_to_virt ( userptr_t userptr, off_t offset ); -/** - * Add offset to user pointer - * - * @v userptr User pointer - * @v offset Offset - * @ret userptr New pointer value - */ -userptr_t userptr_add ( userptr_t userptr, off_t offset ); - -/** - * Subtract user pointers - * - * @v userptr User pointer - * @v subtrahend User pointer to be subtracted - * @ret offset Offset - */ -off_t userptr_diff ( userptr_t userptr, userptr_t subtrahend ); - /** * Convert virtual address to a physical address * diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index ea2d8057c..9fc99c5e2 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -30,7 +30,6 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, user_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); PROVIDE_UACCESS_INLINE(linux, user_to_virt); -PROVIDE_UACCESS_INLINE(linux, userptr_add); PROVIDE_UACCESS_INLINE(linux, memcpy_user); PROVIDE_UACCESS_INLINE(linux, memmove_user); PROVIDE_UACCESS_INLINE(linux, memset_user); -- cgit v1.2.3-55-g7522 From 89fe7886897be76ed902317e311d60ae654057aa Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 20 Apr 2025 18:29:48 +0100 Subject: [uaccess] Remove redundant memcpy_user() and related string functions The memcpy_user(), memmove_user(), memcmp_user(), memset_user(), and strlen_user() functions are now just straightforward wrappers around the corresponding standard library functions. Remove these redundant wrappers. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 2 +- src/arch/x86/image/bzimage.c | 13 +- src/arch/x86/image/com32.c | 2 +- src/arch/x86/image/comboot.c | 4 +- src/arch/x86/image/initrd.c | 12 +- src/arch/x86/image/multiboot.c | 6 +- src/arch/x86/image/nbi.c | 2 +- src/arch/x86/image/pxe_image.c | 2 +- src/arch/x86/image/sdi.c | 4 +- src/arch/x86/image/ucode.c | 2 +- src/arch/x86/include/librm.h | 32 ----- src/arch/x86/interface/pcbios/memtop_umalloc.c | 4 +- src/arch/x86/interface/pxe/pxe_file.c | 6 +- src/arch/x86/interface/syslinux/com32_call.c | 20 ++- src/arch/x86/interface/syslinux/comboot_call.c | 20 +-- src/arch/x86/transitions/librm_mgmt.c | 8 +- src/core/fbcon.c | 24 ++-- src/core/image.c | 2 +- src/core/uaccess.c | 4 - src/crypto/deflate.c | 4 +- src/drivers/net/exanic.c | 2 +- src/drivers/net/gve.c | 2 +- src/drivers/usb/xhci.c | 2 +- src/image/elf.c | 2 +- src/image/segment.c | 2 +- src/include/ipxe/linux/linux_uaccess.h | 32 ----- src/include/ipxe/uaccess.h | 166 +------------------------ src/interface/efi/efi_fbcon.c | 4 +- src/interface/efi/efi_umalloc.c | 4 +- src/interface/linux/linux_uaccess.c | 4 - src/interface/smbios/smbios.c | 2 +- src/tests/cms_test.c | 4 +- src/tests/gzip_test.c | 5 +- src/tests/pixbuf_test.c | 5 +- src/tests/zlib_test.c | 5 +- 35 files changed, 83 insertions(+), 331 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 02072b5bf..2b803f772 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -125,7 +125,7 @@ static int cmdline_init ( void ) { return 0; } cmdline_user = phys_to_user ( cmdline_phys ); - len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ ); + len = ( strlen ( cmdline_user ) + 1 /* NUL */ ); /* Allocate and copy command line */ cmdline_copy = malloc ( len ); diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index d00b9f155..29ebeb507 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -369,8 +369,8 @@ static size_t bzimage_load_initrd ( struct image *image, /* Copy in initrd image body and construct any cpio headers */ if ( address ) { - memmove_user ( address, len, initrd->data, 0, initrd->len ); - memset_user ( address, 0, 0, len ); + memmove ( ( address + len ), initrd->data, initrd->len ); + memset ( address, 0, len ); offset = 0; for ( i = 0 ; ( cpio_len = cpio_header ( initrd, i, &cpio ) ) ; i++ ) { @@ -395,7 +395,7 @@ static size_t bzimage_load_initrd ( struct image *image, /* Zero-pad to next INITRD_ALIGN boundary */ pad_len = ( ( -len ) & ( INITRD_ALIGN - 1 ) ); if ( address ) - memset_user ( address, len, 0, pad_len ); + memset ( ( address + len ), 0, pad_len ); return len; } @@ -562,10 +562,9 @@ static int bzimage_exec ( struct image *image ) { unregister_image ( image_get ( image ) ); /* Load segments */ - memcpy_user ( bzimg.rm_kernel, 0, image->data, - 0, bzimg.rm_filesz ); - memcpy_user ( bzimg.pm_kernel, 0, image->data, - bzimg.rm_filesz, bzimg.pm_sz ); + memcpy ( bzimg.rm_kernel, image->data, bzimg.rm_filesz ); + memcpy ( bzimg.pm_kernel, ( image->data + bzimg.rm_filesz ), + bzimg.pm_sz ); /* Store command line */ bzimage_set_cmdline ( image, &bzimg ); diff --git a/src/arch/x86/image/com32.c b/src/arch/x86/image/com32.c index 6f0e66041..3e38215cb 100644 --- a/src/arch/x86/image/com32.c +++ b/src/arch/x86/image/com32.c @@ -219,7 +219,7 @@ static int com32_load_image ( struct image *image ) { } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, 0, filesz ); + memcpy ( buffer, image->data, filesz ); return 0; } diff --git a/src/arch/x86/image/comboot.c b/src/arch/x86/image/comboot.c index 9a847f0ff..8609eb0f7 100644 --- a/src/arch/x86/image/comboot.c +++ b/src/arch/x86/image/comboot.c @@ -267,10 +267,10 @@ static int comboot_prepare_segment ( struct image *image ) } /* Zero PSP */ - memset_user ( seg_userptr, 0, 0, 0x100 ); + memset ( seg_userptr, 0, 0x100 ); /* Copy image to segment:0100 */ - memcpy_user ( seg_userptr, 0x100, image->data, 0, image->len ); + memcpy ( ( seg_userptr + 0x100 ), image->data, image->len ); return 0; } diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index e32e40341..95f12d804 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -80,7 +80,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) { user_to_phys ( highest->data, highest->len ), user_to_phys ( current, 0 ), user_to_phys ( current, highest->len ) ); - memmove_user ( current, 0, highest->data, 0, highest->len ); + memmove ( current, highest->data, highest->len ); highest->data = current; } @@ -96,8 +96,7 @@ static userptr_t initrd_squash_high ( userptr_t top ) { user_to_phys ( initrd->data, initrd->len ), user_to_phys ( current, 0 ), user_to_phys ( current, initrd->len ) ); - memcpy_user ( current, 0, initrd->data, 0, - initrd->len ); + memcpy ( current, initrd->data, initrd->len ); initrd->data = current; } } @@ -140,9 +139,10 @@ static void initrd_swap ( struct image *low, struct image *high, ~( INITRD_ALIGN - 1 ) ); /* Swap fragments */ - memcpy_user ( free, 0, high->data, len, frag_len ); - memmove_user ( low->data, new_len, low->data, len, low->len ); - memcpy_user ( low->data, len, free, 0, frag_len ); + memcpy ( free, ( high->data + len ), frag_len ); + memmove ( ( low->data + new_len ), ( low->data + len ), + low->len ); + memcpy ( ( low->data + len ), free, frag_len ); len = new_len; } diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index cada021ab..fe21f1f1a 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -222,8 +222,8 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, } /* Copy module */ - memcpy_user ( phys_to_user ( start ), 0, - module_image->data, 0, module_image->len ); + memcpy ( phys_to_user ( start ), module_image->data, + module_image->len ); /* Add module to list */ module = &modules[mbinfo->mods_count++]; @@ -350,7 +350,7 @@ static int multiboot_load_raw ( struct image *image, } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, offset, filesz ); + memcpy ( buffer, ( image->data + offset ), filesz ); /* Record execution entry point and maximum used address */ *entry = hdr->mb.entry_addr; diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 2f0d3164a..0b02a8985 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -131,7 +131,7 @@ static int nbi_prepare_segment ( struct image *image, size_t offset __unused, static int nbi_load_segment ( struct image *image, size_t offset, userptr_t dest, size_t filesz, size_t memsz __unused ) { - memcpy_user ( dest, 0, image->data, offset, filesz ); + memcpy ( dest, ( image->data + offset ), filesz ); return 0; } diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index b6bcb18b4..bdce165ca 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -66,7 +66,7 @@ static int pxe_exec ( struct image *image ) { } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, 0, image->len ); + memcpy ( buffer, image->data, image->len ); /* Arbitrarily pick the most recently opened network device */ if ( ( netdev = last_opened_netdev() ) == NULL ) { diff --git a/src/arch/x86/image/sdi.c b/src/arch/x86/image/sdi.c index fa2d0b73f..5bb5a7569 100644 --- a/src/arch/x86/image/sdi.c +++ b/src/arch/x86/image/sdi.c @@ -97,8 +97,8 @@ static int sdi_exec ( struct image *image ) { user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size ); /* Copy boot code */ - memcpy_user ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), 0, - image->data, sdi.boot_offset, sdi.boot_size ); + memcpy ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), + ( image->data + sdi.boot_offset ), sdi.boot_size ); /* Jump to boot code */ sdiptr = ( user_to_phys ( image->data, 0 ) | SDI_WTF ); diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c index 499c0a940..9b6b5067a 100644 --- a/src/arch/x86/image/ucode.c +++ b/src/arch/x86/image/ucode.c @@ -256,7 +256,7 @@ static int ucode_update_all ( struct image *image, rc = -ENOMEM; goto err_alloc; } - memset_user ( status, 0, 0, len ); + memset ( status, 0, len ); /* Construct control structure */ memset ( &control, 0, sizeof ( control ) ); diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index c0d910287..c117a8b5c 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -137,38 +137,6 @@ UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline void -UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( librm, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index e76b3df93..8239b23b8 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -203,8 +203,8 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { user_to_phys ( ptr, extmem.size ), user_to_phys ( new, 0 ), user_to_phys ( new, new_size )); - memmove_user ( new, 0, ptr, 0, ( ( extmem.size < new_size ) ? - extmem.size : new_size ) ); + memmove ( new, ptr, ( ( extmem.size < new_size ) ? + extmem.size : new_size ) ); bottom = new; heap_size -= ( new_size - extmem.size ); extmem.size = new_size; diff --git a/src/arch/x86/interface/pxe/pxe_file.c b/src/arch/x86/interface/pxe/pxe_file.c index 456ffb5fd..1235520de 100644 --- a/src/arch/x86/interface/pxe/pxe_file.c +++ b/src/arch/x86/interface/pxe/pxe_file.c @@ -61,8 +61,8 @@ static PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open ) { /* Copy name from external program, and open it */ filename = real_to_user ( file_open->FileName.segment, - file_open->FileName.offset ); - filename_len = strlen_user ( filename, 0 ); + file_open->FileName.offset ); + filename_len = strlen ( filename ); { char uri_string[ filename_len + 1 ]; @@ -219,7 +219,7 @@ static PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) { /* Copy name from external program, and exec it */ command = real_to_user ( file_exec->Command.segment, file_exec->Command.offset ); - command_len = strlen_user ( command, 0 ); + command_len = strlen ( command ); { char command_string[ command_len + 1 ]; diff --git a/src/arch/x86/interface/syslinux/com32_call.c b/src/arch/x86/interface/syslinux/com32_call.c index 19fdbaff9..da9d6491a 100644 --- a/src/arch/x86/interface/syslinux/com32_call.c +++ b/src/arch/x86/interface/syslinux/com32_call.c @@ -49,9 +49,8 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad DBGC ( &com32_regs, "COM32 INT%x in %#08lx out %#08lx\n", interrupt, inregs_phys, outregs_phys ); - memcpy_user ( virt_to_user( &com32_regs ), 0, - phys_to_user ( inregs_phys ), 0, - sizeof(com32sys_t) ); + memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + sizeof ( com32sys_t ) ); com32_int_vector = interrupt; @@ -108,9 +107,8 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad : : ); if ( outregs_phys ) { - memcpy_user ( phys_to_user ( outregs_phys ), 0, - virt_to_user( &com32_regs ), 0, - sizeof(com32sys_t) ); + memcpy ( phys_to_user ( outregs_phys ), + virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } @@ -122,9 +120,8 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t DBGC ( &com32_regs, "COM32 farcall %04x:%04x in %#08lx out %#08lx\n", ( proc >> 16 ), ( proc & 0xffff ), inregs_phys, outregs_phys ); - memcpy_user ( virt_to_user( &com32_regs ), 0, - phys_to_user ( inregs_phys ), 0, - sizeof(com32sys_t) ); + memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + sizeof ( com32sys_t ) ); com32_farcall_proc = proc; @@ -170,9 +167,8 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t : : ); if ( outregs_phys ) { - memcpy_user ( phys_to_user ( outregs_phys ), 0, - virt_to_user( &com32_regs ), 0, - sizeof(com32sys_t) ); + memcpy ( phys_to_user ( outregs_phys ), + virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index b75e8ef7c..f26fcad0a 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -119,7 +119,7 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig if ( shuf[ i ].src == 0xFFFFFFFF ) { /* Fill with 0 instead of copying */ - memset_user ( dest_u, 0, 0, shuf[ i ].len ); + memset ( dest_u, 0, shuf[ i ].len ); } else if ( shuf[ i ].dest == 0xFFFFFFFF ) { /* Copy new list of descriptors */ count = shuf[ i ].len / sizeof( comboot_shuffle_descriptor ); @@ -128,7 +128,7 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig i = -1; } else { /* Regular copy */ - memmove_user ( dest_u, 0, src_u, 0, shuf[ i ].len ); + memmove ( dest_u, src_u, shuf[ i ].len ); } } } @@ -347,7 +347,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { case 0x0003: /* Run command */ { userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); - int len = strlen_user ( cmd_u, 0 ); + int len = strlen ( cmd_u ); char cmd[len + 1]; copy_from_user ( cmd, cmd_u, 0, len + 1 ); DBG ( "COMBOOT: executing command '%s'\n", cmd ); @@ -371,7 +371,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { { int fd; userptr_t file_u = real_to_user ( ix86->segs.es, ix86->regs.si ); - int len = strlen_user ( file_u, 0 ); + int len = strlen ( file_u ); char file[len + 1]; copy_from_user ( file, file_u, 0, len + 1 ); @@ -484,7 +484,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { case 0x0010: /* Resolve hostname */ { userptr_t hostname_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); - int len = strlen_user ( hostname_u, 0 ); + int len = strlen ( hostname_u ); char hostname[len]; struct in_addr addr; @@ -551,8 +551,8 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { { userptr_t file_u = real_to_user ( ix86->segs.ds, ix86->regs.si ); userptr_t cmd_u = real_to_user ( ix86->segs.es, ix86->regs.bx ); - int file_len = strlen_user ( file_u, 0 ); - int cmd_len = strlen_user ( cmd_u, 0 ); + int file_len = strlen ( file_u ); + int cmd_len = strlen ( cmd_u ); char file[file_len + 1]; char cmd[cmd_len + 1]; @@ -595,9 +595,9 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx ); /* Copy initial register values to .text16 */ - memcpy_user ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), 0, - real_to_user ( ix86->segs.ds, ix86->regs.si ), 0, - sizeof(syslinux_rm_regs) ); + memcpy ( real_to_user ( rm_cs, (unsigned) __from_text16 ( &comboot_initial_regs ) ), + real_to_user ( ix86->segs.ds, ix86->regs.si ), + sizeof(syslinux_rm_regs) ); /* Load initial register values */ __asm__ __volatile__ ( diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index ec31fceb1..7ebf62137 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -69,7 +69,7 @@ uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) { userptr_t rm_stack; rm_sp -= size; rm_stack = real_to_user ( rm_ss, rm_sp ); - memcpy_user ( rm_stack, 0, data, 0, size ); + memcpy ( rm_stack, data, size ); return rm_sp; }; @@ -83,7 +83,7 @@ uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) { void remove_user_from_rm_stack ( userptr_t data, size_t size ) { if ( data ) { userptr_t rm_stack = real_to_user ( rm_ss, rm_sp ); - memcpy_user ( rm_stack, 0, data, 0, size ); + memcpy ( rm_stack, data, size ); } rm_sp += size; }; @@ -432,10 +432,6 @@ PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_virt ); -PROVIDE_UACCESS_INLINE ( librm, memcpy_user ); -PROVIDE_UACCESS_INLINE ( librm, memmove_user ); -PROVIDE_UACCESS_INLINE ( librm, memset_user ); -PROVIDE_UACCESS_INLINE ( librm, strlen_user ); PROVIDE_UACCESS_INLINE ( librm, memchr_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); PROVIDE_IOMAP ( pages, ioremap, ioremap_pages ); diff --git a/src/core/fbcon.c b/src/core/fbcon.c index ff3132ac7..8d05484e2 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -185,12 +185,12 @@ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell, /* Draw background picture, if applicable */ if ( transparent ) { if ( fbcon->picture.start ) { - memcpy_user ( fbcon->start, offset, - fbcon->picture.start, offset, - fbcon->character.len ); + memcpy ( ( fbcon->start + offset ), + ( fbcon->picture.start + offset ), + fbcon->character.len ); } else { - memset_user ( fbcon->start, offset, 0, - fbcon->character.len ); + memset ( ( fbcon->start + offset ), 0, + fbcon->character.len ); } } @@ -247,8 +247,8 @@ static void fbcon_scroll ( struct fbcon *fbcon ) { /* Scroll up character array */ row_len = ( fbcon->character.width * sizeof ( struct fbcon_text_cell )); - memmove_user ( fbcon->text.start, 0, fbcon->text.start, row_len, - ( row_len * ( fbcon->character.height - 1 ) ) ); + memmove ( fbcon->text.start, ( fbcon->text.start + row_len ), + ( row_len * ( fbcon->character.height - 1 ) ) ); fbcon_clear ( fbcon, ( fbcon->character.height - 1 ) ); /* Update cursor position */ @@ -552,7 +552,7 @@ static int fbcon_picture_init ( struct fbcon *fbcon, ( ygap + pixbuf->height ) ); /* Convert to frame buffer raw format */ - memset_user ( picture->start, 0, 0, len ); + memset ( picture->start, 0, len ); for ( y = 0 ; y < height ; y++ ) { offset = ( indent + ( y * pixel->stride ) ); pixbuf_offset = ( pixbuf_indent + ( y * pixbuf_stride ) ); @@ -684,7 +684,7 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, fbcon_clear ( fbcon, 0 ); /* Set framebuffer to all black (including margins) */ - memset_user ( fbcon->start, 0, 0, fbcon->len ); + memset ( fbcon->start, 0, fbcon->len ); /* Generate pixel buffer from background image, if applicable */ if ( config->pixbuf && @@ -692,10 +692,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, goto err_picture; /* Draw background picture (including margins), if applicable */ - if ( fbcon->picture.start ) { - memcpy_user ( fbcon->start, 0, fbcon->picture.start, 0, - fbcon->len ); - } + if ( fbcon->picture.start ) + memcpy ( fbcon->start, fbcon->picture.start, fbcon->len ); /* Update console width and height */ console_set_size ( fbcon->character.width, fbcon->character.height ); diff --git a/src/core/image.c b/src/core/image.c index c69c05c93..709d0da9c 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -246,7 +246,7 @@ int image_set_data ( struct image *image, userptr_t data, size_t len ) { return rc; /* Copy in new image data */ - memcpy_user ( image->data, 0, data, 0, len ); + memcpy ( image->data, data, len ); return 0; } diff --git a/src/core/uaccess.c b/src/core/uaccess.c index ad17a58ab..01089e6fa 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -36,8 +36,4 @@ PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_virt ); -PROVIDE_UACCESS_INLINE ( flat, memcpy_user ); -PROVIDE_UACCESS_INLINE ( flat, memmove_user ); -PROVIDE_UACCESS_INLINE ( flat, memset_user ); -PROVIDE_UACCESS_INLINE ( flat, strlen_user ); PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/crypto/deflate.c b/src/crypto/deflate.c index 7ad39ec1b..c6cce7516 100644 --- a/src/crypto/deflate.c +++ b/src/crypto/deflate.c @@ -464,8 +464,8 @@ static void deflate_copy ( struct deflate_chunk *out, if ( copy_len > len ) copy_len = len; while ( copy_len-- ) { - memcpy_user ( out->data, out_offset++, - start, offset++, 1 ); + memcpy ( ( out->data + out_offset++ ), + ( start + offset++ ), 1 ); } } out->offset += len; diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index aaa6a28a1..14a17df47 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -395,7 +395,7 @@ static int exanic_open ( struct net_device *netdev ) { } /* Reset receive region contents */ - memset_user ( port->rx, 0, 0xff, EXANIC_RX_LEN ); + memset ( port->rx, 0xff, EXANIC_RX_LEN ); /* Reset transmit feedback region */ *(port->txf) = 0; diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 805feee3d..2cbc401f5 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -980,7 +980,7 @@ static int gve_start ( struct gve_nic *gve ) { } /* Invalidate receive completions */ - memset_user ( rx->cmplt, 0, 0, ( rx->count * rx->type->cmplt_len ) ); + memset ( rx->cmplt, 0, ( rx->count * rx->type->cmplt_len ) ); /* Reset receive sequence */ gve->seq = gve_next ( 0 ); diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index 3247ee69c..f244086ce 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -1000,7 +1000,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { rc = -ENOMEM; goto err_alloc; } - memset_user ( scratch->buffer, 0, 0, buffer_len ); + memset ( scratch->buffer, 0, buffer_len ); /* Allocate scratchpad array */ array_len = ( scratch->count * sizeof ( scratch->array[0] ) ); diff --git a/src/image/elf.c b/src/image/elf.c index 5c2f9db25..46c9fe8eb 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -66,7 +66,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr, } /* Copy image to segment */ - memcpy_user ( buffer, 0, image->data, phdr->p_offset, phdr->p_filesz ); + memcpy ( buffer, ( image->data + phdr->p_offset ), phdr->p_filesz ); return 0; } diff --git a/src/image/segment.c b/src/image/segment.c index 2d0f2f0fc..b7f8ef56c 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -83,7 +83,7 @@ int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) { if ( ( start >= memmap.regions[i].start ) && ( end <= memmap.regions[i].end ) ) { /* Found valid region: zero bss and return */ - memset_user ( segment, filesz, 0, ( memsz - filesz ) ); + memset ( ( segment + filesz ), 0, ( memsz - filesz ) ); return 0; } } diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 790c75123..0c680c08f 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -69,38 +69,6 @@ UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline void -UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( linux, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( linux, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( linux, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( linux, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 93dc60d62..e84ca3eae 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -65,80 +65,6 @@ trivial_user_to_virt ( userptr_t userptr, off_t offset ) { return ( ( void * ) userptr + offset ); } -/** - * Copy data between user buffers - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -static inline __always_inline void -trivial_memcpy_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ) { - memcpy ( ( ( void * ) dest + dest_off ), - ( ( void * ) src + src_off ), len ); -} - -/** - * Copy data between user buffers, allowing for overlap - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -static inline __always_inline void -trivial_memmove_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ) { - memmove ( ( ( void * ) dest + dest_off ), - ( ( void * ) src + src_off ), len ); -} - -/** - * Compare data between user buffers - * - * @v first First buffer - * @v first_off First buffer offset - * @v second Second buffer - * @v second_off Second buffer offset - * @v len Length - * @ret diff Difference - */ -static inline __always_inline int -trivial_memcmp_user ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, size_t len ) { - return memcmp ( ( ( void * ) first + first_off ), - ( ( void * ) second + second_off ), len ); -} - -/** - * Fill user buffer with a constant byte - * - * @v buffer User buffer - * @v offset Offset within buffer - * @v c Constant byte with which to fill - * @v len Length - */ -static inline __always_inline void -trivial_memset_user ( userptr_t buffer, off_t offset, int c, size_t len ) { - memset ( ( ( void * ) buffer + offset ), c, len ); -} - -/** - * Find length of NUL-terminated string in user buffer - * - * @v buffer User buffer - * @v offset Offset within buffer - * @ret len Length of string (excluding NUL) - */ -static inline __always_inline size_t -trivial_strlen_user ( userptr_t buffer, off_t offset ) { - return strlen ( ( void * ) buffer + offset ); -} - /** * Find character in user buffer * @@ -207,38 +133,6 @@ UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) { return trivial_user_to_virt ( userptr, offset ); } -static inline __always_inline void -UACCESS_INLINE ( flat, memcpy_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memcpy_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline void -UACCESS_INLINE ( flat, memmove_user ) ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, - size_t len ) { - trivial_memmove_user ( dest, dest_off, src, src_off, len ); -} - -static inline __always_inline int -UACCESS_INLINE ( flat, memcmp_user ) ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, - size_t len ) { - return trivial_memcmp_user ( first, first_off, second, second_off, len); -} - -static inline __always_inline void -UACCESS_INLINE ( flat, memset_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - trivial_memset_user ( buffer, offset, c, len ); -} - -static inline __always_inline size_t -UACCESS_INLINE ( flat, strlen_user ) ( userptr_t buffer, off_t offset ) { - return trivial_strlen_user ( buffer, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { @@ -310,18 +204,6 @@ static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) { return user_to_virt ( phys_to_user ( phys_addr ), 0 ); } -/** - * Copy data between user buffers - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -void memcpy_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ); - /** * Copy data to user buffer * @@ -332,7 +214,7 @@ void memcpy_user ( userptr_t dest, off_t dest_off, */ static inline __always_inline void copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) { - memcpy_user ( dest, dest_off, virt_to_user ( src ), 0, len ); + memcpy ( ( dest + dest_off ), src, len ); } /** @@ -345,53 +227,9 @@ copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) { */ static inline __always_inline void copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) { - memcpy_user ( virt_to_user ( dest ), 0, src, src_off, len ); + memcpy ( dest, ( src + src_off ), len ); } -/** - * Copy data between user buffers, allowing for overlap - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v src_off Source offset - * @v len Length - */ -void memmove_user ( userptr_t dest, off_t dest_off, - userptr_t src, off_t src_off, size_t len ); - -/** - * Compare data between user buffers - * - * @v first First buffer - * @v first_off First buffer offset - * @v second Second buffer - * @v second_off Second buffer offset - * @v len Length - * @ret diff Difference - */ -int memcmp_user ( userptr_t first, off_t first_off, - userptr_t second, off_t second_off, size_t len ); - -/** - * Fill user buffer with a constant byte - * - * @v userptr User buffer - * @v offset Offset within buffer - * @v c Constant byte with which to fill - * @v len Length - */ -void memset_user ( userptr_t userptr, off_t offset, int c, size_t len ); - -/** - * Find length of NUL-terminated string in user buffer - * - * @v userptr User buffer - * @v offset Offset within buffer - * @ret len Length of string (excluding NUL) - */ -size_t strlen_user ( userptr_t userptr, off_t offset ); - /** * Find character in user buffer * diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index d388e0317..659ebd37e 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -124,7 +124,7 @@ static int efifb_draw ( unsigned int character, unsigned int index, /* Clear existing glyph */ offset = ( index * efifb.font.height ); - memset_user ( efifb.glyphs, offset, 0, efifb.font.height ); + memset ( ( efifb.glyphs + offset ), 0, efifb.font.height ); /* Get glyph */ blt = NULL; @@ -296,7 +296,7 @@ static int efifb_glyphs ( void ) { rc = -ENOMEM; goto err_alloc; } - memset_user ( efifb.glyphs, 0, 0, len ); + memset ( efifb.glyphs, 0, len ); /* Get font data */ for ( character = 0 ; character < EFIFB_ASCII ; character++ ) { diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 175ae367e..488c53f3d 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -87,8 +87,8 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { if ( old_ptr && ( old_ptr != UNOWHERE ) ) { copy_from_user ( &old_size, old_ptr, -EFI_PAGE_SIZE, sizeof ( old_size ) ); - memcpy_user ( new_ptr, 0, old_ptr, 0, - ( (old_size < new_size) ? old_size : new_size )); + memcpy ( new_ptr, old_ptr, + ( (old_size < new_size) ? old_size : new_size ) ); old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 ); phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE ); if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){ diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index 9fc99c5e2..d777bf3dd 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -30,8 +30,4 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, user_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); PROVIDE_UACCESS_INLINE(linux, user_to_virt); -PROVIDE_UACCESS_INLINE(linux, memcpy_user); -PROVIDE_UACCESS_INLINE(linux, memmove_user); -PROVIDE_UACCESS_INLINE(linux, memset_user); -PROVIDE_UACCESS_INLINE(linux, strlen_user); PROVIDE_UACCESS_INLINE(linux, memchr_user); diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index fdd14499f..3e69a0c15 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -277,7 +277,7 @@ int read_smbios_string ( struct smbios_structure *structure, * smbios_strings struct is constructed so as to * always end on a string boundary. */ - string_len = strlen_user ( smbios.address, offset ); + string_len = strlen ( smbios.address + offset ); if ( --index == 0 ) { /* Copy string, truncating as necessary. */ if ( len > string_len ) diff --git a/src/tests/cms_test.c b/src/tests/cms_test.c index fc4f6bd19..debbfeee7 100644 --- a/src/tests/cms_test.c +++ b/src/tests/cms_test.c @@ -1773,8 +1773,8 @@ static void cms_decrypt_okx ( struct cms_test_image *img, /* Check decrypted image matches expected plaintext */ okx ( img->image.len == expected->image.len, file, line ); - okx ( memcmp_user ( img->image.data, 0, expected->image.data, 0, - expected->image.len ) == 0, file, line ); + okx ( memcmp ( img->image.data, expected->image.data, + expected->image.len ) == 0, file, line ); } #define cms_decrypt_ok( data, envelope, keypair, expected ) \ cms_decrypt_okx ( data, envelope, keypair, expected, \ diff --git a/src/tests/gzip_test.c b/src/tests/gzip_test.c index fa76edc53..9226b4c26 100644 --- a/src/tests/gzip_test.c +++ b/src/tests/gzip_test.c @@ -128,9 +128,8 @@ static void gzip_okx ( struct gzip_test *test, const char *file, /* Verify extracted image content */ okx ( extracted->len == test->expected_len, file, line ); - okx ( memcmp_user ( extracted->data, 0, - virt_to_user ( test->expected ), 0, - test->expected_len ) == 0, file, line ); + okx ( memcmp ( extracted->data, virt_to_user ( test->expected ), + test->expected_len ) == 0, file, line ); /* Verify extracted image name */ okx ( strcmp ( extracted->name, test->expected_name ) == 0, diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c index aaa516bb2..1f82e0018 100644 --- a/src/tests/pixbuf_test.c +++ b/src/tests/pixbuf_test.c @@ -71,9 +71,8 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file, /* Check pixel buffer data */ okx ( pixbuf->len == test->len, file, line ); - okx ( memcmp_user ( pixbuf->data, 0, - virt_to_user ( test->data ), 0, - test->len ) == 0, file, line ); + okx ( memcmp ( pixbuf->data, virt_to_user ( test->data ), + test->len ) == 0, file, line ); pixbuf_put ( pixbuf ); } diff --git a/src/tests/zlib_test.c b/src/tests/zlib_test.c index df52d09ac..2efdcbad8 100644 --- a/src/tests/zlib_test.c +++ b/src/tests/zlib_test.c @@ -103,9 +103,8 @@ static void zlib_okx ( struct zlib_test *test, const char *file, /* Verify extracted image content */ okx ( extracted->len == test->expected_len, file, line ); - okx ( memcmp_user ( extracted->data, 0, - virt_to_user ( test->expected ), 0, - test->expected_len ) == 0, file, line ); + okx ( memcmp ( extracted->data, virt_to_user ( test->expected ), + test->expected_len ) == 0, file, line ); /* Verify extracted image name */ okx ( strcmp ( extracted->name, test->expected_name ) == 0, -- cgit v1.2.3-55-g7522 From 4535548cba255c220719a55d02535e06da82ba47 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Apr 2025 00:15:52 +0100 Subject: [uaccess] Remove redundant user_to_virt() The user_to_virt() function is now a straightforward wrapper around addition, with the addend almost invariably being zero. Remove this redundant wrapper. Signed-off-by: Michael Brown --- src/arch/x86/image/bzimage.c | 4 ++-- src/arch/x86/image/initrd.c | 2 +- src/arch/x86/include/librm.h | 5 ----- src/arch/x86/transitions/librm_mgmt.c | 1 - src/core/fdt.c | 7 +++---- src/core/uaccess.c | 1 - src/image/efi_image.c | 8 ++++---- src/include/ipxe/linux/linux_uaccess.h | 5 ----- src/include/ipxe/uaccess.h | 32 +------------------------------- src/interface/efi/efi_pci.c | 2 +- src/interface/linux/linux_acpi.c | 2 +- src/interface/linux/linux_smbios.c | 2 +- src/interface/linux/linux_sysfs.c | 3 +-- src/interface/linux/linux_uaccess.c | 1 - 14 files changed, 15 insertions(+), 60 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index 29ebeb507..32598525f 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -388,7 +388,7 @@ static size_t bzimage_load_initrd ( struct image *image, user_to_phys ( address, ( offset + initrd->len ) ), ( filename ? " " : "" ), ( filename ? filename : "" ) ); DBGC2_MD5A ( image, user_to_phys ( address, offset ), - user_to_virt ( address, offset ), initrd->len ); + ( address + offset ), initrd->len ); } len += initrd->len; @@ -427,7 +427,7 @@ static int bzimage_check_initrds ( struct image *image, ( initrd->cmdline ? " " : "" ), ( initrd->cmdline ? initrd->cmdline : "" ) ); DBGC2_MD5A ( image, user_to_phys ( initrd->data, 0 ), - user_to_virt ( initrd->data, 0 ), initrd->len ); + initrd->data, initrd->len ); } /* Calculate lowest usable address */ diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index 95f12d804..bcf95deef 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -211,7 +211,7 @@ static void initrd_dump ( void ) { initrd->name, user_to_phys ( initrd->data, 0 ), user_to_phys ( initrd->data, initrd->len ) ); DBGC2_MD5A ( &images, user_to_phys ( initrd->data, 0 ), - user_to_virt ( initrd->data, 0 ), initrd->len ); + initrd->data, initrd->len ); } } diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index c117a8b5c..9ed91022e 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -132,11 +132,6 @@ UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) { return trivial_virt_to_user ( addr ); } -static inline __always_inline void * -UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) { - return trivial_user_to_virt ( userptr, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index 7ebf62137..82e8eab39 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -431,7 +431,6 @@ void setup_sipi ( unsigned int vector, uint32_t handler, PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); -PROVIDE_UACCESS_INLINE ( librm, user_to_virt ); PROVIDE_UACCESS_INLINE ( librm, memchr_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); PROVIDE_IOMAP ( pages, ioremap, ioremap_pages ); diff --git a/src/core/fdt.c b/src/core/fdt.c index 54f930286..4c709b342 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -734,8 +734,7 @@ static int fdt_parse_image ( struct fdt *fdt, struct image *image ) { int rc; /* Parse image */ - if ( ( rc = fdt_parse ( fdt, user_to_virt ( image->data, 0 ), - image->len ) ) != 0 ) { + if ( ( rc = fdt_parse ( fdt, image->data, image->len ) ) != 0 ) { DBGC ( fdt, "FDT image \"%s\" is invalid: %s\n", image->name, strerror ( rc ) ); return rc; @@ -1038,7 +1037,7 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) { assert ( len >= fdt->used ); /* Attempt reallocation */ - new = user_to_virt ( urealloc ( virt_to_user ( fdt->raw ), len ), 0 ); + new = urealloc ( virt_to_user ( fdt->raw ), len ); if ( ! new ) { DBGC ( fdt, "FDT could not reallocate from +%#04zx to " "+%#04zx\n", fdt->len, len ); @@ -1112,7 +1111,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { } /* Create modifiable copy */ - copy = user_to_virt ( umalloc ( fdt.len ), 0 ); + copy = umalloc ( fdt.len ); if ( ! copy ) { rc = -ENOMEM; goto err_alloc; diff --git a/src/core/uaccess.c b/src/core/uaccess.c index 01089e6fa..1c33c10b8 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -35,5 +35,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); -PROVIDE_UACCESS_INLINE ( flat, user_to_virt ); PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/image/efi_image.c b/src/image/efi_image.c index c87196487..2b0ff567a 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -245,8 +245,8 @@ static int efi_image_exec ( struct image *image ) { /* Attempt loading image */ handle = NULL; if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path, - user_to_virt ( exec->data, 0 ), - exec->len, &handle ) ) != 0 ) { + exec->data, exec->len, + &handle ) ) != 0 ) { /* Not an EFI image */ rc = -EEFI_LOAD ( efirc ); DBGC ( image, "EFIIMAGE %s could not load: %s\n", @@ -379,8 +379,8 @@ static int efi_image_probe ( struct image *image ) { /* Attempt loading image */ handle = NULL; if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, &empty_path, - user_to_virt ( image->data, 0 ), - image->len, &handle ) ) != 0 ) { + image->data, image->len, + &handle ) ) != 0 ) { /* Not an EFI image */ rc = -EEFI_LOAD ( efirc ); DBGC ( image, "EFIIMAGE %s could not load: %s\n", diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 0c680c08f..4b1257b1e 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -64,11 +64,6 @@ UACCESS_INLINE ( linux, virt_to_user ) ( volatile const void *addr ) { return trivial_virt_to_user ( addr ); } -static inline __always_inline void * -UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) { - return trivial_user_to_virt ( userptr, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index e84ca3eae..4b3524bab 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -51,20 +51,6 @@ trivial_virt_to_user ( volatile const void *addr ) { return ( ( userptr_t ) addr ); } -/** - * Convert user pointer to virtual address - * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret addr Virtual address - * - * This operation is not available under all memory models. - */ -static inline __always_inline void * -trivial_user_to_virt ( userptr_t userptr, off_t offset ) { - return ( ( void * ) userptr + offset ); -} - /** * Find character in user buffer * @@ -128,11 +114,6 @@ UACCESS_INLINE ( flat, virt_to_user ) ( volatile const void *addr ) { return trivial_virt_to_user ( addr ); } -static inline __always_inline void * -UACCESS_INLINE ( flat, user_to_virt ) ( userptr_t userptr, off_t offset ) { - return trivial_user_to_virt ( userptr, offset ); -} - static inline __always_inline off_t UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, int c, size_t len ) { @@ -170,17 +151,6 @@ unsigned long user_to_phys ( userptr_t userptr, off_t offset ); */ userptr_t virt_to_user ( volatile const void *addr ); -/** - * Convert user pointer to virtual address - * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret addr Virtual address - * - * This operation is not available under all memory models. - */ -void * user_to_virt ( userptr_t userptr, off_t offset ); - /** * Convert virtual address to a physical address * @@ -201,7 +171,7 @@ virt_to_phys ( volatile const void *addr ) { * This operation is not available under all memory models. */ static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) { - return user_to_virt ( phys_to_user ( phys_addr ), 0 ); + return ( phys_to_user ( phys_addr ) ); } /** diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index dd11dd342..01351df51 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -669,7 +669,7 @@ static userptr_t efipci_dma_umalloc ( struct dma_device *dma, static void efipci_dma_ufree ( struct dma_device *dma, struct dma_mapping *map, userptr_t addr, size_t len ) { - efipci_dma_free ( dma, map, user_to_virt ( addr, 0 ), len ); + efipci_dma_free ( dma, map, addr, len ); } /** diff --git a/src/interface/linux/linux_acpi.c b/src/interface/linux/linux_acpi.c index e658936f2..846db2f1f 100644 --- a/src/interface/linux/linux_acpi.c +++ b/src/interface/linux/linux_acpi.c @@ -101,7 +101,7 @@ static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) { filename, strerror ( rc ) ); goto err_read; } - header = user_to_virt ( table->data, 0 ); + header = table->data; if ( ( ( ( size_t ) len ) < sizeof ( *header ) ) || ( ( ( size_t ) len ) < le32_to_cpu ( header->length ) ) ) { rc = -ENOENT; diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c index 981873943..abe1b19d7 100644 --- a/src/interface/linux/linux_smbios.c +++ b/src/interface/linux/linux_smbios.c @@ -59,7 +59,7 @@ static int linux_find_smbios ( struct smbios *smbios ) { smbios_entry_filename, strerror ( rc ) ); goto err_entry; } - data = user_to_virt ( entry, 0 ); + data = entry; smbios3_entry = data; smbios_entry = data; if ( ( len >= ( ( int ) sizeof ( *smbios3_entry ) ) ) && diff --git a/src/interface/linux/linux_sysfs.c b/src/interface/linux/linux_sysfs.c index 4f0027cd4..cbb23d81d 100644 --- a/src/interface/linux/linux_sysfs.c +++ b/src/interface/linux/linux_sysfs.c @@ -70,8 +70,7 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) { *data = tmp; /* Read from file */ - read = linux_read ( fd, user_to_virt ( *data, len ), - LINUX_SYSFS_BLKSIZE ); + read = linux_read ( fd, ( *data + len ), LINUX_SYSFS_BLKSIZE ); if ( read == 0 ) break; if ( read < 0 ) { diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index d777bf3dd..e5c394365 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -29,5 +29,4 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, user_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); -PROVIDE_UACCESS_INLINE(linux, user_to_virt); PROVIDE_UACCESS_INLINE(linux, memchr_user); -- cgit v1.2.3-55-g7522 From 8c31270a21a85cc87bce0e07e19e2041d2510a4c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Apr 2025 16:16:01 +0100 Subject: [uaccess] Remove user_to_phys() and phys_to_user() Remove the intermediate concept of a user pointer from physical address conversions, leaving virt_to_phys() and phys_to_virt() as the directly implemented functions. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 4 +-- src/arch/x86/core/vram_settings.c | 2 +- src/arch/x86/image/bzimage.c | 36 ++++++++++---------- src/arch/x86/image/com32.c | 2 +- src/arch/x86/image/initrd.c | 32 +++++++++--------- src/arch/x86/image/multiboot.c | 6 ++-- src/arch/x86/image/nbi.c | 4 +-- src/arch/x86/image/sdi.c | 9 ++--- src/arch/x86/image/ucode.c | 11 +++--- src/arch/x86/include/librm.h | 25 +++++++------- src/arch/x86/include/realmode.h | 2 +- src/arch/x86/interface/pcbios/bios_cachedhcp.c | 2 +- src/arch/x86/interface/pcbios/bios_smbios.c | 4 +-- src/arch/x86/interface/pcbios/int13.c | 6 ++-- src/arch/x86/interface/pcbios/memtop_umalloc.c | 30 ++++++++-------- src/arch/x86/interface/pcbios/rsdp.c | 8 ++--- src/arch/x86/interface/pcbios/vesafb.c | 2 +- src/arch/x86/interface/pxe/pxe_tftp.c | 2 +- src/arch/x86/interface/syslinux/com32_call.c | 10 +++--- src/arch/x86/interface/syslinux/comboot_call.c | 4 +-- src/arch/x86/transitions/librm_mgmt.c | 4 +-- src/core/acpi.c | 24 ++++++------- src/core/blocktrans.c | 2 +- src/core/cachedhcp.c | 2 +- src/core/fbcon.c | 4 +-- src/core/image.c | 4 +-- src/core/uaccess.c | 4 +-- src/drivers/block/srp.c | 4 +-- src/drivers/infiniband/arbel.c | 4 +-- src/drivers/infiniband/golan.c | 4 +-- src/drivers/infiniband/golan.h | 4 +-- src/drivers/infiniband/hermon.c | 4 +-- src/drivers/net/exanic.c | 6 ++-- src/drivers/net/gve.c | 27 +++++++-------- src/drivers/net/thunderx.c | 21 ++++++------ src/drivers/usb/xhci.c | 7 ++-- src/hci/commands/image_mem_cmd.c | 2 +- src/image/elf.c | 2 +- src/image/segment.c | 6 ++-- src/include/ipxe/linux/linux_uaccess.h | 34 +++++++++---------- src/include/ipxe/uaccess.h | 47 +++++++------------------- src/interface/efi/efi_acpi.c | 2 +- src/interface/efi/efi_fbcon.c | 2 +- src/interface/efi/efi_smbios.c | 8 ++--- src/interface/efi/efi_umalloc.c | 4 +-- src/interface/hyperv/vmbus.c | 2 +- src/interface/linux/linux_uaccess.c | 3 +- src/interface/smbios/smbios.c | 8 ++--- 48 files changed, 211 insertions(+), 235 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 2b803f772..2d2a10674 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -124,7 +124,7 @@ static int cmdline_init ( void ) { DBGC ( colour, "RUNTIME found no command line\n" ); return 0; } - cmdline_user = phys_to_user ( cmdline_phys ); + cmdline_user = phys_to_virt ( cmdline_phys ); len = ( strlen ( cmdline_user ) + 1 /* NUL */ ); /* Allocate and copy command line */ @@ -193,7 +193,7 @@ static int initrd_init ( void ) { initrd_phys, ( initrd_phys + initrd_len ) ); /* Create initrd image */ - image = image_memory ( "", phys_to_user ( initrd_phys ), + image = image_memory ( "", phys_to_virt ( initrd_phys ), initrd_len ); if ( ! image ) { DBGC ( colour, "RUNTIME could not create initrd image\n" ); diff --git a/src/arch/x86/core/vram_settings.c b/src/arch/x86/core/vram_settings.c index 9c169b40c..ceeada467 100644 --- a/src/arch/x86/core/vram_settings.c +++ b/src/arch/x86/core/vram_settings.c @@ -47,7 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret len Length of setting data, or negative error */ static int vram_fetch ( void *data, size_t len ) { - userptr_t vram = phys_to_user ( VRAM_BASE ); + userptr_t vram = phys_to_virt ( VRAM_BASE ); /* Copy video RAM */ if ( len > VRAM_LEN ) diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index 32598525f..0f373c1c8 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -169,7 +169,7 @@ static int bzimage_parse_header ( struct image *image, bzimg->rm_memsz += BZI_CMDLINE_SIZE; /* Calculate load address of protected-mode portion */ - bzimg->pm_kernel = phys_to_user ( is_bzimage ? BZI_LOAD_HIGH_ADDR + bzimg->pm_kernel = phys_to_virt ( is_bzimage ? BZI_LOAD_HIGH_ADDR : BZI_LOAD_LOW_ADDR ); /* Extract video mode */ @@ -185,8 +185,8 @@ static int bzimage_parse_header ( struct image *image, DBGC ( image, "bzImage %p version %04x RM %#lx+%#zx PM %#lx+%#zx " "cmdlen %zd\n", image, bzimg->version, - user_to_phys ( bzimg->rm_kernel, 0 ), bzimg->rm_filesz, - user_to_phys ( bzimg->pm_kernel, 0 ), bzimg->pm_sz, + virt_to_phys ( bzimg->rm_kernel ), bzimg->rm_filesz, + virt_to_phys ( bzimg->pm_kernel ), bzimg->pm_sz, bzimg->cmdline_size ); return 0; @@ -215,8 +215,8 @@ static void bzimage_update_header ( struct image *image, /* Set command line */ if ( bzimg->version >= 0x0202 ) { - bzimg->bzhdr.cmd_line_ptr = user_to_phys ( bzimg->rm_kernel, - bzimg->rm_cmdline ); + bzimg->bzhdr.cmd_line_ptr = ( virt_to_phys ( bzimg->rm_kernel ) + + bzimg->rm_cmdline ); } else { bzimg->cmdline_magic.magic = BZI_CMDLINE_MAGIC; bzimg->cmdline_magic.offset = bzimg->rm_cmdline; @@ -383,11 +383,11 @@ static size_t bzimage_load_initrd ( struct image *image, } assert ( offset == len ); DBGC ( image, "bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)" - "%s%s\n", image, initrd, user_to_phys ( address, 0 ), - user_to_phys ( address, offset ), - user_to_phys ( address, ( offset + initrd->len ) ), + "%s%s\n", image, initrd, virt_to_phys ( address ), + ( virt_to_phys ( address ) + offset ), + ( virt_to_phys ( address ) + offset + initrd->len ), ( filename ? " " : "" ), ( filename ? filename : "" ) ); - DBGC2_MD5A ( image, user_to_phys ( address, offset ), + DBGC2_MD5A ( image, ( virt_to_phys ( address ) + offset ), ( address + offset ), initrd->len ); } len += initrd->len; @@ -422,11 +422,11 @@ static int bzimage_check_initrds ( struct image *image, len = bzimage_align ( len ); DBGC ( image, "bzImage %p initrd %p from [%#08lx,%#08lx)%s%s\n", - image, initrd, user_to_phys ( initrd->data, 0 ), - user_to_phys ( initrd->data, initrd->len ), + image, initrd, virt_to_phys ( initrd->data ), + ( virt_to_phys ( initrd->data ) + initrd->len ), ( initrd->cmdline ? " " : "" ), ( initrd->cmdline ? initrd->cmdline : "" ) ); - DBGC2_MD5A ( image, user_to_phys ( initrd->data, 0 ), + DBGC2_MD5A ( image, virt_to_phys ( initrd->data ), initrd->data, initrd->len ); } @@ -445,7 +445,7 @@ static int bzimage_check_initrds ( struct image *image, } /* Check that total length fits within kernel's memory limit */ - if ( user_to_phys ( bottom, len ) > bzimg->mem_limit ) { + if ( ( virt_to_phys ( bottom ) + len ) > bzimg->mem_limit ) { DBGC ( image, "bzImage %p not enough space for initrds\n", image ); return -ENOBUFS; @@ -485,12 +485,12 @@ static void bzimage_load_initrds ( struct image *image, /* Find highest usable address */ top = ( highest->data + bzimage_align ( highest->len ) ); - if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) { - top = phys_to_user ( ( bzimg->mem_limit + 1 ) & + if ( ( virt_to_phys ( top ) - 1UL ) > bzimg->mem_limit ) { + top = phys_to_virt ( ( bzimg->mem_limit + 1 ) & ~( INITRD_ALIGN - 1 ) ); } DBGC ( image, "bzImage %p loading initrds from %#08lx downwards\n", - image, user_to_phys ( top, -1 ) ); + image, ( virt_to_phys ( top ) - 1UL ) ); /* Load initrds in order */ for_each_image ( initrd ) { @@ -512,8 +512,8 @@ static void bzimage_load_initrds ( struct image *image, /* Record initrd location */ if ( ! bzimg->ramdisk_image ) - bzimg->ramdisk_image = user_to_phys ( dest, 0 ); - bzimg->ramdisk_size = ( user_to_phys ( dest, len ) - + bzimg->ramdisk_image = virt_to_phys ( dest ); + bzimg->ramdisk_size = ( virt_to_phys ( dest ) + len - bzimg->ramdisk_image ); } DBGC ( image, "bzImage %p initrds at [%#08lx,%#08lx)\n", diff --git a/src/arch/x86/image/com32.c b/src/arch/x86/image/com32.c index 3e38215cb..a2b60987d 100644 --- a/src/arch/x86/image/com32.c +++ b/src/arch/x86/image/com32.c @@ -211,7 +211,7 @@ static int com32_load_image ( struct image *image ) { filesz = image->len; memsz = filesz; - buffer = phys_to_user ( COM32_START_PHYS ); + buffer = phys_to_virt ( COM32_START_PHYS ); if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) { DBGC ( image, "COM32 %p: could not prepare segment: %s\n", image, strerror ( rc ) ); diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index bcf95deef..fff40dd14 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -76,10 +76,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) { current -= len; DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", highest->name, - user_to_phys ( highest->data, 0 ), - user_to_phys ( highest->data, highest->len ), - user_to_phys ( current, 0 ), - user_to_phys ( current, highest->len ) ); + virt_to_phys ( highest->data ), + ( virt_to_phys ( highest->data ) + highest->len ), + virt_to_phys ( current ), + ( virt_to_phys ( current ) + highest->len ) ); memmove ( current, highest->data, highest->len ); highest->data = current; } @@ -92,10 +92,10 @@ static userptr_t initrd_squash_high ( userptr_t top ) { current -= len; DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", initrd->name, - user_to_phys ( initrd->data, 0 ), - user_to_phys ( initrd->data, initrd->len ), - user_to_phys ( current, 0 ), - user_to_phys ( current, initrd->len ) ); + virt_to_phys ( initrd->data ), + ( virt_to_phys ( initrd->data ) + initrd->len ), + virt_to_phys ( current ), + ( virt_to_phys ( current ) + initrd->len ) ); memcpy ( current, initrd->data, initrd->len ); initrd->data = current; } @@ -119,10 +119,10 @@ static void initrd_swap ( struct image *low, struct image *high, size_t new_len; DBGC ( &images, "INITRD swapping %s [%#08lx,%#08lx)<->[%#08lx,%#08lx) " - "%s\n", low->name, user_to_phys ( low->data, 0 ), - user_to_phys ( low->data, low->len ), - user_to_phys ( high->data, 0 ), - user_to_phys ( high->data, high->len ), high->name ); + "%s\n", low->name, virt_to_phys ( low->data ), + ( virt_to_phys ( low->data ) + low->len ), + virt_to_phys ( high->data ), + ( virt_to_phys ( high->data ) + high->len ), high->name ); /* Round down length of free space */ free_len &= ~( INITRD_ALIGN - 1 ); @@ -208,9 +208,9 @@ static void initrd_dump ( void ) { /* Dump initrd locations */ for_each_image ( initrd ) { DBGC ( &images, "INITRD %s at [%#08lx,%#08lx)\n", - initrd->name, user_to_phys ( initrd->data, 0 ), - user_to_phys ( initrd->data, initrd->len ) ); - DBGC2_MD5A ( &images, user_to_phys ( initrd->data, 0 ), + initrd->name, virt_to_phys ( initrd->data ), + ( virt_to_phys ( initrd->data ) + initrd->len ) ); + DBGC2_MD5A ( &images, virt_to_phys ( initrd->data ), initrd->data, initrd->len ); } } @@ -239,7 +239,7 @@ void initrd_reshuffle ( userptr_t bottom ) { /* Debug */ DBGC ( &images, "INITRD region [%#08lx,%#08lx)\n", - user_to_phys ( bottom, 0 ), user_to_phys ( top, 0 ) ); + virt_to_phys ( bottom ), virt_to_phys ( top ) ); initrd_dump(); /* Squash initrds as high as possible in memory */ diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index fe21f1f1a..24f67e02f 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -212,7 +212,7 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, start = ( ( start + 0xfff ) & ~0xfff ); /* Prepare segment */ - if ( ( rc = prep_segment ( phys_to_user ( start ), + if ( ( rc = prep_segment ( phys_to_virt ( start ), module_image->len, module_image->len ) ) != 0 ) { DBGC ( image, "MULTIBOOT %p could not prepare module " @@ -222,7 +222,7 @@ static int multiboot_add_modules ( struct image *image, physaddr_t start, } /* Copy module */ - memcpy ( phys_to_user ( start ), module_image->data, + memcpy ( phys_to_virt ( start ), module_image->data, module_image->len ); /* Add module to list */ @@ -342,7 +342,7 @@ static int multiboot_load_raw ( struct image *image, ( image->len - offset ) ); memsz = ( hdr->mb.bss_end_addr ? ( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz ); - buffer = phys_to_user ( hdr->mb.load_addr ); + buffer = phys_to_virt ( hdr->mb.load_addr ); if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) { DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n", image, strerror ( rc ) ); diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 0b02a8985..1f72c1287 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -181,7 +181,7 @@ static int nbi_process_segments ( struct image *image, /* Calculate segment load address */ switch ( NBI_LOADADDR_FLAGS ( sh.flags ) ) { case NBI_LOADADDR_ABS: - dest = phys_to_user ( sh.loadaddr ); + dest = phys_to_virt ( sh.loadaddr ); break; case NBI_LOADADDR_AFTER: dest = ( dest + memsz + sh.loadaddr ); @@ -194,7 +194,7 @@ static int nbi_process_segments ( struct image *image, * maintains backwards compatibility with * previous versions of Etherboot. */ - dest = phys_to_user ( ( extmemsize() + 1024 ) * 1024 + dest = phys_to_virt ( ( extmemsize() + 1024 ) * 1024 - sh.loadaddr ); break; default: diff --git a/src/arch/x86/image/sdi.c b/src/arch/x86/image/sdi.c index 5bb5a7569..5e22daeb3 100644 --- a/src/arch/x86/image/sdi.c +++ b/src/arch/x86/image/sdi.c @@ -92,16 +92,17 @@ static int sdi_exec ( struct image *image ) { return -ENOTTY; } DBGC ( image, "SDI %p image at %08lx+%08zx\n", - image, user_to_phys ( image->data, 0 ), image->len ); - DBGC ( image, "SDI %p boot code at %08lx+%llx\n", image, - user_to_phys ( image->data, sdi.boot_offset ), sdi.boot_size ); + image, virt_to_phys ( image->data ), image->len ); + DBGC ( image, "SDI %p boot code at %08llx+%llx\n", image, + ( virt_to_phys ( image->data ) + sdi.boot_offset ), + sdi.boot_size ); /* Copy boot code */ memcpy ( real_to_user ( SDI_BOOT_SEG, SDI_BOOT_OFF ), ( image->data + sdi.boot_offset ), sdi.boot_size ); /* Jump to boot code */ - sdiptr = ( user_to_phys ( image->data, 0 ) | SDI_WTF ); + sdiptr = ( virt_to_phys ( image->data ) | SDI_WTF ); __asm__ __volatile__ ( REAL_CODE ( "ljmp %0, %1\n\t" ) : : "i" ( SDI_BOOT_SEG ), "i" ( SDI_BOOT_OFF ), diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c index 9b6b5067a..a9fa8b8c4 100644 --- a/src/arch/x86/image/ucode.c +++ b/src/arch/x86/image/ucode.c @@ -165,7 +165,7 @@ static int ucode_status ( struct ucode_update *update, assert ( id <= control->apic_max ); /* Read status report */ - copy_from_user ( &status, phys_to_user ( control->status ), + copy_from_user ( &status, phys_to_virt ( control->status ), ( id * sizeof ( status ) ), sizeof ( status ) ); /* Ignore empty optional status reports */ @@ -261,7 +261,7 @@ static int ucode_update_all ( struct image *image, /* Construct control structure */ memset ( &control, 0, sizeof ( control ) ); control.desc = virt_to_phys ( update->desc ); - control.status = user_to_phys ( status, 0 ); + control.status = virt_to_phys ( status ); vendor = update->vendor; if ( vendor ) { control.ver_clear = vendor->ver_clear; @@ -446,8 +446,8 @@ static int ucode_parse_intel ( struct image *image, size_t start, /* Populate descriptor */ desc.signature = hdr.signature; desc.version = hdr.version; - desc.address = user_to_phys ( image->data, - ( start + sizeof ( hdr ) ) ); + desc.address = ( virt_to_phys ( image->data ) + + start + sizeof ( hdr ) ); /* Add non-extended descriptor, if applicable */ ucode_describe ( image, start, &ucode_intel, &desc, hdr.platforms, @@ -589,7 +589,8 @@ static int ucode_parse_amd ( struct image *image, size_t start, copy_from_user ( &patch, image->data, ( start + offset ), sizeof ( patch ) ); desc.version = patch.version; - desc.address = user_to_phys ( image->data, ( start + offset ) ); + desc.address = ( virt_to_phys ( image->data ) + + start + offset ); offset += phdr.len; /* Parse equivalence table to find matching signatures */ diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 9ed91022e..7755abdcf 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -85,33 +85,32 @@ extern const unsigned long virt_offset; /** * Convert physical address to user pointer * - * @v phys_addr Physical address - * @ret userptr User pointer + * @v phys Physical address + * @ret virt Virtual address */ -static inline __always_inline userptr_t -UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) { +static inline __always_inline void * +UACCESS_INLINE ( librm, phys_to_virt ) ( unsigned long phys ) { /* In a 64-bit build, any valid physical address is directly * usable as a virtual address, since the low 4GB is * identity-mapped. */ if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) - return ( ( userptr_t ) phys_addr ); + return ( ( void * ) phys ); /* In a 32-bit build, subtract virt_offset */ - return ( ( userptr_t ) ( phys_addr - virt_offset ) ); + return ( ( void * ) ( phys - virt_offset ) ); } /** - * Convert user buffer to physical address + * Convert virtual address to physical address * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address + * @v virt Virtual address + * @ret phys Physical address */ -static inline __always_inline unsigned long -UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) { - unsigned long addr = ( ( unsigned long ) ( userptr + offset ) ); +static inline __always_inline physaddr_t +UACCESS_INLINE ( librm, virt_to_phys ) ( volatile const void *virt ) { + physaddr_t addr = ( ( physaddr_t ) virt ); /* In a 64-bit build, any virtual address in the low 4GB is * directly usable as a physical address, since the low 4GB is diff --git a/src/arch/x86/include/realmode.h b/src/arch/x86/include/realmode.h index 4defd3b97..616db5eb9 100644 --- a/src/arch/x86/include/realmode.h +++ b/src/arch/x86/include/realmode.h @@ -73,7 +73,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static inline __always_inline userptr_t real_to_user ( unsigned int segment, unsigned int offset ) { - return ( phys_to_user ( ( segment << 4 ) + offset ) ); + return ( phys_to_virt ( ( segment << 4 ) + offset ) ); } /** diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c index bea803d6e..05d89b3b7 100644 --- a/src/arch/x86/interface/pcbios/bios_cachedhcp.c +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -60,7 +60,7 @@ static void cachedhcp_init ( void ) { /* Record cached DHCPACK */ if ( ( rc = cachedhcp_record ( &cached_dhcpack, 0, - phys_to_user ( cached_dhcpack_phys ), + phys_to_virt ( cached_dhcpack_phys ), sizeof ( BOOTPLAYER_t ) ) ) != 0 ) { DBGC ( colour, "CACHEDHCP could not record DHCPACK: %s\n", strerror ( rc ) ); diff --git a/src/arch/x86/interface/pcbios/bios_smbios.c b/src/arch/x86/interface/pcbios/bios_smbios.c index 366679d36..ab53d424b 100644 --- a/src/arch/x86/interface/pcbios/bios_smbios.c +++ b/src/arch/x86/interface/pcbios/bios_smbios.c @@ -54,7 +54,7 @@ static int bios_find_smbios2 ( struct smbios *smbios ) { return rc; /* Fill in entry point descriptor structure */ - smbios->address = phys_to_user ( entry.smbios_address ); + smbios->address = phys_to_virt ( entry.smbios_address ); smbios->len = entry.smbios_len; smbios->count = entry.smbios_count; smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); @@ -85,7 +85,7 @@ static int bios_find_smbios3 ( struct smbios *smbios ) { } /* Fill in entry point descriptor structure */ - smbios->address = phys_to_user ( entry.smbios_address ); + smbios->address = phys_to_virt ( entry.smbios_address ); smbios->len = entry.smbios_len; smbios->count = 0; smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index 372d40ba3..d60f7c7cc 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -743,7 +743,7 @@ static int int13_extended_rw ( struct san_device *sandev, if ( ( addr.count == 0xff ) || ( ( addr.buffer.segment == 0xffff ) && ( addr.buffer.offset == 0xffff ) ) ) { - buffer = phys_to_user ( addr.buffer_phys ); + buffer = phys_to_virt ( addr.buffer_phys ); DBGC2 ( sandev->drive, "%08llx", ( ( unsigned long long ) addr.buffer_phys ) ); } else { @@ -1058,7 +1058,7 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev, /* Read from boot catalog */ if ( ( rc = sandev_read ( sandev, start, command.count, - phys_to_user ( command.buffer ) ) ) != 0 ) { + phys_to_virt ( command.buffer ) ) ) != 0 ) { DBGC ( sandev->drive, "INT13 drive %02x could not read boot " "catalog: %s\n", sandev->drive, strerror ( rc ) ); return -INT13_STATUS_READ_ERROR; @@ -1455,7 +1455,7 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) { "catalog (status %04x)\n", drive, status ); return -EIO; } - copy_from_user ( &catalog, phys_to_user ( eltorito_cmd.buffer ), 0, + copy_from_user ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), 0, sizeof ( catalog ) ); /* Sanity checks */ diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 8239b23b8..b87d22516 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -106,7 +106,7 @@ size_t largest_memblock ( userptr_t *start ) { /* Use largest block */ if ( region_len > len ) { DBG ( "...new best block found\n" ); - *start = phys_to_user ( region_start ); + *start = phys_to_virt ( region_start ); len = region_len; } } @@ -124,7 +124,7 @@ static void init_eheap ( void ) { heap_size = largest_memblock ( &base ); bottom = top = ( base + heap_size ); DBG ( "External heap grows downwards from %lx (size %zx)\n", - user_to_phys ( top, 0 ), heap_size ); + virt_to_phys ( top ), heap_size ); } /** @@ -141,8 +141,8 @@ static void ecollect_free ( void ) { sizeof ( extmem ) ); if ( extmem.used ) break; - DBG ( "EXTMEM freeing [%lx,%lx)\n", user_to_phys ( bottom, 0 ), - user_to_phys ( bottom, extmem.size ) ); + DBG ( "EXTMEM freeing [%lx,%lx)\n", virt_to_phys ( bottom ), + ( virt_to_phys ( bottom ) + extmem.size ) ); len = ( extmem.size + sizeof ( extmem ) ); bottom += len; heap_size += len; @@ -182,7 +182,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { ptr = bottom = ( bottom - sizeof ( extmem ) ); heap_size -= sizeof ( extmem ); DBG ( "EXTMEM allocating [%lx,%lx)\n", - user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) ); + virt_to_phys ( ptr ), virt_to_phys ( ptr ) ); extmem.size = 0; } extmem.used = ( new_size > 0 ); @@ -191,7 +191,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { if ( ptr == bottom ) { /* Update block */ new = ( ptr - ( new_size - extmem.size ) ); - align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) ); + align = ( virt_to_phys ( new ) & ( EM_ALIGN - 1 ) ); new_size += align; new -= align; if ( new_size > ( heap_size + extmem.size ) ) { @@ -199,10 +199,10 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { return UNULL; } DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n", - user_to_phys ( ptr, 0 ), - user_to_phys ( ptr, extmem.size ), - user_to_phys ( new, 0 ), - user_to_phys ( new, new_size )); + virt_to_phys ( ptr ), + ( virt_to_phys ( ptr ) + extmem.size ), + virt_to_phys ( new ), + ( virt_to_phys ( new ) + new_size ) ); memmove ( new, ptr, ( ( extmem.size < new_size ) ? extmem.size : new_size ) ); bottom = new; @@ -213,8 +213,8 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { if ( new_size > extmem.size ) { /* Refuse to expand */ DBG ( "EXTMEM cannot expand [%lx,%lx)\n", - user_to_phys ( ptr, 0 ), - user_to_phys ( ptr, extmem.size ) ); + virt_to_phys ( ptr ), + ( virt_to_phys ( ptr ) + extmem.size ) ); return UNULL; } } @@ -225,9 +225,9 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { /* Collect any free blocks and update hidden memory region */ ecollect_free(); - hide_umalloc ( user_to_phys ( bottom, ( ( bottom == top ) ? - 0 : -sizeof ( extmem ) ) ), - user_to_phys ( top, 0 ) ); + hide_umalloc ( ( virt_to_phys ( bottom ) - + ( ( bottom == top ) ? 0 : sizeof ( extmem ) ) ), + virt_to_phys ( top ) ); return ( new_size ? new : UNOWHERE ); } diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index 3c67b7525..02c58c780 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -78,10 +78,10 @@ static userptr_t rsdp_find_rsdt_range ( userptr_t start, size_t len ) { continue; /* Extract RSDT */ - rsdt = phys_to_user ( le32_to_cpu ( rsdp.rsdt ) ); + rsdt = phys_to_virt ( le32_to_cpu ( rsdp.rsdt ) ); DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n", - user_to_phys ( rsdt, 0 ), - user_to_phys ( start, offset ) ); + virt_to_phys ( rsdt ), + ( virt_to_phys ( start ) + offset ) ); return rsdt; } @@ -114,7 +114,7 @@ static userptr_t rsdp_find_rsdt ( void ) { } /* Search fixed BIOS area */ - rsdt = rsdp_find_rsdt_range ( phys_to_user ( RSDP_BIOS_START ), + rsdt = rsdp_find_rsdt_range ( phys_to_virt ( RSDP_BIOS_START ), RSDP_BIOS_LEN ); if ( rsdt ) return rsdt; diff --git a/src/arch/x86/interface/pcbios/vesafb.c b/src/arch/x86/interface/pcbios/vesafb.c index 86edbda42..61609fa8c 100644 --- a/src/arch/x86/interface/pcbios/vesafb.c +++ b/src/arch/x86/interface/pcbios/vesafb.c @@ -473,7 +473,7 @@ static int vesafb_init ( struct console_configuration *config ) { vesafb_font(); /* Initialise frame buffer console */ - if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ), + if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_virt ( vesafb.start ), &vesafb.pixel, &vesafb.map, &vesafb.font, config ) ) != 0 ) goto err_fbcon_init; diff --git a/src/arch/x86/interface/pxe/pxe_tftp.c b/src/arch/x86/interface/pxe/pxe_tftp.c index 3b4c6d847..2c2eccca4 100644 --- a/src/arch/x86/interface/pxe/pxe_tftp.c +++ b/src/arch/x86/interface/pxe/pxe_tftp.c @@ -492,7 +492,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE } /* Read entire file */ - pxe_tftp.buffer = phys_to_user ( tftp_read_file->Buffer ); + pxe_tftp.buffer = phys_to_virt ( tftp_read_file->Buffer ); pxe_tftp.size = tftp_read_file->BufferSize; while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) step(); diff --git a/src/arch/x86/interface/syslinux/com32_call.c b/src/arch/x86/interface/syslinux/com32_call.c index da9d6491a..47be69f9f 100644 --- a/src/arch/x86/interface/syslinux/com32_call.c +++ b/src/arch/x86/interface/syslinux/com32_call.c @@ -49,7 +49,7 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad DBGC ( &com32_regs, "COM32 INT%x in %#08lx out %#08lx\n", interrupt, inregs_phys, outregs_phys ); - memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + memcpy ( virt_to_user( &com32_regs ), phys_to_virt ( inregs_phys ), sizeof ( com32sys_t ) ); com32_int_vector = interrupt; @@ -107,7 +107,7 @@ void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physad : : ); if ( outregs_phys ) { - memcpy ( phys_to_user ( outregs_phys ), + memcpy ( phys_to_virt ( outregs_phys ), virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } @@ -120,7 +120,7 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t DBGC ( &com32_regs, "COM32 farcall %04x:%04x in %#08lx out %#08lx\n", ( proc >> 16 ), ( proc & 0xffff ), inregs_phys, outregs_phys ); - memcpy ( virt_to_user( &com32_regs ), phys_to_user ( inregs_phys ), + memcpy ( virt_to_user( &com32_regs ), phys_to_virt ( inregs_phys ), sizeof ( com32sys_t ) ); com32_farcall_proc = proc; @@ -167,7 +167,7 @@ void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t : : ); if ( outregs_phys ) { - memcpy ( phys_to_user ( outregs_phys ), + memcpy ( phys_to_virt ( outregs_phys ), virt_to_user ( &com32_regs ), sizeof ( com32sys_t ) ); } } @@ -181,7 +181,7 @@ int __asmcall com32_cfarcall ( uint32_t proc, physaddr_t stack, size_t stacksz ) DBGC ( &com32_regs, "COM32 cfarcall %04x:%04x params %#08lx+%#zx\n", ( proc >> 16 ), ( proc & 0xffff ), stack, stacksz ); - copy_user_to_rm_stack ( phys_to_user ( stack ), stacksz ); + copy_user_to_rm_stack ( phys_to_virt ( stack ), stacksz ); com32_farcall_proc = proc; __asm__ __volatile__ ( diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index f26fcad0a..d7e923b70 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -114,8 +114,8 @@ static void shuffle ( unsigned int list_segment, unsigned int list_offset, unsig /* Do the copies */ for ( i = 0; i < count; i++ ) { - userptr_t src_u = phys_to_user ( shuf[ i ].src ); - userptr_t dest_u = phys_to_user ( shuf[ i ].dest ); + userptr_t src_u = phys_to_virt ( shuf[ i ].src ); + userptr_t dest_u = phys_to_virt ( shuf[ i ].dest ); if ( shuf[ i ].src == 0xFFFFFFFF ) { /* Fill with 0 instead of copying */ diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index 82e8eab39..fbc653969 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -428,8 +428,8 @@ void setup_sipi ( unsigned int vector, uint32_t handler, copy_to_real ( ( vector << 8 ), 0, sipi, ( ( size_t ) sipi_len ) ); } -PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); -PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); +PROVIDE_UACCESS_INLINE ( librm, phys_to_virt ); +PROVIDE_UACCESS_INLINE ( librm, virt_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_UACCESS_INLINE ( librm, memchr_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); diff --git a/src/core/acpi.c b/src/core/acpi.c index 526bf8555..d7da0ccc1 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -128,16 +128,16 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { copy_from_user ( &acpi, rsdt, 0, sizeof ( acpi ) ); if ( acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) { DBGC ( colour, "RSDT %#08lx has invalid signature:\n", - user_to_phys ( rsdt, 0 ) ); - DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi, + virt_to_phys ( rsdt ) ); + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, sizeof ( acpi ) ); return UNULL; } len = le32_to_cpu ( acpi.length ); if ( len < sizeof ( rsdtab->acpi ) ) { DBGC ( colour, "RSDT %#08lx has invalid length:\n", - user_to_phys ( rsdt, 0 ) ); - DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi, + virt_to_phys ( rsdt ) ); + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, sizeof ( acpi ) ); return UNULL; } @@ -154,7 +154,7 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { sizeof ( entry ) ); /* Read table header */ - table = phys_to_user ( entry ); + table = phys_to_virt ( entry ); copy_from_user ( &acpi.signature, table, 0, sizeof ( acpi.signature ) ); @@ -169,20 +169,20 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { /* Check table integrity */ if ( acpi_checksum ( table ) != 0 ) { DBGC ( colour, "RSDT %#08lx found %s with bad " - "checksum at %08lx\n", user_to_phys ( rsdt, 0 ), + "checksum at %08lx\n", virt_to_phys ( rsdt ), acpi_name ( signature ), - user_to_phys ( table, 0 ) ); + virt_to_phys ( table ) ); break; } DBGC ( colour, "RSDT %#08lx found %s at %08lx\n", - user_to_phys ( rsdt, 0 ), acpi_name ( signature ), - user_to_phys ( table, 0 ) ); + virt_to_phys ( rsdt ), acpi_name ( signature ), + virt_to_phys ( table ) ); return table; } DBGC ( colour, "RSDT %#08lx could not find %s\n", - user_to_phys ( rsdt, 0 ), acpi_name ( signature ) ); + virt_to_phys ( rsdt ), acpi_name ( signature ) ); return UNULL; } @@ -218,7 +218,7 @@ static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data, if ( buf != cpu_to_le32 ( signature ) ) continue; DBGC ( zsdt, "DSDT/SSDT %#08lx found %s at offset %#zx\n", - user_to_phys ( zsdt, 0 ), acpi_name ( signature ), + virt_to_phys ( zsdt ), acpi_name ( signature ), offset ); /* Attempt to extract data */ @@ -251,7 +251,7 @@ int acpi_extract ( uint32_t signature, void *data, fadt = acpi_table ( FADT_SIGNATURE, 0 ); if ( fadt ) { copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - dsdt = phys_to_user ( fadtab.dsdt ); + dsdt = phys_to_virt ( fadtab.dsdt ); if ( ( rc = acpi_zsdt ( dsdt, signature, data, extract ) ) == 0 ) return 0; diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index f9dcb95d2..f3be2ba2b 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -248,7 +248,7 @@ int block_translate ( struct interface *block, userptr_t buffer, size_t size ) { DBGC2 ( blktrans, "BLKTRANS %p created", blktrans ); if ( buffer ) { DBGC2 ( blktrans, " for %#lx+%#zx", - user_to_phys ( buffer, 0 ), size ); + virt_to_phys ( buffer ), size ); } DBGC2 ( blktrans, "\n" ); return 0; diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 04945e646..07589f0b8 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -251,7 +251,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan, /* Store as cached packet */ DBGC ( colour, "CACHEDHCP %s at %#08lx+%#zx/%#zx\n", cache->name, - user_to_phys ( data, 0 ), len, max_len ); + virt_to_phys ( data ), len, max_len ); cache->dhcppkt = dhcppkt; cache->vlan = vlan; diff --git a/src/core/fbcon.c b/src/core/fbcon.c index 8d05484e2..6d08ac419 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -613,8 +613,8 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, /* Derive overall length */ fbcon->len = ( pixel->height * pixel->stride ); DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon, - user_to_phys ( fbcon->start, 0 ), - user_to_phys ( fbcon->start, fbcon->len ) ); + virt_to_phys ( fbcon->start ), + ( virt_to_phys ( fbcon->start ) + fbcon->len ) ); /* Calculate margin. If the actual screen size is larger than * the requested screen size, then update the margins so that diff --git a/src/core/image.c b/src/core/image.c index 709d0da9c..e90d82ffb 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -300,8 +300,8 @@ int register_image ( struct image *image ) { image->flags |= IMAGE_REGISTERED; list_add_tail ( &image->list, &images ); DBGC ( image, "IMAGE %s at [%lx,%lx) registered\n", - image->name, user_to_phys ( image->data, 0 ), - user_to_phys ( image->data, image->len ) ); + image->name, virt_to_phys ( image->data ), + ( virt_to_phys ( image->data ) + image->len ) ); /* Try to detect image type, if applicable. Ignore failures, * since we expect to handle some unrecognised images diff --git a/src/core/uaccess.c b/src/core/uaccess.c index 1c33c10b8..32bd1ac38 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -32,7 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ /* Flat address space user access API */ -PROVIDE_UACCESS_INLINE ( flat, phys_to_user ); -PROVIDE_UACCESS_INLINE ( flat, user_to_phys ); +PROVIDE_UACCESS_INLINE ( flat, phys_to_virt ); +PROVIDE_UACCESS_INLINE ( flat, virt_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/drivers/block/srp.c b/src/drivers/block/srp.c index ab4812519..c12f230f7 100644 --- a/src/drivers/block/srp.c +++ b/src/drivers/block/srp.c @@ -428,7 +428,7 @@ static int srp_cmd ( struct srp_device *srpdev, cmd->data_buffer_formats |= SRP_CMD_DO_FMT_DIRECT; data_out = iob_put ( iobuf, sizeof ( *data_out ) ); data_out->address = - cpu_to_be64 ( user_to_phys ( command->data_out, 0 ) ); + cpu_to_be64 ( virt_to_phys ( command->data_out ) ); data_out->handle = ntohl ( srpdev->memory_handle ); data_out->len = ntohl ( command->data_out_len ); } @@ -438,7 +438,7 @@ static int srp_cmd ( struct srp_device *srpdev, cmd->data_buffer_formats |= SRP_CMD_DI_FMT_DIRECT; data_in = iob_put ( iobuf, sizeof ( *data_in ) ); data_in->address = - cpu_to_be64 ( user_to_phys ( command->data_in, 0 ) ); + cpu_to_be64 ( virt_to_phys ( command->data_in ) ); data_in->handle = ntohl ( srpdev->memory_handle ); data_in->len = ntohl ( command->data_in_len ); } diff --git a/src/drivers/infiniband/arbel.c b/src/drivers/infiniband/arbel.c index 8be06d93d..4cb4167e0 100644 --- a/src/drivers/infiniband/arbel.c +++ b/src/drivers/infiniband/arbel.c @@ -2079,7 +2079,7 @@ static int arbel_start_firmware ( struct arbel *arbel ) { } else { assert ( arbel->firmware_len == fw_len ); } - fw_base = user_to_phys ( arbel->firmware_area, 0 ); + fw_base = virt_to_phys ( arbel->firmware_area ); DBGC ( arbel, "Arbel %p firmware area at [%08lx,%08lx)\n", arbel, fw_base, ( fw_base + fw_len ) ); if ( ( rc = arbel_map_vpm ( arbel, arbel_cmd_map_fa, @@ -2452,7 +2452,7 @@ static int arbel_alloc_icm ( struct arbel *arbel, assert ( arbel->icm_len == icm_len ); assert ( arbel->icm_aux_len == icm_aux_len ); } - icm_phys = user_to_phys ( arbel->icm, 0 ); + icm_phys = virt_to_phys ( arbel->icm ); /* Allocate doorbell UAR */ arbel->db_rec = malloc_phys ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE ); diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index 81fc6c0f0..a33bad9ff 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -486,8 +486,8 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages for ( i = 0 , j = MANAGE_PAGES_PSA_OFFSET; i < pas_num; ++i ,++j, next_page_addr += GOLAN_PAGE_SIZE ) { addr = next_page_addr; - if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) { - DBGC (golan ,"Addr not Page alligned [%lx]\n", user_to_phys(addr, 0)); + if (GOLAN_PAGE_MASK & virt_to_phys(addr)) { + DBGC (golan ,"Addr not Page alligned [%lx]\n", virt_to_phys(addr)); } mailbox->mblock.data[j] = USR_2_BE64_BUS(addr); } diff --git a/src/drivers/infiniband/golan.h b/src/drivers/infiniband/golan.h index 2fd06ecf0..f7da1e960 100755 --- a/src/drivers/infiniband/golan.h +++ b/src/drivers/infiniband/golan.h @@ -69,8 +69,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define VIRT_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )virt_to_bus(addr))) #define BE64_BUS_2_VIRT( addr ) bus_to_virt(be64_to_cpu(addr)) -#define USR_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )user_to_phys(addr, 0))) -#define BE64_BUS_2_USR( addr ) be64_to_cpu(phys_to_user(addr)) +#define USR_2_BE64_BUS( addr ) cpu_to_be64(((unsigned long long )virt_to_phys(addr))) +#define BE64_BUS_2_USR( addr ) be64_to_cpu(phys_to_virt(addr)) #define GET_INBOX(golan, idx) (&(((struct mbox *)(golan->mboxes.inbox))[idx])) #define GET_OUTBOX(golan, idx) (&(((struct mbox *)(golan->mboxes.outbox))[idx])) diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index e5c3544fa..3138d8bfb 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -2382,7 +2382,7 @@ static int hermon_start_firmware ( struct hermon *hermon ) { } else { assert ( hermon->firmware_len == fw_len ); } - fw_base = user_to_phys ( hermon->firmware_area, 0 ); + fw_base = virt_to_phys ( hermon->firmware_area ); DBGC ( hermon, "Hermon %p firmware area at physical [%08lx,%08lx)\n", hermon, fw_base, ( fw_base + fw_len ) ); if ( ( rc = hermon_map_vpm ( hermon, hermon_cmd_map_fa, @@ -2752,7 +2752,7 @@ static int hermon_map_icm ( struct hermon *hermon, assert ( hermon->icm_len == icm_len ); assert ( hermon->icm_aux_len == icm_aux_len ); } - icm_phys = user_to_phys ( hermon->icm, 0 ); + icm_phys = virt_to_phys ( hermon->icm ); /* Map ICM auxiliary area */ DBGC ( hermon, "Hermon %p mapping ICM AUX => %08lx\n", diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index 14a17df47..b3148e090 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -406,7 +406,7 @@ static int exanic_open ( struct net_device *netdev ) { port->rx_cons = 0; /* Map receive region */ - exanic_write_base ( phys_to_bus ( user_to_phys ( port->rx, 0 ) ), + exanic_write_base ( phys_to_bus ( virt_to_phys ( port->rx ) ), ( port->regs + EXANIC_PORT_RX_BASE ) ); /* Enable promiscuous mode */ @@ -729,8 +729,8 @@ static int exanic_probe_port ( struct exanic *exanic, struct device *dev, DBGC ( port, "EXANIC %s port %d TX [%#05zx,%#05zx) TXF %#02x RX " "[%#lx,%#lx)\n", netdev->name, index, port->tx_offset, ( port->tx_offset + tx_len ), port->txf_slot, - user_to_phys ( port->rx, 0 ), - user_to_phys ( port->rx, EXANIC_RX_LEN ) ); + virt_to_phys ( port->rx ), + ( virt_to_phys ( port->rx ) + EXANIC_RX_LEN ) ); /* Set initial link state */ exanic_check_link ( netdev ); diff --git a/src/drivers/net/gve.c b/src/drivers/net/gve.c index 2cbc401f5..f9ec388a4 100644 --- a/src/drivers/net/gve.c +++ b/src/drivers/net/gve.c @@ -521,14 +521,14 @@ static int gve_deconfigure ( struct gve_nic *gve ) { static int gve_register ( struct gve_nic *gve, struct gve_qpl *qpl ) { struct gve_pages *pages = &gve->scratch.buf->pages; union gve_admin_command *cmd; - physaddr_t addr; + void *addr; unsigned int i; int rc; /* Build page address list */ for ( i = 0 ; i < qpl->count ; i++ ) { - addr = user_to_phys ( qpl->data, ( i * GVE_PAGE_SIZE ) ); - pages->addr[i] = cpu_to_be64 ( dma_phys ( &qpl->map, addr ) ); + addr = ( qpl->data + ( i * GVE_PAGE_SIZE ) ); + pages->addr[i] = cpu_to_be64 ( dma ( &qpl->map, addr ) ); } /* Construct request */ @@ -575,11 +575,10 @@ static void gve_create_tx_param ( struct gve_queue *queue, union gve_admin_command *cmd ) { struct gve_admin_create_tx *create = &cmd->create_tx; const struct gve_queue_type *type = queue->type; - physaddr_t desc = user_to_phys ( queue->desc, 0 ); /* Construct request parameters */ create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); - create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) ); + create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) ); create->qpl_id = cpu_to_be32 ( type->qpl ); create->notify_id = cpu_to_be32 ( type->irq ); } @@ -594,14 +593,12 @@ static void gve_create_rx_param ( struct gve_queue *queue, union gve_admin_command *cmd ) { struct gve_admin_create_rx *create = &cmd->create_rx; const struct gve_queue_type *type = queue->type; - physaddr_t desc = user_to_phys ( queue->desc, 0 ); - physaddr_t cmplt = user_to_phys ( queue->cmplt, 0 ); /* Construct request parameters */ create->notify_id = cpu_to_be32 ( type->irq ); create->res = cpu_to_be64 ( dma ( &queue->res_map, queue->res ) ); - create->desc = cpu_to_be64 ( dma_phys ( &queue->desc_map, desc ) ); - create->cmplt = cpu_to_be64 ( dma_phys ( &queue->cmplt_map, cmplt ) ); + create->desc = cpu_to_be64 ( dma ( &queue->desc_map, queue->desc ) ); + create->cmplt = cpu_to_be64 ( dma ( &queue->cmplt_map, queue->cmplt )); create->qpl_id = cpu_to_be32 ( type->qpl ); create->bufsz = cpu_to_be16 ( GVE_BUF_SIZE ); } @@ -760,8 +757,8 @@ static int gve_alloc_qpl ( struct gve_nic *gve, struct gve_qpl *qpl, return -ENOMEM; DBGC ( gve, "GVE %p QPL %#08x at [%08lx,%08lx)\n", - gve, qpl->id, user_to_phys ( qpl->data, 0 ), - user_to_phys ( qpl->data, len ) ); + gve, qpl->id, virt_to_phys ( qpl->data ), + ( virt_to_phys ( qpl->data ) + len ) ); return 0; } @@ -883,8 +880,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { goto err_desc; } DBGC ( gve, "GVE %p %s descriptors at [%08lx,%08lx)\n", - gve, type->name, user_to_phys ( queue->desc, 0 ), - user_to_phys ( queue->desc, desc_len ) ); + gve, type->name, virt_to_phys ( queue->desc ), + ( virt_to_phys ( queue->desc ) + desc_len ) ); /* Allocate completions */ if ( cmplt_len ) { @@ -895,8 +892,8 @@ static int gve_alloc_queue ( struct gve_nic *gve, struct gve_queue *queue ) { goto err_cmplt; } DBGC ( gve, "GVE %p %s completions at [%08lx,%08lx)\n", - gve, type->name, user_to_phys ( queue->cmplt, 0 ), - user_to_phys ( queue->cmplt, cmplt_len ) ); + gve, type->name, virt_to_phys ( queue->cmplt ), + ( virt_to_phys ( queue->cmplt ) + cmplt_len ) ); } /* Allocate queue resources */ diff --git a/src/drivers/net/thunderx.c b/src/drivers/net/thunderx.c index 1865a9b91..3d213b167 100644 --- a/src/drivers/net/thunderx.c +++ b/src/drivers/net/thunderx.c @@ -118,14 +118,14 @@ static int txnic_create_sq ( struct txnic *vnic ) { writeq ( TXNIC_QS_SQ_CFG_RESET, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) ); /* Configure and enable send queue */ - writeq ( user_to_phys ( vnic->sq.sqe, 0 ), + writeq ( virt_to_phys ( vnic->sq.sqe ), ( vnic->regs + TXNIC_QS_SQ_BASE(0) ) ); writeq ( ( TXNIC_QS_SQ_CFG_ENA | TXNIC_QS_SQ_CFG_QSIZE_1K ), ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) ); DBGC ( vnic, "TXNIC %s SQ at [%08lx,%08lx)\n", - vnic->name, user_to_phys ( vnic->sq.sqe, 0 ), - user_to_phys ( vnic->sq.sqe, TXNIC_SQ_SIZE ) ); + vnic->name, virt_to_phys ( vnic->sq.sqe ), + ( virt_to_phys ( vnic->sq.sqe ) + TXNIC_SQ_SIZE ) ); return 0; } @@ -277,7 +277,7 @@ static int txnic_create_rq ( struct txnic *vnic ) { ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) ); /* Configure and enable receive buffer descriptor ring */ - writeq ( user_to_phys ( vnic->rq.rqe, 0 ), + writeq ( virt_to_phys ( vnic->rq.rqe ), ( vnic->regs + TXNIC_QS_RBDR_BASE(0) ) ); writeq ( ( TXNIC_QS_RBDR_CFG_ENA | TXNIC_QS_RBDR_CFG_QSIZE_8K | TXNIC_QS_RBDR_CFG_LINES ( TXNIC_RQE_SIZE / @@ -288,8 +288,8 @@ static int txnic_create_rq ( struct txnic *vnic ) { writeq ( TXNIC_QS_RQ_CFG_ENA, ( vnic->regs + TXNIC_QS_RQ_CFG(0) ) ); DBGC ( vnic, "TXNIC %s RQ at [%08lx,%08lx)\n", - vnic->name, user_to_phys ( vnic->rq.rqe, 0 ), - user_to_phys ( vnic->rq.rqe, TXNIC_RQ_SIZE ) ); + vnic->name, virt_to_phys ( vnic->rq.rqe ), + ( virt_to_phys ( vnic->rq.rqe ) + TXNIC_RQ_SIZE ) ); return 0; } @@ -463,14 +463,14 @@ static int txnic_create_cq ( struct txnic *vnic ) { writeq ( TXNIC_QS_CQ_CFG_RESET, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) ); /* Configure and enable completion queue */ - writeq ( user_to_phys ( vnic->cq.cqe, 0 ), + writeq ( virt_to_phys ( vnic->cq.cqe ), ( vnic->regs + TXNIC_QS_CQ_BASE(0) ) ); writeq ( ( TXNIC_QS_CQ_CFG_ENA | TXNIC_QS_CQ_CFG_QSIZE_256 ), ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) ); DBGC ( vnic, "TXNIC %s CQ at [%08lx,%08lx)\n", - vnic->name, user_to_phys ( vnic->cq.cqe, 0 ), - user_to_phys ( vnic->cq.cqe, TXNIC_CQ_SIZE ) ); + vnic->name, virt_to_phys ( vnic->cq.cqe ), + ( virt_to_phys ( vnic->cq.cqe ) + TXNIC_CQ_SIZE ) ); return 0; } @@ -559,7 +559,8 @@ static void txnic_poll_cq ( struct txnic *vnic ) { default: DBGC ( vnic, "TXNIC %s unknown completion type %d\n", vnic->name, cqe.common.cqe_type ); - DBGC_HDA ( vnic, user_to_phys ( vnic->cq.cqe, offset ), + DBGC_HDA ( vnic, + ( virt_to_phys ( vnic->cq.cqe ) + offset ), &cqe, sizeof ( cqe ) ); break; } diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index f244086ce..30ee09bbb 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -1014,8 +1014,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { } /* Populate scratchpad array */ - addr = dma_phys ( &scratch->buffer_map, - user_to_phys ( scratch->buffer, 0 ) ); + addr = dma ( &scratch->buffer_map, scratch->buffer ); for ( i = 0 ; i < scratch->count ; i++ ) { scratch->array[i] = cpu_to_le64 ( addr ); addr += xhci->pagesize; @@ -1027,8 +1026,8 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { scratch->array ) ); DBGC2 ( xhci, "XHCI %s scratchpad [%08lx,%08lx) array [%08lx,%08lx)\n", - xhci->name, user_to_phys ( scratch->buffer, 0 ), - user_to_phys ( scratch->buffer, buffer_len ), + xhci->name, virt_to_phys ( scratch->buffer ), + ( virt_to_phys ( scratch->buffer ) + buffer_len ), virt_to_phys ( scratch->array ), ( virt_to_phys ( scratch->array ) + array_len ) ); return 0; diff --git a/src/hci/commands/image_mem_cmd.c b/src/hci/commands/image_mem_cmd.c index c8bfab1ad..5f8363461 100644 --- a/src/hci/commands/image_mem_cmd.c +++ b/src/hci/commands/image_mem_cmd.c @@ -81,7 +81,7 @@ static int imgmem_exec ( int argc, char **argv ) { return rc; /* Create image */ - if ( ( rc = imgmem ( opts.name, phys_to_user ( data ), len ) ) != 0 ) + if ( ( rc = imgmem ( opts.name, phys_to_virt ( data ), len ) ) != 0 ) return rc; return 0; diff --git a/src/image/elf.c b/src/image/elf.c index 46c9fe8eb..fa714b15f 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -50,7 +50,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr, physaddr_t dest ) { - userptr_t buffer = phys_to_user ( dest ); + userptr_t buffer = phys_to_virt ( dest ); int rc; DBGC ( image, "ELF %p loading segment [%x,%x) to [%lx,%lx,%lx)\n", diff --git a/src/image/segment.c b/src/image/segment.c index b7f8ef56c..ebc2b703d 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -59,9 +59,9 @@ struct errortab segment_errors[] __errortab = { */ int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) { struct memory_map memmap; - physaddr_t start = user_to_phys ( segment, 0 ); - physaddr_t mid = user_to_phys ( segment, filesz ); - physaddr_t end = user_to_phys ( segment, memsz ); + physaddr_t start = virt_to_phys ( segment ); + physaddr_t mid = ( start + filesz ); + physaddr_t end = ( start + memsz ); unsigned int i; DBG ( "Preparing segment [%lx,%lx,%lx)\n", start, mid, end ); diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 4b1257b1e..b4f7e2fc6 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -10,10 +10,9 @@ * * We have no concept of the underlying physical addresses, since * these are not exposed to userspace. We provide a stub - * implementation of user_to_phys() since this is required by - * alloc_memblock(). We provide no implementation of phys_to_user(); - * any code attempting to access physical addresses will therefore - * (correctly) fail to link. + * implementation of virt_to_phys() since this is required by + * alloc_memblock(). We provide a matching stub implementation of + * phys_to_virt(). */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); @@ -25,14 +24,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #endif /** - * Convert user pointer to physical address + * Convert virtual address to physical address * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address + * @v virt Virtual address + * @ret phys Physical address */ -static inline __always_inline unsigned long -UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) { +static inline __always_inline physaddr_t +UACCESS_INLINE ( linux, virt_to_phys ) ( volatile const void *virt ) { /* We do not know the real underlying physical address. We * provide this stub implementation only because it is @@ -43,20 +41,20 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) { * virtual address will suffice for the purpose of determining * alignment. */ - return ( ( unsigned long ) ( userptr + offset ) ); + return ( ( physaddr_t ) virt ); } /** - * Convert physical address to user pointer + * Convert physical address to virtual address * - * @v phys_addr Physical address - * @ret userptr User pointer + * @v phys Physical address + * @ret virt Virtual address */ -static inline __always_inline userptr_t -UACCESS_INLINE ( linux, phys_to_user ) ( physaddr_t phys_addr ) { +static inline __always_inline void * +UACCESS_INLINE ( linux, phys_to_virt ) ( physaddr_t phys ) { - /* For symmetry with the stub user_to_phys() */ - return ( ( userptr_t ) phys_addr ); + /* For symmetry with the stub virt_to_phys() */ + return ( ( void * ) phys ); } static inline __always_inline userptr_t diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 4b3524bab..62030dd8a 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -99,14 +99,14 @@ trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) { #define PROVIDE_UACCESS_INLINE( _subsys, _api_func ) \ PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) -static inline __always_inline userptr_t -UACCESS_INLINE ( flat, phys_to_user ) ( unsigned long phys_addr ) { - return ( ( userptr_t ) phys_addr ); +static inline __always_inline void * +UACCESS_INLINE ( flat, phys_to_virt ) ( physaddr_t phys ) { + return ( ( void * ) phys ); } -static inline __always_inline unsigned long -UACCESS_INLINE ( flat, user_to_phys ) ( userptr_t userptr, off_t offset ) { - return ( ( unsigned long ) ( userptr + offset ) ); +static inline __always_inline physaddr_t +UACCESS_INLINE ( flat, virt_to_phys ) ( volatile const void *virt ) { + return ( ( physaddr_t ) virt ); } static inline __always_inline userptr_t @@ -126,23 +126,6 @@ UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, /* Include all architecture-dependent user access API headers */ #include -/** - * Convert physical address to user pointer - * - * @v phys_addr Physical address - * @ret userptr User pointer - */ -userptr_t phys_to_user ( unsigned long phys_addr ); - -/** - * Convert user pointer to physical address - * - * @v userptr User pointer - * @v offset Offset from user pointer - * @ret phys_addr Physical address - */ -unsigned long user_to_phys ( userptr_t userptr, off_t offset ); - /** * Convert virtual address to user pointer * @@ -154,25 +137,21 @@ userptr_t virt_to_user ( volatile const void *addr ); /** * Convert virtual address to a physical address * - * @v addr Virtual address - * @ret phys_addr Physical address + * @v virt Virtual address + * @ret phys Physical address */ -static inline __always_inline unsigned long -virt_to_phys ( volatile const void *addr ) { - return user_to_phys ( virt_to_user ( addr ), 0 ); -} +physaddr_t __attribute__ (( const )) +virt_to_phys ( volatile const void *virt ); /** * Convert physical address to a virtual address * - * @v addr Virtual address - * @ret phys_addr Physical address + * @v phys Physical address + * @ret virt Virtual address * * This operation is not available under all memory models. */ -static inline __always_inline void * phys_to_virt ( unsigned long phys_addr ) { - return ( phys_to_user ( phys_addr ) ); -} +void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys ); /** * Copy data to user buffer diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index 07a225632..c1046c01a 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -48,7 +48,7 @@ static userptr_t efi_find_rsdt ( void ) { /* Locate RSDT via ACPI configuration table, if available */ if ( rsdp ) - return phys_to_user ( rsdp->RsdtAddress ); + return phys_to_virt ( rsdp->RsdtAddress ); return UNULL; } diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index 659ebd37e..09cfde4c2 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -583,7 +583,7 @@ static int efifb_init ( struct console_configuration *config ) { mode, efifb.pixel.width, efifb.pixel.height, bpp, efifb.start ); /* Initialise frame buffer console */ - if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_user ( efifb.start ), + if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_virt ( efifb.start ), &efifb.pixel, &efifb.map, &efifb.font, config ) ) != 0 ) goto err_fbcon_init; diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index d7877b0aa..3c1b77bdc 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -48,27 +48,27 @@ static int efi_find_smbios ( struct smbios *smbios ) { /* Use 64-bit table if present */ if ( smbios3_entry && ( smbios3_entry->signature == SMBIOS3_SIGNATURE ) ) { - smbios->address = phys_to_user ( smbios3_entry->smbios_address ); + smbios->address = phys_to_virt ( smbios3_entry->smbios_address ); smbios->len = smbios3_entry->smbios_len; smbios->count = 0; smbios->version = SMBIOS_VERSION ( smbios3_entry->major, smbios3_entry->minor ); DBG ( "Found 64-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n", smbios3_entry->major, smbios3_entry->minor, smbios3_entry, - user_to_phys ( smbios->address, 0 ), smbios->len ); + virt_to_phys ( smbios->address ), smbios->len ); return 0; } /* Otherwise, use 32-bit table if present */ if ( smbios_entry && ( smbios_entry->signature == SMBIOS_SIGNATURE ) ) { - smbios->address = phys_to_user ( smbios_entry->smbios_address ); + smbios->address = phys_to_virt ( smbios_entry->smbios_address ); smbios->len = smbios_entry->smbios_len; smbios->count = smbios_entry->smbios_count; smbios->version = SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor ); DBG ( "Found 32-bit SMBIOS v%d.%d entry point at %p (%lx+%zx)\n", smbios_entry->major, smbios_entry->minor, smbios_entry, - user_to_phys ( smbios->address, 0 ), smbios->len ); + virt_to_phys ( smbios->address ), smbios->len ); return 0; } diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 488c53f3d..0636cb7fd 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -72,7 +72,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { return UNULL; } assert ( phys_addr != 0 ); - new_ptr = phys_to_user ( phys_addr + EFI_PAGE_SIZE ); + new_ptr = phys_to_virt ( phys_addr + EFI_PAGE_SIZE ); copy_to_user ( new_ptr, -EFI_PAGE_SIZE, &new_size, sizeof ( new_size ) ); DBG ( "EFI allocated %d pages at %llx\n", @@ -90,7 +90,7 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { memcpy ( new_ptr, old_ptr, ( (old_size < new_size) ? old_size : new_size ) ); old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 ); - phys_addr = user_to_phys ( old_ptr, -EFI_PAGE_SIZE ); + phys_addr = virt_to_phys ( old_ptr - EFI_PAGE_SIZE ); if ( ( efirc = bs->FreePages ( phys_addr, old_pages ) ) != 0 ){ rc = -EEFI ( efirc ); DBG ( "EFI could not free %d pages at %llx: %s\n", diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c index 86d2a08d7..49ccf69c8 100644 --- a/src/interface/hyperv/vmbus.c +++ b/src/interface/hyperv/vmbus.c @@ -277,7 +277,7 @@ int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data, size_t len ) { struct hv_hypervisor *hv = vmdev->hv; struct vmbus *vmbus = hv->vmbus; - physaddr_t addr = user_to_phys ( data, 0 ); + physaddr_t addr = virt_to_phys ( data ); unsigned int pfn_count = hv_pfn_count ( addr, len ); struct { struct vmbus_gpadl_header gpadlhdr; diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index e5c394365..4fdd8c03a 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -27,6 +27,7 @@ FILE_LICENCE(GPL2_OR_LATER); * */ -PROVIDE_UACCESS_INLINE(linux, user_to_phys); +PROVIDE_UACCESS_INLINE(linux, phys_to_virt); +PROVIDE_UACCESS_INLINE(linux, virt_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); PROVIDE_UACCESS_INLINE(linux, memchr_user); diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 3e69a0c15..89fa4d7ca 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -86,14 +86,14 @@ int find_smbios_entry ( userptr_t start, size_t len, if ( ( sum = smbios_checksum ( start, offset, entry->len ) ) != 0 ) { DBG ( "SMBIOS at %08lx has bad checksum %02x\n", - user_to_phys ( start, offset ), sum ); + virt_to_phys ( start + offset ), sum ); continue; } /* Fill result structure */ DBG ( "Found SMBIOS v%d.%d entry point at %08lx\n", entry->major, entry->minor, - user_to_phys ( start, offset ) ); + virt_to_phys ( start + offset ) ); return 0; } @@ -126,14 +126,14 @@ int find_smbios3_entry ( userptr_t start, size_t len, if ( ( sum = smbios_checksum ( start, offset, entry->len ) ) != 0 ) { DBG ( "SMBIOS3 at %08lx has bad checksum %02x\n", - user_to_phys ( start, offset ), sum ); + virt_to_phys ( start + offset ), sum ); continue; } /* Fill result structure */ DBG ( "Found SMBIOS3 v%d.%d entry point at %08lx\n", entry->major, entry->minor, - user_to_phys ( start, offset ) ); + virt_to_phys ( start + offset ) ); return 0; } -- cgit v1.2.3-55-g7522 From 3f8937d2f3a82371022303c2e70369ce7a05f89e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Apr 2025 22:40:59 +0100 Subject: [crypto] Remove userptr_t from ASN.1 parsers Simplify the ASN.1 code by assuming that all objects are fully accessible via pointer dereferences. This allows the concept of "additional data beyond the end of the cursor" to be removed, and simplifies parsing of all ASN.1 image formats. Signed-off-by: Michael Brown --- src/crypto/asn1.c | 46 ++++++++-------------------------- src/drivers/net/iphone.c | 2 +- src/image/der.c | 24 ++++++------------ src/image/efi_siglist.c | 51 +++++++++++++++++++------------------- src/image/pem.c | 24 ++++++++---------- src/include/ipxe/asn1.h | 2 -- src/include/ipxe/der.h | 2 +- src/include/ipxe/efi/efi_siglist.h | 3 +-- src/include/ipxe/pem.h | 3 +-- src/interface/efi/efi_cacert.c | 4 +-- 10 files changed, 61 insertions(+), 100 deletions(-) (limited to 'src/interface') diff --git a/src/crypto/asn1.c b/src/crypto/asn1.c index aa57c6a8b..7b84f6fc3 100644 --- a/src/crypto/asn1.c +++ b/src/crypto/asn1.c @@ -88,7 +88,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v cursor ASN.1 object cursor * @v type Expected type, or ASN1_ANY - * @v extra Additional length not present within partial cursor * @ret len Length of object body, or negative error * * The object cursor will be updated to point to the start of the @@ -100,8 +99,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * modified. If any other error occurs, the object cursor will be * invalidated. */ -static int asn1_start ( struct asn1_cursor *cursor, unsigned int type, - size_t extra ) { +static int asn1_start ( struct asn1_cursor *cursor, unsigned int type ) { unsigned int len_len; unsigned int len; @@ -145,9 +143,9 @@ static int asn1_start ( struct asn1_cursor *cursor, unsigned int type, cursor->data++; cursor->len--; } - if ( ( cursor->len + extra ) < len ) { + if ( cursor->len < len ) { DBGC ( cursor, "ASN1 %p bad length %d (max %zd)\n", - cursor, len, ( cursor->len + extra ) ); + cursor, len, cursor->len ); asn1_invalidate_cursor ( cursor ); return -EINVAL_ASN1_LEN; } @@ -156,58 +154,36 @@ static int asn1_start ( struct asn1_cursor *cursor, unsigned int type, } /** - * Enter ASN.1 partial object + * Enter ASN.1 object * * @v cursor ASN.1 object cursor * @v type Expected type, or ASN1_ANY - * @v extra Additional length beyond partial object * @ret rc Return status code * - * The object cursor and additional length will be updated to point to - * the body of the current ASN.1 object. + * The object cursor will be updated to point to the body of the + * current ASN.1 object. * * If any error occurs, the object cursor will be invalidated. */ -int asn1_enter_partial ( struct asn1_cursor *cursor, unsigned int type, - size_t *extra ) { +int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ) { int len; /* Parse current object */ - len = asn1_start ( cursor, type, *extra ); + len = asn1_start ( cursor, type ); if ( len < 0 ) { asn1_invalidate_cursor ( cursor ); return len; } - /* Update cursor and additional length */ + /* Update cursor */ if ( ( ( size_t ) len ) <= cursor->len ) cursor->len = len; - assert ( ( len - cursor->len ) <= *extra ); - *extra = ( len - cursor->len ); DBGC ( cursor, "ASN1 %p entered object type %02x (len %x)\n", cursor, type, len ); return 0; } -/** - * Enter ASN.1 object - * - * @v cursor ASN.1 object cursor - * @v type Expected type, or ASN1_ANY - * @ret rc Return status code - * - * The object cursor will be updated to point to the body of the - * current ASN.1 object. - * - * If any error occurs, the object cursor will be invalidated. - */ -int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ) { - static size_t no_extra = 0; - - return asn1_enter_partial ( cursor, type, &no_extra ); -} - /** * Skip ASN.1 object if present * @@ -226,7 +202,7 @@ int asn1_skip_if_exists ( struct asn1_cursor *cursor, unsigned int type ) { int len; /* Parse current object */ - len = asn1_start ( cursor, type, 0 ); + len = asn1_start ( cursor, type ); if ( len < 0 ) return len; @@ -281,7 +257,7 @@ int asn1_shrink ( struct asn1_cursor *cursor, unsigned int type ) { /* Find end of object */ memcpy ( &temp, cursor, sizeof ( temp ) ); - len = asn1_start ( &temp, type, 0 ); + len = asn1_start ( &temp, type ); if ( len < 0 ) { asn1_invalidate_cursor ( cursor ); return len; diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index 08459a6e2..bcc9949fe 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -1476,7 +1476,7 @@ static int ipair_rx_pubkey ( struct ipair *ipair, char *msg ) { } /* Decode inner layer of Base64 */ - next = pem_asn1 ( virt_to_user ( decoded ), len, 0, &key ); + next = pem_asn1 ( decoded, len, 0, &key ); if ( next < 0 ) { rc = next; DBGC ( ipair, "IPAIR %p invalid inner public key:\n%s\n", diff --git a/src/image/der.c b/src/image/der.c index ac4992336..600e163c9 100644 --- a/src/image/der.c +++ b/src/image/der.c @@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include /** @file @@ -49,7 +48,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * The caller is responsible for eventually calling free() on the * allocated ASN.1 cursor. */ -int der_asn1 ( userptr_t data, size_t len, size_t offset, +int der_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ) { size_t remaining; void *raw; @@ -67,7 +66,7 @@ int der_asn1 ( userptr_t data, size_t len, size_t offset, /* Populate cursor and data buffer */ (*cursor)->data = raw; (*cursor)->len = remaining; - copy_from_user ( raw, data, offset, remaining ); + memcpy ( raw, ( data + offset ), remaining ); /* Shrink cursor */ asn1_shrink_any ( *cursor ); @@ -83,30 +82,21 @@ int der_asn1 ( userptr_t data, size_t len, size_t offset, */ static int der_image_probe ( struct image *image ) { struct asn1_cursor cursor; - uint8_t buf[8]; - size_t extra; int rc; - /* Sanity check: no realistic DER image can be smaller than this */ - if ( image->len < sizeof ( buf ) ) - return -ENOEXEC; - - /* Prepare partial cursor */ - cursor.data = buf; - cursor.len = sizeof ( buf ); - copy_from_user ( buf, image->data, 0, sizeof ( buf ) ); - extra = ( image->len - sizeof ( buf ) ); + /* Prepare cursor */ + cursor.data = image->data; + cursor.len = image->len; /* Check that image begins with an ASN.1 sequence object */ - if ( ( rc = asn1_enter_partial ( &cursor, ASN1_SEQUENCE, - &extra ) ) != 0 ) { + if ( ( rc = asn1_skip ( &cursor, ASN1_SEQUENCE ) ) != 0 ) { DBGC ( image, "DER %s is not valid ASN.1: %s\n", image->name, strerror ( rc ) ); return rc; } /* Check that image comprises a single well-formed ASN.1 object */ - if ( extra != ( image->len - sizeof ( buf ) ) ) { + if ( cursor.len ) { DBGC ( image, "DER %s is not single ASN.1\n", image->name ); return -ENOEXEC; } diff --git a/src/image/efi_siglist.c b/src/image/efi_siglist.c index 56c8493d6..2bd273dbd 100644 --- a/src/image/efi_siglist.c +++ b/src/image/efi_siglist.c @@ -49,8 +49,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v dhdr Signature data header to fill in * @ret rc Return status code */ -static int efisig_find ( userptr_t data, size_t len, size_t *start, - EFI_SIGNATURE_LIST *lhdr, EFI_SIGNATURE_DATA *dhdr ) { +static int efisig_find ( const void *data, size_t len, size_t *start, + const EFI_SIGNATURE_LIST **lhdr, + const EFI_SIGNATURE_DATA **dhdr ) { size_t offset; size_t remaining; size_t skip; @@ -63,38 +64,38 @@ static int efisig_find ( userptr_t data, size_t len, size_t *start, /* Read list header */ assert ( offset <= len ); remaining = ( len - offset ); - if ( remaining < sizeof ( *lhdr ) ) { + if ( remaining < sizeof ( **lhdr ) ) { DBGC ( data, "EFISIG [%#zx,%#zx) truncated header " "at +%#zx\n", *start, len, offset ); return -EINVAL; } - copy_from_user ( lhdr, data, offset, sizeof ( *lhdr ) ); + *lhdr = ( data + offset ); /* Get length of this signature list */ - if ( remaining < lhdr->SignatureListSize ) { + if ( remaining < (*lhdr)->SignatureListSize ) { DBGC ( data, "EFISIG [%#zx,%#zx) truncated list at " "+%#zx\n", *start, len, offset ); return -EINVAL; } - remaining = lhdr->SignatureListSize; + remaining = (*lhdr)->SignatureListSize; /* Get length of each signature in list */ - dlen = lhdr->SignatureSize; - if ( dlen < sizeof ( *dhdr ) ) { + dlen = (*lhdr)->SignatureSize; + if ( dlen < sizeof ( **dhdr ) ) { DBGC ( data, "EFISIG [%#zx,%#zx) underlength " "signatures at +%#zx\n", *start, len, offset ); return -EINVAL; } /* Strip list header (including variable portion) */ - if ( ( remaining < sizeof ( *lhdr ) ) || - ( ( remaining - sizeof ( *lhdr ) ) < - lhdr->SignatureHeaderSize ) ) { + if ( ( remaining < sizeof ( **lhdr ) ) || + ( ( remaining - sizeof ( **lhdr ) ) < + (*lhdr)->SignatureHeaderSize ) ) { DBGC ( data, "EFISIG [%#zx,%#zx) malformed header at " "+%#zx\n", *start, len, offset ); return -EINVAL; } - skip = ( sizeof ( *lhdr ) + lhdr->SignatureHeaderSize ); + skip = ( sizeof ( **lhdr ) + (*lhdr)->SignatureHeaderSize ); offset += skip; remaining -= skip; @@ -113,12 +114,12 @@ static int efisig_find ( userptr_t data, size_t len, size_t *start, continue; /* Read data header */ - copy_from_user ( dhdr, data, offset, sizeof ( *dhdr )); + *dhdr = ( data + offset ); DBGC2 ( data, "EFISIG [%#zx,%#zx) %s ", offset, ( offset + dlen ), - efi_guid_ntoa ( &lhdr->SignatureType ) ); + efi_guid_ntoa ( &(*lhdr)->SignatureType ) ); DBGC2 ( data, "owner %s\n", - efi_guid_ntoa ( &dhdr->SignatureOwner ) ); + efi_guid_ntoa ( &(*dhdr)->SignatureOwner ) ); *start = offset; return 0; } @@ -137,23 +138,23 @@ static int efisig_find ( userptr_t data, size_t len, size_t *start, * The caller is responsible for eventually calling free() on the * allocated ASN.1 cursor. */ -int efisig_asn1 ( userptr_t data, size_t len, size_t offset, +int efisig_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ) { - EFI_SIGNATURE_LIST lhdr; - EFI_SIGNATURE_DATA dhdr; - int ( * asn1 ) ( userptr_t data, size_t len, size_t offset, + const EFI_SIGNATURE_LIST *lhdr; + const EFI_SIGNATURE_DATA *dhdr; + int ( * asn1 ) ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); - size_t skip = offsetof ( typeof ( dhdr ), SignatureData ); + size_t skip = offsetof ( typeof ( *dhdr ), SignatureData ); int next; int rc; /* Locate signature list entry */ if ( ( rc = efisig_find ( data, len, &offset, &lhdr, &dhdr ) ) != 0 ) goto err_entry; - len = ( offset + lhdr.SignatureSize ); + len = ( offset + lhdr->SignatureSize ); /* Parse as PEM or DER based on first character */ - asn1 = ( ( dhdr.SignatureData[0] == ASN1_SEQUENCE ) ? + asn1 = ( ( dhdr->SignatureData[0] == ASN1_SEQUENCE ) ? der_asn1 : pem_asn1 ); DBGC2 ( data, "EFISIG [%#zx,%#zx) extracting %s\n", offset, len, ( ( asn1 == der_asn1 ) ? "DER" : "PEM" ) ); @@ -189,8 +190,8 @@ int efisig_asn1 ( userptr_t data, size_t len, size_t offset, * @ret rc Return status code */ static int efisig_image_probe ( struct image *image ) { - EFI_SIGNATURE_LIST lhdr; - EFI_SIGNATURE_DATA dhdr; + const EFI_SIGNATURE_LIST *lhdr; + const EFI_SIGNATURE_DATA *dhdr; size_t offset = 0; unsigned int count = 0; int rc; @@ -205,7 +206,7 @@ static int efisig_image_probe ( struct image *image ) { } /* Skip this entry */ - offset += lhdr.SignatureSize; + offset += lhdr->SignatureSize; count++; /* Check if we have reached end of the image */ diff --git a/src/image/pem.c b/src/image/pem.c index 2dcc36442..caff822ad 100644 --- a/src/image/pem.c +++ b/src/image/pem.c @@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include @@ -46,14 +45,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v offset Starting offset * @ret next Offset to next line */ -static size_t pem_next ( userptr_t data, size_t len, size_t offset ) { - off_t eol; +static size_t pem_next ( const void *data, size_t len, size_t offset ) { + const void *sep; /* Find and skip next newline character, if any */ - eol = memchr_user ( data, offset, '\n', ( len - offset ) ); - if ( eol < 0 ) + sep = memchr ( ( data + offset ), '\n', ( len - offset ) ); + if ( ! sep ) return len; - return ( eol + 1 ); + return ( ( sep - data ) + 1 ); } /** @@ -65,9 +64,9 @@ static size_t pem_next ( userptr_t data, size_t len, size_t offset ) { * @v marker Boundary marker * @ret offset Offset to boundary marker line, or negative error */ -static int pem_marker ( userptr_t data, size_t len, size_t offset, +static int pem_marker ( const void *data, size_t len, size_t offset, const char *marker ) { - char buf[ strlen ( marker ) ]; + size_t marker_len = strlen ( marker ); /* Sanity check */ assert ( offset <= len ); @@ -76,10 +75,9 @@ static int pem_marker ( userptr_t data, size_t len, size_t offset, while ( offset < len ) { /* Check for marker */ - if ( ( len - offset ) < sizeof ( buf ) ) + if ( ( len - offset ) < marker_len ) break; - copy_from_user ( buf, data, offset, sizeof ( buf ) ); - if ( memcmp ( buf, marker, sizeof ( buf ) ) == 0 ) + if ( memcmp ( ( data + offset ), marker, marker_len ) == 0 ) return offset; /* Move to next line */ @@ -102,7 +100,7 @@ static int pem_marker ( userptr_t data, size_t len, size_t offset, * The caller is responsible for eventually calling free() on the * allocated ASN.1 cursor. */ -int pem_asn1 ( userptr_t data, size_t len, size_t offset, +int pem_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ) { size_t encoded_len; size_t decoded_max_len; @@ -140,7 +138,7 @@ int pem_asn1 ( userptr_t data, size_t len, size_t offset, rc = -ENOMEM; goto err_alloc_encoded; } - copy_from_user ( encoded, data, begin, encoded_len ); + memcpy ( encoded, ( data + begin ), encoded_len ); encoded[encoded_len] = '\0'; /* Allocate cursor and data buffer */ diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h index 8a7461cd3..9528c40f5 100644 --- a/src/include/ipxe/asn1.h +++ b/src/include/ipxe/asn1.h @@ -481,8 +481,6 @@ asn1_built ( struct asn1_builder *builder ) { return &u->cursor; } -extern int asn1_enter_partial ( struct asn1_cursor *cursor, unsigned int type, - size_t *extra ); extern int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ); extern int asn1_skip_if_exists ( struct asn1_cursor *cursor, unsigned int type ); diff --git a/src/include/ipxe/der.h b/src/include/ipxe/der.h index 983aeb23c..512bc0853 100644 --- a/src/include/ipxe/der.h +++ b/src/include/ipxe/der.h @@ -13,7 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -extern int der_asn1 ( userptr_t data, size_t len, size_t offset, +extern int der_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); extern struct image_type der_image_type __image_type ( PROBE_NORMAL ); diff --git a/src/include/ipxe/efi/efi_siglist.h b/src/include/ipxe/efi/efi_siglist.h index 177f28b00..cbc835dc0 100644 --- a/src/include/ipxe/efi/efi_siglist.h +++ b/src/include/ipxe/efi/efi_siglist.h @@ -10,11 +10,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include -extern int efisig_asn1 ( userptr_t data, size_t len, size_t offset, +extern int efisig_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); extern struct image_type efisig_image_type __image_type ( PROBE_NORMAL ); diff --git a/src/include/ipxe/pem.h b/src/include/ipxe/pem.h index d88ec5b6f..d9ca017d5 100644 --- a/src/include/ipxe/pem.h +++ b/src/include/ipxe/pem.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include @@ -20,7 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Post-encapsulation boundary marker */ #define PEM_END "-----END" -extern int pem_asn1 ( userptr_t data, size_t len, size_t offset, +extern int pem_asn1 ( const void *data, size_t len, size_t offset, struct asn1_cursor **cursor ); extern struct image_type pem_image_type __image_type ( PROBE_NORMAL ); diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c index 5cc268b0e..2b6c5c343 100644 --- a/src/interface/efi/efi_cacert.c +++ b/src/interface/efi/efi_cacert.c @@ -54,14 +54,14 @@ static struct x509_chain efi_cacerts = { * @v offset Offset within data * @v next Next offset, or negative error */ -static int efi_cacert ( void *data, size_t len, size_t offset ) { +static int efi_cacert ( const void *data, size_t len, size_t offset ) { struct asn1_cursor *cursor; struct x509_certificate *cert; int next; int rc; /* Extract ASN.1 object */ - next = efisig_asn1 ( virt_to_user ( data ), len, offset, &cursor ); + next = efisig_asn1 ( data, len, offset, &cursor ); if ( next < 0 ) { rc = next; DBGC ( &efi_cacerts, "EFICA could not parse at +%#zx: %s\n", -- cgit v1.2.3-55-g7522 From 0b3fc48fefd311b17b666fecf3a34688717727e8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 22 Apr 2025 14:13:45 +0100 Subject: [acpi] Remove userptr_t from ACPI table parsing Simplify the ACPI table parsing code by assuming that all table content is fully accessible via pointer dereferences. Signed-off-by: Michael Brown --- src/arch/x86/include/ipxe/rsdp.h | 4 +- src/arch/x86/interface/pcbios/acpi_timer.c | 9 +-- src/arch/x86/interface/pcbios/acpipwr.c | 18 ++--- src/arch/x86/interface/pcbios/rsdp.c | 33 ++++---- src/core/acpi.c | 116 +++++++++++++---------------- src/core/acpi_settings.c | 21 +++--- src/core/acpimac.c | 17 +++-- src/drivers/bus/ecam.c | 34 ++++----- src/include/ipxe/acpi.h | 24 +++--- src/include/ipxe/efi/efi_acpi.h | 4 +- src/include/ipxe/null_acpi.h | 6 +- src/interface/efi/efi_acpi.c | 7 +- src/interface/linux/linux_acpi.c | 9 ++- src/tests/acpi_test.c | 12 +-- 14 files changed, 152 insertions(+), 162 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/include/ipxe/rsdp.h b/src/arch/x86/include/ipxe/rsdp.h index 14afcd774..daaa43077 100644 --- a/src/arch/x86/include/ipxe/rsdp.h +++ b/src/arch/x86/include/ipxe/rsdp.h @@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) const struct acpi_header * ACPI_INLINE ( rsdp, acpi_find ) ( uint32_t signature, unsigned int index ) { return acpi_find_via_rsdt ( signature, index ); diff --git a/src/arch/x86/interface/pcbios/acpi_timer.c b/src/arch/x86/interface/pcbios/acpi_timer.c index 2e4047e38..e1523578b 100644 --- a/src/arch/x86/interface/pcbios/acpi_timer.c +++ b/src/arch/x86/interface/pcbios/acpi_timer.c @@ -102,20 +102,19 @@ static void acpi_udelay ( unsigned long usecs ) { * @ret rc Return status code */ static int acpi_timer_probe ( void ) { - struct acpi_fadt fadtab; - userptr_t fadt; + const struct acpi_fadt *fadt; unsigned int pm_tmr_blk; /* Locate FADT */ - fadt = acpi_table ( FADT_SIGNATURE, 0 ); + fadt = container_of ( acpi_table ( FADT_SIGNATURE, 0 ), + struct acpi_fadt, acpi ); if ( ! fadt ) { DBGC ( &acpi_timer, "ACPI could not find FADT\n" ); return -ENOENT; } /* Read FADT */ - copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - pm_tmr_blk = le32_to_cpu ( fadtab.pm_tmr_blk ); + pm_tmr_blk = le32_to_cpu ( fadt->pm_tmr_blk ); if ( ! pm_tmr_blk ) { DBGC ( &acpi_timer, "ACPI has no timer\n" ); return -ENOENT; diff --git a/src/arch/x86/interface/pcbios/acpipwr.c b/src/arch/x86/interface/pcbios/acpipwr.c index f08b4af25..bff53806b 100644 --- a/src/arch/x86/interface/pcbios/acpipwr.c +++ b/src/arch/x86/interface/pcbios/acpipwr.c @@ -62,8 +62,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * uglier hacks I have ever implemented, but it's still prettier than * the ACPI specification itself. */ -static int acpi_extract_sx ( userptr_t zsdt, size_t len, size_t offset, - void *data ) { +static int acpi_extract_sx ( const struct acpi_header *zsdt, size_t len, + size_t offset, void *data ) { unsigned int *sx = data; uint8_t bytes[4]; uint8_t *byte; @@ -77,7 +77,8 @@ static int acpi_extract_sx ( userptr_t zsdt, size_t len, size_t offset, } /* Read first four bytes of value */ - copy_from_user ( bytes, zsdt, offset, sizeof ( bytes ) ); + memcpy ( bytes, ( ( ( const void * ) zsdt ) + offset ), + sizeof ( bytes ) ); DBGC ( colour, "ACPI found \\_Sx containing %02x:%02x:%02x:%02x\n", bytes[0], bytes[1], bytes[2], bytes[3] ); @@ -111,8 +112,7 @@ static int acpi_extract_sx ( userptr_t zsdt, size_t len, size_t offset, * @ret rc Return status code */ int acpi_poweroff ( void ) { - struct acpi_fadt fadtab; - userptr_t fadt; + const struct acpi_fadt *fadt; unsigned int pm1a_cnt_blk; unsigned int pm1b_cnt_blk; unsigned int pm1a_cnt; @@ -123,16 +123,16 @@ int acpi_poweroff ( void ) { int rc; /* Locate FADT */ - fadt = acpi_table ( FADT_SIGNATURE, 0 ); + fadt = container_of ( acpi_table ( FADT_SIGNATURE, 0 ), + struct acpi_fadt, acpi ); if ( ! fadt ) { DBGC ( colour, "ACPI could not find FADT\n" ); return -ENOENT; } /* Read FADT */ - copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - pm1a_cnt_blk = le32_to_cpu ( fadtab.pm1a_cnt_blk ); - pm1b_cnt_blk = le32_to_cpu ( fadtab.pm1b_cnt_blk ); + pm1a_cnt_blk = le32_to_cpu ( fadt->pm1a_cnt_blk ); + pm1b_cnt_blk = le32_to_cpu ( fadt->pm1b_cnt_blk ); pm1a_cnt = ( pm1a_cnt_blk + ACPI_PM1_CNT ); pm1b_cnt = ( pm1b_cnt_blk + ACPI_PM1_CNT ); diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index c2534c7f6..6bcf19b18 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -53,50 +53,51 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v start Start address to search * @v len Length to search - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -static userptr_t rsdp_find_rsdt_range ( userptr_t start, size_t len ) { +static const struct acpi_rsdt * rsdp_find_rsdt_range ( const void *start, + size_t len ) { static const char signature[8] = RSDP_SIGNATURE; - struct acpi_rsdp rsdp; - userptr_t rsdt; + const struct acpi_rsdp *rsdp; + const struct acpi_rsdt *rsdt; size_t offset; uint8_t sum; unsigned int i; /* Search for RSDP */ - for ( offset = 0 ; ( ( offset + sizeof ( rsdp ) ) < len ) ; + for ( offset = 0 ; ( ( offset + sizeof ( *rsdp ) ) < len ) ; offset += RSDP_STRIDE ) { /* Check signature and checksum */ - copy_from_user ( &rsdp, start, offset, sizeof ( rsdp ) ); - if ( memcmp ( rsdp.signature, signature, + rsdp = ( start + offset ); + if ( memcmp ( rsdp->signature, signature, sizeof ( signature ) ) != 0 ) continue; - for ( sum = 0, i = 0 ; i < sizeof ( rsdp ) ; i++ ) - sum += *( ( ( uint8_t * ) &rsdp ) + i ); + for ( sum = 0, i = 0 ; i < sizeof ( *rsdp ) ; i++ ) + sum += *( ( ( uint8_t * ) rsdp ) + i ); if ( sum != 0 ) continue; /* Extract RSDT */ - rsdt = phys_to_virt ( le32_to_cpu ( rsdp.rsdt ) ); + rsdt = phys_to_virt ( le32_to_cpu ( rsdp->rsdt ) ); DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n", virt_to_phys ( rsdt ), ( virt_to_phys ( start ) + offset ) ); return rsdt; } - return UNULL; + return NULL; } /** * Locate ACPI root system description table * - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -static userptr_t rsdp_find_rsdt ( void ) { - static userptr_t rsdt; +static const struct acpi_rsdt * rsdp_find_rsdt ( void ) { + static const struct acpi_rsdt *rsdt; + const void *ebda; uint16_t ebda_seg; - userptr_t ebda; size_t ebda_len; /* Return existing RSDT if already found */ @@ -119,7 +120,7 @@ static userptr_t rsdp_find_rsdt ( void ) { if ( rsdt ) return rsdt; - return UNULL; + return NULL; } PROVIDE_ACPI ( rsdp, acpi_find_rsdt, rsdp_find_rsdt ); diff --git a/src/core/acpi.c b/src/core/acpi.c index d7da0ccc1..6c5d1e079 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include @@ -54,25 +55,17 @@ typeof ( acpi_find ) *acpi_finder __attribute__ (( weak )) = acpi_find; /** * Compute ACPI table checksum * - * @v table Any ACPI table + * @v acpi Any ACPI table header * @ret checksum 0 if checksum is good */ -static uint8_t acpi_checksum ( userptr_t table ) { - struct acpi_header acpi; +static uint8_t acpi_checksum ( const struct acpi_header *acpi ) { + const uint8_t *byte = ( ( const void * ) acpi ); + size_t len = le32_to_cpu ( acpi->length ); uint8_t sum = 0; - uint8_t data = 0; - unsigned int i; - - /* Read table length */ - copy_from_user ( &acpi.length, table, - offsetof ( typeof ( acpi ), length ), - sizeof ( acpi.length ) ); /* Compute checksum */ - for ( i = 0 ; i < le32_to_cpu ( acpi.length ) ; i++ ) { - copy_from_user ( &data, table, i, sizeof ( data ) ); - sum += data; - } + while ( len-- ) + sum += *(byte++); return sum; } @@ -85,7 +78,7 @@ static uint8_t acpi_checksum ( userptr_t table ) { void acpi_fix_checksum ( struct acpi_header *acpi ) { /* Update checksum */ - acpi->checksum -= acpi_checksum ( virt_to_user ( acpi ) ); + acpi->checksum -= acpi_checksum ( acpi ); } /** @@ -93,9 +86,10 @@ void acpi_fix_checksum ( struct acpi_header *acpi ) { * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -userptr_t acpi_table ( uint32_t signature, unsigned int index ) { +const struct acpi_header * acpi_table ( uint32_t signature, + unsigned int index ) { return ( *acpi_finder ) ( signature, index ); } @@ -105,14 +99,12 @@ userptr_t acpi_table ( uint32_t signature, unsigned int index ) { * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { - struct acpi_header acpi; - struct acpi_rsdt *rsdtab; - typeof ( rsdtab->entry[0] ) entry; - userptr_t rsdt; - userptr_t table; +const struct acpi_header * acpi_find_via_rsdt ( uint32_t signature, + unsigned int index ) { + const struct acpi_rsdt *rsdt; + const struct acpi_header *table; size_t len; unsigned int count; unsigned int i; @@ -121,45 +113,38 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { rsdt = acpi_find_rsdt(); if ( ! rsdt ) { DBG ( "RSDT not found\n" ); - return UNULL; + return NULL; } /* Read RSDT header */ - copy_from_user ( &acpi, rsdt, 0, sizeof ( acpi ) ); - if ( acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) { + if ( rsdt->acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) { DBGC ( colour, "RSDT %#08lx has invalid signature:\n", virt_to_phys ( rsdt ) ); - DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, - sizeof ( acpi ) ); - return UNULL; + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &rsdt->acpi, + sizeof ( rsdt->acpi ) ); + return NULL; } - len = le32_to_cpu ( acpi.length ); - if ( len < sizeof ( rsdtab->acpi ) ) { + len = le32_to_cpu ( rsdt->acpi.length ); + if ( len < sizeof ( rsdt->acpi ) ) { DBGC ( colour, "RSDT %#08lx has invalid length:\n", virt_to_phys ( rsdt ) ); - DBGC_HDA ( colour, virt_to_phys ( rsdt ), &acpi, - sizeof ( acpi ) ); - return UNULL; + DBGC_HDA ( colour, virt_to_phys ( rsdt ), &rsdt->acpi, + sizeof ( rsdt->acpi ) ); + return NULL; } /* Calculate number of entries */ - count = ( ( len - sizeof ( rsdtab->acpi ) ) / sizeof ( entry ) ); + count = ( ( len - sizeof ( rsdt->acpi ) ) / + sizeof ( rsdt->entry[0] ) ); /* Search through entries */ for ( i = 0 ; i < count ; i++ ) { - /* Get table address */ - copy_from_user ( &entry, rsdt, - offsetof ( typeof ( *rsdtab ), entry[i] ), - sizeof ( entry ) ); - /* Read table header */ - table = phys_to_virt ( entry ); - copy_from_user ( &acpi.signature, table, 0, - sizeof ( acpi.signature ) ); + table = phys_to_virt ( rsdt->entry[i] ); /* Check table signature */ - if ( acpi.signature != cpu_to_le32 ( signature ) ) + if ( table->signature != cpu_to_le32 ( signature ) ) continue; /* Check index */ @@ -169,13 +154,13 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { /* Check table integrity */ if ( acpi_checksum ( table ) != 0 ) { DBGC ( colour, "RSDT %#08lx found %s with bad " - "checksum at %08lx\n", virt_to_phys ( rsdt ), + "checksum at %#08lx\n", virt_to_phys ( rsdt ), acpi_name ( signature ), virt_to_phys ( table ) ); break; } - DBGC ( colour, "RSDT %#08lx found %s at %08lx\n", + DBGC ( colour, "RSDT %#08lx found %s at %#08lx\n", virt_to_phys ( rsdt ), acpi_name ( signature ), virt_to_phys ( table ) ); return table; @@ -183,7 +168,7 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { DBGC ( colour, "RSDT %#08lx could not find %s\n", virt_to_phys ( rsdt ), acpi_name ( signature ) ); - return UNULL; + return NULL; } /** @@ -195,26 +180,27 @@ userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { * @v extract Extraction method * @ret rc Return status code */ -static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data, - int ( * extract ) ( userptr_t zsdt, size_t len, - size_t offset, void *data ) ) { - struct acpi_header acpi; +static int acpi_zsdt ( const struct acpi_header *zsdt, + uint32_t signature, void *data, + int ( * extract ) ( const struct acpi_header *zsdt, + size_t len, size_t offset, + void *data ) ) { uint32_t buf; size_t offset; size_t len; int rc; /* Read table header */ - copy_from_user ( &acpi, zsdt, 0, sizeof ( acpi ) ); - len = le32_to_cpu ( acpi.length ); + len = le32_to_cpu ( zsdt->length ); /* Locate signature */ - for ( offset = sizeof ( acpi ) ; + for ( offset = sizeof ( *zsdt ) ; ( ( offset + sizeof ( buf ) /* signature */ ) < len ) ; offset++ ) { /* Check signature */ - copy_from_user ( &buf, zsdt, offset, sizeof ( buf ) ); + memcpy ( &buf, ( ( ( const void * ) zsdt ) + offset ), + sizeof ( buf ) ); if ( buf != cpu_to_le32 ( signature ) ) continue; DBGC ( zsdt, "DSDT/SSDT %#08lx found %s at offset %#zx\n", @@ -238,20 +224,20 @@ static int acpi_zsdt ( userptr_t zsdt, uint32_t signature, void *data, * @ret rc Return status code */ int acpi_extract ( uint32_t signature, void *data, - int ( * extract ) ( userptr_t zsdt, size_t len, - size_t offset, void *data ) ) { - struct acpi_fadt fadtab; - userptr_t fadt; - userptr_t dsdt; - userptr_t ssdt; + int ( * extract ) ( const struct acpi_header *zsdt, + size_t len, size_t offset, + void *data ) ) { + const struct acpi_fadt *fadt; + const struct acpi_header *dsdt; + const struct acpi_header *ssdt; unsigned int i; int rc; /* Try DSDT first */ - fadt = acpi_table ( FADT_SIGNATURE, 0 ); + fadt = container_of ( acpi_table ( FADT_SIGNATURE, 0 ), + struct acpi_fadt, acpi ); if ( fadt ) { - copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) ); - dsdt = phys_to_virt ( fadtab.dsdt ); + dsdt = phys_to_virt ( fadt->dsdt ); if ( ( rc = acpi_zsdt ( dsdt, signature, data, extract ) ) == 0 ) return 0; diff --git a/src/core/acpi_settings.c b/src/core/acpi_settings.c index b9e2b7f61..cdee1f865 100644 --- a/src/core/acpi_settings.c +++ b/src/core/acpi_settings.c @@ -64,14 +64,15 @@ static int acpi_settings_applies ( struct settings *settings __unused, static int acpi_settings_fetch ( struct settings *settings, struct setting *setting, void *data, size_t len ) { - struct acpi_header acpi; + const struct acpi_header *acpi; + const uint8_t *src; + uint8_t *dst; uint32_t tag_high; uint32_t tag_low; uint32_t tag_signature; unsigned int tag_index; size_t tag_offset; size_t tag_len; - userptr_t table; size_t offset; size_t max_len; int delta; @@ -88,15 +89,12 @@ static int acpi_settings_fetch ( struct settings *settings, acpi_name ( tag_signature ), tag_index, tag_offset, tag_len ); /* Locate ACPI table */ - table = acpi_table ( tag_signature, tag_index ); - if ( ! table ) + acpi = acpi_table ( tag_signature, tag_index ); + if ( ! acpi ) return -ENOENT; - /* Read table header */ - copy_from_user ( &acpi, table, 0, sizeof ( acpi ) ); - /* Calculate starting offset and maximum available length */ - max_len = le32_to_cpu ( acpi.length ); + max_len = le32_to_cpu ( acpi->length ); if ( tag_offset > max_len ) return -ENOENT; offset = tag_offset; @@ -115,10 +113,11 @@ static int acpi_settings_fetch ( struct settings *settings, } /* Read data */ + src = ( ( ( const void * ) acpi ) + offset ); + dst = data; for ( i = 0 ; ( ( i < max_len ) && ( i < len ) ) ; i++ ) { - copy_from_user ( data, table, offset, 1 ); - data++; - offset += delta; + *(dst++) = *src; + src += delta; } /* Set type if not already specified */ diff --git a/src/core/acpimac.c b/src/core/acpimac.c index e0074ba43..11ac3243e 100644 --- a/src/core/acpimac.c +++ b/src/core/acpimac.c @@ -142,8 +142,9 @@ static struct acpimac_extractor acpimac_rtxmac = { * string that appears shortly after an "AMAC" or "MACA" signature. * This should work for most implementations encountered in practice. */ -static int acpimac_extract ( userptr_t zsdt, size_t len, size_t offset, - void *data, struct acpimac_extractor *extractor ){ +static int acpimac_extract ( const struct acpi_header *zsdt, size_t len, + size_t offset, void *data, + struct acpimac_extractor *extractor ) { size_t prefix_len = strlen ( extractor->prefix ); uint8_t *hw_addr = data; size_t skip = 0; @@ -161,8 +162,8 @@ static int acpimac_extract ( userptr_t zsdt, size_t len, size_t offset, skip++ ) { /* Read value */ - copy_from_user ( buf, zsdt, ( offset + skip ), - sizeof ( buf ) ); + memcpy ( buf, ( ( ( const void * ) zsdt ) + offset + skip ), + sizeof ( buf ) ); /* Check for expected format */ if ( memcmp ( buf, extractor->prefix, prefix_len ) != 0 ) @@ -203,8 +204,8 @@ static int acpimac_extract ( userptr_t zsdt, size_t len, size_t offset, * @v data Data buffer * @ret rc Return status code */ -static int acpimac_extract_auxmac ( userptr_t zsdt, size_t len, size_t offset, - void *data ) { +static int acpimac_extract_auxmac ( const struct acpi_header *zsdt, + size_t len, size_t offset, void *data ) { return acpimac_extract ( zsdt, len, offset, data, &acpimac_auxmac ); } @@ -218,8 +219,8 @@ static int acpimac_extract_auxmac ( userptr_t zsdt, size_t len, size_t offset, * @v data Data buffer * @ret rc Return status code */ -static int acpimac_extract_rtxmac ( userptr_t zsdt, size_t len, size_t offset, - void *data ) { +static int acpimac_extract_rtxmac ( const struct acpi_header *zsdt, + size_t len, size_t offset, void *data ) { return acpimac_extract ( zsdt, len, offset, data, &acpimac_rtxmac ); } diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index cde5952b8..58d513e88 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -46,49 +46,43 @@ static struct ecam_mapping ecam; */ static int ecam_find ( uint32_t busdevfn, struct pci_range *range, struct ecam_allocation *alloc ) { - struct ecam_allocation tmp; + struct ecam_table *mcfg; + struct ecam_allocation *tmp; unsigned int best = 0; - unsigned int offset; unsigned int count; unsigned int index; - userptr_t mcfg; - uint32_t length; + unsigned int i; uint32_t start; /* Return empty range on error */ range->count = 0; /* Locate MCFG table */ - mcfg = acpi_table ( ECAM_SIGNATURE, 0 ); + mcfg = container_of ( acpi_table ( ECAM_SIGNATURE, 0 ), + struct ecam_table, acpi ); if ( ! mcfg ) { DBGC ( &ecam, "ECAM found no MCFG table\n" ); return -ENOTSUP; } - /* Get length of table */ - copy_from_user ( &length, mcfg, - offsetof ( struct ecam_table, acpi.length ), - sizeof ( length ) ); - /* Iterate over allocations */ - for ( offset = offsetof ( struct ecam_table, alloc ) ; - ( offset + sizeof ( tmp ) ) <= le32_to_cpu ( length ) ; - offset += sizeof ( tmp ) ) { + for ( i = 0 ; ( offsetof ( typeof ( *mcfg ), alloc[ i + 1 ] ) <= + le32_to_cpu ( mcfg->acpi.length ) ) ; i++ ) { /* Read allocation */ - copy_from_user ( &tmp, mcfg, offset, sizeof ( tmp ) ); + tmp = &mcfg->alloc[i]; DBGC2 ( &ecam, "ECAM %04x:[%02x-%02x] has base %08llx\n", - le16_to_cpu ( tmp.segment ), tmp.start, tmp.end, - ( ( unsigned long long ) le64_to_cpu ( tmp.base ) ) ); - start = PCI_BUSDEVFN ( le16_to_cpu ( tmp.segment ), - tmp.start, 0, 0 ); - count = PCI_BUSDEVFN ( 0, ( tmp.end - tmp.start + 1 ), 0, 0 ); + le16_to_cpu ( tmp->segment ), tmp->start, tmp->end, + ( ( unsigned long long ) le64_to_cpu ( tmp->base ) ) ); + start = PCI_BUSDEVFN ( le16_to_cpu ( tmp->segment ), + tmp->start, 0, 0 ); + count = PCI_BUSDEVFN ( 0, ( tmp->end - tmp->start + 1 ), 0, 0 ); /* Check for a matching or new closest allocation */ index = ( busdevfn - start ); if ( ( index < count ) || ( index > best ) ) { if ( alloc ) - memcpy ( alloc, &tmp, sizeof ( *alloc ) ); + memcpy ( alloc, tmp, sizeof ( *alloc ) ); range->start = start; range->count = count; best = index; diff --git a/src/include/ipxe/acpi.h b/src/include/ipxe/acpi.h index c34681238..40a44cffc 100644 --- a/src/include/ipxe/acpi.h +++ b/src/include/ipxe/acpi.h @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -355,7 +354,8 @@ struct acpi_model { #define PROVIDE_ACPI_INLINE( _subsys, _api_func ) \ PROVIDE_SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func ) -extern userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ); +extern const struct acpi_header * acpi_find_via_rsdt ( uint32_t signature, + unsigned int index ); /* Include all architecture-independent ACPI API headers */ #include @@ -368,31 +368,35 @@ extern userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ); /** * Locate ACPI root system description table * - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -userptr_t acpi_find_rsdt ( void ); +const struct acpi_rsdt * acpi_find_rsdt ( void ); /** * Locate ACPI table * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -userptr_t acpi_find ( uint32_t signature, unsigned int index ); +const struct acpi_header * acpi_find ( uint32_t signature, + unsigned int index ); extern struct acpi_descriptor * acpi_describe ( struct interface *interface ); #define acpi_describe_TYPE( object_type ) \ typeof ( struct acpi_descriptor * ( object_type ) ) -extern userptr_t ( * acpi_finder ) ( uint32_t signature, unsigned int index ); +extern const struct acpi_header * ( * acpi_finder ) ( uint32_t signature, + unsigned int index ); extern void acpi_fix_checksum ( struct acpi_header *acpi ); -extern userptr_t acpi_table ( uint32_t signature, unsigned int index ); +extern const struct acpi_header * acpi_table ( uint32_t signature, + unsigned int index ); extern int acpi_extract ( uint32_t signature, void *data, - int ( * extract ) ( userptr_t zsdt, size_t len, - size_t offset, void *data ) ); + int ( * extract ) ( const struct acpi_header *zsdt, + size_t len, size_t offset, + void *data ) ); extern void acpi_add ( struct acpi_descriptor *desc ); extern void acpi_del ( struct acpi_descriptor *desc ); extern int acpi_install ( int ( * install ) ( struct acpi_header *acpi ) ); diff --git a/src/include/ipxe/efi/efi_acpi.h b/src/include/ipxe/efi/efi_acpi.h index a698863a6..68f9c5be7 100644 --- a/src/include/ipxe/efi/efi_acpi.h +++ b/src/include/ipxe/efi/efi_acpi.h @@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) const struct acpi_header * ACPI_INLINE ( efi, acpi_find ) ( uint32_t signature, unsigned int index ) { return acpi_find_via_rsdt ( signature, index ); diff --git a/src/include/ipxe/null_acpi.h b/src/include/ipxe/null_acpi.h index cedb02839..18f059964 100644 --- a/src/include/ipxe/null_acpi.h +++ b/src/include/ipxe/null_acpi.h @@ -9,17 +9,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include + #ifdef ACPI_NULL #define ACPI_PREFIX_null #else #define ACPI_PREFIX_null __null_ #endif -static inline __attribute__ (( always_inline )) userptr_t +static inline __attribute__ (( always_inline )) const struct acpi_header * ACPI_INLINE ( null, acpi_find ) ( uint32_t signature __unused, unsigned int index __unused ) { - return UNULL; + return NULL; } #endif /* _IPXE_NULL_ACPI_H */ diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index c1046c01a..a2021a4f6 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include @@ -42,15 +43,15 @@ EFI_USE_TABLE ( ACPI_10_TABLE, &rsdp, 0 ); /** * Locate ACPI root system description table * - * @ret rsdt ACPI root system description table, or UNULL + * @ret rsdt ACPI root system description table, or NULL */ -static userptr_t efi_find_rsdt ( void ) { +static const struct acpi_rsdt * efi_find_rsdt ( void ) { /* Locate RSDT via ACPI configuration table, if available */ if ( rsdp ) return phys_to_virt ( rsdp->RsdtAddress ); - return UNULL; + return NULL; } PROVIDE_ACPI ( efi, acpi_find_rsdt, efi_find_rsdt ); diff --git a/src/interface/linux/linux_acpi.c b/src/interface/linux/linux_acpi.c index 846db2f1f..a2a8bf12e 100644 --- a/src/interface/linux/linux_acpi.c +++ b/src/interface/linux/linux_acpi.c @@ -42,7 +42,7 @@ struct linux_acpi_table { /** Index */ unsigned int index; /** Cached data */ - userptr_t data; + void *data; }; /** List of cached ACPI tables */ @@ -53,9 +53,10 @@ static LIST_HEAD ( linux_acpi_tables ); * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) { +static const struct acpi_header * linux_acpi_find ( uint32_t signature, + unsigned int index ) { struct linux_acpi_table *table; struct acpi_header *header; union { @@ -121,7 +122,7 @@ static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) { err_read: free ( table ); err_alloc: - return UNULL; + return NULL; } /** diff --git a/src/tests/acpi_test.c b/src/tests/acpi_test.c index 1ca5befaf..6e8840217 100644 --- a/src/tests/acpi_test.c +++ b/src/tests/acpi_test.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* Forcibly enable assertions */ #undef NDEBUG +#include #include #include #include @@ -185,26 +186,27 @@ static struct acpi_test_tables *acpi_test_tables; * * @v signature Requested table signature * @v index Requested index of table with this signature - * @ret table Table, or UNULL if not found + * @ret table Table, or NULL if not found */ -static userptr_t acpi_test_find ( uint32_t signature, unsigned int index ) { +static const struct acpi_header * acpi_test_find ( uint32_t signature, + unsigned int index ) { struct acpi_test_table *table; unsigned int i; /* Fail if no test tables are installed */ if ( ! acpi_test_tables ) - return UNULL; + return NULL; /* Scan through test tables */ for ( i = 0 ; i < acpi_test_tables->count ; i++ ) { table = acpi_test_tables->table[i]; if ( ( signature == le32_to_cpu ( table->signature.raw ) ) && ( index-- == 0 ) ) { - return virt_to_user ( table->data ); + return table->data; } } - return UNULL; + return NULL; } /** Override ACPI table finder */ -- cgit v1.2.3-55-g7522 From 0bf0f8716a3c7f85455707d8c2d727d130ee1024 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 23 Apr 2025 09:53:38 +0100 Subject: [smbios] Remove userptr_t from SMBIOS structure parsing Simplify the SMBIOS structure parsing code by assuming that all structure content is fully accessible via pointer dereferences. In particular, this allows the convoluted find_smbios_structure() and read_smbios_structure() to be combined into a single function smbios_structure() that just returns a direct pointer to the SMBIOS structure, with smbios_string() similarly now returning a direct pointer to the relevant string. Signed-off-by: Michael Brown --- src/arch/x86/interface/pcbios/bios_smbios.c | 36 ++-- src/drivers/net/smsc95xx.c | 93 ++++------- src/include/ipxe/smbios.h | 32 +--- src/interface/efi/efi_smbios.c | 1 + src/interface/linux/linux_smbios.c | 6 +- src/interface/smbios/smbios.c | 249 +++++++++++++--------------- src/interface/smbios/smbios_settings.c | 152 +++++++++-------- 7 files changed, 256 insertions(+), 313 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/interface/pcbios/bios_smbios.c b/src/arch/x86/interface/pcbios/bios_smbios.c index e43c74bad..aaec1eea1 100644 --- a/src/arch/x86/interface/pcbios/bios_smbios.c +++ b/src/arch/x86/interface/pcbios/bios_smbios.c @@ -45,19 +45,18 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ static int bios_find_smbios2 ( struct smbios *smbios ) { - struct smbios_entry entry; - int rc; + const struct smbios_entry *entry; /* Scan through BIOS segment to find SMBIOS 32-bit entry point */ - if ( ( rc = find_smbios_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000, - &entry ) ) != 0 ) - return rc; + entry = find_smbios_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000 ); + if ( ! entry ) + return -ENOENT; /* Fill in entry point descriptor structure */ - smbios->address = phys_to_virt ( entry.smbios_address ); - smbios->len = entry.smbios_len; - smbios->count = entry.smbios_count; - smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); + smbios->address = phys_to_virt ( entry->smbios_address ); + smbios->len = entry->smbios_len; + smbios->count = entry->smbios_count; + smbios->version = SMBIOS_VERSION ( entry->major, entry->minor ); return 0; } @@ -69,26 +68,25 @@ static int bios_find_smbios2 ( struct smbios *smbios ) { * @ret rc Return status code */ static int bios_find_smbios3 ( struct smbios *smbios ) { - struct smbios3_entry entry; - int rc; + const struct smbios3_entry *entry; /* Scan through BIOS segment to find SMBIOS 64-bit entry point */ - if ( ( rc = find_smbios3_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000, - &entry ) ) != 0 ) - return rc; + entry = find_smbios3_entry ( real_to_virt ( BIOS_SEG, 0 ), 0x10000 ); + if ( ! entry ) + return -ENOENT; /* Check that address is accessible */ - if ( entry.smbios_address > ~( ( physaddr_t ) 0 ) ) { + if ( entry->smbios_address > ~( ( physaddr_t ) 0 ) ) { DBG ( "SMBIOS3 at %08llx is inaccessible\n", - ( ( unsigned long long ) entry.smbios_address ) ); + ( ( unsigned long long ) entry->smbios_address ) ); return -ENOTSUP; } /* Fill in entry point descriptor structure */ - smbios->address = phys_to_virt ( entry.smbios_address ); - smbios->len = entry.smbios_len; + smbios->address = phys_to_virt ( entry->smbios_address ); + smbios->len = entry->smbios_len; smbios->count = 0; - smbios->version = SMBIOS_VERSION ( entry.major, entry.minor ); + smbios->version = SMBIOS_VERSION ( entry->major, entry->minor ); return 0; } diff --git a/src/drivers/net/smsc95xx.c b/src/drivers/net/smsc95xx.c index 3ec49584d..0210e9240 100644 --- a/src/drivers/net/smsc95xx.c +++ b/src/drivers/net/smsc95xx.c @@ -64,92 +64,67 @@ static struct profiler smsc95xx_out_profiler __profiler = */ static int smsc95xx_vm3_fetch_mac ( struct smscusb_device *smscusb ) { struct net_device *netdev = smscusb->netdev; - struct smbios_structure structure; - struct smbios_system_information system; - struct { - char manufacturer[ 10 /* "Honeywell" + NUL */ ]; - char product[ 4 /* "VM3" + NUL */ ]; - char mac[ base16_encoded_len ( ETH_ALEN ) + 1 /* NUL */ ]; - } strings; + const struct smbios_header *structure; + const struct smbios_system_information *system; + const char *manufacturer; + const char *product; + const char *mac; int len; int rc; /* Find system information */ - if ( ( rc = find_smbios_structure ( SMBIOS_TYPE_SYSTEM_INFORMATION, 0, - &structure ) ) != 0 ) { + structure = smbios_structure ( SMBIOS_TYPE_SYSTEM_INFORMATION, 0 ); + if ( ! structure ) { DBGC ( smscusb, "SMSC95XX %p could not find system " - "information: %s\n", smscusb, strerror ( rc ) ); - return rc; - } - - /* Read system information */ - if ( ( rc = read_smbios_structure ( &structure, &system, - sizeof ( system ) ) ) != 0 ) { - DBGC ( smscusb, "SMSC95XX %p could not read system " - "information: %s\n", smscusb, strerror ( rc ) ); - return rc; + "information\n", smscusb ); + return -ENOENT; } - - /* NUL-terminate all strings to be fetched */ - memset ( &strings, 0, sizeof ( strings ) ); + system = container_of ( structure, struct smbios_system_information, + header ); /* Fetch system manufacturer name */ - len = read_smbios_string ( &structure, system.manufacturer, - strings.manufacturer, - ( sizeof ( strings.manufacturer ) - 1 ) ); - if ( len < 0 ) { - rc = len; + manufacturer = smbios_string ( structure, system->manufacturer ); + if ( ! manufacturer ) { DBGC ( smscusb, "SMSC95XX %p could not read manufacturer " - "name: %s\n", smscusb, strerror ( rc ) ); - return rc; + "name\n", smscusb ); + return -ENOENT; } /* Fetch system product name */ - len = read_smbios_string ( &structure, system.product, strings.product, - ( sizeof ( strings.product ) - 1 ) ); - if ( len < 0 ) { - rc = len; - DBGC ( smscusb, "SMSC95XX %p could not read product name: " - "%s\n", smscusb, strerror ( rc ) ); - return rc; + product = smbios_string ( structure, system->product ); + if ( ! product ) { + DBGC ( smscusb, "SMSC95XX %p could not read product name\n", + smscusb ); + return -ENOENT; } /* Ignore non-VM3 devices */ - if ( ( strcmp ( strings.manufacturer, "Honeywell" ) != 0 ) || - ( strcmp ( strings.product, "VM3" ) != 0 ) ) + if ( ( strcmp ( manufacturer, "Honeywell" ) != 0 ) || + ( strcmp ( product, "VM3" ) != 0 ) ) return -ENOTTY; /* Find OEM strings */ - if ( ( rc = find_smbios_structure ( SMBIOS_TYPE_OEM_STRINGS, 0, - &structure ) ) != 0 ) { - DBGC ( smscusb, "SMSC95XX %p could not find OEM strings: %s\n", - smscusb, strerror ( rc ) ); - return rc; + structure = smbios_structure ( SMBIOS_TYPE_OEM_STRINGS, 0 ); + if ( ! structure ) { + DBGC ( smscusb, "SMSC95XX %p could not find OEM strings\n", + smscusb ); + return -ENOENT; } /* Fetch MAC address */ - len = read_smbios_string ( &structure, SMSC95XX_VM3_OEM_STRING_MAC, - strings.mac, ( sizeof ( strings.mac ) - 1 )); - if ( len < 0 ) { - rc = len; - DBGC ( smscusb, "SMSC95XX %p could not read OEM string: %s\n", - smscusb, strerror ( rc ) ); - return rc; - } - - /* Sanity check */ - if ( len != ( ( int ) ( sizeof ( strings.mac ) - 1 ) ) ) { - DBGC ( smscusb, "SMSC95XX %p invalid MAC address \"%s\"\n", - smscusb, strings.mac ); - return -EINVAL; + mac = smbios_string ( structure, SMSC95XX_VM3_OEM_STRING_MAC ); + if ( ! mac ) { + DBGC ( smscusb, "SMSC95XX %p could not read OEM string\n", + smscusb ); + return -ENOENT; } /* Decode MAC address */ - len = base16_decode ( strings.mac, netdev->hw_addr, ETH_ALEN ); + len = base16_decode ( mac, netdev->hw_addr, ETH_ALEN ); if ( len < 0 ) { rc = len; DBGC ( smscusb, "SMSC95XX %p invalid MAC address \"%s\"\n", - smscusb, strings.mac ); + smscusb, mac ); return rc; } diff --git a/src/include/ipxe/smbios.h b/src/include/ipxe/smbios.h index f36a5ad40..d9e2c38ed 100644 --- a/src/include/ipxe/smbios.h +++ b/src/include/ipxe/smbios.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /** * Provide an SMBIOS API implementation @@ -126,16 +125,6 @@ struct smbios_header { uint16_t handle; } __attribute__ (( packed )); -/** SMBIOS structure descriptor */ -struct smbios_structure { - /** Copy of SMBIOS structure header */ - struct smbios_header header; - /** Offset of structure within SMBIOS */ - size_t offset; - /** Length of strings section */ - size_t strings_len; -}; - /** SMBIOS system information structure */ struct smbios_system_information { /** SMBIOS structure header */ @@ -207,7 +196,7 @@ struct smbios_enclosure_information { */ struct smbios { /** Start of SMBIOS structures */ - userptr_t address; + const void *address; /** Length of SMBIOS structures */ size_t len; /** Number of SMBIOS structures */ @@ -226,17 +215,14 @@ struct smbios { #define SMBIOS_VERSION( major, minor ) ( ( (major) << 8 ) | (minor) ) extern int find_smbios ( struct smbios *smbios ); -extern int find_smbios_entry ( userptr_t start, size_t len, - struct smbios_entry *entry ); -extern int find_smbios3_entry ( userptr_t start, size_t len, - struct smbios3_entry *entry ); -extern int find_smbios_structure ( unsigned int type, unsigned int instance, - struct smbios_structure *structure ); -extern int read_smbios_structure ( struct smbios_structure *structure, - void *data, size_t len ); -extern int read_smbios_string ( struct smbios_structure *structure, - unsigned int index, - void *data, size_t len ); +extern const struct smbios_entry * find_smbios_entry ( const void *start, + size_t len ); +extern const struct smbios3_entry * find_smbios3_entry ( const void *start, + size_t len ); +extern const struct smbios_header * smbios_structure ( unsigned int type, + unsigned int instance ); +extern const char * smbios_string ( const struct smbios_header *header, + unsigned int index ); extern int smbios_version ( void ); extern void smbios_clear ( void ); diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index 3c1b77bdc..5d0e69d6b 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include +#include #include #include #include diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c index abe1b19d7..a12c936ed 100644 --- a/src/interface/linux/linux_smbios.c +++ b/src/interface/linux/linux_smbios.c @@ -35,7 +35,7 @@ static const char smbios_entry_filename[] = static const char smbios_filename[] = "/sys/firmware/dmi/tables/DMI"; /** Cache SMBIOS data */ -static userptr_t smbios_data; +static void *smbios_data; /** * Find SMBIOS @@ -46,7 +46,7 @@ static userptr_t smbios_data; static int linux_find_smbios ( struct smbios *smbios ) { struct smbios3_entry *smbios3_entry; struct smbios_entry *smbios_entry; - userptr_t entry; + void *entry; void *data; int len; int rc; @@ -98,6 +98,7 @@ static int linux_find_smbios ( struct smbios *smbios ) { return 0; ufree ( smbios_data ); + smbios_data = NULL; err_read: err_version: ufree ( entry ); @@ -116,6 +117,7 @@ static void linux_smbios_shutdown ( int booting __unused ) { /* Free SMBIOS data */ ufree ( smbios_data ); + smbios_data = NULL; } /** SMBIOS shutdown function */ diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 89fa4d7ca..3a1a98b17 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -38,26 +38,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** SMBIOS entry point descriptor */ static struct smbios smbios = { - .address = UNULL, + .address = NULL, }; /** * Calculate SMBIOS entry point structure checksum * * @v start Start address of region - * @v offset Offset of SMBIOS entry point structure * @v len Length of entry point structure * @ret sum Byte checksum */ -static uint8_t smbios_checksum ( userptr_t start, size_t offset, size_t len ) { - size_t end = ( offset + len ); - uint8_t sum; - uint8_t byte; +static uint8_t smbios_checksum ( const void *start, size_t len ) { + const uint8_t *byte = start; + uint8_t sum = 0; + + /* Compute checksum */ + while ( len-- ) + sum += *(byte++); - for ( sum = 0 ; offset < end ; offset++ ) { - copy_from_user ( &byte, start, offset, sizeof ( byte ) ); - sum += byte; - } return sum; } @@ -66,39 +64,45 @@ static uint8_t smbios_checksum ( userptr_t start, size_t offset, size_t len ) { * * @v start Start address of region to scan * @v len Length of region to scan - * @v entry SMBIOS entry point structure to fill in - * @ret rc Return status code + * @ret entry SMBIOS entry point structure, or NULL if not found */ -int find_smbios_entry ( userptr_t start, size_t len, - struct smbios_entry *entry ) { +const struct smbios_entry * find_smbios_entry ( const void *start, + size_t len ) { static size_t offset = 0; /* Avoid repeated attempts to locate SMBIOS */ + const struct smbios_entry *entry; uint8_t sum; /* Try to find SMBIOS */ for ( ; ( offset + sizeof ( *entry ) ) <= len ; offset += 0x10 ) { - /* Read start of header and verify signature */ - copy_from_user ( entry, start, offset, sizeof ( *entry ) ); + /* Verify signature */ + entry = ( start + offset ); if ( entry->signature != SMBIOS_SIGNATURE ) continue; + /* Verify length */ + if ( ( entry->len < sizeof ( *entry ) ) || + ( ( offset + entry->len ) > len ) ) { + DBGC ( &smbios, "SMBIOS at %#08lx has bad length " + "%#02x\n", virt_to_phys ( entry ), entry->len ); + continue; + } + /* Verify checksum */ - if ( ( sum = smbios_checksum ( start, offset, - entry->len ) ) != 0 ) { - DBG ( "SMBIOS at %08lx has bad checksum %02x\n", - virt_to_phys ( start + offset ), sum ); + if ( ( sum = smbios_checksum ( entry, entry->len ) ) != 0 ) { + DBGC ( &smbios, "SMBIOS at %#08lx has bad checksum " + "%#02x\n", virt_to_phys ( entry ), sum ); continue; } /* Fill result structure */ - DBG ( "Found SMBIOS v%d.%d entry point at %08lx\n", - entry->major, entry->minor, - virt_to_phys ( start + offset ) ); - return 0; + DBGC ( &smbios, "Found SMBIOS v%d.%d entry point at %#08lx\n", + entry->major, entry->minor, virt_to_phys ( entry ) ); + return entry; } - DBG ( "No SMBIOS found\n" ); - return -ENODEV; + DBGC ( &smbios, "No SMBIOS found\n" ); + return NULL; } /** @@ -106,39 +110,45 @@ int find_smbios_entry ( userptr_t start, size_t len, * * @v start Start address of region to scan * @v len Length of region to scan - * @v entry SMBIOS entry point structure to fill in - * @ret rc Return status code + * @ret entry SMBIOS entry point structure, or NULL if not found */ -int find_smbios3_entry ( userptr_t start, size_t len, - struct smbios3_entry *entry ) { +const struct smbios3_entry * find_smbios3_entry ( const void *start, + size_t len ) { static size_t offset = 0; /* Avoid repeated attempts to locate SMBIOS */ + const struct smbios3_entry *entry; uint8_t sum; /* Try to find SMBIOS */ for ( ; ( offset + sizeof ( *entry ) ) <= len ; offset += 0x10 ) { - /* Read start of header and verify signature */ - copy_from_user ( entry, start, offset, sizeof ( *entry ) ); + /* Verify signature */ + entry = ( start + offset ); if ( entry->signature != SMBIOS3_SIGNATURE ) continue; + /* Verify length */ + if ( ( entry->len < sizeof ( *entry ) ) || + ( ( offset + entry->len ) > len ) ) { + DBGC ( &smbios, "SMBIOS at %#08lx has bad length " + "%#02x\n", virt_to_phys ( entry ), entry->len ); + continue; + } + /* Verify checksum */ - if ( ( sum = smbios_checksum ( start, offset, - entry->len ) ) != 0 ) { - DBG ( "SMBIOS3 at %08lx has bad checksum %02x\n", - virt_to_phys ( start + offset ), sum ); + if ( ( sum = smbios_checksum ( entry, entry->len ) ) != 0 ) { + DBGC ( &smbios, "SMBIOS3 at %#08lx has bad checksum " + "%#02x\n", virt_to_phys ( entry ), sum ); continue; } /* Fill result structure */ - DBG ( "Found SMBIOS3 v%d.%d entry point at %08lx\n", - entry->major, entry->minor, - virt_to_phys ( start + offset ) ); - return 0; + DBGC ( &smbios, "Found SMBIOS3 v%d.%d entry point at %#08lx\n", + entry->major, entry->minor, virt_to_phys ( entry ) ); + return entry; } - DBG ( "No SMBIOS3 found\n" ); - return -ENODEV; + DBGC ( &smbios, "No SMBIOS3 found\n" ); + return NULL; } /** @@ -148,12 +158,15 @@ int find_smbios3_entry ( userptr_t start, size_t len, * @ret offset Offset to strings terminator, or 0 if not found */ static size_t find_strings_terminator ( size_t offset ) { - size_t max_offset = ( smbios.len - 2 ); - uint16_t nulnul; + const uint16_t *nulnul __attribute__ (( aligned ( 1 ) )); - for ( ; offset <= max_offset ; offset++ ) { - copy_from_user ( &nulnul, smbios.address, offset, 2 ); - if ( nulnul == 0 ) + /* Sanity checks */ + assert ( smbios.address != NULL ); + + /* Check for presence of terminating empty string */ + for ( ; ( offset + sizeof ( *nulnul ) ) <= smbios.len ; offset++ ) { + nulnul = ( smbios.address + offset ); + if ( *nulnul == 0 ) return ( offset + 1 ); } return 0; @@ -164,61 +177,59 @@ static size_t find_strings_terminator ( size_t offset ) { * * @v type Structure type to search for * @v instance Instance of this type of structure - * @v structure SMBIOS structure descriptor to fill in - * @ret rc Return status code + * @ret structure SMBIOS structure header, or NULL if not found */ -int find_smbios_structure ( unsigned int type, unsigned int instance, - struct smbios_structure *structure ) { +const struct smbios_header * smbios_structure ( unsigned int type, + unsigned int instance ) { + const struct smbios_header *structure; unsigned int count = 0; size_t offset = 0; size_t strings_offset; size_t terminator_offset; + size_t strings_len; int rc; /* Find SMBIOS */ - if ( ( smbios.address == UNULL ) && + if ( ( smbios.address == NULL ) && ( ( rc = find_smbios ( &smbios ) ) != 0 ) ) - return rc; - assert ( smbios.address != UNULL ); + return NULL; + assert ( smbios.address != NULL ); /* Scan through list of structures */ - while ( ( ( offset + sizeof ( structure->header ) ) < smbios.len ) && + while ( ( ( offset + sizeof ( *structure ) ) < smbios.len ) && ( ( smbios.count == 0 ) || ( count < smbios.count ) ) ) { - /* Read next SMBIOS structure header */ - copy_from_user ( &structure->header, smbios.address, offset, - sizeof ( structure->header ) ); + /* Access next SMBIOS structure header */ + structure = ( smbios.address + offset ); /* Determine start and extent of strings block */ - strings_offset = ( offset + structure->header.len ); + strings_offset = ( offset + structure->len ); if ( strings_offset > smbios.len ) { - DBG ( "SMBIOS structure at offset %zx with length " - "%x extends beyond SMBIOS\n", offset, - structure->header.len ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS structure at offset %#zx " + "with length %#x extends beyond SMBIOS\n", + offset, structure->len ); + return NULL; } terminator_offset = find_strings_terminator ( strings_offset ); if ( ! terminator_offset ) { - DBG ( "SMBIOS structure at offset %zx has " - "unterminated strings section\n", offset ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS structure at offset %#zx has " + "unterminated strings section\n", offset ); + return NULL; } - structure->strings_len = ( terminator_offset - strings_offset); - - DBG ( "SMBIOS structure at offset %zx has type %d, length %x, " - "strings length %zx\n", offset, structure->header.type, - structure->header.len, structure->strings_len ); + strings_len = ( terminator_offset - strings_offset); + DBGC ( &smbios, "SMBIOS structure at offset %#zx has type %d, " + "length %#x, strings length %#zx\n", offset, + structure->type, structure->len, strings_len ); /* Stop if we have reached an end-of-table marker */ if ( ( smbios.count == 0 ) && - ( structure->header.type == SMBIOS_TYPE_END ) ) + ( structure->type == SMBIOS_TYPE_END ) ) break; /* If this is the structure we want, return */ - if ( ( structure->header.type == type ) && + if ( ( structure->type == type ) && ( instance-- == 0 ) ) { - structure->offset = offset; - return 0; + return structure; } /* Move to next SMBIOS structure */ @@ -226,69 +237,43 @@ int find_smbios_structure ( unsigned int type, unsigned int instance, count++; } - DBG ( "SMBIOS structure type %d not found\n", type ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS structure type %d not found\n", type ); + return NULL; } /** - * Copy SMBIOS structure + * Get indexed string within SMBIOS structure * - * @v structure SMBIOS structure descriptor - * @v data Buffer to hold SMBIOS structure - * @v len Length of buffer - * @ret rc Return status code - */ -int read_smbios_structure ( struct smbios_structure *structure, - void *data, size_t len ) { - - assert ( smbios.address != UNULL ); - - if ( len > structure->header.len ) - len = structure->header.len; - copy_from_user ( data, smbios.address, structure->offset, len ); - return 0; -} - -/** - * Find indexed string within SMBIOS structure - * - * @v structure SMBIOS structure descriptor + * @v structure SMBIOS structure header * @v index String index - * @v data Buffer for string - * @v len Length of string buffer - * @ret rc Length of string, or negative error + * @ret string SMBIOS string, or NULL if not fond */ -int read_smbios_string ( struct smbios_structure *structure, - unsigned int index, void *data, size_t len ) { - size_t strings_start = ( structure->offset + structure->header.len ); - size_t strings_end = ( strings_start + structure->strings_len ); - size_t offset; - size_t string_len; - - assert ( smbios.address != UNULL ); - - /* String numbers start at 1 (0 is used to indicate "no string") */ - if ( ! index ) - return -ENOENT; - - for ( offset = strings_start ; offset < strings_end ; - offset += ( string_len + 1 ) ) { - /* Get string length. This is known safe, since the - * smbios_strings struct is constructed so as to - * always end on a string boundary. +const char * smbios_string ( const struct smbios_header *structure, + unsigned int index ) { + const char *string; + unsigned int i; + size_t len; + + /* Sanity check */ + assert ( smbios.address != NULL ); + + /* Step through strings */ + string = ( ( ( const void * ) structure ) + structure->len ); + for ( i = index ; i-- ; ) { + /* Get string length. This is known safe, since we + * check for the empty-string terminator in + * smbios_structure(). */ - string_len = strlen ( smbios.address + offset ); - if ( --index == 0 ) { - /* Copy string, truncating as necessary. */ - if ( len > string_len ) - len = string_len; - copy_from_user ( data, smbios.address, offset, len ); - return string_len; - } + len = strlen ( string ); + if ( ! len ) + break; + if ( i == 0 ) + return string; + string += ( len + 1 /* NUL */ ); } - DBG ( "SMBIOS string index %d not found\n", index ); - return -ENOENT; + DBGC ( &smbios, "SMBIOS string index %d not found\n", index ); + return NULL; } /** @@ -300,10 +285,10 @@ int smbios_version ( void ) { int rc; /* Find SMBIOS */ - if ( ( smbios.address == UNULL ) && + if ( ( smbios.address == NULL ) && ( ( rc = find_smbios ( &smbios ) ) != 0 ) ) return rc; - assert ( smbios.address != UNULL ); + assert ( smbios.address != NULL ); return smbios.version; } @@ -315,5 +300,5 @@ int smbios_version ( void ) { void smbios_clear ( void ) { /* Clear address */ - smbios.address = UNULL; + smbios.address = NULL; } diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 095c35d37..1fe545f38 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -81,15 +81,17 @@ static int smbios_applies ( struct settings *settings __unused, * @v len Length of buffer * @ret len Length of setting data, or negative error */ -static int smbios_fetch ( struct settings *settings __unused, - struct setting *setting, +static int smbios_fetch ( struct settings *settings, struct setting *setting, void *data, size_t len ) { - struct smbios_structure structure; + const struct smbios_header *structure; unsigned int tag_instance; unsigned int tag_type; unsigned int tag_offset; unsigned int tag_len; - int rc; + const void *src; + size_t src_len; + unsigned int string; + union uuid uuid; /* Split tag into instance, type, offset and length */ tag_instance = ( ( setting->tag >> 24 ) & 0xff ); @@ -98,81 +100,75 @@ static int smbios_fetch ( struct settings *settings __unused, tag_len = ( setting->tag & 0xff ); /* Find SMBIOS structure */ - if ( ( rc = find_smbios_structure ( tag_type, tag_instance, - &structure ) ) != 0 ) - return rc; - - { - uint8_t buf[structure.header.len]; - const void *raw; - union uuid uuid; - unsigned int index; - - /* Read SMBIOS structure */ - if ( ( rc = read_smbios_structure ( &structure, buf, - sizeof ( buf ) ) ) != 0 ) - return rc; + structure = smbios_structure ( tag_type, tag_instance ); + if ( ! structure ) + return -ENOENT; + src = structure; + src_len = structure->len; + string = 0; - /* A of zero indicates that the byte at - * contains a string index. An of - * zero indicates that the contains a literal - * string index. - * - * Since the byte at offset zero can never contain a - * string index, and a literal string index can never - * be zero, the combination of both and - * being zero indicates that the entire - * structure is to be read. - */ - if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { - tag_len = sizeof ( buf ); - } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { - index = ( ( tag_offset == 0 ) ? - tag_len : buf[tag_offset] ); - if ( ( rc = read_smbios_string ( &structure, index, - data, len ) ) < 0 ) { - return rc; - } - if ( ! setting->type ) - setting->type = &setting_type_string; - return rc; - } + /* A of zero indicates that the byte at + * contains a string index. An of zero indicates + * that the contains a literal string index. + * + * Since the byte at offset zero can never contain a string + * index, and a literal string index can never be zero, the + * combination of both and being zero + * indicates that the entire structure is to be read. + */ + if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { + /* Read whole structure */ + } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { + /* Read string */ + string = tag_len; + if ( ( string == 0 ) && ( tag_offset < src_len ) ) + string = *( ( uint8_t * ) src + tag_offset ); + src = smbios_string ( structure, string ); + if ( ! src ) + return -ENOENT; + assert ( string > 0 ); + src_len = strlen ( src ); + } else if ( tag_offset > src_len ) { + /* Empty read beyond end of structure */ + src_len = 0; + } else { + /* Read partial structure */ + src += tag_offset; + src_len -= tag_offset; + if ( src_len > tag_len ) + src_len = tag_len; + } - /* Limit length */ - if ( tag_offset > sizeof ( buf ) ) { - tag_len = 0; - } else if ( ( tag_offset + tag_len ) > sizeof ( buf ) ) { - tag_len = ( sizeof ( buf ) - tag_offset ); - } + /* Mangle UUIDs if necessary. iPXE treats UUIDs as being in + * network byte order (big-endian). SMBIOS specification + * version 2.6 states that UUIDs are stored with little-endian + * values in the first three fields; earlier versions did not + * specify an endianness. dmidecode assumes that the byte + * order is little-endian if and only if the SMBIOS version is + * 2.6 or higher; we match this behaviour. + */ + if ( ( ( setting->type == &setting_type_uuid ) || + ( setting->type == &setting_type_guid ) ) && + ( src_len == sizeof ( uuid ) ) && + ( smbios_version() >= SMBIOS_VERSION ( 2, 6 ) ) ) { + DBGC ( settings, "SMBIOS detected mangled UUID\n" ); + memcpy ( &uuid, src, sizeof ( uuid ) ); + uuid_mangle ( &uuid ); + src = &uuid; + } - /* Mangle UUIDs if necessary. iPXE treats UUIDs as - * being in network byte order (big-endian). SMBIOS - * specification version 2.6 states that UUIDs are - * stored with little-endian values in the first three - * fields; earlier versions did not specify an - * endianness. dmidecode assumes that the byte order - * is little-endian if and only if the SMBIOS version - * is 2.6 or higher; we match this behaviour. - */ - raw = &buf[tag_offset]; - if ( ( ( setting->type == &setting_type_uuid ) || - ( setting->type == &setting_type_guid ) ) && - ( tag_len == sizeof ( uuid ) ) && - ( smbios_version() >= SMBIOS_VERSION ( 2, 6 ) ) ) { - DBG ( "SMBIOS detected mangled UUID\n" ); - memcpy ( &uuid, &buf[tag_offset], sizeof ( uuid ) ); - uuid_mangle ( &uuid ); - raw = &uuid; - } + /* Return data */ + if ( len > src_len ) + len = src_len; + memcpy ( data, src, len ); - /* Return data */ - if ( len > tag_len ) - len = tag_len; - memcpy ( data, raw, len ); - if ( ! setting->type ) - setting->type = &setting_type_hex; - return tag_len; + /* Set default type */ + if ( ! setting->type ) { + setting->type = ( string ? &setting_type_string : + &setting_type_hex ); } + + return src_len; } /** SMBIOS settings operations */ @@ -192,12 +188,12 @@ static struct settings smbios_settings = { /** Initialise SMBIOS settings */ static void smbios_init ( void ) { + struct settings *settings = &smbios_settings; int rc; - if ( ( rc = register_settings ( &smbios_settings, NULL, - "smbios" ) ) != 0 ) { - DBG ( "SMBIOS could not register settings: %s\n", - strerror ( rc ) ); + if ( ( rc = register_settings ( settings, NULL, "smbios" ) ) != 0 ) { + DBGC ( settings, "SMBIOS could not register settings: %s\n", + strerror ( rc ) ); return; } } -- cgit v1.2.3-55-g7522 From 839540cb95a310ebf96d6302afecc3ac97ccf746 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 23 Apr 2025 12:47:53 +0100 Subject: [umalloc] Remove userptr_t from user memory allocations Use standard void pointers for umalloc(), urealloc(), and ufree(), with the "u" prefix retained to indicate that these allocations are made from external ("user") memory rather than from the internal heap. Signed-off-by: Michael Brown --- src/arch/riscv/interface/sbi/sbi_umalloc.c | 11 +++---- src/arch/x86/interface/pcbios/memtop_umalloc.c | 42 ++++++++++++-------------- src/core/dma.c | 9 +++--- src/core/malloc.c | 17 ----------- src/core/xferbuf.c | 12 ++++---- src/include/ipxe/dma.h | 20 ++++++------ src/include/ipxe/malloc.h | 18 +++++++++++ src/include/ipxe/umalloc.h | 23 +++++++------- src/include/ipxe/xferbuf.h | 3 +- src/interface/efi/efi_pci.c | 36 ++-------------------- src/interface/efi/efi_umalloc.c | 25 ++++++++------- src/interface/linux/linux_umalloc.c | 31 +++++++------------ src/tests/umalloc_test.c | 5 ++- 13 files changed, 101 insertions(+), 151 deletions(-) (limited to 'src/interface') diff --git a/src/arch/riscv/interface/sbi/sbi_umalloc.c b/src/arch/riscv/interface/sbi/sbi_umalloc.c index 2f9935adb..0e351748b 100644 --- a/src/arch/riscv/interface/sbi/sbi_umalloc.c +++ b/src/arch/riscv/interface/sbi/sbi_umalloc.c @@ -32,23 +32,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ -/** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ~UNULL ) - /** * Reallocate external memory * - * @v old_ptr Memory previously allocated by umalloc(), or UNULL + * @v old_ptr Memory previously allocated by umalloc(), or NULL * @v new_size Requested size - * @ret new_ptr Allocated memory, or UNULL + * @ret new_ptr Allocated memory, or NULL * * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ -static userptr_t sbi_urealloc ( userptr_t old_ptr, size_t new_size ) { +static void * sbi_urealloc ( void * old_ptr, size_t new_size ) { /* External allocation not yet implemented: allocate from heap */ - return ( ( userptr_t ) realloc ( ( ( void * ) old_ptr ), new_size ) ); + return ( realloc ( old_ptr, new_size ) ); } PROVIDE_UMALLOC ( sbi, urealloc, sbi_urealloc ); diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index b87d22516..d4489fb01 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -44,9 +44,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Alignment of external allocated memory */ #define EM_ALIGN ( 4 * 1024 ) -/** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) ) - /** An external memory block */ struct external_memory { /** Size of this memory block (excluding this header) */ @@ -56,10 +53,10 @@ struct external_memory { }; /** Top of heap */ -static userptr_t top = UNULL; +static void *top = NULL; /** Bottom of heap (current lowest allocated block) */ -static userptr_t bottom = UNULL; +static void *bottom = NULL; /** Remaining space on heap */ static size_t heap_size; @@ -70,7 +67,7 @@ static size_t heap_size; * @ret start Start of region * @ret len Length of region */ -size_t largest_memblock ( userptr_t *start ) { +size_t largest_memblock ( void **start ) { struct memory_map memmap; struct memory_region *region; physaddr_t max = EM_MAX_ADDRESS; @@ -81,7 +78,7 @@ size_t largest_memblock ( userptr_t *start ) { size_t len = 0; /* Avoid returning uninitialised data on error */ - *start = UNULL; + *start = NULL; /* Scan through all memory regions */ get_memmap ( &memmap ); @@ -119,7 +116,7 @@ size_t largest_memblock ( userptr_t *start ) { * */ static void init_eheap ( void ) { - userptr_t base; + void *base; heap_size = largest_memblock ( &base ); bottom = top = ( base + heap_size ); @@ -137,8 +134,8 @@ static void ecollect_free ( void ) { /* Walk the free list and collect empty blocks */ while ( bottom != top ) { - copy_from_user ( &extmem, bottom, -sizeof ( extmem ), - sizeof ( extmem ) ); + memcpy ( &extmem, ( bottom - sizeof ( extmem ) ), + sizeof ( extmem ) ); if ( extmem.used ) break; DBG ( "EXTMEM freeing [%lx,%lx)\n", virt_to_phys ( bottom ), @@ -152,16 +149,16 @@ static void ecollect_free ( void ) { /** * Reallocate external memory * - * @v old_ptr Memory previously allocated by umalloc(), or UNULL + * @v old_ptr Memory previously allocated by umalloc(), or NULL * @v new_size Requested size - * @ret new_ptr Allocated memory, or UNULL + * @ret new_ptr Allocated memory, or NULL * * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ -static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { +static void * memtop_urealloc ( void *ptr, size_t new_size ) { struct external_memory extmem; - userptr_t new = ptr; + void *new = ptr; size_t align; /* (Re)initialise external memory allocator if necessary */ @@ -169,15 +166,15 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { init_eheap(); /* Get block properties into extmem */ - if ( ptr && ( ptr != UNOWHERE ) ) { + if ( ptr && ( ptr != NOWHERE ) ) { /* Determine old size */ - copy_from_user ( &extmem, ptr, -sizeof ( extmem ), - sizeof ( extmem ) ); + memcpy ( &extmem, ( ptr - sizeof ( extmem ) ), + sizeof ( extmem ) ); } else { /* Create a zero-length block */ if ( heap_size < sizeof ( extmem ) ) { DBG ( "EXTMEM out of space\n" ); - return UNULL; + return NULL; } ptr = bottom = ( bottom - sizeof ( extmem ) ); heap_size -= sizeof ( extmem ); @@ -196,7 +193,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { new -= align; if ( new_size > ( heap_size + extmem.size ) ) { DBG ( "EXTMEM out of space\n" ); - return UNULL; + return NULL; } DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n", virt_to_phys ( ptr ), @@ -215,13 +212,12 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { DBG ( "EXTMEM cannot expand [%lx,%lx)\n", virt_to_phys ( ptr ), ( virt_to_phys ( ptr ) + extmem.size ) ); - return UNULL; + return NULL; } } /* Write back block properties */ - copy_to_user ( new, -sizeof ( extmem ), &extmem, - sizeof ( extmem ) ); + memcpy ( ( new - sizeof ( extmem ) ), &extmem, sizeof ( extmem ) ); /* Collect any free blocks and update hidden memory region */ ecollect_free(); @@ -229,7 +225,7 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) { ( ( bottom == top ) ? 0 : sizeof ( extmem ) ) ), virt_to_phys ( top ) ); - return ( new_size ? new : UNOWHERE ); + return ( new_size ? new : NOWHERE ); } PROVIDE_UMALLOC ( memtop, urealloc, memtop_urealloc ); diff --git a/src/core/dma.c b/src/core/dma.c index 5d6868216..1f3c1d8a6 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -130,9 +130,9 @@ static void dma_op_free ( struct dma_mapping *map, void *addr, size_t len ) { * @v align Physical alignment * @ret addr Buffer address, or NULL on error */ -static userptr_t dma_op_umalloc ( struct dma_device *dma, - struct dma_mapping *map, - size_t len, size_t align ) { +static void * dma_op_umalloc ( struct dma_device *dma, + struct dma_mapping *map, + size_t len, size_t align ) { struct dma_operations *op = dma->op; if ( ! op ) @@ -147,8 +147,7 @@ static userptr_t dma_op_umalloc ( struct dma_device *dma, * @v addr Buffer address * @v len Length of buffer */ -static void dma_op_ufree ( struct dma_mapping *map, userptr_t addr, - size_t len ) { +static void dma_op_ufree ( struct dma_mapping *map, void *addr, size_t len ) { struct dma_device *dma = map->dma; assert ( dma != NULL ); diff --git a/src/core/malloc.c b/src/core/malloc.c index c499ce6fd..ec29513ef 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -71,23 +71,6 @@ struct autosized_block { char data[0]; }; -/** - * Address for zero-length memory blocks - * - * @c malloc(0) or @c realloc(ptr,0) will return the special value @c - * NOWHERE. Calling @c free(NOWHERE) will have no effect. - * - * This is consistent with the ANSI C standards, which state that - * "either NULL or a pointer suitable to be passed to free()" must be - * returned in these cases. Using a special non-NULL value means that - * the caller can take a NULL return value to indicate failure, - * without first having to check for a requested size of zero. - * - * Code outside of malloc.c do not ever need to refer to the actual - * value of @c NOWHERE; this is an internal definition. - */ -#define NOWHERE ( ( void * ) ~( ( intptr_t ) 0 ) ) - /** List of free memory blocks */ static LIST_HEAD ( free_blocks ); diff --git a/src/core/xferbuf.c b/src/core/xferbuf.c index 240118557..1c08f8bc3 100644 --- a/src/core/xferbuf.c +++ b/src/core/xferbuf.c @@ -237,8 +237,8 @@ struct xfer_buffer_operations xferbuf_malloc_operations = { * @ret rc Return status code */ static int xferbuf_umalloc_realloc ( struct xfer_buffer *xferbuf, size_t len ) { - userptr_t *udata = xferbuf->data; - userptr_t new_udata; + void **udata = xferbuf->data; + void *new_udata; new_udata = urealloc ( *udata, len ); if ( ! new_udata ) @@ -257,9 +257,9 @@ static int xferbuf_umalloc_realloc ( struct xfer_buffer *xferbuf, size_t len ) { */ static void xferbuf_umalloc_write ( struct xfer_buffer *xferbuf, size_t offset, const void *data, size_t len ) { - userptr_t *udata = xferbuf->data; + void **udata = xferbuf->data; - copy_to_user ( *udata, offset, data, len ); + memcpy ( ( *udata + offset ), data, len ); } /** @@ -272,9 +272,9 @@ static void xferbuf_umalloc_write ( struct xfer_buffer *xferbuf, size_t offset, */ static void xferbuf_umalloc_read ( struct xfer_buffer *xferbuf, size_t offset, void *data, size_t len ) { - userptr_t *udata = xferbuf->data; + void **udata = xferbuf->data; - copy_from_user ( data, *udata, offset, len ); + memcpy ( data, ( *udata + offset ), len ); } /** umalloc()-based data buffer operations */ diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index 385e4baf7..6e5c43289 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -106,9 +106,9 @@ struct dma_operations { * @v align Physical alignment * @ret addr Buffer address, or NULL on error */ - userptr_t ( * umalloc ) ( struct dma_device *dma, - struct dma_mapping *map, - size_t len, size_t align ); + void * ( * umalloc ) ( struct dma_device *dma, + struct dma_mapping *map, + size_t len, size_t align ); /** * Unmap and free DMA-coherent buffer from external (user) memory * @@ -118,7 +118,7 @@ struct dma_operations { * @v len Length of buffer */ void ( * ufree ) ( struct dma_device *dma, struct dma_mapping *map, - userptr_t addr, size_t len ); + void *addr, size_t len ); /** * Set addressable space mask * @@ -265,11 +265,11 @@ DMAAPI_INLINE ( flat, dma_free ) ( struct dma_mapping *map, * @v align Physical alignment * @ret addr Buffer address, or NULL on error */ -static inline __always_inline userptr_t +static inline __always_inline void * DMAAPI_INLINE ( flat, dma_umalloc ) ( struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align __unused ) { - userptr_t addr; + void *addr; /* Allocate buffer */ addr = umalloc ( len ); @@ -292,7 +292,7 @@ DMAAPI_INLINE ( flat, dma_umalloc ) ( struct dma_device *dma, */ static inline __always_inline void DMAAPI_INLINE ( flat, dma_ufree ) ( struct dma_mapping *map, - userptr_t addr, size_t len __unused ) { + void *addr, size_t len __unused ) { /* Free buffer */ ufree ( addr ); @@ -397,8 +397,8 @@ void dma_free ( struct dma_mapping *map, void *addr, size_t len ); * @v align Physical alignment * @ret addr Buffer address, or NULL on error */ -userptr_t dma_umalloc ( struct dma_device *dma, struct dma_mapping *map, - size_t len, size_t align ); +void * dma_umalloc ( struct dma_device *dma, struct dma_mapping *map, + size_t len, size_t align ); /** * Unmap and free DMA-coherent buffer from external (user) memory @@ -407,7 +407,7 @@ userptr_t dma_umalloc ( struct dma_device *dma, struct dma_mapping *map, * @v addr Buffer address * @v len Length of buffer */ -void dma_ufree ( struct dma_mapping *map, userptr_t addr, size_t len ); +void dma_ufree ( struct dma_mapping *map, void *addr, size_t len ); /** * Set addressable space mask diff --git a/src/include/ipxe/malloc.h b/src/include/ipxe/malloc.h index f0fde0bc3..8c3a7769d 100644 --- a/src/include/ipxe/malloc.h +++ b/src/include/ipxe/malloc.h @@ -21,6 +21,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +/** + * Address for zero-length memory blocks + * + * @c malloc(0) or @c realloc(ptr,0) will return the special value @c + * NOWHERE. Calling @c free(NOWHERE) will have no effect. + * + * This is consistent with the ANSI C standards, which state that + * "either NULL or a pointer suitable to be passed to free()" must be + * returned in these cases. Using a special non-NULL value means that + * the caller can take a NULL return value to indicate failure, + * without first having to check for a requested size of zero. + * + * Code outside of the memory allocators themselves does not ever need + * to refer to the actual value of @c NOWHERE; this is an internal + * definition. + */ +#define NOWHERE ( ( void * ) ~( ( intptr_t ) 0 ) ) + extern size_t freemem; extern size_t usedmem; extern size_t maxusedmem; diff --git a/src/include/ipxe/umalloc.h b/src/include/ipxe/umalloc.h index 3892ef53b..a6476a390 100644 --- a/src/include/ipxe/umalloc.h +++ b/src/include/ipxe/umalloc.h @@ -10,9 +10,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include +#include #include -#include /** * Provide a user memory allocation API implementation @@ -34,36 +35,36 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Reallocate external memory * - * @v userptr Memory previously allocated by umalloc(), or UNULL + * @v old_ptr Memory previously allocated by umalloc(), or NULL * @v new_size Requested size - * @ret userptr Allocated memory, or UNULL + * @ret new_ptr Allocated memory, or NULL * * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ -userptr_t urealloc ( userptr_t userptr, size_t new_size ); +void * urealloc ( void *ptr, size_t new_size ); /** * Allocate external memory * * @v size Requested size - * @ret userptr Memory, or UNULL + * @ret ptr Memory, or NULL * * Memory is guaranteed to be aligned to a page boundary. */ -static inline __always_inline userptr_t umalloc ( size_t size ) { - return urealloc ( UNULL, size ); +static inline __always_inline void * umalloc ( size_t size ) { + return urealloc ( NULL, size ); } /** * Free external memory * - * @v userptr Memory allocated by umalloc(), or UNULL + * @v ptr Memory allocated by umalloc(), or NULL * - * If @c ptr is UNULL, no action is taken. + * If @c ptr is NULL, no action is taken. */ -static inline __always_inline void ufree ( userptr_t userptr ) { - urealloc ( userptr, 0 ); +static inline __always_inline void ufree ( void *ptr ) { + urealloc ( ptr, 0 ); } #endif /* _IPXE_UMALLOC_H */ diff --git a/src/include/ipxe/xferbuf.h b/src/include/ipxe/xferbuf.h index cb0b1a0e8..04635999d 100644 --- a/src/include/ipxe/xferbuf.h +++ b/src/include/ipxe/xferbuf.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include #include @@ -84,7 +83,7 @@ xferbuf_malloc_init ( struct xfer_buffer *xferbuf ) { * @v data User pointer */ static inline __attribute__ (( always_inline )) void -xferbuf_umalloc_init ( struct xfer_buffer *xferbuf, userptr_t *data ) { +xferbuf_umalloc_init ( struct xfer_buffer *xferbuf, void **data ) { xferbuf->data = data; xferbuf->op = &xferbuf_umalloc_operations; } diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 01351df51..b8c7df38d 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -640,38 +640,6 @@ static void efipci_dma_free ( struct dma_device *dma, struct dma_mapping *map, dma->allocated--; } -/** - * Allocate and map DMA-coherent buffer from external (user) memory - * - * @v dma DMA device - * @v map DMA mapping to fill in - * @v len Length of buffer - * @v align Physical alignment - * @ret addr Buffer address, or NULL on error - */ -static userptr_t efipci_dma_umalloc ( struct dma_device *dma, - struct dma_mapping *map, - size_t len, size_t align ) { - void *addr; - - addr = efipci_dma_alloc ( dma, map, len, align ); - return virt_to_user ( addr ); -} - -/** - * Unmap and free DMA-coherent buffer from external (user) memory - * - * @v dma DMA device - * @v map DMA mapping - * @v addr Buffer address - * @v len Length of buffer - */ -static void efipci_dma_ufree ( struct dma_device *dma, struct dma_mapping *map, - userptr_t addr, size_t len ) { - - efipci_dma_free ( dma, map, addr, len ); -} - /** * Set addressable space mask * @@ -710,8 +678,8 @@ static struct dma_operations efipci_dma_operations = { .unmap = efipci_dma_unmap, .alloc = efipci_dma_alloc, .free = efipci_dma_free, - .umalloc = efipci_dma_umalloc, - .ufree = efipci_dma_ufree, + .umalloc = efipci_dma_alloc, + .ufree = efipci_dma_free, .set_mask = efipci_dma_set_mask, }; diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 0636cb7fd..419d9b294 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include @@ -35,25 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ -/** Equivalent of NOWHERE for user pointers */ -#define UNOWHERE ( ( userptr_t ) ~( ( intptr_t ) 0 ) ) - /** * Reallocate external memory * - * @v old_ptr Memory previously allocated by umalloc(), or UNULL + * @v old_ptr Memory previously allocated by umalloc(), or NULL * @v new_size Requested size - * @ret new_ptr Allocated memory, or UNULL + * @ret new_ptr Allocated memory, or NULL * * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ -static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { +static void * efi_urealloc ( void *old_ptr, size_t new_size ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_PHYSICAL_ADDRESS phys_addr; unsigned int new_pages, old_pages; - userptr_t new_ptr = UNOWHERE; + void *new_ptr = NOWHERE; size_t old_size; + size_t *info; EFI_STATUS efirc; int rc; @@ -69,12 +68,12 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { rc = -EEFI ( efirc ); DBG ( "EFI could not allocate %d pages: %s\n", new_pages, strerror ( rc ) ); - return UNULL; + return NULL; } assert ( phys_addr != 0 ); new_ptr = phys_to_virt ( phys_addr + EFI_PAGE_SIZE ); - copy_to_user ( new_ptr, -EFI_PAGE_SIZE, - &new_size, sizeof ( new_size ) ); + info = ( new_ptr - EFI_PAGE_SIZE ); + *info = new_size; DBG ( "EFI allocated %d pages at %llx\n", new_pages, phys_addr ); } @@ -84,9 +83,9 @@ static userptr_t efi_urealloc ( userptr_t old_ptr, size_t new_size ) { * is valid, or (b) new_size is 0; either way, the memcpy() is * valid. */ - if ( old_ptr && ( old_ptr != UNOWHERE ) ) { - copy_from_user ( &old_size, old_ptr, -EFI_PAGE_SIZE, - sizeof ( old_size ) ); + if ( old_ptr && ( old_ptr != NOWHERE ) ) { + info = ( old_ptr - EFI_PAGE_SIZE ); + old_size = *info; memcpy ( new_ptr, old_ptr, ( (old_size < new_size) ? old_size : new_size ) ); old_pages = ( EFI_SIZE_TO_PAGES ( old_size ) + 1 ); diff --git a/src/interface/linux/linux_umalloc.c b/src/interface/linux/linux_umalloc.c index a7250fa5b..ab5770e9c 100644 --- a/src/interface/linux/linux_umalloc.c +++ b/src/interface/linux/linux_umalloc.c @@ -31,9 +31,6 @@ FILE_LICENCE(GPL2_OR_LATER); #include -/** Special address returned for empty allocations */ -#define NOWHERE ((void *)-1) - /** Poison to make the metadata more unique */ #define POISON 0xa5a5a5a5 #define min(a,b) (((a)<(b))?(a):(b)) @@ -47,7 +44,16 @@ struct metadata #define SIZE_MD (sizeof(struct metadata)) -/** Simple realloc which passes most of the work to mmap(), mremap() and munmap() */ +/** + * Reallocate external memory + * + * @v old_ptr Memory previously allocated by umalloc(), or NULL + * @v new_size Requested size + * @ret new_ptr Allocated memory, or NULL + * + * Calling realloc() with a new size of zero is a valid way to free a + * memory block. + */ static void * linux_realloc(void *ptr, size_t size) { struct metadata md = {0, 0}; @@ -136,19 +142,4 @@ static void * linux_realloc(void *ptr, size_t size) return ptr; } -/** - * Reallocate external memory - * - * @v old_ptr Memory previously allocated by umalloc(), or UNULL - * @v new_size Requested size - * @ret new_ptr Allocated memory, or UNULL - * - * Calling realloc() with a new size of zero is a valid way to free a - * memory block. - */ -static userptr_t linux_urealloc(userptr_t old_ptr, size_t new_size) -{ - return (userptr_t)linux_realloc((void *)old_ptr, new_size); -} - -PROVIDE_UMALLOC(linux, urealloc, linux_urealloc); +PROVIDE_UMALLOC(linux, urealloc, linux_realloc); diff --git a/src/tests/umalloc_test.c b/src/tests/umalloc_test.c index 53810833c..1a32a0531 100644 --- a/src/tests/umalloc_test.c +++ b/src/tests/umalloc_test.c @@ -1,12 +1,11 @@ #include -#include #include #include void umalloc_test ( void ) { struct memory_map memmap; - userptr_t bob; - userptr_t fred; + void *bob; + void *fred; printf ( "Before allocation:\n" ); get_memmap ( &memmap ); -- cgit v1.2.3-55-g7522 From e8ffe2cd644000c1cca51c40ba14edb546ca769b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 01:30:50 +0100 Subject: [uaccess] Remove trivial uses of userptr_t Signed-off-by: Michael Brown --- src/arch/x86/core/vram_settings.c | 5 +++-- src/arch/x86/image/pxe_image.c | 2 +- src/arch/x86/include/realmode.h | 4 ++-- src/arch/x86/interface/pxe/pxe_preboot.c | 5 ++--- src/arch/x86/interface/pxe/pxe_tftp.c | 12 +++++------- src/arch/x86/interface/pxe/pxe_udp.c | 9 ++++----- src/core/cachedhcp.c | 4 ++-- src/core/dma.c | 2 +- src/core/fdt.c | 6 +++--- src/drivers/infiniband/arbel.c | 2 +- src/drivers/infiniband/arbel.h | 5 ++--- src/drivers/infiniband/golan.c | 12 ++++++------ src/drivers/infiniband/golan.h | 2 +- src/drivers/infiniband/hermon.c | 2 +- src/drivers/infiniband/hermon.h | 5 ++--- src/drivers/net/efi/nii.c | 2 +- src/drivers/net/netvsc.c | 2 +- src/drivers/net/netvsc.h | 2 +- src/drivers/usb/xhci.h | 3 +-- src/image/segment.c | 2 +- src/include/ipxe/cachedhcp.h | 3 +-- src/include/ipxe/linux_sysfs.h | 4 +--- src/include/ipxe/memblock.h | 3 +-- src/include/ipxe/segment.h | 4 ++-- src/include/ipxe/vmbus.h | 3 +-- src/interface/efi/efi_block.c | 3 +-- src/interface/efi/efi_bofm.c | 3 +-- src/interface/efi/efi_cachedhcp.c | 10 ++++------ src/interface/efi/efi_file.c | 17 +++++++---------- src/interface/hyperv/vmbus.c | 4 ++-- src/interface/linux/linux_acpi.c | 1 + src/interface/linux/linux_smbios.c | 1 + src/interface/linux/linux_sysfs.c | 6 +++--- src/tests/bofm_test.c | 5 ++--- 34 files changed, 69 insertions(+), 86 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/core/vram_settings.c b/src/arch/x86/core/vram_settings.c index ceeada467..a97a463fe 100644 --- a/src/arch/x86/core/vram_settings.c +++ b/src/arch/x86/core/vram_settings.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include @@ -47,12 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret len Length of setting data, or negative error */ static int vram_fetch ( void *data, size_t len ) { - userptr_t vram = phys_to_virt ( VRAM_BASE ); + const void *vram = phys_to_virt ( VRAM_BASE ); /* Copy video RAM */ if ( len > VRAM_LEN ) len = VRAM_LEN; - copy_from_user ( data, vram, 0, len ); + memcpy ( data, vram, len ); return VRAM_LEN; } diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index 5472ea594..9f8044fa1 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -54,7 +54,7 @@ const char *pxe_cmdline; * @ret rc Return status code */ static int pxe_exec ( struct image *image ) { - userptr_t buffer = real_to_virt ( 0, 0x7c00 ); + void *buffer = real_to_virt ( 0, 0x7c00 ); struct net_device *netdev; int rc; diff --git a/src/arch/x86/include/realmode.h b/src/arch/x86/include/realmode.h index 0017b42c0..75f7d16e7 100644 --- a/src/arch/x86/include/realmode.h +++ b/src/arch/x86/include/realmode.h @@ -87,7 +87,7 @@ real_to_virt ( unsigned int segment, unsigned int offset ) { static inline __always_inline void copy_to_real ( unsigned int dest_seg, unsigned int dest_off, void *src, size_t n ) { - copy_to_user ( real_to_virt ( dest_seg, dest_off ), 0, src, n ); + memcpy ( real_to_virt ( dest_seg, dest_off ), src, n ); } /** @@ -101,7 +101,7 @@ copy_to_real ( unsigned int dest_seg, unsigned int dest_off, static inline __always_inline void copy_from_real ( void *dest, unsigned int src_seg, unsigned int src_off, size_t n ) { - copy_from_user ( dest, real_to_virt ( src_seg, src_off ), 0, n ); + memcpy ( dest, real_to_virt ( src_seg, src_off ), n ); } /** diff --git a/src/arch/x86/interface/pxe/pxe_preboot.c b/src/arch/x86/interface/pxe/pxe_preboot.c index 727d8e1ea..77dcf66e7 100644 --- a/src/arch/x86/interface/pxe/pxe_preboot.c +++ b/src/arch/x86/interface/pxe/pxe_preboot.c @@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -184,7 +183,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) { union pxe_cached_info *info; unsigned int idx; size_t len; - userptr_t buffer; + void *buffer; DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO %s to %04x:%04x+%x", pxenv_get_cached_info_name ( get_cached_info->PacketType ), @@ -245,7 +244,7 @@ pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) { DBGC ( &pxe_netdev, " buffer may be too short" ); buffer = real_to_virt ( get_cached_info->Buffer.segment, get_cached_info->Buffer.offset ); - copy_to_user ( buffer, 0, info, len ); + memcpy ( buffer, info, len ); get_cached_info->BufferSize = len; } diff --git a/src/arch/x86/interface/pxe/pxe_tftp.c b/src/arch/x86/interface/pxe/pxe_tftp.c index 073414dce..aa675fd13 100644 --- a/src/arch/x86/interface/pxe/pxe_tftp.c +++ b/src/arch/x86/interface/pxe/pxe_tftp.c @@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -49,7 +48,7 @@ struct pxe_tftp_connection { /** Data transfer interface */ struct interface xfer; /** Data buffer */ - userptr_t buffer; + void *buffer; /** Size of data buffer */ size_t size; /** Starting offset of data buffer */ @@ -121,9 +120,8 @@ static int pxe_tftp_xfer_deliver ( struct pxe_tftp_connection *pxe_tftp, ( pxe_tftp->start + pxe_tftp->size ) ); rc = -ENOBUFS; } else { - copy_to_user ( pxe_tftp->buffer, - ( pxe_tftp->offset - pxe_tftp->start ), - iobuf->data, len ); + memcpy ( ( pxe_tftp->buffer + pxe_tftp->offset - + pxe_tftp->start ), iobuf->data, len ); } /* Calculate new buffer position */ @@ -385,7 +383,7 @@ static PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read ) { while ( ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) && ( pxe_tftp.offset == pxe_tftp.start ) ) step(); - pxe_tftp.buffer = UNULL; + pxe_tftp.buffer = NULL; tftp_read->BufferSize = ( pxe_tftp.offset - pxe_tftp.start ); tftp_read->PacketNumber = ++pxe_tftp.blkidx; @@ -496,7 +494,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE pxe_tftp.size = tftp_read_file->BufferSize; while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS ) step(); - pxe_tftp.buffer = UNULL; + pxe_tftp.buffer = NULL; tftp_read_file->BufferSize = pxe_tftp.max_offset; /* Close TFTP file */ diff --git a/src/arch/x86/interface/pxe/pxe_udp.c b/src/arch/x86/interface/pxe/pxe_udp.c index 47abb7df4..61c858dde 100644 --- a/src/arch/x86/interface/pxe/pxe_udp.c +++ b/src/arch/x86/interface/pxe/pxe_udp.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -296,7 +295,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) { }; size_t len; struct io_buffer *iobuf; - userptr_t buffer; + const void *buffer; int rc; DBG ( "PXENV_UDP_WRITE" ); @@ -330,7 +329,7 @@ pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) { } buffer = real_to_virt ( pxenv_udp_write->buffer.segment, pxenv_udp_write->buffer.offset ); - copy_from_user ( iob_put ( iobuf, len ), buffer, 0, len ); + memcpy ( iob_put ( iobuf, len ), buffer, len ); DBG ( " %04x:%04x+%x %d->%s:%d\n", pxenv_udp_write->buffer.segment, pxenv_udp_write->buffer.offset, pxenv_udp_write->buffer_size, @@ -400,7 +399,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) { struct pxe_udp_pseudo_header *pshdr; uint16_t d_port_wanted = pxenv_udp_read->d_port; uint16_t d_port; - userptr_t buffer; + void *buffer; size_t len; /* Try receiving a packet, if the queue is empty */ @@ -443,7 +442,7 @@ static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) { len = iob_len ( iobuf ); if ( len > pxenv_udp_read->buffer_size ) len = pxenv_udp_read->buffer_size; - copy_to_user ( buffer, 0, iobuf->data, len ); + memcpy ( buffer, iobuf->data, len ); pxenv_udp_read->buffer_size = len; /* Fill in source/dest information */ diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 07589f0b8..0d400db16 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -198,7 +198,7 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache, * @ret rc Return status code */ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan, - userptr_t data, size_t max_len ) { + const void *data, size_t max_len ) { struct dhcp_packet *dhcppkt; struct dhcp_packet *tmp; struct dhcphdr *dhcphdr; @@ -216,7 +216,7 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan, return -ENOMEM; } dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) ); - copy_from_user ( dhcphdr, data, 0, max_len ); + memcpy ( dhcphdr, data, max_len ); dhcppkt_init ( dhcppkt, dhcphdr, max_len ); /* Shrink packet to required length. If reallocation fails, diff --git a/src/core/dma.c b/src/core/dma.c index 1f3c1d8a6..cf4b20379 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -136,7 +136,7 @@ static void * dma_op_umalloc ( struct dma_device *dma, struct dma_operations *op = dma->op; if ( ! op ) - return UNULL; + return NULL; return op->umalloc ( dma, map, len, align ); } diff --git a/src/core/fdt.c b/src/core/fdt.c index 4c709b342..7c7127aed 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -1037,7 +1037,7 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) { assert ( len >= fdt->used ); /* Attempt reallocation */ - new = urealloc ( virt_to_user ( fdt->raw ), len ); + new = urealloc ( fdt->raw, len ); if ( ! new ) { DBGC ( fdt, "FDT could not reallocate from +%#04zx to " "+%#04zx\n", fdt->len, len ); @@ -1129,7 +1129,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { return 0; err_bootargs: - ufree ( virt_to_user ( fdt.raw ) ); + ufree ( fdt.raw ); err_alloc: err_image: return rc; @@ -1143,7 +1143,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { void fdt_remove ( struct fdt_header *hdr ) { /* Free modifiable copy */ - ufree ( virt_to_user ( hdr ) ); + ufree ( hdr ); } /* Drag in objects via fdt_describe() */ diff --git a/src/drivers/infiniband/arbel.c b/src/drivers/infiniband/arbel.c index 4cb4167e0..0789ea593 100644 --- a/src/drivers/infiniband/arbel.c +++ b/src/drivers/infiniband/arbel.c @@ -2119,7 +2119,7 @@ static void arbel_stop_firmware ( struct arbel *arbel ) { DBGC ( arbel, "Arbel %p FATAL could not stop firmware: %s\n", arbel, strerror ( rc ) ); /* Leak memory and return; at least we avoid corruption */ - arbel->firmware_area = UNULL; + arbel->firmware_area = NULL; return; } } diff --git a/src/drivers/infiniband/arbel.h b/src/drivers/infiniband/arbel.h index 8a5a996a3..a31e59934 100644 --- a/src/drivers/infiniband/arbel.h +++ b/src/drivers/infiniband/arbel.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include "mlx_bitops.h" #include "MT25218_PRM.h" @@ -492,7 +491,7 @@ struct arbel { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t firmware_area; + void *firmware_area; /** ICM size */ size_t icm_len; /** ICM AUX size */ @@ -503,7 +502,7 @@ struct arbel { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t icm; + void *icm; /** Offset within ICM of doorbell records */ size_t db_rec_offset; /** Doorbell records */ diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index a33bad9ff..ffa78fabf 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -52,7 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); struct golan_page { struct list_head list; - userptr_t addr; + void *addr; }; static void golan_free_fw_areas ( struct golan *golan ) { @@ -61,7 +61,7 @@ static void golan_free_fw_areas ( struct golan *golan ) { for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) { if ( golan->fw_areas[i].area ) { ufree ( golan->fw_areas[i].area ); - golan->fw_areas[i].area = UNULL; + golan->fw_areas[i].area = NULL; } } } @@ -75,7 +75,7 @@ static int golan_init_fw_areas ( struct golan *golan ) { } for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) - golan->fw_areas[i].area = UNULL; + golan->fw_areas[i].area = NULL; return rc; @@ -448,12 +448,12 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages int size_ibox = 0; int size_obox = 0; int rc = 0; - userptr_t next_page_addr = UNULL; + void *next_page_addr = NULL; DBGC(golan, "%s\n", __FUNCTION__); if ( ! fw_area->area ) { fw_area->area = umalloc ( GOLAN_PAGE_SIZE * pages ); - if ( fw_area->area == UNULL ) { + if ( fw_area->area == NULL ) { rc = -ENOMEM; DBGC (golan ,"Failed to allocated %d pages \n",pages); goto err_golan_alloc_fw_area; @@ -467,7 +467,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages unsigned i, j; struct golan_cmd_layout *cmd; struct golan_manage_pages_inbox *in; - userptr_t addr = 0; + void *addr = NULL; mailbox = GET_INBOX(golan, MEM_MBOX); size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE); diff --git a/src/drivers/infiniband/golan.h b/src/drivers/infiniband/golan.h index f7da1e960..8122f8d38 100755 --- a/src/drivers/infiniband/golan.h +++ b/src/drivers/infiniband/golan.h @@ -121,7 +121,7 @@ struct golan_firmware_area { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t area; + void *area; }; /* Queue Pair */ #define GOLAN_SEND_WQE_BB_SIZE 64 diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index 3138d8bfb..d25f4f011 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -2422,7 +2422,7 @@ static void hermon_stop_firmware ( struct hermon *hermon ) { DBGC ( hermon, "Hermon %p FATAL could not stop firmware: %s\n", hermon, strerror ( rc ) ); /* Leak memory and return; at least we avoid corruption */ - hermon->firmware_area = UNULL; + hermon->firmware_area = NULL; return; } } diff --git a/src/drivers/infiniband/hermon.h b/src/drivers/infiniband/hermon.h index a952bbd81..be79ff9d0 100644 --- a/src/drivers/infiniband/hermon.h +++ b/src/drivers/infiniband/hermon.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include -#include #include #include #include @@ -887,7 +886,7 @@ struct hermon { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t firmware_area; + void *firmware_area; /** ICM map */ struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS]; /** ICM size */ @@ -900,7 +899,7 @@ struct hermon { * final teardown, in order to avoid memory map changes at * runtime. */ - userptr_t icm; + void *icm; /** Event queue */ struct hermon_event_queue eq; diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index 6381fb2dd..c60d4ca18 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -177,7 +177,7 @@ struct nii_nic { size_t mtu; /** Hardware transmit/receive buffer */ - userptr_t buffer; + void *buffer; /** Hardware transmit/receive buffer length */ size_t buffer_len; diff --git a/src/drivers/net/netvsc.c b/src/drivers/net/netvsc.c index 5be52fb8e..4bdf7b517 100644 --- a/src/drivers/net/netvsc.c +++ b/src/drivers/net/netvsc.c @@ -622,7 +622,7 @@ static int netvsc_buffer_copy ( struct vmbus_xfer_pages *pages, void *data, return -ERANGE; /* Copy data from buffer */ - copy_from_user ( data, buffer->data, offset, len ); + memcpy ( data, ( buffer->data + offset ), len ); return 0; } diff --git a/src/drivers/net/netvsc.h b/src/drivers/net/netvsc.h index 93192357f..41db49af7 100644 --- a/src/drivers/net/netvsc.h +++ b/src/drivers/net/netvsc.h @@ -305,7 +305,7 @@ struct netvsc_buffer { /** Buffer length */ size_t len; /** Buffer */ - userptr_t data; + void *data; /** GPADL ID */ unsigned int gpadl; }; diff --git a/src/drivers/usb/xhci.h b/src/drivers/usb/xhci.h index a3c8888af..22bc115c2 100644 --- a/src/drivers/usb/xhci.h +++ b/src/drivers/usb/xhci.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include /** Minimum alignment required for data structures @@ -1054,7 +1053,7 @@ struct xhci_scratchpad { /** Number of page-sized scratchpad buffers */ unsigned int count; /** Scratchpad buffer area */ - userptr_t buffer; + void *buffer; /** Buffer DMA mapping */ struct dma_mapping buffer_map; /** Scratchpad array */ diff --git a/src/image/segment.c b/src/image/segment.c index ebc2b703d..2cb637dc2 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -57,7 +57,7 @@ struct errortab segment_errors[] __errortab = { * @v memsz Size of the segment * @ret rc Return status code */ -int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ) { +int prep_segment ( void *segment, size_t filesz, size_t memsz ) { struct memory_map memmap; physaddr_t start = virt_to_phys ( segment ); physaddr_t mid = ( start + filesz ); diff --git a/src/include/ipxe/cachedhcp.h b/src/include/ipxe/cachedhcp.h index 8ebee3b7b..5b19bc59e 100644 --- a/src/include/ipxe/cachedhcp.h +++ b/src/include/ipxe/cachedhcp.h @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include struct net_device; struct cached_dhcp_packet; @@ -20,7 +19,7 @@ extern struct cached_dhcp_packet cached_proxydhcp; extern struct cached_dhcp_packet cached_pxebs; extern int cachedhcp_record ( struct cached_dhcp_packet *cache, - unsigned int vlan, userptr_t data, + unsigned int vlan, const void *data, size_t max_len ); extern void cachedhcp_recycle ( struct net_device *netdev ); diff --git a/src/include/ipxe/linux_sysfs.h b/src/include/ipxe/linux_sysfs.h index d97b649c0..fbe1e6e8a 100644 --- a/src/include/ipxe/linux_sysfs.h +++ b/src/include/ipxe/linux_sysfs.h @@ -9,8 +9,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); -#include - -extern int linux_sysfs_read ( const char *filename, userptr_t *data ); +extern int linux_sysfs_read ( const char *filename, void **data ); #endif /* _IPXE_LINUX_SYSFS_H */ diff --git a/src/include/ipxe/memblock.h b/src/include/ipxe/memblock.h index 2bb38c460..4b6c64156 100644 --- a/src/include/ipxe/memblock.h +++ b/src/include/ipxe/memblock.h @@ -10,8 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include -extern size_t largest_memblock ( userptr_t *start ); +extern size_t largest_memblock ( void **start ); #endif /* _IPXE_MEMBLOCK_H */ diff --git a/src/include/ipxe/segment.h b/src/include/ipxe/segment.h index 9d5ecbd9b..b37c93c93 100644 --- a/src/include/ipxe/segment.h +++ b/src/include/ipxe/segment.h @@ -10,8 +10,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); -#include +#include -extern int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ); +extern int prep_segment ( void *segment, size_t filesz, size_t memsz ); #endif /* _IPXE_SEGMENT_H */ diff --git a/src/include/ipxe/vmbus.h b/src/include/ipxe/vmbus.h index 682441857..5eee230fe 100644 --- a/src/include/ipxe/vmbus.h +++ b/src/include/ipxe/vmbus.h @@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include @@ -634,7 +633,7 @@ vmbus_gpadl_is_obsolete ( unsigned int gpadl ) { return ( gpadl <= vmbus_obsolete_gpadl ); } -extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data, +extern int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data, size_t len ); extern int vmbus_gpadl_teardown ( struct vmbus_device *vmdev, unsigned int gpadl ); diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 5165bd804..94e2aae06 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -110,8 +110,7 @@ static int efi_block_rw ( struct san_device *sandev, uint64_t lba, } /* Read from / write to block device */ - if ( ( rc = sandev_rw ( sandev, lba, count, - virt_to_user ( data ) ) ) != 0 ) { + if ( ( rc = sandev_rw ( sandev, lba, count, data ) ) != 0 ) { DBGC ( sandev->drive, "EFIBLK %#02x I/O failed: %s\n", sandev->drive, strerror ( rc ) ); return rc; diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index b64770d8a..7d1d3619f 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -284,8 +284,7 @@ static int efi_bofm_start ( struct efi_device *efidev ) { efi_handle_name ( device ) ); DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length ); } - bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), - &efipci.pci ); + bofmrc = bofm ( ( bofmtab2 ? bofmtab2 : bofmtab ), &efipci.pci ); DBGC ( device, "EFIBOFM %s status %08x\n", efi_handle_name ( device ), bofmrc ); DBGC2 ( device, "EFIBOFM %s version 1 after processing:\n", diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index eb41a8e43..6bba4173a 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -72,8 +72,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Record DHCPACK, if present */ if ( mode->DhcpAckReceived && - ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, - virt_to_user ( &mode->DhcpAck ), + ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, &mode->DhcpAck, sizeof ( mode->DhcpAck ) ) ) != 0 ) ) { DBGC ( device, "EFI %s could not record DHCPACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -83,7 +82,7 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Record ProxyDHCPOFFER, if present */ if ( mode->ProxyOfferReceived && ( ( rc = cachedhcp_record ( &cached_proxydhcp, vlan, - virt_to_user ( &mode->ProxyOffer ), + &mode->ProxyOffer, sizeof ( mode->ProxyOffer ) ) ) != 0)){ DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -92,9 +91,8 @@ int efi_cachedhcp_record ( EFI_HANDLE device, /* Record PxeBSACK, if present */ if ( mode->PxeReplyReceived && - ( ( rc = cachedhcp_record ( &cached_pxebs, vlan, - virt_to_user ( &mode->PxeReply ), - sizeof ( mode->PxeReply ) ) ) != 0)){ + ( ( rc = cachedhcp_record ( &cached_pxebs, vlan, &mode->PxeReply, + sizeof ( mode->PxeReply ) ) ) != 0 )){ DBGC ( device, "EFI %s could not record PXEBSACK: %s\n", efi_handle_name ( device ), strerror ( rc ) ); return rc; diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index b7b97aee7..79330641d 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -177,12 +177,12 @@ static size_t efi_file_len ( struct efi_file *file ) { * Read chunk of EFI file * * @v reader EFI file reader - * @v data Input data, or UNULL to zero-fill + * @v data Input data, or NULL to zero-fill * @v len Length of input data * @ret len Length of output data */ static size_t efi_file_read_chunk ( struct efi_file_reader *reader, - userptr_t data, size_t len ) { + const void *data, size_t len ) { struct efi_file *file = reader->file; size_t offset; @@ -203,7 +203,7 @@ static size_t efi_file_read_chunk ( struct efi_file_reader *reader, /* Copy or zero output data */ if ( data ) { - copy_from_user ( reader->data, data, offset, len ); + memcpy ( reader->data, ( data + offset ), len ); } else { memset ( reader->data, 0, len ); } @@ -262,7 +262,7 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) { efi_file_name ( file ), reader->pos, ( reader->pos + pad_len ) ); } - len += efi_file_read_chunk ( reader, UNULL, pad_len ); + len += efi_file_read_chunk ( reader, NULL, pad_len ); /* Read CPIO header(s), if applicable */ name = cpio_name ( image ); @@ -274,13 +274,10 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) { efi_file_name ( file ), reader->pos, ( reader->pos + cpio_len + pad_len ), image->name ); - len += efi_file_read_chunk ( reader, - virt_to_user ( &cpio ), + len += efi_file_read_chunk ( reader, &cpio, sizeof ( cpio ) ); - len += efi_file_read_chunk ( reader, - virt_to_user ( name ), - name_len ); - len += efi_file_read_chunk ( reader, UNULL, pad_len ); + len += efi_file_read_chunk ( reader, name, name_len ); + len += efi_file_read_chunk ( reader, NULL, pad_len ); } /* Read file data */ diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c index 49ccf69c8..1c44cab5e 100644 --- a/src/interface/hyperv/vmbus.c +++ b/src/interface/hyperv/vmbus.c @@ -273,7 +273,7 @@ static int vmbus_negotiate_version ( struct hv_hypervisor *hv ) { * @v len Length of data buffer * @ret gpadl GPADL ID, or negative error */ -int vmbus_establish_gpadl ( struct vmbus_device *vmdev, userptr_t data, +int vmbus_establish_gpadl ( struct vmbus_device *vmdev, void *data, size_t len ) { struct hv_hypervisor *hv = vmdev->hv; struct vmbus *vmbus = hv->vmbus; @@ -442,7 +442,7 @@ int vmbus_open ( struct vmbus_device *vmdev, memset ( ring, 0, len ); /* Establish GPADL for ring buffer */ - gpadl = vmbus_establish_gpadl ( vmdev, virt_to_user ( ring ), len ); + gpadl = vmbus_establish_gpadl ( vmdev, ring, len ); if ( gpadl < 0 ) { rc = gpadl; goto err_establish; diff --git a/src/interface/linux/linux_acpi.c b/src/interface/linux/linux_acpi.c index a2a8bf12e..21a2e27cc 100644 --- a/src/interface/linux/linux_acpi.c +++ b/src/interface/linux/linux_acpi.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include +#include #include #include #include diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c index a12c936ed..1450fcf1b 100644 --- a/src/interface/linux/linux_smbios.c +++ b/src/interface/linux/linux_smbios.c @@ -19,6 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include #include #include #include diff --git a/src/interface/linux/linux_sysfs.c b/src/interface/linux/linux_sysfs.c index cbb23d81d..321824ba9 100644 --- a/src/interface/linux/linux_sysfs.c +++ b/src/interface/linux/linux_sysfs.c @@ -42,8 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); * @v data Data to fill in * @ret len Length read, or negative error */ -int linux_sysfs_read ( const char *filename, userptr_t *data ) { - userptr_t tmp; +int linux_sysfs_read ( const char *filename, void **data ) { + void *tmp; ssize_t read; size_t len; int fd; @@ -59,7 +59,7 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) { } /* Read file */ - for ( *data = UNULL, len = 0 ; ; len += read ) { + for ( *data = NULL, len = 0 ; ; len += read ) { /* (Re)allocate space */ tmp = urealloc ( *data, ( len + LINUX_SYSFS_BLKSIZE ) ); diff --git a/src/tests/bofm_test.c b/src/tests/bofm_test.c index 829924887..dbef1eb90 100644 --- a/src/tests/bofm_test.c +++ b/src/tests/bofm_test.c @@ -26,7 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -111,7 +110,7 @@ void bofm_test ( struct pci_device *pci ) { printf ( "BOFMTEST performing harvest\n" ); bofmtab_harvest.en.busdevfn = pci->busdevfn; DBG_HDA ( 0, &bofmtab_harvest, sizeof ( bofmtab_harvest ) ); - bofmrc = bofm ( virt_to_user ( &bofmtab_harvest ), pci ); + bofmrc = bofm ( &bofmtab_harvest, pci ); printf ( "BOFMTEST harvest result %08x\n", bofmrc ); if ( bofmtab_harvest.en.options & BOFM_EN_HVST ) { printf ( "BOFMTEST harvested MAC address %s\n", @@ -125,7 +124,7 @@ void bofm_test ( struct pci_device *pci ) { printf ( "BOFMTEST performing update\n" ); bofmtab_update.en.busdevfn = pci->busdevfn; DBG_HDA ( 0, &bofmtab_update, sizeof ( bofmtab_update ) ); - bofmrc = bofm ( virt_to_user ( &bofmtab_update ), pci ); + bofmrc = bofm ( &bofmtab_update, pci ); printf ( "BOFMTEST update result %08x\n", bofmrc ); if ( bofmtab_update.en.options & BOFM_EN_CSM_SUCCESS ) { printf ( "BOFMTEST updated MAC address to %s\n", -- cgit v1.2.3-55-g7522 From 2742ed5d77e1dd6cdcf20800d2b43295874ac621 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 16:35:49 +0100 Subject: [uaccess] Remove now-obsolete memchr_user() Signed-off-by: Michael Brown --- src/arch/x86/include/librm.h | 7 ------- src/arch/x86/transitions/librm_mgmt.c | 1 - src/core/uaccess.c | 1 - src/include/ipxe/linux/linux_uaccess.h | 6 ------ src/include/ipxe/uaccess.h | 34 ---------------------------------- src/interface/linux/linux_uaccess.c | 1 - 6 files changed, 50 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 7755abdcf..379b6d849 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -131,13 +131,6 @@ UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) { return trivial_virt_to_user ( addr ); } -static inline __always_inline off_t -UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - return trivial_memchr_user ( buffer, offset, c, len ); -} - - /****************************************************************************** * * Access to variables in .data16 and .text16 diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index e0679f0ff..5a6942825 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -431,7 +431,6 @@ void setup_sipi ( unsigned int vector, uint32_t handler, PROVIDE_UACCESS_INLINE ( librm, phys_to_virt ); PROVIDE_UACCESS_INLINE ( librm, virt_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); -PROVIDE_UACCESS_INLINE ( librm, memchr_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); PROVIDE_IOMAP ( pages, ioremap, ioremap_pages ); PROVIDE_IOMAP ( pages, iounmap, iounmap_pages ); diff --git a/src/core/uaccess.c b/src/core/uaccess.c index 32bd1ac38..bf922f66d 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -35,4 +35,3 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); PROVIDE_UACCESS_INLINE ( flat, phys_to_virt ); PROVIDE_UACCESS_INLINE ( flat, virt_to_phys ); PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); -PROVIDE_UACCESS_INLINE ( flat, memchr_user ); diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index b4f7e2fc6..7d5f5f642 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -62,10 +62,4 @@ UACCESS_INLINE ( linux, virt_to_user ) ( volatile const void *addr ) { return trivial_virt_to_user ( addr ); } -static inline __always_inline off_t -UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - return trivial_memchr_user ( buffer, offset, c, len ); -} - #endif /* _IPXE_LINUX_UACCESS_H */ diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 62030dd8a..d0c6882ed 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -51,23 +51,6 @@ trivial_virt_to_user ( volatile const void *addr ) { return ( ( userptr_t ) addr ); } -/** - * Find character in user buffer - * - * @v buffer User buffer - * @v offset Starting offset within buffer - * @v c Character to search for - * @v len Length of user buffer - * @ret offset Offset of character, or <0 if not found - */ -static inline __always_inline off_t -trivial_memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) { - void *found; - - found = memchr ( ( ( void * ) buffer + offset ), c, len ); - return ( found ? ( found - ( void * ) buffer ) : -1 ); -} - /** @} */ /** @@ -114,12 +97,6 @@ UACCESS_INLINE ( flat, virt_to_user ) ( volatile const void *addr ) { return trivial_virt_to_user ( addr ); } -static inline __always_inline off_t -UACCESS_INLINE ( flat, memchr_user ) ( userptr_t buffer, off_t offset, - int c, size_t len ) { - return trivial_memchr_user ( buffer, offset, c, len ); -} - /* Include all architecture-independent user access API headers */ #include @@ -179,15 +156,4 @@ copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) { memcpy ( dest, ( src + src_off ), len ); } -/** - * Find character in user buffer - * - * @v userptr User buffer - * @v offset Starting offset within buffer - * @v c Character to search for - * @v len Length of user buffer - * @ret offset Offset of character, or <0 if not found - */ -off_t memchr_user ( userptr_t userptr, off_t offset, int c, size_t len ); - #endif /* _IPXE_UACCESS_H */ diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index 4fdd8c03a..436707757 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -30,4 +30,3 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, phys_to_virt); PROVIDE_UACCESS_INLINE(linux, virt_to_phys); PROVIDE_UACCESS_INLINE(linux, virt_to_user); -PROVIDE_UACCESS_INLINE(linux, memchr_user); -- cgit v1.2.3-55-g7522 From 2f11f466e6b6cb47ac3b703b145e01f87bf8092e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 17:11:30 +0100 Subject: [block] Remove userptr_t from block device abstraction Simplify the block device code by assuming that all read/write buffers are directly accessible via pointer dereferences. Signed-off-by: Michael Brown --- src/arch/x86/interface/pcbios/int13.c | 17 ++++++++--------- src/core/blockdev.c | 8 ++++---- src/core/blocktrans.c | 8 ++++---- src/core/dummy_sanboot.c | 1 + src/core/sanboot.c | 23 ++++++++++++----------- src/drivers/block/ata.c | 30 +++++++++++++++--------------- src/drivers/block/scsi.c | 16 ++++++++-------- src/drivers/usb/usbblk.c | 10 +++++----- src/include/ipxe/ata.h | 5 ++--- src/include/ipxe/blockdev.h | 13 ++++++------- src/include/ipxe/blocktrans.h | 7 +++---- src/include/ipxe/sanboot.h | 4 ++-- src/include/ipxe/scsi.h | 5 ++--- src/interface/efi/efi_block.c | 5 +++-- src/net/aoe.c | 7 ++----- src/net/fcp.c | 6 +++--- src/net/tcp/httpblock.c | 5 ++--- src/net/tcp/httpcore.c | 2 +- src/net/tcp/iscsi.c | 7 +++---- 19 files changed, 86 insertions(+), 93 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index 498676b70..73fdfebd3 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -181,8 +181,7 @@ static int int13_parse_eltorito ( struct san_device *sandev, void *scratch ) { int rc; /* Read boot record volume descriptor */ - if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1, - virt_to_user ( boot ) ) ) != 0 ) { + if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1, boot ) ) != 0 ) { DBGC ( sandev->drive, "INT13 drive %02x could not read El " "Torito boot record volume descriptor: %s\n", sandev->drive, strerror ( rc ) ); @@ -228,7 +227,7 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch, int rc; /* Read partition table */ - if ( ( rc = sandev_read ( sandev, 0, 1, virt_to_user ( mbr ) ) ) != 0 ) { + if ( ( rc = sandev_read ( sandev, 0, 1, mbr ) ) != 0 ) { DBGC ( sandev->drive, "INT13 drive %02x could not read " "partition table to guess geometry: %s\n", sandev->drive, strerror ( rc ) ); @@ -517,12 +516,12 @@ static int int13_rw_sectors ( struct san_device *sandev, int ( * sandev_rw ) ( struct san_device *sandev, uint64_t lba, unsigned int count, - userptr_t buffer ) ) { + void *buffer ) ) { struct int13_data *int13 = sandev->priv; unsigned int cylinder, head, sector; unsigned long lba; unsigned int count; - userptr_t buffer; + void *buffer; int rc; /* Validate blocksize */ @@ -710,12 +709,12 @@ static int int13_extended_rw ( struct san_device *sandev, int ( * sandev_rw ) ( struct san_device *sandev, uint64_t lba, unsigned int count, - userptr_t buffer ) ) { + void *buffer ) ) { struct int13_disk_address addr; uint8_t bufsize; uint64_t lba; unsigned long count; - userptr_t buffer; + void *buffer; int rc; /* Extended reads are not allowed on floppy drives. @@ -1455,8 +1454,8 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) { "catalog (status %04x)\n", drive, status ); return -EIO; } - copy_from_user ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), 0, - sizeof ( catalog ) ); + memcpy ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), + sizeof ( catalog ) ); /* Sanity checks */ if ( catalog.valid.platform_id != ELTORITO_PLATFORM_X86 ) { diff --git a/src/core/blockdev.c b/src/core/blockdev.c index c219d9673..3513caafa 100644 --- a/src/core/blockdev.c +++ b/src/core/blockdev.c @@ -45,8 +45,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ int block_read ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + uint64_t lba, unsigned int count, void *buffer, + size_t len ) { struct interface *dest; block_read_TYPE ( void * ) *op = intf_get_dest_op ( control, block_read, &dest ); @@ -76,8 +76,8 @@ int block_read ( struct interface *control, struct interface *data, * @ret rc Return status code */ int block_write ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + uint64_t lba, unsigned int count, void *buffer, + size_t len ) { struct interface *dest; block_write_TYPE ( void * ) *op = intf_get_dest_op ( control, block_write, &dest ); diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index f3be2ba2b..ba70462f2 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -81,7 +81,7 @@ static void blktrans_xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset, if ( blktrans->buffer ) { /* Write data to buffer */ - copy_to_user ( blktrans->buffer, offset, data, len ); + memcpy ( ( blktrans->buffer + offset ), data, len ); } else { @@ -107,7 +107,7 @@ static void blktrans_xferbuf_read ( struct xfer_buffer *xferbuf, size_t offset, if ( blktrans->buffer ) { /* Read data from buffer */ - copy_from_user ( data, blktrans->buffer, offset, len ); + memcpy ( data, ( blktrans->buffer + offset ), len ); } else { @@ -216,11 +216,11 @@ static struct interface_descriptor blktrans_xfer_desc = * Insert block device translator * * @v block Block device interface - * @v buffer Data buffer (or UNULL) + * @v buffer Data buffer (or NULL) * @v size Length of data buffer, or block size * @ret rc Return status code */ -int block_translate ( struct interface *block, userptr_t buffer, size_t size ) { +int block_translate ( struct interface *block, void *buffer, size_t size ) { struct block_translator *blktrans; int rc; diff --git a/src/core/dummy_sanboot.c b/src/core/dummy_sanboot.c index e22998da5..5ca120aac 100644 --- a/src/core/dummy_sanboot.c +++ b/src/core/dummy_sanboot.c @@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include diff --git a/src/core/sanboot.c b/src/core/sanboot.c index 4facf86b8..bdac813ff 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -424,10 +424,10 @@ int sandev_reopen ( struct san_device *sandev ) { struct san_command_rw_params { /** SAN device read/write operation */ int ( * block_rw ) ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ); + uint64_t lba, unsigned int count, void *buffer, + size_t len ); /** Data buffer */ - userptr_t buffer; + void *buffer; /** Starting LBA */ uint64_t lba; /** Block count */ @@ -594,11 +594,11 @@ int sandev_reset ( struct san_device *sandev ) { * @ret rc Return status code */ static int sandev_rw ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer, + unsigned int count, void *buffer, int ( * block_rw ) ( struct interface *control, struct interface *data, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) ) { + void *buffer, size_t len ) ) { union san_command_params params; unsigned int remaining; size_t frag_len; @@ -643,11 +643,12 @@ static int sandev_rw ( struct san_device *sandev, uint64_t lba, * @ret rc Return status code */ int sandev_read ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ) { + unsigned int count, void *buffer ) { int rc; /* Read from device */ - if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_read ) ) != 0 ) + if ( ( rc = sandev_rw ( sandev, lba, count, buffer, + block_read ) ) != 0 ) return rc; return 0; @@ -663,11 +664,12 @@ int sandev_read ( struct san_device *sandev, uint64_t lba, * @ret rc Return status code */ int sandev_write ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ) { + unsigned int count, void *buffer ) { int rc; /* Write to device */ - if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_write ) ) != 0 ) + if ( ( rc = sandev_rw ( sandev, lba, count, buffer, + block_write ) ) != 0 ) return rc; /* Quiesce system. This is a heuristic designed to ensure @@ -799,8 +801,7 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) { } /* Read primary volume descriptor */ - if ( ( rc = sandev_read ( sandev, lba, count, - virt_to_user ( scratch ) ) ) != 0 ) { + if ( ( rc = sandev_read ( sandev, lba, count, scratch ) ) != 0 ) { DBGC ( sandev->drive, "SAN %#02x could not read ISO9660 " "primary volume descriptor: %s\n", sandev->drive, strerror ( rc ) ); diff --git a/src/drivers/block/ata.c b/src/drivers/block/ata.c index b1c6855a0..cf98d7c9f 100644 --- a/src/drivers/block/ata.c +++ b/src/drivers/block/ata.c @@ -147,8 +147,8 @@ struct ata_command_type { * @ret data_in Data-in buffer * @ret data_in_len Data-in buffer length */ - void ( * data_in ) ( struct ata_command *atacmd, userptr_t buffer, - size_t len, userptr_t *data_in, + void ( * data_in ) ( struct ata_command *atacmd, void *buffer, + size_t len, void **data_in, size_t *data_in_len ); /** * Calculate data-out buffer @@ -160,8 +160,8 @@ struct ata_command_type { * @ret data_out Data-out buffer * @ret data_out_len Data-out buffer length */ - void ( * data_out ) ( struct ata_command *atacmd, userptr_t buffer, - size_t len, userptr_t *data_out, + void ( * data_out ) ( struct ata_command *atacmd, void *buffer, + size_t len, void **data_out, size_t *data_out_len ); /** * Handle ATA command completion @@ -285,8 +285,8 @@ static void atacmd_done ( struct ata_command *atacmd, int rc ) { * @ret data_len Data buffer length */ static void atacmd_data_buffer ( struct ata_command *atacmd __unused, - userptr_t buffer, size_t len, - userptr_t *data, size_t *data_len ) { + void *buffer, size_t len, + void **data, size_t *data_len ) { *data = buffer; *data_len = len; } @@ -301,8 +301,8 @@ static void atacmd_data_buffer ( struct ata_command *atacmd __unused, * @ret data_len Data buffer length */ static void atacmd_data_none ( struct ata_command *atacmd __unused, - userptr_t buffer __unused, size_t len __unused, - userptr_t *data __unused, + void *buffer __unused, size_t len __unused, + void **data __unused, size_t *data_len __unused ) { /* Nothing to do */ } @@ -317,9 +317,9 @@ static void atacmd_data_none ( struct ata_command *atacmd __unused, * @ret data_len Data buffer length */ static void atacmd_data_priv ( struct ata_command *atacmd, - userptr_t buffer __unused, size_t len __unused, - userptr_t *data, size_t *data_len ) { - *data = virt_to_user ( atacmd_priv ( atacmd ) ); + void *buffer __unused, size_t len __unused, + void **data, size_t *data_len ) { + *data = atacmd_priv ( atacmd ); *data_len = atacmd->type->priv_len; } @@ -455,7 +455,7 @@ static int atadev_command ( struct ata_device *atadev, struct interface *block, struct ata_command_type *type, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { struct ata_command *atacmd; struct ata_cmd command; int tag; @@ -543,7 +543,7 @@ static int atadev_command ( struct ata_device *atadev, static int atadev_read ( struct ata_device *atadev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return atadev_command ( atadev, block, &atacmd_read, lba, count, buffer, len ); } @@ -562,7 +562,7 @@ static int atadev_read ( struct ata_device *atadev, static int atadev_write ( struct ata_device *atadev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return atadev_command ( atadev, block, &atacmd_write, lba, count, buffer, len ); } @@ -581,7 +581,7 @@ static int atadev_read_capacity ( struct ata_device *atadev, assert ( atacmd_identify.priv_len == sizeof ( *identity ) ); assert ( atacmd_identify.priv_len == ATA_SECTOR_SIZE ); return atadev_command ( atadev, block, &atacmd_identify, - 0, 1, UNULL, ATA_SECTOR_SIZE ); + 0, 1, NULL, ATA_SECTOR_SIZE ); } /** diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index ff415f5c6..251210d4f 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -279,7 +279,7 @@ struct scsi_command { /** Number of blocks */ unsigned int count; /** Data buffer */ - userptr_t buffer; + void *buffer; /** Length of data buffer */ size_t len; /** Command tag */ @@ -591,12 +591,12 @@ static void scsicmd_read_capacity_cmd ( struct scsi_command *scsicmd, readcap16->service_action = SCSI_SERVICE_ACTION_READ_CAPACITY_16; readcap16->len = cpu_to_be32 ( sizeof ( *capacity16 ) ); - command->data_in = virt_to_user ( capacity16 ); + command->data_in = capacity16; command->data_in_len = sizeof ( *capacity16 ); } else { /* Use READ CAPACITY (10) */ readcap10->opcode = SCSI_OPCODE_READ_CAPACITY_10; - command->data_in = virt_to_user ( capacity10 ); + command->data_in = capacity10; command->data_in_len = sizeof ( *capacity10 ); } } @@ -721,7 +721,7 @@ static int scsidev_command ( struct scsi_device *scsidev, struct interface *block, struct scsi_command_type *type, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { struct scsi_command *scsicmd; int rc; @@ -773,7 +773,7 @@ static int scsidev_command ( struct scsi_device *scsidev, static int scsidev_read ( struct scsi_device *scsidev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return scsidev_command ( scsidev, block, &scsicmd_read, lba, count, buffer, len ); } @@ -792,7 +792,7 @@ static int scsidev_read ( struct scsi_device *scsidev, static int scsidev_write ( struct scsi_device *scsidev, struct interface *block, uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ) { + void *buffer, size_t len ) { return scsidev_command ( scsidev, block, &scsicmd_write, lba, count, buffer, len ); } @@ -807,7 +807,7 @@ static int scsidev_write ( struct scsi_device *scsidev, static int scsidev_read_capacity ( struct scsi_device *scsidev, struct interface *block ) { return scsidev_command ( scsidev, block, &scsicmd_read_capacity, - 0, 0, UNULL, 0 ); + 0, 0, NULL, 0 ); } /** @@ -820,7 +820,7 @@ static int scsidev_read_capacity ( struct scsi_device *scsidev, static int scsidev_test_unit_ready ( struct scsi_device *scsidev, struct interface *block ) { return scsidev_command ( scsidev, block, &scsicmd_test_unit_ready, - 0, 0, UNULL, 0 ); + 0, 0, NULL, 0 ); } /** diff --git a/src/drivers/usb/usbblk.c b/src/drivers/usb/usbblk.c index 5a086d3f8..39adc012f 100644 --- a/src/drivers/usb/usbblk.c +++ b/src/drivers/usb/usbblk.c @@ -205,7 +205,7 @@ static int usbblk_out_data ( struct usbblk_device *usbblk ) { /* Calculate length */ assert ( cmd->tag ); - assert ( cmd->scsi.data_out != UNULL ); + assert ( cmd->scsi.data_out != NULL ); assert ( cmd->offset < cmd->scsi.data_out_len ); len = ( cmd->scsi.data_out_len - cmd->offset ); if ( len > USBBLK_MAX_LEN ) @@ -220,8 +220,8 @@ static int usbblk_out_data ( struct usbblk_device *usbblk ) { } /* Populate I/O buffer */ - copy_from_user ( iob_put ( iobuf, len ), cmd->scsi.data_out, - cmd->offset, len ); + memcpy ( iob_put ( iobuf, len ), + ( cmd->scsi.data_out + cmd->offset ), len ); /* Send data */ if ( ( rc = usb_stream ( &usbblk->out, iobuf, 0 ) ) != 0 ) { @@ -332,12 +332,12 @@ static int usbblk_in_data ( struct usbblk_device *usbblk, const void *data, /* Sanity checks */ assert ( cmd->tag ); - assert ( cmd->scsi.data_in != UNULL ); + assert ( cmd->scsi.data_in != NULL ); assert ( cmd->offset <= cmd->scsi.data_in_len ); assert ( len <= ( cmd->scsi.data_in_len - cmd->offset ) ); /* Store data */ - copy_to_user ( cmd->scsi.data_in, cmd->offset, data, len ); + memcpy ( ( cmd->scsi.data_in + cmd->offset ), data, len ); cmd->offset += len; return 0; diff --git a/src/include/ipxe/ata.h b/src/include/ipxe/ata.h index a10cfafcc..cd78cd795 100644 --- a/src/include/ipxe/ata.h +++ b/src/include/ipxe/ata.h @@ -2,7 +2,6 @@ #define _IPXE_ATA_H #include -#include #include /** @file @@ -173,7 +172,7 @@ struct ata_cmd { * If non-NULL, this buffer must be ata_command::cb::count * sectors in size. */ - userptr_t data_out; + void *data_out; /** Data-out buffer length * * Must be zero if @c data_out is NULL @@ -184,7 +183,7 @@ struct ata_cmd { * If non-NULL, this buffer must be ata_command::cb::count * sectors in size. */ - userptr_t data_in; + void *data_in; /** Data-in buffer length * * Must be zero if @c data_in is NULL diff --git a/src/include/ipxe/blockdev.h b/src/include/ipxe/blockdev.h index 418c43004..ef6fc8d5a 100644 --- a/src/include/ipxe/blockdev.h +++ b/src/include/ipxe/blockdev.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include /** Block device capacity */ @@ -25,20 +24,20 @@ struct block_device_capacity { }; extern int block_read ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ); + uint64_t lba, unsigned int count, void *buffer, + size_t len ); #define block_read_TYPE( object_type ) \ typeof ( int ( object_type, struct interface *data, \ uint64_t lba, unsigned int count, \ - userptr_t buffer, size_t len ) ) + void *buffer, size_t len ) ) extern int block_write ( struct interface *control, struct interface *data, - uint64_t lba, unsigned int count, - userptr_t buffer, size_t len ); + uint64_t lba, unsigned int count, void *buffer, + size_t len ); #define block_write_TYPE( object_type ) \ typeof ( int ( object_type, struct interface *data, \ uint64_t lba, unsigned int count, \ - userptr_t buffer, size_t len ) ) + void *buffer, size_t len ) ) extern int block_read_capacity ( struct interface *control, struct interface *data ); diff --git a/src/include/ipxe/blocktrans.h b/src/include/ipxe/blocktrans.h index fee71b96c..1167a256e 100644 --- a/src/include/ipxe/blocktrans.h +++ b/src/include/ipxe/blocktrans.h @@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /** A block device translator */ struct block_translator { @@ -27,12 +26,12 @@ struct block_translator { /** Data transfer buffer */ struct xfer_buffer xferbuf; /** Data buffer */ - userptr_t buffer; + void *buffer; /** Block size */ size_t blksize; }; -extern int block_translate ( struct interface *block, - userptr_t buffer, size_t size ); +extern int block_translate ( struct interface *block, void *buffer, + size_t size ); #endif /* _IPXE_BLOCKTRANS_H */ diff --git a/src/include/ipxe/sanboot.h b/src/include/ipxe/sanboot.h index e44367cdb..9d5fceee0 100644 --- a/src/include/ipxe/sanboot.h +++ b/src/include/ipxe/sanboot.h @@ -261,9 +261,9 @@ extern struct san_device * sandev_next ( unsigned int drive ); extern int sandev_reopen ( struct san_device *sandev ); extern int sandev_reset ( struct san_device *sandev ); extern int sandev_read ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ); + unsigned int count, void *buffer ); extern int sandev_write ( struct san_device *sandev, uint64_t lba, - unsigned int count, userptr_t buffer ); + unsigned int count, void *buffer ); extern struct san_device * alloc_sandev ( struct uri **uris, unsigned int count, size_t priv_size ); extern int register_sandev ( struct san_device *sandev, unsigned int drive, diff --git a/src/include/ipxe/scsi.h b/src/include/ipxe/scsi.h index 28b55b2d5..9bb38a059 100644 --- a/src/include/ipxe/scsi.h +++ b/src/include/ipxe/scsi.h @@ -2,7 +2,6 @@ #define _IPXE_SCSI_H #include -#include #include /** @file @@ -252,14 +251,14 @@ struct scsi_cmd { /** CDB for this command */ union scsi_cdb cdb; /** Data-out buffer (may be NULL) */ - userptr_t data_out; + void *data_out; /** Data-out buffer length * * Must be zero if @c data_out is NULL */ size_t data_out_len; /** Data-in buffer (may be NULL) */ - userptr_t data_in; + void *data_in; /** Data-in buffer length * * Must be zero if @c data_in is NULL diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 94e2aae06..aa5ec4e0f 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -95,8 +95,9 @@ struct efi_block_data { static int efi_block_rw ( struct san_device *sandev, uint64_t lba, void *data, size_t len, int ( * sandev_rw ) ( struct san_device *sandev, - uint64_t lba, unsigned int count, - userptr_t buffer ) ) { + uint64_t lba, + unsigned int count, + void *buffer ) ) { struct efi_block_data *block = sandev->priv; unsigned int count; int rc; diff --git a/src/net/aoe.c b/src/net/aoe.c index dba4f51b5..b484bdd33 100644 --- a/src/net/aoe.c +++ b/src/net/aoe.c @@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -391,8 +390,7 @@ static void aoecmd_ata_cmd ( struct aoe_command *aoecmd, if ( ! command->cb.lba48 ) aoeata->lba.bytes[3] |= ( command->cb.device & ATA_DEV_MASK ); - copy_from_user ( aoeata->data, command->data_out, 0, - command->data_out_len ); + memcpy ( aoeata->data, command->data_out, command->data_out_len ); DBGC2 ( aoedev, "AoE %s/%08x ATA cmd %02x:%02x:%02x:%02x:%08llx", aoedev_name ( aoedev ), aoecmd->tag, aoeata->aflags, @@ -452,8 +450,7 @@ static int aoecmd_ata_rsp ( struct aoe_command *aoecmd, const void *data, } /* Copy out data payload */ - copy_to_user ( command->data_in, 0, aoeata->data, - command->data_in_len ); + memcpy ( command->data_in, aoeata->data, command->data_in_len ); return 0; } diff --git a/src/net/fcp.c b/src/net/fcp.c index f78f7bd9b..9701b5d54 100644 --- a/src/net/fcp.c +++ b/src/net/fcp.c @@ -413,7 +413,7 @@ static int fcpcmd_recv_rddata ( struct fcp_command *fcpcmd, fcpdev, fcpcmd->xchg_id, offset, ( offset + len ) ); /* Copy to user buffer */ - copy_to_user ( command->data_in, offset, iobuf->data, len ); + memcpy ( ( command->data_in + offset ), iobuf->data, len ); fcpcmd->offset += len; assert ( fcpcmd->offset <= command->data_in_len ); @@ -464,8 +464,8 @@ static int fcpcmd_send_wrdata ( struct fcp_command *fcpcmd ) { } /* Construct data IU frame */ - copy_from_user ( iob_put ( iobuf, len ), command->data_out, - fcpcmd->offset, len ); + memcpy ( iob_put ( iobuf, len ), + ( command->data_out + fcpcmd->offset ), len ); memset ( &meta, 0, sizeof ( meta ) ); meta.flags = ( XFER_FL_RESPONSE | XFER_FL_ABS_OFFSET ); meta.offset = fcpcmd->offset; diff --git a/src/net/tcp/httpblock.c b/src/net/tcp/httpblock.c index 1abd6b34d..156f11e47 100644 --- a/src/net/tcp/httpblock.c +++ b/src/net/tcp/httpblock.c @@ -31,7 +31,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include -#include #include #include #include @@ -52,7 +51,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret rc Return status code */ int http_block_read ( struct http_transaction *http, struct interface *data, - uint64_t lba, unsigned int count, userptr_t buffer, + uint64_t lba, unsigned int count, void *buffer, size_t len ) { struct http_request_range range; int rc; @@ -101,7 +100,7 @@ int http_block_read_capacity ( struct http_transaction *http, goto err_open; /* Insert block device translator */ - if ( ( rc = block_translate ( data, UNULL, HTTP_BLKSIZE ) ) != 0 ) { + if ( ( rc = block_translate ( data, NULL, HTTP_BLKSIZE ) ) != 0 ) { DBGC ( http, "HTTP %p could not insert block translator: %s\n", http, strerror ( rc ) ); goto err_translate; diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c index 7052bbbad..57c31ac26 100644 --- a/src/net/tcp/httpcore.c +++ b/src/net/tcp/httpcore.c @@ -503,7 +503,7 @@ http_content_buffer ( struct http_transaction *http ) { __weak int http_block_read ( struct http_transaction *http __unused, struct interface *data __unused, uint64_t lba __unused, unsigned int count __unused, - userptr_t buffer __unused, size_t len __unused ) { + void *buffer __unused, size_t len __unused ) { return -ENOTSUP; } diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index dd20849ce..b7b33a51a 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -39,7 +39,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -478,7 +477,7 @@ static int iscsi_rx_data_in ( struct iscsi_session *iscsi, assert ( iscsi->command != NULL ); assert ( iscsi->command->data_in ); assert ( ( offset + len ) <= iscsi->command->data_in_len ); - copy_to_user ( iscsi->command->data_in, offset, data, len ); + memcpy ( ( iscsi->command->data_in + offset ), data, len ); /* Wait for whole SCSI response to arrive */ if ( remaining ) @@ -598,8 +597,8 @@ static int iscsi_tx_data_out ( struct iscsi_session *iscsi ) { if ( ! iobuf ) return -ENOMEM; - copy_from_user ( iob_put ( iobuf, len ), - iscsi->command->data_out, offset, len ); + memcpy ( iob_put ( iobuf, len ), + ( iscsi->command->data_out + offset ), len ); memset ( iob_put ( iobuf, pad_len ), 0, pad_len ); return xfer_deliver_iob ( &iscsi->socket, iobuf ); -- cgit v1.2.3-55-g7522 From aa3cc56ab20763eb1d8e04085ee6013636760606 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 25 Apr 2025 10:52:26 +0100 Subject: [fbcon] Remove userptr_t from framebuffer console drivers Simplify the framebuffer console drivers by assuming that the raw framebuffer, character cell array, background picture, and glyph data are all directly accessible via pointer dereferences. In particular, this avoids the need to copy each glyph during drawing: the VESA framebuffer driver can simply return a pointer to the glyph data stored in the video ROM. Signed-off-by: Michael Brown --- src/arch/x86/interface/pcbios/vesafb.c | 37 ++++----- src/core/fbcon.c | 137 +++++++++++++++------------------ src/include/ipxe/fbcon.h | 13 ++-- src/include/ipxe/pixbuf.h | 19 ++++- src/interface/efi/efi_fbcon.c | 22 +++--- 5 files changed, 112 insertions(+), 116 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/interface/pcbios/vesafb.c b/src/arch/x86/interface/pcbios/vesafb.c index cfa935126..961160ff8 100644 --- a/src/arch/x86/interface/pcbios/vesafb.c +++ b/src/arch/x86/interface/pcbios/vesafb.c @@ -103,7 +103,7 @@ struct vesafb { /** Font definition */ struct fbcon_font font; /** Character glyphs */ - struct segoff glyphs; + const uint8_t *glyphs; /** Saved VGA mode */ uint8_t saved_mode; }; @@ -140,11 +140,10 @@ static int vesafb_rc ( unsigned int status ) { * Get character glyph * * @v character Unicode character - * @v glyph Character glyph to fill in + * @ret glyph Character glyph */ -static void vesafb_glyph ( unsigned int character, uint8_t *glyph ) { +static const uint8_t * vesafb_glyph ( unsigned int character ) { unsigned int index; - size_t offset; /* Identify glyph */ if ( character < VESAFB_ASCII ) { @@ -155,10 +154,8 @@ static void vesafb_glyph ( unsigned int character, uint8_t *glyph ) { index = VESAFB_UNKNOWN; } - /* Copy glyph from BIOS font table */ - offset = ( index * VESAFB_CHAR_HEIGHT ); - copy_from_real ( glyph, vesafb.glyphs.segment, - ( vesafb.glyphs.offset + offset ), VESAFB_CHAR_HEIGHT); + /* Return glyph in BIOS font table */ + return &vesafb.glyphs[ index * VESAFB_CHAR_HEIGHT ]; } /** @@ -166,6 +163,7 @@ static void vesafb_glyph ( unsigned int character, uint8_t *glyph ) { * */ static void vesafb_font ( void ) { + struct segoff glyphs; /* Get font information * @@ -186,12 +184,13 @@ static void vesafb_font ( void ) { "movw %%es, %%cx\n\t" "movw %%bp, %%dx\n\t" "popw %%bp\n\t" /* gcc bug */ ) - : "=c" ( vesafb.glyphs.segment ), - "=d" ( vesafb.glyphs.offset ) + : "=c" ( glyphs.segment ), + "=d" ( glyphs.offset ) : "a" ( VBE_GET_FONT ), "b" ( VESAFB_FONT ) ); DBGC ( &vbe_buf, "VESAFB has font %04x at %04x:%04x\n", - VESAFB_FONT, vesafb.glyphs.segment, vesafb.glyphs.offset ); + VESAFB_FONT, glyphs.segment, glyphs.offset ); + vesafb.glyphs = real_to_virt ( glyphs.segment, glyphs.offset ); vesafb.font.height = VESAFB_CHAR_HEIGHT; vesafb.font.glyph = vesafb_glyph; } @@ -206,8 +205,8 @@ static void vesafb_font ( void ) { */ static int vesafb_mode_list ( uint16_t **mode_numbers ) { struct vbe_controller_info *controller = &vbe_buf.controller; - userptr_t video_mode_ptr; - uint16_t mode_number; + const uint16_t *video_mode_ptr; + const uint16_t *mode_number; uint16_t status; size_t len; int rc; @@ -245,18 +244,16 @@ static int vesafb_mode_list ( uint16_t **mode_numbers ) { /* Calculate length of mode list */ video_mode_ptr = real_to_virt ( controller->video_mode_ptr.segment, controller->video_mode_ptr.offset ); - len = 0; - do { - copy_from_user ( &mode_number, video_mode_ptr, len, - sizeof ( mode_number ) ); - len += sizeof ( mode_number ); - } while ( mode_number != VBE_MODE_END ); + mode_number = video_mode_ptr; + while ( *(mode_number++) != VBE_MODE_END ) {} + len = ( ( ( const void * ) mode_number ) - + ( ( const void * ) video_mode_ptr ) ); /* Allocate and fill mode list */ *mode_numbers = malloc ( len ); if ( ! *mode_numbers ) return -ENOMEM; - copy_from_user ( *mode_numbers, video_mode_ptr, 0, len ); + memcpy ( *mode_numbers, video_mode_ptr, len ); return 0; } diff --git a/src/core/fbcon.c b/src/core/fbcon.c index 6d08ac419..f2b2ea566 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -102,6 +102,23 @@ static void fbcon_set_default_background ( struct fbcon *fbcon ) { fbcon->background = FBCON_TRANSPARENT; } +/** + * Get character cell + * + * @v fbcon Frame buffer console + * @v xpos X position + * @v ypos Y position + * @ret cell Text cell + */ +static inline struct fbcon_text_cell * fbcon_cell ( struct fbcon *fbcon, + unsigned int xpos, + unsigned int ypos ) { + unsigned int index; + + index = ( ( ypos * fbcon->character.width ) + xpos ); + return &fbcon->text.cells[index]; +} + /** * Clear rows of characters * @@ -109,43 +126,21 @@ static void fbcon_set_default_background ( struct fbcon *fbcon ) { * @v ypos Starting Y position */ static void fbcon_clear ( struct fbcon *fbcon, unsigned int ypos ) { - struct fbcon_text_cell cell = { - .foreground = fbcon->foreground, - .background = fbcon->background, - .character = ' ', - }; - size_t offset; + struct fbcon_text_cell *cell; unsigned int xpos; /* Clear stored character array */ + cell = fbcon_cell ( fbcon, 0, ypos ); for ( ; ypos < fbcon->character.height ; ypos++ ) { - offset = ( ypos * fbcon->character.width * sizeof ( cell ) ); for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) { - copy_to_user ( fbcon->text.start, offset, &cell, - sizeof ( cell ) ); - offset += sizeof ( cell ); + cell->foreground = fbcon->foreground; + cell->background = fbcon->background; + cell->character = ' '; + cell++; } } } -/** - * Store character at specified position - * - * @v fbcon Frame buffer console - * @v cell Text cell - * @v xpos X position - * @v ypos Y position - */ -static void fbcon_store ( struct fbcon *fbcon, struct fbcon_text_cell *cell, - unsigned int xpos, unsigned int ypos ) { - size_t offset; - - /* Store cell */ - offset = ( ( ( ypos * fbcon->character.width ) + xpos ) * - sizeof ( *cell ) ); - copy_to_user ( fbcon->text.start, offset, cell, sizeof ( *cell ) ); -} - /** * Draw character at specified position * @@ -156,7 +151,7 @@ static void fbcon_store ( struct fbcon *fbcon, struct fbcon_text_cell *cell, */ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos ) { - uint8_t glyph[fbcon->font->height]; + const uint8_t *glyph; size_t offset; size_t pixel_len; size_t skip_len; @@ -164,10 +159,10 @@ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int column; uint8_t bitmask; int transparent; - void *src; + const void *src; /* Get font character */ - fbcon->font->glyph ( cell->character, glyph ); + glyph = fbcon->font->glyph ( cell->character ); /* Calculate pixel geometry */ offset = ( fbcon->indent + @@ -204,7 +199,7 @@ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell, } else { continue; } - copy_to_user ( fbcon->start, offset, src, pixel_len ); + memcpy ( ( fbcon->start + offset ), src, pixel_len ); } /* Move to next row */ @@ -218,18 +213,16 @@ static void fbcon_draw ( struct fbcon *fbcon, struct fbcon_text_cell *cell, * @v fbcon Frame buffer console */ static void fbcon_redraw ( struct fbcon *fbcon ) { - struct fbcon_text_cell cell; - size_t offset = 0; + struct fbcon_text_cell *cell; unsigned int xpos; unsigned int ypos; /* Redraw characters */ + cell = fbcon_cell ( fbcon, 0, 0 ); for ( ypos = 0 ; ypos < fbcon->character.height ; ypos++ ) { for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) { - copy_from_user ( &cell, fbcon->text.start, offset, - sizeof ( cell ) ); - fbcon_draw ( fbcon, &cell, xpos, ypos ); - offset += sizeof ( cell ); + fbcon_draw ( fbcon, cell, xpos, ypos ); + cell++; } } } @@ -246,8 +239,8 @@ static void fbcon_scroll ( struct fbcon *fbcon ) { assert ( fbcon->ypos == fbcon->character.height ); /* Scroll up character array */ - row_len = ( fbcon->character.width * sizeof ( struct fbcon_text_cell )); - memmove ( fbcon->text.start, ( fbcon->text.start + row_len ), + row_len = ( fbcon->character.width * sizeof ( fbcon->text.cells[0] ) ); + memmove ( fbcon_cell ( fbcon, 0, 0 ), fbcon_cell ( fbcon, 0, 1 ), ( row_len * ( fbcon->character.height - 1 ) ) ); fbcon_clear ( fbcon, ( fbcon->character.height - 1 ) ); @@ -265,18 +258,19 @@ static void fbcon_scroll ( struct fbcon *fbcon ) { * @v show_cursor Show cursor */ static void fbcon_draw_cursor ( struct fbcon *fbcon, int show_cursor ) { - struct fbcon_text_cell cell; - size_t offset; + struct fbcon_text_cell *cell; + struct fbcon_text_cell cursor; - offset = ( ( ( fbcon->ypos * fbcon->character.width ) + fbcon->xpos ) * - sizeof ( cell ) ); - copy_from_user ( &cell, fbcon->text.start, offset, sizeof ( cell ) ); + cell = fbcon_cell ( fbcon, fbcon->xpos, fbcon->ypos ); if ( show_cursor ) { - cell.background = fbcon->foreground; - cell.foreground = ( ( fbcon->background == FBCON_TRANSPARENT ) ? - 0 : fbcon->background ); + cursor.background = fbcon->foreground; + cursor.foreground = + ( ( fbcon->background == FBCON_TRANSPARENT ) ? + 0 : fbcon->background ); + cursor.character = cell->character; + cell = &cursor; } - fbcon_draw ( fbcon, &cell, fbcon->xpos, fbcon->ypos ); + fbcon_draw ( fbcon, cell, fbcon->xpos, fbcon->ypos ); } /** @@ -439,7 +433,7 @@ static struct ansiesc_handler fbcon_ansiesc_handlers[] = { * @v character Character */ void fbcon_putchar ( struct fbcon *fbcon, int character ) { - struct fbcon_text_cell cell; + struct fbcon_text_cell *cell; /* Intercept ANSI escape sequences */ character = ansiesc_process ( &fbcon->ctx, character ); @@ -473,11 +467,11 @@ void fbcon_putchar ( struct fbcon *fbcon, int character ) { break; default: /* Print character at current cursor position */ - cell.foreground = ( fbcon->foreground | fbcon->bold ); - cell.background = fbcon->background; - cell.character = character; - fbcon_store ( fbcon, &cell, fbcon->xpos, fbcon->ypos ); - fbcon_draw ( fbcon, &cell, fbcon->xpos, fbcon->ypos ); + cell = fbcon_cell ( fbcon, fbcon->xpos, fbcon->ypos ); + cell->foreground = ( fbcon->foreground | fbcon->bold ); + cell->background = fbcon->background; + cell->character = character; + fbcon_draw ( fbcon, cell, fbcon->xpos, fbcon->ypos ); /* Advance cursor */ fbcon->xpos++; @@ -508,12 +502,9 @@ static int fbcon_picture_init ( struct fbcon *fbcon, struct fbcon_geometry *pixel = fbcon->pixel; struct fbcon_picture *picture = &fbcon->picture; size_t len; - size_t pixbuf_stride; size_t indent; - size_t pixbuf_indent; size_t offset; - size_t pixbuf_offset; - uint32_t rgb; + const uint32_t *rgb; uint32_t raw; unsigned int x; unsigned int y; @@ -534,13 +525,10 @@ static int fbcon_picture_init ( struct fbcon *fbcon, } /* Centre picture on console */ - pixbuf_stride = ( pixbuf->width * sizeof ( rgb ) ); xgap = ( ( ( int ) ( pixel->width - pixbuf->width ) ) / 2 ); ygap = ( ( ( int ) ( pixel->height - pixbuf->height ) ) / 2 ); indent = ( ( ( ( ygap >= 0 ) ? ygap : 0 ) * pixel->stride ) + ( ( ( xgap >= 0 ) ? xgap : 0 ) * pixel->len ) ); - pixbuf_indent = ( ( ( ( ygap < 0 ) ? -ygap : 0 ) * pixbuf_stride ) + - ( ( ( xgap < 0 ) ? -xgap : 0 ) * sizeof ( rgb ) ) ); width = pixbuf->width; if ( width > pixel->width ) width = pixel->width; @@ -555,15 +543,14 @@ static int fbcon_picture_init ( struct fbcon *fbcon, memset ( picture->start, 0, len ); for ( y = 0 ; y < height ; y++ ) { offset = ( indent + ( y * pixel->stride ) ); - pixbuf_offset = ( pixbuf_indent + ( y * pixbuf_stride ) ); + rgb = pixbuf_pixel ( pixbuf, ( ( xgap < 0 ) ? -xgap : 0 ), + ( ( ( ygap < 0 ) ? -ygap : 0 ) + y ) ); for ( x = 0 ; x < width ; x++ ) { - copy_from_user ( &rgb, pixbuf->data, pixbuf_offset, - sizeof ( rgb ) ); - raw = fbcon_colour ( fbcon, rgb ); - copy_to_user ( picture->start, offset, &raw, - pixel->len ); + raw = fbcon_colour ( fbcon, *rgb ); + memcpy ( ( picture->start + offset ), &raw, + pixel->len ); offset += pixel->len; - pixbuf_offset += sizeof ( rgb ); + rgb++; } } @@ -585,7 +572,7 @@ static int fbcon_picture_init ( struct fbcon *fbcon, * @v config Console configuration * @ret rc Return status code */ -int fbcon_init ( struct fbcon *fbcon, userptr_t start, +int fbcon_init ( struct fbcon *fbcon, void *start, struct fbcon_geometry *pixel, struct fbcon_colour_map *map, struct fbcon_font *font, @@ -674,10 +661,10 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, fbcon_set_default_background ( fbcon ); /* Allocate and initialise stored character array */ - fbcon->text.start = umalloc ( fbcon->character.width * + fbcon->text.cells = umalloc ( fbcon->character.width * fbcon->character.height * - sizeof ( struct fbcon_text_cell ) ); - if ( ! fbcon->text.start ) { + sizeof ( fbcon->text.cells[0] ) ); + if ( ! fbcon->text.cells ) { rc = -ENOMEM; goto err_text; } @@ -702,7 +689,7 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, ufree ( fbcon->picture.start ); err_picture: - ufree ( fbcon->text.start ); + ufree ( fbcon->text.cells ); err_text: err_margin: return rc; @@ -715,6 +702,6 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, */ void fbcon_fini ( struct fbcon *fbcon ) { - ufree ( fbcon->text.start ); + ufree ( fbcon->text.cells ); ufree ( fbcon->picture.start ); } diff --git a/src/include/ipxe/fbcon.h b/src/include/ipxe/fbcon.h index a4c7a9ab3..5233b4d0e 100644 --- a/src/include/ipxe/fbcon.h +++ b/src/include/ipxe/fbcon.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include /** Character width, in pixels */ @@ -38,9 +37,9 @@ struct fbcon_font { * Get character glyph * * @v character Unicode character - * @v glyph Character glyph to fill in + * @ret glyph Character glyph */ - void ( * glyph ) ( unsigned int character, uint8_t *glyph ); + const uint8_t * ( * glyph ) ( unsigned int character ); }; /** A frame buffer geometry @@ -100,19 +99,19 @@ struct fbcon_text_cell { /** A frame buffer text array */ struct fbcon_text { /** Stored text cells */ - userptr_t start; + struct fbcon_text_cell *cells; }; /** A frame buffer background picture */ struct fbcon_picture { /** Start address */ - userptr_t start; + void *start; }; /** A frame buffer console */ struct fbcon { /** Start address */ - userptr_t start; + void *start; /** Length of one complete displayed screen */ size_t len; /** Pixel geometry */ @@ -149,7 +148,7 @@ struct fbcon { int show_cursor; }; -extern int fbcon_init ( struct fbcon *fbcon, userptr_t start, +extern int fbcon_init ( struct fbcon *fbcon, void *start, struct fbcon_geometry *pixel, struct fbcon_colour_map *map, struct fbcon_font *font, diff --git a/src/include/ipxe/pixbuf.h b/src/include/ipxe/pixbuf.h index 615744812..6c70c1c05 100644 --- a/src/include/ipxe/pixbuf.h +++ b/src/include/ipxe/pixbuf.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include /** A pixel buffer */ struct pixel_buffer { @@ -22,7 +21,7 @@ struct pixel_buffer { /** Height */ unsigned int height; /** 32-bit (8:8:8:8) xRGB pixel data, in host-endian order */ - userptr_t data; + uint32_t *data; /** Total length */ size_t len; }; @@ -49,6 +48,22 @@ pixbuf_put ( struct pixel_buffer *pixbuf ) { ref_put ( &pixbuf->refcnt ); } +/** + * Get pixel + * + * @v pixbuf Pixel buffer + * @v x X position + * @v y Y position + * @ret pixel Pixel + */ +static inline __attribute__ (( always_inline )) uint32_t * +pixbuf_pixel ( struct pixel_buffer *pixbuf, unsigned int x, unsigned int y ) { + unsigned int index; + + index = ( ( y * pixbuf->width ) + x ); + return &pixbuf->data[index]; +} + extern struct pixel_buffer * alloc_pixbuf ( unsigned int width, unsigned int height ); diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index 09cfde4c2..9c5d7063d 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -42,6 +42,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -91,7 +92,7 @@ struct efifb { /** Font definition */ struct fbcon_font font; /** Character glyph cache */ - userptr_t glyphs; + uint8_t *glyphs; /** Dynamic characters in cache */ unsigned int dynamic[EFIFB_DYNAMIC]; /** Next dynamic character cache entry to evict */ @@ -117,14 +118,14 @@ static int efifb_draw ( unsigned int character, unsigned int index, unsigned int height; unsigned int x; unsigned int y; + uint8_t *glyph; uint8_t bitmask; - size_t offset; EFI_STATUS efirc; int rc; /* Clear existing glyph */ - offset = ( index * efifb.font.height ); - memset ( ( efifb.glyphs + offset ), 0, efifb.font.height ); + glyph = &efifb.glyphs[ index * efifb.font.height ]; + memset ( glyph, 0, efifb.font.height ); /* Get glyph */ blt = NULL; @@ -157,8 +158,7 @@ static int efifb_draw ( unsigned int character, unsigned int index, pixel++; } bitmask ^= toggle; - copy_to_user ( efifb.glyphs, offset++, &bitmask, - sizeof ( bitmask ) ); + *(glyph++) = bitmask; } /* Free glyph */ @@ -223,11 +223,10 @@ static unsigned int efifb_dynamic ( unsigned int character ) { * Get character glyph * * @v character Unicode character - * @v glyph Character glyph to fill in + * @ret glyph Character glyph to fill in */ -static void efifb_glyph ( unsigned int character, uint8_t *glyph ) { +static const uint8_t * efifb_glyph ( unsigned int character ) { unsigned int index; - size_t offset; /* Identify glyph */ if ( character < EFIFB_ASCII ) { @@ -241,9 +240,8 @@ static void efifb_glyph ( unsigned int character, uint8_t *glyph ) { index = efifb_dynamic ( character ); } - /* Copy cached glyph */ - offset = ( index * efifb.font.height ); - copy_from_user ( glyph, efifb.glyphs, offset, efifb.font.height ); + /* Return cached glyph */ + return &efifb.glyphs[ index * efifb.font.height ]; } /** -- cgit v1.2.3-55-g7522 From 7741756afc003ad042f0b13b30aed38e0ca9b94c Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Sun, 27 Apr 2025 17:30:49 +0100 Subject: [build] Prevent the use of reserved words in C23 GCC 15 defaults to C23, which reserves bool, true, and false as keywords. Avoid using these as parameter or variable names. Modified-by: Michael Brown Signed-off-by: Michael Brown --- src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c | 4 ++-- src/drivers/net/igbvf/igbvf_osdep.h | 7 ++----- src/interface/efi/efi_hii.c | 12 ++++++------ 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src/interface') diff --git a/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c b/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c index 30c1e644e..0b257ed22 100644 --- a/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c +++ b/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c @@ -32,7 +32,7 @@ mlx_status mlx_pci_gw_check_capability_id( IN mlx_utils *utils, IN mlx_uint8 cap_pointer, - OUT mlx_boolean *bool + OUT mlx_boolean *result ) { mlx_status status = MLX_SUCCESS; @@ -41,7 +41,7 @@ mlx_pci_gw_check_capability_id( status = mlx_pci_read(utils, MlxPciWidthUint8, offset, 1, &id); MLX_CHECK_STATUS(utils, status, read_err,"failed to read capability id"); - *bool = ( id == PCI_GW_CAPABILITY_ID ); + *result = ( id == PCI_GW_CAPABILITY_ID ); read_err: return status; } diff --git a/src/drivers/net/igbvf/igbvf_osdep.h b/src/drivers/net/igbvf/igbvf_osdep.h index 8ac179de0..dc65da6c1 100644 --- a/src/drivers/net/igbvf/igbvf_osdep.h +++ b/src/drivers/net/igbvf/igbvf_osdep.h @@ -35,8 +35,9 @@ FILE_LICENCE ( GPL2_ONLY ); #ifndef _IGBVF_OSDEP_H_ #define _IGBVF_OSDEP_H_ +#include + #define u8 unsigned char -#define bool boolean_t #define dma_addr_t unsigned long #define __le16 uint16_t #define __le32 uint32_t @@ -51,10 +52,6 @@ FILE_LICENCE ( GPL2_ONLY ); #define ETH_FCS_LEN 4 typedef int spinlock_t; -typedef enum { - false = 0, - true = 1 -} boolean_t; #define usec_delay(x) udelay(x) #define msec_delay(x) mdelay(x) diff --git a/src/interface/efi/efi_hii.c b/src/interface/efi/efi_hii.c index 506fc8869..66f58affe 100644 --- a/src/interface/efi/efi_hii.c +++ b/src/interface/efi/efi_hii.c @@ -147,13 +147,13 @@ void efi_ifr_end_op ( struct efi_ifr_builder *ifr ) { */ void efi_ifr_false_op ( struct efi_ifr_builder *ifr ) { size_t dispaddr = ifr->ops_len; - EFI_IFR_FALSE *false; + EFI_IFR_FALSE *op; /* Add opcode */ - false = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *false ) ); + op = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *op ) ); DBGC ( ifr, "IFR %p false\n", ifr ); - DBGC2_HDA ( ifr, dispaddr, false, sizeof ( *false ) ); + DBGC2_HDA ( ifr, dispaddr, op, sizeof ( *op ) ); } /** @@ -462,13 +462,13 @@ void efi_ifr_text_op ( struct efi_ifr_builder *ifr, unsigned int prompt_id, */ void efi_ifr_true_op ( struct efi_ifr_builder *ifr ) { size_t dispaddr = ifr->ops_len; - EFI_IFR_TRUE *true; + EFI_IFR_TRUE *op; /* Add opcode */ - true = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *true ) ); + op = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *op ) ); DBGC ( ifr, "IFR %p true\n", ifr ); - DBGC2_HDA ( ifr, dispaddr, true, sizeof ( *true ) ); + DBGC2_HDA ( ifr, dispaddr, op, sizeof ( *op ) ); } /** -- cgit v1.2.3-55-g7522 From 024439f3393e5c8335036efb898116b6500b3426 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 27 Apr 2025 23:28:51 +0100 Subject: [linux] Add missing return statement to linux_poll() Signed-off-by: Michael Brown --- src/interface/linux/linux_api.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/interface') diff --git a/src/interface/linux/linux_api.c b/src/interface/linux/linux_api.c index 21024ede1..459e39fd5 100644 --- a/src/interface/linux/linux_api.c +++ b/src/interface/linux/linux_api.c @@ -225,6 +225,7 @@ int __asmcall linux_poll ( struct pollfd *fds, unsigned int nfds, ret = poll ( fds, nfds, timeout ); if ( ret == -1 ) linux_errno = errno; + return ret; } /** -- cgit v1.2.3-55-g7522 From 7eaa2daf6f978c6aa16f66e03aa42dd3b5a190ae Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 28 Apr 2025 13:42:32 +0100 Subject: [reboot] Generalise warm reboot indicator to a flags bitmask Allow for the possibility of additional reboot types by extending the reboot() function to use a flags bitmask rather than a single flag. Signed-off-by: Michael Brown --- src/arch/riscv/interface/sbi/sbi_reboot.c | 6 ++++-- src/arch/x86/interface/pcbios/bios_reboot.c | 10 +++++----- src/core/null_reboot.c | 4 ++-- src/hci/commands/reboot_cmd.c | 5 ++++- src/include/ipxe/reboot.h | 6 ++++-- src/interface/efi/efi_reboot.c | 8 +++++--- 6 files changed, 24 insertions(+), 15 deletions(-) (limited to 'src/interface') diff --git a/src/arch/riscv/interface/sbi/sbi_reboot.c b/src/arch/riscv/interface/sbi/sbi_reboot.c index 64365b0d3..3529c9d38 100644 --- a/src/arch/riscv/interface/sbi/sbi_reboot.c +++ b/src/arch/riscv/interface/sbi/sbi_reboot.c @@ -37,13 +37,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Reboot system * - * @v warm Perform a warm reboot + * @v flags Reboot flags */ -static void sbi_reboot ( int warm ) { +static void sbi_reboot ( int flags ) { struct sbi_return ret; + int warm; int rc; /* Reboot system */ + warm = ( flags & REBOOT_WARM ); ret = sbi_ecall_2 ( SBI_SRST, SBI_SRST_SYSTEM_RESET, ( warm ? SBI_RESET_WARM : SBI_RESET_COLD ), 0 ); diff --git a/src/arch/x86/interface/pcbios/bios_reboot.c b/src/arch/x86/interface/pcbios/bios_reboot.c index 071173f19..463470245 100644 --- a/src/arch/x86/interface/pcbios/bios_reboot.c +++ b/src/arch/x86/interface/pcbios/bios_reboot.c @@ -38,14 +38,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Reboot system * - * @v warm Perform a warm reboot + * @v flags Reboot flags */ -static void bios_reboot ( int warm ) { - uint16_t flag; +static void bios_reboot ( int flags ) { + uint16_t type; /* Configure BIOS for cold/warm reboot */ - flag = ( warm ? BDA_REBOOT_WARM : 0 ); - put_real ( flag, BDA_SEG, BDA_REBOOT ); + type = ( ( flags & REBOOT_WARM ) ? BDA_REBOOT_WARM : 0 ); + put_real ( type, BDA_SEG, BDA_REBOOT ); /* Jump to system reset vector */ __asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : ); diff --git a/src/core/null_reboot.c b/src/core/null_reboot.c index 7be5612a3..63b6e127e 100644 --- a/src/core/null_reboot.c +++ b/src/core/null_reboot.c @@ -37,9 +37,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Reboot system * - * @v warm Perform a warm reboot + * @v flags Reboot flags */ -static void null_reboot ( int warm __unused ) { +static void null_reboot ( int flags __unused ) { printf ( "Cannot reboot; not implemented\n" ); while ( 1 ) {} diff --git a/src/hci/commands/reboot_cmd.c b/src/hci/commands/reboot_cmd.c index 45d54cc2c..f34468401 100644 --- a/src/hci/commands/reboot_cmd.c +++ b/src/hci/commands/reboot_cmd.c @@ -59,6 +59,7 @@ static struct command_descriptor reboot_cmd = */ static int reboot_exec ( int argc, char **argv ) { struct reboot_options opts; + int flags = 0; int rc; /* Parse options */ @@ -66,7 +67,9 @@ static int reboot_exec ( int argc, char **argv ) { return rc; /* Reboot system */ - reboot ( opts.warm ); + if ( opts.warm ) + flags |= REBOOT_WARM; + reboot ( flags ); return 0; } diff --git a/src/include/ipxe/reboot.h b/src/include/ipxe/reboot.h index 33606d9d5..2d8dadeca 100644 --- a/src/include/ipxe/reboot.h +++ b/src/include/ipxe/reboot.h @@ -51,9 +51,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Reboot system * - * @v warm Perform a warm reboot + * @v flags Reboot flags */ -void reboot ( int warm ); +void reboot ( int flags ); + +#define REBOOT_WARM 0x00000001 /**< Perform a warm reboot */ /** * Power off system diff --git a/src/interface/efi/efi_reboot.c b/src/interface/efi/efi_reboot.c index 35919221e..eb389a4b1 100644 --- a/src/interface/efi/efi_reboot.c +++ b/src/interface/efi/efi_reboot.c @@ -37,13 +37,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Reboot system * - * @v warm Perform a warm reboot + * @v flags Reboot flags */ -static void efi_reboot ( int warm ) { +static void efi_reboot ( int flags ) { EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + EFI_RESET_TYPE type; /* Use runtime services to reset system */ - rs->ResetSystem ( ( warm ? EfiResetWarm : EfiResetCold ), 0, 0, NULL ); + type = ( ( flags & REBOOT_WARM ) ? EfiResetWarm : EfiResetCold ); + rs->ResetSystem ( type, 0, 0, NULL ); } /** -- cgit v1.2.3-55-g7522 From 083e273bbc566e579c2003ab38feb0564066414c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 28 Apr 2025 14:01:17 +0100 Subject: [efi] Add ability to reboot to firmware setup menu Add the ability to reboot to the firmware setup menu (if supported) by setting the relevant value in the OsIndications variable. Signed-off-by: Michael Brown --- src/hci/commands/reboot_cmd.c | 6 ++++++ src/include/ipxe/reboot.h | 1 + src/interface/efi/efi_reboot.c | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) (limited to 'src/interface') diff --git a/src/hci/commands/reboot_cmd.c b/src/hci/commands/reboot_cmd.c index f34468401..5d4e151b8 100644 --- a/src/hci/commands/reboot_cmd.c +++ b/src/hci/commands/reboot_cmd.c @@ -38,12 +38,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); struct reboot_options { /** Perform a warm reboot */ int warm; + /** Reboot to firmware setup */ + int setup; }; /** "reboot" option list */ static struct option_descriptor reboot_opts[] = { OPTION_DESC ( "warm", 'w', no_argument, struct reboot_options, warm, parse_flag ), + OPTION_DESC ( "setup", 's', no_argument, + struct reboot_options, setup, parse_flag ), }; /** "reboot" command descriptor */ @@ -69,6 +73,8 @@ static int reboot_exec ( int argc, char **argv ) { /* Reboot system */ if ( opts.warm ) flags |= REBOOT_WARM; + if ( opts.setup ) + flags |= REBOOT_SETUP; reboot ( flags ); return 0; diff --git a/src/include/ipxe/reboot.h b/src/include/ipxe/reboot.h index 2d8dadeca..cfd5b546d 100644 --- a/src/include/ipxe/reboot.h +++ b/src/include/ipxe/reboot.h @@ -56,6 +56,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); void reboot ( int flags ); #define REBOOT_WARM 0x00000001 /**< Perform a warm reboot */ +#define REBOOT_SETUP 0x00000002 /**< Reboot to firmware setup */ /** * Power off system diff --git a/src/interface/efi/efi_reboot.c b/src/interface/efi/efi_reboot.c index eb389a4b1..7ed9f5c84 100644 --- a/src/interface/efi/efi_reboot.c +++ b/src/interface/efi/efi_reboot.c @@ -31,7 +31,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include +#include #include /** @@ -41,7 +43,28 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ static void efi_reboot ( int flags ) { EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + static CHAR16 wname[] = EFI_OS_INDICATIONS_VARIABLE_NAME; + UINT64 osind; + UINT32 attrs; EFI_RESET_TYPE type; + EFI_STATUS efirc; + int rc; + + /* Request boot to firmware setup, if applicable */ + if ( flags & REBOOT_SETUP ) { + osind = EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + attrs = ( EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS | + EFI_VARIABLE_NON_VOLATILE ); + if ( ( efirc = rs->SetVariable ( wname, &efi_global_variable, + attrs, sizeof ( osind ), + &osind ) ) != 0 ) { + rc = -EEFI ( efirc ); + DBGC ( efi_systab, "EFI could not set %ls: %s\n", + wname, strerror ( rc ) ); + /* Continue to reboot anyway */ + } + } /* Use runtime services to reset system */ type = ( ( flags & REBOOT_WARM ) ? EfiResetWarm : EfiResetCold ); -- cgit v1.2.3-55-g7522 From 837b77293beafa15f8a125a484a0d17453b021f8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 29 Apr 2025 09:16:41 +0100 Subject: [xferbuf] Simplify and generalise data transfer buffers Since all data transfer buffer contents are now accessible via direct pointer dereferences, remove the unnecessary abstractions for read and write operations and create two new data transfer buffer types: a fixed-size buffer, and a void buffer that records its size but can never receive non-zero lengths of data. These replace the custom data buffer types currently implemented for EFI PXE TFTP downloads and for block device translations. A new operation xferbuf_detach() is required to take ownership of the data accumulated in the data transfer buffer, since we no longer rely on the existence of an independently owned external data pointer for data transfer buffers allocated via umalloc(). Signed-off-by: Michael Brown --- src/core/blocktrans.c | 90 +----------------------------- src/core/downloader.c | 16 ++++-- src/core/xferbuf.c | 124 ++++++++++++++++++++++-------------------- src/include/ipxe/blocktrans.h | 2 - src/include/ipxe/xferbuf.h | 67 +++++++++++++---------- src/interface/efi/efi_pxe.c | 47 +--------------- src/net/peermux.c | 7 +-- 7 files changed, 119 insertions(+), 234 deletions(-) (limited to 'src/interface') diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index ba70462f2..362721747 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -38,91 +38,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -/** - * Reallocate block device translator data buffer - * - * @v xferbuf Data transfer buffer - * @v len New length (or zero to free buffer) - * @ret rc Return status code - */ -static int blktrans_xferbuf_realloc ( struct xfer_buffer *xferbuf, - size_t len ) { - struct block_translator *blktrans = - container_of ( xferbuf, struct block_translator, xferbuf ); - - /* Record length, if applicable */ - if ( blktrans->buffer ) { - - /* We have a (non-reallocatable) data buffer */ - return -ENOTSUP; - - } else { - - /* Record length (for block device capacity) */ - xferbuf->len = len; - return 0; - } -} - -/** - * Write data to block device translator data buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to copy - * @v len Length of data - */ -static void blktrans_xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset, - const void *data, size_t len ) { - struct block_translator *blktrans = - container_of ( xferbuf, struct block_translator, xferbuf ); - - /* Write data to buffer, if applicable */ - if ( blktrans->buffer ) { - - /* Write data to buffer */ - memcpy ( ( blktrans->buffer + offset ), data, len ); - - } else { - - /* Sanity check */ - assert ( len == 0 ); - } -} - -/** - * Read data from block device translator data buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to read - * @v len Length of data - */ -static void blktrans_xferbuf_read ( struct xfer_buffer *xferbuf, size_t offset, - void *data, size_t len ) { - struct block_translator *blktrans = - container_of ( xferbuf, struct block_translator, xferbuf ); - - /* Read data from buffer, if applicable */ - if ( blktrans->buffer ) { - - /* Read data from buffer */ - memcpy ( data, ( blktrans->buffer + offset ), len ); - - } else { - - /* Sanity check */ - assert ( len == 0 ); - } -} - -/** Block device translator data transfer buffer operations */ -static struct xfer_buffer_operations blktrans_xferbuf_operations = { - .realloc = blktrans_xferbuf_realloc, - .write = blktrans_xferbuf_write, - .read = blktrans_xferbuf_read, -}; - /** * Close block device translator * @@ -233,11 +148,10 @@ int block_translate ( struct interface *block, void *buffer, size_t size ) { ref_init ( &blktrans->refcnt, NULL ); intf_init ( &blktrans->block, &blktrans_block_desc, &blktrans->refcnt ); intf_init ( &blktrans->xfer, &blktrans_xfer_desc, &blktrans->refcnt ); - blktrans->xferbuf.op = &blktrans_xferbuf_operations; - blktrans->buffer = buffer; if ( buffer ) { - blktrans->xferbuf.len = size; + xferbuf_fixed_init ( &blktrans->xferbuf, buffer, size ); } else { + xferbuf_void_init ( &blktrans->xferbuf ); blktrans->blksize = size; } diff --git a/src/core/downloader.c b/src/core/downloader.c index 33737bfac..449761836 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -67,6 +67,7 @@ static void downloader_free ( struct refcnt *refcnt ) { struct downloader *downloader = container_of ( refcnt, struct downloader, refcnt ); + xferbuf_free ( &downloader->buffer ); image_put ( downloader->image ); free ( downloader ); } @@ -78,18 +79,21 @@ static void downloader_free ( struct refcnt *refcnt ) { * @v rc Reason for termination */ static void downloader_finished ( struct downloader *downloader, int rc ) { + struct xfer_buffer *buffer = &downloader->buffer; + struct image *image = downloader->image; /* Log download status */ if ( rc == 0 ) { - syslog ( LOG_NOTICE, "Downloaded \"%s\"\n", - downloader->image->name ); + syslog ( LOG_NOTICE, "Downloaded \"%s\"\n", image->name ); } else { syslog ( LOG_ERR, "Download of \"%s\" failed: %s\n", - downloader->image->name, strerror ( rc ) ); + image->name, strerror ( rc ) ); } - /* Update image length */ - downloader->image->len = downloader->buffer.len; + /* Transfer ownership from data transfer buffer to image */ + image->data = buffer->data; + image->len = buffer->len; + xferbuf_detach ( buffer ); /* Shut down interfaces */ intf_shutdown ( &downloader->xfer, rc ); @@ -269,7 +273,7 @@ int create_downloader ( struct interface *job, struct image *image ) { intf_init ( &downloader->xfer, &downloader_xfer_desc, &downloader->refcnt ); downloader->image = image_get ( image ); - xferbuf_umalloc_init ( &downloader->buffer, &image->data ); + xferbuf_umalloc_init ( &downloader->buffer ); /* Instantiate child objects and attach to our interfaces */ if ( ( rc = xfer_open_uri ( &downloader->xfer, image->uri ) ) != 0 ) diff --git a/src/core/xferbuf.c b/src/core/xferbuf.c index 1c08f8bc3..d93526577 100644 --- a/src/core/xferbuf.c +++ b/src/core/xferbuf.c @@ -50,6 +50,21 @@ static struct profiler xferbuf_write_profiler __profiler = static struct profiler xferbuf_read_profiler __profiler = { .name = "xferbuf.read" }; +/** + * Detach data from data transfer buffer + * + * @v xferbuf Data transfer buffer + * + * The caller assumes responsibility for eventually freeing the data + * previously owned by the data transfer buffer. + */ +void xferbuf_detach ( struct xfer_buffer *xferbuf ) { + + xferbuf->data = NULL; + xferbuf->len = 0; + xferbuf->pos = 0; +} + /** * Free data transfer buffer * @@ -58,8 +73,7 @@ static struct profiler xferbuf_read_profiler __profiler = void xferbuf_free ( struct xfer_buffer *xferbuf ) { xferbuf->op->realloc ( xferbuf, 0 ); - xferbuf->len = 0; - xferbuf->pos = 0; + xferbuf_detach ( xferbuf ); } /** @@ -109,9 +123,13 @@ int xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset, if ( ( rc = xferbuf_ensure_size ( xferbuf, max_len ) ) != 0 ) return rc; + /* Check that buffer is non-void */ + if ( len && ( ! xferbuf->data ) ) + return -ENOTTY; + /* Copy data to buffer */ profile_start ( &xferbuf_write_profiler ); - xferbuf->op->write ( xferbuf, offset, data, len ); + memcpy ( ( xferbuf->data + offset ), data, len ); profile_stop ( &xferbuf_write_profiler ); return 0; @@ -133,9 +151,13 @@ int xferbuf_read ( struct xfer_buffer *xferbuf, size_t offset, ( len > ( xferbuf->len - offset ) ) ) return -ENOENT; + /* Check that buffer is non-void */ + if ( len && ( ! xferbuf->data ) ) + return -ENOTTY; + /* Copy data from buffer */ profile_start ( &xferbuf_read_profiler ); - xferbuf->op->read ( xferbuf, offset, data, len ); + memcpy ( data, ( xferbuf->data + offset ), len ); profile_stop ( &xferbuf_read_profiler ); return 0; @@ -178,7 +200,7 @@ int xferbuf_deliver ( struct xfer_buffer *xferbuf, struct io_buffer *iobuf, } /** - * Reallocate malloc()-based data buffer + * Reallocate malloc()-based data transfer buffer * * @v xferbuf Data transfer buffer * @v len New length (or zero to free buffer) @@ -194,94 +216,76 @@ static int xferbuf_malloc_realloc ( struct xfer_buffer *xferbuf, size_t len ) { return 0; } -/** - * Write data to malloc()-based data buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to copy - * @v len Length of data - */ -static void xferbuf_malloc_write ( struct xfer_buffer *xferbuf, size_t offset, - const void *data, size_t len ) { - - memcpy ( ( xferbuf->data + offset ), data, len ); -} - -/** - * Read data from malloc()-based data buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to read - * @v len Length of data - */ -static void xferbuf_malloc_read ( struct xfer_buffer *xferbuf, size_t offset, - void *data, size_t len ) { - - memcpy ( data, ( xferbuf->data + offset ), len ); -} - /** malloc()-based data buffer operations */ struct xfer_buffer_operations xferbuf_malloc_operations = { .realloc = xferbuf_malloc_realloc, - .write = xferbuf_malloc_write, - .read = xferbuf_malloc_read, }; /** - * Reallocate umalloc()-based data buffer + * Reallocate umalloc()-based data transfer buffer * * @v xferbuf Data transfer buffer * @v len New length (or zero to free buffer) * @ret rc Return status code */ static int xferbuf_umalloc_realloc ( struct xfer_buffer *xferbuf, size_t len ) { - void **udata = xferbuf->data; void *new_udata; - new_udata = urealloc ( *udata, len ); + new_udata = urealloc ( xferbuf->data, len ); if ( ! new_udata ) return -ENOSPC; - *udata = new_udata; + xferbuf->data = new_udata; return 0; } +/** umalloc()-based data buffer operations */ +struct xfer_buffer_operations xferbuf_umalloc_operations = { + .realloc = xferbuf_umalloc_realloc, +}; + /** - * Write data to umalloc()-based data buffer + * Reallocate fixed-size data transfer buffer * * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to copy - * @v len Length of data + * @v len New length (or zero to free buffer) + * @ret rc Return status code */ -static void xferbuf_umalloc_write ( struct xfer_buffer *xferbuf, size_t offset, - const void *data, size_t len ) { - void **udata = xferbuf->data; +static int xferbuf_fixed_realloc ( struct xfer_buffer *xferbuf, size_t len ) { + + /* Refuse to allocate extra space */ + if ( len > xferbuf->len ) { + /* Note that EFI relies upon this error mapping to + * EFI_BUFFER_TOO_SMALL. + */ + return -ERANGE; + } - memcpy ( ( *udata + offset ), data, len ); + return 0; } +/** Fixed-size data buffer operations */ +struct xfer_buffer_operations xferbuf_fixed_operations = { + .realloc = xferbuf_fixed_realloc, +}; + /** - * Read data from umalloc()-based data buffer + * Reallocate void data transfer buffer * * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to read - * @v len Length of data + * @v len New length (or zero to free buffer) + * @ret rc Return status code */ -static void xferbuf_umalloc_read ( struct xfer_buffer *xferbuf, size_t offset, - void *data, size_t len ) { - void **udata = xferbuf->data; +static int xferbuf_void_realloc ( struct xfer_buffer *xferbuf, + size_t len __unused ) { - memcpy ( data, ( *udata + offset ), len ); + /* Succeed without ever allocating data */ + assert ( xferbuf->data == NULL ); + return 0; } -/** umalloc()-based data buffer operations */ -struct xfer_buffer_operations xferbuf_umalloc_operations = { - .realloc = xferbuf_umalloc_realloc, - .write = xferbuf_umalloc_write, - .read = xferbuf_umalloc_read, +/** Void data buffer operations */ +struct xfer_buffer_operations xferbuf_void_operations = { + .realloc = xferbuf_void_realloc, }; /** diff --git a/src/include/ipxe/blocktrans.h b/src/include/ipxe/blocktrans.h index 1167a256e..1eb388854 100644 --- a/src/include/ipxe/blocktrans.h +++ b/src/include/ipxe/blocktrans.h @@ -25,8 +25,6 @@ struct block_translator { /** Data transfer buffer */ struct xfer_buffer xferbuf; - /** Data buffer */ - void *buffer; /** Block size */ size_t blksize; }; diff --git a/src/include/ipxe/xferbuf.h b/src/include/ipxe/xferbuf.h index 04635999d..04fcf2286 100644 --- a/src/include/ipxe/xferbuf.h +++ b/src/include/ipxe/xferbuf.h @@ -35,41 +35,19 @@ struct xfer_buffer_operations { * @ret rc Return status code */ int ( * realloc ) ( struct xfer_buffer *xferbuf, size_t len ); - /** Write data to buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to write - * @v len Length of data - * - * This call is simply a wrapper for the appropriate - * memcpy()-like operation: the caller is responsible for - * ensuring that the write does not exceed the buffer length. - */ - void ( * write ) ( struct xfer_buffer *xferbuf, size_t offset, - const void *data, size_t len ); - /** Read data from buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to read - * @v len Length of data - * - * This call is simply a wrapper for the appropriate - * memcpy()-like operation: the caller is responsible for - * ensuring that the read does not exceed the buffer length. - */ - void ( * read ) ( struct xfer_buffer *xferbuf, size_t offset, - void *data, size_t len ); }; extern struct xfer_buffer_operations xferbuf_malloc_operations; extern struct xfer_buffer_operations xferbuf_umalloc_operations; +extern struct xfer_buffer_operations xferbuf_fixed_operations; +extern struct xfer_buffer_operations xferbuf_void_operations; /** * Initialise malloc()-based data transfer buffer * * @v xferbuf Data transfer buffer + * + * Data will be automatically allocated using malloc(). */ static inline __attribute__ (( always_inline )) void xferbuf_malloc_init ( struct xfer_buffer *xferbuf ) { @@ -80,14 +58,45 @@ xferbuf_malloc_init ( struct xfer_buffer *xferbuf ) { * Initialise umalloc()-based data transfer buffer * * @v xferbuf Data transfer buffer - * @v data User pointer + * + * Data will be automatically allocated using umalloc() (and may + * therefore alter the system memory map). */ static inline __attribute__ (( always_inline )) void -xferbuf_umalloc_init ( struct xfer_buffer *xferbuf, void **data ) { - xferbuf->data = data; +xferbuf_umalloc_init ( struct xfer_buffer *xferbuf ) { xferbuf->op = &xferbuf_umalloc_operations; } +/** + * Initialise fixed-size data transfer buffer + * + * @v xferbuf Data transfer buffer + * @v data Data buffer + * @v len Length of data buffer + * + * Data will be never be automatically allocated. + */ +static inline __attribute__ (( always_inline )) void +xferbuf_fixed_init ( struct xfer_buffer *xferbuf, void *data, size_t len ) { + xferbuf->data = data; + xferbuf->len = len; + xferbuf->op = &xferbuf_fixed_operations; +} + +/** + * Initialise void data transfer buffer + * + * @v xferbuf Data transfer buffer + * + * No data will be allocated, but the length will be recorded. This + * can be used to capture xfer_seek() results. + */ +static inline __attribute__ (( always_inline )) void +xferbuf_void_init ( struct xfer_buffer *xferbuf ) { + xferbuf->op = &xferbuf_void_operations; +} + +extern void xferbuf_detach ( struct xfer_buffer *xferbuf ); extern void xferbuf_free ( struct xfer_buffer *xferbuf ); extern int xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset, const void *data, size_t len ); diff --git a/src/interface/efi/efi_pxe.c b/src/interface/efi/efi_pxe.c index 732ccdcdf..4ba057019 100644 --- a/src/interface/efi/efi_pxe.c +++ b/src/interface/efi/efi_pxe.c @@ -303,48 +303,6 @@ static int efi_pxe_ip_filter ( struct efi_pxe *pxe, EFI_IP_ADDRESS *ip ) { return 0; } -/****************************************************************************** - * - * Data transfer buffer - * - ****************************************************************************** - */ - -/** - * Reallocate PXE data transfer buffer - * - * @v xferbuf Data transfer buffer - * @v len New length (or zero to free buffer) - * @ret rc Return status code - */ -static int efi_pxe_buf_realloc ( struct xfer_buffer *xferbuf __unused, - size_t len __unused ) { - - /* Can never reallocate: return EFI_BUFFER_TOO_SMALL */ - return -ERANGE; -} - -/** - * Write data to PXE data transfer buffer - * - * @v xferbuf Data transfer buffer - * @v offset Starting offset - * @v data Data to copy - * @v len Length of data - */ -static void efi_pxe_buf_write ( struct xfer_buffer *xferbuf, size_t offset, - const void *data, size_t len ) { - - /* Copy data to buffer */ - memcpy ( ( xferbuf->data + offset ), data, len ); -} - -/** PXE data transfer buffer operations */ -static struct xfer_buffer_operations efi_pxe_buf_operations = { - .realloc = efi_pxe_buf_realloc, - .write = efi_pxe_buf_write, -}; - /****************************************************************************** * * (M)TFTP download interface @@ -966,8 +924,7 @@ efi_pxe_mtftp ( EFI_PXE_BASE_CODE_PROTOCOL *base, pxe->blksize = ( ( callback && blksize ) ? *blksize : -1UL ); /* Initialise data transfer buffer */ - pxe->buf.data = data; - pxe->buf.len = *len; + xferbuf_fixed_init ( &pxe->buf, data, *len ); /* Open download */ if ( ( rc = efi_pxe_tftp_open ( pxe, ip, @@ -987,6 +944,7 @@ efi_pxe_mtftp ( EFI_PXE_BASE_CODE_PROTOCOL *base, err_download: efi_pxe_tftp_close ( pxe, rc ); err_open: + xferbuf_fixed_init ( &pxe->buf, NULL, 0 ); efi_snp_release(); err_opcode: return EFIRC ( rc ); @@ -1611,7 +1569,6 @@ int efi_pxe_install ( EFI_HANDLE handle, struct net_device *netdev ) { pxe->base.Mode = &pxe->mode; memcpy ( &pxe->apple, &efi_apple_net_boot_protocol, sizeof ( pxe->apple ) ); - pxe->buf.op = &efi_pxe_buf_operations; intf_init ( &pxe->tftp, &efi_pxe_tftp_desc, &pxe->refcnt ); intf_init ( &pxe->udp, &efi_pxe_udp_desc, &pxe->refcnt ); INIT_LIST_HEAD ( &pxe->queue ); diff --git a/src/net/peermux.c b/src/net/peermux.c index a391ed373..431ca76e0 100644 --- a/src/net/peermux.c +++ b/src/net/peermux.c @@ -129,6 +129,7 @@ static int peermux_info_deliver ( struct peerdist_multiplexer *peermux, * @v rc Reason for close */ static void peermux_info_close ( struct peerdist_multiplexer *peermux, int rc ){ + struct xfer_buffer *buffer = &peermux->buffer; struct peerdist_info *info = &peermux->cache.info; size_t len; @@ -145,8 +146,7 @@ static void peermux_info_close ( struct peerdist_multiplexer *peermux, int rc ){ intf_shutdown ( &peermux->info, rc ); /* Parse content information */ - if ( ( rc = peerdist_info ( info->raw.data, peermux->buffer.len, - info ) ) != 0 ) { + if ( ( rc = peerdist_info ( buffer->data, buffer->len, info ) ) != 0 ) { DBGC ( peermux, "PEERMUX %p could not parse content info: %s\n", peermux, strerror ( rc ) ); goto err; @@ -422,8 +422,7 @@ int peermux_filter ( struct interface *xfer, struct interface *info, intf_init ( &peermux->xfer, &peermux_xfer_desc, &peermux->refcnt ); intf_init ( &peermux->info, &peermux_info_desc, &peermux->refcnt ); peermux->uri = uri_get ( uri ); - xferbuf_umalloc_init ( &peermux->buffer, - &peermux->cache.info.raw.data ); + xferbuf_umalloc_init ( &peermux->buffer ); process_init_stopped ( &peermux->process, &peermux_process_desc, &peermux->refcnt ); INIT_LIST_HEAD ( &peermux->busy ); -- cgit v1.2.3-55-g7522 From 9962c0a58fdecc6fe7c8026c7b71c8b79cad5bf3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 29 Apr 2025 13:42:42 +0100 Subject: [bofm] Remove userptr_t from BOFM table parsing and updating Signed-off-by: Michael Brown --- src/include/ipxe/bofm.h | 2 +- src/interface/bofm/bofm.c | 94 ++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 51 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/bofm.h b/src/include/ipxe/bofm.h index 816effd4d..a09c770d2 100644 --- a/src/include/ipxe/bofm.h +++ b/src/include/ipxe/bofm.h @@ -348,7 +348,7 @@ bofm_init ( struct bofm_device *bofm, struct pci_device *pci, extern int bofm_register ( struct bofm_device *bofm ); extern void bofm_unregister ( struct bofm_device *bofm ); extern int bofm_find_driver ( struct pci_device *pci ); -extern int bofm ( userptr_t bofmtab, struct pci_device *pci ); +extern int bofm ( void *bofmtab, struct pci_device *pci ); extern void bofm_test ( struct pci_device *pci ); #endif /* _IPXE_BOFM_H */ diff --git a/src/interface/bofm/bofm.c b/src/interface/bofm/bofm.c index 54039193a..b5438e07c 100644 --- a/src/interface/bofm/bofm.c +++ b/src/interface/bofm/bofm.c @@ -26,7 +26,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -150,27 +149,25 @@ static void bofm_remove ( struct pci_device *pci ) { /** * Locate BOFM table section * - * @v bofmtab BOFM table - * @v len Length of BOFM table + * @v bofmhdr BOFM table header * @v magic Section magic - * @v bofmsec BOFM section header to fill in - * @ret offset Offset to section, or 0 if not found + * @ret bofmsec BOFM section header, or NULL if not found */ -static size_t bofm_locate_section ( userptr_t bofmtab, size_t len, - uint32_t magic, - struct bofm_section_header *bofmsec ) { - size_t offset = sizeof ( struct bofm_global_header ); - - while ( offset < len ) { - copy_from_user ( bofmsec, bofmtab, offset, - sizeof ( *bofmsec ) ); +static struct bofm_section_header * +bofm_locate_section ( struct bofm_global_header *bofmhdr, uint32_t magic ) { + struct bofm_section_header *bofmsec; + size_t offset; + + /* Scan for section */ + for ( offset = sizeof ( *bofmhdr ) ; offset < bofmhdr->length ; + offset += ( sizeof ( *bofmsec ) + bofmsec->length ) ) { + bofmsec = ( ( ( void * ) bofmhdr ) + offset ); if ( bofmsec->magic == magic ) - return offset; + return bofmsec; if ( bofmsec->magic == BOFM_DONE_MAGIC ) break; - offset += ( sizeof ( *bofmsec ) + bofmsec->length ); } - return 0; + return NULL; } /** @@ -235,32 +232,31 @@ static int bofm_en ( struct bofm_device *bofm, struct bofm_en *en ) { * @v pci PCI device * @ret bofmrc BOFM return status */ -int bofm ( userptr_t bofmtab, struct pci_device *pci ) { - struct bofm_global_header bofmhdr; - struct bofm_section_header bofmsec; - struct bofm_en en; +int bofm ( void *bofmtab, struct pci_device *pci ) { + struct bofm_global_header *bofmhdr; + struct bofm_section_header *bofmsec; + struct bofm_en *en; struct bofm_device *bofm; - size_t en_region_offset; - size_t en_offset; + size_t offset; int skip; int rc; int bofmrc; /* Read BOFM structure */ - copy_from_user ( &bofmhdr, bofmtab, 0, sizeof ( bofmhdr ) ); - if ( bofmhdr.magic != BOFM_IOAA_MAGIC ) { + bofmhdr = bofmtab; + if ( bofmhdr->magic != BOFM_IOAA_MAGIC ) { DBG ( "BOFM: invalid table signature " BOFM_MAGIC_FMT "\n", - BOFM_MAGIC_ARGS ( bofmhdr.magic ) ); + BOFM_MAGIC_ARGS ( bofmhdr->magic ) ); bofmrc = BOFM_ERR_INVALID_ACTION; goto err_bad_signature; } DBG ( "BOFM: " BOFM_MAGIC_FMT " (profile \"%s\")\n", - BOFM_MAGIC_ARGS ( bofmhdr.action ), bofmhdr.profile ); + BOFM_MAGIC_ARGS ( bofmhdr->action ), bofmhdr->profile ); /* Determine whether or not we should skip normal POST * initialisation. */ - switch ( bofmhdr.action ) { + switch ( bofmhdr->action ) { case BOFM_ACTION_UPDT: case BOFM_ACTION_DFLT: case BOFM_ACTION_HVST: @@ -272,7 +268,7 @@ int bofm ( userptr_t bofmtab, struct pci_device *pci ) { break; default: DBG ( "BOFM: invalid action " BOFM_MAGIC_FMT "\n", - BOFM_MAGIC_ARGS ( bofmhdr.action ) ); + BOFM_MAGIC_ARGS ( bofmhdr->action ) ); bofmrc = BOFM_ERR_INVALID_ACTION; goto err_bad_action; } @@ -291,46 +287,44 @@ int bofm ( userptr_t bofmtab, struct pci_device *pci ) { } /* Locate EN section, if present */ - en_region_offset = bofm_locate_section ( bofmtab, bofmhdr.length, - BOFM_EN_MAGIC, &bofmsec ); - if ( ! en_region_offset ) { + bofmsec = bofm_locate_section ( bofmhdr, BOFM_EN_MAGIC ); + if ( ! bofmsec ) { DBG ( "BOFM: No EN section found\n" ); bofmrc = ( BOFM_SUCCESS | skip ); goto err_no_en_section; } /* Iterate through EN entries */ - for ( en_offset = ( en_region_offset + sizeof ( bofmsec ) ) ; - en_offset < ( en_region_offset + sizeof ( bofmsec ) + - bofmsec.length ) ; en_offset += sizeof ( en ) ) { - copy_from_user ( &en, bofmtab, en_offset, sizeof ( en ) ); + for ( offset = sizeof ( *bofmsec ) ; offset < bofmsec->length ; + offset += sizeof ( *en ) ) { + en = ( ( ( void * ) bofmsec ) + offset ); DBG2 ( "BOFM: EN entry found:\n" ); - DBG2_HDA ( en_offset, &en, sizeof ( en ) ); - if ( ( en.options & BOFM_EN_MAP_MASK ) != BOFM_EN_MAP_PFA ) { + DBG2_HDA ( offset, en, sizeof ( *en ) ); + if ( ( en->options & BOFM_EN_MAP_MASK ) != BOFM_EN_MAP_PFA ) { DBG ( "BOFM: slot %d port %d has no PCI mapping\n", - en.slot, ( en.port + 1 ) ); + en->slot, ( en->port + 1 ) ); continue; } DBG ( "BOFM: slot %d port %d%s is " PCI_FMT " mport %d\n", - en.slot, ( en.port + 1 ), - ( ( en.slot || en.port ) ? "" : "(?)" ), 0, - PCI_BUS ( en.busdevfn ), PCI_SLOT ( en.busdevfn ), - PCI_FUNC ( en.busdevfn ), en.mport ); - bofm = bofm_find_busdevfn ( en.busdevfn ); + en->slot, ( en->port + 1 ), + ( ( en->slot || en->port ) ? "" : "(?)" ), 0, + PCI_BUS ( en->busdevfn ), PCI_SLOT ( en->busdevfn ), + PCI_FUNC ( en->busdevfn ), en->mport ); + bofm = bofm_find_busdevfn ( en->busdevfn ); if ( ! bofm ) { DBG ( "BOFM: " PCI_FMT " mport %d ignored\n", 0, - PCI_BUS ( en.busdevfn ), PCI_SLOT ( en.busdevfn ), - PCI_FUNC ( en.busdevfn ), en.mport ); + PCI_BUS ( en->busdevfn ), + PCI_SLOT ( en->busdevfn ), + PCI_FUNC ( en->busdevfn ), en->mport ); continue; } - if ( ( rc = bofm_en ( bofm, &en ) ) == 0 ) { - en.options |= BOFM_EN_CSM_SUCCESS; + if ( ( rc = bofm_en ( bofm, en ) ) == 0 ) { + en->options |= BOFM_EN_CSM_SUCCESS; } else { - en.options |= BOFM_EN_CSM_FAILED; + en->options |= BOFM_EN_CSM_FAILED; } DBG2 ( "BOFM: EN entry after processing:\n" ); - DBG2_HDA ( en_offset, &en, sizeof ( en ) ); - copy_to_user ( bofmtab, en_offset, &en, sizeof ( en ) ); + DBG2_HDA ( offset, en, sizeof ( *en ) ); } bofmrc = ( BOFM_SUCCESS | skip ); -- cgit v1.2.3-55-g7522 From b6f9e4bab082c3b7a9b587ef64109069fba59baa Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 15:18:34 +0100 Subject: [uaccess] Remove redundant copy_from_user() and copy_to_user() Remove the now-redundant copy_from_user() and copy_to_user() wrapper functions. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 1 + src/arch/x86/drivers/xen/hvm.c | 1 + src/arch/x86/image/elfboot.c | 1 + src/arch/x86/image/initrd.c | 1 + src/arch/x86/image/multiboot.c | 1 + src/arch/x86/image/nbi.c | 1 + src/arch/x86/image/pxe_image.c | 1 + src/arch/x86/image/ucode.c | 1 + src/arch/x86/include/realmode.h | 1 + src/arch/x86/interface/pcbios/acpipwr.c | 1 + src/arch/x86/interface/pcbios/bios_cachedhcp.c | 1 + src/arch/x86/interface/pcbios/bios_reboot.c | 1 + src/arch/x86/interface/pcbios/biosint.c | 1 + src/arch/x86/interface/pcbios/hidemem.c | 1 + src/arch/x86/interface/pcbios/int13.c | 1 + src/arch/x86/interface/pcbios/memmap.c | 1 + src/arch/x86/interface/pcbios/memtop_umalloc.c | 1 + src/arch/x86/interface/pcbios/rsdp.c | 1 + src/core/blocktrans.c | 1 + src/core/cachedhcp.c | 1 + src/core/downloader.c | 1 + src/core/pixbuf.c | 1 + src/core/sanboot.c | 1 + src/drivers/bus/devtree.c | 1 + src/drivers/bus/ecam.c | 1 + src/drivers/bus/pci_settings.c | 1 + src/drivers/bus/usb_settings.c | 1 + src/drivers/infiniband/flexboot_nodnic.c | 1 + src/drivers/infiniband/linda.c | 1 + .../mlx_utils_flexboot/src/mlx_memory_priv.c | 1 + src/drivers/infiniband/qib7322.c | 1 + src/drivers/linux/slirp.c | 1 + src/drivers/net/ath/ath.h | 1 + src/drivers/net/ath/ath5k/ath5k.h | 1 + src/drivers/net/b44.c | 1 + src/drivers/net/bnxt/bnxt.c | 1 + src/drivers/net/eepro100.c | 1 + src/drivers/net/etherfabric.c | 1 + src/drivers/net/marvell/atl2_hw.c | 1 + src/drivers/net/marvell/atl_hw.c | 1 + src/drivers/net/myri10ge.c | 2 +- src/drivers/net/netvsc.c | 1 + src/drivers/net/rtl818x/rtl818x.c | 1 + src/drivers/net/sfc/efx_hunt.c | 1 + src/drivers/net/sfc/sfc_hunt.c | 1 + src/drivers/net/skge.c | 1 + src/drivers/net/sky2.c | 1 + src/drivers/net/tg3/tg3.c | 1 + src/drivers/net/tg3/tg3_hw.c | 1 + src/drivers/net/tg3/tg3_phy.c | 1 + src/drivers/net/vmxnet3.c | 1 + src/drivers/net/vxge/vxge_config.c | 1 + src/drivers/net/vxge/vxge_traffic.c | 1 + src/drivers/nvs/nvsvpd.c | 1 + src/drivers/usb/usbblk.c | 1 + src/hci/commands/cert_cmd.c | 1 + src/hci/commands/image_cmd.c | 1 + src/hci/commands/image_crypt_cmd.c | 1 + src/hci/commands/image_trust_cmd.c | 1 + src/hci/commands/pci_cmd.c | 1 + src/hci/commands/usb_cmd.c | 1 + src/image/der.c | 1 + src/image/efi_image.c | 1 + src/image/efi_siglist.c | 1 + src/image/elf.c | 1 + src/image/pnm.c | 1 + src/image/segment.c | 1 + src/include/ipxe/dummy_pio.h | 2 ++ src/include/ipxe/iomap_virt.h | 2 ++ src/include/ipxe/uaccess.h | 27 ---------------------- src/interface/efi/efi_bofm.c | 1 + src/interface/efi/efi_cmdline.c | 1 + src/interface/efi/efi_pci.c | 1 + src/interface/xen/xenbus.c | 1 + src/net/eapol.c | 1 + src/net/fcoe.c | 1 + src/net/lldp.c | 1 + src/net/peerblk.c | 1 + src/net/peermux.c | 1 + src/net/tcp/httpblock.c | 1 + src/net/tcp/syslogs.c | 1 + src/net/udp/syslog.c | 1 + src/tests/asn1_test.c | 1 + src/tests/cpio_test.c | 1 + src/tests/pixbuf_test.c | 1 + src/tests/test.c | 1 + src/usr/imgarchive.c | 1 + src/usr/imgmgmt.c | 1 + src/usr/imgtrust.c | 1 + 89 files changed, 90 insertions(+), 28 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 1fdf80497..461188d04 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/arch/x86/drivers/xen/hvm.c b/src/arch/x86/drivers/xen/hvm.c index b77cdd14c..cf41cc955 100644 --- a/src/arch/x86/drivers/xen/hvm.c +++ b/src/arch/x86/drivers/xen/hvm.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/arch/x86/image/elfboot.c b/src/arch/x86/image/elfboot.c index 63a3460d3..f662e366f 100644 --- a/src/arch/x86/image/elfboot.c +++ b/src/arch/x86/image/elfboot.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index 8acdd95f7..cb4879036 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/image/multiboot.c b/src/arch/x86/image/multiboot.c index 7c8963475..9444c4047 100644 --- a/src/arch/x86/image/multiboot.c +++ b/src/arch/x86/image/multiboot.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 0a60283fb..0f57bdfcd 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index d7acd0084..3e6cf7268 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include #include diff --git a/src/arch/x86/image/ucode.c b/src/arch/x86/image/ucode.c index 0ae3863cb..fd4689e00 100644 --- a/src/arch/x86/image/ucode.c +++ b/src/arch/x86/image/ucode.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/arch/x86/include/realmode.h b/src/arch/x86/include/realmode.h index 75f7d16e7..5cf644a23 100644 --- a/src/arch/x86/include/realmode.h +++ b/src/arch/x86/include/realmode.h @@ -2,6 +2,7 @@ #define REALMODE_H #include +#include #include #include diff --git a/src/arch/x86/interface/pcbios/acpipwr.c b/src/arch/x86/interface/pcbios/acpipwr.c index bff53806b..cb82ef1b4 100644 --- a/src/arch/x86/interface/pcbios/acpipwr.c +++ b/src/arch/x86/interface/pcbios/acpipwr.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c index 05d89b3b7..897858143 100644 --- a/src/arch/x86/interface/pcbios/bios_cachedhcp.c +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/bios_reboot.c b/src/arch/x86/interface/pcbios/bios_reboot.c index 463470245..c7f25405f 100644 --- a/src/arch/x86/interface/pcbios/bios_reboot.c +++ b/src/arch/x86/interface/pcbios/bios_reboot.c @@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/biosint.c b/src/arch/x86/interface/pcbios/biosint.c index 667e9ed81..f5e54ede8 100644 --- a/src/arch/x86/interface/pcbios/biosint.c +++ b/src/arch/x86/interface/pcbios/biosint.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/hidemem.c b/src/arch/x86/interface/pcbios/hidemem.c index 1a3022c5d..6983c1f4a 100644 --- a/src/arch/x86/interface/pcbios/hidemem.c +++ b/src/arch/x86/interface/pcbios/hidemem.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index 73fdfebd3..045d78e8d 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/memmap.c b/src/arch/x86/interface/pcbios/memmap.c index daae382b8..3bc1229aa 100644 --- a/src/arch/x86/interface/pcbios/memmap.c +++ b/src/arch/x86/interface/pcbios/memmap.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index d4489fb01..bfaffc4bb 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index 6bcf19b18..6913be552 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index 362721747..b793185fe 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 0d400db16..1510f3321 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/core/downloader.c b/src/core/downloader.c index 449761836..9950fe5e4 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/core/pixbuf.c b/src/core/pixbuf.c index d0b80b2a9..506a28c38 100644 --- a/src/core/pixbuf.c +++ b/src/core/pixbuf.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/core/sanboot.c b/src/core/sanboot.c index bdac813ff..e90c5ef1d 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/bus/devtree.c b/src/drivers/bus/devtree.c index cbd8ea8fa..654f8d14f 100644 --- a/src/drivers/bus/devtree.c +++ b/src/drivers/bus/devtree.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 58d513e88..35556a8d9 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c index 98005559d..84aa76827 100644 --- a/src/drivers/bus/pci_settings.c +++ b/src/drivers/bus/pci_settings.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c index db6f94d8a..4fd190d83 100644 --- a/src/drivers/bus/usb_settings.c +++ b/src/drivers/bus/usb_settings.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/infiniband/flexboot_nodnic.c b/src/drivers/infiniband/flexboot_nodnic.c index c6e19b955..a9e6fdd71 100644 --- a/src/drivers/infiniband/flexboot_nodnic.c +++ b/src/drivers/infiniband/flexboot_nodnic.c @@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include +#include #include #include #include diff --git a/src/drivers/infiniband/linda.c b/src/drivers/infiniband/linda.c index 0c8a043a1..2e2b469e4 100644 --- a/src/drivers/infiniband/linda.c +++ b/src/drivers/infiniband/linda.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c index e368d459b..b35c30dee 100644 --- a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c +++ b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include "../../mlx_utils/include/private/mlx_memory_priv.h" diff --git a/src/drivers/infiniband/qib7322.c b/src/drivers/infiniband/qib7322.c index a011dafc1..a9e4566dc 100644 --- a/src/drivers/infiniband/qib7322.c +++ b/src/drivers/infiniband/qib7322.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/drivers/linux/slirp.c b/src/drivers/linux/slirp.c index 8341c9676..d7ab6419e 100644 --- a/src/drivers/linux/slirp.c +++ b/src/drivers/linux/slirp.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include diff --git a/src/drivers/net/ath/ath.h b/src/drivers/net/ath/ath.h index 589bb5634..21f795b70 100644 --- a/src/drivers/net/ath/ath.h +++ b/src/drivers/net/ath/ath.h @@ -23,6 +23,7 @@ FILE_LICENCE ( BSD2 ); #include +#include #include /* This block of functions are from kernel.h v3.0.1 */ diff --git a/src/drivers/net/ath/ath5k/ath5k.h b/src/drivers/net/ath/ath5k/ath5k.h index fa62e8ce5..727d41279 100644 --- a/src/drivers/net/ath/ath5k/ath5k.h +++ b/src/drivers/net/ath/ath5k/ath5k.h @@ -24,6 +24,7 @@ FILE_LICENCE ( MIT ); #include +#include #include #include #include diff --git a/src/drivers/net/b44.c b/src/drivers/net/b44.c index 30ece5574..c6ca99865 100644 --- a/src/drivers/net/b44.c +++ b/src/drivers/net/b44.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include #include #include #include diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index 5de8d094e..402439eef 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -3,6 +3,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include #include +#include #include #include #include diff --git a/src/drivers/net/eepro100.c b/src/drivers/net/eepro100.c index 49b00d443..318db1883 100644 --- a/src/drivers/net/eepro100.c +++ b/src/drivers/net/eepro100.c @@ -101,6 +101,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); */ #include +#include #include #include #include diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c index be30b71f7..a58b71568 100644 --- a/src/drivers/net/etherfabric.c +++ b/src/drivers/net/etherfabric.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL_ANY ); #include #include #include +#include #include #include #include diff --git a/src/drivers/net/marvell/atl2_hw.c b/src/drivers/net/marvell/atl2_hw.c index 805820709..07822a9c2 100644 --- a/src/drivers/net/marvell/atl2_hw.c +++ b/src/drivers/net/marvell/atl2_hw.c @@ -31,6 +31,7 @@ FILE_LICENCE ( BSD2 ); +#include #include #include #include diff --git a/src/drivers/net/marvell/atl_hw.c b/src/drivers/net/marvell/atl_hw.c index e0843e6f4..fa7f2a9b8 100644 --- a/src/drivers/net/marvell/atl_hw.c +++ b/src/drivers/net/marvell/atl_hw.c @@ -31,6 +31,7 @@ FILE_LICENCE ( BSD2 ); +#include #include #include #include diff --git a/src/drivers/net/myri10ge.c b/src/drivers/net/myri10ge.c index 6d0f723f2..fb9dc01b2 100644 --- a/src/drivers/net/myri10ge.c +++ b/src/drivers/net/myri10ge.c @@ -74,7 +74,7 @@ FILE_LICENCE ( GPL2_ONLY ); */ #include - +#include #include #include #include diff --git a/src/drivers/net/netvsc.c b/src/drivers/net/netvsc.c index 4bdf7b517..9b6ee88b4 100644 --- a/src/drivers/net/netvsc.c +++ b/src/drivers/net/netvsc.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * bus (VMBus). It provides a transport layer for RNDIS packets. */ +#include #include #include #include diff --git a/src/drivers/net/rtl818x/rtl818x.c b/src/drivers/net/rtl818x/rtl818x.c index 599d36fad..3bae8a797 100644 --- a/src/drivers/net/rtl818x/rtl818x.c +++ b/src/drivers/net/rtl818x/rtl818x.c @@ -20,6 +20,7 @@ FILE_LICENCE(GPL2_ONLY); #include +#include #include #include #include diff --git a/src/drivers/net/sfc/efx_hunt.c b/src/drivers/net/sfc/efx_hunt.c index abe3e8320..92c0fda62 100644 --- a/src/drivers/net/sfc/efx_hunt.c +++ b/src/drivers/net/sfc/efx_hunt.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/drivers/net/sfc/sfc_hunt.c b/src/drivers/net/sfc/sfc_hunt.c index 43ac229ab..f763fc9d0 100644 --- a/src/drivers/net/sfc/sfc_hunt.c +++ b/src/drivers/net/sfc/sfc_hunt.c @@ -19,6 +19,7 @@ ***************************************************************************/ #include #include +#include #include #include #include diff --git a/src/drivers/net/skge.c b/src/drivers/net/skge.c index cc7f0b91b..828a2a4c9 100755 --- a/src/drivers/net/skge.c +++ b/src/drivers/net/skge.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include +#include #include #include #include diff --git a/src/drivers/net/sky2.c b/src/drivers/net/sky2.c index 4f8ec3e42..db3f6aaa1 100644 --- a/src/drivers/net/sky2.c +++ b/src/drivers/net/sky2.c @@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include +#include #include #include #include diff --git a/src/drivers/net/tg3/tg3.c b/src/drivers/net/tg3/tg3.c index 05af22d61..a6736305c 100644 --- a/src/drivers/net/tg3/tg3.c +++ b/src/drivers/net/tg3/tg3.c @@ -3,6 +3,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include #include +#include #include #include #include diff --git a/src/drivers/net/tg3/tg3_hw.c b/src/drivers/net/tg3/tg3_hw.c index 9a70413b6..5c9506dce 100644 --- a/src/drivers/net/tg3/tg3_hw.c +++ b/src/drivers/net/tg3/tg3_hw.c @@ -18,6 +18,7 @@ FILE_LICENCE ( GPL2_ONLY ); #include +#include #include #include #include diff --git a/src/drivers/net/tg3/tg3_phy.c b/src/drivers/net/tg3/tg3_phy.c index e88b0be0f..a2322329e 100644 --- a/src/drivers/net/tg3/tg3_phy.c +++ b/src/drivers/net/tg3/tg3_phy.c @@ -1,6 +1,7 @@ #include #include +#include #include #include #include diff --git a/src/drivers/net/vmxnet3.c b/src/drivers/net/vmxnet3.c index 3800d6b72..2cc6738f2 100644 --- a/src/drivers/net/vmxnet3.c +++ b/src/drivers/net/vmxnet3.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/net/vxge/vxge_config.c b/src/drivers/net/vxge/vxge_config.c index f4d217097..8c6ee9e96 100644 --- a/src/drivers/net/vxge/vxge_config.c +++ b/src/drivers/net/vxge/vxge_config.c @@ -16,6 +16,7 @@ FILE_LICENCE(GPL2_ONLY); #include #include +#include #include #include #include diff --git a/src/drivers/net/vxge/vxge_traffic.c b/src/drivers/net/vxge/vxge_traffic.c index dbd799015..0adaea2aa 100644 --- a/src/drivers/net/vxge/vxge_traffic.c +++ b/src/drivers/net/vxge/vxge_traffic.c @@ -15,6 +15,7 @@ FILE_LICENCE(GPL2_ONLY); #include +#include #include #include "vxge_traffic.h" diff --git a/src/drivers/nvs/nvsvpd.c b/src/drivers/nvs/nvsvpd.c index 3e88531c7..195973319 100644 --- a/src/drivers/nvs/nvsvpd.c +++ b/src/drivers/nvs/nvsvpd.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/drivers/usb/usbblk.c b/src/drivers/usb/usbblk.c index 39adc012f..cb377efb0 100644 --- a/src/drivers/usb/usbblk.c +++ b/src/drivers/usb/usbblk.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/hci/commands/cert_cmd.c b/src/hci/commands/cert_cmd.c index 24b18bf5c..75d2ccbed 100644 --- a/src/hci/commands/cert_cmd.c +++ b/src/hci/commands/cert_cmd.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index bf97b4deb..4b42695c4 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/hci/commands/image_crypt_cmd.c b/src/hci/commands/image_crypt_cmd.c index 26e9d79f8..4dfb5b131 100644 --- a/src/hci/commands/image_crypt_cmd.c +++ b/src/hci/commands/image_crypt_cmd.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/hci/commands/image_trust_cmd.c b/src/hci/commands/image_trust_cmd.c index b34378f93..9b9e3f859 100644 --- a/src/hci/commands/image_trust_cmd.c +++ b/src/hci/commands/image_trust_cmd.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/hci/commands/pci_cmd.c b/src/hci/commands/pci_cmd.c index 5bae66fbe..fa1fa5ece 100644 --- a/src/hci/commands/pci_cmd.c +++ b/src/hci/commands/pci_cmd.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/src/hci/commands/usb_cmd.c b/src/hci/commands/usb_cmd.c index d1086fd7e..4ee2f2ddb 100644 --- a/src/hci/commands/usb_cmd.c +++ b/src/hci/commands/usb_cmd.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/src/image/der.c b/src/image/der.c index 600e163c9..67117d43b 100644 --- a/src/image/der.c +++ b/src/image/der.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/image/efi_image.c b/src/image/efi_image.c index f71630f4a..f7ee7ff50 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include +#include #include #include #include diff --git a/src/image/efi_siglist.c b/src/image/efi_siglist.c index 2bd273dbd..b264ac558 100644 --- a/src/image/efi_siglist.c +++ b/src/image/efi_siglist.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/image/elf.c b/src/image/elf.c index 83712c3b0..97e07f37f 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * common ELF-related functionality. */ +#include #include #include #include diff --git a/src/image/pnm.c b/src/image/pnm.c index 4b5020b64..489a43304 100644 --- a/src/image/pnm.c +++ b/src/image/pnm.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/image/segment.c b/src/image/segment.c index 2cb637dc2..52272170a 100644 --- a/src/image/segment.c +++ b/src/image/segment.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +#include #include #include #include diff --git a/src/include/ipxe/dummy_pio.h b/src/include/ipxe/dummy_pio.h index 1cdabba14..e7a4cabef 100644 --- a/src/include/ipxe/dummy_pio.h +++ b/src/include/ipxe/dummy_pio.h @@ -13,6 +13,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include + #define DUMMY_INX( _prefix, _suffix, _type ) \ static inline __always_inline _type \ IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \ diff --git a/src/include/ipxe/iomap_virt.h b/src/include/ipxe/iomap_virt.h index 4962b7c37..731d083d5 100644 --- a/src/include/ipxe/iomap_virt.h +++ b/src/include/ipxe/iomap_virt.h @@ -9,6 +9,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include + #ifdef IOMAP_VIRT #define IOMAP_PREFIX_virt #else diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 948ef1fa2..82f29f793 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include -#include #include #include @@ -127,30 +126,4 @@ virt_to_phys ( volatile const void *virt ); */ void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys ); -/** - * Copy data to user buffer - * - * @v dest Destination - * @v dest_off Destination offset - * @v src Source - * @v len Length - */ -static inline __always_inline void -copy_to_user ( userptr_t dest, off_t dest_off, const void *src, size_t len ) { - memcpy ( ( dest + dest_off ), src, len ); -} - -/** - * Copy data from user buffer - * - * @v dest Destination - * @v src Source - * @v src_off Source offset - * @v len Length - */ -static inline __always_inline void -copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) { - memcpy ( dest, ( src + src_off ), len ); -} - #endif /* _IPXE_UACCESS_H */ diff --git a/src/interface/efi/efi_bofm.c b/src/interface/efi/efi_bofm.c index 7d1d3619f..3d956800e 100644 --- a/src/interface/efi/efi_bofm.c +++ b/src/interface/efi/efi_bofm.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index b33bebd8c..13ad0fc35 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index b8c7df38d..1b1f05816 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/interface/xen/xenbus.c b/src/interface/xen/xenbus.c index 5dd01dfa3..8b5ee0a0d 100644 --- a/src/interface/xen/xenbus.c +++ b/src/interface/xen/xenbus.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/net/eapol.c b/src/net/eapol.c index 8b09ca231..0c573d198 100644 --- a/src/net/eapol.c +++ b/src/net/eapol.c @@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include #include #include #include diff --git a/src/net/fcoe.c b/src/net/fcoe.c index 9f3ddf88b..d54f1d431 100644 --- a/src/net/fcoe.c +++ b/src/net/fcoe.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/lldp.c b/src/net/lldp.c index a854d0ace..2b707c874 100644 --- a/src/net/lldp.c +++ b/src/net/lldp.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/net/peerblk.c b/src/net/peerblk.c index bbd5f16ed..58b185102 100644 --- a/src/net/peerblk.c +++ b/src/net/peerblk.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/peermux.c b/src/net/peermux.c index 431ca76e0..5c814b03e 100644 --- a/src/net/peermux.c +++ b/src/net/peermux.c @@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/tcp/httpblock.c b/src/net/tcp/httpblock.c index 156f11e47..8eff1942c 100644 --- a/src/net/tcp/httpblock.c +++ b/src/net/tcp/httpblock.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include diff --git a/src/net/tcp/syslogs.c b/src/net/tcp/syslogs.c index f1f70d59e..5676f3e3e 100644 --- a/src/net/tcp/syslogs.c +++ b/src/net/tcp/syslogs.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c index a45fc459d..198c86ef7 100644 --- a/src/net/udp/syslog.c +++ b/src/net/udp/syslog.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/tests/asn1_test.c b/src/tests/asn1_test.c index df3f01b63..b522b85d7 100644 --- a/src/tests/asn1_test.c +++ b/src/tests/asn1_test.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #undef NDEBUG #include +#include #include #include #include diff --git a/src/tests/cpio_test.c b/src/tests/cpio_test.c index 7eb8b2c74..24baf947b 100644 --- a/src/tests/cpio_test.c +++ b/src/tests/cpio_test.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #undef NDEBUG #include +#include #include #include diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c index 1f82e0018..a8ea1151e 100644 --- a/src/tests/pixbuf_test.c +++ b/src/tests/pixbuf_test.c @@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* Forcibly enable assertions */ #undef NDEBUG +#include #include #include #include diff --git a/src/tests/test.c b/src/tests/test.c index 4c49d4c16..1ec4b21ef 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -34,6 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include +#include #include #include #include diff --git a/src/usr/imgarchive.c b/src/usr/imgarchive.c index 6849dd510..91600760e 100644 --- a/src/usr/imgarchive.c +++ b/src/usr/imgarchive.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index 054137696..65b52fd3a 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c index 7f7e7ed14..4eb631e79 100644 --- a/src/usr/imgtrust.c +++ b/src/usr/imgtrust.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include -- cgit v1.2.3-55-g7522 From cd803ff2e2424b56a7ae5886e4cfe17b47652e6e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 13:22:54 +0100 Subject: [image] Add the concept of a static image Not all images are allocated via alloc_image(). For example: embedded images, the static images created to hold a runtime command line, and the images used by unit tests are all static structures. Using image_set_cmdline() (via e.g. the "imgargs" command) to set the command-line arguments of a static image will succeed but will leak memory, since nothing will ever free the allocated command line. There are no code paths that can lead to calling image_set_len() on a static image, but there is no safety check against future code paths attempting this. Define a flag IMAGE_STATIC to mark an image as statically allocated, generalise free_image() to also handle freeing dynamically allocated portions of static images (such as the command line), and expose free_image() for use by static images. Define a related flag IMAGE_STATIC_NAME to mark the name as statically allocated. Allow a statically allocated name to be replaced with a dynamically allocated name since this is a potentially valid use case (e.g. if "imgdecrypt --name " is used on an embedded image). Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 2 ++ src/core/image.c | 44 ++++++++++++++++++++++++++++++++++++----- src/image/embedded.c | 3 ++- src/include/ipxe/image.h | 19 ++++++++++++++++-- src/interface/efi/efi_cmdline.c | 2 ++ src/tests/asn1_test.h | 1 + src/tests/cms_test.c | 3 +++ src/tests/pixbuf_test.h | 1 + src/tests/test.c | 1 + 9 files changed, 68 insertions(+), 8 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 461188d04..86083b1f9 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -70,6 +70,7 @@ static void cmdline_image_free ( struct refcnt *refcnt ) { struct image *image = container_of ( refcnt, struct image, refcnt ); DBGC ( image, "RUNTIME freeing command line\n" ); + free_image ( refcnt ); free ( cmdline_copy ); } @@ -77,6 +78,7 @@ static void cmdline_image_free ( struct refcnt *refcnt ) { static struct image cmdline_image = { .refcnt = REF_INIT ( cmdline_image_free ), .name = "", + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), .type = &script_image_type, }; diff --git a/src/core/image.c b/src/core/image.c index 72885ec09..4f92dfe57 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -76,22 +76,41 @@ static int require_trusted_images_permanent = 0; * Free executable image * * @v refcnt Reference counter + * + * Image consumers must call image_put() rather than calling + * free_image() directly. This function is exposed for use only by + * static images. */ -static void free_image ( struct refcnt *refcnt ) { +void free_image ( struct refcnt *refcnt ) { struct image *image = container_of ( refcnt, struct image, refcnt ); struct image_tag *tag; + /* Sanity check: free_image() should not be called directly on + * dynamically allocated images. + */ + assert ( refcnt->count < 0 ); DBGC ( image, "IMAGE %s freed\n", image->name ); + + /* Clear any tag weak references */ for_each_table_entry ( tag, IMAGE_TAGS ) { if ( tag->image == image ) tag->image = NULL; } - free ( image->name ); + + /* Free dynamic allocations used by both static and dynamic images */ free ( image->cmdline ); uri_put ( image->uri ); - ufree ( image->data ); image_put ( image->replacement ); - free ( image ); + + /* Free image name, if dynamically allocated */ + if ( ! ( image->flags & IMAGE_STATIC_NAME ) ) + free ( image->name ); + + /* Free image data and image itself, if dynamically allocated */ + if ( ! ( image->flags & IMAGE_STATIC ) ) { + ufree ( image->data ); + free ( image ); + } } /** @@ -165,9 +184,13 @@ int image_set_name ( struct image *image, const char *name ) { if ( ! name_copy ) return -ENOMEM; + /* Free existing name, if not statically allocated */ + if ( ! ( image->flags & IMAGE_STATIC_NAME ) ) + free ( image->name ); + /* Replace existing name */ - free ( image->name ); image->name = name_copy; + image->flags &= ~IMAGE_STATIC_NAME; return 0; } @@ -220,6 +243,10 @@ int image_set_cmdline ( struct image *image, const char *cmdline ) { int image_set_len ( struct image *image, size_t len ) { void *new; + /* Refuse to reallocate static images */ + if ( image->flags & IMAGE_STATIC ) + return -ENOTTY; + /* (Re)allocate image data */ new = urealloc ( image->data, len ); if ( ! new ) @@ -288,6 +315,13 @@ int register_image ( struct image *image ) { char name[8]; /* "imgXXXX" */ int rc; + /* Sanity checks */ + if ( image->flags & IMAGE_STATIC ) { + assert ( ( image->name == NULL ) || + ( image->flags & IMAGE_STATIC_NAME ) ); + assert ( image->cmdline == NULL ); + } + /* Create image name if it doesn't already have one */ if ( ! image->name ) { snprintf ( name, sizeof ( name ), "img%d", imgindex++ ); diff --git a/src/image/embedded.c b/src/image/embedded.c index 58833ac30..028f49308 100644 --- a/src/image/embedded.c +++ b/src/image/embedded.c @@ -31,8 +31,9 @@ EMBED_ALL /* Image structures for all embedded images */ #undef EMBED #define EMBED( _index, _path, _name ) { \ - .refcnt = REF_INIT ( ref_no_free ), \ + .refcnt = REF_INIT ( free_image ), \ .name = _name, \ + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .data = ( userptr_t ) ( embedded_image_ ## _index ## _data ), \ .len = ( size_t ) embedded_image_ ## _index ## _len, \ }, diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index bf2d77626..8ff938a17 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -30,14 +30,22 @@ struct image { /** URI of image */ struct uri *uri; - /** Name */ + /** Name + * + * If the @c IMAGE_STATIC_NAME flag is set, then this is a + * statically allocated string. + */ char *name; /** Flags */ unsigned int flags; /** Command line to pass to image */ char *cmdline; - /** Raw file image */ + /** Raw file image + * + * If the @c IMAGE_STATIC flag is set, then this is a + * statically allocated image. + */ void *data; /** Length of raw file image */ size_t len; @@ -72,6 +80,12 @@ struct image { /** Image will be hidden from enumeration */ #define IMAGE_HIDDEN 0x0008 +/** Image is statically allocated */ +#define IMAGE_STATIC 0x0010 + +/** Image name is statically allocated */ +#define IMAGE_STATIC_NAME 0x0020 + /** An executable image type */ struct image_type { /** Name of this image type */ @@ -185,6 +199,7 @@ static inline struct image * first_image ( void ) { return list_first_entry ( &images, struct image, list ); } +extern void free_image ( struct refcnt *refcnt ); extern struct image * alloc_image ( struct uri *uri ); extern int image_set_uri ( struct image *image, struct uri *uri ); extern int image_set_name ( struct image *image, const char *name ); diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index 13ad0fc35..59bce925f 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -58,6 +58,7 @@ static void efi_cmdline_free ( struct refcnt *refcnt ) { struct image *image = container_of ( refcnt, struct image, refcnt ); DBGC ( image, "CMDLINE freeing command line\n" ); + free_image ( refcnt ); free ( efi_cmdline_copy ); } @@ -65,6 +66,7 @@ static void efi_cmdline_free ( struct refcnt *refcnt ) { static struct image efi_cmdline_image = { .refcnt = REF_INIT ( efi_cmdline_free ), .name = "", + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), .type = &script_image_type, }; diff --git a/src/tests/asn1_test.h b/src/tests/asn1_test.h index c8167ed36..f69a4bf2a 100644 --- a/src/tests/asn1_test.h +++ b/src/tests/asn1_test.h @@ -46,6 +46,7 @@ struct asn1_test { static struct image _name ## __image = { \ .refcnt = REF_INIT ( ref_no_free ), \ .name = #_name, \ + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .data = ( userptr_t ) ( _name ## __file ), \ .len = sizeof ( _name ## __file ), \ }; \ diff --git a/src/tests/cms_test.c b/src/tests/cms_test.c index 5e186cdf0..f80fbaa86 100644 --- a/src/tests/cms_test.c +++ b/src/tests/cms_test.c @@ -85,6 +85,7 @@ struct cms_test_keypair { .image = { \ .refcnt = REF_INIT ( ref_no_free ), \ .name = #NAME, \ + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .data = ( userptr_t ) ( NAME ## _data ), \ .len = sizeof ( NAME ## _data ), \ }, \ @@ -97,6 +98,7 @@ struct cms_test_keypair { .image = { \ .refcnt = REF_INIT ( ref_no_free ), \ .name = #NAME, \ + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .data = ( userptr_t ) ( NAME ## _data ), \ .len = sizeof ( NAME ## _data ), \ }, \ @@ -109,6 +111,7 @@ struct cms_test_keypair { .image = { \ .refcnt = REF_INIT ( ref_no_free ), \ .name = #NAME, \ + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .type = &der_image_type, \ .data = ( userptr_t ) ( NAME ## _data ), \ .len = sizeof ( NAME ## _data ), \ diff --git a/src/tests/pixbuf_test.h b/src/tests/pixbuf_test.h index d12829d89..991c16ba3 100644 --- a/src/tests/pixbuf_test.h +++ b/src/tests/pixbuf_test.h @@ -41,6 +41,7 @@ struct pixel_buffer_test { static struct image _name ## __image = { \ .refcnt = REF_INIT ( ref_no_free ), \ .name = #_name, \ + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .data = ( userptr_t ) ( _name ## __file ), \ .len = sizeof ( _name ## __file ), \ }; \ diff --git a/src/tests/test.c b/src/tests/test.c index 1ec4b21ef..9fa12e27a 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -162,6 +162,7 @@ static struct image_type test_image_type = { static struct image test_image = { .refcnt = REF_INIT ( ref_no_free ), .name = "", + .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), .type = &test_image_type, }; -- cgit v1.2.3-55-g7522 From 05ad7833c51c942a5cb91540a054852bb991333b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 14:14:51 +0100 Subject: [image] Make image data read-only to most consumers Almost all image consumers do not need to modify the content of the image. Now that the image data is a pointer type (rather than the opaque userptr_t type), we can rely on the compiler to enforce this at build time. Change the .data field to be a const pointer, so that the compiler can verify that image consumers do not modify the image content. Provide a transparent .rwdata field for consumers who have a legitimate (and now explicit) reason to modify the image content. We do not attempt to impose any runtime restriction on checking whether or not an image is writable. The only existing instances of genuinely read-only images are the various unit test images, and it is acceptable for defective test cases to result in a segfault rather than a runtime error. Signed-off-by: Michael Brown --- src/arch/x86/image/initrd.c | 11 +++++------ src/arch/x86/image/sdi.c | 2 +- src/core/fdt.c | 2 +- src/core/image.c | 8 ++++---- src/crypto/cms.c | 6 +++--- src/image/efi_image.c | 18 ++++++++++++++---- src/image/embedded.c | 13 +------------ src/image/zlib.c | 3 ++- src/include/ipxe/image.h | 7 ++++++- src/interface/efi/efi_cmdline.c | 2 +- src/tests/asn1_test.c | 3 --- src/tests/asn1_test.h | 2 +- src/tests/cms_test.c | 32 +++----------------------------- src/tests/pixbuf_test.c | 7 ++----- src/tests/pixbuf_test.h | 2 +- 15 files changed, 45 insertions(+), 73 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index cb4879036..98c7a3804 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -63,10 +63,9 @@ static physaddr_t initrd_squash_high ( physaddr_t top ) { /* Find the highest image not yet in its final position */ highest = NULL; for_each_image ( initrd ) { - data = initrd->data; - if ( ( virt_to_phys ( data ) < current ) && + if ( ( virt_to_phys ( initrd->data ) < current ) && ( ( highest == NULL ) || - ( virt_to_phys ( data ) > + ( virt_to_phys ( initrd->data ) > virt_to_phys ( highest->data ) ) ) ) { highest = initrd; } @@ -144,9 +143,9 @@ static void initrd_swap ( struct image *low, struct image *high, /* Swap fragments */ memcpy ( free, ( high->data + len ), frag_len ); - memmove ( ( low->data + new_len ), ( low->data + len ), + memmove ( ( low->rwdata + new_len ), ( low->data + len ), low->len ); - memcpy ( ( low->data + len ), free, frag_len ); + memcpy ( ( low->rwdata + len ), free, frag_len ); len = new_len; } @@ -165,8 +164,8 @@ static void initrd_swap ( struct image *low, struct image *high, static int initrd_swap_any ( void *free, size_t free_len ) { struct image *low; struct image *high; + const void *adjacent; size_t padded_len; - void *adjacent; /* Find any pair of initrds that can be swapped */ for_each_image ( low ) { diff --git a/src/arch/x86/image/sdi.c b/src/arch/x86/image/sdi.c index cdfdeb369..c0cded239 100644 --- a/src/arch/x86/image/sdi.c +++ b/src/arch/x86/image/sdi.c @@ -51,7 +51,7 @@ FEATURE ( FEATURE_IMAGE, "SDI", DHCP_EB_FEATURE_SDI, 1 ); * @ret rc Return status code */ static int sdi_exec ( struct image *image ) { - struct sdi_header *sdi; + const struct sdi_header *sdi; uint32_t sdiptr; /* Sanity check */ diff --git a/src/core/fdt.c b/src/core/fdt.c index 7c7127aed..744e0e705 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -734,7 +734,7 @@ static int fdt_parse_image ( struct fdt *fdt, struct image *image ) { int rc; /* Parse image */ - if ( ( rc = fdt_parse ( fdt, image->data, image->len ) ) != 0 ) { + if ( ( rc = fdt_parse ( fdt, image->rwdata, image->len ) ) != 0 ) { DBGC ( fdt, "FDT image \"%s\" is invalid: %s\n", image->name, strerror ( rc ) ); return rc; diff --git a/src/core/image.c b/src/core/image.c index 4f92dfe57..a06466b72 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -108,7 +108,7 @@ void free_image ( struct refcnt *refcnt ) { /* Free image data and image itself, if dynamically allocated */ if ( ! ( image->flags & IMAGE_STATIC ) ) { - ufree ( image->data ); + ufree ( image->rwdata ); free ( image ); } } @@ -248,10 +248,10 @@ int image_set_len ( struct image *image, size_t len ) { return -ENOTTY; /* (Re)allocate image data */ - new = urealloc ( image->data, len ); + new = urealloc ( image->rwdata, len ); if ( ! new ) return -ENOMEM; - image->data = new; + image->rwdata = new; image->len = len; return 0; @@ -273,7 +273,7 @@ int image_set_data ( struct image *image, const void *data, size_t len ) { return rc; /* Copy in new image data */ - memcpy ( image->data, data, len ); + memcpy ( image->rwdata, data, len ); return 0; } diff --git a/src/crypto/cms.c b/src/crypto/cms.c index 36b87c644..edfcc7fdc 100644 --- a/src/crypto/cms.c +++ b/src/crypto/cms.c @@ -1079,7 +1079,7 @@ int cms_decrypt ( struct cms_message *cms, struct image *image, final_len = ( ( image->len && is_block_cipher ( cipher ) ) ? cipher->blocksize : 0 ); bulk_len = ( image->len - final_len ); - cipher_decrypt ( cipher, ctx, image->data, image->data, bulk_len ); + cipher_decrypt ( cipher, ctx, image->data, image->rwdata, bulk_len ); /* Decrypt final block */ cipher_decrypt ( cipher, ctx, ( image->data + bulk_len ), final, @@ -1117,7 +1117,7 @@ int cms_decrypt ( struct cms_message *cms, struct image *image, * have to include include any error-handling code path to * reconstruct the block padding. */ - memcpy ( ( image->data + bulk_len ), final, final_len ); + memcpy ( ( image->rwdata + bulk_len ), final, final_len ); image->len -= pad_len; /* Clear image type and re-register image, if applicable */ @@ -1137,7 +1137,7 @@ int cms_decrypt ( struct cms_message *cms, struct image *image, * containing the potentially invalid (and therefore * unreproducible) block padding. */ - cipher_encrypt ( cipher, ctxdup, image->data, image->data, bulk_len ); + cipher_encrypt ( cipher, ctxdup, image->data, image->rwdata, bulk_len ); if ( original_flags & IMAGE_REGISTERED ) { register_image ( image ); /* Cannot fail on re-registration */ image_put ( image ); diff --git a/src/image/efi_image.c b/src/image/efi_image.c index f7ee7ff50..e7b19c4ce 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -243,10 +243,15 @@ static int efi_image_exec ( struct image *image ) { goto err_shim_install; } - /* Attempt loading image */ + /* Attempt loading image + * + * LoadImage() does not (allegedly) modify the image content, + * but requires a non-const pointer to SourceBuffer. We + * therefore use the .rwdata field rather than .data. + */ handle = NULL; if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, path, - exec->data, exec->len, + exec->rwdata, exec->len, &handle ) ) != 0 ) { /* Not an EFI image */ rc = -EEFI_LOAD ( efirc ); @@ -377,10 +382,15 @@ static int efi_image_probe ( struct image *image ) { EFI_STATUS efirc; int rc; - /* Attempt loading image */ + /* Attempt loading image + * + * LoadImage() does not (allegedly) modify the image content, + * but requires a non-const pointer to SourceBuffer. We + * therefore use the .rwdata field rather than .data. + */ handle = NULL; if ( ( efirc = bs->LoadImage ( FALSE, efi_image_handle, &empty_path, - image->data, image->len, + image->rwdata, image->len, &handle ) ) != 0 ) { /* Not an EFI image */ rc = -EEFI_LOAD ( efirc ); diff --git a/src/image/embedded.c b/src/image/embedded.c index 028f49308..76d256c9b 100644 --- a/src/image/embedded.c +++ b/src/image/embedded.c @@ -10,7 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include /* Raw image data for all embedded images */ @@ -34,7 +33,7 @@ EMBED_ALL .refcnt = REF_INIT ( free_image ), \ .name = _name, \ .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ - .data = ( userptr_t ) ( embedded_image_ ## _index ## _data ), \ + .rwdata = embedded_image_ ## _index ## _data, \ .len = ( size_t ) embedded_image_ ## _index ## _len, \ }, static struct image embedded_images[] = { @@ -58,18 +57,8 @@ static void embedded_init ( void ) { for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) / sizeof ( embedded_images[0] ) ) ; i++ ) { image = &embedded_images[i]; - - /* virt_to_user() cannot be used in a static - * initialiser, so we cast the pointer to a userptr_t - * in the initialiser and fix it up here. (This will - * actually be a no-op on most platforms.) - */ - data = ( ( void * ) image->data ); - image->data = virt_to_user ( data ); - DBG ( "Embedded image \"%s\": %zd bytes at %p\n", image->name, image->len, data ); - if ( ( rc = register_image ( image ) ) != 0 ) { DBG ( "Could not register embedded image \"%s\": " "%s\n", image->name, strerror ( rc ) ); diff --git a/src/image/zlib.c b/src/image/zlib.c index d7deee88b..23eb50e7d 100644 --- a/src/image/zlib.c +++ b/src/image/zlib.c @@ -65,7 +65,8 @@ int zlib_deflate ( enum deflate_format format, const void *data, size_t len, deflate_init ( deflate, format ); /* Initialise output chunk */ - deflate_chunk_init ( &out, extracted->data, 0, extracted->len ); + deflate_chunk_init ( &out, extracted->rwdata, 0, + extracted->len ); /* Decompress data */ if ( ( rc = deflate_inflate ( deflate, data, len, diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index 8ff938a17..fbf2b63b9 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -46,7 +46,12 @@ struct image { * If the @c IMAGE_STATIC flag is set, then this is a * statically allocated image. */ - void *data; + union { + /** Read-only data */ + const void *data; + /** Writable data */ + void *rwdata; + }; /** Length of raw file image */ size_t len; diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index 59bce925f..d5ec6cee3 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -113,7 +113,7 @@ static int efi_cmdline_init ( void ) { DBGC ( colour, "CMDLINE using command line \"%s\"\n", cmdline ); /* Prepare and register image */ - efi_cmdline_image.data = virt_to_user ( cmdline ); + efi_cmdline_image.data = cmdline; efi_cmdline_image.len = strlen ( cmdline ); if ( efi_cmdline_image.len && ( ( rc = register_image ( &efi_cmdline_image ) ) != 0 ) ) { diff --git a/src/tests/asn1_test.c b/src/tests/asn1_test.c index b522b85d7..4760b97fb 100644 --- a/src/tests/asn1_test.c +++ b/src/tests/asn1_test.c @@ -59,9 +59,6 @@ void asn1_okx ( struct asn1_test *test, const char *file, unsigned int line ) { /* Sanity check */ assert ( sizeof ( out ) == digest->digestsize ); - /* Correct image data pointer */ - test->image->data = virt_to_user ( ( void * ) test->image->data ); - /* Check that image is detected as correct type */ okx ( register_image ( test->image ) == 0, file, line ); okx ( test->image->type == test->type, file, line ); diff --git a/src/tests/asn1_test.h b/src/tests/asn1_test.h index f69a4bf2a..f8310f5ba 100644 --- a/src/tests/asn1_test.h +++ b/src/tests/asn1_test.h @@ -47,7 +47,7 @@ struct asn1_test { .refcnt = REF_INIT ( ref_no_free ), \ .name = #_name, \ .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ - .data = ( userptr_t ) ( _name ## __file ), \ + .data = _name ## __file, \ .len = sizeof ( _name ## __file ), \ }; \ static struct asn1_test_digest _name ## _expected[] = { \ diff --git a/src/tests/cms_test.c b/src/tests/cms_test.c index f80fbaa86..b71190cba 100644 --- a/src/tests/cms_test.c +++ b/src/tests/cms_test.c @@ -37,7 +37,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -86,7 +85,7 @@ struct cms_test_keypair { .refcnt = REF_INIT ( ref_no_free ), \ .name = #NAME, \ .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ - .data = ( userptr_t ) ( NAME ## _data ), \ + .data = NAME ## _data, \ .len = sizeof ( NAME ## _data ), \ }, \ } @@ -99,7 +98,7 @@ struct cms_test_keypair { .refcnt = REF_INIT ( ref_no_free ), \ .name = #NAME, \ .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ - .data = ( userptr_t ) ( NAME ## _data ), \ + .data = NAME ## _data, \ .len = sizeof ( NAME ## _data ), \ }, \ } @@ -113,7 +112,7 @@ struct cms_test_keypair { .name = #NAME, \ .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ .type = &der_image_type, \ - .data = ( userptr_t ) ( NAME ## _data ), \ + .data = NAME ## _data, \ .len = sizeof ( NAME ## _data ), \ }, \ } @@ -1652,16 +1651,9 @@ static time_t test_expired = 1375573111ULL; /* Sat Aug 3 23:38:31 2013 */ */ static void cms_message_okx ( struct cms_test_message *msg, const char *file, unsigned int line ) { - const void *data = ( ( void * ) msg->image.data ); - - /* Fix up image data pointer */ - msg->image.data = virt_to_user ( data ); /* Check ability to parse message */ okx ( cms_message ( &msg->image, &msg->cms ) == 0, file, line ); - - /* Reset image data pointer */ - msg->image.data = ( ( userptr_t ) data ); } #define cms_message_ok( msg ) \ cms_message_okx ( msg, __FILE__, __LINE__ ) @@ -1705,10 +1697,6 @@ static void cms_verify_okx ( struct cms_test_message *msg, time_t time, struct x509_chain *store, struct x509_root *root, const char *file, unsigned int line ) { - const void *data = ( ( void * ) img->image.data ); - - /* Fix up image data pointer */ - img->image.data = virt_to_user ( data ); /* Invalidate any certificates from previous tests */ x509_invalidate_chain ( msg->cms->certificates ); @@ -1717,9 +1705,6 @@ static void cms_verify_okx ( struct cms_test_message *msg, okx ( cms_verify ( msg->cms, &img->image, name, time, store, root ) == 0, file, line ); okx ( img->image.flags & IMAGE_TRUSTED, file, line ); - - /* Reset image data pointer */ - img->image.data = ( ( userptr_t ) data ); } #define cms_verify_ok( msg, img, name, time, store, root ) \ cms_verify_okx ( msg, img, name, time, store, root, \ @@ -1742,10 +1727,6 @@ static void cms_verify_fail_okx ( struct cms_test_message *msg, time_t time, struct x509_chain *store, struct x509_root *root, const char *file, unsigned int line ) { - const void *data = ( ( void * ) img->image.data ); - - /* Fix up image data pointer */ - img->image.data = virt_to_user ( data ); /* Invalidate any certificates from previous tests */ x509_invalidate_chain ( msg->cms->certificates ); @@ -1754,9 +1735,6 @@ static void cms_verify_fail_okx ( struct cms_test_message *msg, okx ( cms_verify ( msg->cms, &img->image, name, time, store, root ) != 0, file, line ); okx ( ! ( img->image.flags & IMAGE_TRUSTED ), file, line ); - - /* Reset image data pointer */ - img->image.data = ( ( userptr_t ) data ); } #define cms_verify_fail_ok( msg, img, name, time, store, root ) \ cms_verify_fail_okx ( msg, img, name, time, store, root, \ @@ -1777,10 +1755,6 @@ static void cms_decrypt_okx ( struct cms_test_image *img, struct cms_test_keypair *keypair, struct cms_test_image *expected, const char *file, unsigned int line ) { - const void *data = ( ( void * ) img->image.data ); - - /* Fix up image data pointer */ - img->image.data = virt_to_user ( data ); /* Check ability to decrypt image */ okx ( cms_decrypt ( envelope->cms, &img->image, NULL, diff --git a/src/tests/pixbuf_test.c b/src/tests/pixbuf_test.c index a8ea1151e..cbc3a7617 100644 --- a/src/tests/pixbuf_test.c +++ b/src/tests/pixbuf_test.c @@ -55,9 +55,6 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file, assert ( ( test->width * test->height * sizeof ( test->data[0] ) ) == test->len ); - /* Correct image data pointer */ - test->image->data = virt_to_user ( ( void * ) test->image->data ); - /* Check that image is detected as correct type */ okx ( register_image ( test->image ) == 0, file, line ); okx ( test->image->type == test->type, file, line ); @@ -72,8 +69,8 @@ void pixbuf_okx ( struct pixel_buffer_test *test, const char *file, /* Check pixel buffer data */ okx ( pixbuf->len == test->len, file, line ); - okx ( memcmp ( pixbuf->data, virt_to_user ( test->data ), - test->len ) == 0, file, line ); + okx ( memcmp ( pixbuf->data, test->data, test->len ) == 0, + file, line ); pixbuf_put ( pixbuf ); } diff --git a/src/tests/pixbuf_test.h b/src/tests/pixbuf_test.h index 991c16ba3..cf3d548f9 100644 --- a/src/tests/pixbuf_test.h +++ b/src/tests/pixbuf_test.h @@ -42,7 +42,7 @@ struct pixel_buffer_test { .refcnt = REF_INIT ( ref_no_free ), \ .name = #_name, \ .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \ - .data = ( userptr_t ) ( _name ## __file ), \ + .data = _name ## __file, \ .len = sizeof ( _name ## __file ), \ }; \ static struct pixel_buffer_test _name = { \ -- cgit v1.2.3-55-g7522 From a169d73593f6c471857a694edc22809608c7d9c0 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 14:33:57 +0100 Subject: [uaccess] Reduce scope of included uaccess.h header The uaccess.h header is no longer required for any code that touches external ("user") memory, since such memory accesses are now performed through pointer dereferences. Reduce the number of files including this header. Signed-off-by: Michael Brown --- src/arch/x86/image/elfboot.c | 1 + src/arch/x86/image/pxe_image.c | 1 - src/arch/x86/interface/pxe/pxe_file.c | 1 - src/core/cachedhcp.c | 1 + src/core/downloader.c | 1 - src/core/fbcon.c | 1 + src/core/image.c | 1 + src/drivers/bus/ecam.c | 1 - src/hci/commands/image_mem_cmd.c | 1 + src/image/elf.c | 1 + src/include/ipxe/dhcp.h | 1 - src/include/ipxe/image.h | 1 - src/include/ipxe/iomap.h | 1 - src/include/ipxe/iomap_virt.h | 1 + src/include/ipxe/xen.h | 1 - src/interface/efi/efi_cmdline.c | 1 + src/net/pccrc.c | 1 - src/usr/imgtrust.c | 1 - 18 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/image/elfboot.c b/src/arch/x86/image/elfboot.c index f662e366f..7f89e8b65 100644 --- a/src/arch/x86/image/elfboot.c +++ b/src/arch/x86/image/elfboot.c @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include /** * @file diff --git a/src/arch/x86/image/pxe_image.c b/src/arch/x86/image/pxe_image.c index 3e6cf7268..ccb3a7d9d 100644 --- a/src/arch/x86/image/pxe_image.c +++ b/src/arch/x86/image/pxe_image.c @@ -34,7 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include diff --git a/src/arch/x86/interface/pxe/pxe_file.c b/src/arch/x86/interface/pxe/pxe_file.c index b934e8fef..997667ccf 100644 --- a/src/arch/x86/interface/pxe/pxe_file.c +++ b/src/arch/x86/interface/pxe/pxe_file.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index 1510f3321..eeb2fca58 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** @file diff --git a/src/core/downloader.c b/src/core/downloader.c index 9950fe5e4..1c638f502 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -31,7 +31,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include diff --git a/src/core/fbcon.c b/src/core/fbcon.c index 43f73fbac..ef158aec7 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/core/image.c b/src/core/image.c index a06466b72..b2bd0956b 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 35556a8d9..976254c18 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include /** @file diff --git a/src/hci/commands/image_mem_cmd.c b/src/hci/commands/image_mem_cmd.c index 5f8363461..fcd766627 100644 --- a/src/hci/commands/image_mem_cmd.c +++ b/src/hci/commands/image_mem_cmd.c @@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #include #include #include diff --git a/src/image/elf.c b/src/image/elf.c index 97e07f37f..8cbb610a6 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h index 51349efd9..4d68d3ca5 100644 --- a/src/include/ipxe/dhcp.h +++ b/src/include/ipxe/dhcp.h @@ -17,7 +17,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include struct interface; struct dhcp_options; diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index fbf2b63b9..e0e70f360 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include struct uri; diff --git a/src/include/ipxe/iomap.h b/src/include/ipxe/iomap.h index b8ded38ef..7d1547d9c 100644 --- a/src/include/ipxe/iomap.h +++ b/src/include/ipxe/iomap.h @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include /** * Calculate static inline I/O mapping API function name diff --git a/src/include/ipxe/iomap_virt.h b/src/include/ipxe/iomap_virt.h index 731d083d5..3dd66bd75 100644 --- a/src/include/ipxe/iomap_virt.h +++ b/src/include/ipxe/iomap_virt.h @@ -10,6 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include +#include #ifdef IOMAP_VIRT #define IOMAP_PREFIX_virt diff --git a/src/include/ipxe/xen.h b/src/include/ipxe/xen.h index 0fb8b7625..382901ff3 100644 --- a/src/include/ipxe/xen.h +++ b/src/include/ipxe/xen.h @@ -14,7 +14,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include #include diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index d5ec6cee3..8b9d8efde 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include diff --git a/src/net/pccrc.c b/src/net/pccrc.c index 29adc4b16..0db6e3cb5 100644 --- a/src/net/pccrc.c +++ b/src/net/pccrc.c @@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include #include #include #include diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c index 4eb631e79..e60854c9f 100644 --- a/src/usr/imgtrust.c +++ b/src/usr/imgtrust.c @@ -28,7 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include -- cgit v1.2.3-55-g7522 From 1534b0a6e9545d3a75ef6ca7cf0e4d89704582a2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Apr 2025 16:07:04 +0100 Subject: [uaccess] Remove redundant virt_to_user() and userptr_t Remove the last remaining traces of the concept of a user pointer, leaving iPXE with a simpler and cleaner memory model that implicitly assumes that all memory locations can be reached through pointer dereferences. Signed-off-by: Michael Brown --- src/arch/x86/include/librm.h | 5 ---- src/arch/x86/transitions/librm_mgmt.c | 1 - src/core/uaccess.c | 1 - src/include/ipxe/linux/linux_uaccess.h | 8 ------- src/include/ipxe/uaccess.h | 42 ---------------------------------- src/interface/linux/linux_uaccess.c | 1 - 6 files changed, 58 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h index 22b7e3933..4fce7e8c8 100644 --- a/src/arch/x86/include/librm.h +++ b/src/arch/x86/include/librm.h @@ -126,11 +126,6 @@ UACCESS_INLINE ( librm, virt_to_phys ) ( volatile const void *virt ) { return ( addr + virt_offset ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) { - return trivial_virt_to_user ( addr ); -} - /****************************************************************************** * * Access to variables in .data16 and .text16 diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index da5055cd8..14e00eda8 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -431,7 +431,6 @@ void setup_sipi ( unsigned int vector, uint32_t handler, PROVIDE_UACCESS_INLINE ( librm, phys_to_virt ); PROVIDE_UACCESS_INLINE ( librm, virt_to_phys ); -PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); PROVIDE_IOMAP_INLINE ( pages, io_to_bus ); PROVIDE_IOMAP ( pages, ioremap, ioremap_pages ); PROVIDE_IOMAP ( pages, iounmap, iounmap_pages ); diff --git a/src/core/uaccess.c b/src/core/uaccess.c index bf922f66d..e73f4d7fb 100644 --- a/src/core/uaccess.c +++ b/src/core/uaccess.c @@ -34,4 +34,3 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* Flat address space user access API */ PROVIDE_UACCESS_INLINE ( flat, phys_to_virt ); PROVIDE_UACCESS_INLINE ( flat, virt_to_phys ); -PROVIDE_UACCESS_INLINE ( flat, virt_to_user ); diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 7d5f5f642..a5d7d73f3 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -5,9 +5,6 @@ * * iPXE user access API for Linux * - * We run with no distinction between internal and external addresses, - * so can use trivial_virt_to_user() et al. - * * We have no concept of the underlying physical addresses, since * these are not exposed to userspace. We provide a stub * implementation of virt_to_phys() since this is required by @@ -57,9 +54,4 @@ UACCESS_INLINE ( linux, phys_to_virt ) ( physaddr_t phys ) { return ( ( void * ) phys ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( linux, virt_to_user ) ( volatile const void *addr ) { - return trivial_virt_to_user ( addr ); -} - #endif /* _IPXE_LINUX_UACCESS_H */ diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index 82f29f793..8d93cbf4f 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -20,35 +20,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define UACCESS_PREFIX_flat __flat_ #endif -/** - * A pointer to a user buffer - * - */ -typedef void * userptr_t; - -/** - * @defgroup uaccess_trivial Trivial user access API implementations - * - * User access API implementations that can be used by environments in - * which virtual addresses allow access to all of memory. - * - * @{ - * - */ - -/** - * Convert virtual address to user pointer - * - * @v addr Virtual address - * @ret userptr User pointer - */ -static inline __always_inline userptr_t -trivial_virt_to_user ( volatile const void *addr ) { - return ( ( userptr_t ) addr ); -} - -/** @} */ - /** * Calculate static inline user access API function name * @@ -88,25 +59,12 @@ UACCESS_INLINE ( flat, virt_to_phys ) ( volatile const void *virt ) { return ( ( physaddr_t ) virt ); } -static inline __always_inline userptr_t -UACCESS_INLINE ( flat, virt_to_user ) ( volatile const void *addr ) { - return trivial_virt_to_user ( addr ); -} - /* Include all architecture-independent user access API headers */ #include /* Include all architecture-dependent user access API headers */ #include -/** - * Convert virtual address to user pointer - * - * @v addr Virtual address - * @ret userptr User pointer - */ -userptr_t virt_to_user ( volatile const void *addr ); - /** * Convert virtual address to a physical address * diff --git a/src/interface/linux/linux_uaccess.c b/src/interface/linux/linux_uaccess.c index 436707757..7f7f8931b 100644 --- a/src/interface/linux/linux_uaccess.c +++ b/src/interface/linux/linux_uaccess.c @@ -29,4 +29,3 @@ FILE_LICENCE(GPL2_OR_LATER); PROVIDE_UACCESS_INLINE(linux, phys_to_virt); PROVIDE_UACCESS_INLINE(linux, virt_to_phys); -PROVIDE_UACCESS_INLINE(linux, virt_to_user); -- cgit v1.2.3-55-g7522 From 9bc559850c53eb630f9bb1089c98bae1d776d3d8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 21 May 2025 14:26:56 +0100 Subject: [fdt] Allow an initrd to be specified when creating a device tree Allow an initrd location to be specified in our constructed device tree via the "linux,initrd-start" and "linux,initrd-end" properties. Signed-off-by: Michael Brown --- src/core/fdt.c | 52 ++++++++++++++++++++++++++++++++------------- src/image/lkrn.c | 2 +- src/include/ipxe/fdt.h | 3 ++- src/interface/efi/efi_fdt.c | 2 +- 4 files changed, 41 insertions(+), 18 deletions(-) (limited to 'src/interface') diff --git a/src/core/fdt.c b/src/core/fdt.c index d20c63c31..c8ae4d949 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -1055,18 +1055,17 @@ static int fdt_ensure_child ( struct fdt *fdt, unsigned int offset, } /** - * Ensure property exists with specified value + * Set property value * * @v fdt Device tree * @v offset Starting node offset * @v name Property name - * @v data Property data + * @v data Property data, or NULL to delete property * @v len Length of property data * @ret rc Return status code */ -static int fdt_ensure_property ( struct fdt *fdt, unsigned int offset, - const char *name, const void *data, - size_t len ) { +static int fdt_set ( struct fdt *fdt, unsigned int offset, const char *name, + const void *data, size_t len ) { struct fdt_descriptor desc; struct { fdt_token_t token; @@ -1112,6 +1111,10 @@ static int fdt_ensure_property ( struct fdt *fdt, unsigned int offset, insert = ( sizeof ( *hdr ) + len ); } + /* Leave property erased if applicable */ + if ( ! data ) + return 0; + /* Insert space */ if ( ( rc = fdt_insert_nop ( fdt, desc.offset, insert ) ) != 0 ) return rc; @@ -1166,10 +1169,15 @@ static int fdt_urealloc ( struct fdt *fdt, size_t len ) { * * @v fdt Device tree * @v cmdline Command line, or NULL + * @v initrd Initial ramdisk address (or 0 for no initrd) + * @v initrd_len Initial ramdisk length (or 0 for no initrd) * @ret rc Return status code */ -static int fdt_bootargs ( struct fdt *fdt, const char *cmdline ) { +static int fdt_bootargs ( struct fdt *fdt, const char *cmdline, + physaddr_t initrd, size_t initrd_len ) { unsigned int chosen; + physaddr_t addr; + const void *data; size_t len; int rc; @@ -1177,14 +1185,25 @@ static int fdt_bootargs ( struct fdt *fdt, const char *cmdline ) { if ( ( rc = fdt_ensure_child ( fdt, 0, "chosen", &chosen ) ) != 0 ) return rc; - /* Use empty command line if none specified */ - if ( ! cmdline ) - cmdline = ""; + /* Set or clear "bootargs" property */ + len = ( cmdline ? ( strlen ( cmdline ) + 1 /* NUL */ ) : 0 ); + if ( ( rc = fdt_set ( fdt, chosen, "bootargs", cmdline, len ) ) != 0 ) + return rc; - /* Ensure "bootargs" property exists */ - len = ( strlen ( cmdline ) + 1 /* NUL */ ); - if ( ( rc = fdt_ensure_property ( fdt, chosen, "bootargs", cmdline, - len ) ) != 0 ) + /* Set or clear initrd properties */ + data = ( initrd_len ? &addr : NULL ); + len = ( initrd_len ? sizeof ( addr ) : 0 ); + addr = initrd; + addr = ( ( sizeof ( addr ) == sizeof ( uint64_t ) ) ? + cpu_to_be64 ( addr ) : cpu_to_be32 ( addr ) ); + if ( ( rc = fdt_set ( fdt, chosen, "linux,initrd-start", data, + len ) ) != 0 ) + return rc; + addr = ( initrd + initrd_len ); + addr = ( ( sizeof ( addr ) == sizeof ( uint64_t ) ) ? + cpu_to_be64 ( addr ) : cpu_to_be32 ( addr ) ); + if ( ( rc = fdt_set ( fdt, chosen, "linux,initrd-end", data, + len ) ) != 0 ) return rc; return 0; @@ -1195,9 +1214,12 @@ static int fdt_bootargs ( struct fdt *fdt, const char *cmdline ) { * * @v hdr Device tree header to fill in (may be set to NULL) * @v cmdline Command line, or NULL + * @v initrd Initial ramdisk address (or 0 for no initrd) + * @v initrd_len Initial ramdisk length (or 0 for no initrd) * @ret rc Return status code */ -int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { +int fdt_create ( struct fdt_header **hdr, const char *cmdline, + physaddr_t initrd, size_t initrd_len ) { struct image *image; struct fdt fdt; void *copy; @@ -1228,7 +1250,7 @@ int fdt_create ( struct fdt_header **hdr, const char *cmdline ) { fdt.realloc = fdt_urealloc; /* Populate boot arguments */ - if ( ( rc = fdt_bootargs ( &fdt, cmdline ) ) != 0 ) + if ( ( rc = fdt_bootargs ( &fdt, cmdline, initrd, initrd_len ) ) != 0 ) goto err_bootargs; no_fdt: diff --git a/src/image/lkrn.c b/src/image/lkrn.c index f8929f3b3..4f04c3ff6 100644 --- a/src/image/lkrn.c +++ b/src/image/lkrn.c @@ -153,7 +153,7 @@ static int lkrn_fdt ( struct image *image, struct lkrn_context *ctx ) { int rc; /* Build device tree (which may change system memory map) */ - if ( ( rc = fdt_create ( &fdt, image->cmdline ) ) != 0 ) + if ( ( rc = fdt_create ( &fdt, image->cmdline, 0, 0 ) ) != 0 ) goto err_create; len = be32_to_cpu ( fdt->totalsize ); diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index 45ae0f92b..461b09632 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -199,7 +199,8 @@ extern int fdt_mac ( struct fdt *fdt, unsigned int offset, struct net_device *netdev ); extern int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr, size_t max_len ); -extern int fdt_create ( struct fdt_header **hdr, const char *cmdline ); +extern int fdt_create ( struct fdt_header **hdr, const char *cmdline, + physaddr_t initrd, size_t initrd_len ); extern void fdt_remove ( struct fdt_header *hdr ); #endif /* _IPXE_FDT_H */ diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 1e0d4b8b7..3a90fd7ce 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -114,7 +114,7 @@ int efi_fdt_install ( const char *cmdline ) { int rc; /* Create device tree */ - if ( ( rc = fdt_create ( &efi_fdt_installed, cmdline ) ) != 0 ) { + if ( ( rc = fdt_create ( &efi_fdt_installed, cmdline, 0, 0 ) ) != 0 ) { DBGC ( &efi_fdt, "EFI_FDT could not install: %s\n", strerror ( rc ) ); goto err_create; -- cgit v1.2.3-55-g7522 From 029c7c4178d0122164770bf4a534aeb94d6c7698 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 22 May 2025 13:41:21 +0100 Subject: [initrd] Rename bzimage_align() to initrd_align() Alignment of initrd lengths is applicable to all Linux kernels, not just those in the x86 bzImage format. Signed-off-by: Michael Brown --- src/arch/x86/image/bzimage.c | 17 +++-------------- src/image/initrd.c | 18 +++++------------- src/include/ipxe/cpio.h | 3 --- src/include/ipxe/initrd.h | 15 +++++++++++++++ src/interface/efi/efi_file.c | 1 + 5 files changed, 24 insertions(+), 30 deletions(-) (limited to 'src/interface') diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c index 63de82c63..08e0d0873 100644 --- a/src/arch/x86/image/bzimage.c +++ b/src/arch/x86/image/bzimage.c @@ -316,17 +316,6 @@ static void bzimage_set_cmdline ( struct image *image, image->name, rm_cmdline ); } -/** - * Align initrd length - * - * @v len Length - * @ret len Length rounded up to INITRD_ALIGN - */ -static inline size_t bzimage_align ( size_t len ) { - - return ( ( len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); -} - /** * Load initrd * @@ -407,7 +396,7 @@ static int bzimage_check_initrds ( struct image *image, /* Calculate length */ len += bzimage_load_initrd ( image, initrd, NULL ); - len = bzimage_align ( len ); + len = initrd_align ( len ); DBGC ( image, "bzImage %s initrd %s from [%#08lx,%#08lx)%s%s\n", image->name, initrd->name, virt_to_phys ( initrd->data ), @@ -467,7 +456,7 @@ static void bzimage_load_initrds ( struct image *image, for_each_image ( initrd ) { if ( virt_to_phys ( initrd->data ) >= top ) { top = ( virt_to_phys ( initrd->data ) + - bzimage_align ( initrd->len ) ); + initrd_align ( initrd->len ) ); } } @@ -491,7 +480,7 @@ static void bzimage_load_initrds ( struct image *image, if ( other == initrd ) offset = 0; offset += bzimage_load_initrd ( image, other, NULL ); - offset = bzimage_align ( offset ); + offset = initrd_align ( offset ); } /* Load initrd at this address */ diff --git a/src/image/initrd.c b/src/image/initrd.c index 386414795..5e8735518 100644 --- a/src/image/initrd.c +++ b/src/image/initrd.c @@ -51,7 +51,6 @@ static void initrd_squash_high ( physaddr_t top ) { struct image *initrd; struct image *highest; void *data; - size_t len; /* Squash up any initrds already within or below the region */ while ( 1 ) { @@ -70,9 +69,7 @@ static void initrd_squash_high ( physaddr_t top ) { break; /* Move this image to its final position */ - len = ( ( highest->len + INITRD_ALIGN - 1 ) & - ~( INITRD_ALIGN - 1 ) ); - current -= len; + current -= initrd_align ( highest->len ); DBGC ( &images, "INITRD squashing %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", highest->name, virt_to_phys ( highest->data ), @@ -86,9 +83,7 @@ static void initrd_squash_high ( physaddr_t top ) { /* Copy any remaining initrds (e.g. embedded images) to the region */ for_each_image ( initrd ) { if ( virt_to_phys ( initrd->data ) >= top ) { - len = ( ( initrd->len + INITRD_ALIGN - 1 ) & - ~( INITRD_ALIGN - 1 ) ); - current -= len; + current -= initrd_align ( initrd->len ); DBGC ( &images, "INITRD copying %s [%#08lx,%#08lx)->" "[%#08lx,%#08lx)\n", initrd->name, virt_to_phys ( initrd->data ), @@ -139,8 +134,8 @@ static void initrd_swap ( struct image *low, struct image *high ) { ( virt_to_phys ( high->data ) + high->len ), high->name ); /* Calculate padded lengths */ - low_len = ( ( low->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); - high_len = ( ( high->len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 )); + low_len = initrd_align ( low->len ); + high_len = initrd_align ( high->len ); len = ( low_len + high_len ); data = low->rwdata; assert ( high->data == ( data + low_len ) ); @@ -165,15 +160,12 @@ static int initrd_swap_any ( void ) { struct image *low; struct image *high; const void *adjacent; - size_t padded_len; /* Find any pair of initrds that can be swapped */ for_each_image ( low ) { /* Calculate location of adjacent image (if any) */ - padded_len = ( ( low->len + INITRD_ALIGN - 1 ) & - ~( INITRD_ALIGN - 1 ) ); - adjacent = ( low->data + padded_len ); + adjacent = ( low->data + initrd_align ( low->len ) ); /* Search for adjacent image */ for_each_image ( high ) { diff --git a/src/include/ipxe/cpio.h b/src/include/ipxe/cpio.h index c45c12b11..744dbd269 100644 --- a/src/include/ipxe/cpio.h +++ b/src/include/ipxe/cpio.h @@ -60,9 +60,6 @@ struct cpio_header { /** CPIO header length alignment */ #define CPIO_ALIGN 4 -/** Alignment for CPIO archives within an initrd */ -#define INITRD_ALIGN 4096 - /** * Get CPIO image name * diff --git a/src/include/ipxe/initrd.h b/src/include/ipxe/initrd.h index 0b0ba0967..10533b53b 100644 --- a/src/include/ipxe/initrd.h +++ b/src/include/ipxe/initrd.h @@ -14,4 +14,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); extern void initrd_reshuffle ( physaddr_t bottom ); extern int initrd_reshuffle_check ( size_t len, physaddr_t bottom ); +/** Initial ramdisk chunk alignment */ +#define INITRD_ALIGN 4096 + +/** + * Align initrd length + * + * @v len Length + * @ret len Aligned length + */ +static inline __attribute__ (( always_inline )) size_t +initrd_align ( size_t len ) { + + return ( ( len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); +} + #endif /* _IPXE_INITRD_H */ diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 79330641d..1909dea10 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -39,6 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include -- cgit v1.2.3-55-g7522 From 22de0c4edf2fe1cdbca5e22c52c86a2289d04816 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 8 Jul 2025 12:38:05 +0100 Subject: [dma] Use virtual addresses for dma_map() Cache management operations must generally be performed on virtual addresses rather than physical addresses. Change the address parameter in dma_map() to be a virtual address, and make dma() the API-level primitive instead of dma_phys(). Signed-off-by: Michael Brown --- src/core/dma.c | 6 +++--- src/drivers/net/intelxl.c | 4 ++-- src/include/ipxe/dma.h | 42 +++++++++++++----------------------------- src/include/ipxe/iobuf.h | 3 +-- src/interface/efi/efi_pci.c | 19 ++++++++++--------- 5 files changed, 29 insertions(+), 45 deletions(-) (limited to 'src/interface') diff --git a/src/core/dma.c b/src/core/dma.c index cf4b20379..cbc9b8d10 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -47,7 +47,7 @@ PROVIDE_DMAAPI_INLINE ( flat, dma_free ); PROVIDE_DMAAPI_INLINE ( flat, dma_umalloc ); PROVIDE_DMAAPI_INLINE ( flat, dma_ufree ); PROVIDE_DMAAPI_INLINE ( flat, dma_set_mask ); -PROVIDE_DMAAPI_INLINE ( flat, dma_phys ); +PROVIDE_DMAAPI_INLINE ( flat, dma ); /****************************************************************************** * @@ -67,7 +67,7 @@ PROVIDE_DMAAPI_INLINE ( flat, dma_phys ); * @ret rc Return status code */ static int dma_op_map ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ) { + void *addr, size_t len, int flags ) { struct dma_operations *op = dma->op; if ( ! op ) @@ -175,4 +175,4 @@ PROVIDE_DMAAPI ( op, dma_free, dma_op_free ); PROVIDE_DMAAPI ( op, dma_umalloc, dma_op_umalloc ); PROVIDE_DMAAPI ( op, dma_ufree, dma_op_ufree ); PROVIDE_DMAAPI ( op, dma_set_mask, dma_op_set_mask ); -PROVIDE_DMAAPI_INLINE ( op, dma_phys ); +PROVIDE_DMAAPI_INLINE ( op, dma ); diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 82b07833c..1d4c22a09 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -65,8 +65,8 @@ int intelxl_msix_enable ( struct intelxl_nic *intelxl, /* Map dummy target location */ if ( ( rc = dma_map ( intelxl->dma, &intelxl->msix.map, - virt_to_phys ( &intelxl->msix.msg ), - sizeof ( intelxl->msix.msg ), DMA_RX ) ) != 0 ) { + &intelxl->msix.msg, sizeof ( intelxl->msix.msg ), + DMA_RX ) ) != 0 ) { DBGC ( intelxl, "INTELXL %p could not map MSI-X target: %s\n", intelxl, strerror ( rc ) ); goto err_map; diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index 6e5c43289..d450ef523 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -68,7 +68,7 @@ struct dma_operations { * @ret rc Return status code */ int ( * map ) ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ); + void *addr, size_t len, int flags ); /** * Unmap buffer * @@ -178,8 +178,7 @@ struct dma_operations { */ static inline __always_inline int DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma, - struct dma_mapping *map, - physaddr_t addr __unused, + struct dma_mapping *map, void *addr __unused, size_t len __unused, int flags __unused ) { /* Increment mapping count (for debugging) */ @@ -319,32 +318,31 @@ DMAAPI_INLINE ( flat, dma_set_mask ) ( struct dma_device *dma __unused, } /** - * Get DMA address from physical address + * Get DMA address from virtual address * * @v map DMA mapping - * @v addr Physical address within the mapped region + * @v addr Address within the mapped region * @ret addr Device-side DMA address */ static inline __always_inline physaddr_t -DMAAPI_INLINE ( flat, dma_phys ) ( struct dma_mapping *map __unused, - physaddr_t addr ) { +DMAAPI_INLINE ( flat, dma ) ( struct dma_mapping *map __unused, void *addr ) { /* Use physical address as device address */ - return addr; + return virt_to_phys ( addr ); } /** - * Get DMA address from physical address + * Get DMA address from virtual address * * @v map DMA mapping - * @v addr Physical address within the mapped region + * @v addr Address within the mapped region * @ret addr Device-side DMA address */ static inline __always_inline physaddr_t -DMAAPI_INLINE ( op, dma_phys ) ( struct dma_mapping *map, physaddr_t addr ) { +DMAAPI_INLINE ( op, dma ) ( struct dma_mapping *map, void *addr ) { /* Adjust physical address using mapping offset */ - return ( addr + map->offset ); + return ( virt_to_phys ( addr ) + map->offset ); } /** @@ -358,7 +356,7 @@ DMAAPI_INLINE ( op, dma_phys ) ( struct dma_mapping *map, physaddr_t addr ) { * @ret rc Return status code */ int dma_map ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ); + void *addr, size_t len, int flags ); /** * Unmap buffer @@ -417,28 +415,14 @@ void dma_ufree ( struct dma_mapping *map, void *addr, size_t len ); */ void dma_set_mask ( struct dma_device *dma, physaddr_t mask ); -/** - * Get DMA address from physical address - * - * @v map DMA mapping - * @v addr Physical address within the mapped region - * @ret addr Device-side DMA address - */ -physaddr_t dma_phys ( struct dma_mapping *map, physaddr_t addr ); - /** * Get DMA address from virtual address * * @v map DMA mapping - * @v addr Virtual address within the mapped region + * @v addr Address within the mapped region * @ret addr Device-side DMA address */ -static inline __always_inline physaddr_t dma ( struct dma_mapping *map, - void *addr ) { - - /* Get DMA address from corresponding physical address */ - return dma_phys ( map, virt_to_phys ( addr ) ); -} +physaddr_t dma ( struct dma_mapping *map, void *addr ); /** * Check if DMA unmapping is required diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index 2bdca6b5d..df8d0b854 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -230,8 +230,7 @@ static inline void iob_populate ( struct io_buffer *iobuf, static inline __always_inline int iob_map ( struct io_buffer *iobuf, struct dma_device *dma, size_t len, int flags ) { - return dma_map ( dma, &iobuf->map, virt_to_phys ( iobuf->data ), - len, flags ); + return dma_map ( dma, &iobuf->map, iobuf->data, len, flags ); } /** diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 1b1f05816..ae0ec4264 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -455,7 +455,7 @@ PROVIDE_PCIAPI ( efi, pci_ioremap, efipci_ioremap ); * @ret rc Return status code */ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, - physaddr_t addr, size_t len, int flags ) { + void *addr, size_t len, int flags ) { struct efi_pci_device *efipci = container_of ( dma, struct efi_pci_device, pci.dma ); struct pci_device *pci = &efipci->pci; @@ -464,6 +464,7 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, EFI_PHYSICAL_ADDRESS bus; UINTN count; VOID *mapping; + physaddr_t phys; EFI_STATUS efirc; int rc; @@ -486,18 +487,19 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, } /* Map buffer (if non-zero length) */ + phys = virt_to_phys ( addr ); count = len; if ( len ) { - if ( ( efirc = pci_io->Map ( pci_io, op, phys_to_virt ( addr ), - &count, &bus, &mapping ) ) != 0 ) { + if ( ( efirc = pci_io->Map ( pci_io, op, addr, &count, &bus, + &mapping ) ) != 0 ) { rc = -EEFI ( efirc ); - DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %08lx+%zx: " + DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %p+%zx: " "%s\n", PCI_ARGS ( pci ), addr, len, strerror ( rc ) ); goto err_map; } } else { - bus = addr; + bus = phys; mapping = NULL; } @@ -508,14 +510,14 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, */ if ( count != len ) { DBGC ( pci, "EFIPCI " PCI_FMT " attempted split mapping for " - "%08lx+%zx\n", PCI_ARGS ( pci ), addr, len ); + "%p+%zx\n", PCI_ARGS ( pci ), addr, len ); rc = -ENOTSUP; goto err_len; } /* Populate mapping */ map->dma = dma; - map->offset = ( bus - addr ); + map->offset = ( bus - phys ); map->token = mapping; /* Increment mapping count (for debugging) */ @@ -594,8 +596,7 @@ static void * efipci_dma_alloc ( struct dma_device *dma, memset ( addr, 0, ( pages * EFI_PAGE_SIZE ) ); /* Map buffer */ - if ( ( rc = efipci_dma_map ( dma, map, virt_to_phys ( addr ), - ( pages * EFI_PAGE_SIZE ), + if ( ( rc = efipci_dma_map ( dma, map, addr, ( pages * EFI_PAGE_SIZE ), DMA_BI ) ) != 0 ) goto err_map; -- cgit v1.2.3-55-g7522 From bbabde8ff8182fcef738893c29a698783758a489 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 10 Jul 2025 14:33:34 +0100 Subject: [riscv] Invalidate data cache on completed RX DMA buffers The data cache must be invalidated twice for RX DMA buffers: once before passing ownership to the DMA device (in case the cache happens to contain dirty data that will be written back at an undefined future point), and once after receiving ownership from the DMA device (in case the CPU happens to have speculatively accessed data in the buffer while it was owned by the hardware). Only the used portion of the buffer needs to be invalidated after completion, since we do not care about data within the unused portion. Update the DMA API to include the used length as an additional parameter to dma_unmap(), and add the necessary second cache invalidation pass to the RISC-V DMA API implementation. Signed-off-by: Michael Brown --- src/arch/riscv/core/riscv_dma.c | 52 +++++++++++++++++++++++++++++---- src/arch/riscv/include/ipxe/riscv_dma.h | 11 ------- src/core/dma.c | 5 ++-- src/drivers/net/intelxl.c | 4 +-- src/include/ipxe/dma.h | 11 +++++-- src/include/ipxe/iobuf.h | 2 +- src/interface/efi/efi_pci.c | 7 +++-- 7 files changed, 65 insertions(+), 27 deletions(-) (limited to 'src/interface') diff --git a/src/arch/riscv/core/riscv_dma.c b/src/arch/riscv/core/riscv_dma.c index d215fba2c..ab88f2785 100644 --- a/src/arch/riscv/core/riscv_dma.c +++ b/src/arch/riscv/core/riscv_dma.c @@ -44,24 +44,57 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @v flags Mapping flags * @ret rc Return status code */ -static int riscv_dma_map ( struct dma_device *dma __unused, - struct dma_mapping *map __unused, +static int riscv_dma_map ( struct dma_device *dma, + struct dma_mapping *map, void *addr, size_t len, int flags ) { /* Sanity check: we cannot support bidirectional mappings */ assert ( ! ( ( flags & DMA_TX ) & ( flags & DMA_RX ) ) ); + /* Populate mapping */ + map->dma = dma; + map->offset = 0; + map->token = NULL; + /* Flush cached data to transmit buffers */ if ( flags & DMA_TX ) cache_clean ( addr, len ); - /* Invalidate cached data in receive buffers */ - if ( flags & DMA_RX ) + /* Invalidate cached data in receive buffers and record address */ + if ( flags & DMA_RX ) { cache_invalidate ( addr, len ); + map->token = addr; + } + + /* Increment mapping count (for debugging) */ + if ( DBG_LOG ) + dma->mapped++; return 0; } +/** + * Unmap buffer + * + * @v map DMA mapping + * @v len Used length + */ +static void riscv_dma_unmap ( struct dma_mapping *map, size_t len ) { + struct dma_device *dma = map->dma; + void *addr = map->token; + + /* Invalidate cached data in receive buffers */ + if ( addr ) + cache_invalidate ( addr, len ); + + /* Clear mapping */ + map->dma = NULL; + + /* Decrement mapping count (for debugging) */ + if ( DBG_LOG ) + dma->mapped--; +} + /** * Allocate and map DMA-coherent buffer * @@ -98,6 +131,10 @@ static void * riscv_dma_alloc ( struct dma_device *dma, DBGC ( dma, "DMA allocated [%#08lx,%#08lx) via %p\n", phys, ( phys + len ), caddr ); + /* Increment allocation count (for debugging) */ + if ( DBG_LOG ) + dma->allocated++; + return caddr; } @@ -111,6 +148,7 @@ static void * riscv_dma_alloc ( struct dma_device *dma, */ static void riscv_dma_free ( struct dma_mapping *map, void *addr, size_t len ) { + struct dma_device *dma = map->dma; /* Sanity check */ assert ( virt_to_phys ( addr ) == virt_to_phys ( map->token ) ); @@ -121,10 +159,14 @@ static void riscv_dma_free ( struct dma_mapping *map, /* Clear mapping */ map->dma = NULL; map->token = NULL; + + /* Decrement allocation count (for debugging) */ + if ( DBG_LOG ) + dma->allocated--; } PROVIDE_DMAAPI ( riscv, dma_map, riscv_dma_map ); -PROVIDE_DMAAPI_INLINE ( riscv, dma_unmap ); +PROVIDE_DMAAPI ( riscv, dma_unmap, riscv_dma_unmap ); PROVIDE_DMAAPI ( riscv, dma_alloc, riscv_dma_alloc ); PROVIDE_DMAAPI ( riscv, dma_free, riscv_dma_free ); PROVIDE_DMAAPI ( riscv, dma_umalloc, riscv_dma_alloc ); diff --git a/src/arch/riscv/include/ipxe/riscv_dma.h b/src/arch/riscv/include/ipxe/riscv_dma.h index 568f28afe..d35904d88 100644 --- a/src/arch/riscv/include/ipxe/riscv_dma.h +++ b/src/arch/riscv/include/ipxe/riscv_dma.h @@ -15,17 +15,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define DMAAPI_PREFIX_riscv __riscv_ #endif -/** - * Unmap buffer - * - * @v map DMA mapping - */ -static inline __always_inline void -DMAAPI_INLINE ( riscv, dma_unmap ) ( struct dma_mapping *map __unused ) { - - /* Nothing to do */ -} - /** * Set addressable space mask * diff --git a/src/core/dma.c b/src/core/dma.c index cbc9b8d10..3f3023c4d 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -79,13 +79,14 @@ static int dma_op_map ( struct dma_device *dma, struct dma_mapping *map, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ -static void dma_op_unmap ( struct dma_mapping *map ) { +static void dma_op_unmap ( struct dma_mapping *map, size_t len ) { struct dma_device *dma = map->dma; assert ( dma != NULL ); assert ( dma->op != NULL ); - dma->op->unmap ( dma, map ); + dma->op->unmap ( dma, map, len ); } /** diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 1d4c22a09..31a3e2577 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -90,7 +90,7 @@ int intelxl_msix_enable ( struct intelxl_nic *intelxl, pci_msix_disable ( pci, &intelxl->msix.cap ); err_enable: - dma_unmap ( &intelxl->msix.map ); + dma_unmap ( &intelxl->msix.map, sizeof ( intelxl->msix.msg ) ); err_map: return rc; } @@ -112,7 +112,7 @@ void intelxl_msix_disable ( struct intelxl_nic *intelxl, pci_msix_disable ( pci, &intelxl->msix.cap ); /* Unmap dummy target location */ - dma_unmap ( &intelxl->msix.map ); + dma_unmap ( &intelxl->msix.map, sizeof ( intelxl->msix.msg ) ); } /****************************************************************************** diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index b675df212..a6e41c1ab 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -74,8 +74,10 @@ struct dma_operations { * * @v dma DMA device * @v map DMA mapping + * @v len Used length */ - void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map ); + void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map, + size_t len ); /** * Allocate and map DMA-coherent buffer * @@ -194,9 +196,11 @@ DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ static inline __always_inline void -DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map ) { +DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map, + size_t len __unused ) { /* Decrement mapping count (for debugging) */ if ( DBG_LOG ) { @@ -365,8 +369,9 @@ int dma_map ( struct dma_device *dma, struct dma_mapping *map, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ -void dma_unmap ( struct dma_mapping *map ); +void dma_unmap ( struct dma_mapping *map, size_t len ); /** * Allocate and map DMA-coherent buffer diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index df8d0b854..46b350458 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -276,7 +276,7 @@ static inline __always_inline physaddr_t iob_dma ( struct io_buffer *iobuf ) { * @ret rc Return status code */ static inline __always_inline void iob_unmap ( struct io_buffer *iobuf ) { - dma_unmap ( &iobuf->map ); + dma_unmap ( &iobuf->map, iob_len ( iobuf ) ); } extern struct io_buffer * __malloc alloc_iob_raw ( size_t len, size_t align, diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index ae0ec4264..fbf06300b 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -537,9 +537,10 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map, * * @v dma DMA device * @v map DMA mapping + * @v len Used length */ static void efipci_dma_unmap ( struct dma_device *dma, - struct dma_mapping *map ) { + struct dma_mapping *map, size_t len __unused ) { struct efi_pci_device *efipci = container_of ( dma, struct efi_pci_device, pci.dma ); EFI_PCI_IO_PROTOCOL *pci_io = efipci->io; @@ -606,7 +607,7 @@ static void * efipci_dma_alloc ( struct dma_device *dma, return addr; - efipci_dma_unmap ( dma, map ); + efipci_dma_unmap ( dma, map, len ); err_map: pci_io->FreeBuffer ( pci_io, pages, addr ); err_alloc: @@ -632,7 +633,7 @@ static void efipci_dma_free ( struct dma_device *dma, struct dma_mapping *map, pages = ( ( len + EFI_PAGE_SIZE - 1 ) / EFI_PAGE_SIZE ); /* Unmap buffer */ - efipci_dma_unmap ( dma, map ); + efipci_dma_unmap ( dma, map, len ); /* Free buffer */ pci_io->FreeBuffer ( pci_io, pages, addr ); -- cgit v1.2.3-55-g7522 From c01c3215dcff1be62347db794dddc1e33c219887 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 14 Jul 2025 12:15:08 +0100 Subject: [efi] Provide efi_tpl_name() for transcribing TPLs in debug messages Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 2 ++ src/interface/efi/efi_debug.c | 21 +++++++++++++++++++++ src/interface/efi/efi_wrap.c | 35 +++++++---------------------------- 3 files changed, 30 insertions(+), 28 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 29c292f36..03081f6f4 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -273,6 +273,8 @@ extern int efi_shutdown_in_progress; extern const __attribute__ (( pure )) char * efi_guid_ntoa ( CONST EFI_GUID *guid ); extern const __attribute__ (( pure )) char * +efi_tpl_name ( EFI_TPL tpl ); +extern const __attribute__ (( pure )) char * efi_locate_search_type_name ( EFI_LOCATE_SEARCH_TYPE search_type ); extern const __attribute__ (( pure )) char * efi_open_attributes_name ( unsigned int attributes ); diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 026adc25e..067899a72 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -46,6 +46,27 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt; EFI_REQUEST_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt ); +/** + * Name EFI TPL + * + * @v tpl Task priority level + * @ret text Task priority level as text + */ +const __attribute__ (( pure )) char * efi_tpl_name ( EFI_TPL tpl ) { + static char buf[ 19 /* "0xXXXXXXXXXXXXXXXX" + NUL */ ]; + + switch ( tpl ) { + case TPL_APPLICATION: return "Application"; + case TPL_CALLBACK: return "Callback"; + case TPL_NOTIFY: return "Notify"; + case TPL_HIGH_LEVEL: return "HighLevel"; + default: + snprintf ( buf, sizeof ( buf ), "%#lx", + ( unsigned long ) tpl ); + return buf; + } +} + /** * Name locate search type * diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index a806a7c60..8c3f41e3b 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -120,27 +120,6 @@ static const char * efi_boolean ( BOOLEAN boolean ) { return ( boolean ? "TRUE" : "FALSE" ); } -/** - * Convert EFI TPL to text - * - * @v tpl Task priority level - * @ret text Task priority level as text - */ -static const char * efi_tpl ( EFI_TPL tpl ) { - static char buf[ 19 /* "0xXXXXXXXXXXXXXXXX" + NUL */ ]; - - switch ( tpl ) { - case TPL_APPLICATION: return "Application"; - case TPL_CALLBACK: return "Callback"; - case TPL_NOTIFY: return "Notify"; - case TPL_HIGH_LEVEL: return "HighLevel"; - default: - snprintf ( buf, sizeof ( buf ), "%#lx", - ( unsigned long ) tpl ); - return buf; - } -} - /** * Convert EFI allocation type to text * @@ -281,9 +260,9 @@ efi_raise_tpl_wrapper ( EFI_TPL new_tpl ) { void *retaddr = __builtin_return_address ( 0 ); EFI_TPL old_tpl; - DBGCP ( colour, "RaiseTPL ( %s ) ", efi_tpl ( new_tpl ) ); + DBGCP ( colour, "RaiseTPL ( %s ) ", efi_tpl_name ( new_tpl ) ); old_tpl = bs->RaiseTPL ( new_tpl ); - DBGCP ( colour, "= %s -> %p\n", efi_tpl ( old_tpl ), retaddr ); + DBGCP ( colour, "= %s -> %p\n", efi_tpl_name ( old_tpl ), retaddr ); return old_tpl; } @@ -296,7 +275,7 @@ efi_restore_tpl_wrapper ( EFI_TPL old_tpl ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; void *retaddr = __builtin_return_address ( 0 ); - DBGCP ( colour, "RestoreTPL ( %s ) ", efi_tpl ( old_tpl ) ); + DBGCP ( colour, "RestoreTPL ( %s ) ", efi_tpl_name ( old_tpl ) ); bs->RestoreTPL ( old_tpl ); DBGCP ( colour, "-> %p\n", retaddr ); } @@ -433,8 +412,8 @@ efi_create_event_wrapper ( UINT32 type, EFI_TPL notify_tpl, void *retaddr = __builtin_return_address ( 0 ); EFI_STATUS efirc; - DBGC ( colour, "CreateEvent ( %#x, %s, %p, %p ) ", - type, efi_tpl ( notify_tpl ), notify_function, notify_context ); + DBGC ( colour, "CreateEvent ( %#x, %s, %p, %p ) ", type, + efi_tpl_name ( notify_tpl ), notify_function, notify_context ); efirc = bs->CreateEvent ( type, notify_tpl, notify_function, notify_context, event ); DBGC ( colour, "= %s ( %p ) -> %p\n", @@ -1207,8 +1186,8 @@ efi_create_event_ex_wrapper ( UINT32 type, EFI_TPL notify_tpl, EFI_STATUS efirc; DBGC ( colour, "CreateEventEx ( %#x, %s, %p, %p, %s ) ", - type, efi_tpl ( notify_tpl ), notify_function, notify_context, - efi_guid_ntoa ( event_group ) ); + type, efi_tpl_name ( notify_tpl ), notify_function, + notify_context, efi_guid_ntoa ( event_group ) ); efirc = bs->CreateEventEx ( type, notify_tpl, notify_function, notify_context, event_group, event ); DBGC ( colour, "= %s ( %p ) -> %p\n", -- cgit v1.2.3-55-g7522 From c3376f86457120e360161ce19e6862f31980c2f2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 14 Jul 2025 12:17:11 +0100 Subject: [efi] Drop to external TPL for calls to ConnectController() There is nothing in the current versions of the UEFI specification that limits the TPL at which we may call ConnectController() or DisconnectController(). However, at least some platforms (observed with a Lenovo ThinkPad T14s Gen 5) will occasionally and unpredictably lock up before returning from ConnectController() if called at a TPL higher than TPL_APPLICATION. Work around whatever defect is present on these systems by dropping to the current external TPL for all calls to ConnectController() or DisconnectController(). Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 2 + src/include/ipxe/errfile.h | 1 + src/interface/efi/efi_block.c | 6 +-- src/interface/efi/efi_connect.c | 110 ++++++++++++++++++++++++++++++++++++++++ src/interface/efi/efi_driver.c | 38 +++----------- src/interface/efi/efi_usb.c | 5 +- src/interface/efi/efi_veto.c | 4 +- 7 files changed, 125 insertions(+), 41 deletions(-) create mode 100644 src/interface/efi/efi_connect.c (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 03081f6f4..33278abed 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -413,6 +413,8 @@ extern int efi_open_by_child_untyped ( EFI_HANDLE handle, EFI_GUID *protocol, EFI_HANDLE child, void **interface ); extern void efi_close_by_child ( EFI_HANDLE handle, EFI_GUID *protocol, EFI_HANDLE child ); +extern int efi_connect ( EFI_HANDLE device, EFI_HANDLE driver ); +extern int efi_disconnect ( EFI_HANDLE device, EFI_HANDLE driver ); /** * Test protocol existence diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index eee71bfaa..0e3634f9e 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -86,6 +86,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_null_smbios ( ERRFILE_CORE | 0x002e0000 ) #define ERRFILE_efi_open ( ERRFILE_CORE | 0x002f0000 ) #define ERRFILE_efi_table ( ERRFILE_CORE | 0x00300000 ) +#define ERRFILE_efi_connect ( ERRFILE_CORE | 0x00310000 ) #define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 ) #define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 ) diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index aa5ec4e0f..cc93edb85 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -218,14 +218,10 @@ efi_block_io_flush ( EFI_BLOCK_IO_PROTOCOL *block_io ) { * @v handle Block device handle */ static void efi_block_connect ( unsigned int drive, EFI_HANDLE handle ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_STATUS efirc; int rc; /* Try to connect all possible drivers to this block device */ - if ( ( efirc = bs->ConnectController ( handle, NULL, NULL, - TRUE ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_connect ( handle, NULL ) ) != 0 ) { DBGC ( drive, "EFIBLK %#02x could not connect drivers: %s\n", drive, strerror ( rc ) ); /* May not be an error; may already be connected */ diff --git a/src/interface/efi/efi_connect.c b/src/interface/efi/efi_connect.c new file mode 100644 index 000000000..5aa8dc689 --- /dev/null +++ b/src/interface/efi/efi_connect.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2025 Michael Brown . + * + * 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. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** @file + * + * EFI driver connection and disconnection + * + */ + +#include +#include +#include + +/* Disambiguate the various error causes */ +#define EINFO_EEFI_CONNECT \ + __einfo_uniqify ( EINFO_EPLATFORM, 0x01, \ + "Could not connect controllers" ) +#define EINFO_EEFI_CONNECT_PROHIBITED \ + __einfo_platformify ( EINFO_EEFI_CONNECT, \ + EFI_SECURITY_VIOLATION, \ + "Connecting controllers prohibited by " \ + "security policy" ) +#define EEFI_CONNECT_PROHIBITED \ + __einfo_error ( EINFO_EEFI_CONNECT_PROHIBITED ) +#define EEFI_CONNECT( efirc ) EPLATFORM ( EINFO_EEFI_CONNECT, efirc, \ + EEFI_CONNECT_PROHIBITED ) + +/** + * Connect UEFI driver(s) + * + * @v device EFI device handle + * @v driver EFI driver handle, or NULL + * @ret rc Return status code + */ +int efi_connect ( EFI_HANDLE device, EFI_HANDLE driver ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE driverlist[2] = { driver, NULL }; + EFI_HANDLE *drivers = ( driver ? driverlist : NULL ); + EFI_STATUS efirc; + int rc; + + /* Attempt connection at external TPL */ + DBGC ( device, "EFI %s connecting ", efi_handle_name ( device ) ); + DBGC ( device, "%s driver at %s TPL\n", + ( driver ? efi_handle_name ( driver ) : "any" ), + efi_tpl_name ( efi_external_tpl ) ); + bs->RestoreTPL ( efi_external_tpl ); + efirc = bs->ConnectController ( device, drivers, NULL, TRUE ); + bs->RaiseTPL ( efi_internal_tpl ); + if ( efirc != 0 ) { + rc = -EEFI_CONNECT ( efirc ); + DBGC ( device, "EFI %s could not connect: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} + +/** + * Disconnect UEFI driver(s) + * + * @v device EFI device handle + * @v driver EFI driver handle, or NULL + * @ret rc Return status code + */ +int efi_disconnect ( EFI_HANDLE device, EFI_HANDLE driver ) { + EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_STATUS efirc; + int rc; + + /* Attempt disconnection at external TPL */ + DBGC ( device, "EFI %s disconnecting ", efi_handle_name ( device ) ); + DBGC ( device, "%s driver at %s TPL\n", + ( driver ? efi_handle_name ( driver ) : "any" ), + efi_tpl_name ( efi_external_tpl ) ); + bs->RestoreTPL ( efi_external_tpl ); + efirc = bs->DisconnectController ( device, driver, NULL ); + bs->RaiseTPL ( efi_internal_tpl ); + if ( ( efirc != 0 ) && ( efirc != EFI_NOT_FOUND ) ) { + rc = -EEFI ( efirc ); + DBGC ( device, "EFI %s could not disconnect: %s\n", + efi_handle_name ( device ), strerror ( rc ) ); + return rc; + } + + return 0; +} diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index ce1db228d..b1ff404be 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -39,20 +39,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); * */ -/* Disambiguate the various error causes */ -#define EINFO_EEFI_CONNECT \ - __einfo_uniqify ( EINFO_EPLATFORM, 0x01, \ - "Could not connect controllers" ) -#define EINFO_EEFI_CONNECT_PROHIBITED \ - __einfo_platformify ( EINFO_EEFI_CONNECT, \ - EFI_SECURITY_VIOLATION, \ - "Connecting controllers prohibited by " \ - "security policy" ) -#define EEFI_CONNECT_PROHIBITED \ - __einfo_error ( EINFO_EEFI_CONNECT_PROHIBITED ) -#define EEFI_CONNECT( efirc ) EPLATFORM ( EINFO_EEFI_CONNECT, efirc, \ - EEFI_CONNECT_PROHIBITED ) - static EFI_DRIVER_BINDING_PROTOCOL efi_driver_binding; /** List of controlled EFI devices */ @@ -485,9 +471,7 @@ int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { DBGC ( device, "EFIDRV %s disconnecting %s driver ", efi_handle_name ( device ), efi_guid_ntoa ( protocol ) ); DBGC ( device, "%s\n", efi_handle_name ( driver ) ); - if ( ( efirc = bs->DisconnectController ( device, driver, - NULL ) ) != 0 ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_disconnect ( device, driver ) ) != 0 ) { DBGC ( device, "EFIDRV %s could not disconnect ", efi_handle_name ( device ) ); DBGC ( device, "%s: %s\n", @@ -512,9 +496,7 @@ int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) { * @ret rc Return status code */ static int efi_driver_connect ( EFI_HANDLE device ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; - EFI_HANDLE drivers[2] = - { efi_driver_binding.DriverBindingHandle, NULL }; + EFI_HANDLE driver = efi_driver_binding.DriverBindingHandle; struct efi_driver *efidrv; EFI_STATUS efirc; int rc; @@ -553,16 +535,14 @@ static int efi_driver_connect ( EFI_HANDLE device ) { /* Connect our driver */ DBGC ( device, "EFIDRV %s connecting new drivers\n", efi_handle_name ( device ) ); - if ( ( efirc = bs->ConnectController ( device, drivers, NULL, - TRUE ) ) != 0 ) { - rc = -EEFI_CONNECT ( efirc ); + if ( ( rc = efi_connect ( device, driver ) ) != 0 ) { DBGC ( device, "EFIDRV %s could not connect new drivers: " "%s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC ( device, "EFIDRV %s connecting driver directly\n", efi_handle_name ( device ) ); if ( ( efirc = efi_driver_start ( &efi_driver_binding, device, NULL ) ) != 0 ) { - rc = -EEFI_CONNECT ( efirc ); + rc = -EEFI ( efirc ); DBGC ( device, "EFIDRV %s could not connect driver " "directly: %s\n", efi_handle_name ( device ), strerror ( rc ) ); @@ -583,14 +563,13 @@ static int efi_driver_connect ( EFI_HANDLE device ) { * @ret rc Return status code */ static int efi_driver_disconnect ( EFI_HANDLE device ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; + EFI_HANDLE driver = efi_driver_binding.DriverBindingHandle; /* Disconnect our driver */ efi_driver_disconnecting = 1; - bs->DisconnectController ( device, - efi_driver_binding.DriverBindingHandle, - NULL ); + efi_disconnect ( device, driver ); efi_driver_disconnecting = 0; + return 0; } @@ -601,10 +580,9 @@ static int efi_driver_disconnect ( EFI_HANDLE device ) { * @ret rc Return status code */ static int efi_driver_reconnect ( EFI_HANDLE device ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; /* Reconnect any available driver */ - bs->ConnectController ( device, NULL, NULL, TRUE ); + efi_connect ( device, NULL ); return 0; } diff --git a/src/interface/efi/efi_usb.c b/src/interface/efi/efi_usb.c index 28dfc8680..b09272f58 100644 --- a/src/interface/efi/efi_usb.c +++ b/src/interface/efi/efi_usb.c @@ -1198,7 +1198,7 @@ static void efi_usb_uninstall ( struct efi_usb_interface *usbintf ) { * when uninstalling protocols. */ if ( ! efi_shutdown_in_progress ) - bs->DisconnectController ( usbintf->handle, NULL, NULL ); + efi_disconnect ( usbintf->handle, NULL ); /* Uninstall protocols */ if ( ( ! efi_shutdown_in_progress ) && @@ -1260,7 +1260,6 @@ static void efi_usb_uninstall_all ( struct efi_usb_device *efiusb ) { */ static int efi_usb_probe ( struct usb_function *func, struct usb_configuration_descriptor *config ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; struct usb_device *usb = func->usb; struct efi_usb_device *usbdev; struct efi_usb_interface *usbintf; @@ -1318,7 +1317,7 @@ static int efi_usb_probe ( struct usb_function *func, /* Connect any external drivers */ list_for_each_entry ( usbintf, &usbdev->interfaces, list ) - bs->ConnectController ( usbintf->handle, NULL, NULL, TRUE ); + efi_connect ( usbintf->handle, NULL ); return 0; diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index 3f9c9940e..da585db60 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -122,9 +122,7 @@ static int efi_veto_disconnect ( struct efi_veto *veto ) { /* Disconnect driver from all handles, in reverse order */ for ( i = 0 ; i < count ; i++ ) { handle = handles[ count - i - 1 ]; - efirc = bs->DisconnectController ( handle, driver, NULL ); - if ( ( efirc != 0 ) && ( efirc != EFI_NOT_FOUND ) ) { - rc = -EEFI ( efirc ); + if ( ( rc = efi_disconnect ( handle, driver ) ) != 0 ) { DBGC ( driver, "EFIVETO %s could not disconnect", efi_handle_name ( driver ) ); DBGC ( driver, " %s: %s\n", -- cgit v1.2.3-55-g7522 From 1e3fb1b37e16cd7cd30f6b20b9eee929568f35a9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Jul 2025 14:08:15 +0100 Subject: [init] Show initialisation function names in debug messages Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid_settings.c | 1 + src/arch/x86/core/debugcon.c | 1 + src/arch/x86/core/pci_autoboot.c | 1 + src/arch/x86/core/video_subr.c | 1 + src/arch/x86/interface/pcbios/bios_cachedhcp.c | 1 + src/arch/x86/interface/pcbios/int13con.c | 1 + src/arch/x86/interface/pcbios/pcicloud.c | 1 + src/arch/x86/interface/pxe/pxe_call.c | 1 + src/arch/x86/interface/vmware/guestinfo.c | 1 + src/arch/x86/interface/vmware/vmconsole.c | 1 + src/core/acpi_settings.c | 1 + src/core/fnrec.c | 1 + src/core/init.c | 4 +++- src/core/malloc.c | 1 + src/core/memmap_settings.c | 1 + src/core/process.c | 1 + src/core/serial.c | 1 + src/core/settings.c | 1 + src/core/timer.c | 1 + src/crypto/certstore.c | 1 + src/crypto/des.c | 1 + src/crypto/x25519.c | 1 + src/drivers/bus/pci_settings.c | 1 + src/drivers/bus/usb_settings.c | 1 + src/drivers/net/efi/snponly.c | 1 + src/image/embedded.c | 1 + src/include/ipxe/init.h | 1 + src/interface/efi/efi_cacert.c | 1 + src/interface/efi/efi_console.c | 1 + src/interface/efi/efi_fdt.c | 1 + src/interface/efi/efi_settings.c | 1 + src/interface/efi/efiprefix.c | 1 + src/interface/smbios/smbios_settings.c | 1 + src/net/netdev_settings.c | 1 + src/tests/bofm_test.c | 1 + src/tests/test.c | 1 + 36 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src/interface') diff --git a/src/arch/x86/core/cpuid_settings.c b/src/arch/x86/core/cpuid_settings.c index 9bc69f477..44d38debc 100644 --- a/src/arch/x86/core/cpuid_settings.c +++ b/src/arch/x86/core/cpuid_settings.c @@ -250,6 +250,7 @@ static void cpuid_settings_init ( void ) { /** CPUID settings initialiser */ struct init_fn cpuid_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "cpuid", .initialise = cpuid_settings_init, }; diff --git a/src/arch/x86/core/debugcon.c b/src/arch/x86/core/debugcon.c index 60de61f55..0e3a5dfc7 100644 --- a/src/arch/x86/core/debugcon.c +++ b/src/arch/x86/core/debugcon.c @@ -86,5 +86,6 @@ static void debugcon_init ( void ) { * Debug port console initialisation function */ struct init_fn debugcon_init_fn __init_fn ( INIT_EARLY ) = { + .name = "debugcon", .initialise = debugcon_init, }; diff --git a/src/arch/x86/core/pci_autoboot.c b/src/arch/x86/core/pci_autoboot.c index 337598091..243e45026 100644 --- a/src/arch/x86/core/pci_autoboot.c +++ b/src/arch/x86/core/pci_autoboot.c @@ -44,5 +44,6 @@ static void pci_autoboot_init ( void ) { /** PCI autoboot device initialisation function */ struct init_fn pci_autoboot_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "autoboot", .initialise = pci_autoboot_init, }; diff --git a/src/arch/x86/core/video_subr.c b/src/arch/x86/core/video_subr.c index f5cc4cdd4..4e9ef466f 100644 --- a/src/arch/x86/core/video_subr.c +++ b/src/arch/x86/core/video_subr.c @@ -109,5 +109,6 @@ struct console_driver vga_console __console_driver = { }; struct init_fn video_init_fn __init_fn ( INIT_EARLY ) = { + .name = "video", .initialise = video_init, }; diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c index 897858143..60191c9c5 100644 --- a/src/arch/x86/interface/pcbios/bios_cachedhcp.c +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -74,5 +74,6 @@ static void cachedhcp_init ( void ) { /** Cached DHCPACK initialisation function */ struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "cachedhcp", .initialise = cachedhcp_init, }; diff --git a/src/arch/x86/interface/pcbios/int13con.c b/src/arch/x86/interface/pcbios/int13con.c index 8106cd153..925228874 100644 --- a/src/arch/x86/interface/pcbios/int13con.c +++ b/src/arch/x86/interface/pcbios/int13con.c @@ -288,6 +288,7 @@ static void int13con_init ( void ) { * INT13 console initialisation function */ struct init_fn int13con_init_fn __init_fn ( INIT_CONSOLE ) = { + .name = "int13con", .initialise = int13con_init, }; diff --git a/src/arch/x86/interface/pcbios/pcicloud.c b/src/arch/x86/interface/pcbios/pcicloud.c index f7d4a2da1..5d4d02ac4 100644 --- a/src/arch/x86/interface/pcbios/pcicloud.c +++ b/src/arch/x86/interface/pcbios/pcicloud.c @@ -191,5 +191,6 @@ static void pcicloud_init ( void ) { /** Cloud VM PCI configuration space access initialisation function */ struct init_fn pcicloud_init_fn __init_fn ( INIT_EARLY ) = { + .name = "pcicloud", .initialise = pcicloud_init, }; diff --git a/src/arch/x86/interface/pxe/pxe_call.c b/src/arch/x86/interface/pxe/pxe_call.c index a530f919f..9a6a20dd3 100644 --- a/src/arch/x86/interface/pxe/pxe_call.c +++ b/src/arch/x86/interface/pxe/pxe_call.c @@ -257,6 +257,7 @@ static void pxe_init_structures ( void ) { /** PXE structure initialiser */ struct init_fn pxe_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "pxe", .initialise = pxe_init_structures, }; diff --git a/src/arch/x86/interface/vmware/guestinfo.c b/src/arch/x86/interface/vmware/guestinfo.c index 4134515c1..c181d96e9 100644 --- a/src/arch/x86/interface/vmware/guestinfo.c +++ b/src/arch/x86/interface/vmware/guestinfo.c @@ -200,6 +200,7 @@ static void guestinfo_init ( void ) { /** GuestInfo settings initialiser */ struct init_fn guestinfo_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "guestinfo", .initialise = guestinfo_init, }; diff --git a/src/arch/x86/interface/vmware/vmconsole.c b/src/arch/x86/interface/vmware/vmconsole.c index f7df4f75b..3b892c837 100644 --- a/src/arch/x86/interface/vmware/vmconsole.c +++ b/src/arch/x86/interface/vmware/vmconsole.c @@ -134,5 +134,6 @@ static void vmconsole_init ( void ) { * VMware logfile console initialisation function */ struct init_fn vmconsole_init_fn __init_fn ( INIT_CONSOLE ) = { + .name = "vmconsole", .initialise = vmconsole_init, }; diff --git a/src/core/acpi_settings.c b/src/core/acpi_settings.c index cdee1f865..63f271855 100644 --- a/src/core/acpi_settings.c +++ b/src/core/acpi_settings.c @@ -156,5 +156,6 @@ static void acpi_settings_init ( void ) { /** ACPI settings initialiser */ struct init_fn acpi_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "acpi", .initialise = acpi_settings_init, }; diff --git a/src/core/fnrec.c b/src/core/fnrec.c index 0430817f8..b63ffc1f5 100644 --- a/src/core/fnrec.c +++ b/src/core/fnrec.c @@ -177,6 +177,7 @@ static void fnrec_init ( void ) { } struct init_fn fnrec_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "fnrec", .initialise = fnrec_init, }; diff --git a/src/core/init.c b/src/core/init.c index c13fd1667..406d22d7b 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -53,8 +53,10 @@ void initialise ( void ) { struct init_fn *init_fn; /* Call registered initialisation functions */ - for_each_table_entry ( init_fn, INIT_FNS ) + for_each_table_entry ( init_fn, INIT_FNS ) { + DBGC ( colour, "INIT initialising %s...\n", init_fn->name ); init_fn->initialise (); + } } /** diff --git a/src/core/malloc.c b/src/core/malloc.c index 545927a30..a05871085 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -765,6 +765,7 @@ static void init_heap ( void ) { /** Memory allocator initialisation function */ struct init_fn heap_init_fn __init_fn ( INIT_EARLY ) = { + .name = "heap", .initialise = init_heap, }; diff --git a/src/core/memmap_settings.c b/src/core/memmap_settings.c index d07e9747e..f54de9150 100644 --- a/src/core/memmap_settings.c +++ b/src/core/memmap_settings.c @@ -243,6 +243,7 @@ static void memmap_settings_init ( void ) { /** Memory map settings initialiser */ struct init_fn memmap_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "memmap", .initialise = memmap_settings_init, }; diff --git a/src/core/process.c b/src/core/process.c index 69852c416..c944b6f50 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -133,5 +133,6 @@ static void init_processes ( void ) { /** Process initialiser */ struct init_fn process_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "process", .initialise = init_processes, }; diff --git a/src/core/serial.c b/src/core/serial.c index 4b569ffad..0883ad051 100644 --- a/src/core/serial.c +++ b/src/core/serial.c @@ -180,6 +180,7 @@ static void serial_shutdown ( int flags __unused ) { /** Serial console initialisation function */ struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = { + .name = "serial", .initialise = serial_init, }; diff --git a/src/core/settings.c b/src/core/settings.c index 9fbf753ab..05e495dcf 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -2819,5 +2819,6 @@ static void builtin_init ( void ) { /** Built-in settings initialiser */ struct init_fn builtin_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "builtin", .initialise = builtin_init, }; diff --git a/src/core/timer.c b/src/core/timer.c index 24745cef7..d45797adb 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -170,6 +170,7 @@ static void timer_probe ( void ) { /** Timer initialisation function */ struct init_fn timer_init_fn __init_fn ( INIT_EARLY ) = { + .name = "timer", .initialise = timer_probe, }; diff --git a/src/crypto/certstore.c b/src/crypto/certstore.c index 81179f9cc..aad874297 100644 --- a/src/crypto/certstore.c +++ b/src/crypto/certstore.c @@ -210,6 +210,7 @@ static void certstore_init ( void ) { /** Certificate store initialisation function */ struct init_fn certstore_init_fn __init_fn ( INIT_LATE ) = { + .name = "certstore", .initialise = certstore_init, }; diff --git a/src/crypto/des.c b/src/crypto/des.c index 6918bec3e..206f78d50 100644 --- a/src/crypto/des.c +++ b/src/crypto/des.c @@ -369,6 +369,7 @@ static void des_init ( void ) { /** Initialisation function */ struct init_fn des_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "des", .initialise = des_init, }; diff --git a/src/crypto/x25519.c b/src/crypto/x25519.c index 995cfa352..41bc5fc5e 100644 --- a/src/crypto/x25519.c +++ b/src/crypto/x25519.c @@ -334,6 +334,7 @@ static void x25519_init_constants ( void ) { /** Initialisation function */ struct init_fn x25519_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "x25519", .initialise = x25519_init_constants, }; diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c index 84aa76827..fc73c651e 100644 --- a/src/drivers/bus/pci_settings.c +++ b/src/drivers/bus/pci_settings.c @@ -125,5 +125,6 @@ static void pci_settings_init ( void ) { /** PCI device settings initialiser */ struct init_fn pci_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "pci", .initialise = pci_settings_init, }; diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c index 4fd190d83..bb01f34d5 100644 --- a/src/drivers/bus/usb_settings.c +++ b/src/drivers/bus/usb_settings.c @@ -173,5 +173,6 @@ static void usb_settings_init ( void ) { /** USB device settings initialiser */ struct init_fn usb_settings_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "usb", .initialise = usb_settings_init, }; diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index f0a5277a2..876479133 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -259,5 +259,6 @@ static void chained_init ( void ) { /** EFI chainloaded-device-only initialisation function */ struct init_fn chained_init_fn __init_fn ( INIT_LATE ) = { + .name = "chained", .initialise = chained_init, }; diff --git a/src/image/embedded.c b/src/image/embedded.c index 2934d4ee7..652cfc85f 100644 --- a/src/image/embedded.c +++ b/src/image/embedded.c @@ -80,5 +80,6 @@ static void embedded_init ( void ) { /** Embedded image initialisation function */ struct init_fn embedded_init_fn __init_fn ( INIT_LATE ) = { + .name = "embedded", .initialise = embedded_init, }; diff --git a/src/include/ipxe/init.h b/src/include/ipxe/init.h index 32927e3a6..da01b2953 100644 --- a/src/include/ipxe/init.h +++ b/src/include/ipxe/init.h @@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * call to initialise(). */ struct init_fn { + const char *name; void ( * initialise ) ( void ); }; diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c index 2b6c5c343..64bb0bae2 100644 --- a/src/interface/efi/efi_cacert.c +++ b/src/interface/efi/efi_cacert.c @@ -178,6 +178,7 @@ static void efi_cacert_init ( void ) { /** EFI CA certificates initialisation function */ struct init_fn efi_cacert_init_fn __init_fn ( INIT_LATE ) = { + .name = "eficacert", .initialise = efi_cacert_init, }; diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 9fc3c65c0..4557671a0 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -448,5 +448,6 @@ static void efi_console_init ( void ) { * EFI console initialisation function */ struct init_fn efi_console_init_fn __init_fn ( INIT_EARLY ) = { + .name = "eficonsole", .initialise = efi_console_init, }; diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 3a90fd7ce..3c249693e 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -77,6 +77,7 @@ static void efi_fdt_init ( void ) { /** EFI Flattened Device Tree initialisation function */ struct init_fn efi_fdt_init_fn __init_fn ( INIT_EARLY ) = { + .name = "efifdt", .initialise = efi_fdt_init, }; diff --git a/src/interface/efi/efi_settings.c b/src/interface/efi/efi_settings.c index cde0ff8d1..5ddbe12f1 100644 --- a/src/interface/efi/efi_settings.c +++ b/src/interface/efi/efi_settings.c @@ -232,5 +232,6 @@ static void efivars_init ( void ) { /** EFI variable settings initialiser */ struct init_fn efivars_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "efivars", .initialise = efivars_init, }; diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c index 10d8f0bf6..ddce6aa60 100644 --- a/src/interface/efi/efiprefix.c +++ b/src/interface/efi/efiprefix.c @@ -98,6 +98,7 @@ static void efi_init_application ( void ) { /** EFI application initialisation function */ struct init_fn efi_init_application_fn __init_fn ( INIT_NORMAL ) = { + .name = "efi", .initialise = efi_init_application, }; diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 1fe545f38..6358a4709 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -200,6 +200,7 @@ static void smbios_init ( void ) { /** SMBIOS settings initialiser */ struct init_fn smbios_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "smbios", .initialise = smbios_init, }; diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c index 9432dc2fa..90b804c6c 100644 --- a/src/net/netdev_settings.c +++ b/src/net/netdev_settings.c @@ -429,6 +429,7 @@ static void netdev_redirect_settings_init ( void ) { /** "netX" settings initialiser */ struct init_fn netdev_redirect_settings_init_fn __init_fn ( INIT_LATE ) = { + .name = "netX", .initialise = netdev_redirect_settings_init, }; diff --git a/src/tests/bofm_test.c b/src/tests/bofm_test.c index 6d472bc7e..bc400284f 100644 --- a/src/tests/bofm_test.c +++ b/src/tests/bofm_test.c @@ -278,5 +278,6 @@ static void bofm_test_init ( void ) { /** BOFM test initialisation function */ struct init_fn bofm_test_init_fn __init_fn ( INIT_NORMAL ) = { + .name = "bofm", .initialise = bofm_test_init, }; diff --git a/src/tests/test.c b/src/tests/test.c index 9fa12e27a..e4f5eb838 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -180,5 +180,6 @@ static void test_init ( void ) { /** Self-test initialisation function */ struct init_fn test_init_fn __init_fn ( INIT_EARLY ) = { + .name = "test", .initialise = test_init, }; -- cgit v1.2.3-55-g7522 From 8701863a17fab4726f1c76d7c123033d6e834019 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Jul 2025 16:51:05 +0100 Subject: [efi] Allow compiler to perform type checks on EFI_EVENT As with EFI_HANDLE, the EFI headers define EFI_EVENT as a void pointer, rendering EFI_EVENT compatible with a pointer to itself and hence guaranteeing that pointer type bugs will be introduced. Redefine EFI_EVENT as a pointer to an anonymous structure (as we already do for EFI_HANDLE) to allow the compiler to perform type checking as expected. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 11 +++++++---- src/interface/efi/efi_console.c | 2 +- src/interface/efi/efi_snp.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 33278abed..9dd26bff0 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -39,10 +39,10 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define EFIAPI __attribute__((cdecl,regparm(0))) #endif -/* EFI headers define EFI_HANDLE as a void pointer, which renders type - * checking somewhat useless. Work around this bizarre sabotage - * attempt by redefining EFI_HANDLE as a pointer to an anonymous - * structure. +/* EFI headers define EFI_HANDLE and EFI_EVENT as void pointers, which + * renders type checking somewhat useless. Work around this bizarre + * sabotage attempt by redefining both as pointers to anonymous + * structures. * * EFI headers perform some ABI validation checks via _Static_assert() * that may fail when EFI headers are included on a non-EFI platform. @@ -50,13 +50,16 @@ FILE_LICENCE ( GPL2_OR_LATER ); * included. */ #define EFI_HANDLE STUPID_EFI_HANDLE +#define EFI_EVENT STUPID_EFI_EVENT #ifndef PLATFORM_efi #define _Static_assert(expr, msg) #endif #include #undef EFI_HANDLE +#undef EFI_EVENT #undef _Static_assert typedef struct {} *EFI_HANDLE; +typedef struct {} *EFI_EVENT; /* Include the top-level EFI header files */ #include diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 4557671a0..c5a3f24ca 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -387,7 +387,7 @@ static int efi_iskey ( void ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_SIMPLE_TEXT_INPUT_PROTOCOL *conin = efi_systab->ConIn; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *conin_ex = efi_conin_ex; - EFI_EVENT *event; + EFI_EVENT event; EFI_STATUS efirc; /* If we are mid-sequence, we are always ready */ diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index b9706d5ab..88334c8d0 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -175,7 +175,7 @@ static void efi_snp_poll ( struct efi_snp_device *snpdev ) { while ( ( iobuf = netdev_rx_dequeue ( snpdev->netdev ) ) ) { list_add_tail ( &iobuf->list, &snpdev->rx ); snpdev->interrupts |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; - bs->SignalEvent ( &snpdev->snp.WaitForPacket ); + bs->SignalEvent ( snpdev->snp.WaitForPacket ); } } -- cgit v1.2.3-55-g7522 From 8a8904aaddcc9497b2c3d110785b52e4d1dca336 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Jul 2025 16:56:11 +0100 Subject: [efi] Check only the non-extended WaitForKey event The WaitForKeyEx event in EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is redundant: by definition it has to signal under exactly the same conditions as the WaitForKey event in EFI_SIMPLE_TEXT_INPUT_PROTOCOL and cannot provide any "extended" information since EFI events do not convey any information beyond their own occurrence. UEFI keyboard drivers such as Ps2KeyboardDxe and UsbKbDxe invariably use a single notification function to implement both events. The console multiplexer driver ConSplitterDxe uses a single notification function for both events, which ends up checking only the WaitForKey event on the underlying console devices. (Since all console input is routed through the console multiplexer, this means that in practice nothing will ever check the underlying devices' WaitForKeyEx events.) UEFI console consumers such as the UEFI shell tend to use only the EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance provided as ConIn in the EFI system table. With the exception of the UEFI text editor (the "edit" command in the UEFI shell), almost nothing bothers to open the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance on the same handle. The Lenovo ThinkPad T14s Gen 5 has a very peculiar firmware bug. Enabling the "UEFI Wi-Fi Network Boot" feature in the BIOS setup will cause the completely unrelated WaitForKeyEx event pointer to be overwritten with a pointer to a FAT_DIRENT structure representing the "BOOT" directory in the EFI system partition. This happens with 100% repeatability. It is not necessary to attempt to boot from Wi-Fi: it is only necessary to have the feature enabled. The root cause is unknown, but is presumably an uninitialised pointer or similar memory-related bug in Lenovo's UEFI Wi-Fi driver. Work around this Lenovo firmware bug by checking only the WaitForKey event, ignoring the WaitForKeyEx event even if we will subsequently use ReadKeyStrokeEx() to read the keypress. Since almost all other UEFI console consumers use only WaitForKey, this ensures that we will be using code paths that the firmware vendor is likely to have tested at least once. Signed-off-by: Michael Brown --- src/interface/efi/efi_console.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index c5a3f24ca..e896c5d88 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -386,8 +386,6 @@ static int efi_getchar ( void ) { static int efi_iskey ( void ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_SIMPLE_TEXT_INPUT_PROTOCOL *conin = efi_systab->ConIn; - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *conin_ex = efi_conin_ex; - EFI_EVENT event; EFI_STATUS efirc; /* If we are mid-sequence, we are always ready */ @@ -395,8 +393,7 @@ static int efi_iskey ( void ) { return 1; /* Check to see if the WaitForKey event has fired */ - event = ( conin_ex ? conin_ex->WaitForKeyEx : conin->WaitForKey ); - if ( ( efirc = bs->CheckEvent ( event ) ) == 0 ) + if ( ( efirc = bs->CheckEvent ( conin->WaitForKey ) ) == 0 ) return 1; return 0; -- cgit v1.2.3-55-g7522 From c10da8b53c9fc9cda21c28de3226f63cf6c79d8e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 28 Aug 2025 15:34:32 +0100 Subject: [efi] Add ability to extract device path from an EFI load option An EFI boot option (stored in a BootXXXX variable) comprises an EFI_LOAD_OPTION structure, which includes some undefined number of EFI device paths. (The structure is extremely messy and awkward to parse in C, but that's par for the course with EFI.) Add a function to extract the first device path from an EFI load option, along with wrapper functions to read and extract the first device path from an EFI boot variable. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi_path.h | 5 + src/interface/efi/efi_path.c | 199 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi_path.h b/src/include/ipxe/efi/efi_path.h index 57fce4028..a37d7b9d7 100644 --- a/src/include/ipxe/efi/efi_path.h +++ b/src/include/ipxe/efi/efi_path.h @@ -43,6 +43,7 @@ efi_path_prev ( EFI_DEVICE_PATH_PROTOCOL *path, extern EFI_DEVICE_PATH_PROTOCOL * efi_path_end ( EFI_DEVICE_PATH_PROTOCOL *path ); extern size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL *path ); +extern int efi_path_check ( EFI_DEVICE_PATH_PROTOCOL *path, size_t max ); extern void * efi_path_mac ( EFI_DEVICE_PATH_PROTOCOL *path ); extern unsigned int efi_path_vlan ( EFI_DEVICE_PATH_PROTOCOL *path ); extern int efi_path_guid ( EFI_DEVICE_PATH_PROTOCOL *path, union uuid *uuid ); @@ -58,6 +59,10 @@ extern EFI_DEVICE_PATH_PROTOCOL * efi_fcp_path ( struct fcp_description *desc ); extern EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path ( struct ib_srp_device *ib_srp ); extern EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function *func ); +extern EFI_DEVICE_PATH_PROTOCOL * efi_load_path ( EFI_LOAD_OPTION *load, + size_t len ); +extern EFI_DEVICE_PATH_PROTOCOL * efi_boot_path ( unsigned int number ); +extern EFI_DEVICE_PATH_PROTOCOL * efi_current_boot_path ( void ); extern EFI_DEVICE_PATH_PROTOCOL * efi_describe ( struct interface *interface ); #define efi_describe_TYPE( object_type ) \ diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c index ac3c04987..65ac3d6f5 100644 --- a/src/interface/efi/efi_path.c +++ b/src/interface/efi/efi_path.c @@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include #include /** @file @@ -147,6 +148,33 @@ size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL *path ) { return ( ( ( void * ) end ) - ( ( void * ) path ) ); } +/** + * Check that device path is well-formed + * + * @v path Device path, or NULL + * @v max Maximum device path length + * @ret rc Return status code + */ +int efi_path_check ( EFI_DEVICE_PATH_PROTOCOL *path, size_t max ) { + EFI_DEVICE_PATH_PROTOCOL *next; + size_t remaining = max; + size_t len; + + /* Check that path terminates within maximum length */ + for ( ; ; path = next ) { + if ( remaining < sizeof ( *path ) ) + return -EINVAL; + next = efi_path_next ( path ); + if ( ! next ) + break; + len = ( ( ( void * ) next ) - ( ( void * ) path ) ); + if ( remaining < len ) + return -EINVAL; + } + + return 0; +} + /** * Get MAC address from device path * @@ -668,6 +696,177 @@ EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function *func ) { return path; } +/** + * Get EFI device path from load option + * + * @v load EFI load option + * @v len Length of EFI load option + * @ret path EFI device path, or NULL on error + * + * The caller is responsible for eventually calling free() on the + * allocated device path. + */ +EFI_DEVICE_PATH_PROTOCOL * efi_load_path ( EFI_LOAD_OPTION *load, + size_t len ) { + EFI_DEVICE_PATH_PROTOCOL *path; + EFI_DEVICE_PATH_PROTOCOL *copy; + CHAR16 *wdesc; + size_t path_max; + size_t wmax; + size_t wlen; + + /* Check basic structure size */ + if ( len < sizeof ( *load ) ) { + DBGC ( load, "EFI load option too short for header:\n" ); + DBGC_HDA ( load, 0, load, len ); + return NULL; + } + + /* Get length of description */ + wdesc = ( ( ( void * ) load ) + sizeof ( *load ) ); + wmax = ( ( len - sizeof ( *load ) ) / sizeof ( wdesc[0] ) ); + wlen = wcsnlen ( wdesc, wmax ); + if ( wlen == wmax ) { + DBGC ( load, "EFI load option has unterminated " + "description:\n" ); + DBGC_HDA ( load, 0, load, len ); + return NULL; + } + + /* Get inline device path */ + path = ( ( ( void * ) load ) + sizeof ( *load ) + + ( wlen * sizeof ( wdesc[0] ) ) + 2 /* wNUL */ ); + path_max = ( len - sizeof ( *load ) - ( wlen * sizeof ( wdesc[0] ) ) + - 2 /* wNUL */ ); + if ( load->FilePathListLength > path_max ) { + DBGC ( load, "EFI load option too short for path(s):\n" ); + DBGC_HDA ( load, 0, load, len ); + return NULL; + } + + /* Check path length */ + if ( efi_path_check ( path, path_max ) != 0 ) { + DBGC ( load, "EFI load option has unterminated device " + "path:\n" ); + DBGC_HDA ( load, 0, load, len ); + return NULL; + } + + /* Allocate copy of path */ + copy = malloc ( path_max ); + if ( ! copy ) + return NULL; + memcpy ( copy, path, path_max ); + + return copy; +} + +/** + * Get EFI device path for numbered boot option + * + * @v number Boot option number + * @ret path EFI device path, or NULL on error + * + * The caller is responsible for eventually calling free() on the + * allocated device path. + */ +EFI_DEVICE_PATH_PROTOCOL * efi_boot_path ( unsigned int number ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + EFI_GUID *guid = &efi_global_variable; + CHAR16 wname[ 9 /* "BootXXXX" + wNUL */ ]; + EFI_LOAD_OPTION *load; + EFI_DEVICE_PATH *path; + UINT32 attrs; + UINTN size; + EFI_STATUS efirc; + int rc; + + /* Construct variable name */ + efi_snprintf ( wname, ( sizeof ( wname ) / sizeof ( wname[0] ) ), + "Boot%04X", number ); + + /* Get variable length */ + size = 0; + if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size, + NULL ) != EFI_BUFFER_TOO_SMALL ) ) { + rc = -EEFI ( efirc ); + DBGC ( rs, "EFI could not get size of %ls: %s\n", + wname, strerror ( rc ) ); + goto err_size; + } + + /* Allocate temporary buffer for EFI_LOAD_OPTION */ + load = malloc ( size ); + if ( ! load ) { + rc = -ENOMEM; + goto err_alloc; + } + + /* Read variable */ + if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size, + load ) != 0 ) ) { + rc = -EEFI ( efirc ); + DBGC ( rs, "EFI could not read %ls: %s\n", + wname, strerror ( rc ) ); + goto err_read; + } + DBGC2 ( rs, "EFI boot option %ls is:\n", wname ); + DBGC2_HDA ( rs, 0, load, size ); + + /* Get device path from load option */ + path = efi_load_path ( load, size ); + if ( ! path ) { + rc = -EINVAL; + DBGC ( rs, "EFI could not parse %ls: %s\n", + wname, strerror ( rc ) ); + goto err_path; + } + + /* Free temporary buffer */ + free ( load ); + + return path; + + err_path: + err_read: + free ( load ); + err_alloc: + err_size: + return NULL; +} + +/** + * Get EFI device path for current boot option + * + * @ret path EFI device path, or NULL on error + * + * The caller is responsible for eventually calling free() on the + * allocated device path. + */ +EFI_DEVICE_PATH_PROTOCOL * efi_current_boot_path ( void ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + EFI_GUID *guid = &efi_global_variable; + CHAR16 wname[] = L"BootCurrent"; + UINT16 current; + UINT32 attrs; + UINTN size; + EFI_STATUS efirc; + int rc; + + /* Read current boot option index */ + size = sizeof ( current ); + if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size, + ¤t ) != 0 ) ) { + rc = -EEFI ( efirc ); + DBGC ( rs, "EFI could not read %ls: %s\n", + wname, strerror ( rc ) ); + return NULL; + } + + /* Get device path from this boot option */ + return efi_boot_path ( current ); +} + /** * Describe object as an EFI device path * -- cgit v1.2.3-55-g7522 From 969ce2c559a6841a949a1b73a3967b1889e0c999 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 28 Aug 2025 15:35:00 +0100 Subject: [efi] Use current boot option as a fallback for obtaining the boot URI Some systems (observed with a Lenovo X1) fail to populate the loaded image device path with a Uri() component when performing a UEFI HTTP boot, instead creating a broken loaded image device path that represents a DHCP+TFTP boot that has not actually taken place. If no URI is found within the loaded image device path, then fall back to looking for a URI within the current boot option. Signed-off-by: Michael Brown --- src/interface/efi/efiprefix.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c index ddce6aa60..64122185a 100644 --- a/src/interface/efi/efiprefix.c +++ b/src/interface/efi/efiprefix.c @@ -81,13 +81,22 @@ EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle, static void efi_init_application ( void ) { EFI_HANDLE device = efi_loaded_image->DeviceHandle; EFI_DEVICE_PATH_PROTOCOL *devpath = efi_loaded_image_path; + EFI_DEVICE_PATH_PROTOCOL *bootpath; struct uri *uri; /* Set current working URI from device path, if present */ + bootpath = efi_current_boot_path(); + DBGC ( device, "EFI has loaded image device path %s\n", + efi_devpath_text ( devpath ) ); + DBGC ( device, "EFI has boot option device path %s\n", + efi_devpath_text ( bootpath ) ); uri = efi_path_uri ( devpath ); + if ( bootpath && ( ! uri ) ) + uri = efi_path_uri ( bootpath ); if ( uri ) churi ( uri ); uri_put ( uri ); + free ( bootpath ); /* Identify autoboot device, if any */ efi_set_autoboot_ll_addr ( device, devpath ); -- cgit v1.2.3-55-g7522 From c0ac23fc56e5f46b8101cb2be7e96b277dd8f51d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Nov 2025 14:45:01 +0000 Subject: [efi] Switch back to VA_START() etc macros for EFIAPI functions Commit 670810b ("[efi] Use standard va_args macros instead of VA_START() etc") fixed a 32-bit RISC-V build error, but broke the functionality of the InstallMultipleProtocolInterfaces() and UninstallMultipleProtocolInterfaces() wrapper functions. GCC does not automatically check the ABI of the current function when using the __builtin_va_start() and related macros, and it is therefore necessary for code to use __builtin_ms_va_start() etc from within functions marked as EFIAPI. Since commit 9016f2e ("[efi] Skip including the EDK2 ProcessorBind.h header for 32-bit RISC-V") has now fixed the original 32-bit RISC-V build error, we can switch back to using the EDK2 VA_START() etc macros to obtain the correct behaviour. Signed-off-by: Michael Brown --- src/interface/efi/efi_wrap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 8c3f41e3b..936074f2a 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -1082,7 +1082,7 @@ efi_install_multiple_protocol_interfaces_wrapper ( EFI_HANDLE *handle, ... ) { void *retaddr = __builtin_return_address ( 0 ); EFI_GUID *protocol[ MAX_WRAP_MULTI + 1 ]; VOID *interface[MAX_WRAP_MULTI]; - va_list ap; + VA_LIST ap; unsigned int i; EFI_STATUS efirc; @@ -1090,20 +1090,20 @@ efi_install_multiple_protocol_interfaces_wrapper ( EFI_HANDLE *handle, ... ) { efi_handle_name ( *handle ) ); memset ( protocol, 0, sizeof ( protocol ) ); memset ( interface, 0, sizeof ( interface ) ); - va_start ( ap, handle ); - for ( i = 0 ; ( protocol[i] = va_arg ( ap, EFI_GUID * ) ) ; i++ ) { + VA_START ( ap, handle ); + for ( i = 0 ; ( protocol[i] = VA_ARG ( ap, EFI_GUID * ) ) ; i++ ) { if ( i == MAX_WRAP_MULTI ) { - va_end ( ap ); + VA_END ( ap ); efirc = EFI_OUT_OF_RESOURCES; DBGC ( colour, " ) = %s " "-> %p\n", efi_status ( efirc ), retaddr ); return efirc; } - interface[i] = va_arg ( ap, VOID * ); + interface[i] = VA_ARG ( ap, VOID * ); DBGC ( colour, ", %s, %p", efi_guid_ntoa ( protocol[i] ), interface[i] ); } - va_end ( ap ); + VA_END ( ap ); DBGC ( colour, " ) " ); efirc = bs->InstallMultipleProtocolInterfaces ( handle, protocol[0], interface[0], protocol[1], interface[1], @@ -1132,7 +1132,7 @@ efi_uninstall_multiple_protocol_interfaces_wrapper ( EFI_HANDLE handle, ... ) { void *retaddr = __builtin_return_address ( 0 ); EFI_GUID *protocol[ MAX_WRAP_MULTI + 1 ]; VOID *interface[MAX_WRAP_MULTI]; - va_list ap; + VA_LIST ap; unsigned int i; EFI_STATUS efirc; @@ -1140,20 +1140,20 @@ efi_uninstall_multiple_protocol_interfaces_wrapper ( EFI_HANDLE handle, ... ) { efi_handle_name ( handle ) ); memset ( protocol, 0, sizeof ( protocol ) ); memset ( interface, 0, sizeof ( interface ) ); - va_start ( ap, handle ); - for ( i = 0 ; ( protocol[i] = va_arg ( ap, EFI_GUID * ) ) ; i++ ) { + VA_START ( ap, handle ); + for ( i = 0 ; ( protocol[i] = VA_ARG ( ap, EFI_GUID * ) ) ; i++ ) { if ( i == MAX_WRAP_MULTI ) { - va_end ( ap ); + VA_END ( ap ); efirc = EFI_OUT_OF_RESOURCES; DBGC ( colour, " ) = %s " "-> %p\n", efi_status ( efirc ), retaddr ); return efirc; } - interface[i] = va_arg ( ap, VOID * ); + interface[i] = VA_ARG ( ap, VOID * ); DBGC ( colour, ", %s, %p", efi_guid_ntoa ( protocol[i] ), interface[i] ); } - va_end ( ap ); + VA_END ( ap ); DBGC ( colour, " ) " ); efirc = bs->UninstallMultipleProtocolInterfaces ( handle, protocol[0], interface[0], protocol[1], interface[1], -- cgit v1.2.3-55-g7522 From 27ec3c76ab2dfdc384c589b9f4c8a610a33ba8d1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Nov 2025 16:18:45 +0000 Subject: [efi] Update to current EDK2 headers Signed-off-by: Michael Brown --- src/include/ipxe/efi/Arm/ProcessorBind.h | 6 +- src/include/ipxe/efi/Base.h | 2 +- src/include/ipxe/efi/Guid/Fdt.h | 5 - src/include/ipxe/efi/IndustryStandard/Acpi50.h | 34 ++++++ src/include/ipxe/efi/IndustryStandard/Acpi51.h | 19 ++++ src/include/ipxe/efi/IndustryStandard/PeImage.h | 1 - src/include/ipxe/efi/Library/BaseLib.h | 127 +++++++++++++++++++---- src/include/ipxe/efi/Pi/PiMultiPhase.h | 51 +++++++++ src/include/ipxe/efi/Pi/PiS3BootScript.h | 2 +- src/include/ipxe/efi/Pi/PiStatusCode.h | 2 +- src/include/ipxe/efi/Protocol/DebugSupport.h | 1 - src/include/ipxe/efi/Protocol/Http.h | 17 ++- src/include/ipxe/efi/Protocol/PxeBaseCode.h | 2 - src/include/ipxe/efi/Protocol/SimplePointer.h | 4 +- src/include/ipxe/efi/Protocol/UnicodeCollation.h | 16 --- src/include/ipxe/efi/Uefi/UefiBaseType.h | 11 -- src/include/ipxe/efi/Uefi/UefiSpec.h | 5 +- src/interface/efi/efi_guid.c | 5 + src/util/efirom.c | 3 + src/util/elf2efi.c | 3 + 20 files changed, 250 insertions(+), 66 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Arm/ProcessorBind.h b/src/include/ipxe/efi/Arm/ProcessorBind.h index 21951ea1b..4f90eff84 100644 --- a/src/include/ipxe/efi/Arm/ProcessorBind.h +++ b/src/include/ipxe/efi/Arm/ProcessorBind.h @@ -19,7 +19,11 @@ FILE_LICENCE ( BSD2_PATENT ); /// /// Define the processor type so other code can make processor based choices /// -#define MDE_CPU_ARM +/// Upstream EDK2 headers no longer accept MDE_CPU_ARM: define +/// MDE_CPU_EBC to prevent build errors. (The definition doesn't +/// actually affect anything used by iPXE.) +/// +#define MDE_CPU_EBC // // Make sure we are using the correct packing rules per EFI specification diff --git a/src/include/ipxe/efi/Base.h b/src/include/ipxe/efi/Base.h index ff90beef5..860a45d39 100644 --- a/src/include/ipxe/efi/Base.h +++ b/src/include/ipxe/efi/Base.h @@ -580,7 +580,7 @@ struct _LIST_ENTRY { **/ #define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1)) -#if defined (_M_ARM) || defined (_M_ARM64) +#if defined (_M_ARM64) // // MSFT ARM variable argument list support. // diff --git a/src/include/ipxe/efi/Guid/Fdt.h b/src/include/ipxe/efi/Guid/Fdt.h index f668d0e63..a7f94a1c4 100644 --- a/src/include/ipxe/efi/Guid/Fdt.h +++ b/src/include/ipxe/efi/Guid/Fdt.h @@ -16,9 +16,4 @@ FILE_LICENCE ( BSD2_PATENT ); extern EFI_GUID gFdtTableGuid; -#define FDT_VARIABLE_GUID \ - { 0x25a4fd4a, 0x9703, 0x4ba9, { 0xa1, 0x90, 0xb7, 0xc8, 0x4e, 0xfb, 0x3e, 0x57 } } - -extern EFI_GUID gFdtVariableGuid; - #endif /* __FDT_H__ */ diff --git a/src/include/ipxe/efi/IndustryStandard/Acpi50.h b/src/include/ipxe/efi/IndustryStandard/Acpi50.h index 600858267..f3759805f 100644 --- a/src/include/ipxe/efi/IndustryStandard/Acpi50.h +++ b/src/include/ipxe/efi/IndustryStandard/Acpi50.h @@ -134,6 +134,40 @@ typedef PACKED struct { UINT16 DeviceSelection; } EFI_ACPI_SERIAL_BUS_RESOURCE_SPI_DESCRIPTOR; +/// Revision ID of serial bus uart descriptor +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_REVISION_ID 0x1 + +/// Type specific flags +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_LITTLE_ENDIAN 0x0 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_BIG_ENDIAN 0x1 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_5_BITS_PER_BYTE 0x0 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_6_BITS_PER_BYTE 0x1 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_7_BITS_PER_BYTE 0x2 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_8_BITS_PER_BYTE 0x3 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_9_BITS_PER_BYTE 0x4 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_STOP_BIT_NONE 0x0 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_STOP_BIT_1 0x1 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_STOP_BIT_1_5 0x2 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_STOP_BIT_2 0x3 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_FC_NONE 0x0 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_FC_HW 0x1 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_TSF_FC_XON_XOFF 0x2 + +/// Parity definitions +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_PARITY_NONE 0x0 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_PARITY_EVEN 0x1 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_PARITY_ODD 0x2 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_PARITY_MARK 0x3 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_PARITY_SPACE 0x4 + +/// Serial lines in use bits +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_LIN_RTS BIT7 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_LIN_CTS BIT6 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_LIN_DTR BIT5 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_LIN_DSR BIT4 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_LIN_RI BIT3 +#define EFI_ACPI_5_0_SERIAL_BUS_RESOURCE_UART_DESCRIPTOR_LIN_DTD BIT2 + /// /// Serial Bus Resource Descriptor (UART) /// diff --git a/src/include/ipxe/efi/IndustryStandard/Acpi51.h b/src/include/ipxe/efi/IndustryStandard/Acpi51.h index de2ed987c..eb7fefab4 100644 --- a/src/include/ipxe/efi/IndustryStandard/Acpi51.h +++ b/src/include/ipxe/efi/IndustryStandard/Acpi51.h @@ -1836,6 +1836,25 @@ typedef struct { UINT32 EntryCount; } EFI_ACPI_5_1_EINJ_TRIGGER_ACTION_TABLE; +/// +/// Windows ACPI Emulated devices Table +/// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + /// + /// Container of a bitmask of Windows behavior that this system requires + /// Bit 0 - RTC good + /// Bit 1 - ACPI PM timer good + /// + UINT32 EmulatedDeviceFlags; +} EFI_ACPI_5_1_WAET_TABLE; + +/// +/// WAET Flags. All other bits are reserved and must be 0. +/// +#define EFI_ACPI_5_1_WAET_FLAGS_RTC_GOOD BIT0 +#define EFI_ACPI_5_1_WAET_FLAGS_ACPI_PM_TIMER_GOOD BIT1 + /// /// Platform Communications Channel Table (PCCT) /// diff --git a/src/include/ipxe/efi/IndustryStandard/PeImage.h b/src/include/ipxe/efi/IndustryStandard/PeImage.h index c1f1a09cb..5cd012e8a 100644 --- a/src/include/ipxe/efi/IndustryStandard/PeImage.h +++ b/src/include/ipxe/efi/IndustryStandard/PeImage.h @@ -27,7 +27,6 @@ FILE_LICENCE ( BSD2_PATENT ); #define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10 #define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 #define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 -#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13///< defined PI Specification, 1.0 // // PE32+ Machine type for EFI images diff --git a/src/include/ipxe/efi/Library/BaseLib.h b/src/include/ipxe/efi/Library/BaseLib.h index f1a8210c8..aeab59988 100644 --- a/src/include/ipxe/efi/Library/BaseLib.h +++ b/src/include/ipxe/efi/Library/BaseLib.h @@ -79,26 +79,6 @@ typedef struct { #endif // defined (MDE_CPU_EBC) -#if defined (MDE_CPU_ARM) - -typedef struct { - UINT32 R3; ///< A copy of R13. - UINT32 R4; - UINT32 R5; - UINT32 R6; - UINT32 R7; - UINT32 R8; - UINT32 R9; - UINT32 R10; - UINT32 R11; - UINT32 R12; - UINT32 R14; -} BASE_LIBRARY_JUMP_BUFFER; - -#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4 - -#endif // defined (MDE_CPU_ARM) - #if defined (MDE_CPU_AARCH64) typedef struct { // GP regs @@ -4717,6 +4697,101 @@ BitFieldCountOnes64 ( IN UINTN EndBit ); +/******************************************************************************* + + UUID (Universally Unique IDentifier), as defined in RFC4122 + (https://datatracker.ietf.org/doc/html/rfc4122#section-4.1), is a 128-bit number + used to uniquely identify information in computer systems. + + UUIDs contains 5 fields: + - time_low: 32 bits + - time_mid: 16 bits + - time_hi_and_version: 16 bits + - clock_seq_hi_and_reserved: 8 bits + - clock_seq_low: 8 bits + - node: 8 bits * 6 + + Each field encoded with the Most Significant Byte first (known as network byte + order, or big-endian). + + GUID (Globally Unique Identifier), on the other hand, is a 128-bit number used + in UEFI environments, which is similar to UUID but has a different byte order + in memory. See https://uefi.org/specs/UEFI/2.11/Apx_A_GUID_and_Time_Formats.html + + GUID also contains 5 fields: + - TimeLow: 32 bits + - TimeMid: 16 bits + - TimeHiAndVersion: 16 bits + - ClockSeqHighAndReserved: 16 bits + - ClockSeqLow: 8 bits + - Node: 8 bits * 6 + + TimeLow, TimeMid, TimeHighAndVersion fields in the EFI are encoded with the Least + Significant Byte first (also known as little-endian). + + Example: + Consider the same string representation/registry format for MM communication v2: + "378daedc-f06b-4446-8314-40ab933c87a3" + + In UUID format, it is represented as: + - Data fields: + - time_low: 0x37 0x8d 0xae 0xdc (0x378daedc in big-endian) + - time_mid: 0xf0 0x6b (0xf06b in big-endian) + - time_hi_and_version: 0x44 0x46 (0x4446 in big-endian) + - clock_seq_hi_and_reserved: 0x83 + - clock_seq_low: 0x14 + - node: 0x00, 0xab, 0x93, 0x3c, 0x87, 0xa3 + - Byte representation in memory: + - 37 8d ae dc f0 6b 44 46 83 14 40 ab 93 3c 87 a3 + + However, in GUID format, it is represented as: + - Data fields: + - TimeLow: 0xdc 0xae 0x8d 0x37 (0x378daedc in little-endian) + - TimeMid: 0x6b 0xf0 (0xf06b in little-endian) + - TimeHiAndVersion: 0x46 0x44 (0x4446 in little-endian) + - ClockSeqHighAndReserved: 0x83 + - ClockSeqLow: 0x14 + - Node: 0x00, 0xab, 0x93, 0x3c, 0x87, 0xa3 + - Byte representation in memory: + - dc ae 8d 37 6b f0 46 44 83 14 40 ab 93 3c 87 a3 + +*******************************************************************************/ + +/** + This function converts a GUID in UEFI format to a UUID in RFC4122 format. + + The conversion is done by swapping the byte order of the TimeLow, TimeMid, and + TimeHiAndVersion fields, while keeping the ClockSeq and Node fields unchanged. + + @param [in] FromGuid GUID in format to be converted to UUID RFC4122 format. + @param [out] ToUuid Pointer to a GUID structure that will hold the converted + UUID in RFC4122 format. +**/ +VOID +EFIAPI +ConvertGuidToUuid ( + IN GUID *FromGuid, + OUT GUID *ToUuid + ); + +/** + This function converts a UUID in RFC4122 format to a GUID in UEFI format. + + The conversion is done by swapping the byte order of the time_low, time_mid, and + time_hi_and_version fields, while keeping the ClockSeq and Node fields unchanged. + This function is symmetric to ConvertGuidToUuid. + + @param [in] FromUuid UUID in RFC4122 format to be converted to GUID in UEFI format. + @param [out] ToGuid Pointer to a GUID structure that will hold the converted + GUID in UEFI format. +**/ +VOID +EFIAPI +ConvertUuidToGuid ( + IN GUID *FromUuid, + OUT GUID *ToGuid + ); + // // Base Library Checksum Functions // @@ -5323,6 +5398,18 @@ TdIsEnabled ( VOID ); +/** + Probe if running as some kind of SEV guest. + + @return FALSE Not running as a guest under any kind of SEV + @return TRUE Running as a guest under any kind of SEV +**/ +BOOLEAN +EFIAPI +SevGuestIsEnabled ( + VOID + ); + #if defined (MDE_CPU_X64) // // The page size for the PVALIDATE instruction diff --git a/src/include/ipxe/efi/Pi/PiMultiPhase.h b/src/include/ipxe/efi/Pi/PiMultiPhase.h index 187b131bc..828ea52f6 100644 --- a/src/include/ipxe/efi/Pi/PiMultiPhase.h +++ b/src/include/ipxe/efi/Pi/PiMultiPhase.h @@ -112,6 +112,14 @@ FILE_LICENCE ( BSD2_PATENT ); #define EFI_SMRAM_CLOSED EFI_MMRAM_CLOSED #define EFI_SMRAM_LOCKED EFI_MMRAM_LOCKED +/// +/// MM Communicate header constants +/// +#define COMMUNICATE_HEADER_V3_GUID \ + { \ + 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } \ + } + /// /// Structure describing a MMRAM region and its accessibility attributes. /// @@ -158,6 +166,47 @@ typedef struct _EFI_MM_RESERVED_MMRAM_REGION { UINT64 MmramReservedSize; } EFI_MM_RESERVED_MMRAM_REGION; +#pragma pack(1) + +/// +/// To avoid confusion in interpreting frames, the buffer communicating to MM core through +/// EFI_MM_COMMUNICATE3 or later should always start with EFI_MM_COMMUNICATE_HEADER_V3. +/// +typedef struct { + /// + /// Indicator GUID for MM core that the communication buffer is compliant with this v3 header. + /// Must be gEfiMmCommunicateHeaderV3Guid. + /// + EFI_GUID HeaderGuid; + /// + /// Describes the size of the entire buffer (in bytes) available for communication, including this communication header. + /// + UINT64 BufferSize; + /// + /// Reserved for future use. + /// + UINT64 Reserved; + /// + /// Allows for disambiguation of the message format. + /// + EFI_GUID MessageGuid; + /// + /// Describes the size of MessageData (in bytes) and does not include the size of the header. + /// + UINT64 MessageSize; + /// + /// Designates an array of bytes that is MessageSize in size. + /// + UINT8 MessageData[]; +} EFI_MM_COMMUNICATE_HEADER_V3; + +#pragma pack() + +STATIC_ASSERT ( + (sizeof (EFI_MM_COMMUNICATE_HEADER_V3) == OFFSET_OF (EFI_MM_COMMUNICATE_HEADER_V3, MessageData)), \ + "sizeof (EFI_MM_COMMUNICATE_HEADER_V3) does not align with the beginning of flexible array MessageData" + ); + typedef enum { EFI_PCD_TYPE_8, EFI_PCD_TYPE_16, @@ -217,4 +266,6 @@ EFI_STATUS IN VOID *ProcedureArgument ); +extern EFI_GUID gEfiMmCommunicateHeaderV3Guid; + #endif diff --git a/src/include/ipxe/efi/Pi/PiS3BootScript.h b/src/include/ipxe/efi/Pi/PiS3BootScript.h index f016e1245..97092ddf9 100644 --- a/src/include/ipxe/efi/Pi/PiS3BootScript.h +++ b/src/include/ipxe/efi/Pi/PiS3BootScript.h @@ -1,5 +1,5 @@ /** @file - This file contains the boot script defintions that are shared between the + This file contains the boot script definitions that are shared between the Boot Script Executor PPI and the Boot Script Save Protocol. Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
diff --git a/src/include/ipxe/efi/Pi/PiStatusCode.h b/src/include/ipxe/efi/Pi/PiStatusCode.h index 3bdc96edf..81611ba7d 100644 --- a/src/include/ipxe/efi/Pi/PiStatusCode.h +++ b/src/include/ipxe/efi/Pi/PiStatusCode.h @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent FILE_LICENCE ( BSD2_PATENT ); // -// Required for IA32, X64, IPF, ARM and EBC defines for CPU exception types +// Required for IA32, X64, IPF, and EBC defines for CPU exception types // #include diff --git a/src/include/ipxe/efi/Protocol/DebugSupport.h b/src/include/ipxe/efi/Protocol/DebugSupport.h index b17befbad..c346be0ff 100644 --- a/src/include/ipxe/efi/Protocol/DebugSupport.h +++ b/src/include/ipxe/efi/Protocol/DebugSupport.h @@ -851,7 +851,6 @@ typedef enum { IsaX64 = IMAGE_FILE_MACHINE_X64, ///< 0x8664 IsaIpf = IMAGE_FILE_MACHINE_IA64, ///< 0x0200 IsaEbc = IMAGE_FILE_MACHINE_EBC, ///< 0x0EBC - IsaArm = IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, ///< 0x01c2 IsaAArch64 = IMAGE_FILE_MACHINE_ARM64 ///< 0xAA64 } EFI_INSTRUCTION_SET_ARCHITECTURE; diff --git a/src/include/ipxe/efi/Protocol/Http.h b/src/include/ipxe/efi/Protocol/Http.h index d13b049ab..3128d39a9 100644 --- a/src/include/ipxe/efi/Protocol/Http.h +++ b/src/include/ipxe/efi/Protocol/Http.h @@ -191,11 +191,26 @@ typedef struct { /// The URI of a remote host. From the information in this field, the HTTP instance /// will be able to determine whether to use HTTP or HTTPS and will also be able to /// determine the port number to use. If no port number is specified, port 80 (HTTP) - /// is assumed. See RFC 3986 for more details on URI syntax. + /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI syntax. /// CHAR16 *Url; } EFI_HTTP_REQUEST_DATA; +/// +/// EFI_HTTP_CONNECT_REQUEST_DATA +/// +typedef struct { + EFI_HTTP_REQUEST_DATA Base; + /// + /// The URI of an Proxy Host. This field will be NULL if there is no Proxy Host + /// in the device path. From the information in this field, the HTTP instance will + /// be able to determine whether to use HTTP or HTTPS and will also be able to + /// determine the port number to use. If no port number is specified, port 80 (HTTP) + /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI syntax. + /// + CHAR16 *ProxyUrl; +} EFI_HTTP_CONNECT_REQUEST_DATA; + /// /// EFI_HTTP_RESPONSE_DATA /// diff --git a/src/include/ipxe/efi/Protocol/PxeBaseCode.h b/src/include/ipxe/efi/Protocol/PxeBaseCode.h index 212dd677b..3498eba5b 100644 --- a/src/include/ipxe/efi/Protocol/PxeBaseCode.h +++ b/src/include/ipxe/efi/Protocol/PxeBaseCode.h @@ -155,8 +155,6 @@ typedef UINT16 EFI_PXE_BASE_CODE_UDP_PORT; #define EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE 0x0006 #elif defined (MDE_CPU_X64) #define EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE 0x0007 -#elif defined (MDE_CPU_ARM) -#define EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE 0x000A #elif defined (MDE_CPU_AARCH64) #define EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE 0x000B #elif defined (MDE_CPU_RISCV64) diff --git a/src/include/ipxe/efi/Protocol/SimplePointer.h b/src/include/ipxe/efi/Protocol/SimplePointer.h index 45ddf8d5c..3993918fb 100644 --- a/src/include/ipxe/efi/Protocol/SimplePointer.h +++ b/src/include/ipxe/efi/Protocol/SimplePointer.h @@ -56,12 +56,12 @@ typedef struct { UINT64 ResolutionX; /// /// The resolution of the pointer device on the y-axis in counts/mm. - /// If 0, then the pointer device does not support an x-axis. + /// If 0, then the pointer device does not support a y-axis. /// UINT64 ResolutionY; /// /// The resolution of the pointer device on the z-axis in counts/mm. - /// If 0, then the pointer device does not support an x-axis. + /// If 0, then the pointer device does not support a z-axis. /// UINT64 ResolutionZ; /// diff --git a/src/include/ipxe/efi/Protocol/UnicodeCollation.h b/src/include/ipxe/efi/Protocol/UnicodeCollation.h index f708624ee..45f1e5e65 100644 --- a/src/include/ipxe/efi/Protocol/UnicodeCollation.h +++ b/src/include/ipxe/efi/Protocol/UnicodeCollation.h @@ -13,11 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent FILE_LICENCE ( BSD2_PATENT ); -#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \ - { \ - 0x1d85cd7f, 0xf43d, 0x11d2, {0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ - } - #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \ { \ 0xa4c751fc, 0x23ae, 0x4c3e, {0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49 } \ @@ -25,16 +20,6 @@ FILE_LICENCE ( BSD2_PATENT ); typedef struct _EFI_UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_PROTOCOL; -/// -/// Protocol GUID name defined in EFI1.1. -/// -#define UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_PROTOCOL_GUID - -/// -/// Protocol defined in EFI1.1. -/// -typedef EFI_UNICODE_COLLATION_PROTOCOL UNICODE_COLLATION_INTERFACE; - /// /// Protocol data structures and defines /// @@ -182,7 +167,6 @@ struct _EFI_UNICODE_COLLATION_PROTOCOL { CHAR8 *SupportedLanguages; }; -extern EFI_GUID gEfiUnicodeCollationProtocolGuid; extern EFI_GUID gEfiUnicodeCollation2ProtocolGuid; #endif diff --git a/src/include/ipxe/efi/Uefi/UefiBaseType.h b/src/include/ipxe/efi/Uefi/UefiBaseType.h index bf3aa9bb2..386d3feb1 100644 --- a/src/include/ipxe/efi/Uefi/UefiBaseType.h +++ b/src/include/ipxe/efi/Uefi/UefiBaseType.h @@ -234,11 +234,6 @@ typedef union { /// #define EFI_IMAGE_MACHINE_X64 0x8664 -/// -/// PE32+ Machine type for ARM mixed ARM and Thumb/Thumb2 images. -/// -#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2 - /// /// PE32+ Machine type for AARCH64 A64 images. /// @@ -272,12 +267,6 @@ typedef union { #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32) - #elif defined (MDE_CPU_ARM) - -#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) - -#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) - #elif defined (MDE_CPU_AARCH64) #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ diff --git a/src/include/ipxe/efi/Uefi/UefiSpec.h b/src/include/ipxe/efi/Uefi/UefiSpec.h index b007afee0..c509602ca 100644 --- a/src/include/ipxe/efi/Uefi/UefiSpec.h +++ b/src/include/ipxe/efi/Uefi/UefiSpec.h @@ -2269,7 +2269,7 @@ typedef struct { #define EFI_REMOVABLE_MEDIA_FILE_NAME_IA32 L"\\EFI\\BOOT\\BOOTIA32.EFI" #define EFI_REMOVABLE_MEDIA_FILE_NAME_IA64 L"\\EFI\\BOOT\\BOOTIA64.EFI" #define EFI_REMOVABLE_MEDIA_FILE_NAME_X64 L"\\EFI\\BOOT\\BOOTX64.EFI" -#define EFI_REMOVABLE_MEDIA_FILE_NAME_ARM L"\\EFI\\BOOT\\BOOTARM.EFI" +#define EFI_REMOVABLE_MEDIA_FILE_NAME_EBC L"\\EFI\\BOOT\\BOOTARM.EFI" #define EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64 L"\\EFI\\BOOT\\BOOTAA64.EFI" #define EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64 L"\\EFI\\BOOT\\BOOTRISCV64.EFI" #define EFI_REMOVABLE_MEDIA_FILE_NAME_LOONGARCH64 L"\\EFI\\BOOT\\BOOTLOONGARCH64.EFI" @@ -2280,8 +2280,7 @@ typedef struct { #elif defined (MDE_CPU_X64) #define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_X64 #elif defined (MDE_CPU_EBC) - #elif defined (MDE_CPU_ARM) -#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_ARM +#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_EBC #elif defined (MDE_CPU_AARCH64) #define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64 #elif defined (MDE_CPU_RISCV64) diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 84c517443..824db1b9a 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -108,6 +108,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); { 0x607f766c, 0x7455, 0x42be, \ { 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f } } +/* Unicode collation protocol GUID was deleted from EDK2 headers */ +#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \ + { 0x1d85cd7f, 0xf43d, 0x11d2, \ + { 0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } + /** Absolute pointer protocol GUID */ EFI_GUID efi_absolute_pointer_protocol_guid = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID; diff --git a/src/util/efirom.c b/src/util/efirom.c index 1220c187a..f5ec9a16d 100644 --- a/src/util/efirom.c +++ b/src/util/efirom.c @@ -34,6 +34,9 @@ #include #include +/* Provide constants spuriously deleted from EDK2 headers */ +#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01c2 + #define eprintf(...) fprintf ( stderr, __VA_ARGS__ ) /* Round up ROM size */ diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c index 5434e7040..91c107ae9 100644 --- a/src/util/elf2efi.c +++ b/src/util/elf2efi.c @@ -38,6 +38,9 @@ #include #include +/* Provide constants spuriously deleted from EDK2 headers */ +#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01c2 + #define eprintf(...) fprintf ( stderr, __VA_ARGS__ ) #undef ELF_R_TYPE -- cgit v1.2.3-55-g7522 From 5154b6fcc50a73eedf78ad4bb4a619054d77ed97 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Nov 2025 16:22:21 +0000 Subject: [efi] Add storage security command protocol header and GUID definition Signed-off-by: Michael Brown --- .../ipxe/efi/Protocol/StorageSecurityCommand.h | 212 +++++++++++++++++++++ src/include/ipxe/efi/efi.h | 1 + src/interface/efi/efi_guid.c | 7 + 3 files changed, 220 insertions(+) create mode 100644 src/include/ipxe/efi/Protocol/StorageSecurityCommand.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Protocol/StorageSecurityCommand.h b/src/include/ipxe/efi/Protocol/StorageSecurityCommand.h new file mode 100644 index 000000000..9e53de70c --- /dev/null +++ b/src/include/ipxe/efi/Protocol/StorageSecurityCommand.h @@ -0,0 +1,212 @@ +/** @file + EFI Storage Security Command Protocol as defined in UEFI 2.3.1 specification. + This protocol is used to abstract mass storage devices to allow code running in + the EFI boot services environment to send security protocol commands to mass + storage devices without specific knowledge of the type of device or controller + that manages the device. + + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __STORAGE_SECURITY_COMMAND_H__ +#define __STORAGE_SECURITY_COMMAND_H__ + +FILE_LICENCE ( BSD2_PATENT ); + +#define EFI_STORAGE_SECURITY_COMMAND_PROTOCOL_GUID \ + { \ + 0xC88B0B6D, 0x0DFC, 0x49A7, {0x9C, 0xB4, 0x49, 0x07, 0x4B, 0x4C, 0x3A, 0x78 } \ + } + +typedef struct _EFI_STORAGE_SECURITY_COMMAND_PROTOCOL EFI_STORAGE_SECURITY_COMMAND_PROTOCOL; + +/** + Send a security protocol command to a device that receives data and/or the result + of one or more commands sent by SendData. + + The ReceiveData function sends a security protocol command to the given MediaId. + The security protocol command sent is defined by SecurityProtocolId and contains + the security protocol specific data SecurityProtocolSpecificData. The function + returns the data from the security protocol command in PayloadBuffer. + + For devices supporting the SCSI command set, the security protocol command is sent + using the SECURITY PROTOCOL IN command defined in SPC-4. + + For devices supporting the ATA command set, the security protocol command is sent + using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize + is non-zero. + + If the PayloadBufferSize is zero, the security protocol command is sent using the + Trusted Non-Data command defined in ATA8-ACS. + + If PayloadBufferSize is too small to store the available data from the security + protocol command, the function shall copy PayloadBufferSize bytes into the + PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL. + + If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero, + the function shall return EFI_INVALID_PARAMETER. + + If the given MediaId does not support security protocol commands, the function shall + return EFI_UNSUPPORTED. If there is no media in the device, the function returns + EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device, + the function returns EFI_MEDIA_CHANGED. + + If the security protocol fails to complete within the Timeout period, the function + shall return EFI_TIMEOUT. + + If the security protocol command completes without an error, the function shall + return EFI_SUCCESS. If the security protocol command completes with an error, the + function shall return EFI_DEVICE_ERROR. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to receive data from. If there is no + block IO protocol supported by the physical device, the + value of MediaId is undefined. + @param Timeout The timeout, in 100ns units, to use for the execution + of the security protocol command. A Timeout value of 0 + means that this function will wait indefinitely for the + security protocol command to execute. If Timeout is greater + than zero, then this function will return EFI_TIMEOUT if the + time required to execute the receive data command is greater than Timeout. + @param SecurityProtocolId The value of the "Security Protocol" parameter of + the security protocol command to be sent. + @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter + of the security protocol command to be sent. + @param PayloadBufferSize Size in bytes of the payload data buffer. + @param PayloadBuffer A pointer to a destination buffer to store the security + protocol command specific payload data for the security + protocol command. The caller is responsible for having + either implicit or explicit ownership of the buffer. + @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the + data written to the payload data buffer. + + @retval EFI_SUCCESS The security protocol command completed successfully. + @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available + data from the device. The PayloadBuffer contains the truncated data. + @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands. + @retval EFI_DEVICE_ERROR The security protocol command completed with an error. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. + @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and + PayloadBufferSize is non-zero. + @retval EFI_TIMEOUT A timeout occurred while waiting for the security + protocol command to execute. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_STORAGE_SECURITY_RECEIVE_DATA)( + IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Timeout, + IN UINT8 SecurityProtocolId, + IN UINT16 SecurityProtocolSpecificData, + IN UINTN PayloadBufferSize, + OUT VOID *PayloadBuffer, + OUT UINTN *PayloadTransferSize + ); + +/** + Send a security protocol command to a device. + + The SendData function sends a security protocol command containing the payload + PayloadBuffer to the given MediaId. The security protocol command sent is + defined by SecurityProtocolId and contains the security protocol specific data + SecurityProtocolSpecificData. If the underlying protocol command requires a + specific padding for the command payload, the SendData function shall add padding + bytes to the command payload to satisfy the padding requirements. + + For devices supporting the SCSI command set, the security protocol command is sent + using the SECURITY PROTOCOL OUT command defined in SPC-4. + + For devices supporting the ATA command set, the security protocol command is sent + using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize + is non-zero. If the PayloadBufferSize is zero, the security protocol command is + sent using the Trusted Non-Data command defined in ATA8-ACS. + + If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall + return EFI_INVALID_PARAMETER. + + If the given MediaId does not support security protocol commands, the function + shall return EFI_UNSUPPORTED. If there is no media in the device, the function + returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the + device, the function returns EFI_MEDIA_CHANGED. + + If the security protocol fails to complete within the Timeout period, the function + shall return EFI_TIMEOUT. + + If the security protocol command completes without an error, the function shall return + EFI_SUCCESS. If the security protocol command completes with an error, the function + shall return EFI_DEVICE_ERROR. + + @param This Indicates a pointer to the calling context. + @param MediaId ID of the medium to receive data from. If there is no + block IO protocol supported by the physical device, the + value of MediaId is undefined. + @param Timeout The timeout, in 100ns units, to use for the execution + of the security protocol command. A Timeout value of 0 + means that this function will wait indefinitely for the + security protocol command to execute. If Timeout is greater + than zero, then this function will return EFI_TIMEOUT if the + time required to execute the receive data command is greater than Timeout. + @param SecurityProtocolId The value of the "Security Protocol" parameter of + the security protocol command to be sent. + @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter + of the security protocol command to be sent. + @param PayloadBufferSize Size in bytes of the payload data buffer. + @param PayloadBuffer A pointer to a destination buffer to store the security + protocol command specific payload data for the security + protocol command. + + @retval EFI_SUCCESS The security protocol command completed successfully. + @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands. + @retval EFI_DEVICE_ERROR The security protocol command completed with an error. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. + @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero. + @retval EFI_TIMEOUT A timeout occurred while waiting for the security + protocol command to execute. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_STORAGE_SECURITY_SEND_DATA)( + IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Timeout, + IN UINT8 SecurityProtocolId, + IN UINT16 SecurityProtocolSpecificData, + IN UINTN PayloadBufferSize, + IN VOID *PayloadBuffer + ); + +/// +/// The EFI_STORAGE_SECURITY_COMMAND_PROTOCOL is used to send security protocol +/// commands to a mass storage device. Two types of security protocol commands +/// are supported. SendData sends a command with data to a device. ReceiveData +/// sends a command that receives data and/or the result of one or more commands +/// sent by SendData. +/// +/// The security protocol command formats supported shall be based on the definition +/// of the SECURITY PROTOCOL IN and SECURITY PROTOCOL OUT commands defined in SPC-4. +/// If the device uses the SCSI command set, no translation is needed in the firmware +/// and the firmware can package the parameters into a SECURITY PROTOCOL IN or SECURITY +/// PROTOCOL OUT command and send the command to the device. If the device uses a +/// non-SCSI command set, the firmware shall map the command and data payload to the +/// corresponding command and payload format defined in the non-SCSI command set +/// (for example, TRUSTED RECEIVE and TRUSTED SEND in ATA8-ACS). +/// +/// The firmware shall automatically add an EFI_STORAGE_SECURITY_COMMAND_PROTOCOL +/// for any storage devices detected during system boot that support SPC-4, ATA8-ACS +/// or their successors. +/// +struct _EFI_STORAGE_SECURITY_COMMAND_PROTOCOL { + EFI_STORAGE_SECURITY_RECEIVE_DATA ReceiveData; + EFI_STORAGE_SECURITY_SEND_DATA SendData; +}; + +extern EFI_GUID gEfiStorageSecurityCommandProtocolGuid; + +#endif diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 9dd26bff0..30b10f507 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -233,6 +233,7 @@ extern EFI_GUID efi_simple_pointer_protocol_guid; extern EFI_GUID efi_simple_text_input_protocol_guid; extern EFI_GUID efi_simple_text_input_ex_protocol_guid; extern EFI_GUID efi_simple_text_output_protocol_guid; +extern EFI_GUID efi_storage_security_command_protocol_guid; extern EFI_GUID efi_supplicant_protocol_guid; extern EFI_GUID efi_tcg_protocol_guid; extern EFI_GUID efi_tcg2_protocol_guid; diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 824db1b9a..8c8c06d7c 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -74,6 +74,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include #include @@ -353,6 +354,10 @@ EFI_GUID efi_simple_text_input_ex_protocol_guid EFI_GUID efi_simple_text_output_protocol_guid = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID; +/** Storage security protocol GUID */ +EFI_GUID efi_storage_security_command_protocol_guid + = EFI_STORAGE_SECURITY_COMMAND_PROTOCOL_GUID; + /** Supplicant protocol GUID */ EFI_GUID efi_supplicant_protocol_guid = EFI_SUPPLICANT_PROTOCOL_GUID; @@ -650,6 +655,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Smbios" }, { &efi_smbios3_table_guid, "Smbios3" }, + { &efi_storage_security_command_protocol_guid, + "StorageSecurityCommand" }, { &efi_supplicant_protocol_guid, "Supplicant" }, { &efi_tcg_protocol_guid, -- cgit v1.2.3-55-g7522 From 5c135240bc2cc0e4d885f65f9a20cfa76bd8916a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 12 Nov 2025 12:01:37 +0000 Subject: [efi] Add Microsoft vendor GUID definition Signed-off-by: Michael Brown --- src/include/ipxe/efi/Guid/MicrosoftVendor.h | 57 +++++++++++++++++++++++++++++ src/include/ipxe/efi/efi.h | 1 + src/include/ipxe/efi/import.pl | 3 +- src/interface/efi/efi_guid.c | 6 +++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/include/ipxe/efi/Guid/MicrosoftVendor.h (limited to 'src/interface') diff --git a/src/include/ipxe/efi/Guid/MicrosoftVendor.h b/src/include/ipxe/efi/Guid/MicrosoftVendor.h new file mode 100644 index 000000000..063c89213 --- /dev/null +++ b/src/include/ipxe/efi/Guid/MicrosoftVendor.h @@ -0,0 +1,57 @@ +/** @file + Declare the GUID that is expected: + + - as EFI_SIGNATURE_DATA.SignatureOwner GUID in association with X509 and + RSA2048 Secure Boot certificates issued by/for Microsoft, + + - as UEFI variable vendor GUID in association with (unspecified) + Microsoft-owned variables. + + Copyright (C) 2014-2019, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Specification Reference: + - MSDN: System.Fundamentals.Firmware at + . +**/ + +#ifndef MICROSOFT_VENDOR_H_ +#define MICROSOFT_VENDOR_H_ + +FILE_LICENCE ( BSD2_PATENT ); + +#include + +// +// The following test cases of the Secure Boot Logo Test in the Microsoft +// Hardware Certification Kit: +// +// - Microsoft.UefiSecureBootLogo.Tests.OutOfBoxVerifyMicrosoftKEKpresent +// - Microsoft.UefiSecureBootLogo.Tests.OutOfBoxConfirmMicrosoftSignatureInDB +// +// expect the EFI_SIGNATURE_DATA.SignatureOwner GUID to be +// 77FA9ABD-0359-4D32-BD60-28F4E78F784B, when the +// EFI_SIGNATURE_DATA.SignatureData field carries any of the following X509 +// certificates: +// +// - "Microsoft Corporation KEK CA 2011" (in KEK) +// - "Microsoft Windows Production PCA 2011" (in db) +// - "Microsoft Corporation UEFI CA 2011" (in db) +// +// This is despite the fact that the UEFI specification requires +// EFI_SIGNATURE_DATA.SignatureOwner to reflect the agent (i.e., OS, +// application or driver) that enrolled and therefore owns +// EFI_SIGNATURE_DATA.SignatureData, and not the organization that issued +// EFI_SIGNATURE_DATA.SignatureData. +// +#define MICROSOFT_VENDOR_GUID \ + { 0x77fa9abd, \ + 0x0359, \ + 0x4d32, \ + { 0xbd, 0x60, 0x28, 0xf4, 0xe7, 0x8f, 0x78, 0x4b }, \ + } + +extern EFI_GUID gMicrosoftVendorGuid; + +#endif /* MICROSOFT_VENDOR_H_ */ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 30b10f507..bfef573ed 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -264,6 +264,7 @@ extern EFI_GUID efi_cert_x509_guid; extern EFI_GUID efi_file_info_id; extern EFI_GUID efi_file_system_info_id; extern EFI_GUID efi_global_variable; +extern EFI_GUID efi_microsoft_vendor_guid; extern EFI_GUID efi_tls_ca_certificate_guid; extern EFI_HANDLE efi_image_handle; diff --git a/src/include/ipxe/efi/import.pl b/src/include/ipxe/efi/import.pl index 75c200de0..cdd58e86d 100755 --- a/src/include/ipxe/efi/import.pl +++ b/src/include/ipxe/efi/import.pl @@ -119,7 +119,8 @@ my $edktop = shift; # Identify edk import directories my $edkdirs = [ "MdePkg/Include", "MdeModulePkg/Include", - "NetworkPkg/Include", "EmbeddedPkg/Include" ]; + "NetworkPkg/Include", "EmbeddedPkg/Include", + "OvmfPkg/Include" ]; foreach my $edkdir ( @$edkdirs ) { die "Directory \"$edktop\" does not appear to contain the EFI EDK2 " ."(missing \"$edkdir\")\n" unless -d catdir ( $edktop, $edkdir ); diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 8c8c06d7c..967f1f1f5 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -95,6 +95,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include #include @@ -466,6 +467,9 @@ EFI_GUID efi_file_system_info_id = EFI_FILE_SYSTEM_INFO_ID; /** Global variable GUID */ EFI_GUID efi_global_variable = EFI_GLOBAL_VARIABLE; +/** Microsoft vendor GUID */ +EFI_GUID efi_microsoft_vendor_guid = MICROSOFT_VENDOR_GUID; + /** TLS CA certificate variable GUID */ EFI_GUID efi_tls_ca_certificate_guid = EFI_TLS_CA_CERTIFICATE_GUID; @@ -615,6 +619,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "ManagedNetwork" }, { &efi_managed_network_service_binding_protocol_guid, "ManagedNetworkSb" }, + { &efi_microsoft_vendor_guid, + "Microsoft" }, { &efi_mtftp4_protocol_guid, "Mtftp4" }, { &efi_mtftp4_service_binding_protocol_guid, -- cgit v1.2.3-55-g7522 From 0a8e34657ea3e266d6e62c0ee2f839fde56be805 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 12 Nov 2025 12:09:40 +0000 Subject: [efi] Add image security database GUID definition Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi.h | 1 + src/interface/efi/efi_guid.c | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index bfef573ed..3085704b0 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -264,6 +264,7 @@ extern EFI_GUID efi_cert_x509_guid; extern EFI_GUID efi_file_info_id; extern EFI_GUID efi_file_system_info_id; extern EFI_GUID efi_global_variable; +extern EFI_GUID efi_image_security_database_guid; extern EFI_GUID efi_microsoft_vendor_guid; extern EFI_GUID efi_tls_ca_certificate_guid; diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 967f1f1f5..135eeb881 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -467,6 +467,9 @@ EFI_GUID efi_file_system_info_id = EFI_FILE_SYSTEM_INFO_ID; /** Global variable GUID */ EFI_GUID efi_global_variable = EFI_GLOBAL_VARIABLE; +/** Image security database GUID */ +EFI_GUID efi_image_security_database_guid = EFI_IMAGE_SECURITY_DATABASE_GUID; + /** Microsoft vendor GUID */ EFI_GUID efi_microsoft_vendor_guid = MICROSOFT_VENDOR_GUID; @@ -589,6 +592,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = { "Http" }, { &efi_http_service_binding_protocol_guid, "HttpSb" }, + { &efi_image_security_database_guid, + "ImageSecDb" }, { &efi_ip4_protocol_guid, "Ip4" }, { &efi_ip4_config_protocol_guid, -- cgit v1.2.3-55-g7522 From 925af2b4d72edd989a12fee46511faa10393bb11 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 13 Nov 2025 13:17:25 +0000 Subject: [efi] Allow SAN-booted images to be traced via DEBUG=efi_wrap Signed-off-by: Michael Brown --- src/interface/efi/efi_block.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/interface') diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index cc93edb85..10952ef8a 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -59,6 +59,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include #include /** ACPI table protocol protocol */ @@ -861,12 +862,18 @@ static int efi_block_exec ( unsigned int drive, } } + /* Wrap calls made by the loaded image (for debugging) */ + efi_wrap_image ( image ); + /* Start image */ efirc = bs->StartImage ( image, NULL, NULL ); rc = ( efirc ? -EEFI ( efirc ) : 0 ); DBGC ( drive, "EFIBLK %#02x boot image returned: %s\n", drive, strerror ( rc ) ); + /* Remove wrapper */ + efi_unwrap(); + err_load_security_violation: bs->UnloadImage ( image ); err_load: -- cgit v1.2.3-55-g7522 From 33834746537d18e899559470970706d37ae2722b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 13 Nov 2025 14:38:12 +0000 Subject: [efi] Wrap a selection of runtime services calls Allow DEBUG=efi_wrap to trace various runtime services calls as well as the existing boot services calls. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi_wrap.h | 1 + src/interface/efi/efi_wrap.c | 255 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 249 insertions(+), 7 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi_wrap.h b/src/include/ipxe/efi/efi_wrap.h index d1e970bde..1cae3d2db 100644 --- a/src/include/ipxe/efi/efi_wrap.h +++ b/src/include/ipxe/efi/efi_wrap.h @@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include extern void efi_wrap_bs ( EFI_BOOT_SERVICES *wrapped ); +extern void efi_wrap_rs ( EFI_RUNTIME_SERVICES *wrapped ); extern void efi_wrap_systab ( int global ); extern void efi_unwrap ( void ); diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 936074f2a..320a32f02 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -40,6 +40,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Colour for debug messages */ #define colour &efi_systab +/** Maximum size for hex dumps */ +#define EFI_WRAP_DUMP_MAX 128 + /** Number of lines to prescroll when needed */ #define EFI_WRAP_PRESCROLL 16 @@ -55,6 +58,12 @@ static EFI_BOOT_SERVICES *efi_bs_orig; /** Backup of original EFI boot services table */ static EFI_BOOT_SERVICES efi_bs_copy; +/** Original EFI runtime services table pointer */ +static EFI_RUNTIME_SERVICES *efi_rs_orig; + +/** Backup of original EFI runtime services table */ +static EFI_RUNTIME_SERVICES efi_rs_copy; + /** * Convert EFI status code to text * @@ -189,6 +198,43 @@ static const char * efi_timer_delay ( EFI_TIMER_DELAY type ) { } } +/** + * Convert EFI time to text + * + * @v time Time, or NULL + * @ret text Time as text + */ +static const char * efi_time ( EFI_TIME *time ) { + static char buf[ 20 /* "xxxx-xx-xx xx:xx:xx" + NUL */ ]; + + if ( ! time ) + return ""; + snprintf ( buf, sizeof ( buf ), "%04d-%02d-%02d %02d:%02d:%02d", + time->Year, time->Month, time->Day, time->Hour, + time->Minute, time->Second ); + return buf; +} + +/** + * Convert EFI reset type to text + * + * @v type Reset type + * @ret text Reset type as text + */ +static const char * efi_reset_type ( EFI_RESET_TYPE type ) { + static char buf[ 11 /* "0xXXXXXXXX" + NUL */ ]; + + switch ( type ) { + case EfiResetCold: return "Cold"; + case EfiResetWarm: return "Warm"; + case EfiResetShutdown: return "Shutdown"; + case EfiResetPlatformSpecific: return "PlatformSpecific"; + default: + snprintf ( buf, sizeof ( buf ), "%#x", type ); + return buf; + } +} + /** * Pre-scroll display to create space for output lines * @@ -837,11 +883,11 @@ efi_stall_wrapper ( UINTN microseconds ) { void *retaddr = __builtin_return_address ( 0 ); EFI_STATUS efirc; - DBGC2 ( colour, "Stall ( %ld.%06lds ) ", + DBGCP ( colour, "Stall ( %ld.%06lds ) ", ( ( unsigned long ) ( microseconds / 1000000 ) ), ( ( unsigned long ) ( microseconds % 1000000 ) ) ); efirc = bs->Stall ( microseconds ); - DBGC2 ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); + DBGCP ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); return efirc; } @@ -1195,6 +1241,169 @@ efi_create_event_ex_wrapper ( UINT32 type, EFI_TPL notify_tpl, return efirc; } +/** + * Wrap GetTime() + * + */ +static EFI_STATUS EFIAPI +efi_get_time_wrapper ( EFI_TIME *time, EFI_TIME_CAPABILITIES *cap ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + EFI_STATUS efirc; + + DBGCP ( colour, "GetTime() " ); + efirc = rs->GetTime ( time, cap ); + DBGCP ( colour, "= %s ( %s ) -> %p\n", + efi_status ( efirc ), efi_time ( time ), retaddr ); + return efirc; +} + +/** + * Wrap SetTime() + * + */ +static EFI_STATUS EFIAPI +efi_set_time_wrapper ( EFI_TIME *time ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + EFI_STATUS efirc; + + DBGC ( colour, "SetTime ( %s ) ", efi_time ( time ) ); + efirc = rs->SetTime ( time ); + DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); + return efirc; +} + +/** + * Wrap GetWakeupTime() + * + */ +static EFI_STATUS EFIAPI +efi_get_wakeup_time_wrapper ( BOOLEAN *enabled, BOOLEAN *pending, + EFI_TIME *time ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + EFI_STATUS efirc; + + DBGC ( colour, "GetWakeupTime() " ); + efirc = rs->GetWakeupTime ( enabled, pending, time ); + DBGC ( colour, "= %s ( %s, %s, %s ) -> %p\n", efi_status ( efirc ), + efi_boolean ( *enabled ), efi_boolean ( *pending ), + efi_time ( time ), retaddr ); + return efirc; +} + +/** + * Wrap SetWakeupTime() + * + */ +static EFI_STATUS EFIAPI +efi_set_wakeup_time_wrapper ( BOOLEAN enable, EFI_TIME *time ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + EFI_STATUS efirc; + + DBGC ( colour, "SetWakeupTime ( %s, %s ) ", + efi_boolean ( enable ), efi_time ( time ) ); + efirc = rs->SetWakeupTime ( enable, time ); + DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); + return efirc; +} + +/** + * Wrap GetVariable() + * + */ +static EFI_STATUS EFIAPI +efi_get_variable_wrapper ( CHAR16 *name, EFI_GUID *guid, UINT32 *attrs, + UINTN *len, VOID *data ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + size_t dumplen; + EFI_STATUS efirc; + + DBGC ( colour, "GetVariable ( %s:%ls, %#llx ) ", + efi_guid_ntoa ( guid ), name, ( ( unsigned long long ) *len ) ); + efirc = rs->GetVariable ( name, guid, attrs, len, data ); + DBGC ( colour, "= %s ( %#llx", + efi_status ( efirc ), ( ( unsigned long long ) *len ) ); + if ( DBG_EXTRA && ( efirc == 0 ) ) { + dumplen = *len; + if ( dumplen > EFI_WRAP_DUMP_MAX ) + dumplen = EFI_WRAP_DUMP_MAX; + DBGC2 ( colour, ",\n" ); + DBGC2_HD ( colour, data, dumplen ); + if ( dumplen != *len ) + DBGC2 ( colour, "... " ); + } else { + DBGC ( colour, " " ); + } + DBGC ( colour, ") -> %p\n", retaddr ); + return efirc; +} + +/** + * Wrap GetNextVariableName() + * + */ +static EFI_STATUS EFIAPI +efi_get_next_variable_name_wrapper ( UINTN *len, CHAR16 *name, + EFI_GUID *guid ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + EFI_STATUS efirc; + + DBGC ( colour, "GetNextVariableName ( %#llx, %s:%ls ) ", + ( ( unsigned long long ) *len ), efi_guid_ntoa ( guid ), name ); + efirc = rs->GetNextVariableName ( len, name, guid ); + DBGC ( colour, "= %s ( %#llx, %s:%ls ) -> %p\n", efi_status ( efirc ), + ( ( unsigned long long ) *len ), efi_guid_ntoa ( guid ), name, + retaddr ); + return efirc; +} + +/** + * Wrap SetVariable() + * + */ +static EFI_STATUS EFIAPI +efi_set_variable_wrapper ( CHAR16 *name, EFI_GUID *guid, UINT32 attrs, + UINTN len, VOID *data ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + EFI_STATUS efirc; + + DBGC ( colour, "SetVariable ( %s:%ls, %#02x", + efi_guid_ntoa ( guid ), name, attrs ); + if ( len ) { + DBGC ( colour, ",\n" ); + DBGC_HD ( colour, data, len ); + DBGC ( colour, ") " ); + } else { + DBGC ( colour, ", %#llx, %p ) ", + ( ( unsigned long long ) len ), data ); + } + efirc = rs->SetVariable ( name, guid, attrs, len, data ); + DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr ); + return efirc; +} + +/** + * Wrap ResetSystem() + * + */ +static VOID EFIAPI +efi_reset_system_wrapper ( EFI_RESET_TYPE type, EFI_STATUS status, + UINTN len, VOID *data ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + void *retaddr = __builtin_return_address ( 0 ); + + DBGC ( colour, "ResetSystem ( %s, %s, %#llx, %p ) -> %p\n", + efi_reset_type ( type ), efi_status ( status ), + ( ( unsigned long long ) len ), data, retaddr ); + rs->ResetSystem ( type, status, len, data ); +} + /** * Wrap a boot services table * @@ -1258,14 +1467,40 @@ void efi_wrap_bs ( EFI_BOOT_SERVICES *wrapper ) { wrapper->CreateEventEx = efi_create_event_ex_wrapper; } +/** + * Wrap a runtime services table + * + * @v wrapper Runtime services table to wrap + */ +void efi_wrap_rs ( EFI_RUNTIME_SERVICES *wrapper ) { + EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; + + /* Do nothing unless debugging is enabled */ + if ( ! DBG_LOG ) + return; + + /* Build boot services table wrapper */ + memcpy ( wrapper, rs, sizeof ( *wrapper ) ); + wrapper->GetTime = efi_get_time_wrapper; + wrapper->SetTime = efi_set_time_wrapper; + wrapper->GetWakeupTime = efi_get_wakeup_time_wrapper; + wrapper->SetWakeupTime = efi_set_wakeup_time_wrapper; + wrapper->GetVariable = efi_get_variable_wrapper; + wrapper->GetNextVariableName = efi_get_next_variable_name_wrapper; + wrapper->SetVariable = efi_set_variable_wrapper; + wrapper->ResetSystem = efi_reset_system_wrapper; +} + /** * Wrap the public EFI system table * * @v global Patch global boot services table in-place */ void efi_wrap_systab ( int global ) { - static EFI_BOOT_SERVICES local; - EFI_BOOT_SERVICES *wrapper; + static EFI_BOOT_SERVICES local_bs; + static EFI_RUNTIME_SERVICES local_rs; + EFI_BOOT_SERVICES *bs; + EFI_RUNTIME_SERVICES *rs; /* Do nothing unless debugging is enabled */ if ( ! DBG_LOG ) @@ -1275,7 +1510,9 @@ void efi_wrap_systab ( int global ) { if ( ! efi_systab_pub ) { efi_systab_pub = efi_systab; efi_bs_orig = efi_systab_pub->BootServices; + efi_rs_orig = efi_systab_pub->RuntimeServices; memcpy ( &efi_bs_copy, efi_bs_orig, sizeof ( efi_bs_copy ) ); + memcpy ( &efi_rs_copy, efi_rs_orig, sizeof ( efi_rs_copy ) ); } /* Construct and use private system table */ @@ -1283,13 +1520,17 @@ void efi_wrap_systab ( int global ) { memcpy ( &efi_systab_priv, efi_systab_pub, sizeof ( efi_systab_priv ) ); efi_systab_priv.BootServices = &efi_bs_copy; + efi_systab_priv.RuntimeServices = &efi_rs_copy; efi_systab = &efi_systab_priv; } /* Wrap global or local boot services table as applicable */ - wrapper = ( global ? efi_bs_orig : &local ); - efi_wrap_bs ( wrapper ); - efi_systab_pub->BootServices = wrapper; + bs = ( global ? efi_bs_orig : &local_bs ); + rs = ( global ? efi_rs_orig : &local_rs ); + efi_wrap_bs ( bs ); + efi_wrap_rs ( rs ); + efi_systab_pub->BootServices = bs; + efi_systab_pub->RuntimeServices = rs; DBGC ( colour, "WRAP installed %s wrappers\n", ( global ? "global" : "local" ) ); } -- cgit v1.2.3-55-g7522 From dfea3bbfad75aa742623beb4d88e2be086a4b8ee Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Nov 2025 20:27:53 +0000 Subject: [pci] Use runtime selectable PCI I/O API for EFI cloud builds On some systems (observed on an AWS m8g.medium instance in eu-west-2), the UEFI firmware omits the PCI host bridge drivers for all but the first PCI bus. The observable result is that any devices on other PCI buses (such as the ENA network device) are not enumerated by the UEFI firmware and are therefore unusable by iPXE. Support these systems by switching to using PCIAPI_CLOUD for EFI cloud builds, trying the EFI PCI I/O API first and falling back to direct access (via ECAM) for devices that the UEFI firmware has failed to enumerate itself. Signed-off-by: Michael Brown --- src/config/cloud/ioapi.h | 10 ++++++++++ src/config/config_pci.c | 3 +++ src/include/ipxe/pci_io.h | 7 ++++--- src/interface/efi/efi_pci.c | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/interface') diff --git a/src/config/cloud/ioapi.h b/src/config/cloud/ioapi.h index bcd245981..3ab05082f 100644 --- a/src/config/cloud/ioapi.h +++ b/src/config/cloud/ioapi.h @@ -8,3 +8,13 @@ #define PCIAPI_RUNTIME_PCBIOS #define PCIAPI_RUNTIME_DIRECT #endif + +/* Work around missing PCI host bridge drivers in the cut-down UEFI found + * in some AWS EC2 instances. + */ +#ifdef PLATFORM_efi +#undef PCIAPI_EFI +#define PCIAPI_CLOUD +#define PCIAPI_RUNTIME_EFI +#define PCIAPI_RUNTIME_ECAM +#endif diff --git a/src/config/config_pci.c b/src/config/config_pci.c index 8ed9f6603..b2adae995 100644 --- a/src/config/config_pci.c +++ b/src/config/config_pci.c @@ -45,3 +45,6 @@ REQUIRE_OBJECT ( pcibios ); #ifdef PCIAPI_RUNTIME_DIRECT REQUIRE_OBJECT ( pcidirect ); #endif +#ifdef PCIAPI_RUNTIME_EFI +REQUIRE_OBJECT ( efi_pci ); +#endif diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 0d32adf81..7ac09efb0 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -192,9 +192,10 @@ struct pci_api { #endif /* PCI runtime selectable API priorities */ -#define PCIAPI_PRIORITY_ECAM 01 /**< ACPI ECAM */ -#define PCIAPI_PRIORITY_PCBIOS 02 /**< PCI BIOS calls */ -#define PCIAPI_PRIORITY_DIRECT 03 /**< Direct Type 1 accesses */ +#define PCIAPI_PRIORITY_EFI 01 /**< EFI PCI I/O protocols */ +#define PCIAPI_PRIORITY_ECAM 02 /**< ACPI ECAM */ +#define PCIAPI_PRIORITY_PCBIOS 03 /**< PCI BIOS calls */ +#define PCIAPI_PRIORITY_DIRECT 04 /**< Direct Type 1 accesses */ /** Provide a runtime selectable PCI I/O API */ #define PROVIDE_PCIAPI_RUNTIME( subsys, priority ) \ diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index fbf06300b..f4853c234 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -436,6 +436,7 @@ PROVIDE_PCIAPI_INLINE ( efi, pci_write_config_byte ); PROVIDE_PCIAPI_INLINE ( efi, pci_write_config_word ); PROVIDE_PCIAPI_INLINE ( efi, pci_write_config_dword ); PROVIDE_PCIAPI ( efi, pci_ioremap, efipci_ioremap ); +PROVIDE_PCIAPI_RUNTIME ( efi, PCIAPI_PRIORITY_EFI ); /****************************************************************************** * -- cgit v1.2.3-55-g7522 From 19dffdc836d0cbfd79ec475160e4a22600f67584 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 25 Nov 2025 11:59:03 +0000 Subject: [efi] Allow for creating devices with no EFI parent device On some systems (observed on an AWS m8g.medium instance in eu-west-2), the UEFI firmware fails to enumerate some of the underlying hardware devices. On these systems, we cannot comply with the UEFI device model by adding our SNP device as a child of the hardware device and appending to the parent hardware device path, since no parent hardware device has been created. Work around these systems by allowing for the creation of SNP devices with no parent device. Signed-off-by: Michael Brown --- src/include/ipxe/efi/efi_snp.h | 4 +-- src/interface/efi/efi_path.c | 82 +++++++++++++++++++++++++++++++----------- src/interface/efi/efi_snp.c | 27 +++++++------- 3 files changed, 76 insertions(+), 37 deletions(-) (limited to 'src/interface') diff --git a/src/include/ipxe/efi/efi_snp.h b/src/include/ipxe/efi/efi_snp.h index 96373b57d..1095b19e3 100644 --- a/src/include/ipxe/efi/efi_snp.h +++ b/src/include/ipxe/efi/efi_snp.h @@ -30,8 +30,8 @@ struct efi_snp_device { struct list_head list; /** The underlying iPXE network device */ struct net_device *netdev; - /** The underlying EFI device */ - struct efi_device *efidev; + /** EFI parent device handle (if any) */ + EFI_HANDLE parent; /** EFI device handle */ EFI_HANDLE handle; /** The SNP structure itself */ diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c index 65ac3d6f5..dd0df67e5 100644 --- a/src/interface/efi/efi_path.c +++ b/src/interface/efi/efi_path.c @@ -47,6 +47,34 @@ FILE_LICENCE ( GPL2_OR_LATER ); * */ +/** Dummy parent device path + * + * This is used as the parent device path when we need to construct a + * path for a device that has no EFI parent device. + */ +static struct { + BBS_BBS_DEVICE_PATH bbs; + CHAR8 tring[4]; + EFI_DEVICE_PATH_PROTOCOL end; +} __attribute__ (( packed )) efi_dummy_parent_path = { + .bbs = { + .Header = { + .Type = BBS_DEVICE_PATH, + .SubType = BBS_BBS_DP, + .Length[0] = ( sizeof ( efi_dummy_parent_path.bbs ) + + sizeof ( efi_dummy_parent_path.tring )), + }, + .DeviceType = BBS_TYPE_UNKNOWN, + .String[0] = 'i', + }, + .tring = "PXE", + .end = { + .Type = END_DEVICE_PATH_TYPE, + .SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE, + .Length[0] = sizeof ( efi_dummy_parent_path.end ), + }, +}; + /** An EFI device path settings block */ struct efi_path_settings { /** Settings interface */ @@ -352,6 +380,24 @@ EFI_DEVICE_PATH_PROTOCOL * efi_paths ( EFI_DEVICE_PATH_PROTOCOL *first, ... ) { return path; } +/** + * Construct EFI parent device path + * + * @v dev Generic device + * @ret path Parent (or dummy) device path + */ +static EFI_DEVICE_PATH_PROTOCOL * efi_parent_path ( struct device *dev ) { + struct efi_device *efidev; + + /* Use EFI parent device's path, if possible */ + efidev = efidev_parent ( dev ); + if ( efidev ) + return efidev->path; + + /* Otherwise, use a dummy parent device path */ + return &efi_dummy_parent_path.bbs.Header; +} + /** * Construct EFI device path for network device * @@ -362,7 +408,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_paths ( EFI_DEVICE_PATH_PROTOCOL *first, ... ) { * allocated device path. */ EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path ( struct net_device *netdev ) { - struct efi_device *efidev; + EFI_DEVICE_PATH_PROTOCOL *parent; EFI_DEVICE_PATH_PROTOCOL *path; MAC_ADDR_DEVICE_PATH *macpath; VLAN_DEVICE_PATH *vlanpath; @@ -371,13 +417,11 @@ EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path ( struct net_device *netdev ) { size_t prefix_len; size_t len; - /* Find parent EFI device */ - efidev = efidev_parent ( netdev->dev ); - if ( ! efidev ) - return NULL; + /* Get parent EFI device path */ + parent = efi_parent_path ( netdev->dev ); /* Calculate device path length */ - prefix_len = efi_path_len ( efidev->path ); + prefix_len = efi_path_len ( parent ); len = ( prefix_len + sizeof ( *macpath ) + sizeof ( *vlanpath ) + sizeof ( *end ) ); @@ -387,7 +431,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path ( struct net_device *netdev ) { return NULL; /* Construct device path */ - memcpy ( path, efidev->path, prefix_len ); + memcpy ( path, parent, prefix_len ); macpath = ( ( ( void * ) path ) + prefix_len ); macpath->Header.Type = MESSAGING_DEVICE_PATH; macpath->Header.SubType = MSG_MAC_ADDR_DP; @@ -601,20 +645,18 @@ EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path ( struct ib_srp_device *ib_srp ) { union ib_srp_target_port_id *id = container_of ( &sbft->srp.target, union ib_srp_target_port_id, srp ); - struct efi_device *efidev; + EFI_DEVICE_PATH_PROTOCOL *parent; EFI_DEVICE_PATH_PROTOCOL *path; INFINIBAND_DEVICE_PATH *ibpath; EFI_DEVICE_PATH_PROTOCOL *end; size_t prefix_len; size_t len; - /* Find parent EFI device */ - efidev = efidev_parent ( ib_srp->ibdev->dev ); - if ( ! efidev ) - return NULL; + /* Get parent EFI device path */ + parent = efi_parent_path ( ib_srp->ibdev->dev ); /* Calculate device path length */ - prefix_len = efi_path_len ( efidev->path ); + prefix_len = efi_path_len ( parent ); len = ( prefix_len + sizeof ( *ibpath ) + sizeof ( *end ) ); /* Allocate device path */ @@ -623,7 +665,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path ( struct ib_srp_device *ib_srp ) { return NULL; /* Construct device path */ - memcpy ( path, efidev->path, prefix_len ); + memcpy ( path, parent, prefix_len ); ibpath = ( ( ( void * ) path ) + prefix_len ); ibpath->Header.Type = MESSAGING_DEVICE_PATH; ibpath->Header.SubType = MSG_INFINIBAND_DP; @@ -653,7 +695,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path ( struct ib_srp_device *ib_srp ) { */ EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function *func ) { struct usb_device *usb = func->usb; - struct efi_device *efidev; + EFI_DEVICE_PATH_PROTOCOL *parent; EFI_DEVICE_PATH_PROTOCOL *path; EFI_DEVICE_PATH_PROTOCOL *end; USB_DEVICE_PATH *usbpath; @@ -664,14 +706,12 @@ EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function *func ) { /* Sanity check */ assert ( func->desc.count >= 1 ); - /* Find parent EFI device */ - efidev = efidev_parent ( &func->dev ); - if ( ! efidev ) - return NULL; + /* Get parent EFI device path */ + parent = efi_parent_path ( &func->dev ); /* Calculate device path length */ count = ( usb_depth ( usb ) + 1 ); - prefix_len = efi_path_len ( efidev->path ); + prefix_len = efi_path_len ( parent ); len = ( prefix_len + ( count * sizeof ( *usbpath ) ) + sizeof ( *end ) ); @@ -681,7 +721,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function *func ) { return NULL; /* Construct device path */ - memcpy ( path, efidev->path, prefix_len ); + memcpy ( path, parent, prefix_len ); end = ( ( ( void * ) path ) + len - sizeof ( *end ) ); efi_path_terminate ( end ); usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) ); diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 88334c8d0..86ad87bde 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -1792,14 +1792,6 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { EFI_STATUS efirc; int rc; - /* Find parent EFI device */ - efidev = efidev_parent ( netdev->dev ); - if ( ! efidev ) { - DBG ( "SNP skipping non-EFI device %s\n", netdev->name ); - rc = 0; - goto err_no_efidev; - } - /* Allocate the SNP device */ snpdev = zalloc ( sizeof ( *snpdev ) ); if ( ! snpdev ) { @@ -1807,9 +1799,13 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { goto err_alloc_snp; } snpdev->netdev = netdev_get ( netdev ); - snpdev->efidev = efidev; INIT_LIST_HEAD ( &snpdev->rx ); + /* Find parent EFI device, if any */ + efidev = efidev_parent ( netdev->dev ); + if ( efidev ) + snpdev->parent = efidev->device; + /* Sanity check */ if ( netdev->ll_protocol->ll_addr_len > sizeof ( EFI_MAC_ADDRESS ) ) { DBGC ( snpdev, "SNPDEV %p cannot support link-layer address " @@ -1931,8 +1927,10 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { goto err_open_nii31; } - /* Add as child of EFI parent device */ - if ( ( rc = efi_child_add ( efidev->device, snpdev->handle ) ) != 0 ) { + /* Add as child of EFI parent device, if applicable */ + if ( snpdev->parent && + ( ( rc = efi_child_add ( snpdev->parent, + snpdev->handle ) ) != 0 ) ) { DBGC ( snpdev, "SNPDEV %p could not become child of %s: %s\n", snpdev, efi_handle_name ( efidev->device ), strerror ( rc ) ); @@ -1959,7 +1957,8 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { list_del ( &snpdev->list ); if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); - efi_child_del ( efidev->device, snpdev->handle ); + if ( snpdev->parent ) + efi_child_del ( snpdev->parent, snpdev->handle ); err_efi_child_add: efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); err_open_nii31: @@ -1996,7 +1995,6 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { free ( snpdev ); } err_alloc_snp: - err_no_efidev: if ( leak ) DBGC ( snpdev, "SNPDEV %p nullified and leaked\n", snpdev ); return rc; @@ -2051,7 +2049,8 @@ static void efi_snp_remove ( struct net_device *netdev, void *priv __unused ) { list_del ( &snpdev->list ); if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); - efi_child_del ( snpdev->efidev->device, snpdev->handle ); + if ( snpdev->parent ) + efi_child_del ( snpdev->parent, snpdev->handle ); efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); if ( ( ! efi_shutdown_in_progress ) && -- cgit v1.2.3-55-g7522 From 86c40a8b1ef860c7c092226f95f9c8fe2d140edd Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 11 Dec 2025 14:04:10 +0000 Subject: [efi] Retry calls to GetRNG() as needed The UEFI specification allows GetRNG() to return EFI_NOT_READY, which is not a particularly helpful error status since there is nothing that can sensibly be done except to retry immediately. Retry failed calls to GetRNG() up to a maximum number of attempts. Debugged-by: Stoo Davies Signed-off-by: Michael Brown --- src/interface/efi/efi_rng.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'src/interface') diff --git a/src/interface/efi/efi_rng.c b/src/interface/efi/efi_rng.c index b76a6fc0d..058f0ee7d 100644 --- a/src/interface/efi/efi_rng.c +++ b/src/interface/efi/efi_rng.c @@ -54,6 +54,15 @@ EFI_REQUEST_PROTOCOL ( EFI_RNG_PROTOCOL, &efirng ); */ #define EFIRNG_LEN 32 +/** Maximum number of times to attempting requesting data from RNG + * + * The UEFI spec allows GetRNG() to return EFI_NOT_READY, which is not + * a particularly helpful error status since there is nothing that can + * sensibly be done except to retry immediately. We retry failed + * calls to GetRNG() (for any reason) up to this number of times. + */ +#define EFIRNG_MAX_RETRY 16 + /** * Enable entropy gathering * @@ -85,29 +94,35 @@ static int efirng_enable ( void ) { */ static int efirng_get_noise ( noise_sample_t *noise ) { uint8_t buf[EFIRNG_LEN]; + unsigned int i; EFI_STATUS efirc; int rc; /* Sanity check */ assert ( efirng != NULL ); - /* Get the minimum allowed number of random bytes */ - if ( ( efirc = efirng->GetRNG ( efirng, NULL, sizeof ( buf ), - buf ) ) != 0 ) { - rc = -EEFI ( efirc ); - DBGC ( &efirng, "ENTROPY could not read from RNG: %s\n", - strerror ( rc ) ); - return rc; + /* Get random bytes, retrying if needed */ + for ( i = 0 ; i < EFIRNG_MAX_RETRY ; i++ ) { + + /* Get the minimum allowed number of random bytes */ + if ( ( efirc = efirng->GetRNG ( efirng, NULL, sizeof ( buf ), + buf ) ) != 0 ) { + rc = -EEFI ( efirc ); + continue; + } + + /* Reduce random bytes to a single noise sample. This + * seems like overkill, but we have no way of knowing + * how much entropy is actually present in the bytes + * returned by the RNG protocol. + */ + *noise = crc32_le ( 0, buf, sizeof ( buf ) ); + return 0; } - /* Reduce random bytes to a single noise sample. This seems - * like overkill, but we have no way of knowing how much - * entropy is actually present in the bytes returned by the - * RNG protocol. - */ - *noise = crc32_le ( 0, buf, sizeof ( buf ) ); - - return 0; + DBGC ( &efirng, "ENTROPY could not read from RNG: %s\n", + strerror ( rc ) ); + return rc; } /** EFI random number generator protocol entropy source */ -- cgit v1.2.3-55-g7522 From 6cccb3bdc00359068c07125258d71ce24db5118a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 14 Jan 2026 13:25:34 +0000 Subject: [build] Mark core files as permitted for UEFI Secure Boot Mark all files used in a standard build of bin-x86_64-efi/snponly.efi as permitted for UEFI Secure Boot. These files represent the core functionality of iPXE that is guaranteed to have been included in every binary that was previously subject to a security review and signed by Microsoft. It is therefore legitimate to assume that at least these files have already been reviewed to the required standard multiple times. Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid.c | 1 + src/arch/x86/core/x86_string.c | 1 + src/arch/x86/core/x86_tcpip.c | 1 + src/arch/x86/hci/commands/cpuid_cmd.c | 1 + src/arch/x86/include/bits/acpi.h | 1 + src/arch/x86/include/bits/endian.h | 1 + src/arch/x86/include/bits/errfile.h | 1 + src/arch/x86/include/bits/io.h | 1 + src/arch/x86/include/bits/iomap.h | 1 + src/arch/x86/include/bits/memmap.h | 1 + src/arch/x86/include/bits/nap.h | 1 + src/arch/x86/include/bits/pci_io.h | 1 + src/arch/x86/include/bits/reboot.h | 1 + src/arch/x86/include/bits/sanboot.h | 1 + src/arch/x86/include/bits/smbios.h | 1 + src/arch/x86/include/bits/string.h | 1 + src/arch/x86/include/bits/tcpip.h | 1 + src/arch/x86/include/bits/time.h | 1 + src/arch/x86/include/ipxe/bios_nap.h | 1 + src/arch/x86/include/ipxe/bios_reboot.h | 1 + src/arch/x86/include/ipxe/bios_sanboot.h | 1 + src/arch/x86/include/ipxe/bios_smbios.h | 1 + src/arch/x86/include/ipxe/cpuid.h | 1 + src/arch/x86/include/ipxe/int15.h | 1 + src/arch/x86/include/ipxe/iomap_pages.h | 1 + src/arch/x86/include/ipxe/pcibios.h | 1 + src/arch/x86/include/ipxe/pcidirect.h | 1 + src/arch/x86/include/ipxe/rsdp.h | 1 + src/arch/x86/include/ipxe/rtc_time.h | 1 + src/arch/x86/include/ipxe/x86_io.h | 1 + src/arch/x86_64/include/bits/byteswap.h | 1 + src/arch/x86_64/include/bits/compiler.h | 1 + src/arch/x86_64/include/bits/profile.h | 1 + src/arch/x86_64/include/bits/stdint.h | 1 + src/arch/x86_64/include/bits/strings.h | 1 + src/arch/x86_64/include/ipxe/efi/dhcparch.h | 1 + src/arch/x86_64/include/limits.h | 1 + src/config/branding.h | 1 + src/config/colour.h | 1 + src/config/config.c | 1 + src/config/config_eap.c | 1 + src/config/config_efi.c | 1 + src/config/config_ethernet.c | 1 + src/config/config_http.c | 1 + src/config/config_pci.c | 1 + src/config/config_route.c | 1 + src/config/config_timer.c | 1 + src/config/console.h | 1 + src/config/defaults.h | 1 + src/config/defaults/efi.h | 1 + src/config/dhcp.h | 1 + src/config/fault.h | 1 + src/config/general.h | 1 + src/config/ioapi.h | 1 + src/config/named.h | 1 + src/config/nap.h | 1 + src/config/reboot.h | 1 + src/config/sanboot.h | 1 + src/config/settings.h | 1 + src/config/sideband.h | 1 + src/config/time.h | 1 + src/config/timer.h | 1 + src/config/umalloc.h | 1 + src/core/acpi.c | 1 + src/core/ansicol.c | 1 + src/core/ansiesc.c | 1 + src/core/asprintf.c | 1 + src/core/base16.c | 1 + src/core/base64.c | 1 + src/core/basename.c | 1 + src/core/bitmap.c | 1 + src/core/blockdev.c | 1 + src/core/blocktrans.c | 1 + src/core/cachedhcp.c | 1 + src/core/console.c | 1 + src/core/cpio.c | 1 + src/core/ctype.c | 1 + src/core/cwuri.c | 1 + src/core/debug.c | 1 + src/core/device.c | 1 + src/core/dma.c | 1 + src/core/downloader.c | 1 + src/core/dynui.c | 1 + src/core/edd.c | 1 + src/core/errno.c | 1 + src/core/exec.c | 1 + src/core/getkey.c | 1 + src/core/getopt.c | 1 + src/core/image.c | 1 + src/core/init.c | 1 + src/core/interface.c | 1 + src/core/iobuf.c | 1 + src/core/job.c | 1 + src/core/keymap.c | 1 + src/core/linebuf.c | 1 + src/core/list.c | 1 + src/core/main.c | 1 + src/core/malloc.c | 1 + src/core/monojob.c | 1 + src/core/nvo.c | 1 + src/core/open.c | 1 + src/core/params.c | 1 + src/core/parseopt.c | 1 + src/core/pending.c | 1 + src/core/pool.c | 1 + src/core/process.c | 1 + src/core/quiesce.c | 1 + src/core/random.c | 1 + src/core/refcnt.c | 1 + src/core/resolv.c | 1 + src/core/sanboot.c | 1 + src/core/settings.c | 1 + src/core/string.c | 1 + src/core/time.c | 1 + src/core/timer.c | 1 + src/core/uri.c | 1 + src/core/utf8.c | 1 + src/core/uuid.c | 1 + src/core/version.c | 1 + src/core/vsprintf.c | 1 + src/core/wchar.c | 1 + src/core/xfer.c | 1 + src/core/xferbuf.c | 1 + src/crypto/chap.c | 1 + src/crypto/crc32.c | 1 + src/crypto/md5.c | 1 + src/drivers/block/ata.c | 1 + src/drivers/block/ibft.c | 1 + src/drivers/block/scsi.c | 1 + src/drivers/bus/pci.c | 1 + src/drivers/bus/pci_settings.c | 1 + src/drivers/net/efi/mnpnet.c | 1 + src/drivers/net/efi/nii.c | 1 + src/drivers/net/efi/nii.h | 1 + src/drivers/net/efi/snpnet.c | 1 + src/drivers/net/efi/snpnet.h | 1 + src/drivers/net/efi/snponly.c | 1 + src/drivers/nvs/nvs.c | 1 + src/hci/commands/autoboot_cmd.c | 1 + src/hci/commands/config_cmd.c | 1 + src/hci/commands/dhcp_cmd.c | 1 + src/hci/commands/dynui_cmd.c | 1 + src/hci/commands/ifmgmt_cmd.c | 1 + src/hci/commands/image_cmd.c | 1 + src/hci/commands/login_cmd.c | 1 + src/hci/commands/nvo_cmd.c | 1 + src/hci/commands/reboot_cmd.c | 1 + src/hci/commands/route_cmd.c | 1 + src/hci/commands/sanboot_cmd.c | 1 + src/hci/commands/shim_cmd.c | 1 + src/hci/commands/sync_cmd.c | 1 + src/hci/editstring.c | 1 + src/hci/jumpscroll.c | 1 + src/hci/mucurses/ansi_screen.c | 1 + src/hci/mucurses/clear.c | 1 + src/hci/mucurses/cursor.h | 1 + src/hci/mucurses/mucurses.c | 1 + src/hci/mucurses/mucurses.h | 1 + src/hci/mucurses/print.c | 1 + src/hci/mucurses/widgets/editbox.c | 1 + src/hci/mucurses/winattrs.c | 1 + src/hci/mucurses/wininit.c | 1 + src/hci/readline.c | 1 + src/hci/shell.c | 1 + src/hci/strerror.c | 1 + src/hci/tui/form_ui.c | 1 + src/hci/tui/login_ui.c | 1 + src/hci/tui/menu_ui.c | 1 + src/hci/tui/message.c | 1 + src/hci/tui/settings_ui.c | 1 + src/image/efi_image.c | 1 + src/image/embedded.c | 1 + src/image/script.c | 1 + src/include/assert.h | 1 + src/include/bits/dma.h | 1 + src/include/bits/uaccess.h | 1 + src/include/bits/umalloc.h | 1 + src/include/bits/virt_offset.h | 1 + src/include/byteswap.h | 1 + src/include/ctype.h | 1 + src/include/curses.h | 1 + src/include/endian.h | 1 + src/include/errno.h | 1 + src/include/getopt.h | 1 + src/include/hci/ifmgmt_cmd.h | 1 + src/include/ipxe/acpi.h | 1 + src/include/ipxe/ansicol.h | 1 + src/include/ipxe/ansiesc.h | 1 + src/include/ipxe/aoe.h | 1 + src/include/ipxe/api.h | 1 + src/include/ipxe/arp.h | 1 + src/include/ipxe/asn1.h | 1 + src/include/ipxe/ata.h | 1 + src/include/ipxe/base16.h | 1 + src/include/ipxe/base64.h | 1 + src/include/ipxe/bitmap.h | 1 + src/include/ipxe/blockdev.h | 1 + src/include/ipxe/blocktrans.h | 1 + src/include/ipxe/cachedhcp.h | 1 + src/include/ipxe/chap.h | 1 + src/include/ipxe/command.h | 1 + src/include/ipxe/console.h | 1 + src/include/ipxe/cpio.h | 1 + src/include/ipxe/crc32.h | 1 + src/include/ipxe/crypto.h | 1 + src/include/ipxe/device.h | 1 + src/include/ipxe/dhcp.h | 1 + src/include/ipxe/dhcparch.h | 1 + src/include/ipxe/dhcpopts.h | 1 + src/include/ipxe/dhcppkt.h | 1 + src/include/ipxe/dhcpv6.h | 1 + src/include/ipxe/dma.h | 1 + src/include/ipxe/dns.h | 1 + src/include/ipxe/downloader.h | 1 + src/include/ipxe/dummy_sanboot.h | 1 + src/include/ipxe/dynui.h | 1 + src/include/ipxe/eap.h | 1 + src/include/ipxe/eapol.h | 1 + src/include/ipxe/ecam_io.h | 1 + src/include/ipxe/edd.h | 1 + src/include/ipxe/editbox.h | 1 + src/include/ipxe/editstring.h | 1 + src/include/ipxe/efi/ProcessorBind.h | 1 + src/include/ipxe/efi/Protocol/AppleNetBoot.h | 1 + src/include/ipxe/efi/Protocol/ShimLock.h | 1 + src/include/ipxe/efi/efi.h | 1 + src/include/ipxe/efi/efi_acpi.h | 1 + src/include/ipxe/efi/efi_autoboot.h | 1 + src/include/ipxe/efi/efi_autoexec.h | 1 + src/include/ipxe/efi/efi_block.h | 1 + src/include/ipxe/efi/efi_cachedhcp.h | 1 + src/include/ipxe/efi/efi_cmdline.h | 1 + src/include/ipxe/efi/efi_download.h | 1 + src/include/ipxe/efi/efi_driver.h | 1 + src/include/ipxe/efi/efi_fdt.h | 1 + src/include/ipxe/efi/efi_file.h | 1 + src/include/ipxe/efi/efi_hii.h | 1 + src/include/ipxe/efi/efi_image.h | 1 + src/include/ipxe/efi/efi_nap.h | 1 + src/include/ipxe/efi/efi_null.h | 1 + src/include/ipxe/efi/efi_path.h | 1 + src/include/ipxe/efi/efi_pci.h | 1 + src/include/ipxe/efi/efi_pci_api.h | 1 + src/include/ipxe/efi/efi_pxe.h | 1 + src/include/ipxe/efi/efi_reboot.h | 1 + src/include/ipxe/efi/efi_service.h | 1 + src/include/ipxe/efi/efi_shim.h | 1 + src/include/ipxe/efi/efi_smbios.h | 1 + src/include/ipxe/efi/efi_snp.h | 1 + src/include/ipxe/efi/efi_strings.h | 1 + src/include/ipxe/efi/efi_table.h | 1 + src/include/ipxe/efi/efi_time.h | 1 + src/include/ipxe/efi/efi_umalloc.h | 1 + src/include/ipxe/efi/efi_utils.h | 1 + src/include/ipxe/efi/efi_veto.h | 1 + src/include/ipxe/efi/efi_watchdog.h | 1 + src/include/ipxe/efi/efi_wrap.h | 1 + src/include/ipxe/efi/mnpnet.h | 1 + src/include/ipxe/errfile.h | 1 + src/include/ipxe/errno/efi.h | 1 + src/include/ipxe/errortab.h | 1 + src/include/ipxe/eth_slow.h | 1 + src/include/ipxe/ethernet.h | 1 + src/include/ipxe/fakedhcp.h | 1 + src/include/ipxe/fault.h | 1 + src/include/ipxe/fc.h | 1 + src/include/ipxe/fcels.h | 1 + src/include/ipxe/fcp.h | 1 + src/include/ipxe/fdtmem.h | 1 + src/include/ipxe/features.h | 1 + src/include/ipxe/fragment.h | 1 + src/include/ipxe/http.h | 1 + src/include/ipxe/ib_mad.h | 1 + src/include/ipxe/ib_packet.h | 1 + src/include/ipxe/ib_srp.h | 1 + src/include/ipxe/ibft.h | 1 + src/include/ipxe/icmp.h | 1 + src/include/ipxe/icmpv6.h | 1 + src/include/ipxe/if_arp.h | 1 + src/include/ipxe/if_ether.h | 1 + src/include/ipxe/image.h | 1 + src/include/ipxe/in.h | 1 + src/include/ipxe/infiniband.h | 1 + src/include/ipxe/init.h | 1 + src/include/ipxe/initrd.h | 1 + src/include/ipxe/interface.h | 1 + src/include/ipxe/io.h | 1 + src/include/ipxe/iobuf.h | 1 + src/include/ipxe/iomap.h | 1 + src/include/ipxe/iomap_virt.h | 1 + src/include/ipxe/ip.h | 1 + src/include/ipxe/ipstat.h | 1 + src/include/ipxe/ipv6.h | 1 + src/include/ipxe/iscsi.h | 1 + src/include/ipxe/iso9660.h | 1 + src/include/ipxe/job.h | 1 + src/include/ipxe/jumpscroll.h | 1 + src/include/ipxe/keymap.h | 1 + src/include/ipxe/keys.h | 1 + src/include/ipxe/linebuf.h | 1 + src/include/ipxe/linux/linux_acpi.h | 1 + src/include/ipxe/linux/linux_nap.h | 1 + src/include/ipxe/linux/linux_pci.h | 1 + src/include/ipxe/linux/linux_smbios.h | 1 + src/include/ipxe/linux/linux_time.h | 1 + src/include/ipxe/linux/linux_uaccess.h | 1 + src/include/ipxe/linux/linux_umalloc.h | 1 + src/include/ipxe/list.h | 1 + src/include/ipxe/lldp.h | 1 + src/include/ipxe/login_ui.h | 1 + src/include/ipxe/malloc.h | 1 + src/include/ipxe/md5.h | 1 + src/include/ipxe/memmap.h | 1 + src/include/ipxe/message.h | 1 + src/include/ipxe/monojob.h | 1 + src/include/ipxe/nap.h | 1 + src/include/ipxe/ndp.h | 1 + src/include/ipxe/neighbour.h | 1 + src/include/ipxe/netdevice.h | 1 + src/include/ipxe/ntlm.h | 1 + src/include/ipxe/null_acpi.h | 1 + src/include/ipxe/null_memmap.h | 1 + src/include/ipxe/null_nap.h | 1 + src/include/ipxe/null_pci.h | 1 + src/include/ipxe/null_reboot.h | 1 + src/include/ipxe/null_sanboot.h | 1 + src/include/ipxe/null_smbios.h | 1 + src/include/ipxe/null_time.h | 1 + src/include/ipxe/nvo.h | 1 + src/include/ipxe/nvs.h | 1 + src/include/ipxe/open.h | 1 + src/include/ipxe/params.h | 1 + src/include/ipxe/parseopt.h | 1 + src/include/ipxe/pci.h | 1 + src/include/ipxe/pci_io.h | 1 + src/include/ipxe/pcicloud.h | 1 + src/include/ipxe/pending.h | 1 + src/include/ipxe/ping.h | 1 + src/include/ipxe/pool.h | 1 + src/include/ipxe/process.h | 1 + src/include/ipxe/profile.h | 1 + src/include/ipxe/quiesce.h | 1 + src/include/ipxe/reboot.h | 1 + src/include/ipxe/refcnt.h | 1 + src/include/ipxe/resolv.h | 1 + src/include/ipxe/retry.h | 1 + src/include/ipxe/rotate.h | 1 + src/include/ipxe/sanboot.h | 1 + src/include/ipxe/sbat.h | 1 + src/include/ipxe/script.h | 1 + src/include/ipxe/scsi.h | 1 + src/include/ipxe/settings.h | 1 + src/include/ipxe/settings_ui.h | 1 + src/include/ipxe/shell.h | 1 + src/include/ipxe/smbios.h | 1 + src/include/ipxe/socket.h | 1 + src/include/ipxe/srp.h | 1 + src/include/ipxe/stp.h | 1 + src/include/ipxe/string.h | 1 + src/include/ipxe/tables.h | 1 + src/include/ipxe/tcp.h | 1 + src/include/ipxe/tcpip.h | 1 + src/include/ipxe/tftp.h | 1 + src/include/ipxe/time.h | 1 + src/include/ipxe/timer.h | 1 + src/include/ipxe/uaccess.h | 1 + src/include/ipxe/udp.h | 1 + src/include/ipxe/uheap.h | 1 + src/include/ipxe/umalloc.h | 1 + src/include/ipxe/uri.h | 1 + src/include/ipxe/usb.h | 1 + src/include/ipxe/utf8.h | 1 + src/include/ipxe/uuid.h | 1 + src/include/ipxe/version.h | 1 + src/include/ipxe/virt_offset.h | 1 + src/include/ipxe/vlan.h | 1 + src/include/ipxe/vsprintf.h | 1 + src/include/ipxe/widget.h | 1 + src/include/ipxe/xfer.h | 1 + src/include/ipxe/xferbuf.h | 1 + src/include/libgen.h | 1 + src/include/readline/readline.h | 1 + src/include/stdarg.h | 1 + src/include/stdbool.h | 1 + src/include/stddef.h | 1 + src/include/stdint.h | 1 + src/include/stdio.h | 1 + src/include/stdlib.h | 1 + src/include/string.h | 1 + src/include/strings.h | 1 + src/include/sys/time.h | 1 + src/include/syslog.h | 1 + src/include/time.h | 1 + src/include/unistd.h | 1 + src/include/usr/autoboot.h | 1 + src/include/usr/dhcpmgmt.h | 1 + src/include/usr/ifmgmt.h | 1 + src/include/usr/imgmgmt.h | 1 + src/include/usr/prompt.h | 1 + src/include/usr/route.h | 1 + src/include/usr/shimmgmt.h | 1 + src/include/usr/sync.h | 1 + src/include/valgrind/memcheck.h | 1 + src/include/valgrind/valgrind.h | 1 + src/include/wchar.h | 1 + src/interface/efi/efi_acpi.c | 1 + src/interface/efi/efi_autoboot.c | 1 + src/interface/efi/efi_autoexec.c | 1 + src/interface/efi/efi_block.c | 1 + src/interface/efi/efi_cachedhcp.c | 1 + src/interface/efi/efi_cmdline.c | 1 + src/interface/efi/efi_connect.c | 1 + src/interface/efi/efi_console.c | 1 + src/interface/efi/efi_download.c | 1 + src/interface/efi/efi_driver.c | 1 + src/interface/efi/efi_file.c | 1 + src/interface/efi/efi_guid.c | 1 + src/interface/efi/efi_hii.c | 1 + src/interface/efi/efi_init.c | 1 + src/interface/efi/efi_local.c | 1 + src/interface/efi/efi_nap.c | 1 + src/interface/efi/efi_null.c | 1 + src/interface/efi/efi_open.c | 1 + src/interface/efi/efi_path.c | 1 + src/interface/efi/efi_pci.c | 1 + src/interface/efi/efi_pxe.c | 1 + src/interface/efi/efi_reboot.c | 1 + src/interface/efi/efi_service.c | 1 + src/interface/efi/efi_settings.c | 1 + src/interface/efi/efi_shim.c | 2 ++ src/interface/efi/efi_smbios.c | 1 + src/interface/efi/efi_snp.c | 1 + src/interface/efi/efi_snp_hii.c | 1 + src/interface/efi/efi_strings.c | 1 + src/interface/efi/efi_table.c | 1 + src/interface/efi/efi_time.c | 1 + src/interface/efi/efi_timer.c | 1 + src/interface/efi/efi_umalloc.c | 1 + src/interface/efi/efi_utils.c | 1 + src/interface/efi/efi_veto.c | 1 + src/interface/efi/efi_watchdog.c | 1 + src/interface/efi/efi_wrap.c | 1 + src/interface/efi/efiprefix.c | 1 + src/interface/smbios/smbios.c | 1 + src/interface/smbios/smbios_settings.c | 1 + src/net/aoe.c | 1 + src/net/arp.c | 1 + src/net/dhcpopts.c | 1 + src/net/dhcppkt.c | 1 + src/net/eap.c | 1 + src/net/eap_md5.c | 1 + src/net/eapol.c | 1 + src/net/eth_slow.c | 1 + src/net/ethernet.c | 1 + src/net/fakedhcp.c | 1 + src/net/fragment.c | 1 + src/net/icmp.c | 1 + src/net/icmpv4.c | 1 + src/net/icmpv6.c | 1 + src/net/iobpad.c | 1 + src/net/ipv4.c | 1 + src/net/ipv6.c | 1 + src/net/lldp.c | 1 + src/net/ndp.c | 1 + src/net/neighbour.c | 1 + src/net/netdev_settings.c | 1 + src/net/netdevice.c | 1 + src/net/nullnet.c | 1 + src/net/retry.c | 1 + src/net/socket.c | 1 + src/net/stp.c | 1 + src/net/tcp.c | 1 + src/net/tcp/http.c | 1 + src/net/tcp/httpauth.c | 1 + src/net/tcp/httpbasic.c | 1 + src/net/tcp/httpblock.c | 1 + src/net/tcp/httpconn.c | 1 + src/net/tcp/httpcore.c | 1 + src/net/tcp/httpdigest.c | 1 + src/net/tcp/iscsi.c | 1 + src/net/tcpip.c | 1 + src/net/udp.c | 1 + src/net/udp/dhcp.c | 1 + src/net/udp/dhcpv6.c | 1 + src/net/udp/dns.c | 1 + src/net/udp/tftp.c | 1 + src/net/vlan.c | 1 + src/usr/autoboot.c | 1 + src/usr/dhcpmgmt.c | 1 + src/usr/ifmgmt.c | 1 + src/usr/imgmgmt.c | 1 + src/usr/prompt.c | 1 + src/usr/route.c | 1 + src/usr/route_ipv4.c | 1 + src/usr/route_ipv6.c | 1 + src/usr/shimmgmt.c | 1 + src/usr/sync.c | 1 + 497 files changed, 498 insertions(+) (limited to 'src/interface') diff --git a/src/arch/x86/core/cpuid.c b/src/arch/x86/core/cpuid.c index b7d9fb6c6..0461b846e 100644 --- a/src/arch/x86/core/cpuid.c +++ b/src/arch/x86/core/cpuid.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/core/x86_string.c b/src/arch/x86/core/x86_string.c index 1a1e79dac..923552f66 100644 --- a/src/arch/x86/core/x86_string.c +++ b/src/arch/x86/core/x86_string.c @@ -28,6 +28,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/core/x86_tcpip.c b/src/arch/x86/core/x86_tcpip.c index ed323d5d0..b3bfe2546 100644 --- a/src/arch/x86/core/x86_tcpip.c +++ b/src/arch/x86/core/x86_tcpip.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/arch/x86/hci/commands/cpuid_cmd.c b/src/arch/x86/hci/commands/cpuid_cmd.c index b1978d5f2..f4d7305e8 100644 --- a/src/arch/x86/hci/commands/cpuid_cmd.c +++ b/src/arch/x86/hci/commands/cpuid_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/bits/acpi.h b/src/arch/x86/include/bits/acpi.h index a6ff90804..287bdafeb 100644 --- a/src/arch/x86/include/bits/acpi.h +++ b/src/arch/x86/include/bits/acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/endian.h b/src/arch/x86/include/bits/endian.h index 85718cfdd..72279117d 100644 --- a/src/arch/x86/include/bits/endian.h +++ b/src/arch/x86/include/bits/endian.h @@ -2,6 +2,7 @@ #define _BITS_ENDIAN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/src/arch/x86/include/bits/errfile.h b/src/arch/x86/include/bits/errfile.h index 4fa9acef6..e7aec6f39 100644 --- a/src/arch/x86/include/bits/errfile.h +++ b/src/arch/x86/include/bits/errfile.h @@ -2,6 +2,7 @@ #define _BITS_ERRFILE_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @addtogroup errfile Error file identifiers diff --git a/src/arch/x86/include/bits/io.h b/src/arch/x86/include/bits/io.h index 95673ad8d..cde0b6829 100644 --- a/src/arch/x86/include/bits/io.h +++ b/src/arch/x86/include/bits/io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Page shift */ #define PAGE_SHIFT 12 diff --git a/src/arch/x86/include/bits/iomap.h b/src/arch/x86/include/bits/iomap.h index d6fff257e..d524bd805 100644 --- a/src/arch/x86/include/bits/iomap.h +++ b/src/arch/x86/include/bits/iomap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/memmap.h b/src/arch/x86/include/bits/memmap.h index 8f821563c..e68550fb8 100644 --- a/src/arch/x86/include/bits/memmap.h +++ b/src/arch/x86/include/bits/memmap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/nap.h b/src/arch/x86/include/bits/nap.h index b7dea736d..52c8d81ba 100644 --- a/src/arch/x86/include/bits/nap.h +++ b/src/arch/x86/include/bits/nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/pci_io.h b/src/arch/x86/include/bits/pci_io.h index b41e562ee..b6c01e5c4 100644 --- a/src/arch/x86/include/bits/pci_io.h +++ b/src/arch/x86/include/bits/pci_io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/bits/reboot.h b/src/arch/x86/include/bits/reboot.h index e702dd3d0..8d8d0b40e 100644 --- a/src/arch/x86/include/bits/reboot.h +++ b/src/arch/x86/include/bits/reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/sanboot.h b/src/arch/x86/include/bits/sanboot.h index 1b9924e64..ff7b88d14 100644 --- a/src/arch/x86/include/bits/sanboot.h +++ b/src/arch/x86/include/bits/sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/smbios.h b/src/arch/x86/include/bits/smbios.h index 9977c87ac..2be98d887 100644 --- a/src/arch/x86/include/bits/smbios.h +++ b/src/arch/x86/include/bits/smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/string.h b/src/arch/x86/include/bits/string.h index c26fe30d5..8b2b3070b 100644 --- a/src/arch/x86/include/bits/string.h +++ b/src/arch/x86/include/bits/string.h @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/arch/x86/include/bits/tcpip.h b/src/arch/x86/include/bits/tcpip.h index 0ac55b1a0..52d032427 100644 --- a/src/arch/x86/include/bits/tcpip.h +++ b/src/arch/x86/include/bits/tcpip.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern uint16_t tcpip_continue_chksum ( uint16_t partial, const void *data, size_t len ); diff --git a/src/arch/x86/include/bits/time.h b/src/arch/x86/include/bits/time.h index 556d96f64..a4aa8cc6e 100644 --- a/src/arch/x86/include/bits/time.h +++ b/src/arch/x86/include/bits/time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/ipxe/bios_nap.h b/src/arch/x86/include/ipxe/bios_nap.h index c9b82c1e5..7d94b3c4a 100644 --- a/src/arch/x86/include/ipxe/bios_nap.h +++ b/src/arch/x86/include/ipxe/bios_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_PCBIOS #define NAP_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/bios_reboot.h b/src/arch/x86/include/ipxe/bios_reboot.h index 3f6df9073..bd1bb42cc 100644 --- a/src/arch/x86/include/ipxe/bios_reboot.h +++ b/src/arch/x86/include/ipxe/bios_reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef REBOOT_PCBIOS #define REBOOT_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/bios_sanboot.h b/src/arch/x86/include/ipxe/bios_sanboot.h index 85d698039..d28339e4e 100644 --- a/src/arch/x86/include/ipxe/bios_sanboot.h +++ b/src/arch/x86/include/ipxe/bios_sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_PCBIOS #define SANBOOT_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/bios_smbios.h b/src/arch/x86/include/ipxe/bios_smbios.h index 9f7f9c8ff..1815e3617 100644 --- a/src/arch/x86/include/ipxe/bios_smbios.h +++ b/src/arch/x86/include/ipxe/bios_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_PCBIOS #define SMBIOS_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/cpuid.h b/src/arch/x86/include/ipxe/cpuid.h index 99b91c5c8..1851a859b 100644 --- a/src/arch/x86/include/ipxe/cpuid.h +++ b/src/arch/x86/include/ipxe/cpuid.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/ipxe/int15.h b/src/arch/x86/include/ipxe/int15.h index e8aa9e2f5..590c0e9a7 100644 --- a/src/arch/x86/include/ipxe/int15.h +++ b/src/arch/x86/include/ipxe/int15.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef MEMMAP_INT15 #define MEMMAP_PREFIX_int15 diff --git a/src/arch/x86/include/ipxe/iomap_pages.h b/src/arch/x86/include/ipxe/iomap_pages.h index 18e0a3002..e74dabd90 100644 --- a/src/arch/x86/include/ipxe/iomap_pages.h +++ b/src/arch/x86/include/ipxe/iomap_pages.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef IOMAP_PAGES #define IOMAP_PREFIX_pages diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index b62b470f0..2fd03198e 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_PCBIOS #define PCIAPI_PREFIX_pcbios diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index 1515b20d4..5863b4d16 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -2,6 +2,7 @@ #define _PCIDIRECT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/ipxe/rsdp.h b/src/arch/x86/include/ipxe/rsdp.h index daaa43077..f371d9a20 100644 --- a/src/arch/x86/include/ipxe/rsdp.h +++ b/src/arch/x86/include/ipxe/rsdp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef ACPI_RSDP #define ACPI_PREFIX_rsdp diff --git a/src/arch/x86/include/ipxe/rtc_time.h b/src/arch/x86/include/ipxe/rtc_time.h index cb8c7f49e..49c6313ed 100644 --- a/src/arch/x86/include/ipxe/rtc_time.h +++ b/src/arch/x86/include/ipxe/rtc_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef TIME_RTC #define TIME_PREFIX_rtc diff --git a/src/arch/x86/include/ipxe/x86_io.h b/src/arch/x86/include/ipxe/x86_io.h index eeb3f8454..164b57e92 100644 --- a/src/arch/x86/include/ipxe/x86_io.h +++ b/src/arch/x86/include/ipxe/x86_io.h @@ -16,6 +16,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef IOAPI_X86 #define IOAPI_PREFIX_x86 diff --git a/src/arch/x86_64/include/bits/byteswap.h b/src/arch/x86_64/include/bits/byteswap.h index d8c5098ef..7c48a27ca 100644 --- a/src/arch/x86_64/include/bits/byteswap.h +++ b/src/arch/x86_64/include/bits/byteswap.h @@ -10,6 +10,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static inline __attribute__ (( always_inline, const )) uint16_t __bswap_variable_16 ( uint16_t x ) { diff --git a/src/arch/x86_64/include/bits/compiler.h b/src/arch/x86_64/include/bits/compiler.h index 1c04a7b30..99185b058 100644 --- a/src/arch/x86_64/include/bits/compiler.h +++ b/src/arch/x86_64/include/bits/compiler.h @@ -2,6 +2,7 @@ #define _BITS_COMPILER_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Dummy relocation type */ #define RELOC_TYPE_NONE R_X86_64_NONE diff --git a/src/arch/x86_64/include/bits/profile.h b/src/arch/x86_64/include/bits/profile.h index c85b6fe5c..c8e0a21f1 100644 --- a/src/arch/x86_64/include/bits/profile.h +++ b/src/arch/x86_64/include/bits/profile.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86_64/include/bits/stdint.h b/src/arch/x86_64/include/bits/stdint.h index fe1f9946a..e75bed502 100644 --- a/src/arch/x86_64/include/bits/stdint.h +++ b/src/arch/x86_64/include/bits/stdint.h @@ -2,6 +2,7 @@ #define _BITS_STDINT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); typedef __SIZE_TYPE__ size_t; typedef signed long ssize_t; diff --git a/src/arch/x86_64/include/bits/strings.h b/src/arch/x86_64/include/bits/strings.h index 3b7911f3b..6da8f1350 100644 --- a/src/arch/x86_64/include/bits/strings.h +++ b/src/arch/x86_64/include/bits/strings.h @@ -2,6 +2,7 @@ #define _BITS_STRINGS_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Find first (i.e. least significant) set bit diff --git a/src/arch/x86_64/include/ipxe/efi/dhcparch.h b/src/arch/x86_64/include/ipxe/efi/dhcparch.h index ccf0f46a0..f75bf9145 100644 --- a/src/arch/x86_64/include/ipxe/efi/dhcparch.h +++ b/src/arch/x86_64/include/ipxe/efi/dhcparch.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86_64/include/limits.h b/src/arch/x86_64/include/limits.h index a1374a17f..e75461acb 100644 --- a/src/arch/x86_64/include/limits.h +++ b/src/arch/x86_64/include/limits.h @@ -2,6 +2,7 @@ #define LIMITS_H 1 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Number of bits in a `char' */ #define CHAR_BIT 8 diff --git a/src/config/branding.h b/src/config/branding.h index 454bf0c03..f28e1b5d2 100644 --- a/src/config/branding.h +++ b/src/config/branding.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/colour.h b/src/config/colour.h index 98198f12f..bde6f9719 100644 --- a/src/config/colour.h +++ b/src/config/colour.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define COLOR_NORMAL_FG COLOR_WHITE #define COLOR_NORMAL_BG COLOR_BLUE diff --git a/src/config/config.c b/src/config/config.c index e49f236a3..c32bcee88 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/config_eap.c b/src/config/config_eap.c index e18c48cae..0c9b7b687 100644 --- a/src/config/config_eap.c +++ b/src/config/config_eap.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_efi.c b/src/config/config_efi.c index 92678d12d..8daaa4329 100644 --- a/src/config/config_efi.c +++ b/src/config/config_efi.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/config_ethernet.c b/src/config/config_ethernet.c index c1b35bfe6..03ed371a7 100644 --- a/src/config/config_ethernet.c +++ b/src/config/config_ethernet.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_http.c b/src/config/config_http.c index 4373ea2c0..ee0643c91 100644 --- a/src/config/config_http.c +++ b/src/config/config_http.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_pci.c b/src/config/config_pci.c index b2adae995..c6c9b92a5 100644 --- a/src/config/config_pci.c +++ b/src/config/config_pci.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/config_route.c b/src/config/config_route.c index c0b4ee91d..59d8f3550 100644 --- a/src/config/config_route.c +++ b/src/config/config_route.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_timer.c b/src/config/config_timer.c index a4fe69b00..12b806129 100644 --- a/src/config/config_timer.c +++ b/src/config/config_timer.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/console.h b/src/config/console.h index 0ff328b7c..028021fa2 100644 --- a/src/config/console.h +++ b/src/config/console.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/defaults.h b/src/config/defaults.h index 32d6dbcce..767b67fdf 100644 --- a/src/config/defaults.h +++ b/src/config/defaults.h @@ -2,6 +2,7 @@ #define CONFIG_DEFAULTS_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define CONFIG_DEFAULTS(_platform) diff --git a/src/config/defaults/efi.h b/src/config/defaults/efi.h index 4c9ba9d2a..524b2b0ea 100644 --- a/src/config/defaults/efi.h +++ b/src/config/defaults/efi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define UACCESS_FLAT #define IOMAP_VIRT diff --git a/src/config/dhcp.h b/src/config/dhcp.h index adfa74a15..65180c38c 100644 --- a/src/config/dhcp.h +++ b/src/config/dhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/fault.h b/src/config/fault.h index 5912ae1a6..ab5503fa2 100644 --- a/src/config/fault.h +++ b/src/config/fault.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/general.h b/src/config/general.h index 683c02ffb..f77248836 100644 --- a/src/config/general.h +++ b/src/config/general.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/ioapi.h b/src/config/ioapi.h index a1498482d..d4ef91f76 100644 --- a/src/config/ioapi.h +++ b/src/config/ioapi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/named.h b/src/config/named.h index ddde6f0a6..f46524f81 100644 --- a/src/config/named.h +++ b/src/config/named.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* config//
.h */ #ifdef CONFIG diff --git a/src/config/nap.h b/src/config/nap.h index e4fe97964..55ff64116 100644 --- a/src/config/nap.h +++ b/src/config/nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/reboot.h b/src/config/reboot.h index 2d1648e7b..a7f90ead1 100644 --- a/src/config/reboot.h +++ b/src/config/reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/sanboot.h b/src/config/sanboot.h index ccc4bda1f..962caec40 100644 --- a/src/config/sanboot.h +++ b/src/config/sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/settings.h b/src/config/settings.h index 7b4af4fdf..bba8c631a 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/sideband.h b/src/config/sideband.h index dd704f9bb..039d28df0 100644 --- a/src/config/sideband.h +++ b/src/config/sideband.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); //#define CONFIG_BOFM /* IBM's BladeCenter Open Fabric Manager */ diff --git a/src/config/time.h b/src/config/time.h index 678f6f864..f938f3aa7 100644 --- a/src/config/time.h +++ b/src/config/time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/timer.h b/src/config/timer.h index 5a54d398c..d2368a13a 100644 --- a/src/config/timer.h +++ b/src/config/timer.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/umalloc.h b/src/config/umalloc.h index 832dd21d1..87fb34527 100644 --- a/src/config/umalloc.h +++ b/src/config/umalloc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/core/acpi.c b/src/core/acpi.c index 3fbf25bd1..d8c1903f3 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/ansicol.c b/src/core/ansicol.c index ddf9ba77c..d53ebeeb6 100644 --- a/src/core/ansicol.c +++ b/src/core/ansicol.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/ansiesc.c b/src/core/ansiesc.c index 7f545db0e..57a2345d7 100644 --- a/src/core/ansiesc.c +++ b/src/core/ansiesc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/asprintf.c b/src/core/asprintf.c index 00edf8e11..17a65c715 100644 --- a/src/core/asprintf.c +++ b/src/core/asprintf.c @@ -5,6 +5,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Write a formatted string to newly allocated memory. diff --git a/src/core/base16.c b/src/core/base16.c index 47e35f414..0c597480f 100644 --- a/src/core/base16.c +++ b/src/core/base16.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/base64.c b/src/core/base64.c index ec11be261..fe7198c42 100644 --- a/src/core/base64.c +++ b/src/core/base64.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/basename.c b/src/core/basename.c index f4f929517..7a903c25f 100644 --- a/src/core/basename.c +++ b/src/core/basename.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/bitmap.c b/src/core/bitmap.c index 2aac33870..e3570c629 100644 --- a/src/core/bitmap.c +++ b/src/core/bitmap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/blockdev.c b/src/core/blockdev.c index 3513caafa..ff0f3b68b 100644 --- a/src/core/blockdev.c +++ b/src/core/blockdev.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c index b793185fe..d9c24582c 100644 --- a/src/core/blocktrans.c +++ b/src/core/blocktrans.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c index eeb2fca58..3f6564efd 100644 --- a/src/core/cachedhcp.c +++ b/src/core/cachedhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/console.c b/src/core/console.c index 2b90809bf..240dde3d6 100644 --- a/src/core/console.c +++ b/src/core/console.c @@ -6,6 +6,7 @@ /** @file */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Current console usage */ int console_usage = CONSOLE_USAGE_STDOUT; diff --git a/src/core/cpio.c b/src/core/cpio.c index 15e33d206..d2f9d0c2d 100644 --- a/src/core/cpio.c +++ b/src/core/cpio.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/ctype.c b/src/core/ctype.c index 891af71ea..d7de060e3 100644 --- a/src/core/ctype.c +++ b/src/core/ctype.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/cwuri.c b/src/core/cwuri.c index 612f0b179..36475b159 100644 --- a/src/core/cwuri.c +++ b/src/core/cwuri.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/debug.c b/src/core/debug.c index 9b2a823f5..3f7661dda 100644 --- a/src/core/debug.c +++ b/src/core/debug.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/device.c b/src/core/device.c index efe4eb687..2ab5fa117 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/dma.c b/src/core/dma.c index 3f3023c4d..dc266545b 100644 --- a/src/core/dma.c +++ b/src/core/dma.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/downloader.c b/src/core/downloader.c index 1c638f502..aa81e7365 100644 --- a/src/core/downloader.c +++ b/src/core/downloader.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/dynui.c b/src/core/dynui.c index 3d139c02a..c2af95f86 100644 --- a/src/core/dynui.c +++ b/src/core/dynui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/edd.c b/src/core/edd.c index a50b74ab1..4fcccf117 100644 --- a/src/core/edd.c +++ b/src/core/edd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/errno.c b/src/core/errno.c index 5de15bb92..7afa40859 100644 --- a/src/core/errno.c +++ b/src/core/errno.c @@ -1,6 +1,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/exec.c b/src/core/exec.c index 534fb9993..4db1248b0 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/getkey.c b/src/core/getkey.c index 0c280d23b..c952e0aea 100644 --- a/src/core/getkey.c +++ b/src/core/getkey.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/getopt.c b/src/core/getopt.c index e6c3948d1..cb4cbf118 100644 --- a/src/core/getopt.c +++ b/src/core/getopt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/image.c b/src/core/image.c index b2bd0956b..7df125971 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/init.c b/src/core/init.c index 406d22d7b..2a32f5795 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/interface.c b/src/core/interface.c index ea0606893..0ebcc8e51 100644 --- a/src/core/interface.c +++ b/src/core/interface.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/iobuf.c b/src/core/iobuf.c index 78fa23924..7e9a4156d 100644 --- a/src/core/iobuf.c +++ b/src/core/iobuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/job.c b/src/core/job.c index 65df80056..f83ce0552 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/keymap.c b/src/core/keymap.c index 36db7bd4c..e2244fdcb 100644 --- a/src/core/keymap.c +++ b/src/core/keymap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/linebuf.c b/src/core/linebuf.c index c197e383c..8995dca66 100644 --- a/src/core/linebuf.c +++ b/src/core/linebuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/list.c b/src/core/list.c index 5175c84ec..8d38d690a 100644 --- a/src/core/list.c +++ b/src/core/list.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/main.c b/src/core/main.c index 3db836491..95e16132f 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -13,6 +13,7 @@ Literature dealing with the network protocols: **************************************************************************/ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/malloc.c b/src/core/malloc.c index 877687d81..3a9f23ee4 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/monojob.c b/src/core/monojob.c index 2f066331c..ff22b4ac8 100644 --- a/src/core/monojob.c +++ b/src/core/monojob.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/nvo.c b/src/core/nvo.c index d2c9b5e73..8e500f816 100644 --- a/src/core/nvo.c +++ b/src/core/nvo.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/open.c b/src/core/open.c index f9198c9d9..8daa90f55 100644 --- a/src/core/open.c +++ b/src/core/open.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/params.c b/src/core/params.c index 58c829f62..d3fffc312 100644 --- a/src/core/params.c +++ b/src/core/params.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/parseopt.c b/src/core/parseopt.c index b657c3fce..b920a7d84 100644 --- a/src/core/parseopt.c +++ b/src/core/parseopt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/pending.c b/src/core/pending.c index 96d0cf197..4a1dd6a34 100644 --- a/src/core/pending.c +++ b/src/core/pending.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/pool.c b/src/core/pool.c index 0163405f7..daf761aa3 100644 --- a/src/core/pool.c +++ b/src/core/pool.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/process.c b/src/core/process.c index c944b6f50..883469dc5 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/quiesce.c b/src/core/quiesce.c index 5d2a919d0..9c4e37849 100644 --- a/src/core/quiesce.c +++ b/src/core/quiesce.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/random.c b/src/core/random.c index e3251964b..e8fbe6966 100644 --- a/src/core/random.c +++ b/src/core/random.c @@ -5,6 +5,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/refcnt.c b/src/core/refcnt.c index 47c975a0b..a66511291 100644 --- a/src/core/refcnt.c +++ b/src/core/refcnt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/resolv.c b/src/core/resolv.c index fab8def4b..0fc02ccf4 100644 --- a/src/core/resolv.c +++ b/src/core/resolv.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/sanboot.c b/src/core/sanboot.c index e90c5ef1d..45cd5eff3 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/settings.c b/src/core/settings.c index 05e495dcf..129620e00 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/string.c b/src/core/string.c index 364c4cf0e..2af19b7fe 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/time.c b/src/core/time.c index c353ac5bd..6d33f6caf 100644 --- a/src/core/time.c +++ b/src/core/time.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/core/timer.c b/src/core/timer.c index d45797adb..db0f32cf1 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/uri.c b/src/core/uri.c index b82472ef0..9da5e298b 100644 --- a/src/core/uri.c +++ b/src/core/uri.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/utf8.c b/src/core/utf8.c index 4ee01baf9..871044fec 100644 --- a/src/core/utf8.c +++ b/src/core/utf8.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/uuid.c b/src/core/uuid.c index b6600af71..0f93e9f8f 100644 --- a/src/core/uuid.c +++ b/src/core/uuid.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/version.c b/src/core/version.c index cd69a8762..75f3160db 100644 --- a/src/core/version.c +++ b/src/core/version.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/vsprintf.c b/src/core/vsprintf.c index 9d3a97c2d..f6032014a 100644 --- a/src/core/vsprintf.c +++ b/src/core/vsprintf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/wchar.c b/src/core/wchar.c index b06cf452a..27a608bf4 100644 --- a/src/core/wchar.c +++ b/src/core/wchar.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/xfer.c b/src/core/xfer.c index 269359e15..5ab303bc7 100644 --- a/src/core/xfer.c +++ b/src/core/xfer.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/xferbuf.c b/src/core/xferbuf.c index d93526577..ca3baaab5 100644 --- a/src/core/xferbuf.c +++ b/src/core/xferbuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/chap.c b/src/crypto/chap.c index c90c16def..008229133 100644 --- a/src/crypto/chap.c +++ b/src/crypto/chap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/crc32.c b/src/crypto/crc32.c index cfef68c02..9ab4899c6 100644 --- a/src/crypto/crc32.c +++ b/src/crypto/crc32.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/crypto/md5.c b/src/crypto/md5.c index 5c62513e2..9418b006c 100644 --- a/src/crypto/md5.c +++ b/src/crypto/md5.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/drivers/block/ata.c b/src/drivers/block/ata.c index cf98d7c9f..ee2acdebb 100644 --- a/src/drivers/block/ata.c +++ b/src/drivers/block/ata.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/block/ibft.c b/src/drivers/block/ibft.c index ca5fad9ff..6120b37dd 100644 --- a/src/drivers/block/ibft.c +++ b/src/drivers/block/ibft.c @@ -26,6 +26,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index 251210d4f..67bf48201 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 3908871b8..30163300a 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c index fc73c651e..3e320da43 100644 --- a/src/drivers/bus/pci_settings.c +++ b/src/drivers/bus/pci_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/efi/mnpnet.c b/src/drivers/net/efi/mnpnet.c index 902eb91f3..fe0ebaadb 100644 --- a/src/drivers/net/efi/mnpnet.c +++ b/src/drivers/net/efi/mnpnet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c index c60d4ca18..d1adf3d44 100644 --- a/src/drivers/net/efi/nii.c +++ b/src/drivers/net/efi/nii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/efi/nii.h b/src/drivers/net/efi/nii.h index df7ab7dbe..e0b07f0a5 100644 --- a/src/drivers/net/efi/nii.h +++ b/src/drivers/net/efi/nii.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct efi_device; diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 8427b6ce3..6046f0a1e 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/efi/snpnet.h b/src/drivers/net/efi/snpnet.h index 507350210..a361a99c0 100644 --- a/src/drivers/net/efi/snpnet.h +++ b/src/drivers/net/efi/snpnet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); struct efi_device; diff --git a/src/drivers/net/efi/snponly.c b/src/drivers/net/efi/snponly.c index 876479133..b7231ce01 100644 --- a/src/drivers/net/efi/snponly.c +++ b/src/drivers/net/efi/snponly.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/nvs/nvs.c b/src/drivers/nvs/nvs.c index af7c466c4..42b54123e 100644 --- a/src/drivers/nvs/nvs.c +++ b/src/drivers/nvs/nvs.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/autoboot_cmd.c b/src/hci/commands/autoboot_cmd.c index 010c6fcb0..a61333a9d 100644 --- a/src/hci/commands/autoboot_cmd.c +++ b/src/hci/commands/autoboot_cmd.c @@ -30,6 +30,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/config_cmd.c b/src/hci/commands/config_cmd.c index 39272196a..cc21ad3fe 100644 --- a/src/hci/commands/config_cmd.c +++ b/src/hci/commands/config_cmd.c @@ -31,6 +31,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/dhcp_cmd.c b/src/hci/commands/dhcp_cmd.c index 33c23fc6e..ccc115b87 100644 --- a/src/hci/commands/dhcp_cmd.c +++ b/src/hci/commands/dhcp_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/dynui_cmd.c b/src/hci/commands/dynui_cmd.c index 56a4acd06..9d1ea0e93 100644 --- a/src/hci/commands/dynui_cmd.c +++ b/src/hci/commands/dynui_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/ifmgmt_cmd.c b/src/hci/commands/ifmgmt_cmd.c index 2906d1d45..f4b9fef3a 100644 --- a/src/hci/commands/ifmgmt_cmd.c +++ b/src/hci/commands/ifmgmt_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 179256862..aaed0ea9b 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/login_cmd.c b/src/hci/commands/login_cmd.c index 005d40342..f8cd73f23 100644 --- a/src/hci/commands/login_cmd.c +++ b/src/hci/commands/login_cmd.c @@ -28,6 +28,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c index 69ab97dca..70086afce 100644 --- a/src/hci/commands/nvo_cmd.c +++ b/src/hci/commands/nvo_cmd.c @@ -34,6 +34,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/reboot_cmd.c b/src/hci/commands/reboot_cmd.c index c5b71c045..daef92dc0 100644 --- a/src/hci/commands/reboot_cmd.c +++ b/src/hci/commands/reboot_cmd.c @@ -27,6 +27,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/route_cmd.c b/src/hci/commands/route_cmd.c index a33754399..ff841ec15 100644 --- a/src/hci/commands/route_cmd.c +++ b/src/hci/commands/route_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c index 122bee527..7bc60e641 100644 --- a/src/hci/commands/sanboot_cmd.c +++ b/src/hci/commands/sanboot_cmd.c @@ -32,6 +32,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/shim_cmd.c b/src/hci/commands/shim_cmd.c index a53bb3fde..1566af4e9 100644 --- a/src/hci/commands/shim_cmd.c +++ b/src/hci/commands/shim_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/sync_cmd.c b/src/hci/commands/sync_cmd.c index 9d6e6a284..e3b97298c 100644 --- a/src/hci/commands/sync_cmd.c +++ b/src/hci/commands/sync_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/editstring.c b/src/hci/editstring.c index be9ca06a5..f88b81f7f 100644 --- a/src/hci/editstring.c +++ b/src/hci/editstring.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/jumpscroll.c b/src/hci/jumpscroll.c index 641f781a0..c6ee5bda0 100644 --- a/src/hci/jumpscroll.c +++ b/src/hci/jumpscroll.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Jump scrolling diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c index 1cf3309dd..7c607b5cc 100644 --- a/src/hci/mucurses/ansi_screen.c +++ b/src/hci/mucurses/ansi_screen.c @@ -4,6 +4,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static void ansiscr_reset(struct _curses_screen *scr) __nonnull; static void ansiscr_movetoyx(struct _curses_screen *scr, diff --git a/src/hci/mucurses/clear.c b/src/hci/mucurses/clear.c index 2054f72cc..d93e9630e 100644 --- a/src/hci/mucurses/clear.c +++ b/src/hci/mucurses/clear.c @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Clear a window to the bottom from current cursor position diff --git a/src/hci/mucurses/cursor.h b/src/hci/mucurses/cursor.h index 2e0c896a6..6f47becae 100644 --- a/src/hci/mucurses/cursor.h +++ b/src/hci/mucurses/cursor.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct cursor_pos { unsigned int y, x; diff --git a/src/hci/mucurses/mucurses.c b/src/hci/mucurses/mucurses.c index 98a8a2c59..7f1779e8f 100644 --- a/src/hci/mucurses/mucurses.c +++ b/src/hci/mucurses/mucurses.c @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static void _wupdcurs ( WINDOW *win ) __nonnull; void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull; diff --git a/src/hci/mucurses/mucurses.h b/src/hci/mucurses/mucurses.h index 270394787..dc6187741 100644 --- a/src/hci/mucurses/mucurses.h +++ b/src/hci/mucurses/mucurses.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define WRAP 0 #define NOWRAP 1 diff --git a/src/hci/mucurses/print.c b/src/hci/mucurses/print.c index e8831c58f..f7e0c8483 100644 --- a/src/hci/mucurses/print.c +++ b/src/hci/mucurses/print.c @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Add a single-byte character and rendition to a window and advance diff --git a/src/hci/mucurses/widgets/editbox.c b/src/hci/mucurses/widgets/editbox.c index c024688ab..5dab3ac5c 100644 --- a/src/hci/mucurses/widgets/editbox.c +++ b/src/hci/mucurses/widgets/editbox.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/mucurses/winattrs.c b/src/hci/mucurses/winattrs.c index 97a5a18b3..e78025543 100644 --- a/src/hci/mucurses/winattrs.c +++ b/src/hci/mucurses/winattrs.c @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Get the background rendition attributes for a window diff --git a/src/hci/mucurses/wininit.c b/src/hci/mucurses/wininit.c index dd84d2f1d..1b651123e 100644 --- a/src/hci/mucurses/wininit.c +++ b/src/hci/mucurses/wininit.c @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Initialise console environment diff --git a/src/hci/readline.c b/src/hci/readline.c index 5b46413e9..3d0330a62 100644 --- a/src/hci/readline.c +++ b/src/hci/readline.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/shell.c b/src/hci/shell.c index 7e2ecaab6..cc7910eb8 100644 --- a/src/hci/shell.c +++ b/src/hci/shell.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/strerror.c b/src/hci/strerror.c index 1bba8c620..48091b413 100644 --- a/src/hci/strerror.c +++ b/src/hci/strerror.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Find error description diff --git a/src/hci/tui/form_ui.c b/src/hci/tui/form_ui.c index 6cc28c369..2bce952fa 100644 --- a/src/hci/tui/form_ui.c +++ b/src/hci/tui/form_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/login_ui.c b/src/hci/tui/login_ui.c index 02552f0d2..31069b154 100644 --- a/src/hci/tui/login_ui.c +++ b/src/hci/tui/login_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c index c7fad4a6b..f789a298f 100644 --- a/src/hci/tui/menu_ui.c +++ b/src/hci/tui/menu_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/message.c b/src/hci/tui/message.c index e3331d655..89c6f7703 100644 --- a/src/hci/tui/message.c +++ b/src/hci/tui/message.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c index 57ff9e9a0..a069c527d 100644 --- a/src/hci/tui/settings_ui.c +++ b/src/hci/tui/settings_ui.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/efi_image.c b/src/image/efi_image.c index e7b19c4ce..2631530e7 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/embedded.c b/src/image/embedded.c index 652cfc85f..22d3738cc 100644 --- a/src/image/embedded.c +++ b/src/image/embedded.c @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/script.c b/src/image/script.c index 257e59a09..57662b788 100644 --- a/src/image/script.c +++ b/src/image/script.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/include/assert.h b/src/include/assert.h index 5affab2db..30277f9a9 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifndef ASSERTING #ifdef NDEBUG diff --git a/src/include/bits/dma.h b/src/include/bits/dma.h index e9cb84942..c44b3e456 100644 --- a/src/include/bits/dma.h +++ b/src/include/bits/dma.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_DMA_H */ diff --git a/src/include/bits/uaccess.h b/src/include/bits/uaccess.h index 09f5f46c8..e3f8b1412 100644 --- a/src/include/bits/uaccess.h +++ b/src/include/bits/uaccess.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_UACCESS_H */ diff --git a/src/include/bits/umalloc.h b/src/include/bits/umalloc.h index 4927f0d00..689755b00 100644 --- a/src/include/bits/umalloc.h +++ b/src/include/bits/umalloc.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_UMALLOC_H */ diff --git a/src/include/bits/virt_offset.h b/src/include/bits/virt_offset.h index 5f026284c..a67b6941e 100644 --- a/src/include/bits/virt_offset.h +++ b/src/include/bits/virt_offset.h @@ -11,5 +11,6 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #endif /* _BITS_VIRT_OFFSET_H */ diff --git a/src/include/byteswap.h b/src/include/byteswap.h index d1028c579..0910e4e2c 100644 --- a/src/include/byteswap.h +++ b/src/include/byteswap.h @@ -2,6 +2,7 @@ #define BYTESWAP_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ctype.h b/src/include/ctype.h index 6fefd5d77..15109ff9d 100644 --- a/src/include/ctype.h +++ b/src/include/ctype.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Check if character is ASCII diff --git a/src/include/curses.h b/src/include/curses.h index cf8cc53c9..bbc437a4e 100644 --- a/src/include/curses.h +++ b/src/include/curses.h @@ -13,6 +13,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #undef ERR #define ERR (-1) diff --git a/src/include/endian.h b/src/include/endian.h index bdae9de45..5565673ca 100644 --- a/src/include/endian.h +++ b/src/include/endian.h @@ -2,6 +2,7 @@ #define _ENDIAN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Constant representing little-endian byte order * diff --git a/src/include/errno.h b/src/include/errno.h index ac012a691..8900cdb34 100644 --- a/src/include/errno.h +++ b/src/include/errno.h @@ -25,6 +25,7 @@ #define ERRNO_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/include/getopt.h b/src/include/getopt.h index db3de1786..4087c332f 100644 --- a/src/include/getopt.h +++ b/src/include/getopt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/hci/ifmgmt_cmd.h b/src/include/hci/ifmgmt_cmd.h index 5debf85c2..f1008e14f 100644 --- a/src/include/hci/ifmgmt_cmd.h +++ b/src/include/hci/ifmgmt_cmd.h @@ -25,6 +25,7 @@ #define _IFMGMT_CMD_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/acpi.h b/src/include/ipxe/acpi.h index 5e9fb5eba..c423aa584 100644 --- a/src/include/ipxe/acpi.h +++ b/src/include/ipxe/acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ansicol.h b/src/include/ipxe/ansicol.h index 2b54ecaca..9c34d596b 100644 --- a/src/include/ipxe/ansicol.h +++ b/src/include/ipxe/ansicol.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include /* For COLOR_RED etc. */ diff --git a/src/include/ipxe/ansiesc.h b/src/include/ipxe/ansiesc.h index 80bc83308..280f51066 100644 --- a/src/include/ipxe/ansiesc.h +++ b/src/include/ipxe/ansiesc.h @@ -27,6 +27,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct ansiesc_context; diff --git a/src/include/ipxe/aoe.h b/src/include/ipxe/aoe.h index 14d11c5cb..c548f42a2 100644 --- a/src/include/ipxe/aoe.h +++ b/src/include/ipxe/aoe.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/api.h b/src/include/ipxe/api.h index d05d3b07a..ab61f4f14 100644 --- a/src/include/ipxe/api.h +++ b/src/include/ipxe/api.h @@ -12,6 +12,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @defgroup Single-implementation APIs * diff --git a/src/include/ipxe/arp.h b/src/include/ipxe/arp.h index 674423c54..c70ea7eff 100644 --- a/src/include/ipxe/arp.h +++ b/src/include/ipxe/arp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h index 86ebb890f..c5dcccb99 100644 --- a/src/include/ipxe/asn1.h +++ b/src/include/ipxe/asn1.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ata.h b/src/include/ipxe/ata.h index cd78cd795..eea086c13 100644 --- a/src/include/ipxe/ata.h +++ b/src/include/ipxe/ata.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * An ATA Logical Block Address diff --git a/src/include/ipxe/base16.h b/src/include/ipxe/base16.h index c9e430e7e..b2cf42eb4 100644 --- a/src/include/ipxe/base16.h +++ b/src/include/ipxe/base16.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/base64.h b/src/include/ipxe/base64.h index 0c70d8382..f93039901 100644 --- a/src/include/ipxe/base64.h +++ b/src/include/ipxe/base64.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/bitmap.h b/src/include/ipxe/bitmap.h index 38aca694b..7533d1bf9 100644 --- a/src/include/ipxe/bitmap.h +++ b/src/include/ipxe/bitmap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/blockdev.h b/src/include/ipxe/blockdev.h index ef6fc8d5a..7e4d48ce4 100644 --- a/src/include/ipxe/blockdev.h +++ b/src/include/ipxe/blockdev.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/blocktrans.h b/src/include/ipxe/blocktrans.h index 1eb388854..66a7e353c 100644 --- a/src/include/ipxe/blocktrans.h +++ b/src/include/ipxe/blocktrans.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/cachedhcp.h b/src/include/ipxe/cachedhcp.h index 5b19bc59e..100e5e098 100644 --- a/src/include/ipxe/cachedhcp.h +++ b/src/include/ipxe/cachedhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/chap.h b/src/include/ipxe/chap.h index 7c693e29d..965143095 100644 --- a/src/include/ipxe/chap.h +++ b/src/include/ipxe/chap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/command.h b/src/include/ipxe/command.h index 331536313..cbd5fb665 100644 --- a/src/include/ipxe/command.h +++ b/src/include/ipxe/command.h @@ -2,6 +2,7 @@ #define _IPXE_COMMAND_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/console.h b/src/include/ipxe/console.h index 1b764aaca..5e652a974 100644 --- a/src/include/ipxe/console.h +++ b/src/include/ipxe/console.h @@ -17,6 +17,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct pixel_buffer; diff --git a/src/include/ipxe/cpio.h b/src/include/ipxe/cpio.h index 744dbd269..f1752ab0a 100644 --- a/src/include/ipxe/cpio.h +++ b/src/include/ipxe/cpio.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/crc32.h b/src/include/ipxe/crc32.h index 30d2fe66c..7fe7ec88e 100644 --- a/src/include/ipxe/crc32.h +++ b/src/include/ipxe/crc32.h @@ -2,6 +2,7 @@ #define _IPXE_CRC32_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h index dd567fb2c..f458d7f30 100644 --- a/src/include/ipxe/crypto.h +++ b/src/include/ipxe/crypto.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/device.h b/src/include/ipxe/device.h index 89e6e4f31..ca12d2c07 100644 --- a/src/include/ipxe/device.h +++ b/src/include/ipxe/device.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhcp.h b/src/include/ipxe/dhcp.h index 43729d0c5..bdbe3b741 100644 --- a/src/include/ipxe/dhcp.h +++ b/src/include/ipxe/dhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhcparch.h b/src/include/ipxe/dhcparch.h index 89ecfb31e..ff611331c 100644 --- a/src/include/ipxe/dhcparch.h +++ b/src/include/ipxe/dhcparch.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Include platform-specific client architecture definitions */ #define PLATFORM_DHCPARCH(_platform) diff --git a/src/include/ipxe/dhcpopts.h b/src/include/ipxe/dhcpopts.h index 707fda4a8..9fe7bb110 100644 --- a/src/include/ipxe/dhcpopts.h +++ b/src/include/ipxe/dhcpopts.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/dhcppkt.h b/src/include/ipxe/dhcppkt.h index 86075960a..7d0153107 100644 --- a/src/include/ipxe/dhcppkt.h +++ b/src/include/ipxe/dhcppkt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhcpv6.h b/src/include/ipxe/dhcpv6.h index 065e9c376..45b36724a 100644 --- a/src/include/ipxe/dhcpv6.h +++ b/src/include/ipxe/dhcpv6.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index a6e41c1ab..e6e7a4793 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dns.h b/src/include/ipxe/dns.h index 738dea6e4..e7fc32c25 100644 --- a/src/include/ipxe/dns.h +++ b/src/include/ipxe/dns.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/downloader.h b/src/include/ipxe/downloader.h index ccb1abfef..f87a8ea78 100644 --- a/src/include/ipxe/downloader.h +++ b/src/include/ipxe/downloader.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct interface; struct image; diff --git a/src/include/ipxe/dummy_sanboot.h b/src/include/ipxe/dummy_sanboot.h index 9c9d942aa..991a2545a 100644 --- a/src/include/ipxe/dummy_sanboot.h +++ b/src/include/ipxe/dummy_sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_DUMMY #define SANBOOT_PREFIX_dummy diff --git a/src/include/ipxe/dynui.h b/src/include/ipxe/dynui.h index f47f5cb36..e50c6ab49 100644 --- a/src/include/ipxe/dynui.h +++ b/src/include/ipxe/dynui.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/eap.h b/src/include/ipxe/eap.h index a44f01e0a..2b3770138 100644 --- a/src/include/ipxe/eap.h +++ b/src/include/ipxe/eap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/eapol.h b/src/include/ipxe/eapol.h index dcf392946..2d44750ec 100644 --- a/src/include/ipxe/eapol.h +++ b/src/include/ipxe/eapol.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ecam_io.h b/src/include/ipxe/ecam_io.h index b2c232013..f31ccdc53 100644 --- a/src/include/ipxe/ecam_io.h +++ b/src/include/ipxe/ecam_io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/edd.h b/src/include/ipxe/edd.h index 1914fd0b0..9529da475 100644 --- a/src/include/ipxe/edd.h +++ b/src/include/ipxe/edd.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/editbox.h b/src/include/ipxe/editbox.h index 1f62485fe..85d5919c9 100644 --- a/src/include/ipxe/editbox.h +++ b/src/include/ipxe/editbox.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/editstring.h b/src/include/ipxe/editstring.h index 7ad8fb304..48dc34f18 100644 --- a/src/include/ipxe/editstring.h +++ b/src/include/ipxe/editstring.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** An editable string */ struct edit_string { diff --git a/src/include/ipxe/efi/ProcessorBind.h b/src/include/ipxe/efi/ProcessorBind.h index 21b873163..9fb8012f7 100644 --- a/src/include/ipxe/efi/ProcessorBind.h +++ b/src/include/ipxe/efi/ProcessorBind.h @@ -2,6 +2,7 @@ #define _IPXE_EFI_PROCESSOR_BIND_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * EFI header files rely on having the CPU architecture directory diff --git a/src/include/ipxe/efi/Protocol/AppleNetBoot.h b/src/include/ipxe/efi/Protocol/AppleNetBoot.h index 5946524fd..417730bc3 100644 --- a/src/include/ipxe/efi/Protocol/AppleNetBoot.h +++ b/src/include/ipxe/efi/Protocol/AppleNetBoot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); #define EFI_APPLE_NET_BOOT_PROTOCOL_GUID \ { 0x78ee99fb, 0x6a5e, 0x4186, \ diff --git a/src/include/ipxe/efi/Protocol/ShimLock.h b/src/include/ipxe/efi/Protocol/ShimLock.h index b31365173..8fd3c3bc8 100644 --- a/src/include/ipxe/efi/Protocol/ShimLock.h +++ b/src/include/ipxe/efi/Protocol/ShimLock.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); #define EFI_SHIM_LOCK_PROTOCOL_GUID \ { 0x605dab50, 0xe046, 0x4300, \ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 3085704b0..9554a6ad7 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); /* EFI headers rudely redefine NULL */ #undef NULL diff --git a/src/include/ipxe/efi/efi_acpi.h b/src/include/ipxe/efi/efi_acpi.h index 68f9c5be7..d11ae95b1 100644 --- a/src/include/ipxe/efi/efi_acpi.h +++ b/src/include/ipxe/efi/efi_acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef ACPI_EFI #define ACPI_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_autoboot.h b/src/include/ipxe/efi/efi_autoboot.h index 94fd2d766..29b80fd86 100644 --- a/src/include/ipxe/efi/efi_autoboot.h +++ b/src/include/ipxe/efi/efi_autoboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_autoexec.h b/src/include/ipxe/efi/efi_autoexec.h index 18bc4200c..1e68daeee 100644 --- a/src/include/ipxe/efi/efi_autoexec.h +++ b/src/include/ipxe/efi/efi_autoexec.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int efi_autoexec_load ( void ); diff --git a/src/include/ipxe/efi/efi_block.h b/src/include/ipxe/efi/efi_block.h index f8cf7fc13..b010d71a3 100644 --- a/src/include/ipxe/efi/efi_block.h +++ b/src/include/ipxe/efi/efi_block.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_EFI #define SANBOOT_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_cachedhcp.h b/src/include/ipxe/efi/efi_cachedhcp.h index 5968a1ea2..86164f463 100644 --- a/src/include/ipxe/efi/efi_cachedhcp.h +++ b/src/include/ipxe/efi/efi_cachedhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_cmdline.h b/src/include/ipxe/efi/efi_cmdline.h index 45abd5493..ed43d71a7 100644 --- a/src/include/ipxe/efi/efi_cmdline.h +++ b/src/include/ipxe/efi/efi_cmdline.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_download.h b/src/include/ipxe/efi/efi_download.h index 740fcadf5..ca96efae2 100644 --- a/src/include/ipxe/efi/efi_download.h +++ b/src/include/ipxe/efi/efi_download.h @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 5ab2d011a..f373e47d3 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_fdt.h b/src/include/ipxe/efi/efi_fdt.h index d18676d7e..644e6ddf9 100644 --- a/src/include/ipxe/efi/efi_fdt.h +++ b/src/include/ipxe/efi/efi_fdt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_file.h b/src/include/ipxe/efi/efi_file.h index 79c073cf1..bf14297a1 100644 --- a/src/include/ipxe/efi/efi_file.h +++ b/src/include/ipxe/efi/efi_file.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int efi_file_install ( EFI_HANDLE handle ); extern void efi_file_uninstall ( EFI_HANDLE handle ); diff --git a/src/include/ipxe/efi/efi_hii.h b/src/include/ipxe/efi/efi_hii.h index bbec31194..8a001723f 100644 --- a/src/include/ipxe/efi/efi_hii.h +++ b/src/include/ipxe/efi/efi_hii.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_image.h b/src/include/ipxe/efi/efi_image.h index 0fc0402b1..7fd2e2894 100644 --- a/src/include/ipxe/efi/efi_image.h +++ b/src/include/ipxe/efi/efi_image.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_nap.h b/src/include/ipxe/efi/efi_nap.h index 1ffb05569..6c01072c3 100644 --- a/src/include/ipxe/efi/efi_nap.h +++ b/src/include/ipxe/efi/efi_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_EFI #define NAP_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_null.h b/src/include/ipxe/efi/efi_null.h index d23d36349..e81545485 100644 --- a/src/include/ipxe/efi/efi_null.h +++ b/src/include/ipxe/efi/efi_null.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_path.h b/src/include/ipxe/efi/efi_path.h index a37d7b9d7..f68d782fb 100644 --- a/src/include/ipxe/efi/efi_path.h +++ b/src/include/ipxe/efi/efi_path.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_pci.h b/src/include/ipxe/efi/efi_pci.h index f8d1e3e40..670fb7d7a 100644 --- a/src/include/ipxe/efi/efi_pci.h +++ b/src/include/ipxe/efi/efi_pci.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_pci_api.h b/src/include/ipxe/efi/efi_pci_api.h index 956795254..474555871 100644 --- a/src/include/ipxe/efi/efi_pci_api.h +++ b/src/include/ipxe/efi/efi_pci_api.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_EFI #define PCIAPI_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_pxe.h b/src/include/ipxe/efi/efi_pxe.h index b356f3789..d9aac455c 100644 --- a/src/include/ipxe/efi/efi_pxe.h +++ b/src/include/ipxe/efi/efi_pxe.h @@ -10,6 +10,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int efi_pxe_install ( EFI_HANDLE handle, struct net_device *netdev ); extern void efi_pxe_uninstall ( EFI_HANDLE handle ); diff --git a/src/include/ipxe/efi/efi_reboot.h b/src/include/ipxe/efi/efi_reboot.h index 249cae8c5..8eb38f271 100644 --- a/src/include/ipxe/efi/efi_reboot.h +++ b/src/include/ipxe/efi/efi_reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef REBOOT_EFI #define REBOOT_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_service.h b/src/include/ipxe/efi/efi_service.h index ca4c7b2a4..2c5bc8fe9 100644 --- a/src/include/ipxe/efi/efi_service.h +++ b/src/include/ipxe/efi/efi_service.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_shim.h b/src/include/ipxe/efi/efi_shim.h index 21f24315a..d205dec6d 100644 --- a/src/include/ipxe/efi/efi_shim.h +++ b/src/include/ipxe/efi/efi_shim.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_smbios.h b/src/include/ipxe/efi/efi_smbios.h index d890d5460..23af651a8 100644 --- a/src/include/ipxe/efi/efi_smbios.h +++ b/src/include/ipxe/efi/efi_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_EFI #define SMBIOS_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_snp.h b/src/include/ipxe/efi/efi_snp.h index 1095b19e3..0822466db 100644 --- a/src/include/ipxe/efi/efi_snp.h +++ b/src/include/ipxe/efi/efi_snp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_strings.h b/src/include/ipxe/efi/efi_strings.h index a7adff827..36f5a7eb0 100644 --- a/src/include/ipxe/efi/efi_strings.h +++ b/src/include/ipxe/efi/efi_strings.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_table.h b/src/include/ipxe/efi/efi_table.h index 9a41d8723..714069e15 100644 --- a/src/include/ipxe/efi/efi_table.h +++ b/src/include/ipxe/efi/efi_table.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_time.h b/src/include/ipxe/efi/efi_time.h index 099994b57..8b2addc0f 100644 --- a/src/include/ipxe/efi/efi_time.h +++ b/src/include/ipxe/efi/efi_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_umalloc.h b/src/include/ipxe/efi/efi_umalloc.h index 4eb2a5f9b..4d5c706ca 100644 --- a/src/include/ipxe/efi/efi_umalloc.h +++ b/src/include/ipxe/efi/efi_umalloc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UMALLOC_EFI #define UMALLOC_PREFIX_efi diff --git a/src/include/ipxe/efi/efi_utils.h b/src/include/ipxe/efi/efi_utils.h index 98659b150..29dc171d2 100644 --- a/src/include/ipxe/efi/efi_utils.h +++ b/src/include/ipxe/efi/efi_utils.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_veto.h b/src/include/ipxe/efi/efi_veto.h index c9ecbb05c..be48441ad 100644 --- a/src/include/ipxe/efi/efi_veto.h +++ b/src/include/ipxe/efi/efi_veto.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void efi_veto ( void ); diff --git a/src/include/ipxe/efi/efi_watchdog.h b/src/include/ipxe/efi/efi_watchdog.h index 4a56b9a29..1801c6d6c 100644 --- a/src/include/ipxe/efi/efi_watchdog.h +++ b/src/include/ipxe/efi/efi_watchdog.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern struct retry_timer efi_watchdog; diff --git a/src/include/ipxe/efi/efi_wrap.h b/src/include/ipxe/efi/efi_wrap.h index 1cae3d2db..7801c77d0 100644 --- a/src/include/ipxe/efi/efi_wrap.h +++ b/src/include/ipxe/efi/efi_wrap.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/mnpnet.h b/src/include/ipxe/efi/mnpnet.h index 99d6cf083..1f2d0d1f6 100644 --- a/src/include/ipxe/efi/mnpnet.h +++ b/src/include/ipxe/efi/mnpnet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct efi_device; struct net_device; diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index d97c5eca6..8379adb13 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/errno/efi.h b/src/include/ipxe/errno/efi.h index 9f010f5fb..2db2d5cb6 100644 --- a/src/include/ipxe/errno/efi.h +++ b/src/include/ipxe/errno/efi.h @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/errortab.h b/src/include/ipxe/errortab.h index 4fe81a6be..6c63bb6d1 100644 --- a/src/include/ipxe/errortab.h +++ b/src/include/ipxe/errortab.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/eth_slow.h b/src/include/ipxe/eth_slow.h index 754ea6e1f..757bb83f0 100644 --- a/src/include/ipxe/eth_slow.h +++ b/src/include/ipxe/eth_slow.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Slow protocols header */ struct eth_slow_header { diff --git a/src/include/ipxe/ethernet.h b/src/include/ipxe/ethernet.h index dd04e00ce..f1eb21dd0 100644 --- a/src/include/ipxe/ethernet.h +++ b/src/include/ipxe/ethernet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fakedhcp.h b/src/include/ipxe/fakedhcp.h index d016b5237..f23a98f2d 100644 --- a/src/include/ipxe/fakedhcp.h +++ b/src/include/ipxe/fakedhcp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/fault.h b/src/include/ipxe/fault.h index 356296c35..251567226 100644 --- a/src/include/ipxe/fault.h +++ b/src/include/ipxe/fault.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fc.h b/src/include/ipxe/fc.h index 840d11f62..8c2bbe5e5 100644 --- a/src/include/ipxe/fc.h +++ b/src/include/ipxe/fc.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fcels.h b/src/include/ipxe/fcels.h index 02f755115..8aa086106 100644 --- a/src/include/ipxe/fcels.h +++ b/src/include/ipxe/fcels.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fcp.h b/src/include/ipxe/fcp.h index d86afab42..96aae37db 100644 --- a/src/include/ipxe/fcp.h +++ b/src/include/ipxe/fcp.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fdtmem.h b/src/include/ipxe/fdtmem.h index 8d7ebfe7e..1bbc38ff9 100644 --- a/src/include/ipxe/fdtmem.h +++ b/src/include/ipxe/fdtmem.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/features.h b/src/include/ipxe/features.h index e86a2d226..2d1ef3b7b 100644 --- a/src/include/ipxe/features.h +++ b/src/include/ipxe/features.h @@ -12,6 +12,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @defgroup featurecat Feature categories diff --git a/src/include/ipxe/fragment.h b/src/include/ipxe/fragment.h index 0069e5e08..474ad5e1c 100644 --- a/src/include/ipxe/fragment.h +++ b/src/include/ipxe/fragment.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/http.h b/src/include/ipxe/http.h index fc3e7b7a1..e84a75237 100644 --- a/src/include/ipxe/http.h +++ b/src/include/ipxe/http.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ib_mad.h b/src/include/ipxe/ib_mad.h index 134274026..dcc432558 100644 --- a/src/include/ipxe/ib_mad.h +++ b/src/include/ipxe/ib_mad.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ib_packet.h b/src/include/ipxe/ib_packet.h index 747f96399..087e86d5a 100644 --- a/src/include/ipxe/ib_packet.h +++ b/src/include/ipxe/ib_packet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct ib_device; struct ib_queue_pair; diff --git a/src/include/ipxe/ib_srp.h b/src/include/ipxe/ib_srp.h index 4b6df8d3b..9bd272a3b 100644 --- a/src/include/ipxe/ib_srp.h +++ b/src/include/ipxe/ib_srp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ibft.h b/src/include/ipxe/ibft.h index 51ce781a6..9534c1e8a 100644 --- a/src/include/ipxe/ibft.h +++ b/src/include/ipxe/ibft.h @@ -29,6 +29,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/include/ipxe/icmp.h b/src/include/ipxe/icmp.h index 803f8e019..a62e63ee8 100644 --- a/src/include/ipxe/icmp.h +++ b/src/include/ipxe/icmp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/icmpv6.h b/src/include/ipxe/icmpv6.h index 0474ddca8..7d0c5ba14 100644 --- a/src/include/ipxe/icmpv6.h +++ b/src/include/ipxe/icmpv6.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/if_arp.h b/src/include/ipxe/if_arp.h index 9d7b03fe8..31d7d8b73 100644 --- a/src/include/ipxe/if_arp.h +++ b/src/include/ipxe/if_arp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/if_ether.h b/src/include/ipxe/if_ether.h index c1168b10e..a7d0e55f9 100644 --- a/src/include/ipxe/if_ether.h +++ b/src/include/ipxe/if_ether.h @@ -2,6 +2,7 @@ #define _IPXE_IF_ETHER_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index e0e70f360..d9abe11ec 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/in.h b/src/include/ipxe/in.h index 05a8122ef..f91ab306a 100644 --- a/src/include/ipxe/in.h +++ b/src/include/ipxe/in.h @@ -2,6 +2,7 @@ #define _IPXE_IN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/infiniband.h b/src/include/ipxe/infiniband.h index 379bc109e..8022ab606 100644 --- a/src/include/ipxe/infiniband.h +++ b/src/include/ipxe/infiniband.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/init.h b/src/include/ipxe/init.h index da01b2953..00946fe83 100644 --- a/src/include/ipxe/init.h +++ b/src/include/ipxe/init.h @@ -2,6 +2,7 @@ #define _IPXE_INIT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/initrd.h b/src/include/ipxe/initrd.h index 0b955a381..50788597b 100644 --- a/src/include/ipxe/initrd.h +++ b/src/include/ipxe/initrd.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/interface.h b/src/include/ipxe/interface.h index d2fa8190c..87fd3c62f 100644 --- a/src/include/ipxe/interface.h +++ b/src/include/ipxe/interface.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/io.h b/src/include/ipxe/io.h index ee2b7e156..1bb49370c 100644 --- a/src/include/ipxe/io.h +++ b/src/include/ipxe/io.h @@ -17,6 +17,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index 46b350458..2ff24e50f 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iomap.h b/src/include/ipxe/iomap.h index 7d1547d9c..23153641e 100644 --- a/src/include/ipxe/iomap.h +++ b/src/include/ipxe/iomap.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iomap_virt.h b/src/include/ipxe/iomap_virt.h index 3dd66bd75..a2564ec76 100644 --- a/src/include/ipxe/iomap_virt.h +++ b/src/include/ipxe/iomap_virt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ip.h b/src/include/ipxe/ip.h index e2cd512ac..3a5c3e175 100644 --- a/src/include/ipxe/ip.h +++ b/src/include/ipxe/ip.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ipstat.h b/src/include/ipxe/ipstat.h index b34ed5fcf..b02673dcd 100644 --- a/src/include/ipxe/ipstat.h +++ b/src/include/ipxe/ipstat.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/ipv6.h b/src/include/ipxe/ipv6.h index 4dd43f16d..bd7181e69 100644 --- a/src/include/ipxe/ipv6.h +++ b/src/include/ipxe/ipv6.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iscsi.h b/src/include/ipxe/iscsi.h index a25eec257..e890e62ad 100644 --- a/src/include/ipxe/iscsi.h +++ b/src/include/ipxe/iscsi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/iso9660.h b/src/include/ipxe/iso9660.h index 34cb8f0a1..6727c7721 100644 --- a/src/include/ipxe/iso9660.h +++ b/src/include/ipxe/iso9660.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/job.h b/src/include/ipxe/job.h index c01bd1740..088012ba7 100644 --- a/src/include/ipxe/job.h +++ b/src/include/ipxe/job.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/jumpscroll.h b/src/include/ipxe/jumpscroll.h index 470f08e71..0eec1b47b 100644 --- a/src/include/ipxe/jumpscroll.h +++ b/src/include/ipxe/jumpscroll.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 49a8915ef..cdb83e03b 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/keys.h b/src/include/ipxe/keys.h index 38ebd7d1a..b2a62744e 100644 --- a/src/include/ipxe/keys.h +++ b/src/include/ipxe/keys.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * Symbolic names for some standard ASCII characters diff --git a/src/include/ipxe/linebuf.h b/src/include/ipxe/linebuf.h index 630278a04..b46168415 100644 --- a/src/include/ipxe/linebuf.h +++ b/src/include/ipxe/linebuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/linux/linux_acpi.h b/src/include/ipxe/linux/linux_acpi.h index a2c33ce2c..f6dbc9252 100644 --- a/src/include/ipxe/linux/linux_acpi.h +++ b/src/include/ipxe/linux/linux_acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef ACPI_LINUX #define ACPI_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_nap.h b/src/include/ipxe/linux/linux_nap.h index d072886c7..329124e52 100644 --- a/src/include/ipxe/linux/linux_nap.h +++ b/src/include/ipxe/linux/linux_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_LINUX #define NAP_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_pci.h b/src/include/ipxe/linux/linux_pci.h index f9cd98819..b0fddc41a 100644 --- a/src/include/ipxe/linux/linux_pci.h +++ b/src/include/ipxe/linux/linux_pci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_LINUX #define PCIAPI_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_smbios.h b/src/include/ipxe/linux/linux_smbios.h index 16c6d8acd..32f006b66 100644 --- a/src/include/ipxe/linux/linux_smbios.h +++ b/src/include/ipxe/linux/linux_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_LINUX #define SMBIOS_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_time.h b/src/include/ipxe/linux/linux_time.h index 872ef5ade..cf02452d7 100644 --- a/src/include/ipxe/linux/linux_time.h +++ b/src/include/ipxe/linux/linux_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef TIME_LINUX #define TIME_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 7770ea90e..c3119a60e 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -13,6 +13,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UACCESS_LINUX #define UACCESS_PREFIX_linux diff --git a/src/include/ipxe/linux/linux_umalloc.h b/src/include/ipxe/linux/linux_umalloc.h index 1811d0bc6..c1669b42a 100644 --- a/src/include/ipxe/linux/linux_umalloc.h +++ b/src/include/ipxe/linux/linux_umalloc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UMALLOC_LINUX #define UMALLOC_PREFIX_linux diff --git a/src/include/ipxe/list.h b/src/include/ipxe/list.h index 2f02e71f0..4282d8455 100644 --- a/src/include/ipxe/list.h +++ b/src/include/ipxe/list.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/lldp.h b/src/include/ipxe/lldp.h index 9951d3b8f..7d4e7f6cf 100644 --- a/src/include/ipxe/lldp.h +++ b/src/include/ipxe/lldp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/login_ui.h b/src/include/ipxe/login_ui.h index 313e07349..2924a2f63 100644 --- a/src/include/ipxe/login_ui.h +++ b/src/include/ipxe/login_ui.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int login_ui ( void ); diff --git a/src/include/ipxe/malloc.h b/src/include/ipxe/malloc.h index d3f056c15..fac46bd00 100644 --- a/src/include/ipxe/malloc.h +++ b/src/include/ipxe/malloc.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * Prototypes for the standard functions (malloc() et al) are in diff --git a/src/include/ipxe/md5.h b/src/include/ipxe/md5.h index 527ad3658..275e63824 100644 --- a/src/include/ipxe/md5.h +++ b/src/include/ipxe/md5.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/memmap.h b/src/include/ipxe/memmap.h index c16e25daa..4a768f867 100644 --- a/src/include/ipxe/memmap.h +++ b/src/include/ipxe/memmap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/message.h b/src/include/ipxe/message.h index e2e783740..997135d70 100644 --- a/src/include/ipxe/message.h +++ b/src/include/ipxe/message.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void msg ( unsigned int row, const char *fmt, ... ); extern void clearmsg ( unsigned int row ); diff --git a/src/include/ipxe/monojob.h b/src/include/ipxe/monojob.h index 1661d91c2..cda27616a 100644 --- a/src/include/ipxe/monojob.h +++ b/src/include/ipxe/monojob.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct interface; diff --git a/src/include/ipxe/nap.h b/src/include/ipxe/nap.h index 8d5d8e3df..eff5ad5b9 100644 --- a/src/include/ipxe/nap.h +++ b/src/include/ipxe/nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ndp.h b/src/include/ipxe/ndp.h index d06672ec1..0c8a9a27d 100644 --- a/src/include/ipxe/ndp.h +++ b/src/include/ipxe/ndp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/neighbour.h b/src/include/ipxe/neighbour.h index e0701f6e3..d400bb93a 100644 --- a/src/include/ipxe/neighbour.h +++ b/src/include/ipxe/neighbour.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index 17695d5b6..62f0dd1f7 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ntlm.h b/src/include/ipxe/ntlm.h index b0436c9ac..867f5ddc3 100644 --- a/src/include/ipxe/ntlm.h +++ b/src/include/ipxe/ntlm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/null_acpi.h b/src/include/ipxe/null_acpi.h index 18f059964..dd3992630 100644 --- a/src/include/ipxe/null_acpi.h +++ b/src/include/ipxe/null_acpi.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/null_memmap.h b/src/include/ipxe/null_memmap.h index 0933d45be..122280d14 100644 --- a/src/include/ipxe/null_memmap.h +++ b/src/include/ipxe/null_memmap.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef MEMMAP_NULL #define MEMMAP_PREFIX_null diff --git a/src/include/ipxe/null_nap.h b/src/include/ipxe/null_nap.h index 17145b48b..3f4fc13ae 100644 --- a/src/include/ipxe/null_nap.h +++ b/src/include/ipxe/null_nap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef NAP_NULL #define NAP_PREFIX_null diff --git a/src/include/ipxe/null_pci.h b/src/include/ipxe/null_pci.h index 0cdcdc109..1e7b4da60 100644 --- a/src/include/ipxe/null_pci.h +++ b/src/include/ipxe/null_pci.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_NULL #define PCIAPI_PREFIX_null diff --git a/src/include/ipxe/null_reboot.h b/src/include/ipxe/null_reboot.h index 5de38afc0..47539300a 100644 --- a/src/include/ipxe/null_reboot.h +++ b/src/include/ipxe/null_reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef REBOOT_NULL #define REBOOT_PREFIX_null diff --git a/src/include/ipxe/null_sanboot.h b/src/include/ipxe/null_sanboot.h index b0e36b8b0..d455edbd6 100644 --- a/src/include/ipxe/null_sanboot.h +++ b/src/include/ipxe/null_sanboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SANBOOT_NULL #define SANBOOT_PREFIX_null diff --git a/src/include/ipxe/null_smbios.h b/src/include/ipxe/null_smbios.h index c430dd089..474398b3c 100644 --- a/src/include/ipxe/null_smbios.h +++ b/src/include/ipxe/null_smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef SMBIOS_NULL #define SMBIOS_PREFIX_null diff --git a/src/include/ipxe/null_time.h b/src/include/ipxe/null_time.h index c670a5fce..db85769f7 100644 --- a/src/include/ipxe/null_time.h +++ b/src/include/ipxe/null_time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef TIME_NULL #define TIME_PREFIX_null diff --git a/src/include/ipxe/nvo.h b/src/include/ipxe/nvo.h index 7a3c7a3db..39e3a707d 100644 --- a/src/include/ipxe/nvo.h +++ b/src/include/ipxe/nvo.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/nvs.h b/src/include/ipxe/nvs.h index 5789f4c0d..1b02acea6 100644 --- a/src/include/ipxe/nvs.h +++ b/src/include/ipxe/nvs.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/open.h b/src/include/ipxe/open.h index 64e12d177..f429cadbe 100644 --- a/src/include/ipxe/open.h +++ b/src/include/ipxe/open.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/params.h b/src/include/ipxe/params.h index 61e46e029..64008380e 100644 --- a/src/include/ipxe/params.h +++ b/src/include/ipxe/params.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/parseopt.h b/src/include/ipxe/parseopt.h index 5c449cd42..dec230b0f 100644 --- a/src/include/ipxe/parseopt.h +++ b/src/include/ipxe/parseopt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pci.h b/src/include/ipxe/pci.h index 2728cbd45..44095afe2 100644 --- a/src/include/ipxe/pci.h +++ b/src/include/ipxe/pci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pci_io.h b/src/include/ipxe/pci_io.h index 7ac09efb0..e67832fec 100644 --- a/src/include/ipxe/pci_io.h +++ b/src/include/ipxe/pci_io.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pcicloud.h b/src/include/ipxe/pcicloud.h index 52268908c..19d5147be 100644 --- a/src/include/ipxe/pcicloud.h +++ b/src/include/ipxe/pcicloud.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef PCIAPI_CLOUD #define PCIAPI_PREFIX_cloud diff --git a/src/include/ipxe/pending.h b/src/include/ipxe/pending.h index be6ed05a1..1ed10df18 100644 --- a/src/include/ipxe/pending.h +++ b/src/include/ipxe/pending.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** A pending operation */ struct pending_operation { diff --git a/src/include/ipxe/ping.h b/src/include/ipxe/ping.h index c55bd1ab2..7a45f1ab7 100644 --- a/src/include/ipxe/ping.h +++ b/src/include/ipxe/ping.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pool.h b/src/include/ipxe/pool.h index 81ff57d75..fbd8567a9 100644 --- a/src/include/ipxe/pool.h +++ b/src/include/ipxe/pool.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/process.h b/src/include/ipxe/process.h index d5e13aa04..0ec94f9bc 100644 --- a/src/include/ipxe/process.h +++ b/src/include/ipxe/process.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/profile.h b/src/include/ipxe/profile.h index fd45b3cdc..c7e6d54f2 100644 --- a/src/include/ipxe/profile.h +++ b/src/include/ipxe/profile.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/quiesce.h b/src/include/ipxe/quiesce.h index 00b530b83..a43628de0 100644 --- a/src/include/ipxe/quiesce.h +++ b/src/include/ipxe/quiesce.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/reboot.h b/src/include/ipxe/reboot.h index cfd5b546d..361988ff1 100644 --- a/src/include/ipxe/reboot.h +++ b/src/include/ipxe/reboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/refcnt.h b/src/include/ipxe/refcnt.h index 7f489abc9..dff67bf58 100644 --- a/src/include/ipxe/refcnt.h +++ b/src/include/ipxe/refcnt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/resolv.h b/src/include/ipxe/resolv.h index ff48d35ca..3f26577c6 100644 --- a/src/include/ipxe/resolv.h +++ b/src/include/ipxe/resolv.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/retry.h b/src/include/ipxe/retry.h index 76d45fbd0..6817bf4c9 100644 --- a/src/include/ipxe/retry.h +++ b/src/include/ipxe/retry.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/rotate.h b/src/include/ipxe/rotate.h index 4dea09aeb..77a87dffd 100644 --- a/src/include/ipxe/rotate.h +++ b/src/include/ipxe/rotate.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/sanboot.h b/src/include/ipxe/sanboot.h index 9d5fceee0..ea44191c2 100644 --- a/src/include/ipxe/sanboot.h +++ b/src/include/ipxe/sanboot.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sbat.h b/src/include/ipxe/sbat.h index 4b74670ed..b708215c1 100644 --- a/src/include/ipxe/sbat.h +++ b/src/include/ipxe/sbat.h @@ -19,6 +19,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * A single line within an SBAT CSV file diff --git a/src/include/ipxe/script.h b/src/include/ipxe/script.h index 7e7a9a3a4..59a42c66f 100644 --- a/src/include/ipxe/script.h +++ b/src/include/ipxe/script.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/scsi.h b/src/include/ipxe/scsi.h index 9bb38a059..858f63547 100644 --- a/src/include/ipxe/scsi.h +++ b/src/include/ipxe/scsi.h @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Maximum block for READ/WRITE (10) commands */ #define SCSI_MAX_BLOCK_10 0xffffffffULL diff --git a/src/include/ipxe/settings.h b/src/include/ipxe/settings.h index 689e011d3..1582aaa8f 100644 --- a/src/include/ipxe/settings.h +++ b/src/include/ipxe/settings.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/settings_ui.h b/src/include/ipxe/settings_ui.h index 0bf21935d..41e3351bc 100644 --- a/src/include/ipxe/settings_ui.h +++ b/src/include/ipxe/settings_ui.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct settings; diff --git a/src/include/ipxe/shell.h b/src/include/ipxe/shell.h index 0d574e028..cbea7b319 100644 --- a/src/include/ipxe/shell.h +++ b/src/include/ipxe/shell.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Shell stop states */ enum shell_stop_state { diff --git a/src/include/ipxe/smbios.h b/src/include/ipxe/smbios.h index d9e2c38ed..5e431504a 100644 --- a/src/include/ipxe/smbios.h +++ b/src/include/ipxe/smbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/socket.h b/src/include/ipxe/socket.h index 8c70ea4c0..f0e80a712 100644 --- a/src/include/ipxe/socket.h +++ b/src/include/ipxe/socket.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/srp.h b/src/include/ipxe/srp.h index 1f66a22b2..c2450038f 100644 --- a/src/include/ipxe/srp.h +++ b/src/include/ipxe/srp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( BSD2 ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/stp.h b/src/include/ipxe/stp.h index 3d85e5ba4..b30e09d20 100644 --- a/src/include/ipxe/stp.h +++ b/src/include/ipxe/stp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/string.h b/src/include/ipxe/string.h index a8cbe8faa..593ced230 100644 --- a/src/include/ipxe/string.h +++ b/src/include/ipxe/string.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern unsigned int digit_value ( unsigned int digit ); diff --git a/src/include/ipxe/tables.h b/src/include/ipxe/tables.h index ac17f4b4b..d0f88cf56 100644 --- a/src/include/ipxe/tables.h +++ b/src/include/ipxe/tables.h @@ -2,6 +2,7 @@ #define _IPXE_TABLES_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @page ifdef_harmful #ifdef considered harmful * diff --git a/src/include/ipxe/tcp.h b/src/include/ipxe/tcp.h index a1e89f718..14e8169e0 100644 --- a/src/include/ipxe/tcp.h +++ b/src/include/ipxe/tcp.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/tcpip.h b/src/include/ipxe/tcpip.h index 414daad53..cfee7aa1e 100644 --- a/src/include/ipxe/tcpip.h +++ b/src/include/ipxe/tcpip.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/tftp.h b/src/include/ipxe/tftp.h index e3661e1ac..fa029e234 100644 --- a/src/include/ipxe/tftp.h +++ b/src/include/ipxe/tftp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/time.h b/src/include/ipxe/time.h index 89bf90e03..1b6f5daff 100644 --- a/src/include/ipxe/time.h +++ b/src/include/ipxe/time.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/timer.h b/src/include/ipxe/timer.h index a6dffaf1c..72ddc9d28 100644 --- a/src/include/ipxe/timer.h +++ b/src/include/ipxe/timer.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index d97db95be..1b0dc9de7 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/udp.h b/src/include/ipxe/udp.h index 7b0de4dc0..693b2a422 100644 --- a/src/include/ipxe/udp.h +++ b/src/include/ipxe/udp.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/uheap.h b/src/include/ipxe/uheap.h index d356786d3..0d37a649a 100644 --- a/src/include/ipxe/uheap.h +++ b/src/include/ipxe/uheap.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UMALLOC_UHEAP #define UMALLOC_PREFIX_uheap diff --git a/src/include/ipxe/umalloc.h b/src/include/ipxe/umalloc.h index da6c34143..c2a13dfdf 100644 --- a/src/include/ipxe/umalloc.h +++ b/src/include/ipxe/umalloc.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/uri.h b/src/include/ipxe/uri.h index a94b525e1..0de0135e4 100644 --- a/src/include/ipxe/uri.h +++ b/src/include/ipxe/uri.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h index d9891b757..9b8c7ae00 100644 --- a/src/include/ipxe/usb.h +++ b/src/include/ipxe/usb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/utf8.h b/src/include/ipxe/utf8.h index 299c25511..10b2fcbd6 100644 --- a/src/include/ipxe/utf8.h +++ b/src/include/ipxe/utf8.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/uuid.h b/src/include/ipxe/uuid.h index 4874b7382..d0120741d 100644 --- a/src/include/ipxe/uuid.h +++ b/src/include/ipxe/uuid.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/version.h b/src/include/ipxe/version.h index a43a33425..6be6096dc 100644 --- a/src/include/ipxe/version.h +++ b/src/include/ipxe/version.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/virt_offset.h b/src/include/ipxe/virt_offset.h index 2762acb40..31c434fc5 100644 --- a/src/include/ipxe/virt_offset.h +++ b/src/include/ipxe/virt_offset.h @@ -47,6 +47,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #ifdef UACCESS_OFFSET #define UACCESS_PREFIX_offset diff --git a/src/include/ipxe/vlan.h b/src/include/ipxe/vlan.h index 20bbc891d..a1cd76182 100644 --- a/src/include/ipxe/vlan.h +++ b/src/include/ipxe/vlan.h @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/vsprintf.h b/src/include/ipxe/vsprintf.h index 9e6297715..8b25422d8 100644 --- a/src/include/ipxe/vsprintf.h +++ b/src/include/ipxe/vsprintf.h @@ -32,6 +32,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/widget.h b/src/include/ipxe/widget.h index 945b4672a..6e61a8ca8 100644 --- a/src/include/ipxe/widget.h +++ b/src/include/ipxe/widget.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/xfer.h b/src/include/ipxe/xfer.h index 3a35fa924..c35be31d9 100644 --- a/src/include/ipxe/xfer.h +++ b/src/include/ipxe/xfer.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xferbuf.h b/src/include/ipxe/xferbuf.h index 04fcf2286..aa0b2471f 100644 --- a/src/include/ipxe/xferbuf.h +++ b/src/include/ipxe/xferbuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/libgen.h b/src/include/libgen.h index ae0861270..b686b15ac 100644 --- a/src/include/libgen.h +++ b/src/include/libgen.h @@ -2,6 +2,7 @@ #define _LIBGEN_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern char * basename ( char *path ); extern char * dirname ( char *path ); diff --git a/src/include/readline/readline.h b/src/include/readline/readline.h index 3caf28b47..a2a1d950a 100644 --- a/src/include/readline/readline.h +++ b/src/include/readline/readline.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** A readline history entry */ struct readline_history_entry { diff --git a/src/include/stdarg.h b/src/include/stdarg.h index 89e94ce22..a981ea24a 100644 --- a/src/include/stdarg.h +++ b/src/include/stdarg.h @@ -2,6 +2,7 @@ #define _STDARG_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); typedef __builtin_va_list va_list; #define va_start( ap, last ) __builtin_va_start ( ap, last ) diff --git a/src/include/stdbool.h b/src/include/stdbool.h index c49a7f192..6afd038db 100644 --- a/src/include/stdbool.h +++ b/src/include/stdbool.h @@ -2,6 +2,7 @@ #define _STDBOOL_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define bool _Bool #define true 1 diff --git a/src/include/stddef.h b/src/include/stddef.h index fb01c489d..7f46a7729 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -2,6 +2,7 @@ #define STDDEF_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/stdint.h b/src/include/stdint.h index 0a239a517..2fcd184fa 100644 --- a/src/include/stdint.h +++ b/src/include/stdint.h @@ -2,6 +2,7 @@ #define _STDINT_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* * This is a standard predefined macro on all gcc's I've seen. It's diff --git a/src/include/stdio.h b/src/include/stdio.h index ac17da83d..5dfa67865 100644 --- a/src/include/stdio.h +++ b/src/include/stdio.h @@ -2,6 +2,7 @@ #define _STDIO_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/stdlib.h b/src/include/stdlib.h index d7748a07e..8a531110e 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -2,6 +2,7 @@ #define STDLIB_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/string.h b/src/include/string.h index 4ee9c7344..3affe8e86 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/strings.h b/src/include/strings.h index d7e9d6971..8eac3e5e4 100644 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/sys/time.h b/src/include/sys/time.h index 6e2a24447..e49df570f 100644 --- a/src/include/sys/time.h +++ b/src/include/sys/time.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/syslog.h b/src/include/syslog.h index 748a4faec..09c0112fd 100644 --- a/src/include/syslog.h +++ b/src/include/syslog.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/time.h b/src/include/time.h index ab93a3dbb..5ef67ece2 100644 --- a/src/include/time.h +++ b/src/include/time.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/unistd.h b/src/include/unistd.h index 6c31c0601..56431d15e 100644 --- a/src/include/unistd.h +++ b/src/include/unistd.h @@ -2,6 +2,7 @@ #define _UNISTD_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/usr/autoboot.h b/src/include/usr/autoboot.h index a081a70df..fbc8b10e9 100644 --- a/src/include/usr/autoboot.h +++ b/src/include/usr/autoboot.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/dhcpmgmt.h b/src/include/usr/dhcpmgmt.h index ed669eb9d..2440b1713 100644 --- a/src/include/usr/dhcpmgmt.h +++ b/src/include/usr/dhcpmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct net_device; diff --git a/src/include/usr/ifmgmt.h b/src/include/usr/ifmgmt.h index 8d8a6bb56..3b489c02a 100644 --- a/src/include/usr/ifmgmt.h +++ b/src/include/usr/ifmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct net_device; struct net_device_configurator; diff --git a/src/include/usr/imgmgmt.h b/src/include/usr/imgmgmt.h index 506c3eb14..f98af7984 100644 --- a/src/include/usr/imgmgmt.h +++ b/src/include/usr/imgmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/prompt.h b/src/include/usr/prompt.h index 8d3eeee3c..22c39105f 100644 --- a/src/include/usr/prompt.h +++ b/src/include/usr/prompt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int prompt ( const char *text, unsigned long timeout, int key ); diff --git a/src/include/usr/route.h b/src/include/usr/route.h index 7ec4a3509..7503c8c55 100644 --- a/src/include/usr/route.h +++ b/src/include/usr/route.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/shimmgmt.h b/src/include/usr/shimmgmt.h index 0c59f54a8..0ed85c468 100644 --- a/src/include/usr/shimmgmt.h +++ b/src/include/usr/shimmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/sync.h b/src/include/usr/sync.h index b6f12ad6e..b24ab32fb 100644 --- a/src/include/usr/sync.h +++ b/src/include/usr/sync.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int sync ( unsigned long timeout ); diff --git a/src/include/valgrind/memcheck.h b/src/include/valgrind/memcheck.h index 7d4b56d31..e7fae01ed 100644 --- a/src/include/valgrind/memcheck.h +++ b/src/include/valgrind/memcheck.h @@ -61,6 +61,7 @@ #define __MEMCHECK_H FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); /* This file is for inclusion into client (your!) code. diff --git a/src/include/valgrind/valgrind.h b/src/include/valgrind/valgrind.h index d48bbccae..1a907cbbf 100644 --- a/src/include/valgrind/valgrind.h +++ b/src/include/valgrind/valgrind.h @@ -74,6 +74,7 @@ #define __VALGRIND_H FILE_LICENCE ( BSD3 ); +FILE_SECBOOT ( PERMITTED ); /* ------------------------------------------------------------------ */ diff --git a/src/include/wchar.h b/src/include/wchar.h index a7e9de4f2..427bfff7a 100644 --- a/src/include/wchar.h +++ b/src/include/wchar.h @@ -2,6 +2,7 @@ #define WCHAR_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index a2021a4f6..cb8b4a5d0 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_autoboot.c b/src/interface/efi/efi_autoboot.c index e52c857d8..9e0c3e42e 100644 --- a/src/interface/efi/efi_autoboot.c +++ b/src/interface/efi/efi_autoboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_autoexec.c b/src/interface/efi/efi_autoexec.c index 73ba5df33..b63ac1602 100644 --- a/src/interface/efi/efi_autoexec.c +++ b/src/interface/efi/efi_autoexec.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c index 10952ef8a..0da92307b 100644 --- a/src/interface/efi/efi_block.c +++ b/src/interface/efi/efi_block.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_cachedhcp.c b/src/interface/efi/efi_cachedhcp.c index 6bba4173a..2f33fcefb 100644 --- a/src/interface/efi/efi_cachedhcp.c +++ b/src/interface/efi/efi_cachedhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_cmdline.c b/src/interface/efi/efi_cmdline.c index 8b9d8efde..f5844f2ad 100644 --- a/src/interface/efi/efi_cmdline.c +++ b/src/interface/efi/efi_cmdline.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_connect.c b/src/interface/efi/efi_connect.c index 5aa8dc689..f4747cf6b 100644 --- a/src/interface/efi/efi_connect.c +++ b/src/interface/efi/efi_connect.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index e896c5d88..afbd722ab 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_download.c b/src/interface/efi/efi_download.c index 8d12bd57c..1c2f13573 100644 --- a/src/interface/efi/efi_download.c +++ b/src/interface/efi/efi_download.c @@ -17,6 +17,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index b1ff404be..cb07af401 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 1909dea10..2f49b1a99 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_guid.c b/src/interface/efi/efi_guid.c index 135eeb881..c989aebfe 100644 --- a/src/interface/efi/efi_guid.c +++ b/src/interface/efi/efi_guid.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_hii.c b/src/interface/efi/efi_hii.c index 66f58affe..fd65ae122 100644 --- a/src/interface/efi/efi_hii.c +++ b/src/interface/efi/efi_hii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index 69aea0d50..ac62ea747 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_local.c b/src/interface/efi/efi_local.c index 4564470fc..58a5f689f 100644 --- a/src/interface/efi/efi_local.c +++ b/src/interface/efi/efi_local.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_nap.c b/src/interface/efi/efi_nap.c index 2bb47627f..9d97dae6e 100644 --- a/src/interface/efi/efi_nap.c +++ b/src/interface/efi/efi_nap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_null.c b/src/interface/efi/efi_null.c index d0f0428cc..fb9ee1780 100644 --- a/src/interface/efi/efi_null.c +++ b/src/interface/efi/efi_null.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_open.c b/src/interface/efi/efi_open.c index 8f8af4ea0..679d1946e 100644 --- a/src/interface/efi/efi_open.c +++ b/src/interface/efi/efi_open.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c index dd0df67e5..37558c36e 100644 --- a/src/interface/efi/efi_path.c +++ b/src/interface/efi/efi_path.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index f4853c234..4bf3977c5 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_pxe.c b/src/interface/efi/efi_pxe.c index 4ba057019..2d1a6fd73 100644 --- a/src/interface/efi/efi_pxe.c +++ b/src/interface/efi/efi_pxe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_reboot.c b/src/interface/efi/efi_reboot.c index 7ed9f5c84..cc35ef7ad 100644 --- a/src/interface/efi/efi_reboot.c +++ b/src/interface/efi/efi_reboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_service.c b/src/interface/efi/efi_service.c index f10733b24..4e2f2e951 100644 --- a/src/interface/efi/efi_service.c +++ b/src/interface/efi/efi_service.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_settings.c b/src/interface/efi/efi_settings.c index 5ddbe12f1..95fe2c03c 100644 --- a/src/interface/efi/efi_settings.c +++ b/src/interface/efi/efi_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index 4bb6df79f..553cb2721 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include @@ -40,6 +41,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Require use of a third party loader binary diff --git a/src/interface/efi/efi_smbios.c b/src/interface/efi/efi_smbios.c index 5d0e69d6b..c10ba1440 100644 --- a/src/interface/efi/efi_smbios.c +++ b/src/interface/efi/efi_smbios.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 86ad87bde..dad8b33df 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_snp_hii.c b/src/interface/efi/efi_snp_hii.c index 8b65c8a78..25287673a 100644 --- a/src/interface/efi/efi_snp_hii.c +++ b/src/interface/efi/efi_snp_hii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_strings.c b/src/interface/efi/efi_strings.c index 765b23ca6..3dae22e41 100644 --- a/src/interface/efi/efi_strings.c +++ b/src/interface/efi/efi_strings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_table.c b/src/interface/efi/efi_table.c index 3c3f35a4b..da5966a13 100644 --- a/src/interface/efi/efi_table.c +++ b/src/interface/efi/efi_table.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_time.c b/src/interface/efi/efi_time.c index 983a0ef5c..a4c77da20 100644 --- a/src/interface/efi/efi_time.c +++ b/src/interface/efi/efi_time.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_timer.c b/src/interface/efi/efi_timer.c index 6427eb1d8..ffb899c86 100644 --- a/src/interface/efi/efi_timer.c +++ b/src/interface/efi/efi_timer.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_umalloc.c b/src/interface/efi/efi_umalloc.c index 419d9b294..257b27bec 100644 --- a/src/interface/efi/efi_umalloc.c +++ b/src/interface/efi/efi_umalloc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 51da06172..a7008afd4 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_veto.c b/src/interface/efi/efi_veto.c index da585db60..788515dd1 100644 --- a/src/interface/efi/efi_veto.c +++ b/src/interface/efi/efi_veto.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_watchdog.c b/src/interface/efi/efi_watchdog.c index dcc9a5668..5e4eb626c 100644 --- a/src/interface/efi/efi_watchdog.c +++ b/src/interface/efi/efi_watchdog.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_wrap.c b/src/interface/efi/efi_wrap.c index 320a32f02..572d05aac 100644 --- a/src/interface/efi/efi_wrap.c +++ b/src/interface/efi/efi_wrap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c index 64122185a..3c095afdc 100644 --- a/src/interface/efi/efiprefix.c +++ b/src/interface/efi/efiprefix.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/smbios/smbios.c b/src/interface/smbios/smbios.c index 3a1a98b17..a23d9bfa2 100644 --- a/src/interface/smbios/smbios.c +++ b/src/interface/smbios/smbios.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 6358a4709..d0ef49d5f 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/aoe.c b/src/net/aoe.c index b484bdd33..edeb81867 100644 --- a/src/net/aoe.c +++ b/src/net/aoe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/arp.c b/src/net/arp.c index c9b4109a9..2bf3c12ec 100644 --- a/src/net/arp.c +++ b/src/net/arp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/dhcpopts.c b/src/net/dhcpopts.c index cdb632b46..844a94d62 100644 --- a/src/net/dhcpopts.c +++ b/src/net/dhcpopts.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/dhcppkt.c b/src/net/dhcppkt.c index 4e64f85e4..a9b454695 100644 --- a/src/net/dhcppkt.c +++ b/src/net/dhcppkt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eap.c b/src/net/eap.c index 87327d723..040566b57 100644 --- a/src/net/eap.c +++ b/src/net/eap.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eap_md5.c b/src/net/eap_md5.c index 0664174f9..1e263c8ec 100644 --- a/src/net/eap_md5.c +++ b/src/net/eap_md5.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eapol.c b/src/net/eapol.c index 0c573d198..d83d63386 100644 --- a/src/net/eapol.c +++ b/src/net/eapol.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/eth_slow.c b/src/net/eth_slow.c index 1103a49f3..fb4e0d972 100644 --- a/src/net/eth_slow.c +++ b/src/net/eth_slow.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/ethernet.c b/src/net/ethernet.c index 3fcdafe6d..60219b98f 100644 --- a/src/net/ethernet.c +++ b/src/net/ethernet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/fakedhcp.c b/src/net/fakedhcp.c index 009b12c56..0020d8225 100644 --- a/src/net/fakedhcp.c +++ b/src/net/fakedhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/fragment.c b/src/net/fragment.c index 781b9bc60..4976167ed 100644 --- a/src/net/fragment.c +++ b/src/net/fragment.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/icmp.c b/src/net/icmp.c index 5371277e4..740b42440 100644 --- a/src/net/icmp.c +++ b/src/net/icmp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/icmpv4.c b/src/net/icmpv4.c index 0858ff37f..ffcc4b375 100644 --- a/src/net/icmpv4.c +++ b/src/net/icmpv4.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/icmpv6.c b/src/net/icmpv6.c index 8555aaf0b..5331b81e8 100644 --- a/src/net/icmpv6.c +++ b/src/net/icmpv6.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/iobpad.c b/src/net/iobpad.c index 936b4bde4..6366efb5e 100644 --- a/src/net/iobpad.c +++ b/src/net/iobpad.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/ipv4.c b/src/net/ipv4.c index 21abfccec..f3dd44384 100644 --- a/src/net/ipv4.c +++ b/src/net/ipv4.c @@ -49,6 +49,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Unique IP datagram identification number (high byte) */ static uint8_t next_ident_high = 0; diff --git a/src/net/ipv6.c b/src/net/ipv6.c index b12d6577e..7e908dd2a 100644 --- a/src/net/ipv6.c +++ b/src/net/ipv6.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/lldp.c b/src/net/lldp.c index 2b707c874..d0e990f23 100644 --- a/src/net/lldp.c +++ b/src/net/lldp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/ndp.c b/src/net/ndp.c index 3c555f4a3..6d96270c1 100644 --- a/src/net/ndp.c +++ b/src/net/ndp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/neighbour.c b/src/net/neighbour.c index ac79041e3..fa8fba5cd 100644 --- a/src/net/neighbour.c +++ b/src/net/neighbour.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c index 90b804c6c..8bc8ce57b 100644 --- a/src/net/netdev_settings.c +++ b/src/net/netdev_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/netdevice.c b/src/net/netdevice.c index c89585708..0af916ff5 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/nullnet.c b/src/net/nullnet.c index 2948b38c0..c665b203a 100644 --- a/src/net/nullnet.c +++ b/src/net/nullnet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/retry.c b/src/net/retry.c index 734567be5..c13ecb6b1 100644 --- a/src/net/retry.c +++ b/src/net/retry.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/socket.c b/src/net/socket.c index 2009ab237..6fed73128 100644 --- a/src/net/socket.c +++ b/src/net/socket.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/stp.c b/src/net/stp.c index 3d78400af..d1b0d4862 100644 --- a/src/net/stp.c +++ b/src/net/stp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/tcp.c b/src/net/tcp.c index 2e52cf480..f08db5250 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -28,6 +28,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** A TCP connection */ struct tcp_connection { diff --git a/src/net/tcp/http.c b/src/net/tcp/http.c index b000ed80f..16cfd035e 100644 --- a/src/net/tcp/http.c +++ b/src/net/tcp/http.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpauth.c b/src/net/tcp/httpauth.c index 2c57e3d48..d682c5f8f 100644 --- a/src/net/tcp/httpauth.c +++ b/src/net/tcp/httpauth.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpbasic.c b/src/net/tcp/httpbasic.c index 52a67063d..4dffc7e0f 100644 --- a/src/net/tcp/httpbasic.c +++ b/src/net/tcp/httpbasic.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpblock.c b/src/net/tcp/httpblock.c index 8eff1942c..14398869e 100644 --- a/src/net/tcp/httpblock.c +++ b/src/net/tcp/httpblock.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpconn.c b/src/net/tcp/httpconn.c index 538c4dcf6..4b99209f0 100644 --- a/src/net/tcp/httpconn.c +++ b/src/net/tcp/httpconn.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c index 8fee0421c..912bea407 100644 --- a/src/net/tcp/httpcore.c +++ b/src/net/tcp/httpcore.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/httpdigest.c b/src/net/tcp/httpdigest.c index 4074078c7..8ff6dbfa5 100644 --- a/src/net/tcp/httpdigest.c +++ b/src/net/tcp/httpdigest.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index b7b33a51a..0d1f0f645 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/tcpip.c b/src/net/tcpip.c index cc7d02005..5ed3d68a9 100644 --- a/src/net/tcpip.c +++ b/src/net/tcpip.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Process a received TCP/IP packet diff --git a/src/net/udp.c b/src/net/udp.c index 2c0b343dc..41aba2fca 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * A UDP connection diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index daa37b96b..59b7c663d 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/dhcpv6.c b/src/net/udp/dhcpv6.c index a49109894..43a569d6e 100644 --- a/src/net/udp/dhcpv6.c +++ b/src/net/udp/dhcpv6.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/dns.c b/src/net/udp/dns.c index f46eeb5c8..3f534b99f 100644 --- a/src/net/udp/dns.c +++ b/src/net/udp/dns.c @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 2ee01862a..760af10e9 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/vlan.c b/src/net/vlan.c index c61bb850e..f7697a9be 100644 --- a/src/net/vlan.c +++ b/src/net/vlan.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 4b64ca82b..3d46e65e0 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/dhcpmgmt.c b/src/usr/dhcpmgmt.c index dcb360b23..2a0a8c718 100644 --- a/src/usr/dhcpmgmt.c +++ b/src/usr/dhcpmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/ifmgmt.c b/src/usr/ifmgmt.c index d87ffff27..80f350ee4 100644 --- a/src/usr/ifmgmt.c +++ b/src/usr/ifmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index 65b52fd3a..bad056f0e 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/prompt.c b/src/usr/prompt.c index fca0a157c..ea233e2ed 100644 --- a/src/usr/prompt.c +++ b/src/usr/prompt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/usr/route.c b/src/usr/route.c index 690ba3b6b..77c68eeb3 100644 --- a/src/usr/route.c +++ b/src/usr/route.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/route_ipv4.c b/src/usr/route_ipv4.c index f79c0ad8f..21b0820da 100644 --- a/src/usr/route_ipv4.c +++ b/src/usr/route_ipv4.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/route_ipv6.c b/src/usr/route_ipv6.c index 9e94b4a15..9d773ec60 100644 --- a/src/usr/route_ipv6.c +++ b/src/usr/route_ipv6.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/shimmgmt.c b/src/usr/shimmgmt.c index 6ac1ac35e..fb063ad51 100644 --- a/src/usr/shimmgmt.c +++ b/src/usr/shimmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/sync.c b/src/usr/sync.c index f599588ae..1e740bd4c 100644 --- a/src/usr/sync.c +++ b/src/usr/sync.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include -- cgit v1.2.3-55-g7522 From adcaaf9b93f9de14ba93bea54aecef103fe16b5f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 14 Jan 2026 14:36:49 +0000 Subject: [build] Mark known reviewed files as permitted for UEFI Secure Boot Some past security reviews carried out for UEFI Secure Boot signing submissions have covered specific drivers or functional areas of iPXE. Mark all of the files comprising these areas as permitted for UEFI Secure Boot. Signed-off-by: Michael Brown --- src/arch/x86/core/cpuid_settings.c | 1 + src/arch/x86/core/rdrand.c | 1 + src/arch/x86/include/bits/bigint.h | 1 + src/arch/x86/include/bits/bitops.h | 1 + src/arch/x86/include/bits/xen.h | 1 + src/config/config_archive.c | 1 + src/config/config_asn1.c | 1 + src/config/config_certs.c | 1 + src/config/config_crypto.c | 1 + src/config/config_digest_cmd.c | 1 + src/config/config_entropy.c | 1 + src/config/config_fc.c | 1 + src/config/config_fdt.c | 1 + src/config/config_infiniband.c | 1 + src/config/config_pixbuf.c | 1 + src/config/config_usb.c | 1 + src/config/crypto.h | 1 + src/config/entropy.h | 1 + src/config/fdt.h | 1 + src/config/usb.h | 1 + src/core/acpi_settings.c | 1 + src/core/acpimac.c | 1 + src/core/ansicoldef.c | 1 + src/core/fbcon.c | 1 + src/core/fdt.c | 1 + src/core/isqrt.c | 1 + src/core/lineconsole.c | 1 + src/core/netbios.c | 1 + src/core/pinger.c | 1 + src/core/pixbuf.c | 1 + src/core/profile.c | 1 + src/crypto/aes.c | 1 + src/crypto/asn1.c | 1 + src/crypto/bigint.c | 1 + src/crypto/cbc.c | 1 + src/crypto/certstore.c | 1 + src/crypto/cms.c | 1 + src/crypto/crypto_null.c | 1 + src/crypto/deflate.c | 1 + src/crypto/dhe.c | 1 + src/crypto/drbg.c | 1 + src/crypto/ecb.c | 1 + src/crypto/ecdhe.c | 1 + src/crypto/ecdsa.c | 1 + src/crypto/entropy.c | 1 + src/crypto/gcm.c | 1 + src/crypto/hash_df.c | 1 + src/crypto/hmac.c | 1 + src/crypto/hmac_drbg.c | 1 + src/crypto/md4.c | 1 + src/crypto/mishmash/cmd_sha224.c | 1 + src/crypto/mishmash/cmd_sha256.c | 1 + src/crypto/mishmash/cmd_sha384.c | 1 + src/crypto/mishmash/cmd_sha512.c | 1 + src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/ecdsa_sha224.c | 1 + src/crypto/mishmash/ecdsa_sha256.c | 1 + src/crypto/mishmash/ecdsa_sha384.c | 1 + src/crypto/mishmash/ecdsa_sha512.c | 1 + src/crypto/mishmash/oid_aes_cbc.c | 1 + src/crypto/mishmash/oid_aes_gcm.c | 1 + src/crypto/mishmash/oid_p256.c | 1 + src/crypto/mishmash/oid_p384.c | 1 + src/crypto/mishmash/oid_rsa.c | 1 + src/crypto/mishmash/oid_sha1.c | 1 + src/crypto/mishmash/oid_sha224.c | 1 + src/crypto/mishmash/oid_sha256.c | 1 + src/crypto/mishmash/oid_sha384.c | 1 + src/crypto/mishmash/oid_sha512.c | 1 + src/crypto/mishmash/oid_sha512_224.c | 1 + src/crypto/mishmash/oid_sha512_256.c | 1 + src/crypto/mishmash/oid_x25519.c | 1 + src/crypto/mishmash/rsa_aes_cbc_sha1.c | 1 + src/crypto/mishmash/rsa_aes_cbc_sha256.c | 1 + src/crypto/mishmash/rsa_aes_gcm_sha256.c | 1 + src/crypto/mishmash/rsa_aes_gcm_sha384.c | 1 + src/crypto/mishmash/rsa_sha1.c | 1 + src/crypto/mishmash/rsa_sha224.c | 1 + src/crypto/mishmash/rsa_sha256.c | 1 + src/crypto/mishmash/rsa_sha384.c | 1 + src/crypto/mishmash/rsa_sha512.c | 1 + src/crypto/ntlm.c | 1 + src/crypto/ocsp.c | 1 + src/crypto/p256.c | 1 + src/crypto/p384.c | 1 + src/crypto/privkey.c | 1 + src/crypto/random_nz.c | 1 + src/crypto/rbg.c | 1 + src/crypto/rootcert.c | 1 + src/crypto/rsa.c | 1 + src/crypto/sha1.c | 1 + src/crypto/sha224.c | 1 + src/crypto/sha256.c | 1 + src/crypto/sha384.c | 1 + src/crypto/sha512.c | 1 + src/crypto/sha512_224.c | 1 + src/crypto/sha512_256.c | 1 + src/crypto/weierstrass.c | 1 + src/crypto/x25519.c | 1 + src/crypto/x509.c | 1 + src/drivers/bus/cdc.c | 1 + src/drivers/bus/pcibackup.c | 1 + src/drivers/bus/pciextra.c | 1 + src/drivers/bus/pcimsix.c | 1 + src/drivers/bus/usb.c | 1 + src/drivers/bus/usb_settings.c | 1 + src/drivers/net/acm.c | 1 + src/drivers/net/acm.h | 1 + src/drivers/net/axge.c | 1 + src/drivers/net/axge.h | 1 + src/drivers/net/dm96xx.c | 1 + src/drivers/net/dm96xx.h | 1 + src/drivers/net/ecm.c | 1 + src/drivers/net/ecm.h | 1 + src/drivers/net/ice.c | 1 + src/drivers/net/ice.h | 1 + src/drivers/net/intel.c | 1 + src/drivers/net/intel.h | 1 + src/drivers/net/intelvf.c | 1 + src/drivers/net/intelvf.h | 1 + src/drivers/net/intelx.c | 1 + src/drivers/net/intelx.h | 1 + src/drivers/net/intelxl.c | 1 + src/drivers/net/intelxl.h | 1 + src/drivers/net/intelxlvf.c | 1 + src/drivers/net/intelxlvf.h | 1 + src/drivers/net/intelxvf.c | 1 + src/drivers/net/intelxvf.h | 1 + src/drivers/net/iphone.c | 1 + src/drivers/net/iphone.h | 1 + src/drivers/net/lan78xx.c | 1 + src/drivers/net/lan78xx.h | 1 + src/drivers/net/mii.c | 1 + src/drivers/net/ncm.c | 1 + src/drivers/net/ncm.h | 1 + src/drivers/net/netfront.c | 1 + src/drivers/net/netfront.h | 1 + src/drivers/net/smsc75xx.c | 1 + src/drivers/net/smsc75xx.h | 1 + src/drivers/net/smsc95xx.c | 1 + src/drivers/net/smsc95xx.h | 1 + src/drivers/net/smscusb.c | 1 + src/drivers/net/smscusb.h | 1 + src/drivers/net/vmxnet3.c | 1 + src/drivers/net/vmxnet3.h | 1 + src/drivers/usb/ehci.c | 1 + src/drivers/usb/ehci.h | 1 + src/drivers/usb/uhci.c | 1 + src/drivers/usb/uhci.h | 1 + src/drivers/usb/usbblk.c | 1 + src/drivers/usb/usbblk.h | 1 + src/drivers/usb/usbhub.c | 1 + src/drivers/usb/usbhub.h | 1 + src/drivers/usb/usbnet.c | 1 + src/drivers/usb/xhci.c | 1 + src/hci/commands/cert_cmd.c | 1 + src/hci/commands/console_cmd.c | 1 + src/hci/commands/digest_cmd.c | 1 + src/hci/commands/image_trust_cmd.c | 1 + src/hci/commands/ipstat_cmd.c | 1 + src/hci/commands/neighbour_cmd.c | 1 + src/hci/commands/nslookup_cmd.c | 1 + src/hci/commands/ntp_cmd.c | 1 + src/hci/commands/param_cmd.c | 1 + src/hci/commands/ping_cmd.c | 1 + src/hci/commands/poweroff_cmd.c | 1 + src/hci/commands/profstat_cmd.c | 1 + src/hci/commands/vlan_cmd.c | 1 + src/image/der.c | 1 + src/image/efi_siglist.c | 1 + src/image/pem.c | 1 + src/image/png.c | 1 + src/include/hci/digest_cmd.h | 1 + src/include/ipxe/acpimac.h | 1 + src/include/ipxe/aes.h | 1 + src/include/ipxe/bigint.h | 1 + src/include/ipxe/bitops.h | 1 + src/include/ipxe/cbc.h | 1 + src/include/ipxe/cdc.h | 1 + src/include/ipxe/certstore.h | 1 + src/include/ipxe/cms.h | 1 + src/include/ipxe/deflate.h | 1 + src/include/ipxe/der.h | 1 + src/include/ipxe/dhe.h | 1 + src/include/ipxe/drbg.h | 1 + src/include/ipxe/ecb.h | 1 + src/include/ipxe/ecdhe.h | 1 + src/include/ipxe/ecdsa.h | 1 + src/include/ipxe/efi/efi_siglist.h | 1 + src/include/ipxe/efi/efi_usb.h | 3 +++ src/include/ipxe/entropy.h | 1 + src/include/ipxe/fbcon.h | 1 + src/include/ipxe/fdt.h | 1 + src/include/ipxe/gcm.h | 1 + src/include/ipxe/hash_df.h | 1 + src/include/ipxe/hmac.h | 1 + src/include/ipxe/hmac_drbg.h | 1 + src/include/ipxe/isqrt.h | 1 + src/include/ipxe/lineconsole.h | 1 + src/include/ipxe/md4.h | 1 + src/include/ipxe/mii.h | 1 + src/include/ipxe/netbios.h | 1 + src/include/ipxe/ntp.h | 1 + src/include/ipxe/ocsp.h | 1 + src/include/ipxe/p256.h | 1 + src/include/ipxe/p384.h | 1 + src/include/ipxe/pccrc.h | 1 + src/include/ipxe/pccrd.h | 1 + src/include/ipxe/pccrr.h | 1 + src/include/ipxe/pcibackup.h | 1 + src/include/ipxe/pcimsix.h | 1 + src/include/ipxe/peerblk.h | 1 + src/include/ipxe/peerdisc.h | 1 + src/include/ipxe/peermux.h | 1 + src/include/ipxe/pem.h | 1 + src/include/ipxe/pinger.h | 1 + src/include/ipxe/pixbuf.h | 1 + src/include/ipxe/png.h | 1 + src/include/ipxe/privkey.h | 1 + src/include/ipxe/random_nz.h | 1 + src/include/ipxe/rbg.h | 1 + src/include/ipxe/rndis.h | 1 + src/include/ipxe/rootcert.h | 1 + src/include/ipxe/rsa.h | 1 + src/include/ipxe/sha1.h | 1 + src/include/ipxe/sha256.h | 1 + src/include/ipxe/sha512.h | 1 + src/include/ipxe/syslog.h | 1 + src/include/ipxe/tls.h | 1 + src/include/ipxe/usbnet.h | 1 + src/include/ipxe/validator.h | 1 + src/include/ipxe/weierstrass.h | 1 + src/include/ipxe/x25519.h | 1 + src/include/ipxe/x509.h | 1 + src/include/ipxe/xen.h | 1 + src/include/ipxe/xenbus.h | 1 + src/include/ipxe/xenevent.h | 1 + src/include/ipxe/xengrant.h | 1 + src/include/ipxe/xenstore.h | 1 + src/include/ipxe/xhci.h | 1 + src/include/mii.h | 1 + src/include/usr/certmgmt.h | 1 + src/include/usr/imgtrust.h | 1 + src/include/usr/ipstat.h | 1 + src/include/usr/neighmgmt.h | 1 + src/include/usr/nslookup.h | 1 + src/include/usr/ntpmgmt.h | 1 + src/include/usr/pingmgmt.h | 1 + src/include/usr/profstat.h | 1 + src/include/xen/arch-x86/xen-x86_64.h | 1 + src/include/xen/arch-x86/xen.h | 1 + src/include/xen/event_channel.h | 1 + src/include/xen/grant_table.h | 1 + src/include/xen/io/netif.h | 1 + src/include/xen/io/ring.h | 1 + src/include/xen/io/xenbus.h | 1 + src/include/xen/io/xs_wire.h | 1 + src/include/xen/xen-compat.h | 1 + src/include/xen/xen.h | 1 + src/interface/efi/efi_cacert.c | 1 + src/interface/efi/efi_entropy.c | 1 + src/interface/efi/efi_fbcon.c | 1 + src/interface/efi/efi_fdt.c | 1 + src/interface/efi/efi_rng.c | 1 + src/interface/efi/efi_usb.c | 1 + src/interface/xen/xenbus.c | 1 + src/interface/xen/xengrant.c | 1 + src/interface/xen/xenstore.c | 1 + src/net/pccrc.c | 1 + src/net/pccrd.c | 1 + src/net/peerblk.c | 1 + src/net/peerdisc.c | 1 + src/net/peerdist.c | 1 + src/net/peermux.c | 1 + src/net/ping.c | 1 + src/net/rndis.c | 1 + src/net/tcp/httpntlm.c | 1 + src/net/tcp/https.c | 1 + src/net/tcp/syslogs.c | 1 + src/net/tls.c | 1 + src/net/udp/ntp.c | 1 + src/net/udp/syslog.c | 1 + src/net/validator.c | 1 + src/usr/certmgmt.c | 1 + src/usr/imgtrust.c | 1 + src/usr/ipstat.c | 1 + src/usr/neighmgmt.c | 1 + src/usr/nslookup.c | 1 + src/usr/ntpmgmt.c | 1 + src/usr/pingmgmt.c | 1 + src/usr/profstat.c | 1 + 304 files changed, 306 insertions(+) (limited to 'src/interface') diff --git a/src/arch/x86/core/cpuid_settings.c b/src/arch/x86/core/cpuid_settings.c index 44d38debc..ef0164069 100644 --- a/src/arch/x86/core/cpuid_settings.c +++ b/src/arch/x86/core/cpuid_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/core/rdrand.c b/src/arch/x86/core/rdrand.c index 850ab1f11..05fc3cd23 100644 --- a/src/arch/x86/core/rdrand.c +++ b/src/arch/x86/core/rdrand.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/arch/x86/include/bits/bigint.h b/src/arch/x86/include/bits/bigint.h index c6f097a34..21cffa0cf 100644 --- a/src/arch/x86/include/bits/bigint.h +++ b/src/arch/x86/include/bits/bigint.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/arch/x86/include/bits/bitops.h b/src/arch/x86/include/bits/bitops.h index f697b8c8f..cdbc3b0a2 100644 --- a/src/arch/x86/include/bits/bitops.h +++ b/src/arch/x86/include/bits/bitops.h @@ -14,6 +14,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/arch/x86/include/bits/xen.h b/src/arch/x86/include/bits/xen.h index 3433cea1f..313bec254 100644 --- a/src/arch/x86/include/bits/xen.h +++ b/src/arch/x86/include/bits/xen.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Hypercall registers */ #ifdef __x86_64__ diff --git a/src/config/config_archive.c b/src/config/config_archive.c index 746fc7e44..71c883dcc 100644 --- a/src/config/config_archive.c +++ b/src/config/config_archive.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_asn1.c b/src/config/config_asn1.c index 107f99c1d..ad3e95b96 100644 --- a/src/config/config_asn1.c +++ b/src/config/config_asn1.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_certs.c b/src/config/config_certs.c index a325d132c..ad5a2f708 100644 --- a/src/config/config_certs.c +++ b/src/config/config_certs.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_crypto.c b/src/config/config_crypto.c index 4bba147e5..724b95d02 100644 --- a/src/config/config_crypto.c +++ b/src/config/config_crypto.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_digest_cmd.c b/src/config/config_digest_cmd.c index 5a8752ae1..1c4d8dca1 100644 --- a/src/config/config_digest_cmd.c +++ b/src/config/config_digest_cmd.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_entropy.c b/src/config/config_entropy.c index 92aa97884..494b19f20 100644 --- a/src/config/config_entropy.c +++ b/src/config/config_entropy.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_fc.c b/src/config/config_fc.c index 33fc9462a..3aea9b080 100644 --- a/src/config/config_fc.c +++ b/src/config/config_fc.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_fdt.c b/src/config/config_fdt.c index e8d425933..a6fb6f332 100644 --- a/src/config/config_fdt.c +++ b/src/config/config_fdt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_infiniband.c b/src/config/config_infiniband.c index 4da8fe219..9e0826169 100644 --- a/src/config/config_infiniband.c +++ b/src/config/config_infiniband.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_pixbuf.c b/src/config/config_pixbuf.c index f8ff59daf..b2dbd869a 100644 --- a/src/config/config_pixbuf.c +++ b/src/config/config_pixbuf.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/config_usb.c b/src/config/config_usb.c index 10dec221a..b3fd412e9 100644 --- a/src/config/config_usb.c +++ b/src/config/config_usb.c @@ -20,6 +20,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/config/crypto.h b/src/config/crypto.h index a0774390b..e28ba2777 100644 --- a/src/config/crypto.h +++ b/src/config/crypto.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** Minimum TLS version */ #define TLS_VERSION_MIN TLS_VERSION_TLS_1_1 diff --git a/src/config/entropy.h b/src/config/entropy.h index c79060fd5..db180c61a 100644 --- a/src/config/entropy.h +++ b/src/config/entropy.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/fdt.h b/src/config/fdt.h index 4d13e0535..7f3d39768 100644 --- a/src/config/fdt.h +++ b/src/config/fdt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/config/usb.h b/src/config/usb.h index 4252ec229..09e0b82e6 100644 --- a/src/config/usb.h +++ b/src/config/usb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/core/acpi_settings.c b/src/core/acpi_settings.c index 63f271855..8dc2a7fd8 100644 --- a/src/core/acpi_settings.c +++ b/src/core/acpi_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/core/acpimac.c b/src/core/acpimac.c index 11ac3243e..04fd98836 100644 --- a/src/core/acpimac.c +++ b/src/core/acpimac.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/ansicoldef.c b/src/core/ansicoldef.c index 6d8598e11..4555c4e36 100644 --- a/src/core/ansicoldef.c +++ b/src/core/ansicoldef.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/fbcon.c b/src/core/fbcon.c index ef158aec7..e07605470 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/fdt.c b/src/core/fdt.c index 08adb166e..8ac781b05 100644 --- a/src/core/fdt.c +++ b/src/core/fdt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/isqrt.c b/src/core/isqrt.c index c4d0571e7..b553c0935 100644 --- a/src/core/isqrt.c +++ b/src/core/isqrt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/lineconsole.c b/src/core/lineconsole.c index 0a72d1434..25eae39dd 100644 --- a/src/core/lineconsole.c +++ b/src/core/lineconsole.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/netbios.c b/src/core/netbios.c index 0d4e2086f..299e0d599 100644 --- a/src/core/netbios.c +++ b/src/core/netbios.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/pinger.c b/src/core/pinger.c index 0ff7bb9f2..bbfa83f8d 100644 --- a/src/core/pinger.c +++ b/src/core/pinger.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/core/pixbuf.c b/src/core/pixbuf.c index 506a28c38..df187f93d 100644 --- a/src/core/pixbuf.c +++ b/src/core/pixbuf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/core/profile.c b/src/core/profile.c index 3655108ea..27d481d45 100644 --- a/src/core/profile.c +++ b/src/core/profile.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/aes.c b/src/crypto/aes.c index 5200e7760..fe6ccb222 100644 --- a/src/crypto/aes.c +++ b/src/crypto/aes.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/asn1.c b/src/crypto/asn1.c index dd0b954e1..98d5b638f 100644 --- a/src/crypto/asn1.c +++ b/src/crypto/asn1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/bigint.c b/src/crypto/bigint.c index 9ccd9ff88..5d2f7b560 100644 --- a/src/crypto/bigint.c +++ b/src/crypto/bigint.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/cbc.c b/src/crypto/cbc.c index 0ba17ee48..ddba7abd9 100644 --- a/src/crypto/cbc.c +++ b/src/crypto/cbc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/certstore.c b/src/crypto/certstore.c index aad874297..8472a2eed 100644 --- a/src/crypto/certstore.c +++ b/src/crypto/certstore.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/cms.c b/src/crypto/cms.c index 7775e581b..4c0f3f5a6 100644 --- a/src/crypto/cms.c +++ b/src/crypto/cms.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/crypto_null.c b/src/crypto/crypto_null.c index e80f2707f..8637987b1 100644 --- a/src/crypto/crypto_null.c +++ b/src/crypto/crypto_null.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/crypto/deflate.c b/src/crypto/deflate.c index 5d0101184..1d54749e0 100644 --- a/src/crypto/deflate.c +++ b/src/crypto/deflate.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/dhe.c b/src/crypto/dhe.c index a249f9b40..2785a500b 100644 --- a/src/crypto/dhe.c +++ b/src/crypto/dhe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/drbg.c b/src/crypto/drbg.c index a3366e806..c4dc7646d 100644 --- a/src/crypto/drbg.c +++ b/src/crypto/drbg.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/ecb.c b/src/crypto/ecb.c index 3c9cf340c..73eef09c2 100644 --- a/src/crypto/ecb.c +++ b/src/crypto/ecb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/ecdhe.c b/src/crypto/ecdhe.c index 6c86b1c90..016253457 100644 --- a/src/crypto/ecdhe.c +++ b/src/crypto/ecdhe.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/ecdsa.c b/src/crypto/ecdsa.c index cd06d5578..6f10a1a0f 100644 --- a/src/crypto/ecdsa.c +++ b/src/crypto/ecdsa.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/entropy.c b/src/crypto/entropy.c index 419007159..ac0e92c42 100644 --- a/src/crypto/entropy.c +++ b/src/crypto/entropy.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/gcm.c b/src/crypto/gcm.c index b93925d07..b9c9d3a39 100644 --- a/src/crypto/gcm.c +++ b/src/crypto/gcm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/hash_df.c b/src/crypto/hash_df.c index dc0dc0ce8..ec4bcaebc 100644 --- a/src/crypto/hash_df.c +++ b/src/crypto/hash_df.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/hmac.c b/src/crypto/hmac.c index 7109bbf6a..ed4cefaad 100644 --- a/src/crypto/hmac.c +++ b/src/crypto/hmac.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/crypto/hmac_drbg.c b/src/crypto/hmac_drbg.c index 57bde4d1d..bd831e239 100644 --- a/src/crypto/hmac_drbg.c +++ b/src/crypto/hmac_drbg.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/md4.c b/src/crypto/md4.c index dcd86a428..a9184aa57 100644 --- a/src/crypto/md4.c +++ b/src/crypto/md4.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/mishmash/cmd_sha224.c b/src/crypto/mishmash/cmd_sha224.c index 3975a37c5..fd8095937 100644 --- a/src/crypto/mishmash/cmd_sha224.c +++ b/src/crypto/mishmash/cmd_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/cmd_sha256.c b/src/crypto/mishmash/cmd_sha256.c index 8076e8dbf..259ae3eac 100644 --- a/src/crypto/mishmash/cmd_sha256.c +++ b/src/crypto/mishmash/cmd_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/cmd_sha384.c b/src/crypto/mishmash/cmd_sha384.c index ed7265ab9..c31154d24 100644 --- a/src/crypto/mishmash/cmd_sha384.c +++ b/src/crypto/mishmash/cmd_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/cmd_sha512.c b/src/crypto/mishmash/cmd_sha512.c index 96b8ade88..b6207f86d 100644 --- a/src/crypto/mishmash/cmd_sha512.c +++ b/src/crypto/mishmash/cmd_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c index 05e409f7a..ec2155001 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c index 6ce428642..4e6226e87 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c index dc5cad9f8..6bbe4d00d 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c index 0448255f3..336feb195 100644 --- a/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c index d6eaf8b0a..0d9fcd15d 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c index 0fc486fbd..4b7cf1620 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c index 5106c18ce..85373911a 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_cbc_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c index 2b118e7a5..5aeb2f3d9 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c index b4946df88..3dc6149d7 100644 --- a/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/ecdhe_ecdsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c index c23f65cc0..46b42ac1e 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c index 431e2e304..dd524ec78 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c index c52976809..7524d1ccc 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c index 4f4e38c69..978be2a4c 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c index 0bc7c305f..5ca6f0457 100644 --- a/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha224.c b/src/crypto/mishmash/ecdsa_sha224.c index ab42658cb..92aa881cd 100644 --- a/src/crypto/mishmash/ecdsa_sha224.c +++ b/src/crypto/mishmash/ecdsa_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha256.c b/src/crypto/mishmash/ecdsa_sha256.c index 12cbec80c..025d6ec73 100644 --- a/src/crypto/mishmash/ecdsa_sha256.c +++ b/src/crypto/mishmash/ecdsa_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha384.c b/src/crypto/mishmash/ecdsa_sha384.c index b52621311..d7a0ca5d6 100644 --- a/src/crypto/mishmash/ecdsa_sha384.c +++ b/src/crypto/mishmash/ecdsa_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/ecdsa_sha512.c b/src/crypto/mishmash/ecdsa_sha512.c index 420c685e7..15391abf2 100644 --- a/src/crypto/mishmash/ecdsa_sha512.c +++ b/src/crypto/mishmash/ecdsa_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_aes_cbc.c b/src/crypto/mishmash/oid_aes_cbc.c index b5f716574..d5b81541a 100644 --- a/src/crypto/mishmash/oid_aes_cbc.c +++ b/src/crypto/mishmash/oid_aes_cbc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_aes_gcm.c b/src/crypto/mishmash/oid_aes_gcm.c index af1432d8e..6be1a132d 100644 --- a/src/crypto/mishmash/oid_aes_gcm.c +++ b/src/crypto/mishmash/oid_aes_gcm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_p256.c b/src/crypto/mishmash/oid_p256.c index d473df09f..81ae1d11e 100644 --- a/src/crypto/mishmash/oid_p256.c +++ b/src/crypto/mishmash/oid_p256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_p384.c b/src/crypto/mishmash/oid_p384.c index 968fb45c1..a7d36aee4 100644 --- a/src/crypto/mishmash/oid_p384.c +++ b/src/crypto/mishmash/oid_p384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_rsa.c b/src/crypto/mishmash/oid_rsa.c index 582022628..02bb59edb 100644 --- a/src/crypto/mishmash/oid_rsa.c +++ b/src/crypto/mishmash/oid_rsa.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha1.c b/src/crypto/mishmash/oid_sha1.c index 5dae6d27c..5ddd2aba8 100644 --- a/src/crypto/mishmash/oid_sha1.c +++ b/src/crypto/mishmash/oid_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha224.c b/src/crypto/mishmash/oid_sha224.c index ee7ed22e4..6658bda56 100644 --- a/src/crypto/mishmash/oid_sha224.c +++ b/src/crypto/mishmash/oid_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha256.c b/src/crypto/mishmash/oid_sha256.c index 963fddb63..8da40a70b 100644 --- a/src/crypto/mishmash/oid_sha256.c +++ b/src/crypto/mishmash/oid_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha384.c b/src/crypto/mishmash/oid_sha384.c index 81ff48bbf..57c1ab53b 100644 --- a/src/crypto/mishmash/oid_sha384.c +++ b/src/crypto/mishmash/oid_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha512.c b/src/crypto/mishmash/oid_sha512.c index 78bae48b4..73d7cb78f 100644 --- a/src/crypto/mishmash/oid_sha512.c +++ b/src/crypto/mishmash/oid_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha512_224.c b/src/crypto/mishmash/oid_sha512_224.c index 6f61f9cac..a6291097b 100644 --- a/src/crypto/mishmash/oid_sha512_224.c +++ b/src/crypto/mishmash/oid_sha512_224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_sha512_256.c b/src/crypto/mishmash/oid_sha512_256.c index bce4762e4..d36199372 100644 --- a/src/crypto/mishmash/oid_sha512_256.c +++ b/src/crypto/mishmash/oid_sha512_256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/oid_x25519.c b/src/crypto/mishmash/oid_x25519.c index 30b7905ea..2907eb461 100644 --- a/src/crypto/mishmash/oid_x25519.c +++ b/src/crypto/mishmash/oid_x25519.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_cbc_sha1.c b/src/crypto/mishmash/rsa_aes_cbc_sha1.c index 0862fb5ac..35f5f6eb7 100644 --- a/src/crypto/mishmash/rsa_aes_cbc_sha1.c +++ b/src/crypto/mishmash/rsa_aes_cbc_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_cbc_sha256.c b/src/crypto/mishmash/rsa_aes_cbc_sha256.c index e5928db82..22705df7e 100644 --- a/src/crypto/mishmash/rsa_aes_cbc_sha256.c +++ b/src/crypto/mishmash/rsa_aes_cbc_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_gcm_sha256.c b/src/crypto/mishmash/rsa_aes_gcm_sha256.c index b18bbd844..d3fd00f1e 100644 --- a/src/crypto/mishmash/rsa_aes_gcm_sha256.c +++ b/src/crypto/mishmash/rsa_aes_gcm_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_aes_gcm_sha384.c b/src/crypto/mishmash/rsa_aes_gcm_sha384.c index 06558aaed..908db086a 100644 --- a/src/crypto/mishmash/rsa_aes_gcm_sha384.c +++ b/src/crypto/mishmash/rsa_aes_gcm_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha1.c b/src/crypto/mishmash/rsa_sha1.c index 264f871f1..8907ac08a 100644 --- a/src/crypto/mishmash/rsa_sha1.c +++ b/src/crypto/mishmash/rsa_sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha224.c b/src/crypto/mishmash/rsa_sha224.c index 1465a033d..b676d41f3 100644 --- a/src/crypto/mishmash/rsa_sha224.c +++ b/src/crypto/mishmash/rsa_sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha256.c b/src/crypto/mishmash/rsa_sha256.c index 7283c3e29..8a6a7a5cf 100644 --- a/src/crypto/mishmash/rsa_sha256.c +++ b/src/crypto/mishmash/rsa_sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha384.c b/src/crypto/mishmash/rsa_sha384.c index 6f8c29b29..cc1878bd4 100644 --- a/src/crypto/mishmash/rsa_sha384.c +++ b/src/crypto/mishmash/rsa_sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/mishmash/rsa_sha512.c b/src/crypto/mishmash/rsa_sha512.c index bb4463a5a..9c995e1c8 100644 --- a/src/crypto/mishmash/rsa_sha512.c +++ b/src/crypto/mishmash/rsa_sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/ntlm.c b/src/crypto/ntlm.c index fb120f8db..f9ce51bde 100644 --- a/src/crypto/ntlm.c +++ b/src/crypto/ntlm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/ocsp.c b/src/crypto/ocsp.c index 1712d614e..5d6acb605 100644 --- a/src/crypto/ocsp.c +++ b/src/crypto/ocsp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/p256.c b/src/crypto/p256.c index 2ba66e72c..a513555b3 100644 --- a/src/crypto/p256.c +++ b/src/crypto/p256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/p384.c b/src/crypto/p384.c index a53a9ce9d..bdd23d460 100644 --- a/src/crypto/p384.c +++ b/src/crypto/p384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/privkey.c b/src/crypto/privkey.c index cbe8deff3..c67a4400b 100644 --- a/src/crypto/privkey.c +++ b/src/crypto/privkey.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/random_nz.c b/src/crypto/random_nz.c index 5fe576e05..96b12359c 100644 --- a/src/crypto/random_nz.c +++ b/src/crypto/random_nz.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/rbg.c b/src/crypto/rbg.c index 5e1c25f53..17914542e 100644 --- a/src/crypto/rbg.c +++ b/src/crypto/rbg.c @@ -34,6 +34,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/rootcert.c b/src/crypto/rootcert.c index b198c1d95..6eb08256a 100644 --- a/src/crypto/rootcert.c +++ b/src/crypto/rootcert.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c index 9c0982cf6..be055d881 100644 --- a/src/crypto/rsa.c +++ b/src/crypto/rsa.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/crypto/sha1.c b/src/crypto/sha1.c index 8eecc75b3..023becec6 100644 --- a/src/crypto/sha1.c +++ b/src/crypto/sha1.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha224.c b/src/crypto/sha224.c index e54a0abb0..7e0cfd34e 100644 --- a/src/crypto/sha224.c +++ b/src/crypto/sha224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha256.c b/src/crypto/sha256.c index c30300eb4..742393612 100644 --- a/src/crypto/sha256.c +++ b/src/crypto/sha256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha384.c b/src/crypto/sha384.c index f1af6fc6f..3e5e98a31 100644 --- a/src/crypto/sha384.c +++ b/src/crypto/sha384.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha512.c b/src/crypto/sha512.c index d7d44b284..724cb71a5 100644 --- a/src/crypto/sha512.c +++ b/src/crypto/sha512.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha512_224.c b/src/crypto/sha512_224.c index b6728726c..3b256a3b9 100644 --- a/src/crypto/sha512_224.c +++ b/src/crypto/sha512_224.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/sha512_256.c b/src/crypto/sha512_256.c index 8163631e0..04df3f5bc 100644 --- a/src/crypto/sha512_256.c +++ b/src/crypto/sha512_256.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/weierstrass.c b/src/crypto/weierstrass.c index bb9b50bf8..a64626c85 100644 --- a/src/crypto/weierstrass.c +++ b/src/crypto/weierstrass.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/x25519.c b/src/crypto/x25519.c index 4b4c489da..95c42ea13 100644 --- a/src/crypto/x25519.c +++ b/src/crypto/x25519.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/crypto/x509.c b/src/crypto/x509.c index 1206e4023..6a3fe423b 100644 --- a/src/crypto/x509.c +++ b/src/crypto/x509.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/cdc.c b/src/drivers/bus/cdc.c index 373a03072..c3a2a450b 100644 --- a/src/drivers/bus/cdc.c +++ b/src/drivers/bus/cdc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pcibackup.c b/src/drivers/bus/pcibackup.c index 4cf126f83..81fcb7e05 100644 --- a/src/drivers/bus/pcibackup.c +++ b/src/drivers/bus/pcibackup.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pciextra.c b/src/drivers/bus/pciextra.c index 3654a2d1c..f769a3172 100644 --- a/src/drivers/bus/pciextra.c +++ b/src/drivers/bus/pciextra.c @@ -1,4 +1,5 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/pcimsix.c b/src/drivers/bus/pcimsix.c index f55488ad7..008c1c22f 100644 --- a/src/drivers/bus/pcimsix.c +++ b/src/drivers/bus/pcimsix.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c index b3b361b0d..30c288df9 100644 --- a/src/drivers/bus/usb.c +++ b/src/drivers/bus/usb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/bus/usb_settings.c b/src/drivers/bus/usb_settings.c index bb01f34d5..e34c79126 100644 --- a/src/drivers/bus/usb_settings.c +++ b/src/drivers/bus/usb_settings.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/acm.c b/src/drivers/net/acm.c index 16dab4be8..0cb2713b2 100644 --- a/src/drivers/net/acm.c +++ b/src/drivers/net/acm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/acm.h b/src/drivers/net/acm.h index d4944967b..3f10f0fa2 100644 --- a/src/drivers/net/acm.h +++ b/src/drivers/net/acm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/axge.c b/src/drivers/net/axge.c index fb274d24f..922c94d91 100644 --- a/src/drivers/net/axge.c +++ b/src/drivers/net/axge.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/axge.h b/src/drivers/net/axge.h index e22e0ec47..c30ca5950 100644 --- a/src/drivers/net/axge.h +++ b/src/drivers/net/axge.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/dm96xx.c b/src/drivers/net/dm96xx.c index 61b957be9..193980a40 100644 --- a/src/drivers/net/dm96xx.c +++ b/src/drivers/net/dm96xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/dm96xx.h b/src/drivers/net/dm96xx.h index 43a1a4e30..33e404e17 100644 --- a/src/drivers/net/dm96xx.h +++ b/src/drivers/net/dm96xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ecm.c b/src/drivers/net/ecm.c index 7b3e92b9b..9a13b68a5 100644 --- a/src/drivers/net/ecm.c +++ b/src/drivers/net/ecm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ecm.h b/src/drivers/net/ecm.h index a7d03cf94..d77b0c64f 100644 --- a/src/drivers/net/ecm.h +++ b/src/drivers/net/ecm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ice.c b/src/drivers/net/ice.c index b5d66f1bb..1abc8ecd0 100644 --- a/src/drivers/net/ice.c +++ b/src/drivers/net/ice.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ice.h b/src/drivers/net/ice.h index 26291a7a1..c4b7b95be 100644 --- a/src/drivers/net/ice.h +++ b/src/drivers/net/ice.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include "intelxl.h" diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index 845ba3e7f..57c0151a4 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intel.h b/src/drivers/net/intel.h index 29cf3a7d8..bfd250f00 100644 --- a/src/drivers/net/intel.h +++ b/src/drivers/net/intel.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelvf.c b/src/drivers/net/intelvf.c index 0d48b4178..e99b67626 100644 --- a/src/drivers/net/intelvf.c +++ b/src/drivers/net/intelvf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelvf.h b/src/drivers/net/intelvf.h index ffb18e040..378f9b075 100644 --- a/src/drivers/net/intelvf.h +++ b/src/drivers/net/intelvf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "intel.h" diff --git a/src/drivers/net/intelx.c b/src/drivers/net/intelx.c index 343d01374..ceb687e4f 100644 --- a/src/drivers/net/intelx.c +++ b/src/drivers/net/intelx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelx.h b/src/drivers/net/intelx.h index d7f3b78e8..d68f50082 100644 --- a/src/drivers/net/intelx.h +++ b/src/drivers/net/intelx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 76b9ff48f..f8d325ead 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxl.h b/src/drivers/net/intelxl.h index d23acf96e..4481300d3 100644 --- a/src/drivers/net/intelxl.h +++ b/src/drivers/net/intelxl.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxlvf.c b/src/drivers/net/intelxlvf.c index 083195513..ab4df4c47 100644 --- a/src/drivers/net/intelxlvf.c +++ b/src/drivers/net/intelxlvf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxlvf.h b/src/drivers/net/intelxlvf.h index 95ddf9474..63ed0b202 100644 --- a/src/drivers/net/intelxlvf.h +++ b/src/drivers/net/intelxlvf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "intelxl.h" diff --git a/src/drivers/net/intelxvf.c b/src/drivers/net/intelxvf.c index d50bac698..70ed8efe3 100644 --- a/src/drivers/net/intelxvf.c +++ b/src/drivers/net/intelxvf.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/intelxvf.h b/src/drivers/net/intelxvf.h index 4663272aa..1dac98699 100644 --- a/src/drivers/net/intelxvf.h +++ b/src/drivers/net/intelxvf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "intelvf.h" diff --git a/src/drivers/net/iphone.c b/src/drivers/net/iphone.c index 11f763553..b58017560 100644 --- a/src/drivers/net/iphone.c +++ b/src/drivers/net/iphone.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/iphone.h b/src/drivers/net/iphone.h index 2db6da7bd..3448af37f 100644 --- a/src/drivers/net/iphone.h +++ b/src/drivers/net/iphone.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/lan78xx.c b/src/drivers/net/lan78xx.c index 3f4f21b60..32333e787 100644 --- a/src/drivers/net/lan78xx.c +++ b/src/drivers/net/lan78xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/lan78xx.h b/src/drivers/net/lan78xx.h index 39422aec0..ea6d7ce52 100644 --- a/src/drivers/net/lan78xx.h +++ b/src/drivers/net/lan78xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "smscusb.h" #include "smsc75xx.h" diff --git a/src/drivers/net/mii.c b/src/drivers/net/mii.c index 87605f0cb..85749b941 100644 --- a/src/drivers/net/mii.c +++ b/src/drivers/net/mii.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ncm.c b/src/drivers/net/ncm.c index 2c0f91e21..48f9856b0 100644 --- a/src/drivers/net/ncm.c +++ b/src/drivers/net/ncm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/ncm.h b/src/drivers/net/ncm.h index 6b0d21cdb..53e96cf72 100644 --- a/src/drivers/net/ncm.h +++ b/src/drivers/net/ncm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/netfront.c b/src/drivers/net/netfront.c index 12713c5b4..ba6a20002 100644 --- a/src/drivers/net/netfront.c +++ b/src/drivers/net/netfront.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/netfront.h b/src/drivers/net/netfront.h index de16d5291..0520a0b2a 100644 --- a/src/drivers/net/netfront.h +++ b/src/drivers/net/netfront.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smsc75xx.c b/src/drivers/net/smsc75xx.c index 861669edf..8ae65e42a 100644 --- a/src/drivers/net/smsc75xx.c +++ b/src/drivers/net/smsc75xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smsc75xx.h b/src/drivers/net/smsc75xx.h index 72339df03..51330993d 100644 --- a/src/drivers/net/smsc75xx.h +++ b/src/drivers/net/smsc75xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "smscusb.h" diff --git a/src/drivers/net/smsc95xx.c b/src/drivers/net/smsc95xx.c index 0210e9240..16086b33e 100644 --- a/src/drivers/net/smsc95xx.c +++ b/src/drivers/net/smsc95xx.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smsc95xx.h b/src/drivers/net/smsc95xx.h index 0cdf38248..0cb6ab4c7 100644 --- a/src/drivers/net/smsc95xx.h +++ b/src/drivers/net/smsc95xx.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include "smscusb.h" diff --git a/src/drivers/net/smscusb.c b/src/drivers/net/smscusb.c index 93007e386..486b5953b 100644 --- a/src/drivers/net/smscusb.c +++ b/src/drivers/net/smscusb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/smscusb.h b/src/drivers/net/smscusb.h index e866bb747..e4ad61915 100644 --- a/src/drivers/net/smscusb.h +++ b/src/drivers/net/smscusb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/vmxnet3.c b/src/drivers/net/vmxnet3.c index 2cc6738f2..95e4f79c2 100644 --- a/src/drivers/net/vmxnet3.c +++ b/src/drivers/net/vmxnet3.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/net/vmxnet3.h b/src/drivers/net/vmxnet3.h index 5e1e0cb6e..b6c3bc50d 100644 --- a/src/drivers/net/vmxnet3.h +++ b/src/drivers/net/vmxnet3.h @@ -25,6 +25,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index 77022a47d..9f9d94175 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/ehci.h b/src/drivers/usb/ehci.h index 42e282e92..a0166bc63 100644 --- a/src/drivers/usb/ehci.h +++ b/src/drivers/usb/ehci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/uhci.c b/src/drivers/usb/uhci.c index 47474bdc7..2c70a11bd 100644 --- a/src/drivers/usb/uhci.c +++ b/src/drivers/usb/uhci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/uhci.h b/src/drivers/usb/uhci.h index ba4c28f7e..629f6ae3b 100644 --- a/src/drivers/usb/uhci.h +++ b/src/drivers/usb/uhci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbblk.c b/src/drivers/usb/usbblk.c index cb377efb0..b42c70645 100644 --- a/src/drivers/usb/usbblk.c +++ b/src/drivers/usb/usbblk.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbblk.h b/src/drivers/usb/usbblk.h index 65d0705e3..1fa0ebad8 100644 --- a/src/drivers/usb/usbblk.h +++ b/src/drivers/usb/usbblk.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbhub.c b/src/drivers/usb/usbhub.c index 28d6cb33d..1d7b03e77 100644 --- a/src/drivers/usb/usbhub.c +++ b/src/drivers/usb/usbhub.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbhub.h b/src/drivers/usb/usbhub.h index a5f123acc..9768b81a9 100644 --- a/src/drivers/usb/usbhub.h +++ b/src/drivers/usb/usbhub.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/usbnet.c b/src/drivers/usb/usbnet.c index 0fac00b56..e773ab882 100644 --- a/src/drivers/usb/usbnet.c +++ b/src/drivers/usb/usbnet.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index 440c347c8..f812ed338 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/cert_cmd.c b/src/hci/commands/cert_cmd.c index efa4c3c12..ebd9a25cd 100644 --- a/src/hci/commands/cert_cmd.c +++ b/src/hci/commands/cert_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/console_cmd.c b/src/hci/commands/console_cmd.c index 19d19ef1b..29347bbba 100644 --- a/src/hci/commands/console_cmd.c +++ b/src/hci/commands/console_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/digest_cmd.c b/src/hci/commands/digest_cmd.c index a7f43f69e..4d7da0385 100644 --- a/src/hci/commands/digest_cmd.c +++ b/src/hci/commands/digest_cmd.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/image_trust_cmd.c b/src/hci/commands/image_trust_cmd.c index 314aa0998..a8ec5784e 100644 --- a/src/hci/commands/image_trust_cmd.c +++ b/src/hci/commands/image_trust_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/ipstat_cmd.c b/src/hci/commands/ipstat_cmd.c index 488016e3a..fc454c57d 100644 --- a/src/hci/commands/ipstat_cmd.c +++ b/src/hci/commands/ipstat_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/neighbour_cmd.c b/src/hci/commands/neighbour_cmd.c index 520d5aa06..870024ee0 100644 --- a/src/hci/commands/neighbour_cmd.c +++ b/src/hci/commands/neighbour_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/nslookup_cmd.c b/src/hci/commands/nslookup_cmd.c index dc9d61704..b13127dd4 100644 --- a/src/hci/commands/nslookup_cmd.c +++ b/src/hci/commands/nslookup_cmd.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/ntp_cmd.c b/src/hci/commands/ntp_cmd.c index fed126f4c..d7604227a 100644 --- a/src/hci/commands/ntp_cmd.c +++ b/src/hci/commands/ntp_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/param_cmd.c b/src/hci/commands/param_cmd.c index 0924df597..ed57c5eaa 100644 --- a/src/hci/commands/param_cmd.c +++ b/src/hci/commands/param_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/ping_cmd.c b/src/hci/commands/ping_cmd.c index 4e86ae1c0..e132fb457 100644 --- a/src/hci/commands/ping_cmd.c +++ b/src/hci/commands/ping_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/poweroff_cmd.c b/src/hci/commands/poweroff_cmd.c index 2c6f1369a..63aeb3d5b 100644 --- a/src/hci/commands/poweroff_cmd.c +++ b/src/hci/commands/poweroff_cmd.c @@ -29,6 +29,7 @@ #include FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/hci/commands/profstat_cmd.c b/src/hci/commands/profstat_cmd.c index da01068b2..3303ebcf3 100644 --- a/src/hci/commands/profstat_cmd.c +++ b/src/hci/commands/profstat_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/hci/commands/vlan_cmd.c b/src/hci/commands/vlan_cmd.c index 636e5927f..69aef9f3c 100644 --- a/src/hci/commands/vlan_cmd.c +++ b/src/hci/commands/vlan_cmd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/der.c b/src/image/der.c index 67117d43b..ace106b84 100644 --- a/src/image/der.c +++ b/src/image/der.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/efi_siglist.c b/src/image/efi_siglist.c index b264ac558..71d597006 100644 --- a/src/image/efi_siglist.c +++ b/src/image/efi_siglist.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/image/pem.c b/src/image/pem.c index caff822ad..0fea5fbea 100644 --- a/src/image/pem.c +++ b/src/image/pem.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/image/png.c b/src/image/png.c index b7864f770..ab279eae5 100644 --- a/src/image/png.c +++ b/src/image/png.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/hci/digest_cmd.h b/src/include/hci/digest_cmd.h index 0986f775e..9cb4fde1a 100644 --- a/src/include/hci/digest_cmd.h +++ b/src/include/hci/digest_cmd.h @@ -25,6 +25,7 @@ #define _DIGEST_CMD_H FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/acpimac.h b/src/include/ipxe/acpimac.h index de673eb28..074165a92 100644 --- a/src/include/ipxe/acpimac.h +++ b/src/include/ipxe/acpimac.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int acpi_mac ( uint8_t *hw_addr ); diff --git a/src/include/ipxe/aes.h b/src/include/ipxe/aes.h index 8731de6ba..1c0024ccb 100644 --- a/src/include/ipxe/aes.h +++ b/src/include/ipxe/aes.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h index 9eab89d25..9c31f4540 100644 --- a/src/include/ipxe/bigint.h +++ b/src/include/ipxe/bigint.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/bitops.h b/src/include/ipxe/bitops.h index 7366cd9f1..59a4fb442 100644 --- a/src/include/ipxe/bitops.h +++ b/src/include/ipxe/bitops.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/cbc.h b/src/include/ipxe/cbc.h index f02e51937..154fc5666 100644 --- a/src/include/ipxe/cbc.h +++ b/src/include/ipxe/cbc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/cdc.h b/src/include/ipxe/cdc.h index b8b4a59d9..a61fe61ea 100644 --- a/src/include/ipxe/cdc.h +++ b/src/include/ipxe/cdc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/certstore.h b/src/include/ipxe/certstore.h index e276d6792..293f6dec7 100644 --- a/src/include/ipxe/certstore.h +++ b/src/include/ipxe/certstore.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/cms.h b/src/include/ipxe/cms.h index 084cd81f8..d2e426c5c 100644 --- a/src/include/ipxe/cms.h +++ b/src/include/ipxe/cms.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/deflate.h b/src/include/ipxe/deflate.h index 67292d77e..7e5ae01b9 100644 --- a/src/include/ipxe/deflate.h +++ b/src/include/ipxe/deflate.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/der.h b/src/include/ipxe/der.h index 512bc0853..17e96405e 100644 --- a/src/include/ipxe/der.h +++ b/src/include/ipxe/der.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/dhe.h b/src/include/ipxe/dhe.h index 3cd24a880..f89e7bd02 100644 --- a/src/include/ipxe/dhe.h +++ b/src/include/ipxe/dhe.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/drbg.h b/src/include/ipxe/drbg.h index ed2b3757a..0512f0833 100644 --- a/src/include/ipxe/drbg.h +++ b/src/include/ipxe/drbg.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ecb.h b/src/include/ipxe/ecb.h index db22d996d..c29602fca 100644 --- a/src/include/ipxe/ecb.h +++ b/src/include/ipxe/ecb.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/ecdhe.h b/src/include/ipxe/ecdhe.h index 36fc0a1ee..c6575678c 100644 --- a/src/include/ipxe/ecdhe.h +++ b/src/include/ipxe/ecdhe.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/ecdsa.h b/src/include/ipxe/ecdsa.h index f55af3973..fdf8c6159 100644 --- a/src/include/ipxe/ecdsa.h +++ b/src/include/ipxe/ecdsa.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/efi/efi_siglist.h b/src/include/ipxe/efi/efi_siglist.h index cbc835dc0..f2a2fcfd0 100644 --- a/src/include/ipxe/efi/efi_siglist.h +++ b/src/include/ipxe/efi/efi_siglist.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/efi/efi_usb.h b/src/include/ipxe/efi/efi_usb.h index 06baff529..cbcef0e52 100644 --- a/src/include/ipxe/efi/efi_usb.h +++ b/src/include/ipxe/efi/efi_usb.h @@ -7,6 +7,9 @@ * */ +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); + #include #include #include diff --git a/src/include/ipxe/entropy.h b/src/include/ipxe/entropy.h index 82bb11826..8ec8f1047 100644 --- a/src/include/ipxe/entropy.h +++ b/src/include/ipxe/entropy.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fbcon.h b/src/include/ipxe/fbcon.h index 5233b4d0e..75cda3390 100644 --- a/src/include/ipxe/fbcon.h +++ b/src/include/ipxe/fbcon.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h index e951aea59..6aa078ff6 100644 --- a/src/include/ipxe/fdt.h +++ b/src/include/ipxe/fdt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/gcm.h b/src/include/ipxe/gcm.h index 2c785a977..5635a1031 100644 --- a/src/include/ipxe/gcm.h +++ b/src/include/ipxe/gcm.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/hash_df.h b/src/include/ipxe/hash_df.h index e57682446..61c3420ce 100644 --- a/src/include/ipxe/hash_df.h +++ b/src/include/ipxe/hash_df.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/hmac.h b/src/include/ipxe/hmac.h index cf9d08677..12312c540 100644 --- a/src/include/ipxe/hmac.h +++ b/src/include/ipxe/hmac.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/hmac_drbg.h b/src/include/ipxe/hmac_drbg.h index a0f22da75..e9113807c 100644 --- a/src/include/ipxe/hmac_drbg.h +++ b/src/include/ipxe/hmac_drbg.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/isqrt.h b/src/include/ipxe/isqrt.h index 68255d1bc..4308cebd2 100644 --- a/src/include/ipxe/isqrt.h +++ b/src/include/ipxe/isqrt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern unsigned long isqrt ( unsigned long value ); diff --git a/src/include/ipxe/lineconsole.h b/src/include/ipxe/lineconsole.h index 31117e73c..b02822dcf 100644 --- a/src/include/ipxe/lineconsole.h +++ b/src/include/ipxe/lineconsole.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/md4.h b/src/include/ipxe/md4.h index 9f6cb8a5f..60512993b 100644 --- a/src/include/ipxe/md4.h +++ b/src/include/ipxe/md4.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/mii.h b/src/include/ipxe/mii.h index 89fc92a4a..061aeb24e 100644 --- a/src/include/ipxe/mii.h +++ b/src/include/ipxe/mii.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/netbios.h b/src/include/ipxe/netbios.h index c11552556..80f791738 100644 --- a/src/include/ipxe/netbios.h +++ b/src/include/ipxe/netbios.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern const char * netbios_domain ( char **username ); diff --git a/src/include/ipxe/ntp.h b/src/include/ipxe/ntp.h index f5b3d2326..7f83c6d4f 100644 --- a/src/include/ipxe/ntp.h +++ b/src/include/ipxe/ntp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/ocsp.h b/src/include/ipxe/ocsp.h index a973f6f5e..9302506f8 100644 --- a/src/include/ipxe/ocsp.h +++ b/src/include/ipxe/ocsp.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/p256.h b/src/include/ipxe/p256.h index 0c4e81665..14d429cd9 100644 --- a/src/include/ipxe/p256.h +++ b/src/include/ipxe/p256.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/p384.h b/src/include/ipxe/p384.h index f4631b5f2..2fdd8d13c 100644 --- a/src/include/ipxe/p384.h +++ b/src/include/ipxe/p384.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/pccrc.h b/src/include/ipxe/pccrc.h index bec2b271a..6d0e3f194 100644 --- a/src/include/ipxe/pccrc.h +++ b/src/include/ipxe/pccrc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pccrd.h b/src/include/ipxe/pccrd.h index 3daa92f29..453ef666d 100644 --- a/src/include/ipxe/pccrd.h +++ b/src/include/ipxe/pccrd.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** PeerDist discovery port */ #define PEERDIST_DISCOVERY_PORT 3702 diff --git a/src/include/ipxe/pccrr.h b/src/include/ipxe/pccrr.h index 4de94fda3..92522d0b7 100644 --- a/src/include/ipxe/pccrr.h +++ b/src/include/ipxe/pccrr.h @@ -10,6 +10,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/pcibackup.h b/src/include/ipxe/pcibackup.h index e5249df99..a25421d7d 100644 --- a/src/include/ipxe/pcibackup.h +++ b/src/include/ipxe/pcibackup.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/pcimsix.h b/src/include/ipxe/pcimsix.h index b40c6c357..a7a6899a9 100644 --- a/src/include/ipxe/pcimsix.h +++ b/src/include/ipxe/pcimsix.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/peerblk.h b/src/include/ipxe/peerblk.h index f16f207b0..596c78b57 100644 --- a/src/include/ipxe/peerblk.h +++ b/src/include/ipxe/peerblk.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/peerdisc.h b/src/include/ipxe/peerdisc.h index 45d592e76..9a8f13ecf 100644 --- a/src/include/ipxe/peerdisc.h +++ b/src/include/ipxe/peerdisc.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/peermux.h b/src/include/ipxe/peermux.h index 54acbfec9..849488d0a 100644 --- a/src/include/ipxe/peermux.h +++ b/src/include/ipxe/peermux.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pem.h b/src/include/ipxe/pem.h index d9ca017d5..95c55408b 100644 --- a/src/include/ipxe/pem.h +++ b/src/include/ipxe/pem.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pinger.h b/src/include/ipxe/pinger.h index 227f002dc..ade12ec12 100644 --- a/src/include/ipxe/pinger.h +++ b/src/include/ipxe/pinger.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/pixbuf.h b/src/include/ipxe/pixbuf.h index 47ea0065e..e2cbcdca7 100644 --- a/src/include/ipxe/pixbuf.h +++ b/src/include/ipxe/pixbuf.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/png.h b/src/include/ipxe/png.h index 3505eefc8..31cac0534 100644 --- a/src/include/ipxe/png.h +++ b/src/include/ipxe/png.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/privkey.h b/src/include/ipxe/privkey.h index a65cf6106..56f23143e 100644 --- a/src/include/ipxe/privkey.h +++ b/src/include/ipxe/privkey.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/random_nz.h b/src/include/ipxe/random_nz.h index 4c433fa38..2de1a1a33 100644 --- a/src/include/ipxe/random_nz.h +++ b/src/include/ipxe/random_nz.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/rbg.h b/src/include/ipxe/rbg.h index 4bf3055d1..0b65a408c 100644 --- a/src/include/ipxe/rbg.h +++ b/src/include/ipxe/rbg.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/rndis.h b/src/include/ipxe/rndis.h index e8ece1e85..bd64eddfe 100644 --- a/src/include/ipxe/rndis.h +++ b/src/include/ipxe/rndis.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/rootcert.h b/src/include/ipxe/rootcert.h index d1a69723d..f07c612ff 100644 --- a/src/include/ipxe/rootcert.h +++ b/src/include/ipxe/rootcert.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/rsa.h b/src/include/ipxe/rsa.h index e36a75edf..c5ae919ae 100644 --- a/src/include/ipxe/rsa.h +++ b/src/include/ipxe/rsa.h @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sha1.h b/src/include/ipxe/sha1.h index 9cbbebdee..33b07ecc3 100644 --- a/src/include/ipxe/sha1.h +++ b/src/include/ipxe/sha1.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sha256.h b/src/include/ipxe/sha256.h index f226ad07b..e8a81b889 100644 --- a/src/include/ipxe/sha256.h +++ b/src/include/ipxe/sha256.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/sha512.h b/src/include/ipxe/sha512.h index 82a9e4e69..74cdb413c 100644 --- a/src/include/ipxe/sha512.h +++ b/src/include/ipxe/sha512.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/syslog.h b/src/include/ipxe/syslog.h index 138440d66..67f45fdb4 100644 --- a/src/include/ipxe/syslog.h +++ b/src/include/ipxe/syslog.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/tls.h b/src/include/ipxe/tls.h index 1a1d9c982..b4a92a044 100644 --- a/src/include/ipxe/tls.h +++ b/src/include/ipxe/tls.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/usbnet.h b/src/include/ipxe/usbnet.h index a7276eba5..937a26d9a 100644 --- a/src/include/ipxe/usbnet.h +++ b/src/include/ipxe/usbnet.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/validator.h b/src/include/ipxe/validator.h index 367e4045d..4d95766fa 100644 --- a/src/include/ipxe/validator.h +++ b/src/include/ipxe/validator.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/weierstrass.h b/src/include/ipxe/weierstrass.h index 15dd9ce03..ced99b4fc 100644 --- a/src/include/ipxe/weierstrass.h +++ b/src/include/ipxe/weierstrass.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/x25519.h b/src/include/ipxe/x25519.h index d570282c5..ef294f7b2 100644 --- a/src/include/ipxe/x25519.h +++ b/src/include/ipxe/x25519.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/x509.h b/src/include/ipxe/x509.h index 4903eb656..360e2b19a 100644 --- a/src/include/ipxe/x509.h +++ b/src/include/ipxe/x509.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xen.h b/src/include/ipxe/xen.h index 382901ff3..9ddfcdf81 100644 --- a/src/include/ipxe/xen.h +++ b/src/include/ipxe/xen.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /* Define Xen interface version before including any Xen header files */ #define __XEN_INTERFACE_VERSION__ 0x00040400 diff --git a/src/include/ipxe/xenbus.h b/src/include/ipxe/xenbus.h index ec5782eed..d73f29781 100644 --- a/src/include/ipxe/xenbus.h +++ b/src/include/ipxe/xenbus.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xenevent.h b/src/include/ipxe/xenevent.h index f0bd3465e..8be9e2b2f 100644 --- a/src/include/ipxe/xenevent.h +++ b/src/include/ipxe/xenevent.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xengrant.h b/src/include/ipxe/xengrant.h index fcb7a7157..8af27f3e3 100644 --- a/src/include/ipxe/xengrant.h +++ b/src/include/ipxe/xengrant.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/ipxe/xenstore.h b/src/include/ipxe/xenstore.h index 892640755..c2079cec5 100644 --- a/src/include/ipxe/xenstore.h +++ b/src/include/ipxe/xenstore.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/ipxe/xhci.h b/src/include/ipxe/xhci.h index 586d5d320..2f5c256a0 100644 --- a/src/include/ipxe/xhci.h +++ b/src/include/ipxe/xhci.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/include/mii.h b/src/include/mii.h index 515ba224d..9d6b2b3b7 100644 --- a/src/include/mii.h +++ b/src/include/mii.h @@ -12,6 +12,7 @@ */ FILE_LICENCE ( GPL2_ONLY ); +FILE_SECBOOT ( PERMITTED ); /* Generic MII registers. */ #define MII_BMCR 0x00 /* Basic mode control register */ diff --git a/src/include/usr/certmgmt.h b/src/include/usr/certmgmt.h index 4363b03e1..ff646236b 100644 --- a/src/include/usr/certmgmt.h +++ b/src/include/usr/certmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/imgtrust.h b/src/include/usr/imgtrust.h index 414e07a80..1e43f5d3d 100644 --- a/src/include/usr/imgtrust.h +++ b/src/include/usr/imgtrust.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/ipstat.h b/src/include/usr/ipstat.h index 803254bcb..2399446eb 100644 --- a/src/include/usr/ipstat.h +++ b/src/include/usr/ipstat.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void ipstat ( void ); diff --git a/src/include/usr/neighmgmt.h b/src/include/usr/neighmgmt.h index 06f03716e..5ed5829c4 100644 --- a/src/include/usr/neighmgmt.h +++ b/src/include/usr/neighmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void nstat ( void ); diff --git a/src/include/usr/nslookup.h b/src/include/usr/nslookup.h index d34649e9f..3b2bb504d 100644 --- a/src/include/usr/nslookup.h +++ b/src/include/usr/nslookup.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); extern int nslookup ( const char *name, const char *setting_name ); diff --git a/src/include/usr/ntpmgmt.h b/src/include/usr/ntpmgmt.h index 284e668e6..6d90ec749 100644 --- a/src/include/usr/ntpmgmt.h +++ b/src/include/usr/ntpmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern int ntp ( const char *hostname ); diff --git a/src/include/usr/pingmgmt.h b/src/include/usr/pingmgmt.h index c7a8434be..d15a748d8 100644 --- a/src/include/usr/pingmgmt.h +++ b/src/include/usr/pingmgmt.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include diff --git a/src/include/usr/profstat.h b/src/include/usr/profstat.h index b7812ca7f..c5d545a86 100644 --- a/src/include/usr/profstat.h +++ b/src/include/usr/profstat.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); extern void profstat ( void ); diff --git a/src/include/xen/arch-x86/xen-x86_64.h b/src/include/xen/arch-x86/xen-x86_64.h index 8287fd20f..618bf07d7 100644 --- a/src/include/xen/arch-x86/xen-x86_64.h +++ b/src/include/xen/arch-x86/xen-x86_64.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* * Hypercall interface: diff --git a/src/include/xen/arch-x86/xen.h b/src/include/xen/arch-x86/xen.h index 2b7afb2f4..7df850650 100644 --- a/src/include/xen/arch-x86/xen.h +++ b/src/include/xen/arch-x86/xen.h @@ -13,6 +13,7 @@ #define __XEN_PUBLIC_ARCH_X86_XEN_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* Structural guest handles introduced in 0x00030201. */ #if __XEN_INTERFACE_VERSION__ >= 0x00030201 diff --git a/src/include/xen/event_channel.h b/src/include/xen/event_channel.h index 0c3752723..a3145d76f 100644 --- a/src/include/xen/event_channel.h +++ b/src/include/xen/event_channel.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_EVENT_CHANNEL_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "xen.h" diff --git a/src/include/xen/grant_table.h b/src/include/xen/grant_table.h index f0ae17c41..141a17f56 100644 --- a/src/include/xen/grant_table.h +++ b/src/include/xen/grant_table.h @@ -12,6 +12,7 @@ #define __XEN_PUBLIC_GRANT_TABLE_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "xen.h" diff --git a/src/include/xen/io/netif.h b/src/include/xen/io/netif.h index bec61ab3e..59887a80f 100644 --- a/src/include/xen/io/netif.h +++ b/src/include/xen/io/netif.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_IO_NETIF_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "ring.h" #include "../grant_table.h" diff --git a/src/include/xen/io/ring.h b/src/include/xen/io/ring.h index 41b50e2cf..3451bbb52 100644 --- a/src/include/xen/io/ring.h +++ b/src/include/xen/io/ring.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_IO_RING_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* * When #include'ing this header, you need to provide the following diff --git a/src/include/xen/io/xenbus.h b/src/include/xen/io/xenbus.h index 473f538b8..3bf417c3a 100644 --- a/src/include/xen/io/xenbus.h +++ b/src/include/xen/io/xenbus.h @@ -11,6 +11,7 @@ #define _XEN_PUBLIC_IO_XENBUS_H FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); /* * The state of either end of the Xenbus, i.e. the current communication diff --git a/src/include/xen/io/xs_wire.h b/src/include/xen/io/xs_wire.h index cffd75cde..99dc91781 100644 --- a/src/include/xen/io/xs_wire.h +++ b/src/include/xen/io/xs_wire.h @@ -10,6 +10,7 @@ #define _XS_WIRE_H FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); enum xsd_sockmsg_type { diff --git a/src/include/xen/xen-compat.h b/src/include/xen/xen-compat.h index 8b2361807..8e4ed2434 100644 --- a/src/include/xen/xen-compat.h +++ b/src/include/xen/xen-compat.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_XEN_COMPAT_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #define __XEN_LATEST_INTERFACE_VERSION__ 0x00040e00 diff --git a/src/include/xen/xen.h b/src/include/xen/xen.h index c35008aa0..6d8192f8d 100644 --- a/src/include/xen/xen.h +++ b/src/include/xen/xen.h @@ -11,6 +11,7 @@ #define __XEN_PUBLIC_XEN_H__ FILE_LICENCE ( MIT ); +FILE_SECBOOT ( PERMITTED ); #include "xen-compat.h" diff --git a/src/interface/efi/efi_cacert.c b/src/interface/efi/efi_cacert.c index 64bb0bae2..3e941ddc5 100644 --- a/src/interface/efi/efi_cacert.c +++ b/src/interface/efi/efi_cacert.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/interface/efi/efi_entropy.c b/src/interface/efi/efi_entropy.c index cda1c3640..b6bd12ccc 100644 --- a/src/interface/efi/efi_entropy.c +++ b/src/interface/efi/efi_entropy.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_fbcon.c b/src/interface/efi/efi_fbcon.c index 9c5d7063d..3896fd4d1 100644 --- a/src/interface/efi/efi_fbcon.c +++ b/src/interface/efi/efi_fbcon.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c index 3c249693e..cd8580fcb 100644 --- a/src/interface/efi/efi_fdt.c +++ b/src/interface/efi/efi_fdt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_rng.c b/src/interface/efi/efi_rng.c index 058f0ee7d..66b37fe89 100644 --- a/src/interface/efi/efi_rng.c +++ b/src/interface/efi/efi_rng.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/efi/efi_usb.c b/src/interface/efi/efi_usb.c index b09272f58..a3b153c88 100644 --- a/src/interface/efi/efi_usb.c +++ b/src/interface/efi/efi_usb.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/xen/xenbus.c b/src/interface/xen/xenbus.c index 8b5ee0a0d..95bfdf7da 100644 --- a/src/interface/xen/xenbus.c +++ b/src/interface/xen/xenbus.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/xen/xengrant.c b/src/interface/xen/xengrant.c index 269cd5836..b0a15010b 100644 --- a/src/interface/xen/xengrant.c +++ b/src/interface/xen/xengrant.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/interface/xen/xenstore.c b/src/interface/xen/xenstore.c index caeb4e934..a076cd046 100644 --- a/src/interface/xen/xenstore.c +++ b/src/interface/xen/xenstore.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/pccrc.c b/src/net/pccrc.c index 0db6e3cb5..4bf2f441e 100644 --- a/src/net/pccrc.c +++ b/src/net/pccrc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/pccrd.c b/src/net/pccrd.c index 04b5dd86c..a7182c8ee 100644 --- a/src/net/pccrd.c +++ b/src/net/pccrd.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peerblk.c b/src/net/peerblk.c index 58b185102..6efd4ebf6 100644 --- a/src/net/peerblk.c +++ b/src/net/peerblk.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peerdisc.c b/src/net/peerdisc.c index 86ff94a87..2ba733697 100644 --- a/src/net/peerdisc.c +++ b/src/net/peerdisc.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peerdist.c b/src/net/peerdist.c index 3210ac0ec..8e0f5dc13 100644 --- a/src/net/peerdist.c +++ b/src/net/peerdist.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/peermux.c b/src/net/peermux.c index 5c814b03e..7160d1c43 100644 --- a/src/net/peermux.c +++ b/src/net/peermux.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/ping.c b/src/net/ping.c index f0729e159..5782813e1 100644 --- a/src/net/ping.c +++ b/src/net/ping.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/rndis.c b/src/net/rndis.c index a3b562bc2..f04bc775f 100644 --- a/src/net/rndis.c +++ b/src/net/rndis.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/tcp/httpntlm.c b/src/net/tcp/httpntlm.c index 25187bd19..a7e44d5f6 100644 --- a/src/net/tcp/httpntlm.c +++ b/src/net/tcp/httpntlm.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/https.c b/src/net/tcp/https.c index 85f1f124f..bccfafe15 100644 --- a/src/net/tcp/https.c +++ b/src/net/tcp/https.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/tcp/syslogs.c b/src/net/tcp/syslogs.c index 5676f3e3e..eff53ea94 100644 --- a/src/net/tcp/syslogs.c +++ b/src/net/tcp/syslogs.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/tls.c b/src/net/tls.c index 6140ca58a..4f8ea2692 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); /** * @file diff --git a/src/net/udp/ntp.c b/src/net/udp/ntp.c index 559233575..b3056184d 100644 --- a/src/net/udp/ntp.c +++ b/src/net/udp/ntp.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c index 198c86ef7..07ab3ed0c 100644 --- a/src/net/udp/syslog.c +++ b/src/net/udp/syslog.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** @file * diff --git a/src/net/validator.c b/src/net/validator.c index e1371d2e6..c1f353b2a 100644 --- a/src/net/validator.c +++ b/src/net/validator.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/certmgmt.c b/src/usr/certmgmt.c index e6bf51fd8..9056a917c 100644 --- a/src/usr/certmgmt.c +++ b/src/usr/certmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c index e60854c9f..fa8282da0 100644 --- a/src/usr/imgtrust.c +++ b/src/usr/imgtrust.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/ipstat.c b/src/usr/ipstat.c index b9c5e02a7..c0d9739fa 100644 --- a/src/usr/ipstat.c +++ b/src/usr/ipstat.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/neighmgmt.c b/src/usr/neighmgmt.c index fcdcbbfbb..79f62e6d3 100644 --- a/src/usr/neighmgmt.c +++ b/src/usr/neighmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/nslookup.c b/src/usr/nslookup.c index eb2b08b42..e4386e2c0 100644 --- a/src/usr/nslookup.c +++ b/src/usr/nslookup.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/ntpmgmt.c b/src/usr/ntpmgmt.c index 765c6dc9e..8b61662a0 100644 --- a/src/usr/ntpmgmt.c +++ b/src/usr/ntpmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/pingmgmt.c b/src/usr/pingmgmt.c index bb33c5d47..fee6b438b 100644 --- a/src/usr/pingmgmt.c +++ b/src/usr/pingmgmt.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include diff --git a/src/usr/profstat.c b/src/usr/profstat.c index d80fa26b2..7fafd7b5f 100644 --- a/src/usr/profstat.c +++ b/src/usr/profstat.c @@ -22,6 +22,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include #include -- cgit v1.2.3-55-g7522