From nobody Sat May 30 11:15:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=igalia.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1779807206429781.5530383564242; Tue, 26 May 2026 07:53:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1319969.1587383 (Exim 4.92) (envelope-from ) id 1wRt9K-0002vb-28; Tue, 26 May 2026 14:52:54 +0000 Received: by outflank-mailman (output) from mailman id 1319969.1587383; Tue, 26 May 2026 14:52:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9J-0002vU-V9; Tue, 26 May 2026 14:52:53 +0000 Received: by outflank-mailman (input) for mailman id 1319969; Tue, 26 May 2026 14:52:52 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9I-0002vJ-4f for xen-devel@lists.xenproject.org; Tue, 26 May 2026 14:52:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRt9H-00DAaE-Gr for xen-devel@lists.xenproject.org; Tue, 26 May 2026 16:52:51 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b3ad-5cb7-0a2a0a5109dd-0a2a4504a6a4-42 for ; Tue, 26 May 2026 16:52:51 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b3c2-1dec-0a2a45040019-d561b338ae9e-3 for ; Tue, 26 May 2026 16:52:51 +0200 Received: from 186-249-145-161.shared.desktop.com.br ([186.249.145.161] helo=[192.168.1.68]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wRt9G-008TwX-4x; Tue, 26 May 2026 16:52:50 +0200 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20170329 header.d=igalia.com header.i="@igalia.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" 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=rZqhwZAX9gu8lRikViZCp0rEPli4a286DTrRRjyvllQ=; b=WuYAJhANIcWzzse+dgQGkYqb5a sTO9DiiY9WqvwBeNnKJgGHjCYn/gJh9auXrf16rHEn4GligS1r5rYO1ULIahN2W4UH5P5cTD3sDfv oju7p8gCs1SvahCyN18CxQTeQrr7ZlVdnmFa/IL+fmp5TELb+oIbxd4hpWxqQKsRTjSa73NSlaMbT 9fR8xMsZZbSiW7o/VDf/UsUmw14ax0q2W2+1nLvR5HD6JI2O893xWpRIXDFCxHLrIcoYuhhL/Vhzb +6d5I7f7kq9l6f5dw2S1xF1++r5c4AVPSbZVwee2+jMdpzr1QyfQursdOS9ftc9JrMvAFX9eZo7tg AXa8kRnQ==; From: Mauricio Faria de Oliveira Date: Tue, 26 May 2026 11:52:33 -0300 Subject: [PATCH v4 1/4] x86/asm: move inline string functions to MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260526-pvh-kasan-inline-v4-1-a310e6a25ecd@igalia.com> References: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@igalia.com> In-Reply-To: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@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 , kernel test robot X-Mailer: b4 0.14.2 X-purgate-ID: tlsNG-ebf023/1779807171-2BF6D3FF-CF7AE7A2/0/0 X-purgate-type: clean X-purgate-size: 4470 X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779807209784154100 In a future patch, 'boot/string.c' will include inline string functions. Using the header is problematic for a couple of reasons (i.e., build errors), which can be addressed, but introduce unnecessary complexity and regression risk (beyond these _found_ couple of reasons). Using a new header is simpler and transparent to existing users of , with less changes to 'boot/string.c' and its users (eg 'boot/compressed/string.c' and 'purgatory/purgatory.ro'), which minimize regression risk. No functional change intended. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202605140922.q7IlUv7o-lkp@int= el.com/ Signed-off-by: Mauricio Faria de Oliveira Reviewed-by: Juergen Gross --- (*) Reasons not to include in 'boot/string.c': 1) 'boot/string.c' is built for 16-bit/real mode thus some type and word size errors happen when include, e.g., . This can be addressed with '#ifndef _SETUP' (defined by 'boot/Makefile'). 2) 'boot/string.c' is included by 'boot/compressed/string.c' which is the source of 'purgatory/string.o', linked by 'purgatory/purgatory.ro' (CONFIG_KEXEC_FILE). In 64BIT, includes , which references __memset() and __memmove() with KCFI_REFERENCE(), ie, __ADDRESSABLE(); however, 'purgatory/purgatory.ro' is not linked with implementations. So, CONFIG_KEXEC_FILE and CONFIG_CFI without CONFIG_KASAN hit errors: >> ld.lld: error: undefined symbol: __memset >>> referenced by string.c >>> arch/x86/purgatory/purgatory.ro:\ (__UNIQUE_ID_addressable___memset_0) -- >> ld.lld: error: undefined symbol: __memmove >>> referenced by string.c >>> arch/x86/purgatory/purgatory.ro:\ (__UNIQUE_ID_addressable___memmove_1) (Note: this is not hit with CONFIG_KASAN because 'boot/compressed/string.c' adds aliases __memset()/__memmove() to memset()/memmove() in that case.) This can be addressed with 'CFLAGS_string.o :=3D -D__DISABLE_EXPORTS' so to disable KCFI_REFERENCE() in 'purgatory/Makefile' (it removes CC_FLAGS_CFI anyway). ... However, since a change in this series would need more changes to address errors it causes, it is reasonable to change the series not to cause them, by using a separate header with _just_ inline string functions. --- arch/x86/include/asm/string.h | 21 +-------------------- arch/x86/include/asm/string_inline.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 9cb5aae7fba9ffcf0f5af8f939d30467750ccaa9..8a849bb5d0c7100a2a1820ec0af= 9fc9f850727fd 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 */ diff --git a/arch/x86/include/asm/string_inline.h b/arch/x86/include/asm/st= ring_inline.h new file mode 100644 index 0000000000000000000000000000000000000000..ffcfa6583d2bc7b91d078888518= d0e80248af940 --- /dev/null +++ b/arch/x86/include/asm/string_inline.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_STRING_INLINE_H +#define _ASM_X86_STRING_INLINE_H + +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; +} + +#endif /* _ASM_X86_STRING_INLINE_H */ --=20 2.51.0 From nobody Sat May 30 11:15:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=igalia.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1779807205609328.4484026456586; Tue, 26 May 2026 07:53:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1319971.1587402 (Exim 4.92) (envelope-from ) id 1wRt9P-0003Mh-FW; Tue, 26 May 2026 14:52:59 +0000 Received: by outflank-mailman (output) from mailman id 1319971.1587402; Tue, 26 May 2026 14:52:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9P-0003MX-Bf; Tue, 26 May 2026 14:52:59 +0000 Received: by outflank-mailman (input) for mailman id 1319971; Tue, 26 May 2026 14:52:57 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9N-0003Ll-Nc for xen-devel@lists.xenproject.org; Tue, 26 May 2026 14:52:57 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRt9N-009wiG-3Y for xen-devel@lists.xenproject.org; Tue, 26 May 2026 16:52:57 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b3bc-2eae-0a2a0a5409dd-0a2a4502d2a2-24 for ; Tue, 26 May 2026 16:52:56 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b3c7-af86-0a2a45020019-d561b338cd9a-3 for ; Tue, 26 May 2026 16:52:55 +0200 Received: from 186-249-145-161.shared.desktop.com.br ([186.249.145.161] helo=[192.168.1.68]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wRt9K-008TwX-OV; Tue, 26 May 2026 16:52:55 +0200 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20170329 header.d=igalia.com header.i="@igalia.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" 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=UTOmAuiPQ1w9q3gPb2qsdx9jiBuxtzvoq44hIQ1/dkQ=; b=RJTHWlKG1FeZ9gjM4LsjQuc4z9 +EQtwpdyMJpAtgaD4rOIVqx8Z99YlVI9XB6jBHb6uJYJoPyHJixkVQMqzdi7qdxja69KdeeFeGMhz 3yxL2rVgY6JiUVCUZyeK+kgW5Df5TQ1MvN8IcIOJJ4RLddvuoncNls7UDgyWAfAyBSJ9riQS3MjgK y4/bYCWT6uTLVwUq+vX0ms9ijYzHwBU6gudxf6Zwt4E0sGM/pwigpWIuDzfkvy6TpvLfQD6O+eGsE C7csYOpMgdpyVA2bjrhy1dclhRahumZC3ivC8LdLf9uYdd8dnf2DGxYTnK1Sc5gn/crvTQStqiMu/ 7qXv9MQw==; From: Mauricio Faria de Oliveira Date: Tue, 26 May 2026 11:52:34 -0300 Subject: [PATCH v4 2/4] x86/asm, x86/boot: expose inline memcmp MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260526-pvh-kasan-inline-v4-2-a310e6a25ecd@igalia.com> References: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@igalia.com> In-Reply-To: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@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 X-purgate-ID: tlsNG-720697/1779807176-8117D161-4AE29E21/0/0 X-purgate-type: clean X-purgate-size: 2102 X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779807209740154100 Move the inline memcmp function currently only available in 'boot/string.c' and its users (eg, 'boot/compressed/string.c' and 'purgatory/purgatory.ro') into the inline string functions header to be reused. Note that the inline memcmp() returns 0/1, not -1/0/1 as regular memcmp() (reported by David Laight ), which is not caused or changed by this commit; this will be addressed separately. Signed-off-by: Mauricio Faria de Oliveira Reviewed-by: Juergen Gross --- arch/x86/boot/string.c | 6 ++---- arch/x86/include/asm/string_inline.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index ac0f900ebc47efa81c92e1bb2010ea41677899c4..544681d046c3f87101309ffaca0= c90512a244856 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_inline.h b/arch/x86/include/asm/st= ring_inline.h index ffcfa6583d2bc7b91d078888518d0e80248af940..91ed89bfdfa9b148002441e94f4= 8039b17f70391 100644 --- a/arch/x86/include/asm/string_inline.h +++ b/arch/x86/include/asm/string_inline.h @@ -23,4 +23,15 @@ static __always_inline void *__inline_memset(void *s, in= t v, size_t n) return ret; } =20 +/* 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_STRING_INLINE_H */ --=20 2.51.0 From nobody Sat May 30 11:15:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=igalia.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1779807206433601.3592301454505; Tue, 26 May 2026 07:53:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1319972.1587410 (Exim 4.92) (envelope-from ) id 1wRt9S-0003cN-Qw; Tue, 26 May 2026 14:53:02 +0000 Received: by outflank-mailman (output) from mailman id 1319972.1587410; Tue, 26 May 2026 14:53:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9S-0003cG-NY; Tue, 26 May 2026 14:53:02 +0000 Received: by outflank-mailman (input) for mailman id 1319972; Tue, 26 May 2026 14:53:01 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9R-0003b9-GU for xen-devel@lists.xenproject.org; Tue, 26 May 2026 14:53:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRt9Q-00DAfa-SN for xen-devel@lists.xenproject.org; Tue, 26 May 2026 16:53:00 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b3c2-5cb7-0a2a0a5109dd-0a2a45019a54-32 for ; Tue, 26 May 2026 16:53:00 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b3cc-c1f2-0a2a45010019-d561b338dc20-3 for ; Tue, 26 May 2026 16:53:00 +0200 Received: from 186-249-145-161.shared.desktop.com.br ([186.249.145.161] helo=[192.168.1.68]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wRt9P-008TwX-IX; Tue, 26 May 2026 16:52:59 +0200 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20170329 header.d=igalia.com header.i="@igalia.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" 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=gJKjWXfILv4BRccqYgfSFnf+b13WkiYn/6GuwfAO050=; b=OesFYrIBBOauSSY3AjjpMej7ph hJ248d7jDB7xvJ41ugaGoBXE1n/qxNNG9q9C4d7IDIlr5JZw8AKJ7CMf78LHGqnHVAkvIRMQL6s6l ajpvLYA8iUA0R3szIb9A//tTX/rFpCyULIUoz+mQXlZi00WnBEmq+RcRRU01a2fCx/Rh8dw/gQi5k QP8x3PBNb7gDGrClTdZhImkXmJpiM2+qj8B9eOzp30jaL20bichpfZEnmHpAQwePZLnF/r4UNF2s/ HzBMg7x8ZJvBRX5y9PFxNC2AbMbhkrPB3gY1lQrRX5IhUUV3LahNH1ftxzJuJBcyH0hQVdL+GbsUA tixH9UfQ==; From: Mauricio Faria de Oliveira Date: Tue, 26 May 2026 11:52:35 -0300 Subject: [PATCH v4 3/4] x86/cpuid: fix unbootable VMs by really inlining memcmp() in hypervisor_cpuid_base() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260526-pvh-kasan-inline-v4-3-a310e6a25ecd@igalia.com> References: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@igalia.com> In-Reply-To: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@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 X-purgate-ID: tlsNG-d62444/1779807180-AD9A9FF4-E1028600/0/0 X-purgate-type: clean X-purgate-size: 1458 X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779807209736154100 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.51.0 From nobody Sat May 30 11:15:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=igalia.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1779807209262237.24718906633632; Tue, 26 May 2026 07:53:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1319973.1587419 (Exim 4.92) (envelope-from ) id 1wRt9X-0003v8-2o; Tue, 26 May 2026 14:53:07 +0000 Received: by outflank-mailman (output) from mailman id 1319973.1587419; Tue, 26 May 2026 14:53:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9W-0003uo-VX; Tue, 26 May 2026 14:53:06 +0000 Received: by outflank-mailman (input) for mailman id 1319973; Tue, 26 May 2026 14:53:06 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRt9W-0003tv-AM for xen-devel@lists.xenproject.org; Tue, 26 May 2026 14:53:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRt9V-00DAdi-Mk for xen-devel@lists.xenproject.org; Tue, 26 May 2026 16:53:05 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b3ce-e002-0a2a0a5209dd-0a2a450acc28-8 for ; Tue, 26 May 2026 16:53:05 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b3d1-56b3-0a2a450a0019-d561b338b71c-3 for ; Tue, 26 May 2026 16:53:05 +0200 Received: from 186-249-145-161.shared.desktop.com.br ([186.249.145.161] helo=[192.168.1.68]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wRt9U-008TwX-CT; Tue, 26 May 2026 16:53:04 +0200 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20170329 header.d=igalia.com header.i="@igalia.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" 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=L3Sr9rY5U1mD/3546TE+xOT1mBFRY3YzwAzYlEgEGo8=; b=TFfbZM3IVCe7bLF1pen0oFglI9 HTAI6yIrD2Gg0QVnwokdz1pXUAVJtb7hIrrmnNha9t7eOmhF5Ysx/U6xGn0VQx6vto16KLFrrj9SR d5crj92d0FUNleg2g1o0LH1IX+CJijWoyevMnfvLCoSA9nzPEsZrcB5SCzfLSlV6n4NoaqUspGG3L 4/gkvo2aUFoc+9l+uQzU3zlSMwJ7fU5WZVquW3asjZDLvF8QPHU2mQHxoXxZ5ubwBoRs2oNWt1MPr NGCsMBJIgJJ3u0gnC5BXfxGe61gr22kRvKe05py6xTl15MS0QkJn20DqpQuXX1RuDN2AUje79vYCK L8Uc4siw==; From: Mauricio Faria de Oliveira Date: Tue, 26 May 2026 11:52:36 -0300 Subject: [PATCH v4 4/4] x86/pvh: fix unbootable VMs by really inlining memset() in xen_prepare_pvh() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260526-pvh-kasan-inline-v4-4-a310e6a25ecd@igalia.com> References: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@igalia.com> In-Reply-To: <20260526-pvh-kasan-inline-v4-0-a310e6a25ecd@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 X-purgate-ID: tlsNG-4011c0/1779807185-7EF8B8B7-5731982A/0/0 X-purgate-type: clean X-purgate-size: 1474 X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779807211288154100 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 the case, as seen with the previous commit. Switch the builtin to the inline implementation to prevent a similar issue. 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.51.0