From: Catalin Marinas <catalin.marinas@arm.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
x86@kernel.org, Will Deacon <will@kernel.org>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H . Peter Anvin" <hpa@zytor.com>, Borislav Petkov <bp@suse.de>,
Heiko Carstens <hca@linux.ibm.com>,
Johannes Berg <johannes@sipsolutions.net>,
Mark Rutland <mark.rutland@arm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH v3] random: handle archrandom with multiple longs
Date: Tue, 19 Jul 2022 14:48:42 +0100 [thread overview]
Message-ID: <Yta2OuRXHdKhacu4@arm.com> (raw)
In-Reply-To: <20220719130207.147536-1-Jason@zx2c4.com>
On Tue, Jul 19, 2022 at 03:02:07PM +0200, Jason A. Donenfeld wrote:
> The archrandom interface was originally designed for x86, which supplies
> RDRAND/RDSEED for receiving random words into registers, resulting in
> one function to generate an int and another to generate a long. However,
> other architectures don't follow this.
>
> On arm64, the SMCCC TRNG interface can return between 1 and 3 longs. On
> s390, the CPACF TRNG interface can return arbitrary amounts, with 32
> longs having the same cost as one. On UML, the os_getrandom() interface
> can return arbitrary amounts.
>
> So change the api signature to take a "max_longs" parameter designating
> the maximum number of longs requested, and then return the number of
> longs generated.
>
> Since callers need to check this return value and loop anyway, each arch
> implementation does not bother implementing its own loop to try again to
> fill the maximum number of longs. Additionally, all existing callers
> pass in a constant max_longs parameter. Taken together, these two things
> mean that the codegen doesn't really change much for one-word-at-a-time
> platforms, while performance is greatly improved on platforms such as
> s390.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Acked-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
For arm64:
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Heiko Carstens <hca@linux.ibm.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Johannes Berg <johannes@sipsolutions.net>,
Harald Freudenberger <freude@linux.ibm.com>,
"H . Peter Anvin" <hpa@zytor.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Borislav Petkov <bp@suse.de>, Will Deacon <will@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3] random: handle archrandom with multiple longs
Date: Tue, 19 Jul 2022 14:48:42 +0100 [thread overview]
Message-ID: <Yta2OuRXHdKhacu4@arm.com> (raw)
In-Reply-To: <20220719130207.147536-1-Jason@zx2c4.com>
On Tue, Jul 19, 2022 at 03:02:07PM +0200, Jason A. Donenfeld wrote:
> The archrandom interface was originally designed for x86, which supplies
> RDRAND/RDSEED for receiving random words into registers, resulting in
> one function to generate an int and another to generate a long. However,
> other architectures don't follow this.
>
> On arm64, the SMCCC TRNG interface can return between 1 and 3 longs. On
> s390, the CPACF TRNG interface can return arbitrary amounts, with 32
> longs having the same cost as one. On UML, the os_getrandom() interface
> can return arbitrary amounts.
>
> So change the api signature to take a "max_longs" parameter designating
> the maximum number of longs requested, and then return the number of
> longs generated.
>
> Since callers need to check this return value and loop anyway, each arch
> implementation does not bother implementing its own loop to try again to
> fill the maximum number of longs. Additionally, all existing callers
> pass in a constant max_longs parameter. Taken together, these two things
> mean that the codegen doesn't really change much for one-word-at-a-time
> platforms, while performance is greatly improved on platforms such as
> s390.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Acked-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
For arm64:
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
x86@kernel.org, Will Deacon <will@kernel.org>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H . Peter Anvin" <hpa@zytor.com>, Borislav Petkov <bp@suse.de>,
Heiko Carstens <hca@linux.ibm.com>,
Johannes Berg <johannes@sipsolutions.net>,
Mark Rutland <mark.rutland@arm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH v3] random: handle archrandom with multiple longs
Date: Tue, 19 Jul 2022 14:48:42 +0100 [thread overview]
Message-ID: <Yta2OuRXHdKhacu4@arm.com> (raw)
In-Reply-To: <20220719130207.147536-1-Jason@zx2c4.com>
On Tue, Jul 19, 2022 at 03:02:07PM +0200, Jason A. Donenfeld wrote:
> The archrandom interface was originally designed for x86, which supplies
> RDRAND/RDSEED for receiving random words into registers, resulting in
> one function to generate an int and another to generate a long. However,
> other architectures don't follow this.
>
> On arm64, the SMCCC TRNG interface can return between 1 and 3 longs. On
> s390, the CPACF TRNG interface can return arbitrary amounts, with 32
> longs having the same cost as one. On UML, the os_getrandom() interface
> can return arbitrary amounts.
>
> So change the api signature to take a "max_longs" parameter designating
> the maximum number of longs requested, and then return the number of
> longs generated.
>
> Since callers need to check this return value and loop anyway, each arch
> implementation does not bother implementing its own loop to try again to
> fill the maximum number of longs. Additionally, all existing callers
> pass in a constant max_longs parameter. Taken together, these two things
> mean that the codegen doesn't really change much for one-word-at-a-time
> platforms, while performance is greatly improved on platforms such as
> s390.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Acked-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
For arm64:
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-07-19 14:17 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-17 11:24 [PATCH] random: handle archrandom in plural words Jason A. Donenfeld
2022-07-17 11:43 ` Jason A. Donenfeld
2022-07-17 20:03 ` [PATCH v2] " Jason A. Donenfeld
2022-07-17 20:03 ` Jason A. Donenfeld
2022-07-17 20:03 ` Jason A. Donenfeld
2022-07-17 20:03 ` Jason A. Donenfeld
2022-07-18 6:31 ` Michael Ellerman
2022-07-18 6:31 ` Michael Ellerman
2022-07-18 6:31 ` Michael Ellerman
2022-07-18 6:46 ` Gabriel Paubert
2022-07-18 6:46 ` Gabriel Paubert
2022-07-18 6:46 ` Gabriel Paubert
2022-07-20 3:03 ` Michael Ellerman
2022-07-20 3:03 ` Michael Ellerman
2022-07-20 3:03 ` Michael Ellerman
2022-07-19 12:42 ` Mark Rutland
2022-07-19 12:42 ` Mark Rutland
2022-07-19 12:42 ` Mark Rutland
2022-07-19 12:46 ` Jason A. Donenfeld
2022-07-19 12:46 ` Jason A. Donenfeld
2022-07-19 12:46 ` Jason A. Donenfeld
2022-07-19 13:02 ` [PATCH v3] random: handle archrandom with multiple longs Jason A. Donenfeld
2022-07-19 13:02 ` Jason A. Donenfeld
2022-07-19 13:02 ` Jason A. Donenfeld
2022-07-19 13:17 ` Mark Rutland
2022-07-19 13:17 ` Mark Rutland
2022-07-19 13:17 ` Mark Rutland
2022-07-19 13:48 ` Catalin Marinas [this message]
2022-07-19 13:48 ` Catalin Marinas
2022-07-19 13:48 ` Catalin Marinas
2022-07-22 12:06 ` Heiko Carstens
2022-07-22 12:06 ` Heiko Carstens
2022-07-22 12:06 ` Heiko Carstens
2022-07-24 22:47 ` Jason A. Donenfeld
2022-07-25 9:19 ` Borislav Petkov
2022-07-25 9:19 ` Borislav Petkov
2022-07-25 9:19 ` Borislav Petkov
2022-07-25 9:26 ` Jason A. Donenfeld
2022-07-25 9:26 ` Jason A. Donenfeld
2022-07-25 9:26 ` Jason A. Donenfeld
2022-07-25 9:36 ` David Laight
2022-07-25 9:36 ` David Laight
2022-07-25 9:36 ` David Laight
2022-07-25 9:37 ` Jason A. Donenfeld
2022-07-25 9:37 ` Jason A. Donenfeld
2022-07-25 9:37 ` Jason A. Donenfeld
2022-07-25 11:10 ` [PATCH] random: discourage use of archrandom outside of rng Jason A. Donenfeld
2022-07-25 11:25 ` Borislav Petkov
2022-07-25 11:33 ` Heiko Carstens
2022-07-25 13:02 ` Mark Rutland
2022-07-25 11:25 ` [PATCH v3] random: handle archrandom with multiple longs Borislav Petkov
2022-07-25 11:25 ` Borislav Petkov
2022-07-25 11:25 ` Borislav Petkov
2022-08-01 14:46 ` Harald Freudenberger
2022-08-01 14:46 ` Harald Freudenberger
2022-08-01 14:46 ` Harald Freudenberger
2022-08-01 14:50 ` Jason A. Donenfeld
2022-08-01 14:50 ` Jason A. Donenfeld
2022-08-01 14:50 ` Jason A. Donenfeld
2022-07-22 8:08 ` [PATCH v2] random: handle archrandom in plural words Holger Dengler
2022-07-22 8:08 ` Holger Dengler
2022-07-22 8:08 ` Holger Dengler
2022-07-22 11:22 ` Jason A. Donenfeld
2022-07-22 11:22 ` Jason A. Donenfeld
2022-07-22 11:22 ` Jason A. Donenfeld
2022-08-03 12:01 ` Holger Dengler
2022-08-03 12:01 ` Holger Dengler
2022-08-03 12:01 ` Holger Dengler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yta2OuRXHdKhacu4@arm.com \
--to=catalin.marinas@arm.com \
--cc=Jason@zx2c4.com \
--cc=agordeev@linux.ibm.com \
--cc=bp@suse.de \
--cc=freude@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=johannes@sipsolutions.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=mpe@ellerman.id.au \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.