Re: [PATCH v3 0/5] treewide cleanup of random integer usage

2022-10-07 Thread Ulf Hansson
On Thu, 6 Oct 2022 at 18:54, Jason A. Donenfeld wrote: > > Changes v2->v3: > - Handle get_random_int() conversions too, which were overlooked before, > in the same way as the rest. > > Hi folks, > > This is a five part treewide cleanup of random integer handling. The > rules for random integers

RE: [PATCH v3 3/5] treewide: use get_random_u32() when possible

2022-10-07 Thread David Laight
From: Christophe Leroy > Sent: 06 October 2022 18:43 ... > But taking into account that sp must remain 16 bytes aligned, would it > be better to do something like ? > > sp -= prandom_u32_max(PAGE_SIZE >> 4) << 4; That makes me think... If prandom_u32_max() is passed a (constant) power of 2

Re: [PATCH v3 3/5] treewide: use get_random_u32() when possible

2022-10-07 Thread Mika Westerberg
On Thu, Oct 06, 2022 at 10:53:44AM -0600, Jason A. Donenfeld wrote: > drivers/thunderbolt/xdomain.c | 2 +- Acked-by: Mika Westerberg ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/l

Re: [PATCH v3 3/5] treewide: use get_random_u32() when possible

2022-10-07 Thread Jason A. Donenfeld
On Fri, Oct 07, 2022 at 04:57:24AM +, Christophe Leroy wrote: > > > Le 07/10/2022 à 01:36, Jason A. Donenfeld a écrit : > > On 10/6/22, Christophe Leroy wrote: > >> > >> > >> Le 06/10/2022 à 19:31, Christophe Leroy a écrit : > >>> > >>> > >>> Le 06/10/2022 à 19:24, Jason A. Donenfeld a écrit

Re: [PATCH v2 39/44] cpuidle,clk: Remove trace_.*_rcuidle()

2022-10-07 Thread Ulf Hansson
On Mon, 19 Sept 2022 at 12:17, Peter Zijlstra wrote: > > OMAP was the one and only user. OMAP? :-) > > Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/clk/clk.c |8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > --- a/dri

Re: [PATCH v2 07/44] cpuidle,psci: Push RCU-idle into driver

2022-10-07 Thread Kajetan Puchalski
On Mon, Sep 19, 2022 at 11:59:46AM +0200, Peter Zijlstra wrote: > Doing RCU-idle outside the driver, only to then temporarily enable it > again, at least twice, before going idle is daft. > > Signed-off-by: Peter Zijlstra (Intel) Tried it on Pixel 6 running psci_idle, looks good with no apparent

Re: [PATCH v2 12/44] cpuidle,dt: Push RCU-idle into driver

2022-10-07 Thread Ulf Hansson
On Mon, 19 Sept 2022 at 12:18, Peter Zijlstra wrote: > > Doing RCU-idle outside the driver, only to then temporarily enable it > again before going idle is daft. > > Notably: this converts all dt_init_idle_driver() and > __CPU_PM_CPU_IDLE_ENTER() users for they are inextrably intertwined. > > Sign

Re: [PATCH v2 07/44] cpuidle,psci: Push RCU-idle into driver

2022-10-07 Thread Guo Ren
Reviewed-by: Guo Ren On Mon, Sep 19, 2022 at 6:17 PM Peter Zijlstra wrote: > > Doing RCU-idle outside the driver, only to then temporarily enable it > again, at least twice, before going idle is daft. > > Signed-off-by: Peter Zijlstra (Intel) > --- > drivers/cpuidle/cpuidle-psci.c |9 +

Re: [PATCH v2 38/44] cpuidle,powerdomain: Remove trace_.*_rcuidle()

2022-10-07 Thread Ulf Hansson
On Mon, 19 Sept 2022 at 12:17, Peter Zijlstra wrote: > > OMAP was the one and only user. > > Signed-off-by: Peter Zijlstra (Intel) There are changes to the runtime PM core as part of $subject patch. Perhaps move those parts into a separate patch? In any case, the code looks good to me. Reviewed

Re: [PATCH v2 33/44] ftrace: WARN on rcuidle

