Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2649163pxt; Mon, 9 Aug 2021 05:51:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz8qL6CyWD08u/WWUhjUrJR+yJDnClhw+1azJcM7ZCiHgq1qIjR8lG5LwLlrynIXEHgKc8 X-Received: by 2002:a05:6402:1c06:: with SMTP id ck6mr643486edb.320.1628513484031; Mon, 09 Aug 2021 05:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628513484; cv=none; d=google.com; s=arc-20160816; b=klmXeNuklZ1kccG8ALvnjUtPzXI7oDpoUtEO3jN/LV0Lrl1gTmXd8p8gHmaACDb81P qOrU8PibXu3Sq/1/sqYYfjZaOUbNhXSyF+hPvvsXkqPOQwVpGkUM1z0fr1O3L91jGJSJ cCCwX/Tw9W+DeWMM6ObkbpIL1taS6zlbbC3EHa62IQsxu9XoEF4GDW/P/RNJ02V+yl7F gWqe6W24VCGVfEAShtBaKcFrjJo05f+nXwdR4O8zatWkRv9SGwr60cW2JazpeD95+DMb OtbZ4h662IY39QD9kHyBuYots0J9ttTqlnOUKabqajE6fpgZHkIn7u7FV+rn/32wKCo+ Pcyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=sb/xfMKHuTuvgOwZY8fE8iUhoerof3qhmdKilREAw/0=; b=Zvv3fIGq8KyFezpK9tTu8GU1bqetGffGhByDV7+Q5755MiYMGItIrPxeE0etOsXwsY Tv44/0AVshh1VQdZVpCj18oyEOjY6EEShHdrYehn29k3mISEA3o8/AvjB/2daK9YoGE1 1Ctz3iLvDKQuLo4ups8levT8ruLw42lPlGAlRCsFK60oY1KWfLRXzSvVIPY+pYA2KidB bZO2ApD0GBYSptApsK4TH0JPV2W508pzoroFB1Z7AG+pfn7qNqAigyvrkmQiFLqJX76V 2D+L+KhYtSpGVsuucSoDIPnRWmmDLgnlm1597oNsV9+9sQSBfBXMhrPUYI9sO6JjpP3O hZOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jk+7pKgZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn42si11118675ejc.103.2021.08.09.05.51.00; Mon, 09 Aug 2021 05:51:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jk+7pKgZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233310AbhHIMt7 (ORCPT + 99 others); Mon, 9 Aug 2021 08:49:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:35918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbhHIMt5 (ORCPT ); Mon, 9 Aug 2021 08:49:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B53160FE3; Mon, 9 Aug 2021 12:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628513377; bh=DuWuffUzHWTlh5RyIppkfZJMBWUzwes3xWNKxmTLe/0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jk+7pKgZ+88oYQV9NkXW4+7DYuSYjjTwrgQJpOrttxXIl5tKNVCJEgrkyQdFPhMBz f+hMsHunXnbXXesw+l55zR366ZFmUEFCU46XuqwsX9p51Orqm4/orNB9V6uk/Qf427 M8lkagHV1KbxaWYI5iHUprg2PxaP5mEWPsbx4edZ51DKNkwnlvb24ksb39kRyXaIUh R4mSwsA0e80ppbX3SHwNrX0m85MhDas0fjY1UT3lTv39wJhvOa8g5cqTbMM2vtoEbn CNkDkUHMlk+b6ei3yicYLMvxr7anZ9IQoNRNMXm/AvyXMBtyTtb5tMvU3WkqdmVQv3 Yh+XgBvSP2Q1A== Date: Mon, 9 Aug 2021 13:49:32 +0100 From: Will Deacon To: Robin Murphy Cc: joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, suravee.suthikulpanit@amd.com, baolu.lu@linux.intel.com, john.garry@huawei.com, dianders@chromium.org, rajatja@google.com, chenxiang66@hisilicon.com, Sai Praneeth Prakhya Subject: Re: [PATCH v3 25/25] iommu: Allow enabling non-strict mode dynamically Message-ID: <20210809124931.GA1097@willie-the-truck> References: <22b044263f69e2bfe404c4379a435005ea58b3e2.1628094601.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22b044263f69e2bfe404c4379a435005ea58b3e2.1628094601.git.robin.murphy@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 04, 2021 at 06:15:53PM +0100, Robin Murphy wrote: > Allocating and enabling a flush queue is in fact something we can > reasonably do while a DMA domain is active, without having to rebuild it > from scratch. Thus we can allow a strict -> non-strict transition from > sysfs without requiring to unbind the device's driver, which is of > particular interest to users who want to make selective relaxations to > critical devices like the one serving their root filesystem. > > Disabling and draining a queue also seems technically possible to > achieve without rebuilding the whole domain, but would certainly be more > involved. Furthermore there's not such a clear use-case for tightening > up security *after* the device may already have done whatever it is that > you don't trust it not to do, so we only consider the relaxation case. > > CC: Sai Praneeth Prakhya > Signed-off-by: Robin Murphy > > --- > > v3: Actually think about concurrency, rework most of the fq data > accesses to be (hopefully) safe and comment it all > --- > drivers/iommu/dma-iommu.c | 25 ++++++++++++++++++------- > drivers/iommu/iommu.c | 16 ++++++++++++---- > drivers/iommu/iova.c | 9 ++++++--- > 3 files changed, 36 insertions(+), 14 deletions(-) I failed to break this, so hopefully you've caught everything now. Only thing I wasn't sure of is why we still need the smp_wmb() in init_iova_flush_queue(). Can we remove it now that we have one before assigning into the cookie? Will