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 7BF7E2417D1 for ; Wed, 1 Jul 2026 20:03: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=1782936211; cv=none; b=IkeJfHPjj8SwzDmhYBw+PIpy6GZTFbB2ZubZQCRWjo9n3eoaBoDlTtrOrdld5QhnCNussyhruo2h68YvmHakgDtVp64Kl7wZe8J67n4p9Cu/q+/BBq+ryZFGw06k00d1RUcAhf8gw8+hpnjMBwDODr36xN3ACLpBz5jyWzfPXeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782936211; c=relaxed/simple; bh=6c5n3wVK9x05XXSYMzEgjv0Jfz6UJuG2yrUE3Q195y8=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type; b=JEllIDkzbRl04+Kud7yolSKYCGW5NyPkbpGUuWTy1XsW2+ovLIAbCg4vD3fVnZ7Jbqs7CUC3GyFUXlIWjR4/YWhfNLdUV+tE95fK3Q4sNJ0wDo3u9mauoXhAE3M0Q+7bDu0gA9aRUmAErtUCWqekptPdsEydh9hpw/Y8aQzGnC4= 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=eXh1+rNK; 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="eXh1+rNK" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:Message-ID:References: In-Reply-To:Subject:Cc:To:From:Date:MIME-Version: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=h8lMXBcYlOyRE4pQKie/bg8QzKCuakYmyioerwHH1+M=; b=eXh1+rNK/Agog1Cz9/pcvxMMW9 sokenI9OuaFH9ZytFg5ZjyaJb9ougXQkL1fK0EnDBBYg+As7+DktzNVpksHIjBLtYNE3tciRfdB+J smM6qRWJljDWQgB7Aru2gemMvxXuBjar+KMOm0Qlvya6KdDj26dKF52iVQUFGtXtH4ho1uvxfx98u NMgN6oI8Qj704OXcOvEBXc6LMDalNRKcCTEpuT3DTLaNJoVZbUcOYciV7ESsTdmVPyyk8hLoRpaLX rGE/oMpiw9F06Rz+hwRNdaL0p34gLprKVUN6E5ZSAB/0E5+U2pipMQNYsusK7IiwU4DKj9gpYrddg Sx4pRuzQ==; Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine2.igalia.com with esmtps (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wf19G-007jIE-GQ; Wed, 01 Jul 2026 22:03:06 +0200 Received: from webmail.service.igalia.com ([192.168.21.45]) by mail.igalia.com with esmtp (Exim) id 1wf19E-008PvG-Bh; Wed, 01 Jul 2026 22:03:06 +0200 Received: from localhost ([127.0.0.1] helo=webmail.igalia.com) by webmail.service.igalia.com with esmtp (Exim 4.98.2) (envelope-from ) id 1wf19E-0000000DrRf-0aWf; Wed, 01 Jul 2026 22:03:04 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Wed, 01 Jul 2026 17:03:04 -0300 From: Mauricio Faria de Oliveira To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , kernel-dev@igalia.com, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Subject: Re: [PATCH RESEND v5 1/3] x86/asm, x86/boot: expose inline memcmp In-Reply-To: References: <20260630-pvh-kasan-inline-v5-0-52afc979be81@igalia.com> <20260630-pvh-kasan-inline-v5-1-52afc979be81@igalia.com> <20260701184014.GDakVfDhIgaIKurzTb@fat_crate.local> Message-ID: X-Sender: mfo@igalia.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Report: NO, Score=-4.7, Tests=ALL_TRUSTED=-3,AWL=-2.551,BAYES_50=0.8,URIBL_BLOCKED=0.001,URIBL_DBL_BLOCKED_OPENDNS=0.001,URIBL_ZEN_BLOCKED_OPENDNS=0.001 X-Spam-Score: -46 X-Spam-Bar: ---- On 2026-07-01 16:57, Mauricio Faria de Oliveira wrote: > Thanks for looking at this again. > > On 2026-07-01 15:40, Borislav Petkov wrote: >> On Tue, Jun 30, 2026 at 02:21:46PM -0300, Mauricio Faria de Oliveira wrote: >>> 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 ). >> >> This belongs ... >> >> >>> >>> Signed-off-by: Mauricio Faria de Oliveira >>> --- >> >> ... here, if anywhere. > > I'm not sure, as Reported-by and Suggested-by mean something different. > Oops, I missed the triple dash in your comment. That would discard the credit attribution when applied, AFAIK. So, still: > Maybe a simpler statement would do? e.g., '(Thanks to David Laight for > noticing the return value difference between inline and regular > memcmp())'. That gives credit while avoiding confusion with tags. Thanks, > >> >>> 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(-) >> >> Also, PeterZ has a point - we should group all __inline_ functions into >> shared/string.h and say why that is the case at the top of the header. > > Ok. > >>> diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c >>> index ac0f900ebc47efa81c92e1bb2010ea41677899c4..be454a6864225f3a972c3e81826b77ed4e8a57fe 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" >>> >>> @@ -31,10 +32,7 @@ >>> >>> int memcmp(const void *s1, const void *s2, size_t len) >>> { >>> - bool diff; >>> - asm("repe cmpsb" >>> - : "=@ccnz" (diff), "+D" (s1), "+S" (s2), "+c" (len)); >>> - return diff; >>> + return __inline_memcmp(s1, s2, len); >>> } >>> >>> /* >>> diff --git a/arch/x86/include/asm/shared/string.h b/arch/x86/include/asm/shared/string.h >>> new file mode 100644 >>> index 0000000000000000000000000000000000000000..422952152f533ad75b98f3873297b39c4f5e2477 >>> --- /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(). */ >> >> Please document it properly - what does 0 mean as a return value and what 1. > > Ok. > > cheers, > >> >> Thx. -- Mauricio