From 852efbf5bd3047b12c1926564d792a7a1cea9eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 23:32:23 +0200 Subject: efi_loader: Update description of internal efi_mem_carve_out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 74c16acce30bb882ad5951829d8dafef8eea564c the return values where changed, but the description was kept. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 80e4e26e05e..ebe8e94c834 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -62,9 +62,17 @@ static void efi_mem_sort(void) * Unmaps all memory occupied by the carve_desc region from the * list entry pointed to by map. * - * Returns 1 if carving was performed or 0 if the regions don't overlap. - * Returns -1 if it would affect non-RAM regions but overlap_only_ram is set. - * Carving is only guaranteed to complete when all regions return 0. + * Returns EFI_CARVE_NO_OVERLAP if the regions don't overlap. + * Returns EFI_CARVE_OVERLAPS_NONRAM if the carve and map overlap, + * and the map contains anything but free ram. + * (only when overlap_only_ram is true) + * Returns EFI_CARVE_LOOP_AGAIN if the mapping list should be traversed + * again, as it has been altered + * Returns the number of overlapping pages. The pages are removed from + * the mapping list. + * + * In case of EFI_CARVE_OVERLAPS_NONRAM it is the callers responsibility + * to readd the already carved out pages to the mapping. */ static int efi_mem_carve_out(struct efi_mem_list *map, struct efi_mem_desc *carve_desc, -- cgit v1.2.3 From bdf5c1b3607bd6384ac5319caad2d8107130ace1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 9 Oct 2016 22:17:07 +0200 Subject: efi_loader: Fix memory map size check to avoid out-of-bounds access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current efi_get_memory_map() function overwrites the map_size property before reading its value. That way the sanity check whether our memory map fits into the given array always succeeds, potentially overwriting arbitrary payload memory. This patch moves the property update write after its sanity check, so that the check actually verifies the correct value. So far this has not triggered any known bugs, but we're better off safe than sorry. If the buffer is to small, the returned memory_map_size indicates the required size to the caller. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index ebe8e94c834..1d237830202 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -336,6 +336,7 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, ulong map_size = 0; int map_entries = 0; struct list_head *lhandle; + unsigned long provided_map_size = *memory_map_size; list_for_each(lhandle, &efi_mem) map_entries++; @@ -350,7 +351,7 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, if (descriptor_version) *descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION; - if (*memory_map_size < map_size) + if (provided_map_size < map_size) return EFI_BUFFER_TOO_SMALL; /* Copy list into array */ -- cgit v1.2.3 From 991d62fa73a35598a8939a83dd84369168220d35 Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Tue, 13 Sep 2016 18:36:53 +0100 Subject: efi_loader: Fix crash on 32-bit systems A type mismatch in the efi_allocate_pool boot service flow causes hazardous memory scribbling on 32-bit systems. This is efi_allocate_pool's prototype: static efi_status_t EFIAPI efi_allocate_pool(int pool_type, unsigned long size, void **buffer); Internally, it invokes efi_allocate_pages as follows: efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, (void*)buffer); This is efi_allocate_pages' prototype: efi_status_t efi_allocate_pages(int type, int memory_type, unsigned long pages, uint64_t *memory); The problem: efi_allocate_pages does this internally: *memory = addr; This fix in efi_allocate_pool uses a transitional uintptr_t cast to ensure the correct outcome, irrespective of the system's native word size. This was observed when bootefi'ing the EFI instance of FreeBSD's first stage bootstrap (boot1.efi) on a 32-bit ARM platform (Qemu VExpress + Cortex-a9). Signed-off-by: Robin Randhawa Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 792db39f516..a11100f4fcd 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -134,9 +134,11 @@ static efi_status_t EFIAPI efi_allocate_pool(int pool_type, unsigned long size, void **buffer) { efi_status_t r; + efi_physical_addr_t t; EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer); - r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, (void*)buffer); + r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, &t); + *buffer = (void *)(uintptr_t)t; return EFI_EXIT(r); } -- cgit v1.2.3 From ead1274b7f9578e346b3cdcb3d9e2002ef8f0e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 9 Oct 2016 22:17:18 +0200 Subject: efi_loader: Move efi_allocate_pool implementation to efi_memory.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We currently handle efi_allocate_pool() in our boot time service file. In the following patch, pool allocation will receive additional internal semantics that we should preserve inside efi_memory.c instead. As foundation for those changes, split the function into an externally facing efi_allocate_pool_ext() for use by payloads and an internal helper efi_allocate_pool() in efi_memory.c that handles the actual allocation. While at it, change the magic 0xfff / 12 constants to the more obvious EFI_PAGE_MASK/SHIFT defines. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 11 +++++------ lib/efi_loader/efi_memory.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index a11100f4fcd..05b93e87bfb 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -130,15 +130,14 @@ efi_status_t EFIAPI efi_get_memory_map_ext(unsigned long *memory_map_size, return EFI_EXIT(r); } -static efi_status_t EFIAPI efi_allocate_pool(int pool_type, unsigned long size, - void **buffer) +static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type, + unsigned long size, + void **buffer) { efi_status_t r; - efi_physical_addr_t t; EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer); - r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, &t); - *buffer = (void *)(uintptr_t)t; + r = efi_allocate_pool(pool_type, size, buffer); return EFI_EXIT(r); } @@ -736,7 +735,7 @@ static const struct efi_boot_services efi_boot_services = { .allocate_pages = efi_allocate_pages_ext, .free_pages = efi_free_pages_ext, .get_memory_map = efi_get_memory_map_ext, - .allocate_pool = efi_allocate_pool, + .allocate_pool = efi_allocate_pool_ext, .free_pool = efi_free_pool, .create_event = efi_create_event, .set_timer = efi_set_timer, diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 1d237830202..be642f12a92 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -327,6 +327,20 @@ efi_status_t efi_free_pages(uint64_t memory, unsigned long pages) return EFI_SUCCESS; } +efi_status_t efi_allocate_pool(int pool_type, unsigned long size, + void **buffer) +{ + efi_status_t r; + efi_physical_addr_t t; + u64 num_pages = (size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + + r = efi_allocate_pages(0, pool_type, num_pages, &t); + if (r == EFI_SUCCESS) + *buffer = (void *)(uintptr_t)t; + + return r; +} + efi_status_t efi_get_memory_map(unsigned long *memory_map_size, struct efi_mem_desc *memory_map, unsigned long *map_key, -- cgit v1.2.3 From 42417bc84d1d56f739d43d562773d4821cf1bf47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 9 Oct 2016 22:17:26 +0200 Subject: efi_loader: Track size of pool allocations to allow freeing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need a functional free_pool implementation, as otherwise each allocate_pool causes growth of the memory descriptor table. Different to free_pages, free_pool does not provide the size for the to be freed allocation, thus we have to track the size ourselves. As the only EFI requirement for pool allocation is an alignment of 8 bytes, we can keep allocating a range using the page allocator, reserve the first 8 bytes for our bookkeeping and hand out the remainder to the caller. This saves us from having to use any independent data structures for tracking. To simplify the conversion between pool allocations and the corresponding page allocation, we create an auxiliary struct efi_pool_allocation. Given the allocation size free_pool size can handoff freeing the page range, which was indirectly allocated by a call to allocate_pool, to free_pages. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 6 +++--- lib/efi_loader/efi_memory.c | 42 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 05b93e87bfb..6c8d93b2613 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -141,12 +141,12 @@ static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type, return EFI_EXIT(r); } -static efi_status_t EFIAPI efi_free_pool(void *buffer) +static efi_status_t EFIAPI efi_free_pool_ext(void *buffer) { efi_status_t r; EFI_ENTRY("%p", buffer); - r = efi_free_pages((ulong)buffer, 0); + r = efi_free_pool(buffer); return EFI_EXIT(r); } @@ -736,7 +736,7 @@ static const struct efi_boot_services efi_boot_services = { .free_pages = efi_free_pages_ext, .get_memory_map = efi_get_memory_map_ext, .allocate_pool = efi_allocate_pool_ext, - .free_pool = efi_free_pool, + .free_pool = efi_free_pool_ext, .create_event = efi_create_event, .set_timer = efi_set_timer, .wait_for_event = efi_wait_for_event, diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index be642f12a92..de28db6e44b 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -33,6 +33,19 @@ LIST_HEAD(efi_mem); void *efi_bounce_buffer; #endif +/* + * U-Boot services each EFI AllocatePool request as a separate + * (multiple) page allocation. We have to track the number of pages + * to be able to free the correct amount later. + * EFI requires 8 byte alignment for pool allocations, so we can + * prepend each allocation with an 64 bit header tracking the + * allocation size, and hand out the remainder to the caller. + */ +struct efi_pool_allocation { + u64 num_pages; + char data[]; +}; + /* * Sorts the memory list from highest address to lowest address * @@ -332,11 +345,34 @@ efi_status_t efi_allocate_pool(int pool_type, unsigned long size, { efi_status_t r; efi_physical_addr_t t; - u64 num_pages = (size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + u64 num_pages = (size + sizeof(u64) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + + if (size == 0) { + *buffer = NULL; + return EFI_SUCCESS; + } r = efi_allocate_pages(0, pool_type, num_pages, &t); - if (r == EFI_SUCCESS) - *buffer = (void *)(uintptr_t)t; + + if (r == EFI_SUCCESS) { + struct efi_pool_allocation *alloc = (void *)(uintptr_t)t; + alloc->num_pages = num_pages; + *buffer = alloc->data; + } + + return r; +} + +efi_status_t efi_free_pool(void *buffer) +{ + efi_status_t r; + struct efi_pool_allocation *alloc; + + alloc = container_of(buffer, struct efi_pool_allocation, data); + /* Sanity check, was the supplied address returned by allocate_pool */ + assert(((uintptr_t)alloc & EFI_PAGE_MASK) == 0); + + r = efi_free_pages((uintptr_t)alloc, alloc->num_pages); return r; } -- cgit v1.2.3 From b61d857b2ff3b0b099ef187d7ceebe26ea788578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 23:32:27 +0200 Subject: efi_loader: Readd freed pages to memory pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently each allocation creates a new mapping. Readding the mapping as free memory (EFI_CONVENTIONAL_MEMORY) potentially allows to hand out an existing mapping, thus limiting the number of mapping descriptors in the memory map. Mitigates a problem with current (4.8rc7) linux kernels when doing an efi_get_memory map, resulting in an infinite loop. Space for the memory map is reserved with allocate_pool (implicitly creating a new mapping) and filled. If there is insufficient slack space (8 entries) in the map, the space is freed and a new round is started, with space for one more entry. As each round increases requirement and allocation by exactly one, there is never enough slack space. (At least 32 entries are allocated, so as long as there are less than 24 entries, there is enough slack). Earlier kernels reserved no slack, and did less allocations, so this problem was not visible. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index de28db6e44b..d3a2ffdac68 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -336,8 +336,15 @@ void *efi_alloc(uint64_t len, int memory_type) efi_status_t efi_free_pages(uint64_t memory, unsigned long pages) { - /* We don't free, let's cross our fingers we have plenty RAM */ - return EFI_SUCCESS; + uint64_t r = 0; + + r = efi_add_memory_map(memory, pages, EFI_CONVENTIONAL_MEMORY, false); + /* Merging of adjacent free regions is missing */ + + if (r == memory) + return EFI_SUCCESS; + + return EFI_NOT_FOUND; } efi_status_t efi_allocate_pool(int pool_type, unsigned long size, -- cgit v1.2.3 From b6a951727504d4159467ac98434849f81aaf9ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 23:32:28 +0200 Subject: efi_loader: Keep memory mapping sorted when splitting an entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code assumes sorted mappings in descending address order. When splitting a mapping, insert the new part next to the current mapping. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index d3a2ffdac68..742bc9084ff 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -135,7 +135,8 @@ static int efi_mem_carve_out(struct efi_mem_list *map, newmap->desc = map->desc; newmap->desc.physical_start = carve_start; newmap->desc.num_pages = (map_end - carve_start) >> EFI_PAGE_SHIFT; - list_add_tail(&newmap->link, &efi_mem); + /* Insert before current entry (descending address order) */ + list_add_tail(&newmap->link, &map->link); /* Shrink the map to [ map_start ... carve_start ] */ map_desc->num_pages = (carve_start - map_start) >> EFI_PAGE_SHIFT; -- cgit v1.2.3 From 511d0b97ef709d13da4922fb694d55ef9a5ef641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 1 Oct 2016 23:32:29 +0200 Subject: efi_loader: Do not leak memory when unlinking a mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As soon as a mapping is unlinked from the list, there are no further references to it, so it should be freed. If it not unlinked, update the start address and length. Signed-off-by: Stefan Brüns Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 742bc9084ff..95aa590c8af 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -116,10 +116,13 @@ static int efi_mem_carve_out(struct efi_mem_list *map, if (map_end == carve_end) { /* Full overlap, just remove map */ list_del(&map->link); + free(map); + } else { + map->desc.physical_start = carve_end; + map->desc.num_pages = (map_end - carve_end) + >> EFI_PAGE_SHIFT; } - map_desc->physical_start = carve_end; - map_desc->num_pages = (map_end - carve_end) >> EFI_PAGE_SHIFT; return (carve_end - carve_start) >> EFI_PAGE_SHIFT; } -- cgit v1.2.3 From 80a4800ee1526a4a46cd02b3ea2fd37eebb77504 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 16 Aug 2016 21:08:45 +0200 Subject: efi_loader: Allow boards to implement get_time and reset_system EFI allows an OS to leverage firmware drivers while the OS is running. In the generic code we so far had to stub those implementations out, because we would need board specific knowledge about MMIO setups for it. However, boards can easily implement those themselves. This patch provides the framework so that a board can implement its own versions of get_time and reset_system which would actually do something useful. While at it we also introduce a simple way for code to reserve MMIO pointers as runtime available. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_runtime.c | 102 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 11 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 99b5ef11c2e..f73e6d97cbc 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -16,6 +16,16 @@ /* For manual relocation support */ DECLARE_GLOBAL_DATA_PTR; +struct efi_runtime_mmio_list { + struct list_head link; + void **ptr; + u64 paddr; + u64 len; +}; + +/* This list contains all runtime available mmio regions */ +LIST_HEAD(efi_runtime_mmio); + static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_unimplemented(void); static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_device_error(void); static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_invalid_parameter(void); @@ -55,9 +65,10 @@ struct elf_rela { * handle a good number of runtime callbacks */ -static void EFIAPI efi_reset_system(enum efi_reset_type reset_type, - efi_status_t reset_status, - unsigned long data_size, void *reset_data) +static void EFIAPI efi_reset_system_boottime( + enum efi_reset_type reset_type, + efi_status_t reset_status, + unsigned long data_size, void *reset_data) { EFI_ENTRY("%d %lx %lx %p", reset_type, reset_status, data_size, reset_data); @@ -72,11 +83,12 @@ static void EFIAPI efi_reset_system(enum efi_reset_type reset_type, break; } - EFI_EXIT(EFI_SUCCESS); + while (1) { } } -static efi_status_t EFIAPI efi_get_time(struct efi_time *time, - struct efi_time_cap *capabilities) +static efi_status_t EFIAPI efi_get_time_boottime( + struct efi_time *time, + struct efi_time_cap *capabilities) { #if defined(CONFIG_CMD_DATE) && defined(CONFIG_DM_RTC) struct rtc_time tm; @@ -107,6 +119,33 @@ static efi_status_t EFIAPI efi_get_time(struct efi_time *time, #endif } +/* Boards may override the helpers below to implement RTS functionality */ + +void __weak EFI_RUNTIME_TEXT EFIAPI efi_reset_system( + enum efi_reset_type reset_type, + efi_status_t reset_status, + unsigned long data_size, void *reset_data) +{ + /* Nothing we can do */ + while (1) { } +} + +void __weak efi_reset_system_init(void) +{ +} + +efi_status_t __weak EFI_RUNTIME_TEXT EFIAPI efi_get_time( + struct efi_time *time, + struct efi_time_cap *capabilities) +{ + /* Nothing we can do */ + return EFI_DEVICE_ERROR; +} + +void __weak efi_get_time_init(void) +{ +} + struct efi_runtime_detach_list_struct { void *ptr; void *patchto; @@ -116,7 +155,7 @@ static const struct efi_runtime_detach_list_struct efi_runtime_detach_list[] = { { /* do_reset is gone */ .ptr = &efi_runtime_services.reset_system, - .patchto = NULL, + .patchto = efi_reset_system, }, { /* invalidate_*cache_all are gone */ .ptr = &efi_runtime_services.set_virtual_address_map, @@ -124,7 +163,7 @@ static const struct efi_runtime_detach_list_struct efi_runtime_detach_list[] = { }, { /* RTC accessors are gone */ .ptr = &efi_runtime_services.get_time, - .patchto = &efi_device_error, + .patchto = &efi_get_time, }, { /* Clean up system table */ .ptr = &systab.con_in, @@ -233,12 +272,39 @@ static efi_status_t EFIAPI efi_set_virtual_address_map( EFI_ENTRY("%lx %lx %x %p", memory_map_size, descriptor_size, descriptor_version, virtmap); + /* Rebind mmio pointers */ + for (i = 0; i < n; i++) { + struct efi_mem_desc *map = (void*)virtmap + + (descriptor_size * i); + struct list_head *lhandle; + efi_physical_addr_t map_start = map->physical_start; + efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT; + efi_physical_addr_t map_end = map_start + map_len; + + /* Adjust all mmio pointers in this region */ + list_for_each(lhandle, &efi_runtime_mmio) { + struct efi_runtime_mmio_list *lmmio; + + lmmio = list_entry(lhandle, + struct efi_runtime_mmio_list, + link); + if ((map_start <= lmmio->paddr) && + (map_end >= lmmio->paddr)) { + u64 off = map->virtual_start - map_start; + uintptr_t new_addr = lmmio->paddr + off; + *lmmio->ptr = (void *)new_addr; + } + } + } + + /* Move the actual runtime code over */ for (i = 0; i < n; i++) { struct efi_mem_desc *map; map = (void*)virtmap + (descriptor_size * i); if (map->type == EFI_RUNTIME_SERVICES_CODE) { - ulong new_offset = map->virtual_start - (runtime_start - gd->relocaddr); + ulong new_offset = map->virtual_start - + (runtime_start - gd->relocaddr); efi_runtime_relocate(new_offset, map); /* Once we're virtual, we can no longer handle @@ -251,6 +317,20 @@ static efi_status_t EFIAPI efi_set_virtual_address_map( return EFI_EXIT(EFI_INVALID_PARAMETER); } +void efi_add_runtime_mmio(void *mmio_ptr, u64 len) +{ + struct efi_runtime_mmio_list *newmmio; + + u64 pages = (len + EFI_PAGE_SIZE - 1) >> EFI_PAGE_SHIFT; + efi_add_memory_map(*(uintptr_t *)mmio_ptr, pages, EFI_MMAP_IO, false); + + newmmio = calloc(1, sizeof(*newmmio)); + newmmio->ptr = mmio_ptr; + newmmio->paddr = *(uintptr_t *)mmio_ptr; + newmmio->len = len; + list_add_tail(&newmmio->link, &efi_runtime_mmio); +} + /* * In the second stage, U-Boot has disappeared. To isolate our runtime code * that at this point still exists from the rest, we put it into a special @@ -292,7 +372,7 @@ struct efi_runtime_services EFI_RUNTIME_DATA efi_runtime_services = { .revision = EFI_RUNTIME_SERVICES_REVISION, .headersize = sizeof(struct efi_table_hdr), }, - .get_time = &efi_get_time, + .get_time = &efi_get_time_boottime, .set_time = (void *)&efi_device_error, .get_wakeup_time = (void *)&efi_unimplemented, .set_wakeup_time = (void *)&efi_unimplemented, @@ -302,5 +382,5 @@ struct efi_runtime_services EFI_RUNTIME_DATA efi_runtime_services = { .get_next_variable = (void *)&efi_device_error, .set_variable = (void *)&efi_device_error, .get_next_high_mono_count = (void *)&efi_device_error, - .reset_system = &efi_reset_system, + .reset_system = &efi_reset_system_boottime, }; -- cgit v1.2.3 From 712cd2987489fe62aedeb24730e730871b1eb627 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 6 Sep 2016 14:26:27 +0200 Subject: efi_loader: Allow bouncing for network So far bounce buffers were only used for disk I/O, but network I/O may suffer from the same problem. On platforms that have problems doing DMA on high addresses, let's also bounce outgoing network packets. Incoming ones always already get bounced. This patch fixes EFI PXE boot on ZynqMP for me. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_net.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index dd3b48570d8..6a8a0d7b1d7 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -152,7 +152,14 @@ static efi_status_t EFIAPI efi_net_transmit(struct efi_simple_network *this, return EFI_EXIT(EFI_INVALID_PARAMETER); } +#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER + /* Ethernet packets always fit, just bounce */ + memcpy(efi_bounce_buffer, buffer, buffer_size); + net_send_packet(efi_bounce_buffer, buffer_size); +#else net_send_packet(buffer, buffer_size); +#endif + new_tx_packet = buffer; return EFI_EXIT(EFI_SUCCESS); -- cgit v1.2.3 From 8f661a5b662af05d4d6da32dc0a3437542f6e866 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 7 Jun 2016 00:57:05 +0200 Subject: efi_loader: gop: Expose fb when 32bpp When we're running in 32bpp mode, expose the frame buffer address to our payloads so that Linux efifb can pick it up. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_gop.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index 33a3d717671..286ad830976 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -129,6 +129,7 @@ int efi_gop_register(void) { struct efi_gop_obj *gopobj; u32 bpix, col, row; + u64 fb_base, fb_size; #ifdef CONFIG_DM_VIDEO struct udevice *vdev; @@ -141,11 +142,16 @@ int efi_gop_register(void) bpix = priv->bpix; col = video_get_xsize(vdev); row = video_get_ysize(vdev); + fb_base = (uintptr_t)priv->fb; + fb_size = priv->fb_size; #else + int line_len; bpix = panel_info.vl_bpix; col = panel_info.vl_col; row = panel_info.vl_row; + fb_base = gd->fb_base; + fb_size = lcd_get_size(&line_len); #endif switch (bpix) { @@ -177,6 +183,16 @@ int efi_gop_register(void) gopobj->mode.info = &gopobj->info; gopobj->mode.info_size = sizeof(gopobj->info); +#ifdef CONFIG_DM_VIDEO + if (bpix == VIDEO_BPP32) { +#else + if (bpix == LCD_COLOR32) { +#endif + /* With 32bit color space we can directly expose the fb */ + gopobj->mode.fb_base = fb_base; + gopobj->mode.fb_size = fb_size; + } + gopobj->info.version = 0; gopobj->info.width = col; gopobj->info.height = row; -- cgit v1.2.3 From 488bf12d842e51b8d596f104bc9bd9aa4d0501b6 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 19 Aug 2016 01:23:24 +0200 Subject: efi_loader: Expose efi_install_configuration_table We want to be able to add configuration table entries from our own code as well as from EFI payload code. Export the boot service function internally too, so that we can reuse it. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 6c8d93b2613..51961d20606 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -37,7 +37,7 @@ static bool efi_is_direct_boot = true; * In most cases we want to pass an FDT to the payload, so reserve one slot of * config table space for it. The pointer gets populated by do_bootefi_exec(). */ -static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[1]; +static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[2]; /* * The "gd" pointer lives in a register on ARM and AArch64 that we declare @@ -376,31 +376,35 @@ static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol, return EFI_EXIT(EFI_NOT_FOUND); } -static efi_status_t EFIAPI efi_install_configuration_table(efi_guid_t *guid, - void *table) +efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table) { int i; - EFI_ENTRY("%p, %p", guid, table); - /* Check for guid override */ for (i = 0; i < systab.nr_tables; i++) { if (!guidcmp(guid, &efi_conf_table[i].guid)) { efi_conf_table[i].table = table; - return EFI_EXIT(EFI_SUCCESS); + return EFI_SUCCESS; } } /* No override, check for overflow */ if (i >= ARRAY_SIZE(efi_conf_table)) - return EFI_EXIT(EFI_OUT_OF_RESOURCES); + return EFI_OUT_OF_RESOURCES; /* Add a new entry */ memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid)); efi_conf_table[i].table = table; systab.nr_tables = i; - return EFI_EXIT(EFI_SUCCESS); + return EFI_SUCCESS; +} + +static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid, + void *table) +{ + EFI_ENTRY("%p, %p", guid, table); + return EFI_EXIT(efi_install_configuration_table(guid, table)); } static efi_status_t EFIAPI efi_load_image(bool boot_policy, @@ -751,7 +755,7 @@ static const struct efi_boot_services efi_boot_services = { .register_protocol_notify = efi_register_protocol_notify, .locate_handle = efi_locate_handle, .locate_device_path = efi_locate_device_path, - .install_configuration_table = efi_install_configuration_table, + .install_configuration_table = efi_install_configuration_table_ext, .load_image = efi_load_image, .start_image = efi_start_image, .exit = efi_exit, -- cgit v1.2.3 From e663b350f1699312281ddd1439dda6b5fc86598d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 19 Aug 2016 01:23:29 +0200 Subject: smbios: Expose in efi_loader as table We can pass SMBIOS easily as EFI configuration table to an EFI payload. This patch adds enablement for that case. While at it, we also enable SMBIOS generation for ARM systems, since they support EFI_LOADER. Signed-off-by: Alexander Graf Reviewed-by: Bin Meng Reviewed-by: Simon Glass --- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_smbios.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 lib/efi_loader/efi_smbios.c (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 2a3849e31b9..12159dd5ce8 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -12,3 +12,4 @@ obj-y += efi_memory.o obj-$(CONFIG_LCD) += efi_gop.o obj-$(CONFIG_PARTITIONS) += efi_disk.o obj-$(CONFIG_NET) += efi_net.o +obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c new file mode 100644 index 00000000000..ac412e7362a --- /dev/null +++ b/lib/efi_loader/efi_smbios.c @@ -0,0 +1,32 @@ +/* + * EFI application tables support + * + * Copyright (c) 2016 Alexander Graf + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include + +static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID; + +void efi_smbios_register(void) +{ + /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */ + uint64_t dmi = 0xffffffff; + /* Reserve 4kb for SMBIOS */ + uint64_t pages = 1; + int memtype = EFI_RUNTIME_SERVICES_DATA; + + if (efi_allocate_pages(1, memtype, pages, &dmi) != EFI_SUCCESS) + return; + + /* Generate SMBIOS tables */ + write_smbios_table(dmi); + + /* And expose them to our EFI payload */ + efi_install_configuration_table(&smbios_guid, (void*)(uintptr_t)dmi); +} -- cgit v1.2.3 From aba5e9194b98988162e5bd026dbcb6627a53efe5 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 19 Aug 2016 01:23:30 +0200 Subject: efi_loader: Fix efi_install_configuration_table So far we were only installing the FDT table and didn't have space to store any other. Hence nobody realized that our efi table allocation was broken in that it didn't set the indicator for the number of tables plus one. This patch fixes it, allowing code to allocate new efi tables. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 51961d20606..17f19274657 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -395,7 +395,7 @@ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table /* Add a new entry */ memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid)); efi_conf_table[i].table = table; - systab.nr_tables = i; + systab.nr_tables = i + 1; return EFI_SUCCESS; } -- cgit v1.2.3 From e275458c2f011a7e66ac01e6558f15f4cf4972f9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 25 Sep 2016 15:27:32 -0600 Subject: efi: Fix missing EFIAPI specifiers These are missing in some functions. Add them to keep things consistent. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Reviewed-by: Alexander Graf Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 5 +++-- lib/efi_loader/efi_disk.c | 13 +++++++------ lib/efi_loader/efi_net.c | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 17f19274657..ac26375072f 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -160,7 +160,7 @@ static struct { u32 trigger_time; u64 trigger_next; unsigned long notify_tpl; - void (*notify_function) (void *event, void *context); + void (EFIAPI *notify_function) (void *event, void *context); void *notify_context; } efi_event = { /* Disable timers on bootup */ @@ -169,7 +169,8 @@ static struct { static efi_status_t EFIAPI efi_create_event( enum efi_event_type type, ulong notify_tpl, - void (*notify_function) (void *event, void *context), + void (EFIAPI *notify_function) (void *event, + void *context), void *notify_context, void **event) { EFI_ENTRY("%d, 0x%lx, %p, %p", type, notify_tpl, notify_function, diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index d8ddcc9b423..1e3dca46ba2 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -35,9 +35,10 @@ struct efi_disk_obj { const struct blk_desc *desc; }; -static efi_status_t efi_disk_open_block(void *handle, efi_guid_t *protocol, - void **protocol_interface, void *agent_handle, - void *controller_handle, uint32_t attributes) +static efi_status_t EFIAPI efi_disk_open_block(void *handle, + efi_guid_t *protocol, void **protocol_interface, + void *agent_handle, void *controller_handle, + uint32_t attributes) { struct efi_disk_obj *diskobj = handle; @@ -46,7 +47,7 @@ static efi_status_t efi_disk_open_block(void *handle, efi_guid_t *protocol, return EFI_SUCCESS; } -static efi_status_t efi_disk_open_dp(void *handle, efi_guid_t *protocol, +static efi_status_t EFIAPI efi_disk_open_dp(void *handle, efi_guid_t *protocol, void **protocol_interface, void *agent_handle, void *controller_handle, uint32_t attributes) { @@ -108,7 +109,7 @@ static efi_status_t EFIAPI efi_disk_rw_blocks(struct efi_block_io *this, return EFI_EXIT(EFI_SUCCESS); } -static efi_status_t efi_disk_read_blocks(struct efi_block_io *this, +static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this, u32 media_id, u64 lba, unsigned long buffer_size, void *buffer) { @@ -143,7 +144,7 @@ static efi_status_t efi_disk_read_blocks(struct efi_block_io *this, return EFI_EXIT(r); } -static efi_status_t efi_disk_write_blocks(struct efi_block_io *this, +static efi_status_t EFIAPI efi_disk_write_blocks(struct efi_block_io *this, u32 media_id, u64 lba, unsigned long buffer_size, void *buffer) { diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 6a8a0d7b1d7..3796496caa1 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -198,7 +198,7 @@ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this, return EFI_EXIT(EFI_SUCCESS); } -static efi_status_t efi_net_open_dp(void *handle, efi_guid_t *protocol, +static efi_status_t EFIAPI efi_net_open_dp(void *handle, efi_guid_t *protocol, void **protocol_interface, void *agent_handle, void *controller_handle, uint32_t attributes) { @@ -210,7 +210,7 @@ static efi_status_t efi_net_open_dp(void *handle, efi_guid_t *protocol, return EFI_SUCCESS; } -static efi_status_t efi_net_open_pxe(void *handle, efi_guid_t *protocol, +static efi_status_t EFIAPI efi_net_open_pxe(void *handle, efi_guid_t *protocol, void **protocol_interface, void *agent_handle, void *controller_handle, uint32_t attributes) { -- cgit v1.2.3 From 65e4c0b168651285adeab66f32f3a14668f3e4bd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 25 Sep 2016 15:27:35 -0600 Subject: x86: efi: Add EFI loader support for x86 Add the required pieces to support the EFI loader on x86. Since U-Boot only builds for 32-bit on x86, only a 32-bit EFI application is supported. If a 64-bit kernel must be booted, U-Boot supports this directly using FIT (see doc/uImage.FIT/kernel.its). U-Boot can act as a payload for both 32-bit and 64-bit EFI. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 9 +++++++++ lib/efi_loader/efi_runtime.c | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index ac26375072f..476ef1b88aa 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -39,6 +39,7 @@ static bool efi_is_direct_boot = true; */ static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[2]; +#ifdef CONFIG_ARM /* * The "gd" pointer lives in a register on ARM and AArch64 that we declare * fixed when compiling U-Boot. However, the payload does not know about that @@ -46,16 +47,20 @@ static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[2]; * EFI callback entry/exit. */ static volatile void *efi_gd, *app_gd; +#endif /* Called from do_bootefi_exec() */ void efi_save_gd(void) { +#ifdef CONFIG_ARM efi_gd = gd; +#endif } /* Called on every callback entry */ void efi_restore_gd(void) { +#ifdef CONFIG_ARM /* Only restore if we're already in EFI context */ if (!efi_gd) return; @@ -63,12 +68,16 @@ void efi_restore_gd(void) if (gd != efi_gd) app_gd = gd; gd = efi_gd; +#endif } /* Called on every callback exit */ efi_status_t efi_exit_func(efi_status_t ret) { +#ifdef CONFIG_ARM gd = app_gd; +#endif + return ret; } diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index f73e6d97cbc..f007ca640a3 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -44,6 +44,10 @@ static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_invalid_parameter(void); #elif defined(CONFIG_ARM) #define R_RELATIVE 23 #define R_MASK 0xffULL +#elif defined(CONFIG_X86) +#include +#define R_RELATIVE R_386_RELATIVE +#define R_MASK 0xffULL #else #error Need to add relocation awareness #endif -- cgit v1.2.3 From 3c63db9ca9765c85bbcf2a06f4183cfb0036ea33 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 14 Oct 2016 13:45:30 +0200 Subject: efi_loader: Rename EFI_RUNTIME_{TEXT, DATA} to __efi_runtime{, _data} Compiler attributes are more commonly __foo style tags rather than big upper case eye sores like EFI_RUNTIME_TEXT. Simon Glass felt quite strongly about this, so this patch converts our existing defines over to more eye friendly ones. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass --- lib/efi_loader/efi_boottime.c | 6 +++--- lib/efi_loader/efi_runtime.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'lib/efi_loader') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 476ef1b88aa..1fdddf4591c 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -37,7 +37,7 @@ static bool efi_is_direct_boot = true; * In most cases we want to pass an FDT to the payload, so reserve one slot of * config table space for it. The pointer gets populated by do_bootefi_exec(). */ -static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[2]; +static struct efi_configuration_table __efi_runtime_data efi_conf_table[2]; #ifdef CONFIG_ARM /* @@ -790,10 +790,10 @@ static const struct efi_boot_services efi_boot_services = { }; -static uint16_t EFI_RUNTIME_DATA firmware_vendor[] = +static uint16_t __efi_runtime_data firmware_vendor[] = { 'D','a','s',' ','U','-','b','o','o','t',0 }; -struct efi_system_table EFI_RUNTIME_DATA systab = { +struct efi_system_table __efi_runtime_data systab = { .hdr = { .signature = EFI_SYSTEM_TABLE_SIGNATURE, .revision = 0x20005, /* 2.5 */ diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index f007ca640a3..dd52755d1d7 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -26,9 +26,9 @@ struct efi_runtime_mmio_list { /* This list contains all runtime available mmio regions */ LIST_HEAD(efi_runtime_mmio); -static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_unimplemented(void); -static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_device_error(void); -static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_invalid_parameter(void); +static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void); +static efi_status_t __efi_runtime EFIAPI efi_device_error(void); +static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); #ifdef CONFIG_SYS_CACHELINE_SIZE #define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE @@ -125,7 +125,7 @@ static efi_status_t EFIAPI efi_get_time_boottime( /* Boards may override the helpers below to implement RTS functionality */ -void __weak EFI_RUNTIME_TEXT EFIAPI efi_reset_system( +void __weak __efi_runtime EFIAPI efi_reset_system( enum efi_reset_type reset_type, efi_status_t reset_status, unsigned long data_size, void *reset_data) @@ -138,7 +138,7 @@ void __weak efi_reset_system_init(void) { } -efi_status_t __weak EFI_RUNTIME_TEXT EFIAPI efi_get_time( +efi_status_t __weak __efi_runtime EFIAPI efi_get_time( struct efi_time *time, struct efi_time_cap *capabilities) { @@ -346,7 +346,7 @@ void efi_add_runtime_mmio(void *mmio_ptr, u64 len) * function or variable below this line. * * Please keep everything fully self-contained and annotated with - * EFI_RUNTIME_TEXT and EFI_RUNTIME_DATA markers. + * __efi_runtime and __efi_runtime_data markers. */ /* @@ -355,22 +355,22 @@ void efi_add_runtime_mmio(void *mmio_ptr, u64 len) * address map calls. */ -static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_unimplemented(void) +static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void) { return EFI_UNSUPPORTED; } -static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_device_error(void) +static efi_status_t __efi_runtime EFIAPI efi_device_error(void) { return EFI_DEVICE_ERROR; } -static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_invalid_parameter(void) +static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void) { return EFI_INVALID_PARAMETER; } -struct efi_runtime_services EFI_RUNTIME_DATA efi_runtime_services = { +struct efi_runtime_services __efi_runtime_data efi_runtime_services = { .hdr = { .signature = EFI_RUNTIME_SERVICES_SIGNATURE, .revision = EFI_RUNTIME_SERVICES_REVISION, -- cgit v1.2.3