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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 91269C2B9F4 for ; Fri, 25 Jun 2021 14:45:35 +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 5D04F61969 for ; Fri, 25 Jun 2021 14:45:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D04F61969 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=08vjg1i81AJ778Dw2/4QMi25gdQvxzndAA4RK/ru8jM=; b=UemzwqKYUrSRn6 VU2YTw3fVgV4NqpZKWeG14LYkpT5Cf5OzLoGbd3PCBrG3ClPv6rc73fRw3xkrcGHIUv5Cjm2Df6kb RE7XFz2wJIRTCg5Mabeo5Tsv7lxpajwQKGg6v1GgdPT41z2vh/f7ziZ+3zdjp6CSa/7/xf9intDjO CFy/bq3PX7RIQUr6wJycnxDBuLHcxUUoSdZO1sk8nIu6nmqeFDJ2TF/4zhx7at8QiRSdeoLg1dvms Edv6QJVxyi9iAc9bccODiu4v+FY6IHULDWrNM6UdCL9ALpcYRSuaoCoM4jyrE68QCHW/Ty1Ucuw2Q PVbHbFkJjMkNJOMaxFlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwn3U-0020v5-RU; Fri, 25 Jun 2021 14:43:44 +0000 Received: from mail-ua1-x92e.google.com ([2607:f8b0:4864:20::92e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwn2W-0020TI-F9 for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 14:42:42 +0000 Received: by mail-ua1-x92e.google.com with SMTP id a14so3642870uan.3 for ; Fri, 25 Jun 2021 07:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j8m5Di25YEHezMhSM0CIBaRcSl+2cupixwUQS08gJpo=; b=M6vw5n1mivkEmZrZaE7zieAlKLsTCL3sm9eT56bSI/8K31Go3QolQ35P0EOIUStr1i Ps9F1aHzu148M6CnpnCl479CYign0nk21Ld54dTETQxPeTlpC0v+vVMC1vqhwLBpIR1T 3JmEdCj0y7cmRGSI/pvihxB5MGkxE/h5jVHys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=j8m5Di25YEHezMhSM0CIBaRcSl+2cupixwUQS08gJpo=; b=ekcm0L/gJH5jFtAFNJ9VXtnsbYsSFvSQeb02rd2Umhe99WK253DNz1a1eKu7lrHhtE ifmqLcN386asD17y9ogI68GjUHgTUGU/p0HBuqYHPQKjU1KAChaSSiXw+dzra6sMW1Hy JdH2D4JoHF9uvm9TsgP0Ir96VWXrutCoM5AerNjkTavtg47BW+/UdzuP1gBZI/wNA5LV 1jLvthkjo3U05K3TapwDHyW/d8CUC98vP5D9CfF3we4ktxwy4JmCLlRftBbY6sqK+3Rd /JvzkPC9sJWG3lcJRs43F63RCnkqtbkKMDhGZNiT6bNl+wsOvSwocdJvMKyVcCGGK3NQ Bl2A== X-Gm-Message-State: AOAM530XLWHR8yfavaoj8Xh4N1x5YHVztHVkhUodSI7aZmvGNwLlcape xbYHLcNZfrNsnrDwXGskXxuL7aAf95wDwQ== X-Google-Smtp-Source: ABdhPJzbE8e1oi54CxBEZF/+zloqNuTod12Du8FrQiLQWV/nPVsFTeZjq7ln50yLnua3vkLefKDmNg== X-Received: by 2002:ab0:26c4:: with SMTP id b4mr4181834uap.10.1624632159154; Fri, 25 Jun 2021 07:42:39 -0700 (PDT) Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com. [209.85.222.48]) by smtp.gmail.com with ESMTPSA id b14sm1049415vke.45.2021.06.25.07.42.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Jun 2021 07:42:38 -0700 (PDT) Received: by mail-ua1-f48.google.com with SMTP id f34so3641347uae.4 for ; Fri, 25 Jun 2021 07:42:38 -0700 (PDT) X-Received: by 2002:a25:ad60:: with SMTP id l32mr10591974ybe.276.1624632147433; Fri, 25 Jun 2021 07:42:27 -0700 (PDT) MIME-Version: 1.0 References: <20210624171759.4125094-1-dianders@chromium.org> In-Reply-To: From: Doug Anderson Date: Fri, 25 Jun 2021 07:42:15 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 0/3] iommu: Enable non-strict DMA on QCom SD/MMC To: Joerg Roedel X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210625_074240_530292_AB67937A X-CRM114-Status: GOOD ( 36.89 ) 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: , Cc: Ulf Hansson , Linux Doc Mailing List , Peter Zijlstra , linux-pci@vger.kernel.org, Konrad Dybcio , Jordan Crouse , Thierry Reding , Joel Fernandes , Rajat Jain , Will Deacon , Rob Clark , Sai Prakash Ranjan , Saravana Kannan , Jonathan Corbet , quic_c_gdjako@quicinc.com, Linux ARM , Viresh Kumar , Veerabhadrarao Badiganti , "Paul E. McKenney" , linux-arm-msm , John Garry , Nicolin Chen , Bjorn Helgaas , Bjorn Andersson , Sonny Rao , Vlastimil Babka , Randy Dunlap , Linux MMC List , Adrian Hunter , LKML , "list@263.net:IOMMU DRIVERS , Joerg Roedel , " , Andrew Morton , Robin Murphy , "Maciej W. Rozycki" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Fri, Jun 25, 2021 at 6:19 AM Joerg Roedel wrote: > > Hi Douglas, > > On Thu, Jun 24, 2021 at 10:17:56AM -0700, Douglas Anderson wrote: > > The goal of this patch series is to get better SD/MMC performance on > > Qualcomm eMMC controllers and in generally nudge us forward on the > > path of allowing some devices to be in strict mode and others to be in > > non-strict mode. > > So if I understand it right, this patch-set wants a per-device decision > about setting dma-mode to strict vs. non-strict. > > I think we should get to the reason why strict mode is used by default > first. Is the default on ARM platforms to use iommu-strict mode by > default and if so, why? > > The x86 IOMMUs use non-strict mode by default (yes, it is a security > trade-off). It is certainly a good question. I will say that, as per usual, I'm fumbling around trying to solve problems in subsystems I'm not an expert at, so if something I'm saying sounds like nonsense it probably is. Please correct me. I guess I'd start out by thinking about what devices I think need to be in "strict" mode. Most of my thoughts on this are in the 3rd patch in the series. I think devices where it's important to be in strict mode fall into "Case 1" from that patch description, copied here: Case 1: IOMMUs prevent malicious code running on the peripheral (maybe a malicious peripheral or maybe someone exploited a benign peripheral) from turning into an exploit of the Linux kernel. This is particularly important if the peripheral has loadable / updatable firmware or if the peripheral has some type of general purpose processor and is processing untrusted inputs. It's also important if the device is something that can be easily plugged into the host and the device has direct DMA access itself, like a PCIe device. Using sc7180 as an example (searching for iommus in sc7180.dtsi), I'd expect these peripherals to be in strict mode: * WiFi / LTE - I'm almost certain we want this in "strict" mode. Both have loadable / updatable firmware and both do complex processing on untrusted inputs. Both have a history of being compromised over the air just by being near an attacker. Note that on sc7180 these are _not_ connected over PCI so we can't leverage any PCI mechanism for deciding strict / non-strict. * Video decode / encode - pretty sure we want this in strict. It's got loadable / updatable firmware and processing complex / untrusted inputs. * LPASS (low power audio subsystem) - I don't know a ton and I think we don't use this much on our designs, but I believe it meets the definitions for needing "strict". * The QUPs (handles UART, SPI, and i2c) - I'm not as sure here. These are much "smarter" than you'd expect. They have loadable / updatable firmware and certainly have a sort of general purpose processor in them. They also might be processing untrusted inputs, but presumably in a pretty simple way. At the moment we don't use a ton of DMA here anyway and these are pretty low speed, so I would tend to leave them as strict just to be on the safe side. I'd expect these to be non-strict: * SD/MMC - as described in this patch series. * USB - As far as I know firmware isn't updatable and has no history of being compromised. Special: * GPU - This already has a bunch of special cases, so we probably don't need to discuss here. As far as I can tell everything in sc7180.dtsi that has an "iommus" property is classified above. So, unless I'm wrong and it's totally fine to run LTE / WiFi / Video / LPASS in non-strict mode then: * We still need some way to pick strict vs. non-strict. * Since I've only identified two peripherals that I think should be non-strict, having "strict" the default seems like fewer special cases. It's also safer. In terms of thinking about x86 / AMD where the default is non-strict, I don't have any historical knowledge there. I guess the use of PCI for connecting WiFi is more common (so you can use the PCI special cases) and I'd sorta hope that WiFi is running in strict mode. For video encode / decode, perhaps x86 / AMD are just accepting the risk here because there was no kernel infrastructure for doing better? I'd also expect that x86/AMD don't have something quite as crazy as the QUPs for UART/I2C/SPI, but even if they do I wouldn't be terribly upset if they were in non-strict mode. ...so I guess maybe the super short answer to everything above is that I believe that at least WiFi ought to be in "strict" mode and it's not on PCI so we need to come up with some type of per-device solution. -Doug _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel