Re: [PATCH v2] random: handle archrandom in plural words

Holger Dengler
2022-08-03T12:03:43Z

Hi Jason,

On 22/07/2022 13:22, Jason A. Donenfeld wrote:
> On Fri, Jul 22, 2022 at 10:08:05AM +0200, Holger Dengler wrote:
>> Why not changing the API to take bytes instead of words? Sure, at the
>> moment it looks like all platforms with TRNG support are able to
>> deliver at least one word, but bytes would be more flexible.
>
> The idea is to strike a sweet spot between capabilities. S390x is fine
> with byte-level granularity up to arbitrary lengths, while x86 is best
> with word-level granularity of length 1. The happy intersection between
> the two is just word-level granularity of arbitrary length. Yes we
> _could_ introduce a lot of code complexity by cascading the x86 case
> down into smaller and smaller registers, ignoring the fact that it's no
> longer efficient below 32- or 64-bit registers depending on vendor. But
> then we're relying on the inliner to remove all of that extra code,
> since all callers actually only ever want 32 or 64 bytes. Why bloat for
> nothing? The beauty of this approach is that it translates very
> naturally over all the various quirks of architectures without having to
> have a lot of coupling code.

You're absolutely right. Your solution addresses all needs of current architectures. My proposal was just meant as preparation for the case, that new (smaller) architectures may come up in the future with a TRNG support, but with other granularity. But anyhow: we can handle it as soon as it happens, fine with me.

--
Mit freundlichen Grüßen / Kind regards
Holger Dengler
--
IBM Systems, Linux on IBM Z Development
dengler@linux.ibm.com