linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/sgx: Use goto to remove redundant if check in sgx_encl_init
@ 2025-12-10 13:00 Thorsten Blum
  2025-12-10 15:32 ` Jarkko Sakkinen
  0 siblings, 1 reply; 8+ messages in thread
From: Thorsten Blum @ 2025-12-10 13:00 UTC (permalink / raw)
  To: Jarkko Sakkinen, Dave Hansen, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, x86, H. Peter Anvin
  Cc: Thorsten Blum, linux-sgx, linux-kernel

Immediately break out of both loops when 'ret != SGX_UNMASKED_EVENT'
instead of checking for the same condition again in the outer loop.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/x86/kernel/cpu/sgx/ioctl.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index 9322a9287dc7..c1e9841685e8 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -521,15 +521,10 @@ static int sgx_encl_init(struct sgx_encl *encl, struct sgx_sigstruct *sigstruct,
 
 			preempt_enable();
 
-			if (ret == SGX_UNMASKED_EVENT)
-				continue;
-			else
-				break;
+			if (ret != SGX_UNMASKED_EVENT)
+				goto skip_loop;
 		}
 
-		if (ret != SGX_UNMASKED_EVENT)
-			break;
-
 		msleep_interruptible(SGX_EINIT_SLEEP_TIME);
 
 		if (signal_pending(current)) {
@@ -538,6 +533,7 @@ static int sgx_encl_init(struct sgx_encl *encl, struct sgx_sigstruct *sigstruct,
 		}
 	}
 
+skip_loop:
 	if (encls_faulted(ret)) {
 		if (encls_failed(ret))
 			ENCLS_WARN(ret, "EINIT");
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4


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

end of thread, other threads:[~2025-12-13 19:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 13:00 [PATCH] x86/sgx: Use goto to remove redundant if check in sgx_encl_init Thorsten Blum
2025-12-10 15:32 ` Jarkko Sakkinen
2025-12-10 15:48   ` Thorsten Blum
2025-12-11 20:03     ` Jarkko Sakkinen
2025-12-11 20:15       ` Jarkko Sakkinen
2025-12-12 21:05         ` Thorsten Blum
2025-12-13 19:11           ` Jarkko Sakkinen
2025-12-13 19:14             ` Jarkko Sakkinen

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).