From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 D975614A601; Thu, 11 Jul 2024 08:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720685617; cv=none; b=GsYgCJtBtuTAlwUr/C8gCQ/Z5oXuj6Q+t3JdB/oeqvoOg4s57KGhqxjFwIQY24nbLnZU40sJ+5/fKId7MZMg+LXFckGtaSoV8mlp1Bg9gIN1GHVwpJegcCqf4y6MhSqWI6N6QdJ/QYJlKv0xECXpQExkNp8nweElzn3m9rT1ID4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720685617; c=relaxed/simple; bh=xsG4j8CUM95pevTZX83N2m0JtsePZz3hLlfpPlr4wKk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=efdy6vDwX88G5L2iQ2jxeAg9bDO7dpDRQt8aBPhcZPQXB52Od6ZnG4qaJFWQuVQr1Tgb/rIKfZ4nNTspXXLoS+k4s5MKBQ+pNsO8Vw0uH59CqP2/ELtNmT7rWtknZnO8BENv3bqrLrTChrFvGvvKD4aXrrYG5SskNl6LvymPWaY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=e32/Jtfc; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="e32/Jtfc" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=60rL9HOaet6vlUzwQrfSKu77VABHNI32SxBnaB3w5cU=; b=e32/JtfceHqCWcvBeGyYpWTATg D3/hTYRoWVcR1zO5HI67cewxepVSWuwZZ0k9hIXtNI4rSFVTN1WSZ+/wcuOx26UPaYRUo0F75uf0R D5A7ZoZGkbM9t+Qw06DJQiRBJuNntVye7JqYZl+GOQOsYz1dLKszDJGoAQweVHgv4X7Ag2xx0PXm/ RBd9N7T174wp/Dfewj9LTvJntoj8f3TLfs6dsUXp1/+Qw5FngxuOFtugs24UxuucOEG8ucdoAYwll atQjPQivw1uy46YLS7b7yi75lU1zbymPYcMB1XoVT4qy6UitgV3wEwqtUZzXSVKJjyk5PmT2Dq2VW 65RHdjcw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRovW-0000000Ak7d-17YF; Thu, 11 Jul 2024 08:13:18 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id DFA3830050D; Thu, 11 Jul 2024 10:13:17 +0200 (CEST) Date: Thu, 11 Jul 2024 10:13:17 +0200 From: Peter Zijlstra To: Alexander Shishkin Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ard Biesheuvel , "Paul E. McKenney" , Josh Poimboeuf , Xiongwei Song , Xin Li , "Mike Rapoport (IBM)" , Brijesh Singh , Michael Roth , Tony Luck , "Kirill A. Shutemov" , Alexey Kardashevskiy , Jonathan Corbet , Sohil Mehta , Ingo Molnar , Pawan Gupta , Daniel Sneddon , Kai Huang , Sandipan Das , Breno Leitao , Rick Edgecombe , Yian Chen , Alexei Starovoitov , Hou Tao , Juergen Gross , Vegard Nossum , Kees Cook , Eric Biggers , Jason Gunthorpe , "Masami Hiramatsu (Google)" , Andrew Morton , Luis Chamberlain , Yuntao Wang , Rasmus Villemoes , Christophe Leroy , Tejun Heo , Changbin Du , Huang Shijie , Geert Uytterhoeven , Namhyung Kim , Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v4 02/16] x86/asm: Introduce inline memcpy and memset Message-ID: <20240711081317.GD4587@noisy.programming.kicks-ass.net> References: <20240710160655.3402786-1-alexander.shishkin@linux.intel.com> <20240710160655.3402786-3-alexander.shishkin@linux.intel.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240710160655.3402786-3-alexander.shishkin@linux.intel.com> On Wed, Jul 10, 2024 at 07:06:38PM +0300, Alexander Shishkin wrote: > From: Peter Zijlstra > > Provide inline memcpy and memset functions that can be used instead of > the GCC builtins whenever necessary. > > Code posted by Peter Zijlstra . We haz a tag for that: Originally-by: Peter Zijlstra > Link: https://lore.kernel.org/lkml/Y759AJ%2F0N9fqwDED@hirez.programming.kicks-ass.net/ > [Missing Signed-off-by from PeterZ] There, lemme fix that for you: Signed-off-by: Peter Zijlstra (Intel) > Signed-off-by: Sohil Mehta > Signed-off-by: Alexander Shishkin > --- > arch/x86/include/asm/string.h | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h > index c3c2c1914d65..9cb5aae7fba9 100644 > --- a/arch/x86/include/asm/string.h > +++ b/arch/x86/include/asm/string.h > @@ -1,6 +1,32 @@ > /* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_X86_STRING_H > +#define _ASM_X86_STRING_H > + > #ifdef CONFIG_X86_32 > # include > #else > # include > #endif > + > +static __always_inline void *__inline_memcpy(void *to, const void *from, size_t len) > +{ > + void *ret = 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 = s; > + > + asm volatile("rep stosb" > + : "+D" (s), "+c" (n) > + : "a" ((uint8_t)v) > + : "memory"); > + return ret; > +} > + > +#endif /* _ASM_X86_STRING_H */ > -- > 2.43.0 >