From nobody Thu Sep 3 07:03:35 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 3907B361657 for ; Sat, 22 Aug 2026 18:33:12 +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=1787423597; cv=none; b=KYP8qAQCHdLApNyVnNJVbmz9LUjgJaA6Z5U7EQneQve35XXRPgRseN6WBwiwZLvzfWApKIDOKviTVZNU2NStu99SzwT+z7w8Mbw2bLjN3V99rNBFTMh1M8IIbBvPM1fck/E0sPB11crP411cAxF/g/n1l2pQpocCflLXOc9cJdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787423597; c=relaxed/simple; bh=Bpa6wQ+Om3zM4glj2pBixglyuBEGHYawNzswq+Z1DyE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E4kIOFZ/43/OIbpru7rOtoYrpvYmQ/XsFIHuSiOGuhY5sDmJHRCfLOiEsWm5A4vLDbejX+Q7e5U8GFT3ce9De+nfBUtgOY+sS8Q8YmzbYBWeOk7HLkY6qARhHOrQUjnD/CrGMB069ZVhjF64da5qF48r6Xze84INSkE0udYS4EI= 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=cP6yEYns; 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="cP6yEYns" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=n2eXcmcuOEY5+UkfCm5BTRwUz6gPnjMX1HXpAy+v/E8=; b=cP6yEYns8j2dRwJXrWoFYQ5BVR qfq6ToaLjISpVJANbLI3P1DvSluu2WkFJEVIqY4tE2Z7T9SwN1Jdw+eF0y1CxZ7RmG92O2tAcRVkv LjqxzDHDLDiX7wDdGalIqKDBD+LU6DXJEezoQ06jxmkGwWW/1jdUEHTdES/+mh1beEwdMW3c3i8Ds VPHlyVJd8FnmCKFLJaEuusG1OuniSIPpRQmnWuyT9gp9r16spbqif03L9VUxfuKJBW+GaPwopDlHF GXkGqQWsMf8e6DlaWBbu6z1gw/Ypw830A2mbdmFKoQlrvC24qcuV3zeLzYdBYueKWItwzWNzzvZ3n e5tBH3ow==; Received: from 186-249-148-4.shared.desktop.com.br ([186.249.148.4] helo=[127.0.1.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wxqWY-007bWT-8S; Sat, 22 Aug 2026 20:32:58 +0200 From: Mauricio Faria de Oliveira Date: Sat, 22 Aug 2026 15:33:17 -0300 Subject: [PATCH v9 1/5] x86/boot: Remove "cc" clobber from 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: <20260822-pvh-kasan-inline-v9-1-e70ef3b75b6a@igalia.com> References: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> In-Reply-To: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , Jan Beulich , Brian Gerst 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 According to the GCC documentation, conditions in the flags register (e.g., "=3D@ccnz") are output operands [1] and the compiler is aware [2]. Also, clobbers (e.g., "cc") may not overlap with an output operand [2]. Thus, remove the "cc" clobber as it is redudant, and overlaps with, the "=3D@ccnz" output operand. """ 6.11.2.4 Flag Output Operands On some targets, a special form of output operand exists by which conditions in the flags register may be outputs of the asm. [...] 6.11.2.6 Clobbers and Scratch Registers While the compiler is aware of changes to entries listed in the output operands, [...] Clobber descriptions may not in any way overlap with an input or output operand. [...] """ Reported-by: "H. Peter Anvin" Link: https://lore.kernel.org/all/5e19b195-0ca2-4510-81cb-497b40e4aaf5@zyto= r.com/ Fixes: a8c171c107c0 ("x86/boot: Add volatile, clobbers and zero-length test= in memcmp()") Signed-off-by: Mauricio Faria de Oliveira Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Flag-Output-Oper= ands [1] Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers-and-Scr= atch-Registers-1 [2] Reviewed-by: Jan Beulich --- arch/x86/boot/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index 1632d40e1f545ae0665597069b568ea6b6c263e5..03278b4393887cb71cb063818d3= 378c4f52b06f8 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -40,7 +40,7 @@ int memcmp(const void *s1, const void *s2, size_t len) asm volatile("test %3, %3\n\t" "repe cmpsb" : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len) - : : "cc", "memory"); + : : "memory"); return diff; } =20 --=20 2.47.3 From nobody Thu Sep 3 07:03:35 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 357F935F8C9 for ; Sat, 22 Aug 2026 18:33:12 +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=1787423596; cv=none; b=iMBSCci4ko2Oko/NeZXVRg393Yf3Eb5qE839LmjbX8MUSDnIjDeJ3WbUfT8lcFKufwS1DN4mh8xlrrZzFn4QlakXn/CYOCJeX/jvWydf0intYPE3xNIzQoamxtxcdIbJglpha2LjiK2o6GbolnH51vNsG0F1mB7TDeCh1V1I7MM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787423596; c=relaxed/simple; bh=ttEOtfMUlQNZRhLXYSAIaxxQVNy8G6eDqI8W7SsNVoU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lmgY4IjHxynVNwroV3sE5CnNr0qvK/R/DrOsypYVe/ckSCR7ts3m9IA2TcdD3dE90KlTqTRU0gjIHPFCLC1j2/dO3twGyi9nnY7l5ed9lIUr9dgQM6i2bTWzPsnY8yRshSXWJzkg1VwN1GPnZ2uDOS0YdYzoSWiY6PWo1jQqtKQ= 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=o1Z+vuNG; 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="o1Z+vuNG" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=MfLC1dIVusQxZmyyohtK3IB4hBpAg/kOqSLp9mxwz1M=; b=o1Z+vuNGqvlMK/ozeR0ZPZbzr1 gAQJqvr5CTnKAOkG9FSljuSrO7FBTDKKyyxvLqRc0XQYtRff6BhHSr6b2JpR8m8aqc3MYeM8fhc7u C5rwoS4DgpDkFS2xMIqzIMu4VHDgWluOs6s236Wx+O6j7O0z0FoMWlIt5GbxY6MwBRs5xNFuKz7ut GOU0x8Sho2S8rnKR2SZzqU1YpjnhxkZSMunIiVO9M2TZzt25+FiG0ysrCy8nBQihnZLZD8RUWVwUu 0iig+O6Dt7z1KJcrkzHM27AKSg+JjS/hcQZek133GV2/n+ZY6sEroD+a4QyRaV8CJZa8AIfcZn9/A 7oo4Zviw==; Received: from 186-249-148-4.shared.desktop.com.br ([186.249.148.4] helo=[127.0.1.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wxqWc-007bWT-5S; Sat, 22 Aug 2026 20:33:02 +0200 From: Mauricio Faria de Oliveira Date: Sat, 22 Aug 2026 15:33:18 -0300 Subject: [PATCH v9 2/5] 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: <20260822-pvh-kasan-inline-v9-2-e70ef3b75b6a@igalia.com> References: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> In-Reply-To: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , Jan Beulich , Brian Gerst 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 in 'boot/string.c' into the shared string function header to be reused. This is not done through to avoid pulling unnecessary code in 'boot/string.c' that causes build errors in 'boot/compressed/string.c' and 'purgatory/purgatory.ro'. No functional changes. Signed-off-by: Mauricio Faria de Oliveira --- Thanks to David Laight for noticing the return value difference between inline and regular memcmp(). --- arch/x86/boot/string.c | 13 ++----------- arch/x86/include/asm/shared/string.h | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index 03278b4393887cb71cb063818d3378c4f52b06f8..be454a6864225f3a972c3e81826= b77ed4e8a57fe 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,17 +32,7 @@ =20 int memcmp(const void *s1, const void *s2, size_t len) { - bool diff; - - /* - * Make sure ZF is properly set in the len=3D=3D0 case because in it, - * RCX=3D=3D0 and the REPE; CMPSB won't get executed. - */ - asm volatile("test %3, %3\n\t" - "repe cmpsb" - : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len) - : : "memory"); - return diff; + return __inline_memcmp(s1, s2, len); } =20 /* diff --git a/arch/x86/include/asm/shared/string.h b/arch/x86/include/asm/sh= ared/string.h new file mode 100644 index 0000000000000000000000000000000000000000..06c1d5e5013e4d59cfb49866d10= e164362d2c4cc --- /dev/null +++ b/arch/x86/include/asm/shared/string.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SHARED_STRING_H +#define _ASM_X86_SHARED_STRING_H + +/* + * This inline memcmp() returns 0 (equal) or 1 (not equal). + * The regular memcmp() returns <0 (less than), 0 (equal), or >0 (greater = than) + * to indicate ordering as well. + */ +static __always_inline int __inline_memcmp(const void *s1, const void *s2,= size_t len) +{ + bool diff; + + /* + * Make sure ZF is properly set in the len=3D=3D0 case because in it, + * RCX=3D=3D0 and the REPE; CMPSB won't get executed. + */ + asm volatile("test %3, %3\n\t" + "repe cmpsb" + : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len) + : : "memory"); + + return diff; +} + +#endif /* _ASM_X86_SHARED_STRING_H */ --=20 2.47.3 From nobody Thu Sep 3 07:03:35 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 3FA453612DB for ; Sat, 22 Aug 2026 18:33:17 +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=1787423600; cv=none; b=SjemkfCFmRjMYYE4BxgzrGkhPH+dGs0fqwXPK3IuAKQCztyVJkTrw2KnN0pdQhA0VSqjhmCaY9h1/bZz4kLSVgBdcRQxHaGI/UlwGBfpWfU9MeVQQqeOs9XStGEZYVNYWtiSmdz7I6lGo56EurvEEip+BYA2UPnyh+A5Gm5b6hM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787423600; c=relaxed/simple; bh=oJ6jcQ1fpWcFC2BOdFmbpkR80LJHebD7WY+b6uxsbUM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZBcZ6Nx6pePZ/bSMD2vGXeOP+pT7Kg8vK1yf/+6aygM/eah3EBUQYq7QDYxlymlaKFpOf+N7qBynJMsJmCv9Ph8lTE4EBIDKfMoq36tUk4TWJy9bWguShWmi+e54AjVKnodki4OQHGYAqLQ6aJxjJxQUi4Wp/JEDm9foxHM85h0= 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=eWq9lcDU; 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="eWq9lcDU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=KORz1Q6LN2S1qss23Rp2FxzHVmjdGy5eAsOyJ8LP8DE=; b=eWq9lcDUFjq4cazwokKPFifDbT 10Qazbh7iMb0SIeZZDywA9Z1h60qVk/3mVGCzACps0digm7EUwGtjA0aHvzQiPXETbzZCCmtr0xYL r1MAPHj4L+UIQ7YEBxTQjww8uFjqaLZoqRi/vYBTHnRqM8oyCHsBHCWOwAUzN3EX/NyQzjAmvHfBL kmS8lgeXag4ewv8uLXYmd7f3QB6k484nBy9bGeXRZg6Efy8PRY8i8KdeSIvf51Pqyh21DvzHm+QUb xEqNRsvJdmM5BL+xvw8bHVhDN2VpedmJ25G1C2ejk94gFIW1iJpacz1YLYRXUtt9i+3A099GIk+eC a0Dhcd3A==; Received: from 186-249-148-4.shared.desktop.com.br ([186.249.148.4] helo=[127.0.1.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wxqWg-007bWT-2k; Sat, 22 Aug 2026 20:33:06 +0200 From: Mauricio Faria de Oliveira Date: Sat, 22 Aug 2026 15:33:19 -0300 Subject: [PATCH v9 3/5] x86/asm: group inline string functions 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: <20260822-pvh-kasan-inline-v9-3-e70ef3b75b6a@igalia.com> References: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> In-Reply-To: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , Jan Beulich , Brian Gerst 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 Group the __inline string functions in the same header. Use since __inline_memcmp() must remain there for use by arch/x86/boot/string.c. No functional changes. Signed-off-by: Mauricio Faria de Oliveira --- arch/x86/include/asm/shared/string.h | 21 +++++++++++++++++++++ arch/x86/include/asm/string.h | 21 +-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/shared/string.h b/arch/x86/include/asm/sh= ared/string.h index 06c1d5e5013e4d59cfb49866d10e164362d2c4cc..ab033d27c581e44ba3f5a494ca2= 9e31776be51f2 100644 --- a/arch/x86/include/asm/shared/string.h +++ b/arch/x86/include/asm/shared/string.h @@ -2,6 +2,27 @@ #ifndef _ASM_X86_SHARED_STRING_H #define _ASM_X86_SHARED_STRING_H =20 +static __always_inline void *__inline_memcpy(void *to, const void *from, s= ize_t len) +{ + void *ret =3D to; + + asm volatile("rep movsb" + : "+D" (to), "+S" (from), "+c" (len) + : : "memory"); + return ret; +} + +static __always_inline void *__inline_memset(void *s, int v, size_t n) +{ + void *ret =3D s; + + asm volatile("rep stosb" + : "+D" (s), "+c" (n) + : "a" ((uint8_t)v) + : "memory"); + return ret; +} + /* * This inline memcmp() returns 0 (equal) or 1 (not equal). * The regular memcmp() returns <0 (less than), 0 (equal), or >0 (greater = than) diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 9cb5aae7fba9ffcf0f5af8f939d30467750ccaa9..dbf59f0d4cca71e2ddce0d8764a= eec8782236669 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -8,25 +8,6 @@ # include #endif =20 -static __always_inline void *__inline_memcpy(void *to, const void *from, s= ize_t len) -{ - void *ret =3D to; - - asm volatile("rep movsb" - : "+D" (to), "+S" (from), "+c" (len) - : : "memory"); - return ret; -} - -static __always_inline void *__inline_memset(void *s, int v, size_t n) -{ - void *ret =3D s; - - asm volatile("rep stosb" - : "+D" (s), "+c" (n) - : "a" ((uint8_t)v) - : "memory"); - return ret; -} +#include =20 #endif /* _ASM_X86_STRING_H */ --=20 2.47.3 From nobody Thu Sep 3 07:03:35 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 B00253630AC for ; Sat, 22 Aug 2026 18:33:21 +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=1787423604; cv=none; b=g5Y0zDHOiaTacH+HIngUhlyYfTxyXE8/T11jLaqrYEJDH12EVYqtQPVZQmHZel2ev5dQC/rnu3S1VVzb2M8bNWaZue4YDKMD9h8iLCMta/Rj9I41bzL3IWLmFoyHI0HQXg+yo9WRjRKhoNXiqxWoe0XxMLltHChAvnobEn1YxX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787423604; c=relaxed/simple; bh=OkIa3z1AcMrSUna4J8u5Lsiefie52xz4ktG4ssBuhdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ka2Bg2pv77vSQlm6KFZNCDy/pMg5JiAgOGktAeSqRg8fEPiIIsY0Z4uvXZ5tdWNz0UOynUCHaQF1YrxbrB03PIPAIreLpkYS9zeuPn6BBcW7/0+MzluSfWAlOFht4D/9MHyq06K17+PUlXsHGLZ2DqKJiie57fCHoXUFbHSdMBk= 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=H7scH/f9; 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="H7scH/f9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=H2GAc7mtrFpKl87p+adcJZhrkVbc1evwDywNzt1ulrU=; b=H7scH/f9ODImbbUeyRMgVs7MXe Nr3swyCLfgndRrDO16yiFdMGz4KKClK2UPeUFBZKVfLxmIqMoKb3T/QUykYiNYSaZ+lSiBkOAWs8K mPeTyiyzWVBYg9kn5vwI13IGSEJN/hnVR7zvusHc8vC26fNDy9EUiMtHFDEj94edspLbLPj0qPZq4 ef0YCA0Glz2UqWlN13YuFbgT6H+EpD/oSjikDrT4RmtRcavY+AxKlreaSo2i+Izsrzy5b2QqYq13E x23H4ImJH+EvyLOnra8OZnARhQqFHaeyv6Doe0SPuSjiGkp9KCVP5E1viUqPqeS0iUv4cIYeaQW6V m0Hwf4Qg==; Received: from 186-249-148-4.shared.desktop.com.br ([186.249.148.4] helo=[127.0.1.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wxqWj-007bWT-Vu; Sat, 22 Aug 2026 20:33:10 +0200 From: Mauricio Faria de Oliveira Date: Sat, 22 Aug 2026 15:33:20 -0300 Subject: [PATCH v9 4/5] x86/cpuid: fix unbootable VMs by really inlining memcmp() in hypervisor_cpuid_base() 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: <20260822-pvh-kasan-inline-v9-4-e70ef3b75b6a@igalia.com> References: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> In-Reply-To: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , Jan Beulich , Brian Gerst 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 Even with __builtin the compiler may decide to use the out of line function instead of the inline implementation. The existing code is broken with gcc-14/15 but not gcc-12/13 (Ubuntu 25.10) and vmlinux no longer boots with CONFIG_PVH if CONFIG_KASAN_GENERIC is set. For testing purposes, if the size argument is reduced from 12 to 8 then the compiler decides to use the inline implementation; that shows results vary. Switch the builtin to the inline implementation to address it. Fixes: 416a33c9afce ("x86/cpu: fix unbootable VMs by inlining memcmp() in h= ypervisor_cpuid_base()") Signed-off-by: Mauricio Faria de Oliveira Reviewed-by: Juergen Gross --- arch/x86/include/asm/cpuid/api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index 82eddfa2347b32b76c2ea9b85f005ca5416ac71f..2d9f3d4d63de6e721f275d9e80d= 372edbdfedf30 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -204,7 +204,7 @@ static inline u32 cpuid_base_hypervisor(const char *sig= , u32 leaves) * from PVH early boot code before instrumentation is set up * and memcmp() itself may be instrumented. */ - if (!__builtin_memcmp(sig, signature, 12) && + if (!__inline_memcmp(sig, signature, 12) && (leaves =3D=3D 0 || ((eax - base) >=3D leaves))) return base; } --=20 2.47.3 From nobody Thu Sep 3 07:03:35 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 2C4C415C14F for ; Sat, 22 Aug 2026 18:33:24 +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=1787423607; cv=none; b=YpwodDPLKaT2Fnw6HA09LHxW1BN9ToOMOSBugUcK2SPCFsDhuo7OEaDaCuwDm0GtHlEj4ScdTZ577K6Obj/RoYffRkwybV3QfaornGK9qv/9WKwJikaQUeLBtLUkiBqIErfpcn8gWxWedtI8hS8LsaqFj53Jnmbw28fuuadZqhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787423607; c=relaxed/simple; bh=tVuJTrndrhWukjL2JH+r8Z+UgyP7i4IP5gkTm3V37Hs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eDoSEDpHOpP1ekvEAYhwl45NJ/nKmtQmOSwJ5LCdZ9R4xO7F2nPeiFFRwr96msooAOgvCmahcfWxZGEoV1f2XolHnX1cj4pgx4PG3ZhkJGMpI2BcHTJVILDAQuwk6P9ycK9fHgxV0JxxRTkhWy81opaOIIbNaS2VtYjMtVPzCv4= 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=dMe2VFbX; 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="dMe2VFbX" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=zBAAE6UPiVcuOT4Hdx5zYoG+Uei+rPkEJSxQ4+nbtAc=; b=dMe2VFbXG6LVZ97XCcOZogZ+Xl pKsLTJrh/GztxOCmUVySpFIS2alUMuV7GQayR1mRTdceykiWxoYxkoXRUr9C11Pz+F5zH8JYYNNBn Yi34qxXxtXJTg9qskyzCCk3Jp0JFGk+HajY3LrNFeIupDUyEn8sDEd69O8PSekVprWRmtrcY6qz0h dUJQRc9gZjDsw6kVPls2+HBH9cXK6TLxG74P7DLapJem2fZLzH96NXtGfJcYVp2IOW7ZVmk1fr3ma GCZ4xsK38gihLmcLo7yiNGxFgLlrLScn9kh7auOPKiiCL0IrA/QuBeKySEhAsDxw/ap2dp4nINRux PDVnSvmg==; Received: from 186-249-148-4.shared.desktop.com.br ([186.249.148.4] helo=[127.0.1.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wxqWn-007bWT-T1; Sat, 22 Aug 2026 20:33:14 +0200 From: Mauricio Faria de Oliveira Date: Sat, 22 Aug 2026 15:33:21 -0300 Subject: [PATCH v9 5/5] x86/pvh: fix unbootable VMs by really inlining memset() in xen_prepare_pvh() 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: <20260822-pvh-kasan-inline-v9-5-e70ef3b75b6a@igalia.com> References: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> In-Reply-To: <20260822-pvh-kasan-inline-v9-0-e70ef3b75b6a@igalia.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , Jan Beulich , Brian Gerst 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 Even with __builtin the compiler may decide to use the out of line function instead of the inline implementation. This particular one (still) generated the inline implementation as expected (at least in these compiler versions) but this is not guaranteed to remain. Switch the builtin to the inline implementation to address it. Fixes: fbe5a6dfe492 ("xen, pvh: fix unbootable VMs by inlining memset() in = xen_prepare_pvh()") Signed-off-by: Mauricio Faria de Oliveira Reviewed-by: Juergen Gross --- arch/x86/platform/pvh/enlighten.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enli= ghten.c index f2053cbe9b0ce3d2178938269607c652ae8f528e..cb442cbd9d828619421babb281b= fe9759edbca8a 100644 --- a/arch/x86/platform/pvh/enlighten.c +++ b/arch/x86/platform/pvh/enlighten.c @@ -8,6 +8,7 @@ #include #include #include +#include =20 #include =20 @@ -129,7 +130,7 @@ void __init xen_prepare_pvh(void) * This must not compile to "call memset" because memset() may be * instrumented. */ - __builtin_memset(&pvh_bootparams, 0, sizeof(pvh_bootparams)); + __inline_memset(&pvh_bootparams, 0, sizeof(pvh_bootparams)); =20 hypervisor_specific_init(xen_guest); =20 --=20 2.47.3