From patchwork Fri Mar 3 14:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 13158849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F8EDC64EC4 for ; Fri, 3 Mar 2023 14:21:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F17B6B0078; Fri, 3 Mar 2023 09:21:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A1E56B007D; Fri, 3 Mar 2023 09:21:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 168EC6B0080; Fri, 3 Mar 2023 09:21:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0666F6B0078 for ; Fri, 3 Mar 2023 09:21:55 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DD421ABA25 for ; Fri, 3 Mar 2023 14:21:54 +0000 (UTC) X-FDA: 80527800948.15.4C4A661 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf24.hostedemail.com (Postfix) with ESMTP id E913F18001C for ; Fri, 3 Mar 2023 14:21:52 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=tlAJFWQb; spf=pass (imf24.hostedemail.com: domain of 31gACZAYKCAcnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=31gACZAYKCAcnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677853313; a=rsa-sha256; cv=none; b=jc8yYea5TPWRJ6TX1ZJJX6Wj2GNMe1MeBaYwL117jMP/NEZn+jwe+qjIgmoftROChxPLcD WLq+2bLZBWYWPeTpGHAhm1Zc+SKb8VOLD67T7/4BJCwpT7Aqr52Vg/c/eU1tTOZZF0mh5Y x7jz8aN7EAa7hi0Eym/c68uO+iCRUTM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=tlAJFWQb; spf=pass (imf24.hostedemail.com: domain of 31gACZAYKCAcnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=31gACZAYKCAcnspklynvvnsl.jvtspu14-ttr2hjr.vyn@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677853313; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NAtSFGVTwhm/tX8WamH/Zd7xaJyhhcixand9gS9KqOo=; b=2vk1coYtjUFZFQ8Fm641iNIXfn1U2it9qI5eujry+kAndjss83EtJEyg10q1mk5iynzejJ nUZ/l5tNe2ZaKIRePKKZbySDQlh9UzCRwbyQ+bh2+rKLG/9Ov0e0RK43lfJYE2LKF2/Ntd 9psN5hbXGLpnykY4Pplbx6iCyu2f+Nk= Received: by mail-wm1-f74.google.com with SMTP id s18-20020a7bc392000000b003deaf780ab6so1072163wmj.4 for ; Fri, 03 Mar 2023 06:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677853311; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NAtSFGVTwhm/tX8WamH/Zd7xaJyhhcixand9gS9KqOo=; b=tlAJFWQb1a8DmXOV1S6Nv1PvWVzoK80hhYLo2g6Yvo8IYTwFe+UxNximwHce2BtK0K SNJHISOlptqfn9oLcdeY0bKTHs8alEL6yCwSDfU2rYl7sWJunjp0IjUFlItUt/MdaiX4 3vdPU2ZafKLVykHU/WMZX41Ra9tbK+pKU1C7Jm0xThmHLpU1z/Ct7S+NaAbLpQnn/dpq 4IjzWyARt7zP+PhPI7viEdfDZmTobONxyVbjWvTFtYVVOjBVvAJAWr2ACwChWO/Y/3Tm NYIn35yJ2f7jfgaWqnq1cEnHNmTC3dKVMuKhicvVpcjiGzcI3R4p71dHEW9514lXte5f s9zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677853311; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NAtSFGVTwhm/tX8WamH/Zd7xaJyhhcixand9gS9KqOo=; b=NM0hQ61jRQU/LV8CSC42IlDede3XnlggLBA9UcGGRoz04ivG3vlTXjkMWPEHACOykX OgdTwNn2813zF7nEeZT3DsnFYWprNdSKJYQov59h8rVo9WEQy9idwh55IxXru3bz1yTc 8av1R5FtMz1emHg2PDjnVs4udFJXl9/MzpF5KfgLq7qAzyS6uCcuZkaEN6j0NtaDz3l3 S1NnpyoPg5cAmm+IqB3WPzvWd+Br0OwIOUAkr4NluVkBdgtCsYENflYEayeGrOm5IOfJ t1apd3K4ukiqEdMUE8c297YtNmX79Bd4KOUD0nH3B+Q41nodWxzHCTevyjNuoqNN/NNh nW0w== X-Gm-Message-State: AO0yUKXcB+GCZbR4TqPa013OVRxZqOUSZeBWptBzV3VPM/SW5jx73Uqg oNLB5KiX1D/gziJix72e6R0aKXWEQtU= X-Google-Smtp-Source: AK7set9ovVaTOZsd0wnlPkswC0ekqTesP61gdVe/s0v8ISscKbGWSxjuV4vTctRIUgfB7uruGzs1glnmf18= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:f11e:2fac:5069:a04d]) (user=glider job=sendgmr) by 2002:a50:d581:0:b0:4bf:7914:98c5 with SMTP id v1-20020a50d581000000b004bf791498c5mr1171964edi.4.1677852886570; Fri, 03 Mar 2023 06:14:46 -0800 (PST) Date: Fri, 3 Mar 2023 15:14:32 +0100 In-Reply-To: <20230303141433.3422671-1-glider@google.com> Mime-Version: 1.0 References: <20230303141433.3422671-1-glider@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230303141433.3422671-3-glider@google.com> Subject: [PATCH 3/4] x86: kmsan: use C versions of memset16/memset32/memset64 From: Alexander Potapenko To: glider@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, dave.hansen@linux.intel.com, hpa@zytor.com, akpm@linux-foundation.org, elver@google.com, dvyukov@google.com, nathan@kernel.org, ndesaulniers@google.com, kasan-dev@googlegroups.com, Geert Uytterhoeven , Daniel Vetter , Helge Deller , Tetsuo Handa X-Rspam-User: X-Rspamd-Queue-Id: E913F18001C X-Rspamd-Server: rspam01 X-Stat-Signature: c51dafhnjs4grta6nx1shg9j67niegqu X-HE-Tag: 1677853312-865864 X-HE-Meta: U2FsdGVkX1+NVo8X9rcCebqd8eaE3c6MexD8qaZcMO1239TsNwWxr6fwNVuZkcfmkcAroV6GwURb5LNE7LVXMX3ipfn45TXXAsauEizGbYx8ZEYCq6E4I05Qfi3b4vpOgcV/QWNAi+9//Z+M1Zc2LH+6H990K4v1u+4BOr60b2++/t9jyK8JhiGdChXB57q78l/Rw368TY/rrSWFK3xXzP2UyXx0AXcqSz4ezaYT4jjlTN6wXXjRDCgpgqCskdlM4qR/ZjUmB4UBatCWgGBrvxHXMkQCK1W6qTnJtv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RLIzmwsR+ZgEvTDJAk5FeSktW+Xxm9IFa55N8fmf9LiI2a7/SX6MlRTZKWFKRILKBIL8XjWFn2tTDFJ60xqs9f/IjmuqiHefRQfiCgH8pPc+jiWZv+UdDWpJuz1cxrH8b385HRpaAXKzN9HHPsm4Xf86u/SPCtLs/C4U5mc22o92hsAbT1C/0vLLSbbZK5y1KylM7SuP2w62JhElFUIe7fseVSuYblA0obrvWENSqmyH1mH5g2qktmDwFg6t7KgB8h904WbGbwKQQ3QhPLw7+oNKliAxf3v4+LHv4VQJGW3w7NetYQEPBg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: KMSAN must see as many memory accesses as possible to prevent false positive reports. Fall back to versions of memset16()/memset32()/memset64() implemented in lib/string.c instead of those written in assembly. Cc: Geert Uytterhoeven Cc: Daniel Vetter Cc: Helge Deller Suggested-by: Tetsuo Handa Signed-off-by: Alexander Potapenko Reviewed-by: Marco Elver --- arch/x86/include/asm/string_64.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index 9be401d971a99..e9c736f4686f5 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h @@ -22,6 +22,11 @@ extern void *__memcpy(void *to, const void *from, size_t len); void *memset(void *s, int c, size_t n); void *__memset(void *s, int c, size_t n); +/* + * KMSAN needs to instrument as much code as possible. Use C versions of + * memsetXX() from lib/string.c under KMSAN. + */ +#if !defined(CONFIG_KMSAN) #define __HAVE_ARCH_MEMSET16 static inline void *memset16(uint16_t *s, uint16_t v, size_t n) { @@ -57,6 +62,7 @@ static inline void *memset64(uint64_t *s, uint64_t v, size_t n) : "memory"); return s; } +#endif #define __HAVE_ARCH_MEMMOVE void *memmove(void *dest, const void *src, size_t count);