From nobody Sat Jul 4 21:11:36 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 C934B3B4EAA for ; Tue, 30 Jun 2026 17:21:57 +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=1782840119; cv=none; b=fXuGptq8odMVbGPIofXJmXGZYRKpQLFx4nKMdEGthEB61ct1ok5ebtW2yeBE4iVph40uHpFZS5/pnyrlPYDsnEvs9HU0Y0ENfkCMtAa7tYhRr32+SdShUrh4zAaD23koNV4teGE+NJJAMAbshiXvCKxAQ6Klwy7dBH9iA4je+Dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782840119; c=relaxed/simple; bh=a+zwFal1N58N8BgxUmRxSdrRXaRD8pB8llkdTlP1cg8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HQgiUtXeZplvkM9ONipjHXHYPYeKtB2BVLS0zUz6+JTpr+KAf/i4wQ/VAZqFWOOfxtm7/zIuJgLKNe4FrnoY7x8Mm4c/rR2izol5no9f8y3WPAS/YGocBnWdAOZCDY/hidjjfi3mvAtnUDP6TVqBR4gVNI/pzhoFigEHXjvA5jA= 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=BTkz3qCe; 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="BTkz3qCe" 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=cbo7APVGgkBxZ4BLzRh6ix97JTDWhDJxr3+WL6IL7Rs=; b=BTkz3qCey4JPMY//jgxOnO/7ot 00QsFQ5llkizDf4B9od45FXxTfERTo7ucs2n6EAOLNf4qxJ01XoToOESTo62ghZ7ISObCZ0DiwLa6 hlmpblEMqCpofaPwu1Ln2TUD160reIeEx3taO4ndLAaNoQL0tg2M1PEwGgz9LS//F47DCpiBm5SEb dktLMdqMWfuRuSimBgP6dTsdGwnC1M2CQm5Jq7cJzALB6JGwnBNjfrdZ+WEZL5uVingkzrV3tB5ol TqW/5mgh7EEjhGjhGp7ld+cFrBKZpL75CvuxWyr6DcE7DByK8yBeH9XNjO6p6Sg7iXwWnFxfJqQSd 6Mf3TBDw==; Received: from 186-249-148-121.shared.desktop.com.br ([186.249.148.121] 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 1wec9d-007CH3-5x; Tue, 30 Jun 2026 19:21:49 +0200 From: Mauricio Faria de Oliveira Date: Tue, 30 Jun 2026 14:21:46 -0300 Subject: [PATCH RESEND v5 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: <20260630-pvh-kasan-inline-v5-1-52afc979be81@igalia.com> References: <20260630-pvh-kasan-inline-v5-0-52afc979be81@igalia.com> In-Reply-To: <20260630-pvh-kasan-inline-v5-0-52afc979be81@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 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'. Note that the inline memcmp() returns 0/1, not -1/0/1 as regular memcmp() (reported by David Laight ). Signed-off-by: Mauricio Faria de Oliveira --- arch/x86/boot/string.c | 6 ++---- arch/x86/include/asm/shared/string.h | 16 ++++++++++++++++ arch/x86/include/asm/string.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index ac0f900ebc47efa81c92e1bb2010ea41677899c4..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,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/shared/string.h b/arch/x86/include/asm/sh= ared/string.h new file mode 100644 index 0000000000000000000000000000000000000000..422952152f533ad75b98f387329= 7b39c4f5e2477 --- /dev/null +++ b/arch/x86/include/asm/shared/string.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SHARED_STRING_H +#define _ASM_X86_SHARED_STRING_H + +/* Note: this memcmp() returns 0/1, not -1/0/1 as regular memcmp(). */ +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_SHARED_STRING_H */ diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 9cb5aae7fba9ffcf0f5af8f939d30467750ccaa9..f0f4fd8227bf992e78c69209efb= 31f0a9a0cc3b1 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -7,6 +7,7 @@ #else # include #endif +#include =20 static __always_inline void *__inline_memcpy(void *to, const void *from, s= ize_t len) { --=20 2.47.3 From nobody Sat Jul 4 21:11:36 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 CDA133DD532 for ; Tue, 30 Jun 2026 17:22:01 +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=1782840123; cv=none; b=P+3szdDQAd6Vn6lxYvF2J9c5gSzzDWWARHu1rvSou2FcxmKzSQPgPAQ7UGaJGUa4PEXq5xzPySyhtECGHWT3EfW6sNCXL8FQvtfJweuMPbQO/EmJrOqSd66D4qYp2m7EVcSV13JQD1WoPVPvsXgAmM3R5+s5qQw8Slwg+Vh36wI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782840123; c=relaxed/simple; bh=OkIa3z1AcMrSUna4J8u5Lsiefie52xz4ktG4ssBuhdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XPfbK2XRK3UFquXyzO4LZjrZ2vnKT9t1lgDA5AR5QuvAGPk2dyfQkHNFwmA/61gR/doPYBCI2tTfm2Q2nGtU8rSUh3We0Z2KK7ceyOof9nO4A01nNCkziFfVNmSL4swJOFbySyvByV6QI6ZRWaCTTKLroELrD1WRA3wgvNjkrCs= 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=QgFWWISO; 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="QgFWWISO" 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=H2GAc7mtrFpKl87p+adcJZhrkVbc1evwDywNzt1ulrU=; b=QgFWWISO9VOjE7VfkaXi8KyANF fwI4SBsOoVTagpwP7spLlHq3GcbN+CJvKxNiscGaMYU8i+9r4R0xF3GvBwynUNH9vpn6rZc2wL0yY UpX/sL3Z2Hgvc0FTdz1FI/DGHBBmBcjcZt4T2/Kr9RYiqKeOeYJb7RKm+wUSOHPy87syEVgYQKzfo yLyoFBt/7LJKiFlQ3o+WmR8p5o686Q5NqTK/1kD/W7Cjy+ySWIWQUjSjNSdnrEMWmAeVk0GqfpWo3 r7kkwSRouR3pQ2SJaz0/e0597X7al3ybVlHh1QfLJxeWJccpo/5VFK0iLNKilDVJ0JjtGaqBXYIMn +0eXvzGA==; Received: from 186-249-148-121.shared.desktop.com.br ([186.249.148.121] 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 1wec9h-007CH3-55; Tue, 30 Jun 2026 19:21:53 +0200 From: Mauricio Faria de Oliveira Date: Tue, 30 Jun 2026 14:21:47 -0300 Subject: [PATCH RESEND v5 2/3] 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: <20260630-pvh-kasan-inline-v5-2-52afc979be81@igalia.com> References: <20260630-pvh-kasan-inline-v5-0-52afc979be81@igalia.com> In-Reply-To: <20260630-pvh-kasan-inline-v5-0-52afc979be81@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 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 Sat Jul 4 21:11:36 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 86B6B3DE421 for ; Tue, 30 Jun 2026 17:22:05 +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=1782840127; cv=none; b=kwYxO0+0m44Abkf8igMhT+nX10XnX5NDz1TXRF88hsiGTr+7LqW3AxzwDQooX8dJoal8Y7i4KUAwZUnZAw151gicFmMzdR6nYfs9CL4w1Lw89/m22+ptCMXWAwgyUB+V2gXEfaDK8esoosXSA7e2iQ1V4v6FSxEOi0VihPgdVcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782840127; c=relaxed/simple; bh=tVuJTrndrhWukjL2JH+r8Z+UgyP7i4IP5gkTm3V37Hs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ngHufiilrPxeSAcpDHF0j3tpdrFfg3AoqNx2B1ydK4sgsQ/EQqhQP8Yds6bhcpQneFikyDORSt4enbSdOtWB/tRctgZyz9DsAYhPSy0UkRelXgmM61Uouw2cgE3IvCYIcS6MlVs15Vnywfy9olmiA6DkHRSig/66DTOWwXW3gd0= 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=SZo77jHq; 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="SZo77jHq" 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=zBAAE6UPiVcuOT4Hdx5zYoG+Uei+rPkEJSxQ4+nbtAc=; b=SZo77jHqJ9ZYoDxvDGqIOS+zQF b+GbMOt6GNvL1lW5VlxLrPY+Y35a1XOiFtOjcv6fU5n8JkFxqHYTv6JJHOdYYEnWH8Kr5QdStkYiV m3sWmFyUFmieiRNB/WJrPzrim9h6LEO8U5CZWk8N/k5pN3vI1Wc/qshchmpenKN7A2W5gGDnKqo4e 76w15wPdKjaKIJ9NLJ6athW+OW1iyA0jpU4XU+TNrcmainfYxx0PDwPq+Qwb90nBc9CuMREp17wmc 2V2oDMj6kah5UCJKCQ+dH1XyXy1Uchh3VlrNm/qF9wKDMBDs+4eu20HVuo2bHKwtIH/4L5WgQi1fO sSrf1wQg==; Received: from 186-249-148-121.shared.desktop.com.br ([186.249.148.121] 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 1wec9l-007CH3-4r; Tue, 30 Jun 2026 19:21:57 +0200 From: Mauricio Faria de Oliveira Date: Tue, 30 Jun 2026 14:21:48 -0300 Subject: [PATCH RESEND v5 3/3] 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: <20260630-pvh-kasan-inline-v5-3-52afc979be81@igalia.com> References: <20260630-pvh-kasan-inline-v5-0-52afc979be81@igalia.com> In-Reply-To: <20260630-pvh-kasan-inline-v5-0-52afc979be81@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 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