lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 May 2020 17:10:51 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org, rostedt@...dmis.org,
        mhiramat@...nel.org, bristot@...hat.com, jbaron@...mai.com,
        torvalds@...ux-foundation.org, tglx@...utronix.de,
        mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
        ard.biesheuvel@...aro.org, pbonzini@...hat.com,
        mathieu.desnoyers@...icios.com
Subject: Re: [PATCH v4 07/18] static_call: Add inline static call
 infrastructure

On Fri, May 01, 2020 at 10:28:56PM +0200, Peter Zijlstra wrote:
> +#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
> +
> +struct static_call_mod {
> +	struct static_call_mod *next;
> +	struct module *mod; /* for vmlinux, mod == NULL */
> +	struct static_call_site *sites;
> +};
> +
> +struct static_call_key {
> +	void *func;
> +	struct static_call_mod *next;
> +};

"next" implies it links to another key.  How about "mods" or
"site_mods"?

> +++ b/include/linux/static_call_types.h
> @@ -2,14 +2,27 @@
>  #ifndef _STATIC_CALL_TYPES_H
>  #define _STATIC_CALL_TYPES_H
>  
> +#include <linux/types.h>
>  #include <linux/stringify.h>
>  
>  #define STATIC_CALL_PREFIX		__SC__
> +#define STATIC_CALL_PREFIX_STR		__stringify(STATIC_CALL_PREFIX)
> +#define STATIC_CALL_PREFIX_LEN		(sizeof(STATIC_CALL_PREFIX_STR) - 1)

STATIC_CALL_KEY_PREFIX_STR
STATIC_CALL_KEY_PREFIX_LEN

> +void __static_call_update(struct static_call_key *key, void *tramp, void *func)
> +{
> +	struct static_call_site *site, *stop;
> +	struct static_call_mod *site_mod;
> +
> +	cpus_read_lock();
> +	static_call_lock();
> +
> +	if (key->func == func)
> +		goto done;
> +
> +	key->func = func;
> +
> +	arch_static_call_transform(NULL, tramp, func);
> +
> +	/*
> +	 * If uninitialized, we'll not update the callsites, but they still
> +	 * point to the trampoline and we just patched that.
> +	 */
> +	if (WARN_ON_ONCE(!static_call_initialized))
> +		goto done;
> +
> +	for (site_mod = key->next; site_mod; site_mod = site_mod->next) {
> +		if (!site_mod->sites) {
> +			/*
> +			 * This can happen if the static call key is defined in
> +			 * a module which doesn't use it.
> +			 */
> +			continue;
> +		}
> +
> +		stop = __stop_static_call_sites;
> +
> +#ifdef CONFIG_MODULES
> +		if (site_mod->mod) {
> +			stop = site_mod->mod->static_call_sites +
> +			       site_mod->mod->num_static_call_sites;
> +		}
> +#endif

Instead of defining 'mod' in the inner loop below, it can be set at the
top of the outer loop above.  Then the above 'stop' calculation can
be a little less verbose.

-- 
Josh

Powered by blists - more mailing lists