From nobody Fri Jul 24 21:53:24 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=pass; 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=pass(p=none dis=none) header.from=igalia.com ARC-Seal: i=1; a=rsa-sha256; t=1784848463; cv=none; d=zohomail.com; s=zohoarc; b=c5P1LgTNR2iGBSgq17bc/63PnTZquzJ1T96LZG0/DXBxASw1O90xJRyfgD4uhPr11BXrM/ycCEBhFADsYOmMb038bXZxw2VynFn+v4XOdyuQmEVxhxqwahZFBq6oVtcV6FsudYNEZe1AFuWNUaFmNNahwx2zAqAE2KllRt1JoyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784848463; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+Q2m+yozez2bdzT3Nq6OWg4kVQdgVnIRf7/C3OSAOVU=; b=U4x8iSoCAwsmH1V6MXLC4SKYoFDX1WX3ZF2kTKu8/6zV3xZrSy0RHQZeY1QOzXtRZATG8CjzaIyL9lCUirXxGcufLb2g7GTJI/Iw2hrnTuRmqjEB9GGr45XIlg2sDpElFj5Rs8WF4mKxzH6UOenQg2T8jCjMc/aQHCC1BhS4XYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784848463194810.3459118387009; Thu, 23 Jul 2026 16:14:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1369668.1618237 (Exim 4.92) (envelope-from ) id 1wn2cE-0007WM-Fl; Thu, 23 Jul 2026 23:14:10 +0000 Received: by outflank-mailman (output) from mailman id 1369668.1618237; Thu, 23 Jul 2026 23:14:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cE-0007WF-CU; Thu, 23 Jul 2026 23:14:10 +0000 Received: by outflank-mailman (input) for mailman id 1369668; Thu, 23 Jul 2026 23:14:08 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cC-0007HT-OT for xen-devel@lists.xenproject.org; Thu, 23 Jul 2026 23:14:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wn2cC-00A9gi-5N for xen-devel@lists.xenproject.org; Fri, 24 Jul 2026 01:14:08 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a629fc2-e002-0a2a0a5209dd-0a2a4502ebd2-38 for ; Fri, 24 Jul 2026 01:14:08 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a62a03f-6ca4-0a2a45020019-d561b338b144-3 for ; Fri, 24 Jul 2026 01:14:08 +0200 Received: from 186-249-149-197.shared.desktop.com.br ([186.249.149.197] 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 1wn2cA-003dsJ-8L; Fri, 24 Jul 2026 01:14:06 +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: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:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=+Q2m+yozez2bdzT3Nq6OWg4kVQdgVnIRf7/C3OSAOVU=; b=lJASM5Ju6yF8L/0l8SfXkn0RQ+ wNDcr8pEsU7VeTmV6+5Qu5HqMwyJFJi5MMj4O6RfC4gu8FdYieG8ie2ehWHrAspRtcLvQwYvGGHGw SrHbVJVyN/bVHCIer3pr/V6UzDihAPWkdU1wBT6NRdTmCpals98/WsC2OYIh1NqbXyOXeh1RbXZF4 eEY0ZD1cqhk6SK4N5pW2g18ApStw1oUMh13D6h+kH0/sRtGloIhfmCuSE+LOKUOs8uAfI894zizlG 8Ze0MKxcIheW85wpxeLqU4xxOpGMMiCLNnZarpbUFRyuyFsJ2z8de7DirX93lTRMJi14XXnDZnfuv PkDWYvmg==; From: Mauricio Faria de Oliveira Date: Thu, 23 Jul 2026 20:13:51 -0300 Subject: [PATCH v8 1/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: <20260723-pvh-kasan-inline-v8-1-c1f62c156f52@igalia.com> References: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@igalia.com> In-Reply-To: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@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 X-purgate-ID: tlsNG-720697/1784848448-670B02AC-7673CAE7/0/0 X-purgate-type: clean X-purgate-size: 2320 X-ZohoMail-DKIM: pass (identity @igalia.com) X-ZM-MESSAGEID: 1784848465644158500 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'. 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 | 8 ++------ arch/x86/include/asm/shared/string.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index 6827551720dd9b96afe8c55a051401d6cdc6f05e..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,12 +32,7 @@ =20 int memcmp(const void *s1, const void *s2, size_t len) { - bool diff; - asm volatile("test %3, %3\n\t" - "repe cmpsb" - : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len) - : : "cc", "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..66a446168fd1e9914b9e0054026= 9f555abe4738d --- /dev/null +++ b/arch/x86/include/asm/shared/string.h @@ -0,0 +1,22 @@ +/* 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; + + asm volatile("test %3, %3\n\t" + "repe cmpsb" + : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len) + : : "cc", "memory"); + + return diff; +} + +#endif /* _ASM_X86_SHARED_STRING_H */ --=20 2.47.3 From nobody Fri Jul 24 21:53:24 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=pass; 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=pass(p=none dis=none) header.from=igalia.com ARC-Seal: i=1; a=rsa-sha256; t=1784848472; cv=none; d=zohomail.com; s=zohoarc; b=kTGYKx+wgG2MtCUwx7AxtEWKxRrkQqIdECxFDbrYpyDGr0zMwv2RWcqdK2dV/f8KHBbUmRO8kQLDYIyHP/fMG130GbWYy9Z9LcEwOYhrZUUvkF9aOhPQG1DGbWsC2nKAdvZzpJTLqCyOLGcngCUgbjsxxaOhuXk8MQ7Fhm2uk1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784848472; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dAdbZ5UO2RrbRs396cB08KKrdlvaGcoVOWOuItnYYv8=; b=JjPFbQbA6jOzB8+497DpUMKuwME3Q/xm7s4ak+8MEsQhK3D944ddkjPAqfjHEd8vooKWOqV75ZFPeTQgMFYpc4tl28JWX7EriVVQXH2X8JNI8CEtPiaVtYUyU0tdruIMxd7D3LX5KMFdYxiG8b7I1Aj6xhxqP4IH5N/pdCyip0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784848472081807.5203615214199; Thu, 23 Jul 2026 16:14:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1369673.1618246 (Exim 4.92) (envelope-from ) id 1wn2cJ-0007oy-Me; Thu, 23 Jul 2026 23:14:15 +0000 Received: by outflank-mailman (output) from mailman id 1369673.1618246; Thu, 23 Jul 2026 23:14:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cJ-0007or-Jc; Thu, 23 Jul 2026 23:14:15 +0000 Received: by outflank-mailman (input) for mailman id 1369673; Thu, 23 Jul 2026 23:14:14 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cI-0007oF-Sm for xen-devel@lists.xenproject.org; Thu, 23 Jul 2026 23:14:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wn2cI-0056f5-9c for xen-devel@lists.xenproject.org; Fri, 24 Jul 2026 01:14:14 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a62a043-2eae-0a2a0a5409dd-0a2a4506af92-10 for ; Fri, 24 Jul 2026 01:14:14 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a62a045-195a-0a2a45060019-d561b338e49c-3 for ; Fri, 24 Jul 2026 01:14:13 +0200 Received: from 186-249-149-197.shared.desktop.com.br ([186.249.149.197] 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 1wn2cF-003dsJ-FF; Fri, 24 Jul 2026 01:14:11 +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: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:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=dAdbZ5UO2RrbRs396cB08KKrdlvaGcoVOWOuItnYYv8=; b=Q/xb8EIrwpYG0LaYCItdOI88rL D4MMVT60hHLH0XHUO26e7/osQFpdzWbLaC9oprLcSJy9TTOnI+dEqZ7GJqOpfando4KtpCY0AMlDE 2wNOfdnuyWSJn9gOd1ZmXLgGK8dJTBy3w2fP/+Nm5U7s3Ir7ij54dxlGoiudzr31LFJIVMfLOeBNC VivGQOWI0P8i4U3NyEG9GGdLx0sJ9roNrmb1+KDBIs6kQWQ/sMKT6dI6/v8NBT2eIjrLrWrTWbR/E gs6Xsd8t52SxhIMaJyWes0MFqBqz8hz4XzNrH82lNVart4cpNKAxN+Wa8s7NROFwEpqZc2B2R9pif sPnAQUdQ==; From: Mauricio Faria de Oliveira Date: Thu, 23 Jul 2026 20:13:52 -0300 Subject: [PATCH v8 2/4] x86/asm: group inline string functions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-pvh-kasan-inline-v8-2-c1f62c156f52@igalia.com> References: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@igalia.com> In-Reply-To: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@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 X-purgate-ID: tlsNG-16d1c6/1784848454-F5C0F77B-012B5296/0/0 X-purgate-type: clean X-purgate-size: 2271 X-ZohoMail-DKIM: pass (identity @igalia.com) X-ZM-MESSAGEID: 1784848473496158500 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 66a446168fd1e9914b9e00540269f555abe4738d..68b4e5a509d9758271bf203382b= 62dd0943274c8 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 Fri Jul 24 21:53:24 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=pass; 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=pass(p=none dis=none) header.from=igalia.com ARC-Seal: i=1; a=rsa-sha256; t=1784848472; cv=none; d=zohomail.com; s=zohoarc; b=Cb27LmxNQAQgBLmgb04IB+Q+XanDNuvfLsK4ONoEsr+ZgsTBHE7FqTdKKX4FYItckJa1S5gGevM/lZyb4hEyQk/HKuhpc64d1xMA7RSxM4ZZNwoy2jkFMBNP9qMnSjRUTGHGSH4um30GUjWvet4VeSpAL9/pDqszX98y1uNO1qY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784848472; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H2GAc7mtrFpKl87p+adcJZhrkVbc1evwDywNzt1ulrU=; b=XmNppP7GXxw16qha8PZ/61Bynh93qlSCpaVzJ4NSPEbQ2jCGcszCY5klpExX88hckDEa+Iu0leAqjFXA9S8JPb48HORxK38/3Df5vZ5p+IsCTCB/T66Tx3HTHLiKdNBeR2jK7BYtFu3oeIi1MUW+QCA+VWUOFbxc1f+H7ph2g3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 178484847208119.07165851480113; Thu, 23 Jul 2026 16:14:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1369674.1618255 (Exim 4.92) (envelope-from ) id 1wn2cO-00088Q-Tm; Thu, 23 Jul 2026 23:14:20 +0000 Received: by outflank-mailman (output) from mailman id 1369674.1618255; Thu, 23 Jul 2026 23:14:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cO-00088H-QH; Thu, 23 Jul 2026 23:14:20 +0000 Received: by outflank-mailman (input) for mailman id 1369674; Thu, 23 Jul 2026 23:14:19 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cN-000865-BW for xen-devel@lists.xenproject.org; Thu, 23 Jul 2026 23:14:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wn2cM-00A9m0-Od for xen-devel@lists.xenproject.org; Fri, 24 Jul 2026 01:14:18 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a629fc2-e002-0a2a0a5209dd-0a2a4502ebd2-42 for ; Fri, 24 Jul 2026 01:14:18 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a62a049-6ca4-0a2a45020019-d561b338e4ac-3 for ; Fri, 24 Jul 2026 01:14:18 +0200 Received: from 186-249-149-197.shared.desktop.com.br ([186.249.149.197] 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 1wn2cK-003dsJ-D3; Fri, 24 Jul 2026 01:14:16 +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: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:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=H2GAc7mtrFpKl87p+adcJZhrkVbc1evwDywNzt1ulrU=; b=Ur7Yt83nqIk/wpx4DPoDQVuRHt YHYl3AzgDiwl86MiN+W7vEu1yvRIOwnFrEU+ugLCqkQ7j882mWh5ZxtXD4O3G/pDWEIuWXFk63NqA KZ9ggpizpV+1Ejg2taK9IFeWWpyxjkmCemu+mArn1f/uj7sTif1XYyQrJMCGU2eu030bFnfiRKo33 C5mQFqkWmMQ1xUJIQ31uOn00VgKp/6pTrRZgTh8JLqunabmQ1v+mA2mKAnSjDlTuVYmsCEfCXhG1g KavB3Eg5daAVTkG3we0F6mWOjUn/ECTmH51MXfDZtBnecP5cgKyWNfRmHAwWUwASkZiiGx6Rc9cc8 JyxilkEg==; From: Mauricio Faria de Oliveira Date: Thu, 23 Jul 2026 20:13:53 -0300 Subject: [PATCH v8 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: <20260723-pvh-kasan-inline-v8-3-c1f62c156f52@igalia.com> References: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@igalia.com> In-Reply-To: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@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 X-purgate-ID: tlsNG-720697/1784848458-F0AA52AC-CC2B6E7F/0/0 X-purgate-type: clean X-purgate-size: 1458 X-ZohoMail-DKIM: pass (identity @igalia.com) X-ZM-MESSAGEID: 1784848473369158500 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 Fri Jul 24 21:53:24 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=pass; 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=pass(p=none dis=none) header.from=igalia.com ARC-Seal: i=1; a=rsa-sha256; t=1784848481; cv=none; d=zohomail.com; s=zohoarc; b=RWnv6QM7PQ5NToeHXyp4dpxY/cXoa2nKROcuoQPA+1RyFKpz+KC3wUct7GVNuafwL7VRXiHro+tFlhkTOXkyxAqvtT/07/1pRJgbTDwXLYWwShshFbTm9cubD3tMU2qCLyIPOdVWQJh/E/Ohu0S4EgRIT4YM8OQEF9tlRjs1Q4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784848481; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zBAAE6UPiVcuOT4Hdx5zYoG+Uei+rPkEJSxQ4+nbtAc=; b=HHpDx1eYl6TIpqENFw83mCnsYTOpKptzCxdk33tod9X1pFzZN7UXGdsryM6LVL+XUkQi3ESab96k9L8qgUGqEaJMUdBaheQXW2kpk1tbXNE3aY0RBY1VuQ/pSd2ZOzphvxaPGpX9lqhIjx6pAt++DvkdYmzr7VbVNn9r2K+pMFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17848484815541008.6897882107725; Thu, 23 Jul 2026 16:14:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1369678.1618264 (Exim 4.92) (envelope-from ) id 1wn2cU-0008UA-69; Thu, 23 Jul 2026 23:14:26 +0000 Received: by outflank-mailman (output) from mailman id 1369678.1618264; Thu, 23 Jul 2026 23:14:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cU-0008U3-26; Thu, 23 Jul 2026 23:14:26 +0000 Received: by outflank-mailman (input) for mailman id 1369678; Thu, 23 Jul 2026 23:14:24 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wn2cS-0008Qm-Nl for xen-devel@lists.xenproject.org; Thu, 23 Jul 2026 23:14:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wn2cS-002RKf-4b for xen-devel@lists.xenproject.org; Fri, 24 Jul 2026 01:14:24 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a62a04f-bab6-0a2a0a5309dd-0a2a450cde10-0 for ; Fri, 24 Jul 2026 01:14:23 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a62a04e-f479-0a2a450c0019-d561b338ed68-3 for ; Fri, 24 Jul 2026 01:14:23 +0200 Received: from 186-249-149-197.shared.desktop.com.br ([186.249.149.197] 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 1wn2cP-003dsJ-Jn; Fri, 24 Jul 2026 01:14:21 +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: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:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=zBAAE6UPiVcuOT4Hdx5zYoG+Uei+rPkEJSxQ4+nbtAc=; b=R/gjQH2VSgkl4pACIKZMge3cYq mEx2tgfcbgdYNPGm9D38BSk4JWIG350FyRZnrJ91Nq159jjVPzrr1xs+sq6JH2ShauIebrVQxZP36 /MYI/+PJf26/q+EoxLTiK9i45/spWyDtNoWXurvB/GR/hhSeDa/E6VmDZKq6qiIZouVE59xVJimjh 7hUhbvPPVIHB09zhVgv1TmM+7R0x+q7HIkcsj5KkPE9EK1iKOx2hE1J1flI3vNqpufm5F9iKRFh/Y BHK8Vu1JA9EtzvVAx20riQAcho0e8+ppozUg/YXzlBOwMIuFxBBUn9kPS9/IxMiEX4MardB9mTFjI mRKV173A==; From: Mauricio Faria de Oliveira Date: Thu, 23 Jul 2026 20:13:54 -0300 Subject: [PATCH v8 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: <20260723-pvh-kasan-inline-v8-4-c1f62c156f52@igalia.com> References: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@igalia.com> In-Reply-To: <20260723-pvh-kasan-inline-v8-0-c1f62c156f52@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 X-purgate-ID: tlsNG-d25034/1784848463-00ACCA5B-16A44BEB/0/0 X-purgate-type: clean X-purgate-size: 1416 X-ZohoMail-DKIM: pass (identity @igalia.com) X-ZM-MESSAGEID: 1784848483365158500 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