linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
@ 2025-06-16  8:56 Uros Bizjak
  2025-06-17 14:44 ` Jarkko Sakkinen
  2025-08-27  6:45 ` [tip: x86/cleanups] " tip-bot2 for Uros Bizjak
  0 siblings, 2 replies; 7+ messages in thread
From: Uros Bizjak @ 2025-06-16  8:56 UTC (permalink / raw)
  To: linux-sgx, x86, linux-kernel
  Cc: Uros Bizjak, Jarkko Sakkinen, Dave Hansen, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin

Current minimum required version of binutils is 2.30,
which supports ENCLS instruction mnemonic.

Replace the byte-wise specification of ENCLS with
this proper mnemonic.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/kernel/cpu/sgx/encls.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h
index 99004b02e2ed..42a088a337c5 100644
--- a/arch/x86/kernel/cpu/sgx/encls.h
+++ b/arch/x86/kernel/cpu/sgx/encls.h
@@ -68,7 +68,7 @@ static inline bool encls_failed(int ret)
 	({							\
 	int ret;						\
 	asm volatile(						\
-	"1: .byte 0x0f, 0x01, 0xcf;\n\t"			\
+	"1: encls\n"						\
 	"2:\n"							\
 	_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX)		\
 	: "=a"(ret)						\
@@ -111,8 +111,8 @@ static inline bool encls_failed(int ret)
 	({							\
 	int ret;						\
 	asm volatile(						\
-	"1: .byte 0x0f, 0x01, 0xcf;\n\t"			\
-	"   xor %%eax,%%eax;\n"					\
+	"1: encls\n\t"						\
+	"xor %%eax,%%eax\n"					\
 	"2:\n"							\
 	_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX)		\
 	: "=a"(ret), "=b"(rbx_out)				\
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
  2025-06-16  8:56 [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h> Uros Bizjak
@ 2025-06-17 14:44 ` Jarkko Sakkinen
  2025-06-17 15:01   ` Dave Hansen
  2025-08-27  6:45 ` [tip: x86/cleanups] " tip-bot2 for Uros Bizjak
  1 sibling, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2025-06-17 14:44 UTC (permalink / raw)
  To: Uros Bizjak
  Cc: linux-sgx, x86, linux-kernel, Dave Hansen, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin

On Mon, Jun 16, 2025 at 10:56:30AM +0200, Uros Bizjak wrote:
> Current minimum required version of binutils is 2.30,
> which supports ENCLS instruction mnemonic.
> 
> Replace the byte-wise specification of ENCLS with
> this proper mnemonic.
> 
> No functional change intended.
> 
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Jarkko Sakkinen <jarkko@kernel.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> ---
>  arch/x86/kernel/cpu/sgx/encls.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h
> index 99004b02e2ed..42a088a337c5 100644
> --- a/arch/x86/kernel/cpu/sgx/encls.h
> +++ b/arch/x86/kernel/cpu/sgx/encls.h
> @@ -68,7 +68,7 @@ static inline bool encls_failed(int ret)
>  	({							\
>  	int ret;						\
>  	asm volatile(						\
> -	"1: .byte 0x0f, 0x01, 0xcf;\n\t"			\
> +	"1: encls\n"						\
>  	"2:\n"							\
>  	_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX)		\
>  	: "=a"(ret)						\
> @@ -111,8 +111,8 @@ static inline bool encls_failed(int ret)
>  	({							\
>  	int ret;						\
>  	asm volatile(						\
> -	"1: .byte 0x0f, 0x01, 0xcf;\n\t"			\
> -	"   xor %%eax,%%eax;\n"					\
> +	"1: encls\n\t"						\
> +	"xor %%eax,%%eax\n"					\
>  	"2:\n"							\
>  	_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX)		\
>  	: "=a"(ret), "=b"(rbx_out)				\
> -- 
> 2.49.0
> 

I don't really see how this is that useful. That said, f a bug fix or
feature used encls mnemonic, I'd had no problems with acking it.

BR, Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
  2025-06-17 14:44 ` Jarkko Sakkinen
@ 2025-06-17 15:01   ` Dave Hansen
  2025-06-17 16:20     ` Uros Bizjak
  2025-06-24 20:47     ` Jarkko Sakkinen
  0 siblings, 2 replies; 7+ messages in thread
From: Dave Hansen @ 2025-06-17 15:01 UTC (permalink / raw)
  To: Jarkko Sakkinen, Uros Bizjak
  Cc: linux-sgx, x86, linux-kernel, Dave Hansen, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin

On 6/17/25 07:44, Jarkko Sakkinen wrote:
> I don't really see how this is that useful. That said, f a bug fix or
> feature used encls mnemonic, I'd had no problems with acking it.

It's not _that_ useful.

But old assemblers that we still want to use *NEVER* have support for
newfanlged instructions, so we always add new instructions with ".byte".
Then, a few years down the road when we've moved to just old assemblers
instead of super old assemblers, we move to the real instruction names.

This is all business as usual.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
  2025-06-17 15:01   ` Dave Hansen
@ 2025-06-17 16:20     ` Uros Bizjak
  2025-06-24 20:49       ` Jarkko Sakkinen
  2025-06-24 20:47     ` Jarkko Sakkinen
  1 sibling, 1 reply; 7+ messages in thread
From: Uros Bizjak @ 2025-06-17 16:20 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Jarkko Sakkinen, linux-sgx, x86, linux-kernel, Dave Hansen,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin

On Tue, Jun 17, 2025 at 5:01 PM Dave Hansen <dave.hansen@intel.com> wrote:
>
> On 6/17/25 07:44, Jarkko Sakkinen wrote:
> > I don't really see how this is that useful. That said, f a bug fix or
> > feature used encls mnemonic, I'd had no problems with acking it.
>
> It's not _that_ useful.
>
> But old assemblers that we still want to use *NEVER* have support for
> newfanlged instructions, so we always add new instructions with ".byte".
> Then, a few years down the road when we've moved to just old assemblers
> instead of super old assemblers, we move to the real instruction names.

That, and the code becomes self-documenting. You don't have to scratch
your head what the .byte stream represents when reading assembly.

Uros.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
  2025-06-17 15:01   ` Dave Hansen
  2025-06-17 16:20     ` Uros Bizjak
@ 2025-06-24 20:47     ` Jarkko Sakkinen
  1 sibling, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2025-06-24 20:47 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Uros Bizjak, linux-sgx, x86, linux-kernel, Dave Hansen,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin

On Tue, Jun 17, 2025 at 08:01:28AM -0700, Dave Hansen wrote:
> On 6/17/25 07:44, Jarkko Sakkinen wrote:
> > I don't really see how this is that useful. That said, f a bug fix or
> > feature used encls mnemonic, I'd had no problems with acking it.
> 
> It's not _that_ useful.
> 
> But old assemblers that we still want to use *NEVER* have support for
> newfanlged instructions, so we always add new instructions with ".byte".
> Then, a few years down the road when we've moved to just old assemblers
> instead of super old assemblers, we move to the real instruction names.
> 
> This is all business as usual.

OK, I'm fine with this reasoning as it is neither by any means distruptive
change either:

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
  2025-06-17 16:20     ` Uros Bizjak
@ 2025-06-24 20:49       ` Jarkko Sakkinen
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2025-06-24 20:49 UTC (permalink / raw)
  To: Uros Bizjak
  Cc: Dave Hansen, linux-sgx, x86, linux-kernel, Dave Hansen,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin

On Tue, Jun 17, 2025 at 06:20:49PM +0200, Uros Bizjak wrote:
> On Tue, Jun 17, 2025 at 5:01 PM Dave Hansen <dave.hansen@intel.com> wrote:
> >
> > On 6/17/25 07:44, Jarkko Sakkinen wrote:
> > > I don't really see how this is that useful. That said, f a bug fix or
> > > feature used encls mnemonic, I'd had no problems with acking it.
> >
> > It's not _that_ useful.
> >
> > But old assemblers that we still want to use *NEVER* have support for
> > newfanlged instructions, so we always add new instructions with ".byte".
> > Then, a few years down the road when we've moved to just old assemblers
> > instead of super old assemblers, we move to the real instruction names.
> 
> That, and the code becomes self-documenting. You don't have to scratch
> your head what the .byte stream represents when reading assembly.

I hear you but I doubt that here looking into the code in detail and
not being aware of ENCLS opcode would be unlikely :-)

That said, I'm cool with applying the patch to tip.

> 
> Uros.

BR, Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip: x86/cleanups] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
  2025-06-16  8:56 [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h> Uros Bizjak
  2025-06-17 14:44 ` Jarkko Sakkinen
@ 2025-08-27  6:45 ` tip-bot2 for Uros Bizjak
  1 sibling, 0 replies; 7+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2025-08-27  6:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Uros Bizjak, Borislav Petkov (AMD), Jarkko Sakkinen, x86,
	linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     13bdfb53aa04eeb8022af87288c5bc0a5d13a834
Gitweb:        https://git.kernel.org/tip/13bdfb53aa04eeb8022af87288c5bc0a5d13a834
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Mon, 16 Jun 2025 10:56:30 +02:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 25 Aug 2025 17:28:43 +02:00

x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>

Current minimum required version of binutils is 2.30, which supports ENCLS
instruction mnemonic.

Replace the byte-wise specification of ENCLS with this proper mnemonic.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/20250616085716.158942-1-ubizjak@gmail.com
---
 arch/x86/kernel/cpu/sgx/encls.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h
index 99004b0..42a088a 100644
--- a/arch/x86/kernel/cpu/sgx/encls.h
+++ b/arch/x86/kernel/cpu/sgx/encls.h
@@ -68,7 +68,7 @@ static inline bool encls_failed(int ret)
 	({							\
 	int ret;						\
 	asm volatile(						\
-	"1: .byte 0x0f, 0x01, 0xcf;\n\t"			\
+	"1: encls\n"						\
 	"2:\n"							\
 	_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX)		\
 	: "=a"(ret)						\
@@ -111,8 +111,8 @@ static inline bool encls_failed(int ret)
 	({							\
 	int ret;						\
 	asm volatile(						\
-	"1: .byte 0x0f, 0x01, 0xcf;\n\t"			\
-	"   xor %%eax,%%eax;\n"					\
+	"1: encls\n\t"						\
+	"xor %%eax,%%eax\n"					\
 	"2:\n"							\
 	_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX)		\
 	: "=a"(ret), "=b"(rbx_out)				\

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-27  6:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16  8:56 [PATCH] x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h> Uros Bizjak
2025-06-17 14:44 ` Jarkko Sakkinen
2025-06-17 15:01   ` Dave Hansen
2025-06-17 16:20     ` Uros Bizjak
2025-06-24 20:49       ` Jarkko Sakkinen
2025-06-24 20:47     ` Jarkko Sakkinen
2025-08-27  6:45 ` [tip: x86/cleanups] " tip-bot2 for Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).