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: <CAMuHMdU8HMSgxAPFUSoCnKDs=y8T9w+5K+sTMUzmi37=ynH5FQ@mail.gmail.com>
Date:   Fri, 8 Sep 2023 08:51:38 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Finn Thain <fthain@...ux-m68k.org>
Cc:     linux-m68k@...ts.linux-m68k.org, Arnd Bergmann <arnd@...db.de>,
        Michael Schmitz <schmitzmic@...il.com>,
        Philip Blundell <philb@....org>,
        Greg Ungerer <gerg@...ux-m68k.org>,
        Joshua Thompson <funaho@...ai.org>,
        Sam Creasey <sammy@...my.net>,
        Laurent Vivier <laurent@...ier.eu>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 25/52] m68k: apollo: Replace set but not used variable by READ_ONCE()

Hi Finn,

On Fri, Sep 8, 2023 at 1:37 AM Finn Thain <fthain@...ux-m68k.org> wrote:
> On Thu, 7 Sep 2023, Geert Uytterhoeven wrote:
> > --- a/arch/m68k/apollo/config.c
> > +++ b/arch/m68k/apollo/config.c
> > @@ -146,13 +146,11 @@ void __init config_apollo(void)
> >
> >  irqreturn_t dn_timer_int(int irq, void *dev_id)
> >  {
> > -     volatile unsigned char x;
> > -
> >       legacy_timer_tick(1);
> >       timer_heartbeat();
> >
> > -     x = *(volatile unsigned char *)(apollo_timer + 3);
> > -     x = *(volatile unsigned char *)(apollo_timer + 5);
> > +     READ_ONCE(*(volatile unsigned char *)(apollo_timer + 3));
> > +     READ_ONCE(*(volatile unsigned char *)(apollo_timer + 5));
> >
> >       return IRQ_HANDLED;
> >  }
> >
>
> I believe the volatile cast is redundant here, as READ_ONCE does that.

Yes it does.  I didn't drop the volatile out of fear of introducing
some higher W-level warning about casting away volatility, but upon
closer look, the apollo_timer definition itself does not use volatile.

> Perhaps the remaining cast could be deduplicated like so:
>
> -       volatile unsigned char x;
> +       unsigned char *at = (unsigned char *)apollo_timer;
>
>         legacy_timer_tick(1);
>         timer_heartbeat();
>
> -       x = *(volatile unsigned char *)(apollo_timer + 3);
> -       x = *(volatile unsigned char *)(apollo_timer + 5);
> +       READ_ONCE(*(at + 3));
> +       READ_ONCE(*(at + 5));

Thanks for the suggestion!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