From mboxrd@z Thu Jan 1 00:00:00 1970 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 82D3D400E0C for ; Tue, 26 May 2026 14:53:13 +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=1779807195; cv=none; b=qlxr6T9Gl0yBcL/UyTXoYD0u/3ftThRAC3Lh6LVmqdwAZ2DPQHBudJif3LYMGQog+3EmiXxgBjNvNXWP6vaPN11eC38iLHTKQ2UePbJfGFIaynf8w3CJHz0UdN8uyRnrAvx0G5nH9JlbmGzlTdXOD621CtHOo9KETY40Cx1ARdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807195; c=relaxed/simple; bh=Basg6a2TPqzJwyH2ZRpWZyteT1hkK4BdLH3njV8NH1E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hK2x9MrL4FILB/qzvoH1GKDU2+ol+M3r3TWDVpakRIfhetMCM6Q425xM/5by28zSBYH8aXlO0ZxD3C+N8YU/JlRzsLhx0SKIYX8sixyD0GGvW/MCjwg7avf5MvhY2qDlph1MswEcpA49Xe5kfhXCXpeY/RkXwn+mcC8XL8qBIz8= 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=OesFYrIB; 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="OesFYrIB" 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==; 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 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() 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: 7bit 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 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 hypervisor_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..2d9f3d4d63de6e721f275d9e80d372edbdfedf30 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 == 0 || ((eax - base) >= leaves))) return base; } -- 2.51.0