2022-10-07 Thread Mark Rutland
On Mon, Sep 19, 2022 at 12:00:12PM +0200, Peter Zijlstra wrote: > CONFIG_GENERIC_ENTRY disallows any and all tracing when RCU isn't > enabled. > > XXX if s390 (the only other GENERIC_ENTRY user as of this writing) > isn't comfortable with this, we could switch to > HAVE_NOINSTR_VALIDATION which is

Re: [PATCH v2 00/44] cpuidle,rcu: Clean up the mess

2022-10-07 Thread Ulf Hansson
On Mon, 19 Sept 2022 at 12:18, Peter Zijlstra wrote: > > Hi All! > > At long last, a respin of the cpuidle vs rcu cleanup patches. > > v1: https://lkml.kernel.org/r/20220608142723.103523...@infradead.org > > These here patches clean up the mess that is cpuidle vs rcuidle. > > At the end of the rid

Re: [PATCH v2 23/44] arm,smp: Remove trace_.*_rcuidle() usage

2022-10-07 Thread Ulf Hansson
On Mon, 19 Sept 2022 at 12:18, Peter Zijlstra wrote: > > None of these functions should ever be ran with RCU disabled anymore. > > Specifically, do_handle_IPI() is only called from handle_IPI() which > explicitly does irq_enter()/irq_exit() which ensures RCU is watching. > > The problem with smp_c

Re: [PATCH v2 37/44] arm,omap2: Use WFI for omap2_pm_idle()

2022-10-07 Thread Tony Lindgren
* Peter Zijlstra [220919 10:09]: > arch_cpu_idle() is a very simple idle interface and exposes only a > single idle state and is expected to not require RCU and not do any > tracing/instrumentation. > > As such, omap2_pm_idle() is not a valid implementation. Replace it > with a simple (shallow) o

Re: [PATCH v2 12/44] cpuidle,dt: Push RCU-idle into driver

2022-10-07 Thread Ulf Hansson
On Tue, 4 Oct 2022 at 13:03, Ulf Hansson wrote: > > On Mon, 19 Sept 2022 at 12:18, Peter Zijlstra wrote: > > > > Doing RCU-idle outside the driver, only to then temporarily enable it > > again before going idle is daft. > > > > Notably: this converts all dt_init_idle_driver() and > > __CPU_PM_CPU

Re: [PATCH v2 14/44] cpuidle,cpu_pm: Remove RCU fiddling from cpu_pm_{enter,exit}()

2022-10-07 Thread Ulf Hansson
On Mon, 19 Sept 2022 at 12:17, Peter Zijlstra wrote: > > All callers should still have RCU enabled. > > Signed-off-by: Peter Zijlstra (Intel) > Acked-by: Mark Rutland Reviewed-by: Ulf Hansson Kind regards Uffe > --- > kernel/cpu_pm.c |9 - > 1 file changed, 9 deletions(-) > > --

Re: [PATCH v2 00/44] cpuidle,rcu: Clean up the mess

2022-10-07 Thread Tony Lindgren
Hi, * Peter Zijlstra [220919 10:08]: > Hi All! > > At long last, a respin of the cpuidle vs rcu cleanup patches. > > v1: https://lkml.kernel.org/r/20220608142723.103523...@infradead.org > > These here patches clean up the mess that is cpuidle vs rcuidle. I just gave these a quick test and thi

Re: [PATCH v2 33/44] ftrace: WARN on rcuidle

2022-10-07 Thread Steven Rostedt
Nit, the subject should have "tracing:" an not "ftrace:" as the former encompasses the tracing infrastructure and the latter is for the function hook part of that. On Mon, 19 Sep 2022 12:00:12 +0200 Peter Zijlstra wrote: > CONFIG_GENERIC_ENTRY disallows any and all tracing when RCU isn't > ena

Re: [PATCH v3 3/5] treewide: use get_random_u32() when possible

2022-10-07 Thread Jason A. Donenfeld
On Fri, Oct 07, 2022 at 10:12:42AM -0700, Kees Cook wrote: > On Fri, Oct 07, 2022 at 08:07:58AM -0600, Jason A. Donenfeld wrote: > > On Fri, Oct 07, 2022 at 04:57:24AM +, Christophe Leroy wrote: > > > > > > > > > Le 07/10/2022 à 01:36, Jason A. Donenfeld a écrit : > > > > On 10/6/22, Christop

