Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1131428pxb; Wed, 29 Sep 2021 18:10:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9CQNL8uQ7iqASF6LK9a6GRanycunsb7a+x7rGrs6TvZgGJt5AfaQbFgLRqyubNWA/FJIb X-Received: by 2002:a17:907:628d:: with SMTP id nd13mr3593431ejc.7.1632964252509; Wed, 29 Sep 2021 18:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632964252; cv=none; d=google.com; s=arc-20160816; b=Zdod9Jm9gkkhJKOuJYPb7LZNt4ypgImY3MrKLPRYbAwTeu+pXQOzKkBhwDYoZbi9aL sc6i8RASyscyW97boXxzKLL82KXYFVsta8MuKeZgZ17Nq1kPcfAEMCWEAHA/Z9J7BdM7 X//1DPRA4vENxitYrO3IjqM0mQqLTIF/5YqFEFjxQvYga/scJ2UzL+hxF2QrkO/othBo 7bDG4Zps0w+Vf9l2v8MvwVVOtT+gIp77f/ZxS9nVntG8BCfjaZ/j3ANg0DrDaX/OFDl8 ynWoWHzIaMz3bGM45Tj6YIT7Ru3bZHQHq397FZyc1niVeWmHl6+ufMM7QeZJy3bHLo6U 2zaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hp7korL1mWTSt1xbZSGQnwCAshddwAW29YQr+tbvqrY=; b=uJz1L2klSY5lWIOVYMaubQ3AJigjUDOAGCZUBsaGduXYE2b9W255DCre1ZsQ//ToEG dFvV+OIB96lOfdF4P/52oSwoZbAoLfvh56fj6oB+q6fdpkEdb1Cm5Ve4/n+bsLLRd3uY /3RmED3KgW9jUsLWpd1cSfFJtpeEiyscdH1TqkGf7CD6wLrTHdvSjegJFkUfkGMrv6JT vjpS8aSQg9g36MQdoE7WZVTdiDFbAsFFyezzLvIlLaVV68qrsRsQDIWoNMXCkKCB7Q+B wo+AzwFQBCkVovnf6EW4sRwm4q02YubdqmCxVIiqS+7IHi+4owwU/fFSVObmJ00fEPLH 0nBA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si1999843ejk.41.2021.09.29.18.10.29; Wed, 29 Sep 2021 18:10:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347679AbhI3BH0 (ORCPT + 99 others); Wed, 29 Sep 2021 21:07:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:24480 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347601AbhI3BHT (ORCPT ); Wed, 29 Sep 2021 21:07:19 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="212330117" X-IronPort-AV: E=Sophos;i="5.85,334,1624345200"; d="scan'208";a="212330117" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2021 18:05:37 -0700 X-IronPort-AV: E=Sophos;i="5.85,334,1624345200"; d="scan'208";a="521027386" Received: from yzhu3-mobl.amr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.37.25]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2021 18:05:36 -0700 From: Kuppuswamy Sathyanarayanan To: Greg Kroah-Hartman , Borislav Petkov Cc: x86@kernel.org, Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Andreas Noever , "Michael S . Tsirkin" , Michael Jamet , Yehezkel Bernat , "Rafael J . Wysocki" , Mika Westerberg , Jonathan Corbet , Jason Wang , Dan Williams , Andi Kleen , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v2 6/6] PCI: Initialize authorized attribute for confidential guest Date: Wed, 29 Sep 2021 18:05:11 -0700 Message-Id: <20210930010511.3387967-7-sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930010511.3387967-1-sathyanarayanan.kuppuswamy@linux.intel.com> References: <20210930010511.3387967-1-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Confidential guest platforms like TDX have a requirement to allow only trusted devices. So initialize the "authorized" attribute using cc_guest_dev_authorized(). By default the confidential-guest core arranges for all devices to default to unauthorized (via dev_default_authorization) in device_initialize(). So, consult a core list of allowed devices to override that default. ARCH code will use its device allow list in cc_guest_dev_authorized() to determine the status of the authorized attribute. Reviewed-by: Dan Williams Signed-off-by: Kuppuswamy Sathyanarayanan --- drivers/pci/probe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index d9fc02a71baa..aab9d1917d52 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "pci.h" #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ @@ -2491,6 +2493,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) pci_configure_device(dev); device_initialize(&dev->dev); + if (cc_platform_has(CC_ATTR_GUEST_DEVICE_FILTER)) + dev->dev.authorized = cc_guest_dev_authorized(&dev->dev); dev->dev.release = pci_release_dev; set_dev_node(&dev->dev, pcibus_to_node(bus)); -- 2.25.1