Patch queue for efi - 2017-07-04

Highlights this time: bugfixes. With these changes, OpenBSD should
 be more happy.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJZWz4rAAoJECszeR4D/txgCR8P/i/LMQP6hsyKiJGhvbbjUYAJ
 FkttUkMJgqmhQgdMPomRsSzkpRMpeM4J8iQZ7uHDV9UhEjlONI2lx1HHZqRa75u5
 ucC/6refSFkNH28XSTBe770Nme5NkNcvdyiKKnn4tC7rHNHCG6MmXElKITE/FQg6
 JRF9jM6KHszR8u4O/ORQ295zIVfyJbdiOoVi1qSYZkCPJvzJxqOFlXpVhVdOhnOr
 Payk0/JNP2hyKKFdhmNnIHOJeUi3W5RSDFqYBzd/8i7tEpenfVu+76T+8RCDTswj
 kGKOfB09t3OZiQYQgseKyd72dEPOgdebaL3lBWIPUmWBE5PAxpP+cL/NMh5owxn4
 81zeGAZenul+CLGvtv/U2sfsjK7EF/bUhJ3n9biE02pXQF3ZZDb8FmSssGCuvMTT
 Sr1hnyobOKkUGrYVUOzhfNbkHiYQJArhZXTqaUQtbjBxdVWRA4Ht1O+a65q3Y3mc
 4tmsBjcRsa1CxCiTadleFFeC4CTfq56osfHLZEoVFQxwi1YDPrSZvOIbzye2B63r
 z+gqcnlCYqX4kHT9IsFHr3jF1q+hjvzvao78xAZMD8gfnKQF90HuDPohi/wFmxay
 nADvBbjqAi+XzeKeAzBMTUo9gzU38kc7czp/UObU+QZzJ3Q9jqCDmn+tvINsmWHX
 WnRUqdUwUIi1eEDGzKvv
 =TXN1
 -----END PGP SIGNATURE-----

Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot

Patch queue for efi - 2017-07-04

Highlights this time: bugfixes. With these changes, OpenBSD should
be more happy.
This commit is contained in:
Tom Rini 2017-07-04 08:00:16 -04:00
commit 7e09145ea2
5 changed files with 44 additions and 14 deletions

View file

@ -264,6 +264,7 @@ F: test/dm/
EFI PAYLOAD EFI PAYLOAD
M: Alexander Graf <agraf@suse.de> M: Alexander Graf <agraf@suse.de>
S: Maintained S: Maintained
T: git git://github.com/agraf/u-boot.git
F: include/efi_loader.h F: include/efi_loader.h
F: lib/efi_loader/ F: lib/efi_loader/
F: cmd/bootefi.c F: cmd/bootefi.c

View file

@ -133,7 +133,13 @@ static void *copy_fdt(void *fdt)
&new_fdt_addr) != EFI_SUCCESS) { &new_fdt_addr) != EFI_SUCCESS) {
/* If we can't put it there, put it somewhere */ /* If we can't put it there, put it somewhere */
new_fdt_addr = (ulong)memalign(4096, fdt_size); new_fdt_addr = (ulong)memalign(4096, fdt_size);
if (efi_allocate_pages(1, EFI_BOOT_SERVICES_DATA, fdt_pages,
&new_fdt_addr) != EFI_SUCCESS) {
printf("ERROR: Failed to reserve space for FDT\n");
return NULL;
}
} }
new_fdt = (void*)(ulong)new_fdt_addr; new_fdt = (void*)(ulong)new_fdt_addr;
memcpy(new_fdt, fdt, fdt_totalsize(fdt)); memcpy(new_fdt, fdt, fdt_totalsize(fdt));
fdt_set_totalsize(new_fdt, fdt_size); fdt_set_totalsize(new_fdt, fdt_size);

View file

