From patchwork Wed Mar 1 14:39: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: 13156069 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 85789C64ED6 for ; Wed, 1 Mar 2023 14:39:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2236C6B0075; Wed, 1 Mar 2023 09:39:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D3B76B007B; Wed, 1 Mar 2023 09:39:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0745C6B007D; Wed, 1 Mar 2023 09:39:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EDE0C6B0075 for ; Wed, 1 Mar 2023 09:39:45 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C16FB40790 for ; Wed, 1 Mar 2023 14:39:45 +0000 (UTC) X-FDA: 80520588330.16.CAE4667 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf21.hostedemail.com (Postfix) with ESMTP id EF2341C0002 for ; Wed, 1 Mar 2023 14:39:43 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=DcQhFeZ5; spf=pass (imf21.hostedemail.com: domain of 3rmP_YwYKCJk9EB67K9HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3rmP_YwYKCJk9EB67K9HH9E7.5HFEBGNQ-FFDO35D.HK9@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=1677681584; 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=h2FIkUEqU6YxkmcIL1AtVszo9ZqqtqhQ8yghIzSXGmA=; b=lw95epjBeJtyEZi551AxneSnYKUSGZYywho8xopzUi+ryn7eruwi+RZ3OLHjcH17vmRXnL nIeF+wr+qM3ggnpA0yKM3We8dgfM142jjjyBEkacowDlQ7+jkkNUiOMvi3Uw44N8CnCVcG QqfHUQ1tC2Y/EHie0R02GcyYizRxhJ0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=DcQhFeZ5; spf=pass (imf21.hostedemail.com: domain of 3rmP_YwYKCJk9EB67K9HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3rmP_YwYKCJk9EB67K9HH9E7.5HFEBGNQ-FFDO35D.HK9@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677681584; a=rsa-sha256; cv=none; b=JMHMZU7J8mjlLFAjijbDZfYlzGZaxsW2mHQWhNCtYUgvd6vVkPzUJr0LmFtnR3oWS9Z1mt 6yO5YSROp7hv7pYRIKcE6btnYgNrO/BJ4zvo3QloNcUaIBNHQSj1e2LLoSMFG2JucNxsNQ 8Kq1Kb6Pp7T5zJEvW8ZdjjRcM1oCl8M= Received: by mail-ed1-f74.google.com with SMTP id da15-20020a056402176f00b004ace822b750so19599450edb.20 for ; Wed, 01 Mar 2023 06:39:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=h2FIkUEqU6YxkmcIL1AtVszo9ZqqtqhQ8yghIzSXGmA=; b=DcQhFeZ5qGp+AKIQFJAYw7mSn3Y3zdJdiwbFpjR09nWHgumpyTqJ77smBudhJx90b2 +of4MO5DstJZPnWALbM1Of06Za2o7NytkJzXNNFiETyWdzrdaTvwzeqjQvfk8WKO4zWX nZ+35n8p65W1JWEwmllJK+DRCas7pBVJAabnp3AlbmD9fL442oIjUjwwK9Aw0IVzmE4G LaCLGdq2wBlsOXftBi7owZAHb13CKHLWbeuJyMfJKrGq7rXdtXxsVCEBJ1eC4cyZayTC p0+kMXLSlqoFuK/nAnKUEN/l83vYbnRP2DpS/RVn8EjMzruu3T02ZPom1pnLs708E3j1 cpHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=h2FIkUEqU6YxkmcIL1AtVszo9ZqqtqhQ8yghIzSXGmA=; b=mD2jCkLkbNfEoI7Jx4s04DirGykZv2AHpDnhfr0ruj5TKbMG2wg1k3wknB5P0rtDKG MtJYLr1QP+9YHjihN4dkPjPs1YVhyh8TvlLb06izE8cKA4v6S5cWJ6rdo0rLhvOPov1/ WFk+b1cDqtoL1uLHAsPy8ZSFW1YEQltAE8Zy8yEs0MNwdbvI9iOHmKWJfi5/yk/Iehr6 xw0LjFFtoP2uVBOdx1/FkUZjj/RQ+jUdde33/rsJGnZC0f31j5W4g3gjOLod9oD8gWPl 8xlbhAKOlX03aBPwxe8/VNVqG8XnLaDIYnA4OJWmKjHQfgzZ3a3rkiRW07mb88QB9eu5 tGgQ== X-Gm-Message-State: AO0yUKWRPOcYUiij69xS30SmAMy1kmvTwdPWdZdJwCOagP0FMl04NUv+ YdoCIjMzD/ane/cSqMUGlNGl6zXHBSw= X-Google-Smtp-Source: AK7set8s3Ggkq5cG5lUrm0qbBrwvCtbXX/8McRuVafkppgzT3vG80DIvRRgW6QRGvNCDsu1QYruyNWhJhlw= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:3c31:b0cf:1498:e916]) (user=glider job=sendgmr) by 2002:a50:aa8b:0:b0:4ae:f648:950b with SMTP id q11-20020a50aa8b000000b004aef648950bmr3893580edc.7.1677681582665; Wed, 01 Mar 2023 06:39:42 -0800 (PST) Date: Wed, 1 Mar 2023 15:39:32 +0100 In-Reply-To: <20230301143933.2374658-1-glider@google.com> Mime-Version: 1.0 References: <20230301143933.2374658-1-glider@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Message-ID: <20230301143933.2374658-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EF2341C0002 X-Stat-Signature: juaebz33xa3qt8h6kzaeqic51e7b1xep X-Rspam-User: X-HE-Tag: 1677681583-536785 X-HE-Meta: U2FsdGVkX1+izTPYQCeC4fqQ2MAD1IDj83ezkKLECMXcB0CxCYg0+MCXKEJKIbuVN7lKuy4VnlMHPfrKldw4YLStXXmTGu48J0wD6HjrN2Q7anKomDjZPZ2biKVEBAZt1IoWKmZjdWWnTlpi1GaQY79cfzvl/gm5O4bWgbSWSqzrJZQBjPlYq1M+H+Y2CU+5oS1SNQ0fWCv3zoduz7qB2RYG7EpS3T6KOjMtj1a7SpfaukzU8l+7BnniuaYffw6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mrYby9LohYXR1oW/L9taXM3tnY1HcPuyrUnPpS1+yfSGzybocXlFsFvENQNqVwKgJa/fLeKF+lmeMunCyGeqkil2VxuQslp+fowE2NlFCARA38q9Y0QoGB9PjgdBp9Z9XWIiWcyQmtz5SNcDdSZyCT4AtaBYMq2Tk7nnhO2deRkd7Vh0AGSMTl986+dorU4n+QLsy1tXerkce5CNIhrgJzYUJCv5ihaPuPzYdiesnuv06hbJLzAZy3onOqKJ/qwYkmu15XEpGzctQesIKWzaNFyYw== 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);