From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30330C1975A for ; Wed, 25 Mar 2020 16:15:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1D9D20409 for ; Wed, 25 Mar 2020 16:15:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jrhJO5nL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1D9D20409 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 421456B00B2; Wed, 25 Mar 2020 12:14:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ABF76B00B4; Wed, 25 Mar 2020 12:14:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 273FD6B00B5; Wed, 25 Mar 2020 12:14:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 023866B00B2 for ; Wed, 25 Mar 2020 12:14:51 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E40A31CFB6 for ; Wed, 25 Mar 2020 16:14:51 +0000 (UTC) X-FDA: 76634383182.17.boot29_81b7bbd463063 X-HE-Tag: boot29_81b7bbd463063 X-Filterd-Recvd-Size: 6314 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 16:14:51 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id n25so866021wmi.5 for ; Wed, 25 Mar 2020 09:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=CXGfvgsU88R7r/Q38NQ1qLmAnAQj/bYiiq1RkhMwKVQ=; b=jrhJO5nLX7n7Sdsbo4M5WuoNmmg+4OHZT/NUr049eN1rBintF6ymq14V81QBL8Q3xy vE236CywIMuCsX9bAJ9wNhfs+7RtnFc066RGg5s2r5DFuo1t59QFfVM3rkoM8ofpyPI0 cvIT3Cp2XYXyJj2UmLAgeesrF8Qt2dEgx4qgtpPnuEQzCvOLE1MOSmUw6oXYuY7ZdRWc wiFEWM0TQ2kL9IsI11ECu2oHcPmF/mVevUdM4nYzzF+YTeKc+7e0U2t4GAXrT2rWKtyk pLefmCntf/E2LSlm5iB1iq2/ShL9K42XQylu8KNIZI9lNiDS9yc15azauFsy1KdsDqWR tJYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CXGfvgsU88R7r/Q38NQ1qLmAnAQj/bYiiq1RkhMwKVQ=; b=SBdR39aKHPfgMR62v9LwsGDoLwthDuWuqi0uVeHbaDtdu1Op2GhHqAJxJ8s9D2m5DU lA4ycQMzfKBiGJHm35Qg6QMkGWZlErq/DRfYZYQvy2tLApcUdp3iSK4K1OKR9Eh85kui esm1wIKTiewdr5lI9bNtLs7R0Uyp7cfrKzY7vC9DjMAtLc26b4ibWonTgy+EN0ZR8IU7 2uz64ce5+XnJDUwnX4oWE6JJNfYDOqQdqshKvQcbxQf3Ip7bWcrS6hP8OZM35oUe0Rjw ccfy7Z/V/0StJO7WLM7z0KHKSFhMvTbzkA88Q+VhKihPk8lQcG2vDI79yecmCGD7ALLr jpKA== X-Gm-Message-State: ANhLgQ0b2Jht9FSb//ytV9ZfHY3kmeQ92R9Nw7Zm+BSNKAFKxGY7GuyA Nch4tKIn7iOKcylNSRFEFISjLm77cfA= X-Google-Smtp-Source: ADFU+vsKbvfy+LMn86f1LKADSDMeUoVM/ysFo7I1oex2nDTiYHm9Bn8PLBW+TYfxWX5RMlN6GLXpCe8aeME= X-Received: by 2002:a5d:6581:: with SMTP id q1mr4110038wru.17.1585152889861; Wed, 25 Mar 2020 09:14:49 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:47 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-37-glider@google.com> Mime-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v5 36/38] x86: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN From: glider@google.com To: Arnd Bergmann , Michal Simek , Andrey Ryabinin , Vegard Nossum , Dmitry Vyukov , Marco Elver , Andrey Konovalov , Randy Dunlap , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, luto@kernel.org, ard.biesheuvel@linaro.org, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, mhocko@suse.com, pmladek@suse.com, cai@lca.pw, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de Content-Type: text/plain; charset="UTF-8" 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: This is needed to allow memory tools like KASAN and KMSAN see the memory accesses from the checksum code. Without CONFIG_GENERIC_CSUM the tools can't see memory accesses originating from handwritten assembly code. For KASAN it's a question of detecting more bugs, for KMSAN using the C implementation also helps avoid false positives originating from seemingly uninitialized checksum values. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Arnd Bergmann Cc: Michal Simek Cc: Andrey Ryabinin Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Marco Elver Cc: Andrey Konovalov Cc: Randy Dunlap Cc: linux-mm@kvack.org --- v2: - dropped the "default n" (as requested by Randy Dunlap) v4: - changed "net:" to "x86:" in the patch name Change-Id: I645e2c097253a8d5717ad87e2e2df6f6f67251f3 --- arch/x86/Kconfig | 4 ++++ arch/x86/include/asm/checksum.h | 10 +++++++--- arch/x86/lib/Makefile | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 376c13480def2..c45c937682863 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -274,6 +274,10 @@ config GENERIC_ISA_DMA def_bool y depends on ISA_DMA_API +config GENERIC_CSUM + bool + default y if KMSAN || KASAN + config GENERIC_BUG def_bool y depends on BUG diff --git a/arch/x86/include/asm/checksum.h b/arch/x86/include/asm/checksum.h index d79d1e622dcf1..ab3464cbce26d 100644 --- a/arch/x86/include/asm/checksum.h +++ b/arch/x86/include/asm/checksum.h @@ -1,6 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifdef CONFIG_X86_32 -# include +#ifdef CONFIG_GENERIC_CSUM +# include #else -# include +# ifdef CONFIG_X86_32 +# include +# else +# include +# endif #endif diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 6110bce7237bd..40d6704c4767d 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -64,7 +64,9 @@ endif lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o else obj-y += iomap_copy_64.o +ifneq ($(CONFIG_GENERIC_CSUM),y) lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o +endif lib-y += clear_page_64.o copy_page_64.o lib-y += memmove_64.o memset_64.o lib-y += copy_user_64.o -- 2.25.1.696.g5e7596f4ac-goog