[PATCH v4 0/6] treewide cleanup of random integer usage

2022-10-07 Thread Jason A. Donenfeld
Changes v3->v4: - Split coccinelle mechanical step from non-mechanical step. - Handle `get_random_int() & ~PAGE_MASK` -> `prandom_u32_max(PAGE_SIZE)`. Hi folks, This is a five part treewide cleanup of random integer handling. The rules for random integers are: - If you want a secure or an insecu

[PATCH v4 1/6] treewide: use prandom_u32_max() when possible, mechanically

2022-10-07 Thread Jason A. Donenfeld
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done mechanically with these coccinelle scripts: @no_modulo@ expression E;

[PATCH v4 2/6] treewide: use prandom_u32_max() when possible

2022-10-07 Thread Jason A. Donenfeld
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. Reviewed-by: Kees Cook Reviewed-by: KP Singh Reviewed-by: Christoph Böhmwalder # for drbd

[PATCH v4 5/6] treewide: use get_random_bytes when possible

2022-10-07 Thread Jason A. Donenfeld
The prandom_bytes() function has been a deprecated inline wrapper around get_random_bytes() for several releases now, and compiles down to the exact same code. Replace the deprecated wrapper with a direct call to the real function. Reviewed-by: Kees Cook Reviewed-by: Christophe Leroy # powerpc S

[PATCH v4 6/6] prandom: remove unused functions

2022-10-07 Thread Jason A. Donenfeld
With no callers left of prandom_u32() and prandom_bytes(), as well as get_random_int(), remove these deprecated wrappers, in favor of get_random_u32() and get_random_bytes(). Reviewed-by: Kees Cook Signed-off-by: Jason A. Donenfeld --- drivers/char/random.c | 11 +-- include/linux/pra

[PATCH v4 3/6] treewide: use get_random_{u8,u16}() when possible

2022-10-07 Thread Jason A. Donenfeld
Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value, simply use the get_random_{u8,u16}() functions, which are faster than wasting the additional bytes from a 32-bit value. Reviewed-by: Kees Cook Acked-by: Toke Høiland-Jørgensen # for sch_cake Signed-off-by: Jason A. Donenfel

[PATCH v4 4/6] treewide: use get_random_u32() when possible

2022-10-07 Thread Jason A. Donenfeld
The prandom_u32() function has been a deprecated inline wrapper around get_random_u32() for several releases now, and compiles down to the exact same code. Replace the deprecated wrapper with a direct call to the real function. The same also applies to get_random_int(), which is just a wrapper arou

Re: [PATCH v4 4/6] treewide: use get_random_u32() when possible

2022-10-07 Thread Rolf Eike Beer
> diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c > index 7c37e09c92da..18c4f0e3e906 100644 > --- a/arch/parisc/kernel/process.c > +++ b/arch/parisc/kernel/process.c > @@ -288,7 +288,7 @@ __get_wchan(struct task_struct *p) > > static inline unsigned long brk_rnd(void) >

Re: [PATCH v4 1/6] treewide: use prandom_u32_max() when possible, mechanically

2022-10-07 Thread Darrick J. Wong
On Fri, Oct 07, 2022 at 12:01:02PM -0600, Jason A. Donenfeld wrote: > Rather than incurring a division or requesting too many random bytes for > the given range, use the prandom_u32_max() function, which only takes > the minimum required bytes from the RNG and avoids divisions. This was > done mech

Re: [PATCH v4 2/6] treewide: use prandom_u32_max() when possible

2022-10-07 Thread Darrick J. Wong
On Fri, Oct 07, 2022 at 12:01:03PM -0600, Jason A. Donenfeld wrote: > Rather than incurring a division or requesting too many random bytes for > the given range, use the prandom_u32_max() function, which only takes > the minimum required bytes from the RNG and avoids divisions. > > Reviewed-by: Ke

Re: [PATCH v4 4/6] treewide: use get_random_u32() when possible

