From nobody Tue Dec 2 02:30:42 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 432172D59F7 for ; Wed, 19 Nov 2025 16:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763568273; cv=none; b=Bx0HTP60A/z6ZwJKXa1i6bLucUaW18IDRwqnbC1EUAX8bfVZ+mC2B1FdnlsLwZybxvRmqsyR9V32dM0FyKLo7naIDXrOURRlxWK5RbgKCB/wFrtsNzX1OY0WPU97jQUD9VPaA9G8UHLX54dJl1V9ShpmRTcYbDAZs4ANPsrpm8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763568273; c=relaxed/simple; bh=3b/su8Y6e/SFh4n2bk8gduGGGZn5V7dXw6C8ohPklRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZDVINwCaSunche5J6Pv0IvhyadqEnp/uL6HnAM5s0UUbReanpPWr7bq6KfX9s3YJaGC20yhO3z+K2aoiLM7Twgbx/dH5KWnlNvhEyRl9w0pkFEWnzF0ow9w7GfNC4/R0Hh/XZLXmm3nHQ5SiGPy6Y6+bQ2RUO3xsIuZRAHaHYAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2DF7A21744; Wed, 19 Nov 2025 16:04:28 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CDB053EA61; Wed, 19 Nov 2025 16:04:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 7FiKMIvqHWl6UgAAD6G6ig (envelope-from ); Wed, 19 Nov 2025 16:04:27 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v4 1/3] x86/alternative: Drop not needed test after call of alt_replace_call() Date: Wed, 19 Nov 2025 17:04:18 +0100 Message-ID: <20251119160420.22160-2-jgross@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251119160420.22160-1-jgross@suse.com> References: <20251119160420.22160-1-jgross@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 2DF7A21744 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" alt_replace_call() will never return a negative value, so testing the return value to be less than zero can be dropped. This makes it possible to switch the return type of alt_replace_call() and the type of insn_buff_sz to unsigned int. Signed-off-by: Juergen Gross --- V2: - new patch --- arch/x86/kernel/alternative.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 8ee5ff547357..4f3ea50e41e8 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -559,7 +559,7 @@ EXPORT_SYMBOL(BUG_func); * Rewrite the "call BUG_func" replacement to point to the target of the * indirect pv_ops call "call *disp(%ip)". */ -static int alt_replace_call(u8 *instr, u8 *insn_buff, struct alt_instr *a) +static unsigned int alt_replace_call(u8 *instr, u8 *insn_buff, struct alt_= instr *a) { void *target, *bug =3D &BUG_func; s32 disp; @@ -643,7 +643,7 @@ void __init_or_module noinline apply_alternatives(struc= t alt_instr *start, * order. */ for (a =3D start; a < end; a++) { - int insn_buff_sz =3D 0; + unsigned int insn_buff_sz =3D 0; =20 /* * In case of nested ALTERNATIVE()s the outer alternative might @@ -683,11 +683,8 @@ void __init_or_module noinline apply_alternatives(stru= ct alt_instr *start, memcpy(insn_buff, replacement, a->replacementlen); insn_buff_sz =3D a->replacementlen; =20 - if (a->flags & ALT_FLAG_DIRECT_CALL) { + if (a->flags & ALT_FLAG_DIRECT_CALL) insn_buff_sz =3D alt_replace_call(instr, insn_buff, a); - if (insn_buff_sz < 0) - continue; - } =20 for (; insn_buff_sz < a->instrlen; insn_buff_sz++) insn_buff[insn_buff_sz] =3D 0x90; --=20 2.51.0