Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp951176pxp; Wed, 16 Mar 2022 22:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjpDweq22xJZtE6VBRCha0HnebxpWrq+HPvuM9AGPlaZS5XfzLpQloGJf446g2xvScG76i X-Received: by 2002:a63:ef03:0:b0:374:7286:14d0 with SMTP id u3-20020a63ef03000000b00374728614d0mr2333148pgh.552.1647494674882; Wed, 16 Mar 2022 22:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494674; cv=none; d=google.com; s=arc-20160816; b=de+QYQobJox5//zBJ+gia71uV85KnEFqEDpo/vywb9TUlASoVe4F2qIagKUSX62XpB kGz0nHQYjI2qAgoZMPSkFOVGDFLyfNCj8E7hNvy6xKBwRuMhEhJYzdxkDUaHkDwS4yGf y6BV9+/EMsMPFFd5QpvpbnRLH67FYu3gRYxM1VODPO+mR3tzQIv2zl6o8XqslrPLfAi1 xuwdL2iE9fSDwMr6I7gluzM4DmxpzNED5z+dEjB/J/9yBL5hRgkXWaTp0Oy6D1zus791 Y7Xf4dePldtaAIcfU48yPLT/fp6otdZbGeoNx05vtS/e7+BtY8gIEyDmWujrsNvpjcxV IFlw== 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=phCuGpUSl/7vUtBRyNneiGacNH8cOXddoAbmy6jnnO4=; b=Wlub4eY2jpHwj0BRHG25SYyB/nsol3d/VYfZN5Haa9/itFBUI4dYo/woiCW4XNO19b fIcRqGqvEvXCXxMFz6hjNpZczbo6xMwXwrcmN3W/9d1XuBJ3nZAocM+ZuOVy8vRJRM+d +Nq2RBlfgV5+v4bcNrGgtr4HklXyryWcmYlecTO7q4d8JaP/Hnwujo9qz5DADXDsGBF0 RxN4cnz7bIYzNcvpEu7gU6fwKUl2VA+wUn+RpJFo/f+huBLkm5PbVTHaCYnAYsz8hWYY IK0ro08A+sT4lBwEo9qDAYsYVzEHCUZlE7RtJgjDnYAYsye6oZ4Vb0tZCI3SH7u79Yg6 woLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZMgq3Dhx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t195-20020a6378cc000000b003816043f014si1011916pgc.521.2022.03.16.22.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:24:34 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=ZMgq3Dhx; 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=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 33CC123D5BB; Wed, 16 Mar 2022 21:31:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239218AbiCPO4p (ORCPT + 99 others); Wed, 16 Mar 2022 10:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239650AbiCPO4o (ORCPT ); Wed, 16 Mar 2022 10:56:44 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EF6566AE4; Wed, 16 Mar 2022 07:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647442529; x=1678978529; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hSZezmWlLRnJispv91DeDwlHSOXFgX7BmpKgikab/4Q=; b=ZMgq3Dhxiy2526C/Hk4og9XQkNWPcuzAaS3/NYZpQK/R55oOxaTWSFMw OpdITwxgCKQaA3Rg4TeOSe7rFcokm1YqKsTZarg5y4mwIwEhxmguuKjQm ML7/fapB9+xmavczx/bE/M9SIojyCcJd2XyjOr3OckPG9MPpA/mXb0Tjq 7IKptN0GqeDadfOLvv68gOQwl7by+fdsaobQh+t8Bk2DzFCTQDOOMrXex m1FMSKQ79o7iooPsxDQPpoc0o9W+6rpVUA2BfEDirtN+DU1WtUWj4Pw1P viRpSszy09HnwTCjADUor2TdU6jvZXcYI4ymN2KLpp1dNOclJ+EYFk0HQ w==; X-IronPort-AV: E=McAfee;i="6200,9189,10286"; a="256806766" X-IronPort-AV: E=Sophos;i="5.90,186,1643702400"; d="scan'208";a="256806766" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2022 07:41:49 -0700 X-IronPort-AV: E=Sophos;i="5.90,186,1643702400"; d="scan'208";a="516364599" 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 07:41:45 -0700 Received: by lahna (sSMTP sendmail emulation); Wed, 16 Mar 2022 16:39:30 +0200 Date: Wed, 16 Mar 2022 16:39:30 +0200 From: Mika Westerberg To: "Limonciello, Mario" Cc: Andreas Noever , Michael Jamet , Yehezkel Bernat , "open list:THUNDERBOLT DRIVER" , open list Subject: Re: [RFC] thunderbolt: Automatically authorize PCIe tunnels when IOMMU is active Message-ID: References: <20220315213008.5357-1-mario.limonciello@amd.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 On Wed, Mar 16, 2022 at 01:48:49PM +0000, Limonciello, Mario wrote: > [Public] > > > > > IOMMU is active > > > > > > > > Hi Mario, > > > > > > > > On Tue, Mar 15, 2022 at 04:30:08PM -0500, Mario Limonciello wrote: > > > > > Historically TBT3 in Linux used "Thunderbolt security levels" as a primary > > > > > means of "security" against DMA attacks. This mean that users would > > need > > > > to > > > > > ack any device plugged in via userspace. In ~2018 machines started to > > use > > > > > the IOMMU for protection, but instead of dropping security levels a > > > > > convoluted flow was introduced: > > > > > * User hotplugs device > > > > > * Driver discovers supported tunnels > > > > > * Driver emits a uevent to userspace that a PCIe tunnel is present > > > > > * Userspace reads 'iommu_dma_protection' attribute (which currently > > > > > indicates an Intel IOMMU is present and was enabled pre-boot not > > that > > > > > it's active "now") > > > > > * Based on that value userspace then authorizes automatically or > > prompts > > > > > the user like how security level based support worked. > > > > > > > > There are legitimate reasons to disable PCIe tunneling even if the > > IOMMU > > > > bits are in place. The ACPI _OSC allows the boot firmware to do so and > > > > our "security levels" allows the userspace policy to do the same. I > > > > would not like to change that unless absolutely necessary. > > > > > > Actually I intentionally left that in the RFC patch, to only do this based off > > > of tb_acpi_may_tunnel_pcie, so I think that should still work as you > > described > > > if boot firmware turned off PCIe tunneling. > > > > Right but if the user still wants to disable it, like say you are > > travelling and you want to be sure that no PCIe devices get attached > > while your laptop is charging from a public "charging station" (whatever > > is the right term). > > So wouldn't you flip the default in BIOS setup to disable PCIe tunnels then for > this use case? What if you are on Chromebook? Or something where this is not user configurable? > Otherwise with how it is today you end up with the PCIe tunnel created in the > boot FW and then coming into the OS if it's the same path the tunnel stays > in place with no opportunity for userspace to authorize it, no? The boot FW does not need to support CM capabilites nor does it need to provide the ACPI _OSC.