2022-10-07 Thread Darrick J. Wong
On Fri, Oct 07, 2022 at 12:01:05PM -0600, Jason A. Donenfeld wrote: > The prandom_u32() function has been a deprecated inline wrapper around > get_random_u32() for several releases now, and compiles down to the > exact same code. Replace the deprecated wrapper with a direct call to > the real funct

Re: [PATCH v4 2/6] treewide: use prandom_u32_max() when possible

2022-10-07 Thread Jason A. Donenfeld
On Fri, Oct 07, 2022 at 02:17:22PM -0700, Darrick J. Wong wrote: > On Fri, Oct 07, 2022 at 12:01:03PM -0600, Jason A. Donenfeld wrote: > > Rather than incurring a division or requesting too many random bytes for > > the given range, use the prandom_u32_max() function, which only takes > > the minim

Re: [PATCH v4 4/6] treewide: use get_random_u32() when possible

2022-10-07 Thread Jason A. Donenfeld
On Fri, Oct 07, 2022 at 10:34:47PM +0200, Rolf Eike Beer wrote: > > diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c > > index 7c37e09c92da..18c4f0e3e906 100644 > > --- a/arch/parisc/kernel/process.c > > +++ b/arch/parisc/kernel/process.c > > @@ -288,7 +288,7 @@ __get_wchan(

Re: [PATCH v4 2/6] treewide: use prandom_u32_max() when possible

2022-10-07 Thread Jason A. Donenfeld
On Fri, Oct 07, 2022 at 03:47:44PM -0700, Kees Cook wrote: > On Fri, Oct 07, 2022 at 12:01:03PM -0600, Jason A. Donenfeld wrote: > > Rather than incurring a division or requesting too many random bytes for > > the given range, use the prandom_u32_max() function, which only takes > > the minimum req

Re: [PATCH v4 2/6] treewide: use prandom_u32_max() when possible

2022-10-07 Thread Jason A. Donenfeld
On Fri, Oct 07, 2022 at 03:47:44PM -0700, Kees Cook wrote: > > diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c > > index 4f2f2d1bac56..56ffaa8dd3f6 100644 > > --- a/lib/test_vmalloc.c > > +++ b/lib/test_vmalloc.c > > @@ -151,9 +151,7 @@ static int random_size_alloc_test(void) > > int i; >

[PATCH v5 0/7] treewide cleanup of random integer usage

2022-10-07 Thread Jason A. Donenfeld
Changes v4->v5: - Coccinelle is now used for as much mechanical aspects as possible, with mechanical parts split off from non-mechanical parts. This should drastically reduce the amount of code that needs to be reviewed carefully. Each commit mentions now if it was done by hand or is mechan

[PATCH v5 2/7] treewide: use prandom_u32_max() when possible, part 2

2022-10-07 Thread Jason A. Donenfeld
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done by hand, covering things that coccinelle could not do on its own. Reviewed-by:

[PATCH v5 1/7] treewide: use prandom_u32_max() when possible, part 1

2022-10-07 Thread Jason A. Donenfeld
Rather than incurring a division or requesting too many random bytes for the given range, use the prandom_u32_max() function, which only takes the minimum required bytes from the RNG and avoids divisions. This was done mechanically with this coccinelle script: @basic@ expression E; type T; identif

[PATCH v5 3/7] treewide: use get_random_{u8,u16}() when possible, part 1

2022-10-07 Thread Jason A. Donenfeld
Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value, simply use the get_random_{u8,u16}() functions, which are faster than wasting the additional bytes from a 32-bit value. This was done mechanically with this coccinelle script: @@ expression E; identifier get_random_u32 =~ "ge

[PATCH v5 4/7] treewide: use get_random_{u8,u16}() when possible, part 2

2022-10-07 Thread Jason A. Donenfeld
Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value, simply use the get_random_{u8,u16}() functions, which are faster than wasting the additional bytes from a 32-bit value. This was done by hand, identifying all of the places where one of the random integer functions was used in

[PATCH v5 5/7] treewide: use get_random_u32() when possible

2022-10-07 Thread Jason A. Donenfeld
The prandom_u32() function has been a deprecated inline wrapper around get_random_u32() for several releases now, and compiles down to the exact same code. Replace the deprecated wrapper with a direct call to the real function. The same also applies to get_random_int(), which is just a wrapper arou