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: <20230726115427.aigzl2wjgc6ccyt6@viti.kaiser.cx>
Date:   Wed, 26 Jul 2023 13:54:27 +0200
From:   Martin Kaiser <lists@...ser.cx>
To:     Alexey Romanov <AVRomanov@...rdevices.ru>
Cc:     "narmstrong@...libre.com" <narmstrong@...libre.com>,
        "neil.armstrong@...aro.org" <neil.armstrong@...aro.org>,
        "olivia@...enic.com" <olivia@...enic.com>,
        "herbert@...dor.apana.org.au" <herbert@...dor.apana.org.au>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "krzysztof.kozlowski+dt@...aro.org" 
        <krzysztof.kozlowski+dt@...aro.org>,
        "conor+dt@...nel.org" <conor+dt@...nel.org>,
        "khilman@...libre.com" <khilman@...libre.com>,
        "jbrunet@...libre.com" <jbrunet@...libre.com>,
        "martin.blumenstingl@...glemail.com" 
        <martin.blumenstingl@...glemail.com>,
        "f.fainelli@...il.com" <f.fainelli@...il.com>,
        "hkallweit1@...il.com" <hkallweit1@...il.com>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "linux-amlogic@...ts.infradead.org" 
        <linux-amlogic@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        kernel <kernel@...rdevices.ru>
Subject: Re: [PATCH v1 1/3] drivers: rng: add check status bit feature

Hi Alexey,

Alexey Romanov (AVRomanov@...rdevices.ru) wrote:

> > > +static int meson_rng_wait_status(void __iomem *cfg_addr, int bit)
> > > +{
> > > +	u32 status;
> > > +	u32 cnt = 0;
> > > +
> > > +	do {
> > > +		status = readl_relaxed(cfg_addr) & BIT(bit);
> > > +		cpu_relax();
> > > +	} while (status && (cnt++ < RETRY_CNT));
> > > +

> > Could you use readl_relaxed_poll_timeout here instead of open coding the
> > loop?

> At first I also thought about this API. But later I came to the
> conclusion that it is inappropriate here:

> 1. We can't call rng_read from an atomic context.

Agreed. A hwrng read function may sleep (an example for this is
exynos_trng_do_read). But this doesn't prevent us from using
readl_relaxed_poll_timeout.

> 2. RNG for me looks like a very lightweight primitive to me that 
> should work quiclky.

> But, now I looked again at the API and realized that we can use
> readl_relaxed_poll_timeout_atomic() instead of
> readl_relaxed_poll_timeout(). What do you think?

Ok, if you know that your rng hardware won't need much time to set the
bit that you're checking, you may use readl_relaxed_poll_timeout_atomic.

stm32_rtc_set_alarm does something similar.

Best regards,
Martin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