... before making changes to the involved logic. Signed-off-by: Jan Beulich <jbeul...@suse.com> --- While Andrew validly suggests cf_check isn't a requirement for selecting which function(s) to use (with the non-upstream gcc patch that we're using in CI), that's only because of how the non-upstream patch works. Going function-pointer -> unsigned long -> function-pointer without it being diagnosed that the cf_check is missing is a shortcoming there, and might conceivably be fixed at some point. (Imo any address-taking on a function should require it to be cf_check.) Hence I'd like to stick to using cf_check functions only for passing to test_lookup().
With this FAST_SYMBOL_LOOKUP may make sense to permit enabling even when LIVEPATCH=n. Thoughts? (In this case "symbols: centralize and re- arrange $(all_symbols) calculation" would want pulling ahead.) --- a/xen/common/symbols.c +++ b/xen/common/symbols.c @@ -260,6 +260,41 @@ unsigned long symbols_lookup_by_name(con return 0; } +#ifdef CONFIG_SELF_TESTS + +static void __init test_lookup(unsigned long addr, const char *expected) +{ + char buf[KSYM_NAME_LEN + 1]; + const char *name, *symname; + unsigned long size, offs; + + name = symbols_lookup(addr, &size, &offs, buf); + if ( !name ) + panic("%s: address not found\n", expected); + if ( offs ) + panic("%s: non-zero offset (%#lx) unexpected\n", expected, offs); + + /* Cope with static symbols, where varying file names/paths may be used. */ + symname = strchr(name, '#'); + symname = symname ? symname + 1 : name; + if ( strcmp(symname, expected) ) + panic("%s: unexpected symbol name: '%s'\n", expected, symname); + + offs = symbols_lookup_by_name(name); + if ( offs != addr ) + panic("%s: address %#lx unexpected; wanted %#lx\n", + expected, offs, addr); +} + +static void __init __constructor test_symbols(void) +{ + /* Be sure to only try this for cf_check functions. */ + test_lookup((unsigned long)dump_execstate, "dump_execstate"); + test_lookup((unsigned long)test_symbols, __func__); +} + +#endif /* CONFIG_SELF_TESTS */ + /* * Local variables: * mode: C