[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200319140416.GK25468@kitsune.suse.cz>
Date: Thu, 19 Mar 2020 15:04:16 +0100
From: Michal Suchánek <msuchanek@...e.de>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT"
<linuxppc-dev@...ts.ozlabs.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Rob Herring <robh@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Christophe Leroy <christophe.leroy@....fr>,
Thomas Gleixner <tglx@...utronix.de>,
Arnd Bergmann <arnd@...db.de>,
Nayna Jain <nayna@...ux.ibm.com>,
Eric Richter <erichte@...ux.ibm.com>,
Claudio Carvalho <cclaudio@...ux.ibm.com>,
Nicholas Piggin <npiggin@...il.com>,
Hari Bathini <hbathini@...ux.ibm.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Thiago Jung Bauermann <bauerman@...ux.ibm.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Valentin Schneider <valentin.schneider@....com>,
Jordan Niethe <jniethe5@...il.com>,
Michael Neuling <mikey@...ling.org>,
Gustavo Luiz Duarte <gustavold@...ux.ibm.com>,
Allison Randal <allison@...utok.net>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"linux-fsdevel @ vger . kernel . org --in-reply-to="
<20200225173541.1549955-1-npiggin@...il.com>
Subject: Re: [PATCH v11 4/8] powerpc/perf: consolidate valid_user_sp
On Thu, Mar 19, 2020 at 03:35:03PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 19, 2020 at 1:54 PM Michal Suchanek <msuchanek@...e.de> wrote:
> >
> > Merge the 32bit and 64bit version.
> >
> > Halve the check constants on 32bit.
> >
> > Use STACK_TOP since it is defined.
> >
> > Passing is_64 is now redundant since is_32bit_task() is used to
> > determine which callchain variant should be used. Use STACK_TOP and
> > is_32bit_task() directly.
> >
> > This removes a page from the valid 32bit area on 64bit:
> > #define TASK_SIZE_USER32 (0x0000000100000000UL - (1 * PAGE_SIZE))
> > #define STACK_TOP_USER32 TASK_SIZE_USER32
>
> ...
>
> > +static inline int valid_user_sp(unsigned long sp)
> > +{
> > + bool is_64 = !is_32bit_task();
> > +
> > + if (!sp || (sp & (is_64 ? 7 : 3)) || sp > STACK_TOP - (is_64 ? 32 : 16))
> > + return 0;
> > + return 1;
> > +}
>
> Perhaps better to read
>
> if (!sp)
> return 0;
>
> if (is_32bit_task()) {
> if (sp & 0x03)
> return 0;
> if (sp > STACK_TOP - 16)
> return 0;
> } else {
> ...
> }
>
> return 1;
>
> Other possibility:
>
> unsigned long align = is_32bit_task() ? 3 : 7;
> unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32);
>
> return !(!sp || (sp & align) || sp > top);
Sounds reasonale.
Thanks
Michal
>
> --
> With Best Regards,
> Andy Shevchenko
Powered by blists - more mailing lists