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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 D710EC4338F for ; Mon, 9 Aug 2021 13:40:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3FE061019 for ; Mon, 9 Aug 2021 13:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233640AbhHINke (ORCPT ); Mon, 9 Aug 2021 09:40:34 -0400 Received: from foss.arm.com ([217.140.110.172]:32974 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229474AbhHINke (ORCPT ); Mon, 9 Aug 2021 09:40:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 751486D; Mon, 9 Aug 2021 06:40:13 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D5783F718; Mon, 9 Aug 2021 06:40:12 -0700 (PDT) Subject: Re: [PATCH v3 25/25] iommu: Allow enabling non-strict mode dynamically To: Will Deacon Cc: linux-kernel@vger.kernel.org, dianders@chromium.org, iommu@lists.linux-foundation.org, rajatja@google.com, linux-arm-kernel@lists.infradead.org References: <22b044263f69e2bfe404c4379a435005ea58b3e2.1628094601.git.robin.murphy@arm.com> <20210809124931.GA1097@willie-the-truck> From: Robin Murphy Message-ID: <283ba58e-0257-8785-d0e6-eb96ab169e35@arm.com> Date: Mon, 9 Aug 2021 14:40:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210809124931.GA1097@willie-the-truck> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-08-09 13:49, Will Deacon wrote: > 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? Mostly because I failed to spot it, I think :) Indeed now that we don't have any callers other than iommu_dma_init_fq() to worry about, I don't think that one matters any more. It would if were testing cookie->iovad->fq directly as our indicator instead of cookie->fq_domain, but then we'd still need the new barrier to ensure iommu_dma_flush_iotlb_all() properly observes the latter, so we may as well rely on that everywhere and let it fully replace the old one. Thanks, Robin. 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 855D0C4338F for ; Mon, 9 Aug 2021 13:40:18 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B8C76101E for ; Mon, 9 Aug 2021 13:40:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1B8C76101E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id DA18A827CE; Mon, 9 Aug 2021 13:40:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GAyqYTs9kRxM; Mon, 9 Aug 2021 13:40:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id C597E827DD; Mon, 9 Aug 2021 13:40:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A0E20C001A; Mon, 9 Aug 2021 13:40:16 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id B1E01C000E for ; Mon, 9 Aug 2021 13:40:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9036A4025D for ; Mon, 9 Aug 2021 13:40:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tx8OOu2oDf3M for ; Mon, 9 Aug 2021 13:40:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp2.osuosl.org (Postfix) with ESMTP id 4204B4022D for ; Mon, 9 Aug 2021 13:40:14 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 751486D; Mon, 9 Aug 2021 06:40:13 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D5783F718; Mon, 9 Aug 2021 06:40:12 -0700 (PDT) Subject: Re: [PATCH v3 25/25] iommu: Allow enabling non-strict mode dynamically To: Will Deacon References: <22b044263f69e2bfe404c4379a435005ea58b3e2.1628094601.git.robin.murphy@arm.com> <20210809124931.GA1097@willie-the-truck> From: Robin Murphy Message-ID: <283ba58e-0257-8785-d0e6-eb96ab169e35@arm.com> Date: Mon, 9 Aug 2021 14:40:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210809124931.GA1097@willie-the-truck> Content-Language: en-GB Cc: iommu@lists.linux-foundation.org, rajatja@google.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dianders@chromium.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 2021-08-09 13:49, Will Deacon wrote: > 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? Mostly because I failed to spot it, I think :) Indeed now that we don't have any callers other than iommu_dma_init_fq() to worry about, I don't think that one matters any more. It would if were testing cookie->iovad->fq directly as our indicator instead of cookie->fq_domain, but then we'd still need the new barrier to ensure iommu_dma_flush_iotlb_all() properly observes the latter, so we may as well rely on that everywhere and let it fully replace the old one. Thanks, Robin. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 8916EC4338F for ; Mon, 9 Aug 2021 13:42:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4502560FF2 for ; Mon, 9 Aug 2021 13:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4502560FF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=svvkc9j3EXYh0rrelCuDRU8GQnyHRddikerHPPyGVkA=; b=0NuGL1K9GBFK6DSqjlsnVbk7sZ LyJpsG/NCzpo5VGvJP4eHNj+k4OVpgrVmxnOLtV665HujqnL9HiZQZr1nhIInUA0ujyqd5TYGl82X qaXuyOqkt1ogFDyyD2qBwiXjd5FAzJWC2PBUwXwC4AA5ERrBBjdWUiZCiCAlzXqPt9YXYKn9KXQ6h ugOflnnzC+Z+95w6fwpPkTnoVG0c8MCjQOBE91dJpKQDIy1jstraITbWewl7npa2/xfkZqRm/HTrX O97Ss1YAicxK97AjZvxW5Ohf839JlWCt0ryd69eQI/tlSvY2AzlDdp8TQl1cy5mzq8pVlBYRFkd1H o5PTOOjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD5Vr-000ndl-9G; Mon, 09 Aug 2021 13:40:19 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD5Vo-000ndA-8H for linux-arm-kernel@lists.infradead.org; Mon, 09 Aug 2021 13:40:17 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 751486D; Mon, 9 Aug 2021 06:40:13 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D5783F718; Mon, 9 Aug 2021 06:40:12 -0700 (PDT) Subject: Re: [PATCH v3 25/25] iommu: Allow enabling non-strict mode dynamically To: Will Deacon Cc: linux-kernel@vger.kernel.org, dianders@chromium.org, iommu@lists.linux-foundation.org, rajatja@google.com, linux-arm-kernel@lists.infradead.org References: <22b044263f69e2bfe404c4379a435005ea58b3e2.1628094601.git.robin.murphy@arm.com> <20210809124931.GA1097@willie-the-truck> From: Robin Murphy Message-ID: <283ba58e-0257-8785-d0e6-eb96ab169e35@arm.com> Date: Mon, 9 Aug 2021 14:40:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210809124931.GA1097@willie-the-truck> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210809_064016_399600_3F210C6D X-CRM114-Status: GOOD ( 21.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-08-09 13:49, Will Deacon wrote: > 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? Mostly because I failed to spot it, I think :) Indeed now that we don't have any callers other than iommu_dma_init_fq() to worry about, I don't think that one matters any more. It would if were testing cookie->iovad->fq directly as our indicator instead of cookie->fq_domain, but then we'd still need the new barrier to ensure iommu_dma_flush_iotlb_all() properly observes the latter, so we may as well rely on that everywhere and let it fully replace the old one. Thanks, Robin. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel