From patchwork Wed Mar 25 16:12:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11458303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C0FD913 for ; Wed, 25 Mar 2020 16:15:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1165820409 for ; Wed, 25 Mar 2020 16:15:12 +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 1165820409 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3ABF76B00B4; Wed, 25 Mar 2020 12:14:52 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 2,0,0,f71f4d9b48dc201a,d41d8cd98f00b204,3eyn7xgykcggmrojkxmuumrk.iusrotad-ssqbgiq.uxm@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3872:4117:4250:4321:4605:5007:6261:6653:6742:6743:7875:7903:7904:9121:9969:10004:10400:11026:11473:11657:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13255:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30012:30029:30041:30054:30064,0,RBL:209.85.128.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:20,LUA_SUMMARY:none 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 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 Reviewed-by: Andrey Konovalov --- 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