From nobody Sun Aug 23 23:46:06 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 615A03F2101 for ; Wed, 22 Apr 2026 20:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776888501; cv=none; b=JMpxvhnKZnZw2TykcYZfNLwr8ZH6FCUbcC/yXWpmhVqaCsAKbb+7reCpp0VrtgOhPzKS75HuaIV6ZRf1u5mMCDmPJfs34PsrAjMkoOaAgiTN2AsGlylmkOmBKVGA45a0qlVhZyUEYcDKrtRgykiKrUGFtWc6th6LNWaD6L/Rwcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776888501; c=relaxed/simple; bh=WcNkcyhmAEyLm48OH/jAibAdAw8Tviad++8Rcyw615E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DtHhBSwND7M8Rt+w4lc9/AFeWmuDEnNI/6F4su2otJbNYCSpTK9tkokVGHrYLmBG24riftXzrYzw3EjEhZSI+vCx+BAHlQ4337q8d8SqIUcXm6aTI/Qdx5f2TAaVVsAvhtjfdMPvw5nUSjMoYrGdsKe2/P3aPJBAEhFTx6ChDE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=OKwd6A5x; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="OKwd6A5x" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CG+f99gT7Cze+FGPfBLcF87S5O/36isH7njf38xR63Q=; b=OKwd6A5xLH1bJcdBLDOnv8XZ2i lWl1UWUVu3h86BrLtoFeWCBfpU2bihQEf8FeBcOQ56n6T2kTO/ZzQUVxOh60BnBY8zmH4WsOo9sj2 pj1egl1mFkGBZBpZjIrH6aFWFOXTkaJNPiNANr8YsKfqigBdRd3T9/vUw8gN8237zaR//pMRs3Aaw VocJZgfgNK8hun7DHMiw8Y1CSA9E1pK4stZ9xNZkDaLwX+fuBeO+TdkzZwpK5qP8ojYf4hbMqpRir CmX0EGP6b5coLgijMwibBWxbpOAG/HMpmCvfk0rdAWbiuJqQjaebumMcZrYfQB7G1OFqOqKt1X4HB i0BgXmbA==; Received: from 186-249-145-131.shared.desktop.com.br ([186.249.145.131] helo=[192.168.1.66]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wFdro-000QN6-2I; Wed, 22 Apr 2026 22:08:11 +0200 From: Mauricio Faria de Oliveira Date: Wed, 22 Apr 2026 17:07:45 -0300 Subject: [PATCH 1/3] x86/asm, x86/boot: Expose inline memcmp Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260422-pvh-kasan-inline-v1-1-7e6194344c92@igalia.com> References: <20260422-pvh-kasan-inline-v1-0-7e6194344c92@igalia.com> In-Reply-To: <20260422-pvh-kasan-inline-v1-0-7e6194344c92@igalia.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky Cc: kernel-dev@igalia.com, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Mauricio Faria de Oliveira X-Mailer: b4 0.14.2 Move the inline memcmp function, currently only available to boot code (boot/string.c), into the header with similar inline string functions (include/asm/string.h) so it may be reused. Add a _SETUP guard in string.h so not to include the 32/64-bit specific string headers in boot/ code (16-bit, real mode) and avoid build errors. Signed-off-by: Mauricio Faria de Oliveira --- arch/x86/boot/string.c | 6 ++---- arch/x86/include/asm/string.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index b25c6a9303b7314d5caf5c9306239811705294fe..bbee78637b349e42e9281d8df50= d89d48f4490b9 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "ctype.h" #include "string.h" =20 @@ -31,10 +32,7 @@ =20 int memcmp(const void *s1, const void *s2, size_t len) { - bool diff; - asm("repe cmpsb" - : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len)); - return diff; + return __inline_memcmp(s1, s2, len); } =20 /* diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 9cb5aae7fba9ffcf0f5af8f939d30467750ccaa9..736a6f6a31f0a68281b4f17415a= ba0fcd95dc228 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -2,11 +2,13 @@ #ifndef _ASM_X86_STRING_H #define _ASM_X86_STRING_H =20 +#ifndef _SETUP #ifdef CONFIG_X86_32 # include #else # include #endif +#endif =20 static __always_inline void *__inline_memcpy(void *to, const void *from, s= ize_t len) { @@ -29,4 +31,13 @@ static __always_inline void *__inline_memset(void *s, in= t v, size_t n) return ret; } =20 +static __always_inline int __inline_memcmp(const void *s1, const void *s2,= size_t len) +{ + bool diff; + + asm("repe cmpsb" + : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len)); + return diff; +} + #endif /* _ASM_X86_STRING_H */ --=20 2.51.0