Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3545174rdh; Thu, 28 Sep 2023 15:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGj/f0StN25I6XT20yUdQvu6dHPwCtXpcO9qGNSIsWBHUJQhg4lgtn4z75u0MjXIZhnX5Sk X-Received: by 2002:a17:90a:f408:b0:25d:eca9:1621 with SMTP id ch8-20020a17090af40800b0025deca91621mr2287342pjb.6.1695939451182; Thu, 28 Sep 2023 15:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695939451; cv=none; d=google.com; s=arc-20160816; b=TV4aNTLfyzt9qeAg2VbiGUFVlFQ8mHBYpaApc9bagwFRWZe2qhp4QexoAuNaDdqVs/ PB/FmOhkrg0IcuHdNw8g1pMOg/kXuzZ5pLavg1s8iw0gs/0aVdAOIjsfwXaEwSvj0qeC huT3V5OunqtluC3AYa+C/JV7CmcRtAnTn3OVR1LejW2YptVFTmh2Nv7OUWct07NiRcee 5UYa48G2JTFrFWk/K4rcJhKrkYlnHroUPuT4rqbMIj6bsXHCb3wiuLXQKDMx9b9Ew2lh nqXgLpvr4zfVGx1cCBH+0ccpgFnU1kmKgCiqmxiqTvyMgIinkA7emQLuuIPhIV2JUvzB gUFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=p469W9XInE59/vnc2w8MJndcGm8KAMBXNFVAn/JwZEc=; fh=c9v6WPddNAS7LOPGPPxAK5MgMS36helJY/NbWNuaZWc=; b=NnSHecBN0eFNJBCFkWQqPdbQxMtOLy4rOXMHxi/42z69hA0TzM6wEoP1nh0mHnveC1 5cPkq5YhM18BMiPcFgEwX4m0C1cY+2omR/DICVnG9iQ7vKylvI8JEwNLOF1oql4sbCeU wDkgC0FCDqRJ1ggXZNWKmEAwpwkX4yAUNjHv+RiCi1ZbaOnNG3ufTGYoBPX+gPZeEiOs 7L8GikV55EpCKtlVgaXWojKdgQK24HjqPkAUyeXXCjK7hHrAP534P9OvpEUZ06VPfghE 8gGncvXbMHMgNbdN21IitH5KlHe0ANFGFWeLhUCdnnyRqJL9vS9OM39Fv4f3hJtRY33Z CoHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=Z1Kq296j; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JD7SZWCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id p8-20020a17090a748800b002613720fcd5si139989pjk.35.2023.09.28.15.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 15:17:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=Z1Kq296j; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JD7SZWCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 454818114D08; Thu, 28 Sep 2023 09:21:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230331AbjI1QV1 (ORCPT + 99 others); Thu, 28 Sep 2023 12:21:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbjI1QVZ (ORCPT ); Thu, 28 Sep 2023 12:21:25 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 639CE136 for ; Thu, 28 Sep 2023 09:21:22 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 297385C0326; Thu, 28 Sep 2023 12:21:19 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Thu, 28 Sep 2023 12:21:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1695918079; x=1696004479; bh=p4 69W9XInE59/vnc2w8MJndcGm8KAMBXNFVAn/JwZEc=; b=Z1Kq296job7vIE/mHu VbYAvcBzkKkYvSUTPLWGS9loNusIlqPcMhqfwYzenbo798nIvGXv5wuF2KgxJqPH ZaZXEaYppw1FXDHgmY+DrHYXD9IfywbETYIHhmB/qPcfAum6z9xlwfvcWnZoW2sQ VUuPjWuglLUqof6omzQUt7UyRjK4esti+K/gM1FourvAcCwvS4Efa89U0gr1+72e IsT33D1cBpvIygNIf+G8wIX6NIN6ujO28aTfuPsWmHklIWyE/iENqWyfYVJKMWRb XbcJ8IEqBNO7tO9gXrnaHnwUqOn6chylfEZrgkMPvEnHn3TgNRu4NoAwtXo6WvKR pOFQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1695918079; x=1696004479; bh=p469W9XInE59/ vnc2w8MJndcGm8KAMBXNFVAn/JwZEc=; b=JD7SZWCc1+erEigqzF1UR86Q4nect JM6ZE+yzZCwc3yzImH8KKsd4HEZkv4XhXnacHvPrQsO7lVWMwz4sgLwpGNP0dxav +rrzXE709wxj6CLygtVwG9azQI6yba22R/ifCP/41p+L3VaDjTOiMCW5DDlyzIk3 NYXVqZQ8CQ3fxpy0uyUU/TCJMwaAJw5pQfMgds7iTKzwMJqsbwaxSL6ltntAJhqI oZw2tKxfvf9g4Rr1tWgr/ivdDokveDrFIlOrDqaUOcpBHqHNvxkTKOAb65QMRc9I w/HNplw9LVYkjN+h1K/rUgziIuV3sz2WkqxZS5mZmL7rIteixAPwyjD3g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrtddtgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A70AAB6008F; Thu, 28 Sep 2023 12:21:17 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-958-g1b1b911df8-fm-20230927.002-g1b1b911d MIME-Version: 1.0 Message-Id: In-Reply-To: References: <20230926175208.9298-1-james.quinlan@broadcom.com> <20230926175208.9298-2-james.quinlan@broadcom.com> <1f08bd12-0ac4-43ea-b058-7836521eec12@app.fastmail.com> Date: Thu, 28 Sep 2023 12:20:56 -0400 From: "Arnd Bergmann" To: "Robin Murphy" , "Jim Quinlan" Cc: "Linus Walleij" , "Christoph Hellwig" , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, "Russell King" , "Geert Uytterhoeven" , "Russell King" , "Andrew Morton" , "Jonathan Corbet" , "Thomas Gleixner" , "Sebastian Reichel" , "Mike Rapoport" , "Eric DeVolder" , "Nathan Chancellor" , "Kirill A. Shutemov" , "Christophe Leroy" , "moderated list:ARM PORT" , "open list" , "Claire Chang" Subject: Re: [PATCH v1 1/1] ARM: Select DMA_DIRECT_REMAP to fix restricted DMA Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 28 Sep 2023 09:21:38 -0700 (PDT) On Thu, Sep 28, 2023, at 11:33, Robin Murphy wrote: > On 28/09/2023 4:16 pm, Arnd Bergmann wrote: > >> It's unlikely but not impossible, as the driver has some >> unusual constructs, using a lot of coherent mappings that >> might otherwise be streaming mappings, and relying on >> dma_sync_single_for_device(..., DMA_BIDIRECTIONAL) for other >> data, but without the corresponding dma_sync_single_for_cpu(). >> If all the testing happens on x86, this might easily lead >> to a bug that only shows up on non-coherent systems but >> is never seen during testing. > > Probably the significant thing about restricted DMA is that it forces > all streaming DMA to be bounce-buffered. That should expose busted > synchronisation even more decisively than a lack of coherency. If > there's no IOMMU, then testing the driver in the absence of restricted > DMA but with "swiotlb=force" should confirm or disprove that. I see this sequence in the iwlwifi driver, in the iwl_save_fw_paging() function: block = alloc_pages(GFP_KERNEL, order); phys = dma_map_page(dev, block, 0, PAGE_SIZE << order, DMA_BIDIRECTIONAL); memcpy(page_address(block), ...); dma_sync_single_for_device(dev, phys, size, DMA_BIDIRECTIONAL); Which clearly violates the interface by writing into a page that is already owned by the device, without giving it back to the cpu first. Not sure if or how this would explain actual data corruption on armv7, since we write back the buffers in both the map and sync operations and never invalidate the cache, but the driver also doesn't ever read from the buffer (despite it being bidirectional). If it's not this problem, there is a good chance of others. Arnd