Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4998605pxj; Tue, 22 Jun 2021 12:45:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLGIXf6knDk6yGkTASZtqVmrSC8LLCMfZpt3jrcHnRnR1oMbX6Jv4q2/IkI5ZN/EeDdGmz X-Received: by 2002:a92:901:: with SMTP id y1mr244498ilg.212.1624391150735; Tue, 22 Jun 2021 12:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624391150; cv=none; d=google.com; s=arc-20160816; b=DoLUK7R0ztvD3wBJAVp/IQI5Emk+itDDBxDqPosir81c5/2vj0chmE9om5fWnZB3h/ vGWPQwW86KTHoinb5fBPaC37zFoKB2BJMqe3qFgaa44lTmJL/6eztgNewq/olohn6YdV fKOghEYJ/wt1vfqWMaC99QWoFQvhNd0NFgaSanfEsQRNrUjdOvUq6WSP/kr8J0v50d6m gcIkZTuXXfjTrAhn+MHQ8CHSrOzPMavOd6tds9lSFz3ZNuYc9nVinSxwZGEf1gTh2WSh 2C4cQORH82MwqgOzTvitlt+shxBtk3aJyttlwETiaRIaqa0WCQCCdqbz/kBGvu3R7Mkl cGEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KbphWW+YCq0HiY8JKMK80s61y/VI/u5uRCvjvuYgRvo=; b=efVZvKtbYidNN+tkxI+7zrNW+g9Zbfd5V7Wpx4XegoSKVWge06oSVwLAg0nqQ+Pifq q7qwdF0CHL5D5jNuBRZLEdQ5cLX62Jr5IM6+jCjkGSnBNOaojj9U39uyoBPMphZ8fSz9 RtSM4cLYH1iL+ULSoeYoixQukiZ7W6UNxWddPBVJrGM8w+3lAXbHSiIaDGuxiCewiGOq aC39VLXtVaMxlb0sh9IqV/kgSZfe/xO/pTs4/8CmtNifOexrbaM7zRuWEF/r61O5gwiu 9GO5QJIhf/lv+/Smyg4HH4NA8OCywCz38ySFd+5BC4NigQ6imfEAechHq+9uwzNB/mxS 5/cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B0KKMBDv; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e14si332716jaq.1.2021.06.22.12.45.37; Tue, 22 Jun 2021 12:45:50 -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=@chromium.org header.s=google header.b=B0KKMBDv; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232721AbhFVToW (ORCPT + 99 others); Tue, 22 Jun 2021 15:44:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232631AbhFVToN (ORCPT ); Tue, 22 Jun 2021 15:44:13 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83C7C06175F for ; Tue, 22 Jun 2021 12:35:23 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id d19so599981oic.7 for ; Tue, 22 Jun 2021 12:35:23 -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=KbphWW+YCq0HiY8JKMK80s61y/VI/u5uRCvjvuYgRvo=; b=B0KKMBDv6mmc1lnaI4uPkAm6cPTmdb7TIXjhicSbGznIFUVv9JjjbjCqNCaOd7EpYM pnnEU8sbe0AVpMJXATFzGWXRlVkOSlojtJ9YUkl0HamHxDkd3CMgYIcUaibp/wBrGa39 arNtBQL0FAKJSiCk0bIOZEIS47O+vz6l2FCAk= 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=KbphWW+YCq0HiY8JKMK80s61y/VI/u5uRCvjvuYgRvo=; b=kVtbyMm9HQEM7yKBmLjjfTMOhZ04iiE3Ui2LZYlmvUhbXrG49BFqvSYHUYVUX44QAf 4qNtM0aLkldhSDd8ANQ3UofTRIdsxNXcpQkwkGQz/EGE8Wm7XUpm6wOeKXH1lK44KGja MIjOJyPHiOackQ+vDGA57TSCIwih3jiQ6rVWy6Jy3hrZDaMqgmL9E7hLerP+rnc+lO+q nZREPOreCB+E408O0pDcO/dKOjT2AtStcH2LUV6u5Wbh63fuPXRqXAhDWgKh4Gh/C43R 7cfg3wy3s4Ufe93UOXgK3+I7uEfGQnYN5PXzGlYDG+L1KjatVjVRWY0APcCaXlXeTu7w ZZbA== X-Gm-Message-State: AOAM530vLIt1z8YTGz1/DROj5S5LhLE9nnN7fWWQEP8Zy+791GYsjKX1 aHceY3E1WYr5vSBMlunCtbdLpj1G0q+6Cg== X-Received: by 2002:aca:c688:: with SMTP id w130mr311547oif.116.1624390522941; Tue, 22 Jun 2021 12:35:22 -0700 (PDT) Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com. [209.85.210.44]) by smtp.gmail.com with ESMTPSA id v10sm671944ool.45.2021.06.22.12.35.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Jun 2021 12:35:22 -0700 (PDT) Received: by mail-ot1-f44.google.com with SMTP id w23-20020a9d5a970000b02903d0ef989477so22268177oth.9 for ; Tue, 22 Jun 2021 12:35:22 -0700 (PDT) X-Received: by 2002:a25:2405:: with SMTP id k5mr6758869ybk.405.1624390512166; Tue, 22 Jun 2021 12:35:12 -0700 (PDT) MIME-Version: 1.0 References: <20210621235248.2521620-1-dianders@chromium.org> <20210621165230.4.Id84a954e705fcad3fdb35beb2bc372e4bf2108c7@changeid> In-Reply-To: From: Doug Anderson Date: Tue, 22 Jun 2021 12:35:00 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/6] iommu: Combine device strictness requests with the global default To: Rajat Jain Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , "Rafael J. Wysocki" , Will Deacon , Robin Murphy , Joerg Roedel , Bjorn Andersson , Ulf Hansson , Adrian Hunter , Bjorn Helgaas , Rob Clark , linux-arm-msm , linux-pci@vger.kernel.org, quic_c_gdjako@quicinc.com, "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Sonny Rao , Sai Prakash Ranjan , Linux MMC List , Veerabhadrarao Badiganti , Saravana Kannan , Joel Fernandes , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Jun 22, 2021 at 11:45 AM Rajat Jain wrote: > > On Mon, Jun 21, 2021 at 4:53 PM Douglas Anderson wrote: > > > > In the patch ("drivers: base: Add bits to struct device to control > > iommu strictness") we add the ability for devices to tell us about > > their IOMMU strictness requirements. Let's now take that into account > > in the IOMMU layer. > > > > A few notes here: > > * Presumably this is always how iommu_get_dma_strict() was intended to > > behave. Had this not been the intention then it never would have > > taken a domain as a parameter. > > * The iommu_set_dma_strict() feels awfully non-symmetric now. That > > function sets the _default_ strictness globally in the system > > whereas iommu_get_dma_strict() returns the value for a given domain > > (falling back to the default). Presumably, at least, the fact that > > iommu_set_dma_strict() doesn't take a domain makes this obvious. > > > > The function iommu_get_dma_strict() should now make it super obvious > > where strictness comes from and who overides who. Though the function > > changed a bunch to make the logic clearer, the only two new rules > > should be: > > * Devices can force strictness for themselves, overriding the cmdline > > "iommu.strict=0" or a call to iommu_set_dma_strict(false)). > > * Devices can request non-strictness for themselves, assuming there > > was no cmdline "iommu.strict=1" or a call to > > iommu_set_dma_strict(true). > > Along the same lines, I believe a platform (device tree / ACPI) should > also be able to have a say in this. I assume in your proposal, a > platform would expose a property in device tree which the device > driver would need to parse and then use it to set these bits in the > "struct device"? Nothing would prevent creating a device tree or ACPI property that caused either "force-strict" or "request-non-strict" from being set if everyone agrees that it's a good idea. I wouldn't reject the idea myself, but I do worry that we'd devolve into the usual bikeshed for exactly how this should look. I talked about this a bit in my response to Saravana, but basically: * If there was some generic property, would we call it "untrusted", "external", or something else? * How do you describe "trust" in a generic "objective" way? It's not really boolean and trying to describe exactly how trustworthy something should be considered is hard. * At least for the device tree there's a general requirement that it describes the hardware and not so much how the software should configure the hardware. As I understand it there is _some_ leeway here where it's OK to describe how the hardware was designed for the OS to configure it, but it's a pretty high bar and a hard sell. In general the device tree isn't supposed to be used to describe "policy". In other words: if one OS might decide on one setting and another OS on another then it doesn't really belong in the device tree. * In general the kernel is also not really supposed to have policy hardcoded in either, though it feels like we can get away with having a good default/sane policy and allowing overriding the policy with command line parameters (like iommu.strict). In the case where something has to be configured at bootup there's not many ways to do better. tl;dr: I have no plans to try to make an overarching property, but my patch series does allow subsystems to come up with and easily implement their own rules as it makes sense. While this might seem hodgepodge I prefer to see it as "flexible" since I'm not convinced that we're going to be able to come up with an overarching trust framework. -Doug