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: <CAK8P3a0fRy8NhLJAtVpn0bH7sEgXcHJQXEJhzc7ArwTxseqLZw@mail.gmail.com>
Date:   Thu, 21 Jan 2021 12:36:27 +0100
From:   Arnd Bergmann <arnd@...nel.org>
To:     Mohamed Mediouni <mohamed.mediouni@...amail.com>
Cc:     Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Mark Rutland <mark.rutland@....com>,
        Catalin Marinas <catalin.marinas@....com>,
        Hector Martin <marcan@...can.st>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Marc Zyngier <maz@...nel.org>, Will Deacon <will@...nel.org>,
        Stan Skowronek <stan@...ellium.com>
Subject: Re: [RFC PATCH 2/7] arm64: kernel: Add a WFI hook.

On Thu, Jan 21, 2021 at 12:01 PM Mohamed Mediouni
<mohamed.mediouni@...amail.com> wrote:
> > On 21 Jan 2021, at 11:52, Arnd Bergmann <arnd@...nel.org> wrote:
> >
> > On Wed, Jan 20, 2021 at 2:27 PM Mohamed Mediouni
> > <mohamed.mediouni@...amail.com> wrote:
> >> --- a/arch/arm64/kernel/cpu_ops.c
> >> +++ b/arch/arm64/kernel/cpu_ops.c
> >
> >> #if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK)
> >> #include <linux/stackprotector.h>
> >> @@ -74,8 +75,14 @@ void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
> >>
> >> static void noinstr __cpu_do_idle(void)
> >> {
> >> -       dsb(sy);
> >> -       wfi();
> >> +       const struct cpu_operations *ops = get_cpu_ops(task_cpu(current));
> >> +
> >> +       if (ops->cpu_wfi) {
> >> +               ops->cpu_wfi();
> >> +       } else {
> >> +               dsb(sy);
> >> +               wfi();
> >> +       }
> >> }
> >
> > I think the correct place to put this would be a platform specific driver
> > in drivers/cpuidle/ instead of an added low-level callback in the
> > default idle function and a custom cpu_operations structure.
>
> Can we make sure that wfi never gets called even on early
> boot when using a cpuidle driver?

Good question, I don't know what all the possible call sites are
for this, but if there is nothing else works (such as what Alex suggested),
it may be possible to just patch out the wfi instruction here and
do a busy loop until the cpuidle driver has come up.

The main issue here is the existence of the custom cpu_operations
in the first place: I don't think we want or need the custom start_secondary
at the moment (as commented in the other patch), but then there is
no obvious place to put the custom wfi.

Note that there are a few other uses of the wfi instruction besides the
one in __cpu_do_idle(), so whatever you do here may also apply to the
others.

arch/arm64/include/asm/smp.h:           wfi();
arch/arm64/kernel/head.S:       wfi
arch/arm64/kernel/head.S:       wfi
arch/arm64/kernel/head.S:       wfi
arch/arm64/kernel/process.c:    wfi();
arch/arm64/kvm/hyp/nvhe/hyp-init.S:     wfi

       Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