Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2233282pxp; Mon, 21 Mar 2022 14:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9UM2AR2zCxArR1Z2EIvVgdmhoS9yFESZGcE98g1DbWR6GFqII60zdZhoRgW98SzTB4Uq1 X-Received: by 2002:a62:3896:0:b0:4f7:87dc:de5b with SMTP id f144-20020a623896000000b004f787dcde5bmr26135480pfa.49.1647898281670; Mon, 21 Mar 2022 14:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647898281; cv=none; d=google.com; s=arc-20160816; b=SpXhcMJoWuGiAlqy6TepXKTsRCcU8Hg2ftCjJxhAZNt9tNn+gdK67aJPwl13yvAGoL bG+mZPk5lBNH6gPLsCuCRC2XwXgQ/iQVCkcrd7Py4H3mFQX3jrq7d0aIqBeuPUP/E/xv SvV9HHB1I8TIiJatbT2z547Zr93cLRGfZPMfdwFPSRBoB/6rBfQAHBuIRoey0T+8T67w v/UicFm7xQjJKin2rJ+8BMwfBCp/7ZMZ788P1RVQADmAaPfRc5BmpxYLfX/CM08L8QiG 2YWnx99HyStkAnJmp7kC4W9tpTQSLxnBtmUQaoko+hczinM56vRlPLQBGUtiz1hd933G KJgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=+Fd+e/PIVAgqSqfs+Lo1xEDdEZvGfEVvV8gNJgP0d6Y=; b=Z4cqgzDutFOqtUeEp7qhrR2y3MltMgQ0aEnTnJatrMQYEToPvmnJxthDlvJeR5ihJB sNGEj9adLtlaThLU0hpC/P5xs2dE0kwcnD04vAOW9wT5XMcka6MUe0kOClSgNGLfkjy2 PzNlvBKrqQpE6DCIA7gDkhdSC7xZ+/489HOgXdkjlDgVqxm5CiL8KMpv4H765UxsrJ6k s9Dr5o6zCt8jk3BiswM7yTTURW4SFBDeCNF68Pj0Vmh/e1d9VEwCqaiFyERVgENzyzSm 9SleGunmI93PDoPqGplsLEFJ4tnYgp86aQejkZEW6ymJ3bM2vWAHr9aarnaV2L6J6nXC 8jcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 129-20020a630487000000b0038216f93fadsi12632169pge.326.2022.03.21.14.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 14:31:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F164215917; Mon, 21 Mar 2022 14:10:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346700AbiCULNS (ORCPT + 99 others); Mon, 21 Mar 2022 07:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345241AbiCULNO (ORCPT ); Mon, 21 Mar 2022 07:13:14 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BA39393E7; Mon, 21 Mar 2022 04:11:49 -0700 (PDT) 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 DF93C1042; Mon, 21 Mar 2022 04:11:48 -0700 (PDT) Received: from [10.57.43.230] (unknown [10.57.43.230]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA0783F766; Mon, 21 Mar 2022 04:11:46 -0700 (PDT) Message-ID: Date: Mon, 21 Mar 2022 11:11:42 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2 2/2] thunderbolt: Make iommu_dma_protection more accurate Content-Language: en-GB To: "mika.westerberg@linux.intel.com" , "Limonciello, Mario" Cc: "joro@8bytes.org" , "baolu.lu@linux.intel.com" , "andreas.noever@gmail.com" , "michael.jamet@intel.com" , "YehezkelShB@gmail.com" , "iommu@lists.linux-foundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "hch@lst.de" References: <0dd14883930c9f55ace22162e23765a37d91a057.1647624084.git.robin.murphy@arm.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-03-21 10:58, mika.westerberg@linux.intel.com wrote: > Hi Mario, > > On Fri, Mar 18, 2022 at 10:29:59PM +0000, Limonciello, Mario wrote: >> [Public] >> >>> Between me trying to get rid of iommu_present() and Mario wanting to >>> support the AMD equivalent of DMAR_PLATFORM_OPT_IN, scrutiny has >>> shown >>> that the iommu_dma_protection attribute is being far too optimistic. >>> Even if an IOMMU might be present for some PCI segment in the system, >>> that doesn't necessarily mean it provides translation for the device(s) >>> we care about. Furthermore, all that DMAR_PLATFORM_OPT_IN really does >>> is tell us that memory was protected before the kernel was loaded, and >>> prevent the user from disabling the intel-iommu driver entirely. While >>> that lets us assume kernel integrity, what matters for actual runtime >>> DMA protection is whether we trust individual devices, based on the >>> "external facing" property that we expect firmware to describe for >>> Thunderbolt ports. >>> >>> It's proven challenging to determine the appropriate ports accurately >>> given the variety of possible topologies, so while still not getting a >>> perfect answer, by putting enough faith in firmware we can at least get >>> a good bit closer. If we can see that any device near a Thunderbolt NHI >>> has all the requisites for Kernel DMA Protection, chances are that it >>> *is* a relevant port, but moreover that implies that firmware is playing >>> the game overall, so we'll use that to assume that all Thunderbolt ports >>> should be correctly marked and thus will end up fully protected. >>> >> >> This approach looks generally good to me. I do worry a little bit about older >> systems that didn't set ExternalFacingPort in the FW but were previously setting >> iommu_dma_protection, but I think that those could be treated on a quirk >> basis to set PCI IDs for those root ports as external facing if/when they come >> up. > > There are no such systems out there AFAICT. And even if there are, as above they've never actually been fully protected and still won't be, so it's arguably a good thing for them to stop thinking so. >> I'll send up a follow up patch that adds the AMD ACPI table check. >> If it looks good can roll it into your series for v3, or if this series goes >> as is for v2 it can come on its own. >> >>> CC: Mario Limonciello >>> Signed-off-by: Robin Murphy >>> --- >>> >>> v2: Give up trying to look for specific devices, just look for evidence >>> that firmware cares at all. >> >> I still do think you could know exactly which devices to use if you're in >> SW CM mode, but I guess the consensus is to not bifurcate the way this >> can be checked. > > Indeed. > > The patch looks good to me now. I will give it a try on a couple of > systems later today or tomorrow and let you guys know how it went. I > don't expect any problems but let's see. > > Thanks a lot Robin for working on this :) Heh, let's just hope the other half-dozen or so subsystems I need to touch for this IOMMU cleanup aren't all quite as involved as this turned out to be :) Cheers, Robin.