From: Thorsten Blum <thorsten.blum@linux.dev>
To: Jarkko Sakkinen <jarkko@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86/sgx: Use goto to remove redundant if check in sgx_encl_init
Date: Wed, 10 Dec 2025 14:00:35 +0100 [thread overview]
Message-ID: <20251210130035.545132-1-thorsten.blum@linux.dev> (raw)
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
next reply other threads:[~2025-12-10 13:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 13:00 Thorsten Blum [this message]
2025-12-10 15:32 ` [PATCH] x86/sgx: Use goto to remove redundant if check in sgx_encl_init 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
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=20251210130035.545132-1-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).