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  linux-cve-announce  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]
Message-ID: <20200711102702.GC597537@hirez.programming.kicks-ass.net>
Date:   Sat, 11 Jul 2020 12:27:02 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.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, jpoimboe@...hat.com,
        pbonzini@...hat.com, mathieu.desnoyers@...icios.com,
        linux@...musvillemoes.dk
Subject: Re: [PATCH v6 11/17] static_call: Simple self-test

On Fri, Jul 10, 2020 at 06:42:29PM -0400, Steven Rostedt wrote:
> On Fri, 10 Jul 2020 15:38:42 +0200
> Peter Zijlstra <peterz@...radead.org> wrote:

> > +static int __init test_static_call_init(void)
> > +{
> > +	WARN_ON(static_call(sc_selftest)(2) != 3);
> > +	static_call_update(sc_selftest, &func_b);
> > +	WARN_ON(static_call(sc_selftest)(2) != 4);
> > +	static_call_update(sc_selftest, &func_a);
> > +	WARN_ON(static_call(sc_selftest)(2) != 3);
> > +
> > +	return 0;
> > +}
> 
> I wonder if this would be better if we were testing the same static call each time?

Makes sense, I suppose.

> static int __init run_static_call(int val)
> {
> 	return static_call(sc_selftest)(val);
> }

Don't think we need this, or are you afraid of loop unrolling, in which
case you also want a noinline here I suppose.

> 
> static struct {
> 	int (*func)(int);
> 	int val;
> 	int expect;
> } static_call_data [] = {
> 	{ NULL, 2, 3 }
> 	( func_b, 2 , 4},
> 	{ func_a, 2, 3}
> } __initdata;
> 
> static int __init test_static_call_init(void)
> {
> 	int i;
> 
> 	for (i = 0; i < ARRAY_SIZE(static_call_data); i++ ) {
> 		if (static_call_data[i].func)
> 			static_call_update(sc_selftest, static_call_data[i].func);
> 		WARN_ON(run_static_call(static_call_data[i].val) != static_call_data[i].expect);
> 	}
> 
> 	return 0;
> }

Lots of compile errors with that, fixed them all :-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