From patchwork Fri Dec 20 18:49:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11306209 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 EE2D56C1 for ; Fri, 20 Dec 2019 18:52:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB6B8206D8 for ; Fri, 20 Dec 2019 18:52:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AnKGc5B3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB6B8206D8 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 20BF88E01C9; Fri, 20 Dec 2019 13:52:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1927B8E019D; Fri, 20 Dec 2019 13:52:04 -0500 (EST) 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 EAF778E01C9; Fri, 20 Dec 2019 13:52:03 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id CF8A08E019D for ; Fri, 20 Dec 2019 13:52:03 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id A2AD5181AEF15 for ; Fri, 20 Dec 2019 18:52:03 +0000 (UTC) X-FDA: 76286414526.03.ray78_865b646794937 X-Spam-Summary: 2,0,0,1373688f784bca2e,d41d8cd98f00b204,3uhj9xqykcg0rwtopcrzzrwp.nzxwtyfi-xxvglnv.zcr@flex--glider.bounces.google.com,:hch@lst.de:m.szyprowski@samsung.com:robin.murphy@arm.com:vegard.nossum@oracle.com:dvyukov@google.com:elver@google.com:andreyknvl@google.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@infradead.org: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:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.com:mhocko@suse.com:monstr@monstr.eu:pmladek@suse.com:cai@lca.pw:rdunlap@infradead.org:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.c om:tytso X-HE-Tag: ray78_865b646794937 X-Filterd-Recvd-Size: 4807 Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Dec 2019 18:52:03 +0000 (UTC) Received: by mail-qt1-f201.google.com with SMTP id b7so3521090qtg.23 for ; Fri, 20 Dec 2019 10:52:03 -0800 (PST) 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=fANmMKYNuoGlfJD9atDKa1RrxfnEwpzWODPOQOs3l7Y=; b=AnKGc5B3N9D/HTD/U0BZE3pudc+8QB4cuilS0ObIwCRscuQBi0iSaYttgxJRltVH9Q z4H7YvYPRocmwaffIJXak3GxT+BCQVNzTyvRWA7Ou3atwhkfBfVbFDoV8gYE9Jxwp+q/ RrS1UXMsJTP76l1GXnu3zQsha3Y3bSEfP/U6TpyDUnVZWBBYysbgbJt374tXhRHyEwI5 8GPHPo+hwaKRrJQ8plpUK2tOAVxGaGCidjRQS2ZXY4/mBjA08VKhj7Uscht1bHbQIMha 9TXjiIFY5GvKqdQzPIk+zj/KMBPRRVQAk9VW656WnZdV+oyxV513uCSgZfFu+2fMyn5P EX6g== 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=fANmMKYNuoGlfJD9atDKa1RrxfnEwpzWODPOQOs3l7Y=; b=OLspUqaPt3pg/+TzQTFRIjEvpSVVX2fd3xJnC2rFClJrJRAhWOOXBuzV5ehGYW+G4r wRlpiCChGwVJguP3HVGCWAzD2IfQ2gwHvL9lArlrK0KP4CBmY2L5+LRYkHqPJtL8fTLX ei7wc30+ma4oU4i6FpCkbKh6n75pVDTRtDRkznUcAKd7OS7+h7RnzXZsowv5SrliJnkK YaC84M1vEo5SIPM36wpJnRtj+G9NZTKYh/IE7XNnIlGs+uDw2oZTlNl8P51L5hXbCHng hKPlNOHFdjhx5penpnJC9PjFwbNx4om7HOPs8Pbd7E/9vYoDpSiBkDURGzVbop760ZoE CCBQ== X-Gm-Message-State: APjAAAXUOdOCs1+ieVuZZ0z2yk4ZBxRJIp5HCTi7EPAceBy+EkaZFv1X kgnUG1J23S8wJTgULmOl8sPWVmMvlCw= X-Google-Smtp-Source: APXvYqzrD5RQFMNHN4KA6pBY/qKv7AIqvOO7myf5jEnlfrJLqVXq23N3Sc7hBSjXM5KyCfCBhixbHYKlUv8= X-Received: by 2002:ad4:4d91:: with SMTP id cv17mr3551207qvb.101.1576867922519; Fri, 20 Dec 2019 10:52:02 -0800 (PST) Date: Fri, 20 Dec 2019 19:49:51 +0100 In-Reply-To: <20191220184955.223741-1-glider@google.com> Message-Id: <20191220184955.223741-39-glider@google.com> Mime-Version: 1.0 References: <20191220184955.223741-1-glider@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH RFC v4 38/42] kmsan: dma: unpoison memory mapped by dma_direct_map_page() From: glider@google.com To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Vegard Nossum , Dmitry Vyukov , Marco Elver , Andrey Konovalov , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, 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, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, mhocko@suse.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, 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: KMSAN doesn't know about DMA memory writes performed by devices. We unpoison such memory when it's mapped to avoid false positive reports. Signed-off-by: Alexander Potapenko Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Marco Elver Cc: Andrey Konovalov Cc: linux-mm@kvack.org --- Change-Id: Ib1019ed531fea69f88b5cdec3d1e27403f2f3d64 --- kernel/dma/direct.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 6af7ae83c4ad..19d6d7dd10ec 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -376,6 +376,7 @@ dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, report_addr(dev, dma_addr, size); return DMA_MAPPING_ERROR; } + kmsan_handle_dma(page_address(page) + offset, size, dir); if (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) arch_sync_dma_for_device(phys, size, dir);