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 33B7337B03C for ; Wed, 20 May 2026 21:12:56 +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=1779311578; cv=none; b=of/1z8S4TPfFb+ciD+rxJ01Zstk3Kt4IrYR4D34OM/bJpL4Dyt9mKQM35m/rqEPX2uJ5akmYW7B4+CcwFoffqeZCkUTXaOpkLOQSyf76oIlfBXVvJzX/FAsJk2zzC47j0VIIjaHS0eLHDgkENv8A6hqjw+USN2eKZJm4Co7Y9Zo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779311578; c=relaxed/simple; bh=o1vdctGaqu+Oe1fNnNQVxKJIgmAXKes0ejKdyn47QyU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=biNv//qlXy38UWxU6t5/0gGDtkOvjh7U12g+wi/274ZOcKIByyaeDuWGSyzZntoD+MCTUK/6UOIhC8d5oyYWosF17sLxUg2VFM9xzmps2sJj68OGNq+5SBCeVjqoGlckQHdEdg2NBmtj8EeKhrPkBM7xrWxTtl1TKW2xxI2pfH4= 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=k0wISdlG; 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="k0wISdlG" 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=QWDJ2OzZaJom0a60jnwGYvvAozNLoOMpVxRWdTCYrLY=; b=k0wISdlG2PRGKql4/MXlPi0po4 EfelhhvuoBBZAUZY1KGzV8lbvG53iTgc3x9kKP66naKIZNo7xHGstbidJ6sMr0YL4w3vMBC/hnTwv 0GdgVAjRGCRlGhMoW+ofgtEzcU6REh6OX0BSJVUP00+BD7qD5i1Us2ijJlI3NbLqyG3FyoZ2zCXps N2ETl/O8vHJyASsxVO2zCNbjpA/m9aYC+q1GAqVJufiNSgYUQJCEq5+Uo8aK1A0GdukhrAs/TosIB xdFYNv7CSitO+KF2Rwm1wI8dc8b99jTvpIBDZtbZjWMclDN64XwsDUXbzEnJXMsZnImd8KZkl+F7P 1HCZg+bQ==; 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 1wPoDS-0041Tq-O9; Wed, 20 May 2026 23:12:35 +0200 From: Mauricio Faria de Oliveira Date: Wed, 20 May 2026 18:12:05 -0300 Subject: [PATCH v3 1/4] x86/asm: move inline string functions to 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: <20260520-pvh-kasan-inline-v3-1-bede769c6ec7@igalia.com> References: <20260520-pvh-kasan-inline-v3-0-bede769c6ec7@igalia.com> In-Reply-To: <20260520-pvh-kasan-inline-v3-0-bede769c6ec7@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 , kernel test robot X-Mailer: b4 0.14.2 In next patch, inline string functions are included from 'boot/string.c'. Using the header is problematic for a couple of reasons (*) (i.e., build errors), which can be addressed, but introduce unnecessary complexity and regression risk (beyond these _found_ couple of reasons). Using a new header is simpler and transparent to existing users of , with less changes to 'boot/string.c' and its users (eg 'boot/compressed/string.c' and 'purgatory/purgatory.ro'), which minimize regression risk. No functional change intended. (*) Reasons not to include in 'boot/string.c': 1) 'boot/string.c' is built for 16-bit/real mode thus some type and word size errors happen when include, e.g., . This can be addressed with '#ifndef _SETUP' (defined by 'boot/Makefile'). 2) 'boot/string.c' is included by 'boot/compressed/string.c' which is the source of 'purgatory/string.o', linked by 'purgatory/purgatory.ro' (CONFIG_KEXEC_FILE). In 64BIT, includes , which references __memset() and __memmove() with KCFI_REFERENCE(), ie, __ADDRESSABLE(); however, 'purgatory/purgatory.ro' is not linked with implementations. So, CONFIG_KEXEC_FILE and CONFIG_CFI without CONFIG_KASAN hit errors: >> ld.lld: error: undefined symbol: __memset >>> referenced by string.c >>> arch/x86/purgatory/purgatory.ro:\ (__UNIQUE_ID_addressable___memset_0) -- >> ld.lld: error: undefined symbol: __memmove >>> referenced by string.c >>> arch/x86/purgatory/purgatory.ro:\ (__UNIQUE_ID_addressable___memmove_1) (Note: this is not hit with CONFIG_KASAN because 'boot/compressed/string.c' adds aliases __memset()/__memmove() to memset()/memmove() in that case.) This can be addressed with 'CFLAGS_string.o := -D__DISABLE_EXPORTS' so to disable KCFI_REFERENCE() in 'purgatory/Makefile' (it removes CC_FLAGS_CFI anyway). ... However, since a change in this series would need more changes to address errors it causes, it is reasonable to change the series not to cause them, by using a separate header with _just_ inline string functions. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202605140922.q7IlUv7o-lkp@intel.com/ Signed-off-by: Mauricio Faria de Oliveira --- arch/x86/include/asm/string.h | 21 +-------------------- arch/x86/include/asm/string_inline.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 9cb5aae7fba9ffcf0f5af8f939d30467750ccaa9..8a849bb5d0c7100a2a1820ec0af9fc9f850727fd 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -8,25 +8,6 @@ # 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; -} +#include #endif /* _ASM_X86_STRING_H */ diff --git a/arch/x86/include/asm/string_inline.h b/arch/x86/include/asm/string_inline.h new file mode 100644 index 0000000000000000000000000000000000000000..ffcfa6583d2bc7b91d078888518d0e80248af940 --- /dev/null +++ b/arch/x86/include/asm/string_inline.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_STRING_INLINE_H +#define _ASM_X86_STRING_INLINE_H + +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_INLINE_H */ -- 2.51.0