Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp959592pxp; Wed, 16 Mar 2022 22:41:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFpYysbvQpNZPLV5OGKyiCj/sZRqYJahIC6M8WDzEYl9rNHN6djXmiJ/PC1+C+n6duQmjR X-Received: by 2002:a05:6a00:2485:b0:4f7:37cd:d040 with SMTP id c5-20020a056a00248500b004f737cdd040mr2712839pfv.55.1647495665652; Wed, 16 Mar 2022 22:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647495665; cv=none; d=google.com; s=arc-20160816; b=QjmaLFOwYGIIrtRveuAJHxo8Cst29ThhJHNVj4LWpheTHW9kHSNOpLu0L4hE/jne3T 7fdly1cRC/szj3xDrtDu+KeaHplLoFAIaZ9uJn4/nZE3FAjPq4K8hbAzEUwQlYEI8K1P uBuYFLti39Aw/QpnFtlPn0YTFsOYjh/WQ9IpZXqre3CGLSggZLJao89AAZkAAHA/feGo wzW3h5hwWdPXcVEpfqLYvjrSOS3IuE3gH/xxXaZkV/gHfq267cuxlxAIy5xf+lEzaYBY yL0l7/dyKuv1o7qF8a2WIYbq0HyX52eg1LN41rwEJBtgHNnJVgBWFdvkWHvEZ/OtwjO5 VwEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6FOJqwWcsRFUMrMsj+l4kV7kA/b61VXcaqhh4xyDxII=; b=YdG3v+SR1jrOWVtLvfegehAvEV5OBoseCsqvQ5BLvCIgUDDGUW3YbOP+hHR6sf96JC IAwq7BCcBo8qbIA1qakW9nPh6Z2RtvKQujiD/HIn0TLe40+K8vRe4HJDY8IOPZCKyEH1 Zs6hjkMAT0PLDyWGl+oRh1VRHxovGsE7GNWMWLrOjckIAeVBkqKnqGy6HRyntWJmC93f qzPeSYUTHF426rHAeO2IvFKeKI5uNr0URb+fkNkLLPGD4n8xip293IbZp3phayoVltbW LerxXXn2q173WaAclABHpLpoIbqYM5yL08Ohej/kUFREqY8HORnH2kAhj8W55rly7gt5 jbZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Xzy1ll8e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i25-20020aa78d99000000b004f0fc0ad94fsi3682368pfr.87.2022.03.16.22.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:41:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Xzy1ll8e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C774111753; Wed, 16 Mar 2022 21:49:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357634AbiCPRia (ORCPT + 99 others); Wed, 16 Mar 2022 13:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357657AbiCPRi1 (ORCPT ); Wed, 16 Mar 2022 13:38:27 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B692068FB6; Wed, 16 Mar 2022 10:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647452232; x=1678988232; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=O35iNXQlRH+OS+APj1svNRdnOY4rt7s7kW6OPFwzhnA=; b=Xzy1ll8ePcbMN4hVXc0iG+h8pU/7SNcX3nHhfFKgy1NMtjHUefLjonTS UjgpcY5/hlN+NuD/TmDtZlhPlt0x/KAnyhOC4r9w1lLJVbikeaRVqpmUE IMQJ1w0yYeSgDw3LTHDDQdc9HaIWSMlcuAf1btL5U/syIgHy8biRGO126 CLw5lLUKdJrXIdKbhV/iXC4i5aLnWoiSod3eAfU+69g/Ri2K7+Q9a8tpP 4qkynTlZyBdDXtdGW/WXEuA8ckz+28qw7pAFvsVjyBlxbZn9Yo13Esmr7 ZPHI6d+RzIP1ZXJgXyJe6gwonpO0z7Q+NqsctCS00wH4bTK7PG3sWdnsI A==; X-IronPort-AV: E=McAfee;i="6200,9189,10288"; a="236619157" X-IronPort-AV: E=Sophos;i="5.90,187,1643702400"; d="scan'208";a="236619157" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2022 10:37:12 -0700 X-IronPort-AV: E=Sophos;i="5.90,187,1643702400"; d="scan'208";a="516437363" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.162]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2022 10:37:08 -0700 Received: by lahna (sSMTP sendmail emulation); Wed, 16 Mar 2022 19:37:05 +0200 Date: Wed, 16 Mar 2022 19:37:05 +0200 From: Mika Westerberg To: "Limonciello, Mario" Cc: Robin Murphy , "andreas.noever@gmail.com" , "michael.jamet@intel.com" , "YehezkelShB@gmail.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "hch@lst.de" Subject: Re: [PATCH] thunderbolt: Stop using iommu_present() Message-ID: References: <16852eb2-98bb-6337-741f-8c2f06418b08@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hi Mario, On Wed, Mar 16, 2022 at 05:24:38PM +0000, Limonciello, Mario wrote: > [Public] > > > On Wed, Mar 16, 2022 at 02:49:09PM +0000, Robin Murphy wrote: > > > > What we want is to make sure the Tunneled PCIe ports get the full > > IOMMU > > > > protection. In case of the discrete above it is also fine if all the > > > > devices behind the PCIe root port get the full IOMMU protection. Note in > > > > the integrated all the devices are "siblings". > > > > > > Ah, OK, I wasn't aware that the NHI isn't even the right thing in the first > > > place :( > > > > > > Is there an easy way to get from the struct tb to a PCI device representing > > > the end of its relevant tunnel, or do we have a circular dependency > > problem > > > where the latter won't appear until we've authorised it (and thus the > > IOMMU > > > layer won't know about it yet either)? > > > > The PCIe root ports (and the PCIe downstream ports) are there already > > even without "authorization". > > > > There is a way to figure out the "tunneled" PCIe ports by looking at > > certain properties and we do that already actually. The BIOS has the > > following under these ports: > > > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs > > .microsoft.com%2Fen-us%2Fwindows-hardware%2Fdrivers%2Fpci%2Fdsd- > > for-pcie-root-ports%23identifying-externally-exposed-pcie-root- > > ports&data=04%7C01%7Cmario.limonciello%40amd.com%7C0465d319a > > 6684335d9c208da07710e7c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7 > > C0%7C637830479402895833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w > > LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&am > > p;sdata=z6hpYGpj%2B%2BVvz9d6MXiO4N66PUm4zwhOdI%2Br6l3PjhQ%3D > > &reserved=0 > > > > and the ports will have dev->external_facing set to 1. Perhaps looking > > at that field helps here? > > External facing isn't a guarantee from the firmware though. It's something we > all expect in practice, but I think it's better to look at the ones that are from > the _DSD usb4-host-interface to be safer. Right but then we have the discrete ones with the DVSEC that exposes the tunneled ports :( > Mika, you might not have seen it yet, but I sent a follow up diff in this thread > to Robin's patch. If that looks good Robin can submit a v2 (or I'm happy to do > so as well as I confirmed it helps my original intent too). I saw it now and I'm thinking are we making this unnecessary complex? I mean Microsoft solely depends on the DMAR platform opt-in flag: https://docs.microsoft.com/en-us/windows/security/information-protection/kernel-dma-protection-for-thunderbolt We also do turn on full IOMMU mappings in that case for devices that are marked as external facing by the same firmware that provided the DMAR bit. If the user decides to disable IOMMU from command line for instance then we expect she knows what she is doing.