From: hpa@zytor.com
To: Uros Bizjak <ubizjak@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] x86: Use RDRAND and RDSEED mnemonics in archrandom.h
Date: Fri, 08 May 2020 09:57:40 -0700 [thread overview]
Message-ID: <BACCC7C6-D456-4FAF-A11B-213995FE356A@zytor.com> (raw)
In-Reply-To: <20200508105817.207887-1-ubizjak@gmail.com>
On May 8, 2020 3:58:17 AM PDT, Uros Bizjak <ubizjak@gmail.com> wrote:
>Current minimum required version of binutils is 2.23,
>which supports RDRAND and RDSEED instruction mnemonics.
>
>Replace the byte-wise specification of RDRAND and
>RDSEED with these proper mnemonics.
>
>Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
>CC: "H. Peter Anvin" <hpa@zytor.com>
>CC: Ingo Molnar <mingo@redhat.com>
>CC: Thomas Gleixner <tglx@linutronix.de>
>---
> arch/x86/include/asm/archrandom.h | 26 ++++++++------------------
> 1 file changed, 8 insertions(+), 18 deletions(-)
>
>diff --git a/arch/x86/include/asm/archrandom.h
>b/arch/x86/include/asm/archrandom.h
>index 7a4bb1bd4bdb..ebc248e49549 100644
>--- a/arch/x86/include/asm/archrandom.h
>+++ b/arch/x86/include/asm/archrandom.h
>@@ -15,16 +15,6 @@
>
> #define RDRAND_RETRY_LOOPS 10
>
>-#define RDRAND_INT ".byte 0x0f,0xc7,0xf0"
>-#define RDSEED_INT ".byte 0x0f,0xc7,0xf8"
>-#ifdef CONFIG_X86_64
>-# define RDRAND_LONG ".byte 0x48,0x0f,0xc7,0xf0"
>-# define RDSEED_LONG ".byte 0x48,0x0f,0xc7,0xf8"
>-#else
>-# define RDRAND_LONG RDRAND_INT
>-# define RDSEED_LONG RDSEED_INT
>-#endif
>-
> /* Unconditional execution of RDRAND and RDSEED */
>
> static inline bool __must_check rdrand_long(unsigned long *v)
>@@ -32,9 +22,9 @@ static inline bool __must_check rdrand_long(unsigned
>long *v)
> bool ok;
> unsigned int retry = RDRAND_RETRY_LOOPS;
> do {
>- asm volatile(RDRAND_LONG
>+ asm volatile("rdrand %[out]"
> CC_SET(c)
>- : CC_OUT(c) (ok), "=a" (*v));
>+ : CC_OUT(c) (ok), [out] "=r" (*v));
> if (ok)
> return true;
> } while (--retry);
>@@ -46,9 +36,9 @@ static inline bool __must_check rdrand_int(unsigned
>int *v)
> bool ok;
> unsigned int retry = RDRAND_RETRY_LOOPS;
> do {
>- asm volatile(RDRAND_INT
>+ asm volatile("rdrand %[out]"
> CC_SET(c)
>- : CC_OUT(c) (ok), "=a" (*v));
>+ : CC_OUT(c) (ok), [out] "=r" (*v));
> if (ok)
> return true;
> } while (--retry);
>@@ -58,18 +48,18 @@ static inline bool __must_check rdrand_int(unsigned
>int *v)
> static inline bool __must_check rdseed_long(unsigned long *v)
> {
> bool ok;
>- asm volatile(RDSEED_LONG
>+ asm volatile("rdseed %[out]"
> CC_SET(c)
>- : CC_OUT(c) (ok), "=a" (*v));
>+ : CC_OUT(c) (ok), [out] "=r" (*v));
> return ok;
> }
>
> static inline bool __must_check rdseed_int(unsigned int *v)
> {
> bool ok;
>- asm volatile(RDSEED_INT
>+ asm volatile("rdseed %[out]"
> CC_SET(c)
>- : CC_OUT(c) (ok), "=a" (*v));
>+ : CC_OUT(c) (ok), [out] "=r" (*v));
> return ok;
> }
>
Reviewed-by: H. Peter Anvin (Intel) <hpa@zytor.com>
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
next prev parent reply other threads:[~2020-05-08 16:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 10:58 Uros Bizjak
2020-05-08 16:57 ` hpa [this message]
2020-05-18 18:06 ` [tip: x86/cpu] x86/cpu: " tip-bot2 for Uros Bizjak
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=BACCC7C6-D456-4FAF-A11B-213995FE356A@zytor.com \
--to=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=ubizjak@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®