@ -28,6 +28,9 @@ enum efi_event_type {
EFI_TIMER_RELATIVE = 2 EFI_TIMER_RELATIVE = 2
}; };
#define EVT_NOTIFY_WAIT 0x00000100
#define EVT_NOTIFY_SIGNAL 0x00000200
/* EFI Boot Services table */ /* EFI Boot Services table */
struct efi_boot_services { struct efi_boot_services {
struct efi_table_hdr hdr; struct efi_table_hdr hdr;

View file

@ -104,9 +104,9 @@ static void EFIAPI efi_restore_tpl(unsigned long old_tpl)
EFI_EXIT(efi_unsupported(__func__)); EFI_EXIT(efi_unsupported(__func__));
} }
efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type, static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type,
unsigned long pages, unsigned long pages,
uint64_t *memory) uint64_t *memory)
{ {
efi_status_t r; efi_status_t r;
@ -115,7 +115,8 @@ efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type,
return EFI_EXIT(r); return EFI_EXIT(r);
} }
efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory, unsigned long pages) static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory,
unsigned long pages)
{ {
efi_status_t r; efi_status_t r;
@ -124,11 +125,12 @@ efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory, unsigned long pages)
return EFI_EXIT(r); return EFI_EXIT(r);
} }
efi_status_t EFIAPI efi_get_memory_map_ext(unsigned long *memory_map_size, static efi_status_t EFIAPI efi_get_memory_map_ext(
struct efi_mem_desc *memory_map, unsigned long *memory_map_size,
unsigned long *map_key, struct efi_mem_desc *memory_map,
unsigned long *descriptor_size, unsigned long *map_key,
uint32_t *descriptor_version) unsigned long *descriptor_size,
uint32_t *descriptor_version)
{ {
efi_status_t r; efi_status_t r;
@ -189,6 +191,16 @@ static efi_status_t EFIAPI efi_create_event(
return EFI_EXIT(EFI_OUT_OF_RESOURCES); return EFI_EXIT(EFI_OUT_OF_RESOURCES);
} }
if (event == NULL)
return EFI_EXIT(EFI_INVALID_PARAMETER);
if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
return EFI_EXIT(EFI_INVALID_PARAMETER);
if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
notify_function == NULL)
return EFI_EXIT(EFI_INVALID_PARAMETER);
efi_event.type = type; efi_event.type = type;
efi_event.notify_tpl = notify_tpl; efi_event.notify_tpl = notify_tpl;
efi_event.notify_function = notify_function; efi_event.notify_function = notify_function;
@ -210,7 +222,9 @@ void efi_timer_check(void)
/* Triggering! */ /* Triggering! */
if (efi_event.trigger_type == EFI_TIMER_PERIODIC) if (efi_event.trigger_type == EFI_TIMER_PERIODIC)
efi_event.trigger_next += efi_event.trigger_time / 10; efi_event.trigger_next += efi_event.trigger_time / 10;
efi_event.notify_function(&efi_event, efi_event.notify_context); if (efi_event.type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL))
efi_event.notify_function(&efi_event,
efi_event.notify_context);
} }
WATCHDOG_RESET(); WATCHDOG_RESET();
@ -738,8 +752,8 @@ static efi_status_t EFIAPI efi_handle_protocol(void *handle,
efi_guid_t *protocol, efi_guid_t *protocol,
void **protocol_interface) void **protocol_interface)
{ {
return efi_open_protocol(handle, protocol, protocol_interface, return efi_open_protocol(handle, protocol, protocol_interface, NULL,
NULL, NULL, 0); NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
} }
static const struct efi_boot_services efi_boot_services = { static const struct efi_boot_services efi_boot_services = {

View file

@ -26,7 +26,7 @@ efi_status_t EFIAPI efi_return_handle(void *handle, efi_guid_t *protocol,
return EFI_SUCCESS; return EFI_SUCCESS;
} }
static void efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel, static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel,
unsigned long rel_size, void *efi_reloc) unsigned long rel_size, void *efi_reloc)
{ {
const IMAGE_BASE_RELOCATION *end; const IMAGE_BASE_RELOCATION *end;
@ -63,11 +63,13 @@ static void efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel,
default: default:
printf("Unknown Relocation off %x type %x\n", printf("Unknown Relocation off %x type %x\n",
offset, type); offset, type);
return EFI_LOAD_ERROR;
} }
relocs++; relocs++;
} }
rel = (const IMAGE_BASE_RELOCATION *)relocs; rel = (const IMAGE_BASE_RELOCATION *)relocs;
} }
return EFI_SUCCESS;
} }
void __weak invalidate_icache_all(void) void __weak invalidate_icache_all(void)
@ -171,7 +173,11 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
} }
/* Run through relocations */ /* Run through relocations */
efi_loader_relocate(rel, rel_size, efi_reloc); if (efi_loader_relocate(rel, rel_size, efi_reloc) != EFI_SUCCESS) {
efi_free_pages((uintptr_t) efi_reloc,
(virt_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT);
return NULL;
}
/* Flush cache */ /* Flush cache */
flush_cache((ulong)efi_reloc, flush_cache((ulong)efi_reloc,