From nobody Thu Sep 24 17:02:47 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 BB9B7367281 for ; Tue, 22 Sep 2026 01:36:14 +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=1790040977; cv=none; b=YkTjlPQtOLIHdg9a1elZy6DU5cX2NBI9UryIRuGYUYH2DysodYvqzFqrrV8QIx8KENYsuq77hVNh353u3wOjNuHVY8eneARKK+4mHljNsml5ew6CZ6l/SYCuSm2DNOWG4lW9iADZIr/WKSM/FP2LmUn9eWRUFSnM4zlxvCinLYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040977; c=relaxed/simple; bh=3pQhyUHhZ5ongcsuf1OXS70a+7ZXbEBB0BXBVEfBvZQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OggBV52jQQhg9hSkfkU4YwIdeBG0ZlGyyjhRwQmkKxeEXUj3MxRczMCD0l5Rjc38ZgFPt+ZvAstl5y1cyqflqR1yFXsOdBZkENsl78+ihd8wBBJXMUUYtzttR46nkfoTGXuT4xy31wGaSu4A9pTD/LYyc4bivD2RXYfojCmc9sI= 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=CrVUaQ0+; 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="CrVUaQ0+" 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=wN61/NMUXl8+9R6hcjMozN8cH7kE8ssen0RwmNOyhaw=; b=CrVUaQ0+B87GdmscCHTnNP8VEF +qdlqxIhIySV9oSq9UbjJGCumPJ4KKHHlB77hnREOlp4czDEjNMYy24Y8eXEYPYbFVWGU6Bhe0r0O eXI8EUm+awT/31kIviX4jw87FCtRKUq778TW4GMw0jRNAZLCOHqn0gTxh+XpWo4tJSrA+Slu7zKmC InK+jrO8tkCBmcldBgv2KVpZ+FZVjbX9sOjWOzQMMBxPVV2inqpbQkrbofSozJ02mGnD81wWTKoKP KXESrL2cNTaAqNgrS5nzkqoKQAjJX+CM0yU2BvoMvGPj+OQAM6lwOFbYgPnb/Frw8FROzTo2IhQIH nvRatv2w==; Received: from 186-249-150-130.shared.desktop.com.br ([186.249.150.130] 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 1x8pQV-005NkF-4j; Tue, 22 Sep 2026 03:36:07 +0200 From: Mauricio Faria de Oliveira Date: Mon, 21 Sep 2026 22:36:32 -0300 Subject: [PATCH v10 1/4] x86/boot: comment out and document redundant "cc" clobber in 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: <20260921-pvh-kasan-inline-v10-1-08da47943d8e@igalia.com> References: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@igalia.com> In-Reply-To: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@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 The "cc" clobber remains recognized for source compatibility, but it has no meaning anymore; it is automatically generated without condition-code constraints (explanation in [1]; related code in gcc [2] and clang [3]). Comment out the redundant "cc" clobber for documentation purposes. Reported-by: "H. Peter Anvin" Link: https://lore.kernel.org/all/5e19b195-0ca2-4510-81cb-497b40e4aaf5@zyto= r.com/ Link: https://lore.kernel.org/all/57b0d188-b256-bde4-43e6-99dae4f59d60@suse= .de/ [1] Link: https://github.com/gcc-mirror/gcc/blob/78d4ac73dd391005b895a6148cd983= 1e28e1208b/gcc/config/i386/i386.cc#L25355-L25363 [2] Link: https://github.com/llvm/llvm-project/blob/6dfe1677ab8dffbc6ec13d53a1e= 0215d75147689/clang/lib/Basic/Targets/X86.h#L299-L301 [3] Fixes: a8c171c107c0 ("x86/boot: Add volatile, clobbers and zero-length test= in memcmp()") Signed-off-by: Mauricio Faria de Oliveira --- arch/x86/boot/string.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index 1632d40e1f545ae0665597069b568ea6b6c263e5..e10260ed58b69fc734a4e63f157= 85a643f414441 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -36,11 +36,15 @@ int memcmp(const void *s1, const void *s2, size_t len) /* * 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. + * + * The "cc" clobber has no meaning anymore, just source compatibility. + * On x86 the flag status bits are automatically added to the clobber + * set when there are no =3D@ccXY constraints. Keep it as documentation. */ asm volatile("test %3, %3\n\t" "repe cmpsb" : "=3D@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len) - : : "cc", "memory"); + : : /* "cc", */ "memory"); return diff; } =20 --=20 2.47.3 From nobody Thu Sep 24 17:02:47 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=1790041007; cv=none; d=zohomail.com; s=zohoarc; b=Ocxh3YrZyrpO45eul3oqoXPzYH24Su9MEaEKav2uWmVw83ANsJ8apbP/982L9hsNdNyS3HtmQXpGmCklQ5rmZXtiSTxYjdAI5oggt+So+Vu/lAg1msVvxly/mu5c+v9QMVfmrlHLhXkAsTMj6LW4iXJTzbmKUP5sQPfFeFbT2o4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790041007; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j9CxFCWuPrvGlLqznnNoJgjx2OHznuUku/3wRXkyArk=; b=VLgVZekVXyy1oIa4bJg7+zJzeKsIpCVSJE8fyqFYmZu9hshLl8VqzbFexognulryxRF/hj8OAKOftlfbU5y9J0IbNqNo64bxlyk1+J/EeYkndFSE0/+HZbYyQlsPRvg0+AnpfNWaMEU89SnIsJqhn6D9s+4sOx3jc5L6o5Cx+lw= 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 1790041007540752.9006269414708; Mon, 21 Sep 2026 18:36:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1427980.1650691 (Exim 4.92) (envelope-from ) id 1x8pQh-0004j4-AG; Tue, 22 Sep 2026 01:36:19 +0000 Received: by outflank-mailman (output) from mailman id 1427980.1650691; Tue, 22 Sep 2026 01:36:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x8pQh-0004it-6Q; Tue, 22 Sep 2026 01:36:19 +0000 Received: by outflank-mailman (input) for mailman id 1427980; Tue, 22 Sep 2026 01:36:17 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x8pQf-0004hr-GG for xen-devel@lists.xenproject.org; Tue, 22 Sep 2026 01:36:17 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x8pQe-00Ee9j-Kc for xen-devel@lists.xenproject.org; Tue, 22 Sep 2026 03:36:16 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ab1db62-e002-0a2a0a5209dd-0a2a4503e1f0-44 for ; Tue, 22 Sep 2026 03:36:15 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ab1db8f-fae8-0a2a45030019-d561b338d8ce-3 for ; Tue, 22 Sep 2026 03:36:15 +0200 Received: from 186-249-150-130.shared.desktop.com.br ([186.249.150.130] 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 1x8pQc-005NkF-0M; Tue, 22 Sep 2026 03:36:14 +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=j9CxFCWuPrvGlLqznnNoJgjx2OHznuUku/3wRXkyArk=; b=L0/vA5CkOQE34d8kurstyXKXMd lHLDh/ey5KyOtpiMjY+BGOESVYS31Wt/ziwV+XCmlCgmrWP3DVjLKHR1/SjTBaerDhXthhtLYKjPp ccpPKU0bquKjhsW3FRuX414I6hM/xsBkgIMXTVwOHUWgYOF6oyHfPn2jV6glcREYLCz/C4AyurK+y GFlgIqH89YGxE77Su4xXzx27M5P7IxSe44MF7I6vXW2Mkm6OAIlO4uHwbybv8ZD2lOpHFoPs17HIH hQg1Pd3WXC5MklfBe6qmbxxYLfqLNw+MfB+aYCHNYFCb1L94385Gg0neNNicnYmQlk5Q8lwBjUodw yEheJjVg==; From: Mauricio Faria de Oliveira Date: Mon, 21 Sep 2026 22:36:33 -0300 Subject: [PATCH v10 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: <20260921-pvh-kasan-inline-v10-2-08da47943d8e@igalia.com> References: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@igalia.com> In-Reply-To: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@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-33051d/1790040975-6FCC34E9-584DA3F3/0/0 X-purgate-type: clean X-purgate-size: 3044 X-ZohoMail-DKIM: pass (identity @igalia.com) X-ZM-MESSAGEID: 1790041008674158500 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 | 17 ++--------------- arch/x86/include/asm/shared/string.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index e10260ed58b69fc734a4e63f15785a643f414441..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,21 +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. - * - * The "cc" clobber has no meaning anymore, just source compatibility. - * On x86 the flag status bits are automatically added to the clobber - * set when there are no =3D@ccXY constraints. Keep it as documentation. - */ - 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..6291653fe629babf15e29060b01= 3d357d8eacf4c --- /dev/null +++ b/arch/x86/include/asm/shared/string.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SHARED_STRING_H +#define _ASM_X86_SHARED_STRING_H + +/* + * Returns: 0 (equal) + * 1 (not equal) + * + * In contrast, the regular memcmp() follows glibc return value semantics. + */ +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. + * + * The "cc" clobber has no meaning anymore, just source compatibility. + * On x86 the flag status bits are automatically added to the clobber + * set when there are no =3D@ccXY constraints. Keep it as documentation. + */ + 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 Thu Sep 24 17:02:47 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=1790041007; cv=none; d=zohomail.com; s=zohoarc; b=VIoSNm2JTIhiM9fEDch98QZdnzOolL6X5BWV6QWHbxMO8kji//Ik7DAQW5ZsPcfTJ8oXpWbGSomMli8Ms7MfOrvVSGcUhSqNuAqPKoJg7z8RWsiXk/soDI5vo0GXCos2shoOHbBQlk0rwkzVQmGZQ4h1ShmhznJ3ytRWsYHNpEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790041007; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/0RnjeWeqK4aiVrc0W7dEG+Kp++1YdIPUBuPx6eJkJo=; b=FF06UepuMXNXyMPEA2HTUEKzEXoWeqEhif17QKIXaBhrIr3k1682S1OrFu/hTTvW79yoXZ8NovmTW6Ix0K/tHwL28xEq2uFXnhXBFdo0QQB6wWrKkuAak8fB7cxPE8A0lh92GeJWkeVGZH5ZpGL3aMxLdr2gzOJpegUvA6ChsZU= 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 1790041007325752.5507895889057; Mon, 21 Sep 2026 18:36:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1427983.1650700 (Exim 4.92) (envelope-from ) id 1x8pQo-00051i-I4; Tue, 22 Sep 2026 01:36:26 +0000 Received: by outflank-mailman (output) from mailman id 1427983.1650700; Tue, 22 Sep 2026 01:36: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 1x8pQo-00051U-Cd; Tue, 22 Sep 2026 01:36:26 +0000 Received: by outflank-mailman (input) for mailman id 1427983; Tue, 22 Sep 2026 01:36:24 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x8pQm-0004zp-FB for xen-devel@lists.xenproject.org; Tue, 22 Sep 2026 01:36:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x8pQl-00172J-SX for xen-devel@lists.xenproject.org; Tue, 22 Sep 2026 03:36:23 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ab1daab-2eae-0a2a0a5409dd-0a2a450aec12-48 for ; Tue, 22 Sep 2026 03:36:23 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ab1db97-f2d2-0a2a450a0019-d561b338b002-3 for ; Tue, 22 Sep 2026 03:36:23 +0200 Received: from 186-249-150-130.shared.desktop.com.br ([186.249.150.130] 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 1x8pQk-005NkF-GM; Tue, 22 Sep 2026 03:36:22 +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=/0RnjeWeqK4aiVrc0W7dEG+Kp++1YdIPUBuPx6eJkJo=; b=piMg6SB47ayxfzarEnOYpmtKR1 uTyjJv5bKFQt0uxq8Ag9kFZz9ttM441plX3lbFarwhxbBiykQOHq7yMtEeKdDfdiv1Qz4f6b7WxPI re8ZfcQihykfWDfPCO7HAXelkL09g8BbUqwzyjjRalKtqJ3Zk/cCH0sjfA4fSYHw7T3jiqshaYj5a JrvKdiI3RLfmxVtbnq/svAvDHhrmtXlZWsOxxOYAv8sTx2hFZGK8Byn6bwXfGbtbvtODi7GFGtDfa XwIFcmSatLglcOYEcod85tibWAYZct+YJAhZldjDa6mOmc9MlMshgoWNG981zxVioPDZYwzoyUajw IGF/86yQ==; From: Mauricio Faria de Oliveira Date: Mon, 21 Sep 2026 22:36:34 -0300 Subject: [PATCH v10 3/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: <20260921-pvh-kasan-inline-v10-3-08da47943d8e@igalia.com> References: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@igalia.com> In-Reply-To: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@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-4011c0/1790040983-50ACCCFC-3F9B2406/0/0 X-purgate-type: clean X-purgate-size: 2172 X-ZohoMail-DKIM: pass (identity @igalia.com) X-ZM-MESSAGEID: 1790041008660158500 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 6291653fe629babf15e29060b013d357d8eacf4c..6bef90d62a21138ec56c939ffc4= 74732999bf465 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; +} + /* * Returns: 0 (equal) * 1 (not equal) 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 24 17:02:47 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 37E951FBC8C for ; Tue, 22 Sep 2026 01:36:38 +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=1790041000; cv=none; b=oGuBIxGpU+zJ/73pdNYVAK/p+Qbm116PHSBfa+z7EG3DE3UahY81CeMiRFLfAf8FxF9uZVsiuUGk28lVUPGrTzPMgkxUpLpttES63eCpQ6aqC5JuaPYnUNLzFdIrLt7vTEzp7262pUTgpxTOoHaQSlTCv7etNWnEh7RWQhiuJjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790041000; c=relaxed/simple; bh=ujpK8OEW3FZmpmkP0A/G1nyS8tVAZhHHIDpsIr1cNIE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H+luy/sBB8iiEmYLVwcyNORAOn9fWzPeoFRu1Ja7DZHeNz8O6nKkHk/xGv5TMGLDI3DYMI+LKFp2c9BvG5ZoSC9fmBtZSLQmkvONaYQHUpyEKhczTb1N5paQIpt1Ztynbo6KRAC7T1CQTAHvx92BMaHpl7qpmjUTCKM+lnMppt4= 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=IpObFzvx; 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="IpObFzvx" 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=vD0k0Ck20NkaSxC+0yD9Mf/6md9yMaogJma8MOuOCCM=; b=IpObFzvx6OMOkVteh8tSW55725 2zMdnjO0AJ2F0aI9fUvhxpgfdu/a6I9p52vKandRvZpy811pd5QsAzeLT/t2csxIKraMucDaL0qK3 wDdUbce7+tYpFzUxggUko7j5ytHpdkWEYoxjRl5FsXaFi4DWreCxw5pC9s08IqQZAL4fpxpoKyO// 15N6GxwY/ukBdeX1IJse6gmHiNXxbBgb7YcSysNJZYCe4TD5O4Ob8SSyVot0nDIzg2M0rdiW/5UOj C5ZRct7ITrl98hI4NnU1kPPKGt5yondaXCc53o1YApMrXrXBuUJT6pwyMqUPIpmBlKI/weInDJwpV XY9F7PhQ==; Received: from 186-249-150-130.shared.desktop.com.br ([186.249.150.130] 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 1x8pQs-005NkF-MI; Tue, 22 Sep 2026 03:36:30 +0200 From: Mauricio Faria de Oliveira Date: Mon, 21 Sep 2026 22:36:35 -0300 Subject: [PATCH v10 4/4] x86/cpuid: fix unbootable VMs by really inlining memcmp() in cpuid_base_hypervisor() and 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: <20260921-pvh-kasan-inline-v10-4-08da47943d8e@igalia.com> References: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@igalia.com> In-Reply-To: <20260921-pvh-kasan-inline-v10-0-08da47943d8e@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. The instrumented out of line function performs a memory access to a region not yet initialized by KASAN, as it is still in the PVH kernel entry point. For testing purposes, if the size argument in cpuid_base_hypervisor() is reduced from 12 to 8 the compiler decides to use the inline implementation. In xen_prepare_pvh(), it (still) decides to use the inline implementation (at least in these compiler versions), but it is not guaranteed to remain. Switch the builtin to the inline implementation to address this. Fixes: 416a33c9afce ("x86/cpu: fix unbootable VMs by inlining memcmp() in h= ypervisor_cpuid_base()") 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/include/asm/cpuid/api.h | 2 +- arch/x86/platform/pvh/enlighten.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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; } 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