diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Kconfig | 4 | ||||
-rw-r--r-- | lib/abuf.c | 21 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 6 | ||||
-rw-r--r-- | lib/efi_loader/efi_conformance.c | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_console.c | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_gop.c | 11 | ||||
-rw-r--r-- | lib/efi_loader/efi_image_loader.c | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_root_node.c | 6 | ||||
-rw-r--r-- | lib/efi_loader/efi_runtime.c | 4 | ||||
-rw-r--r-- | lib/efi_loader/efi_setup.c | 1 | ||||
-rw-r--r-- | lib/efi_loader/efi_var_common.c | 10 | ||||
-rw-r--r-- | lib/efi_loader/efi_variable.c | 25 | ||||
-rw-r--r-- | lib/efi_loader/helloworld.c | 3 | ||||
-rw-r--r-- | lib/efi_loader/initrddump.c | 2 | ||||
-rw-r--r-- | lib/hashtable.c | 2 | ||||
-rw-r--r-- | lib/lmb.c | 17 | ||||
-rw-r--r-- | lib/time.c | 14 | ||||
-rw-r--r-- | lib/trace.c | 93 | ||||
-rw-r--r-- | lib/vsprintf.c | 2 |
19 files changed, 151 insertions, 76 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index 549bd357785..83e5edd73b0 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -368,7 +368,7 @@ config TRACE_EARLY_SIZE config TRACE_EARLY_CALL_DEPTH_LIMIT int "Early trace call depth limit" depends on TRACE_EARLY - default 200 + default 15 help Sets the maximum call depth up to which function calls are recorded during early tracing. @@ -1038,7 +1038,7 @@ config LMB_USE_MAX_REGIONS config LMB_MAX_REGIONS int "Number of memory and reserved regions in lmb lib" depends on LMB && LMB_USE_MAX_REGIONS - default 8 + default 16 help Define the number of supported regions, memory and reserved, in the library logical memory blocks. diff --git a/lib/abuf.c b/lib/abuf.c index 1635d58682c..bd270467dd4 100644 --- a/lib/abuf.c +++ b/lib/abuf.c @@ -6,11 +6,14 @@ * Written by Simon Glass <sjg@chromium.org> */ +#ifndef USE_HOSTCC #include <common.h> -#include <abuf.h> #include <malloc.h> #include <mapmem.h> #include <string.h> +#endif + +#include <abuf.h> void abuf_set(struct abuf *abuf, void *data, size_t size) { @@ -19,10 +22,26 @@ void abuf_set(struct abuf *abuf, void *data, size_t size) abuf->size = size; } +#ifndef USE_HOSTCC void abuf_map_sysmem(struct abuf *abuf, ulong addr, size_t size) { abuf_set(abuf, map_sysmem(addr, size), size); } +#else +/* copied from lib/string.c for convenience */ +static char *memdup(const void *src, size_t len) +{ + char *p; + + p = malloc(len); + if (!p) + return NULL; + + memcpy(p, src, len); + + return p; +} +#endif bool abuf_realloc(struct abuf *abuf, size_t new_size) { diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index ba28989f36a..caaab685ee0 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -264,7 +264,7 @@ static void efi_queue_event(struct efi_event *event) * @tpl: TPL level to check * Return: status code */ -efi_status_t is_valid_tpl(efi_uintn_t tpl) +static efi_status_t is_valid_tpl(efi_uintn_t tpl) { switch (tpl) { case TPL_APPLICATION: @@ -592,7 +592,7 @@ efi_status_t efi_remove_protocol(const efi_handle_t handle, * * Return: status code */ -efi_status_t efi_remove_all_protocols(const efi_handle_t handle) +static efi_status_t efi_remove_all_protocols(const efi_handle_t handle) { struct efi_object *efiobj; struct efi_handler *protocol; @@ -728,6 +728,7 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, /* * efi_create_event_ex() - create an event in a group + * * @type: type of the event to create * @notify_tpl: task priority level of the event * @notify_function: notification function of the event @@ -742,6 +743,7 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, * * Return: status code */ +static efi_status_t EFIAPI efi_create_event_ex(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c index 3036d46349a..0ca26f57a7f 100644 --- a/lib/efi_loader/efi_conformance.c +++ b/lib/efi_loader/efi_conformance.c @@ -22,7 +22,7 @@ static const efi_guid_t efi_ebbr_2_1_guid = */ efi_status_t efi_ecpt_register(void) { - int num_entries = 0; + u16 num_entries = 0; struct efi_conformance_profiles_table *ecpt; efi_status_t ret; size_t ecpt_size; diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 1ed8c7aa36e..43176309077 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -669,7 +669,7 @@ static LIST_HEAD(cin_notify_functions); * @mod: Xterm shift mask * @key_state: receives the state of the shift, alt, control, and logo keys */ -void set_shift_mask(int mod, struct efi_key_state *key_state) +static void set_shift_mask(int mod, struct efi_key_state *key_state) { key_state->key_shift_state = EFI_SHIFT_STATE_VALID; if (mod) { diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index d1dc2f22d0f..778b693f983 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -400,11 +400,12 @@ out: * @delta: length in bytes of a line in the pixel buffer (optional) * Return: status code */ -efi_status_t EFIAPI gop_blt(struct efi_gop *this, struct efi_gop_pixel *buffer, - u32 operation, efi_uintn_t sx, - efi_uintn_t sy, efi_uintn_t dx, - efi_uintn_t dy, efi_uintn_t width, - efi_uintn_t height, efi_uintn_t delta) +static efi_status_t EFIAPI gop_blt(struct efi_gop *this, + struct efi_gop_pixel *buffer, + u32 operation, efi_uintn_t sx, + efi_uintn_t sy, efi_uintn_t dx, + efi_uintn_t dy, efi_uintn_t width, + efi_uintn_t height, efi_uintn_t delta) { efi_status_t ret = EFI_INVALID_PARAMETER; efi_uintn_t vid_bpp; diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index eaf75a5803d..26df0da16c9 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -938,7 +938,7 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, goto err; } -#if CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL) +#if IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL) /* Measure an PE/COFF image */ ret = tcg2_measure_pe_image(efi, efi_size, handle, loaded_image_info); if (ret == EFI_SECURITY_VIOLATION) { diff --git a/lib/efi_loader/efi_root_node.c b/lib/efi_loader/efi_root_node.c index a4eb6f493dc..108c14b95bd 100644 --- a/lib/efi_loader/efi_root_node.c +++ b/lib/efi_loader/efi_root_node.c @@ -58,7 +58,7 @@ efi_status_t efi_root_node_register(void) &efi_guid_device_path_to_text_protocol, &efi_device_path_to_text, #endif -#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_UTIL) +#if IS_ENABLED(CONFIG_EFI_DEVICE_PATH_UTIL) /* Device path utilities protocol */ &efi_guid_device_path_utilities_protocol, &efi_device_path_utilities, @@ -68,11 +68,11 @@ efi_status_t efi_root_node_register(void) &efi_guid_dt_fixup_protocol, &efi_dt_fixup_prot, #endif -#if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2) +#if IS_ENABLED(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) &efi_guid_unicode_collation_protocol2, &efi_unicode_collation_protocol2, #endif -#if CONFIG_IS_ENABLED(EFI_LOADER_HII) +#if IS_ENABLED(CONFIG_EFI_LOADER_HII) /* HII string protocol */ &efi_guid_hii_string_protocol, &efi_hii_string, diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index ad2ab825d19..cee96bfc7fc 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -462,7 +462,7 @@ efi_status_t __weak __efi_runtime EFIAPI efi_set_time(struct efi_time *time) * @scatter_gather_list: pointer to array of physical pointers * Returns: status code */ -efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( +static efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, u64 scatter_gather_list) @@ -484,7 +484,7 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( * @reset_type: type of reset needed for capsule update * Returns: status code */ -efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported( +static efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported( struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, u64 *maximum_capsule_size, diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index f0f01d3b1d5..69aaefab633 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -11,6 +11,7 @@ #include <efi_loader.h> #include <efi_variable.h> #include <log.h> +#include <asm-generic/unaligned.h> #define OBJ_LIST_NOT_INITIALIZED 1 diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index eb837027818..ad50bffd2b2 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -165,17 +165,9 @@ efi_status_t EFIAPI efi_query_variable_info( if (!maximum_variable_storage_size || !remaining_variable_storage_size || - !maximum_variable_size || - !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) + !maximum_variable_size) return EFI_EXIT(EFI_INVALID_PARAMETER); - if ((attributes & ~(u32)EFI_VARIABLE_MASK) || - (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || - (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) || - (!IS_ENABLED(CONFIG_EFI_SECURE_BOOT) && - (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS))) - return EFI_EXIT(EFI_UNSUPPORTED); - ret = efi_query_variable_info_int(attributes, maximum_variable_storage_size, remaining_variable_storage_size, diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 7c32adf6e5b..4c85cfa607e 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -349,6 +349,29 @@ efi_status_t efi_query_variable_info_int(u32 attributes, u64 *remaining_variable_storage_size, u64 *maximum_variable_size) { + if (attributes == 0) + return EFI_INVALID_PARAMETER; + + /* EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated */ + if ((attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || + ((attributes & EFI_VARIABLE_MASK) == 0)) + return EFI_UNSUPPORTED; + + if ((attributes & EFI_VARIABLE_MASK) == EFI_VARIABLE_NON_VOLATILE) + return EFI_INVALID_PARAMETER; + + /* Make sure if runtime bit is set, boot service bit is set also. */ + if ((attributes & + (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == + EFI_VARIABLE_RUNTIME_ACCESS) + return EFI_INVALID_PARAMETER; + + if (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) + return EFI_UNSUPPORTED; + + if (attributes & ~(u32)EFI_VARIABLE_MASK) + return EFI_INVALID_PARAMETER; + *maximum_variable_storage_size = EFI_VAR_BUF_SIZE - sizeof(struct efi_var_file); *remaining_variable_storage_size = efi_var_mem_free(); @@ -372,7 +395,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes, * selected type * Returns: status code */ -efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime( +static efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime( u32 attributes, u64 *maximum_variable_storage_size, u64 *remaining_variable_storage_size, diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c index d565f327457..49fa8cc2f00 100644 --- a/lib/efi_loader/helloworld.c +++ b/lib/efi_loader/helloworld.c @@ -125,7 +125,7 @@ static void print_config_tables(void) * @systable: system table * @con_out: simple text output protocol */ -void print_load_options(struct efi_loaded_image *loaded_image) +static void print_load_options(struct efi_loaded_image *loaded_image) { /* Output the load options */ con_out->output_string(con_out, u"Load options: "); @@ -143,6 +143,7 @@ void print_load_options(struct efi_loaded_image *loaded_image) * @device_path: device path to print * @dp2txt: device path to text protocol */ +static efi_status_t print_device_path(struct efi_device_path *device_path, struct efi_device_path_to_text_protocol *dp2txt) { diff --git a/lib/efi_loader/initrddump.c b/lib/efi_loader/initrddump.c index 98721069816..971a3b6236c 100644 --- a/lib/efi_loader/initrddump.c +++ b/lib/efi_loader/initrddump.c @@ -439,7 +439,7 @@ out: * * Return: load options or NULL */ -u16 *get_load_options(void) +static u16 *get_load_options(void) { efi_status_t ret; struct efi_loaded_image *loaded_image; diff --git a/lib/hashtable.c b/lib/hashtable.c index 90c8465611e..f2d36bd34b4 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -942,7 +942,7 @@ int himport_r(struct hsearch_data *htab, e.data = value; hsearch_r(e, ENV_ENTER, &rv, htab, flag); -#if !CONFIG_IS_ENABLED(ENV_WRITEABLE_LIST) +#if !IS_ENABLED(CONFIG_ENV_WRITEABLE_LIST) if (rv == NULL) { printf("himport_r: can't insert \"%s=%s\" into hash table\n", name, value); diff --git a/lib/lmb.c b/lib/lmb.c index ec790760db6..2444b2a6212 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -175,11 +175,14 @@ static __maybe_unused int efi_lmb_reserve(struct lmb *lmb) return 1; for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) { - if (map->type != EFI_CONVENTIONAL_MEMORY) - lmb_reserve(lmb, - map_to_sysmem((void *)(uintptr_t) - map->physical_start), - map->num_pages * EFI_PAGE_SIZE); + if (map->type != EFI_CONVENTIONAL_MEMORY) { + lmb_reserve_flags(lmb, + map_to_sysmem((void *)(uintptr_t) + map->physical_start), + map->num_pages * EFI_PAGE_SIZE, + map->type == EFI_RESERVED_MEMORY_TYPE + ? LMB_NOMAP : LMB_NONE); + } } efi_free_pool(memmap); @@ -244,8 +247,10 @@ static long lmb_add_region_flags(struct lmb_region *rgn, phys_addr_t base, phys_addr_t rgnbase = rgn->region[i].base; phys_size_t rgnsize = rgn->region[i].size; phys_size_t rgnflags = rgn->region[i].flags; + phys_addr_t end = base + size - 1; + phys_addr_t rgnend = rgnbase + rgnsize - 1; - if (rgnbase == base && rgnsize == size) { + if (rgnbase <= base && end <= rgnend) { if (flags == rgnflags) /* Already have this region, so we're done */ return 0; diff --git a/lib/time.c b/lib/time.c index 5252190af53..00f4a1ac8fb 100644 --- a/lib/time.c +++ b/lib/time.c @@ -70,15 +70,14 @@ extern unsigned long timer_read_counter(void); ulong notrace get_tbclk(void) { if (!gd->timer) { -#ifdef CONFIG_TIMER_EARLY - return timer_early_get_rate(); -#else int ret; + if (IS_ENABLED(CONFIG_TIMER_EARLY)) + return timer_early_get_rate(); + ret = dm_timer_init(); if (ret) return ret; -#endif } return timer_get_rate(gd->timer); @@ -90,15 +89,14 @@ uint64_t notrace get_ticks(void) int ret; if (!gd->timer) { -#ifdef CONFIG_TIMER_EARLY - return timer_early_get_count(); -#else int ret; + if (IS_ENABLED(CONFIG_TIMER_EARLY)) + return timer_early_get_count(); + ret = dm_timer_init(); if (ret) panic("Could not initialize timer (err %d)\n", ret); -#endif } ret = timer_get_count(gd->timer, &count); diff --git a/lib/trace.c b/lib/trace.c index b9dc6d2e4b5..1091a5793a1 100644 --- a/lib/trace.c +++ b/lib/trace.c @@ -35,9 +35,11 @@ struct trace_hdr { ulong ftrace_count; /* Num. of ftrace records written */ ulong ftrace_too_deep_count; /* Functions that were too deep */ - int depth; - int depth_limit; - int max_depth; + int depth; /* Depth of function calls */ + int depth_limit; /* Depth limit to trace to */ + int max_depth; /* Maximum depth seen so far */ + int min_depth; /* Minimum depth seen so far */ + bool trace_locked; /* Used to detect recursive tracing */ }; /* Pointer to start of trace buffer */ @@ -118,18 +120,6 @@ static void notrace add_ftrace(void *func_ptr, void *caller, ulong flags) hdr->ftrace_count++; } -static void notrace add_textbase(void) -{ - if (hdr->ftrace_count < hdr->ftrace_size) { - struct trace_call *rec = &hdr->ftrace[hdr->ftrace_count]; - - rec->func = CONFIG_TEXT_BASE; - rec->caller = 0; - rec->flags = FUNCF_TEXTBASE; - } - hdr->ftrace_count++; -} - /** * __cyg_profile_func_enter() - record function entry * @@ -144,6 +134,14 @@ void notrace __cyg_profile_func_enter(void *func_ptr, void *caller) if (trace_enabled) { int func; + if (hdr->trace_locked) { + trace_enabled = 0; + puts("trace: recursion detected, disabling\n"); + hdr->trace_locked = false; + return; + } + + hdr->trace_locked = true; trace_swap_gd(); add_ftrace(func_ptr, caller, FUNCF_ENTRY); func = func_ptr_to_num(func_ptr); @@ -154,9 +152,10 @@ void notrace __cyg_profile_func_enter(void *func_ptr, void *caller) hdr->untracked_count++; } hdr->depth++; - if (hdr->depth > hdr->depth_limit) + if (hdr->depth > hdr->max_depth) hdr->max_depth = hdr->depth; trace_swap_gd(); + hdr->trace_locked = false; } } @@ -170,8 +169,10 @@ void notrace __cyg_profile_func_exit(void *func_ptr, void *caller) { if (trace_enabled) { trace_swap_gd(); - add_ftrace(func_ptr, caller, FUNCF_EXIT); hdr->depth--; + add_ftrace(func_ptr, caller, FUNCF_EXIT); + if (hdr->depth < hdr->min_depth) + hdr->min_depth = hdr->depth; trace_swap_gd(); } } @@ -278,8 +279,11 @@ int trace_list_calls(void *buff, size_t buff_size, size_t *needed) /* Update the header */ if (output_hdr) { + memset(output_hdr, '\0', sizeof(*output_hdr)); output_hdr->rec_count = upto; output_hdr->type = TRACE_CHUNK_CALLS; + output_hdr->version = TRACE_VERSION; + output_hdr->text_base = CONFIG_TEXT_BASE; } /* Work out how must of the buffer we used */ @@ -318,11 +322,17 @@ void trace_print_stats(void) printf(" (%lu dropped due to overflow)", hdr->ftrace_count - hdr->ftrace_size); } - puts("\n"); - printf("%15d maximum observed call depth\n", hdr->max_depth); + + /* Add in minimum depth since the trace did not start at top level */ + printf("\n%15d maximum observed call depth\n", + hdr->max_depth - hdr->min_depth); printf("%15d call depth limit\n", hdr->depth_limit); print_grouped_ull(hdr->ftrace_too_deep_count, 10); puts(" calls not traced due to depth\n"); + print_grouped_ull(hdr->ftrace_size, 10); + puts(" max function calls\n"); + printf("\ntrace buffer %lx call records %lx\n", + (ulong)map_to_sysmem(hdr), (ulong)map_to_sysmem(hdr->ftrace)); } void notrace trace_set_enabled(int enabled) @@ -330,6 +340,17 @@ void notrace trace_set_enabled(int enabled) trace_enabled = enabled != 0; } +static int get_func_count(void) +{ + /* Detect no support for mon_len since this means tracing cannot work */ + if (IS_ENABLED(CONFIG_SANDBOX) && !gd->mon_len) { + puts("Tracing is not supported on this board\n"); + return -ENOTSUPP; + } + + return gd->mon_len / FUNC_SITE_SIZE; +} + /** * trace_init() - initialize the tracing system and enable it * @@ -339,16 +360,18 @@ void notrace trace_set_enabled(int enabled) */ int notrace trace_init(void *buff, size_t buff_size) { - ulong func_count = gd->mon_len / FUNC_SITE_SIZE; + int func_count = get_func_count(); size_t needed; int was_disabled = !trace_enabled; + if (func_count < 0) + return func_count; trace_save_gd(); if (!was_disabled) { #ifdef CONFIG_TRACE_EARLY + ulong used, count; char *end; - ulong used; /* * Copy over the early trace data if we have it. Disable @@ -357,12 +380,19 @@ int notrace trace_init(void *buff, size_t buff_size) trace_enabled = 0; hdr = map_sysmem(CONFIG_TRACE_EARLY_ADDR, CONFIG_TRACE_EARLY_SIZE); - end = (char *)&hdr->ftrace[min(hdr->ftrace_count, - hdr->ftrace_size)]; + count = min(hdr->ftrace_count, hdr->ftrace_size); + end = (char *)&hdr->ftrace[count]; used = end - (char *)hdr; printf("trace: copying %08lx bytes of early data from %x to %08lx\n", used, CONFIG_TRACE_EARLY_ADDR, (ulong)map_to_sysmem(buff)); + printf("%lu traced function calls", count); + if (hdr->ftrace_count > hdr->ftrace_size) { + printf(" (%lu dropped due to overflow)", + hdr->ftrace_count - hdr->ftrace_size); + hdr->ftrace_count = hdr->ftrace_size; + } + puts("\n"); memcpy(buff, hdr, used); #else puts("trace: already enabled\n"); @@ -372,23 +402,24 @@ int notrace trace_init(void *buff, size_t buff_size) hdr = (struct trace_hdr *)buff; needed = sizeof(*hdr) + func_count * sizeof(uintptr_t); if (needed > buff_size) { - printf("trace: buffer size %zd bytes: at least %zd needed\n", + printf("trace: buffer size %zx bytes: at least %zx needed\n", buff_size, needed); return -ENOSPC; } - if (was_disabled) + if (was_disabled) { memset(hdr, '\0', needed); + hdr->min_depth = INT_MAX; + } hdr->func_count = func_count; hdr->call_accum = (uintptr_t *)(hdr + 1); /* Use any remaining space for the timed function trace */ hdr->ftrace = (struct trace_call *)(buff + needed); hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace); - add_textbase(); + hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT; puts("trace: enabled\n"); - hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT; trace_enabled = 1; trace_inited = 1; @@ -403,10 +434,12 @@ int notrace trace_init(void *buff, size_t buff_size) */ int notrace trace_early_init(void) { - ulong func_count = gd->mon_len / FUNC_SITE_SIZE; + int func_count = get_func_count(); size_t buff_size = CONFIG_TRACE_EARLY_SIZE; size_t needed; + if (func_count < 0) + return func_count; /* We can ignore additional calls to this function */ if (trace_enabled) return 0; @@ -414,7 +447,7 @@ int notrace trace_early_init(void) hdr = map_sysmem(CONFIG_TRACE_EARLY_ADDR, CONFIG_TRACE_EARLY_SIZE); needed = sizeof(*hdr) + func_count * sizeof(uintptr_t); if (needed > buff_size) { - printf("trace: buffer size is %zd bytes, at least %zd needed\n", + printf("trace: buffer size is %zx bytes, at least %zx needed\n", buff_size, needed); return -ENOSPC; } @@ -422,11 +455,11 @@ int notrace trace_early_init(void) memset(hdr, '\0', needed); hdr->call_accum = (uintptr_t *)(hdr + 1); hdr->func_count = func_count; + hdr->min_depth = INT_MAX; /* Use any remaining space for the timed function trace */ hdr->ftrace = (struct trace_call *)((char *)hdr + needed); hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace); - add_textbase(); hdr->depth_limit = CONFIG_TRACE_EARLY_CALL_DEPTH_LIMIT; printf("trace: early enable at %08x\n", CONFIG_TRACE_EARLY_ADDR); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8de3882fb6c..2d13e68b579 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -629,7 +629,7 @@ repeat: case 's': /* U-Boot uses UTF-16 strings in the EFI context only. */ -#if (CONFIG_IS_ENABLED(EFI_LOADER) || CONFIG_IS_ENABLED(EFI_APP)) && \ +#if (CONFIG_IS_ENABLED(EFI_LOADER) || IS_ENABLED(CONFIG_EFI_APP)) && \ !defined(API_BUILD) if (qualifier == 'l') { str = string16(str, end, va_arg(args, u16 *), |