From nobody Mon Jun 8 05:28:16 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 0BECC3E1CF0 for ; Mon, 1 Jun 2026 17:57:29 +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=1780336652; cv=none; b=jGAtRrbmOFereQ5YVaRXgahQDWReA7bklU+VNOt1ZVq2tC407iJEP9QnNpc+6G4DWtziqe+IO1miArb3qcLE6bjYjtToK8uBJFMtv7aW6gR3NwIIjiVvNxyaPaF+5XgDmNOf+vdQ3Xn7m9W8zE0Eg8PEkbpjFcZ4pGHktrp1wCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780336652; c=relaxed/simple; bh=UHe9yIAfymXP4Vo9N52/bNfF39CN6KPFBEPmSLXOads=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ffIG7sH87VF4ktJZTvAgX3nnCjQAhoG/w4Rs2NqZBtAqo1maajrS9BmQYpkAlzNOGWmmPBUu9LZdIjqaLNIeyAPNBuaVCg5Sn5qLzRg60qoZW3bRrawQy0iqNjiNg2TVwimr2eGLkhjug8dJIep/l2AeCHe0EnGBkjvnlPx8yTM= 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=EHJdQBUi; 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="EHJdQBUi" 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=Fx35SUani/GVKASKFEJ/+AWnTbq4eOjUX4rrpFs2nCc=; b=EHJdQBUijfqeW75xYENnCyiitG aSW/C7eohgOyPfLX4vswQxZIHsKdUx7tuAgRpmb2hezwWACRoYXM3Xbt40adH3Nou8f5AaFywdMwV vpSiB2tnwLAZ7w/NeJKRgwY3CaKJxZcxJESbyQkuDYlXzSZkIAZXSSijkG1lQTwI5q4t7ghCaO7iD rhJD5He2nBSISPe+kBujxVMMhnoymh13nmRzdIuP+JGERtK1ZvP40zpmhMsDaOJZh2i9Bzv0rpvMu n+KasA3TvbjVVwfxaczM7blOiggqf69/zXzy6R3FJWJWDByVPI1+DOR2E2BBR6mBK1JguO5UUM5TR PgWMR2Lg==; Received: from 186-249-147-15.shared.desktop.com.br ([186.249.147.15] 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 1wU6tD-00B8VT-OY; Mon, 01 Jun 2026 19:57:28 +0200 From: Mauricio Faria de Oliveira Date: Mon, 01 Jun 2026 14:56:57 -0300 Subject: [PATCH 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: <20260601-pvh-kasan-inline-v5-1-c996e92dfe9a@igalia.com> References: <20260601-pvh-kasan-inline-v5-0-c996e92dfe9a@igalia.com> In-Reply-To: <20260601-pvh-kasan-inline-v5-0-c996e92dfe9a@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.51.0 From nobody Mon Jun 8 05:28:16 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 178033668222511.50169800809158; Mon, 1 Jun 2026 10:58:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1324054.1589742 (Exim 4.92) (envelope-from ) id 1wU6tW-0005un-9N; Mon, 01 Jun 2026 17:57:46 +0000 Received: by outflank-mailman (output) from mailman id 1324054.1589742; Mon, 01 Jun 2026 17:57:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wU6tW-0005ua-52; Mon, 01 Jun 2026 17:57:46 +0000 Received: by outflank-mailman (input) for mailman id 1324054; Mon, 01 Jun 2026 17:57:45 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wU6tV-0005u1-8D for xen-devel@lists.xenproject.org; Mon, 01 Jun 2026 17:57:45 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wU6tU-009LW7-LM for xen-devel@lists.xenproject.org; Mon, 01 Jun 2026 19:57:44 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a1dc7f7-5cb7-0a2a0a5109dd-0a2a4505b602-48 for ; Mon, 01 Jun 2026 19:57:44 +0200 Received: from [213.97.179.56] (helo=fanzine2.igalia.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a1dc817-aaa8-0a2a45050019-d561b338dea8-3 for ; Mon, 01 Jun 2026 19:57:44 +0200 Received: from 186-249-147-15.shared.desktop.com.br ([186.249.147.15] 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 1wU6tS-00B8VT-GR; Mon, 01 Jun 2026 19:57:43 +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=cEgkxcl8u5OoV3+U6fgPXtVoiK K5KdTkDU+Nr1qbOXTsmlB1w4/Z+ocUf/cB0C4SMvqYQMaG42IO4DQGKUYF8Wnxikg8wJjUBT9oyTs 3QCRppVmq//kvGym9w1BdJwacnaM2S/0lnajPE9XtFeIuVTtsPcUQ4f357NOxpKHLpBWA2dgiHP5d STKYun8cqFN4oPLi5Zy8T1VfFohp6OJY2kEwFpMLrSlSlUmuXWMumGY8eTVd2AjVSErjkMyR89pgp gmArjxv0KoGvHpLDaJtsYYrwGuCnkWO5UJql4jhB5FlqR3Tw/yCThk1Qpl89X2FWxf/REH1JyoCjP 9ul/6pkQ==; From: Mauricio Faria de Oliveira Date: Mon, 01 Jun 2026 14:56:58 -0300 Subject: [PATCH v5 2/3] 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: <20260601-pvh-kasan-inline-v5-2-c996e92dfe9a@igalia.com> References: <20260601-pvh-kasan-inline-v5-0-c996e92dfe9a@igalia.com> In-Reply-To: <20260601-pvh-kasan-inline-v5-0-c996e92dfe9a@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-c201ff/1780336664-E119B443-28B9E2BB/0/0 X-purgate-type: clean X-purgate-size: 1458 X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1780336689486154100 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 Mon Jun 8 05:28:16 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 4135E3E316D for ; Mon, 1 Jun 2026 17:58: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=1780336686; cv=none; b=D98F7+KiK6DxjW3m6nqLPmXTEJKy+fyBkjP3VCs0bKrhSJzjH4mURZjiuJK6uJFlc6+FGJTndfpXtc9BB4cSKQPkLoEqXXj62qys7AfRZNcRVUee/DU1KUPTqn95gbBEaSIuiK3H/VJh4AL5fPQ65sWq1w16oB+Udvupzn75dbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780336686; c=relaxed/simple; bh=VvT8BiI0iQnZsJGpQb4aYRptJ9pvc866Z87I9s8rAWE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GpHv4Fd+Jm9SnyH69JgaU+la3vnOOKpw4kJu1zBUOu4o05IWYuPvAdEi1mL+cmPmhGQPaYEwlJHKYxnCY4W1n02pYfUeWOvm7l3md44BbAVob1ZzRyb70bt5wFLJ2nJwZRmIQ/3Q7pVltDOuhFxWkw/AqR1KVvct+DuCYtRncrs= 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=IwtnTfG8; 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="IwtnTfG8" 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=gVOYRAOO+Mh5oBl1QeoqitXujUCY2P63meD8Qlv2Ukw=; b=IwtnTfG8tJ/FMypnBeTUkihO38 HVJ13BsRTPj0/nrXa5tUXqDm37o9WVph3mB0YM1MDMx7ZHXBg3CrTqMN6miuBsG/4bXNZA+5InYVL a/Uu4xwqoD3CjtDi8GYVIfqEwoXGhxpTxZ93NLMaYb1PSzMTmyM7pXxmCo9w24bFRTUDG+/hmPXRc O4bYpQiE4rmbqr5nwBWImZWYkDLKWMtSPgcNG7o0WnQ7/QulbcYqcax1H1yo4DBM2GrtyngrZ7gA3 f1uBNBbuR6ETdxle9N1OmqQmHCu6s+txURhbgBOe+u9sTukzSAdPFwX2hL2Mgvn6/VfCWT5+nSgpD DWHZEHTA==; Received: from 186-249-147-15.shared.desktop.com.br ([186.249.147.15] 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 1wU6tl-00B8VT-OV; Mon, 01 Jun 2026 19:58:03 +0200 From: Mauricio Faria de Oliveira Date: Mon, 01 Jun 2026 14:56:59 -0300 Subject: [PATCH 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: <20260601-pvh-kasan-inline-v5-3-c996e92dfe9a@igalia.com> References: <20260601-pvh-kasan-inline-v5-0-c996e92dfe9a@igalia.com> In-Reply-To: <20260601-pvh-kasan-inline-v5-0-c996e92dfe9a@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.51.0