Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1206467pxb; Fri, 21 Jan 2022 12:14:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3ODwj2BQM5hVGH14pfzmNIrJoqE5DwOzr8+LImT72Djv0NGJIkZURnh31Uxyo8Js7i18e X-Received: by 2002:a17:902:e80f:b0:14a:43d9:c91 with SMTP id u15-20020a170902e80f00b0014a43d90c91mr5145302plg.160.1642796046378; Fri, 21 Jan 2022 12:14:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642796046; cv=none; d=google.com; s=arc-20160816; b=Nzw9iiZl2lvsEqNcs/4a2RNA5X3je2oMQVutSFWqfq2DfG6TA8E9DL3EIkWKF+QTkf IFtCxmFowUo64nddTO92J7pN6miNJfRl8moGpGEhGttCnhHd4PUhL+Qt2jQU15SOnQR8 QCgwqf6Xv+8OifOj1b9Lc5mexjnPqu3/pn0qpoPOdsuMlkJvx24EvlXaqjzffMMy0iNk FLMqBo1JJOMVPjYPR9YysVNSr7UIN+3qS4w2pxNfDLzEat4w20ITY5XbQlS0wc1P8O8o vrpxWgDpwViFdKvkPKT3ruOxi6LVdb/sPMD+DTo7cjksV9xxUUCvhXSyjQoT/eiKpjJf XW7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=k7+5PtSi2SaE/0SJmGi4QGUE4EmxDvz5Ukuy4725lAE=; b=g4mv/HhgKrI10FMuz6t0EMGtUZpQ/Uwz8acCow53tTkTWF/StmL4it/Zszr+vviiQ0 1r7M++7qs+axXtBGnxflGJoIuF8hL5lknNSjswS8dFKPscVpp+sHzR38pJr2ptF9gsSk xLgXSlLlTEMKxjKDaN4hksK89F3rNFhlLFemIYTaQ4oNOBmxQdg3vg+XOvSrW76P8Qq2 oYRje74ZW2kI0IKBfNsN+BnU+uaLaY0r/c7aePWDfxNugCHU2qTXp03LmerAUF1Blgtb 0DDMQ4MjcGTpCYhZlmWQt+DmIAAIBjK12OUVz2i9Q+ce6IZCUXTirJPT78u8Mq7nEP2r AEIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Iyr+MG88; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 189si6411396pga.684.2022.01.21.12.13.52; Fri, 21 Jan 2022 12:14:06 -0800 (PST) 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=@google.com header.s=20210112 header.b=Iyr+MG88; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344718AbiATAER (ORCPT + 99 others); Wed, 19 Jan 2022 19:04:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344602AbiATAEP (ORCPT ); Wed, 19 Jan 2022 19:04:15 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 687FEC06173E for ; Wed, 19 Jan 2022 16:04:15 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id v70-20020a25c549000000b006130de5790aso8207860ybe.4 for ; Wed, 19 Jan 2022 16:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=k7+5PtSi2SaE/0SJmGi4QGUE4EmxDvz5Ukuy4725lAE=; b=Iyr+MG88n+iHRt04O0HAxgK5CL4awNioywRv0cYQLtlwJ7Cp2SF2E+wRqKyckrKrSy hmfqoFYVLlfPXiyjZU06fsJiaM/B8aeEaNl3VbXQGhaWdYv6ndFzA8ejdebFsaE4eeIH kEvmt22o01TDRtXrlTgL3RIJthagpYwzNqQ089bNvHagB0KLUVE+3Qebav6fE5W+MVK6 0aES0QD7R8qT9H/ciOd7arS2npXxDYv2+lDyzoviHA4D/0fKmtDzFqx3ZZuExjD1dTVD 6mRh2ScSTKfbsEbGwT5BFTnd5Hj5sxoVitLpDVQeh5FObEJFXH+HRD6SHTvrHlLmyzbR fK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=k7+5PtSi2SaE/0SJmGi4QGUE4EmxDvz5Ukuy4725lAE=; b=Vhe8De35opc4KT6heD2TXbkG+L1xVHNCSAOi2uZ7bAklG6Ltly0jtI49wsoJkeNlNi jG02Si3MDwEVJ7m6vq+LRNKqwovRawzj3kM1q2qDf1KMf3vBXsN5iYnqlWlUm1YMnbTW vLkueFIuV2AK5VFV3p7Pib+6nzTll6Vq6otc4GMmcmTayA06aIeCqAWxUW1hG2fZ/gP1 P3I9dZ7ZsW8rJqxmuSry7TWPQIn00RlvPyBYLwh69Zj9Ha2BO0drEtArZ6a8vZwZfTxU tz+5zMh/y21j7GSEzjhNPhSzLFZzBKrZxRB4tJWkdb3ZtIrDhvT/Om/NCtiyTQKBJOlh 636g== X-Gm-Message-State: AOAM5331RcrYljoO9bW5xc2VZU25nYWIJnIlicjRxY+auFJPQj6WlGTd DLVkxcQH30nNf8t9tWRiozzcGfXRh1TR X-Received: from rajat2.mtv.corp.google.com ([2620:15c:202:201:4305:5632:a281:7eb0]) (user=rajatja job=sendgmr) by 2002:a25:7e87:: with SMTP id z129mr45619551ybc.719.1642637054515; Wed, 19 Jan 2022 16:04:14 -0800 (PST) Date: Wed, 19 Jan 2022 16:04:09 -0800 Message-Id: <20220120000409.2706549-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [PATCH] PCI: ACPI: Allow internal devices to be marked as untrusted From: Rajat Jain To: "Rafael J. Wysocki" , Len Brown , Bjorn Helgaas , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajat Jain , rajatxjain@gmail.com, dtor@google.com, jsbarnes@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Today the pci_dev->untrusted is set for any devices sitting downstream an external facing port (determined via "ExternalFacingPort" property). This however, disallows any internal devices to be marked as untrusted. There are use-cases though, where a platform would like to treat an internal device as untrusted (perhaps because it runs untrusted firmware, or offers an attack surface by handling untrusted network data etc). This patch introduces a new "UntrustedDevice" property that can be used by the firmware to mark any device as untrusted. Signed-off-by: Rajat Jain --- drivers/pci/pci-acpi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index a42dbf448860..3d9e5fa49451 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1350,12 +1350,25 @@ static void pci_acpi_set_external_facing(struct pci_dev *dev) dev->external_facing = 1; } +static void pci_acpi_set_untrusted(struct pci_dev *dev) +{ + u8 val; + + if (device_property_read_u8(&dev->dev, "UntrustedDevice", &val)) + return; + + /* These PCI devices are not trustworthy */ + if (val) + dev->untrusted = 1; +} + void pci_acpi_setup(struct device *dev, struct acpi_device *adev) { struct pci_dev *pci_dev = to_pci_dev(dev); pci_acpi_optimize_delay(pci_dev, adev->handle); pci_acpi_set_external_facing(pci_dev); + pci_acpi_set_untrusted(pci_dev); pci_acpi_add_edr_notifier(pci_dev); pci_acpi_add_pm_notifier(adev, pci_dev); -- 2.34.1.703.g22d0c6ccf7-goog