[PATCH v2 3/4] ARM: Reduce the number of #ifdef CONFIG_CPU_SW_DOMAIN_PAN

Linus Walleij linus.walleij at linaro.org
Tue Mar 12 01:30:37 PDT 2024


On Tue, Mar 12, 2024 at 9:22 AM Linus Walleij <linus.walleij at linaro.org> wrote:
> On Mon, Mar 11, 2024 at 5:02 PM Russell King (Oracle)
> <linux at armlinux.org.uk> wrote:
> > On Wed, Feb 21, 2024 at 12:04:02AM +0100, Linus Walleij wrote:
> > > @@ -24,9 +24,10 @@
> > >   * perform such accesses (eg, via list poison values) which could then
> > >   * be exploited for priviledge escalation.
> > >   */
> > > +#if defined(CONFIG_CPU_SW_DOMAIN_PAN)
> > > +
> > >  static __always_inline unsigned int uaccess_save_and_enable(void)
> > >  {
> > > -#ifdef CONFIG_CPU_SW_DOMAIN_PAN
> >
> > This is an interesting way to reduce the #ifdef count... why switch it
> > from #ifdef to #if defined ?
>
> Hm that looks like a development artifact from a point where we
> has if defined(A) && defined(B) and then one of them was removed.

Ah no, now I see it. In the next patch a pattern with

#elif defined(CONFIG_CPU_TTBR0_PAN)

is used, so in order to not look confusing the #elif defined() is paired
with #if defined().

I think the C++ preprocessor supports #elifdef but with plain cpp
we are left with this. (At least last time I checked.)

The commit message should be clearer on this though, so I need
to fix that.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list