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 C2FB5EED8 for ; Wed, 1 Jul 2026 19:58:35 +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=1782935918; cv=none; b=KMw5glXkcHFbO6aohnD9EYFWwxo9wrN+va6KaAyAs9GptDj5J5VQRTmFgrrnpBKFSsCL5+SDtVMM2gZFsCZYjXaMMscfw3untSCftO/+Hcum53QqZP/QR9cBhmNF+UNPxc/+MD8oLxeVZpqht0pZI7d3L7dvmbFpfXud5CU9FrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782935918; c=relaxed/simple; bh=zes7gGTPsR3i3aaBTJUgszdc4r28FykycoeV9+FJyuU=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type; b=kSKHqzXusXMwoA7MU3t/kAip6KLylEZ/OFO4GWX3+Owm9ZoLA95KZUqvBUYqH9YHzSEkhAUOwF1iiXeNyNeCfncHHdeobXd3qCdJKBbFH05+dfnIG6+fMQmVQzaLNsyW7HblC5PEOo2zMSIINmQ34ufOEXsSzqOM+CaZLBj/JBk= 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=OqayeKvT; 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="OqayeKvT" 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=dVUHDiCCPenmpG77txOrHpZNog3IAMhNPv3S4y6Xv3I=; b=OqayeKvT0MXw8cB8Ns1EfUMh7J s9QSbqteOd0Zwx51NK2xKTgD/wxJoiuRr/zNDkqCUC+FpqsfJwDrlZDZiWZOCmvru6uekZtL1/ads qVqnNAidpHDdmgxhVZuojnbw7BfuDxTdYLrU5A5B8Pv1yfvUq+rFUnxyfzWEZgc+8fWR78Es4+mSC sFR22dLv8h7lEIAyxZpcucX6Kjw/TB31ckB2tcea+6rawvSF8Qtmcpbirc0zdevzK/tp6p1GU+h5h bIVtLs+PEr+QGcADMLMHx15QUNWgB/s+7TnIgfpPA1y43dYTpGdgkI/+slYgRKJIGRyUCg206mH5t Eor31ldg==; 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 1wf14K-007jBt-Bw; Wed, 01 Jul 2026 21:58:00 +0200 Received: from webmail.service.igalia.com ([192.168.21.45]) by mail.igalia.com with esmtp (Exim) id 1wf14I-008PZ7-7c; Wed, 01 Jul 2026 21:58:00 +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 1wf14I-0000000DrOF-026U; Wed, 01 Jul 2026 21:57:58 +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 16:57:57 -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: <20260701184014.GDakVfDhIgaIKurzTb@fat_crate.local> 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: ---- 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. 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. > >> 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