Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp652924pxb; Thu, 17 Feb 2022 11:40:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxERn+3Eup1gyxsqfan1oxGqiwFqTb1OexCFvVsmcRtGtsC4peeQj5jiMvas/Pg1atZe1zY X-Received: by 2002:a17:906:40da:b0:6ce:51b:a593 with SMTP id a26-20020a17090640da00b006ce051ba593mr3681554ejk.604.1645126853519; Thu, 17 Feb 2022 11:40:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645126853; cv=none; d=google.com; s=arc-20160816; b=mOXIwhS2CE5qlF2TdjOCvUdZryPnefYYKBl1aAyYjASYAoAE5Oifeet1lwZTUbQOwB CnHSVD0lc7ACDnIvjJCMV18oBZbmcWLbDLhAqdUPXAJNyzU5UwEJ0Rgc+GMesqoLo+Q1 PqwF7yHu0G4UMfSCERtdhKgd5rdEI0IaZTI5rGUgNov2QAuAqDMNOMyeepVCkGfhFsD9 iso7qGnWJjubcmwa0f2wo9Zne0xv9wHLTwdGA0RKp8bobwO4jdSrNHiqCPXTdFLVgisx uMO06saR3n0QPeqvub0QiS2C7msH9YrvyqaVu3ixmT/wivpu0pInpl+qcsLLVLtxeI/i CrQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=O7XAdhfqnK4iH4EoLafYbReQ6dbwtazRaihHUR1ZOE0=; b=egTnxDpxJR/asYuSauhB6JEV7VG7CpGErRJsmqu1b17QGnyiMMgU2lKC70TrwW2lAX D0c0uklAua7SkJv2p/cgT3VfvrLyF9peLpAHqairEwEQbH1ljI4SM5B/AH/vctjUTaCf GjjtZhXemcttJhmdX3FYxTMioHg8AYudKB36ckMilwUvY2ThnJlaWMvNmbZ3pI6JdFYQ NZc09T6buVBGmpH8n3IdIf1PchNf3LyHYO3rX3z36TwtufiVRBS0i/+Qi0/RhS9koPc9 vHDsVrPY3K7XfqMUYEJeoXEUfCVEgy7fvHv5H1Y30YKfqNAzQW8wLTAO61OVxAQ3qtAy c6NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aOQEOW87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14si4765902edb.275.2022.02.17.11.40.30; Thu, 17 Feb 2022 11:40:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aOQEOW87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244294AbiBQS2H (ORCPT + 99 others); Thu, 17 Feb 2022 13:28:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244466AbiBQS1o (ORCPT ); Thu, 17 Feb 2022 13:27:44 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791DC1FA60 for ; Thu, 17 Feb 2022 10:27:16 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id 10so5255294plj.1 for ; Thu, 17 Feb 2022 10:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O7XAdhfqnK4iH4EoLafYbReQ6dbwtazRaihHUR1ZOE0=; b=aOQEOW87par6/hUQsWI+atBymO6HJq3KNqivVuk3LN53R/lXy0VZ1sMi9cb4Ezfu0k YcuA89dLFp6bwGyZBL0DWx0DNjvezBlAXmwcfKGPnFpt4zv+aWbt6ruHafRLZERyKDdg /ywSUhrnG7+TlBxdXQhUEjmKNDiJBIy4H4nAaiF2OPGqwZNNQkUMp1Yd1HVkzcfNQREr dhU+0IEc9tV0eofRN/OrDTJrycEHvvTySUNYqRbsJiA6fK2xbcn4vFEzHk5G2535nsn1 ibXnD79AQeOqK0rNYxPUuGKn7BVsj01prmiRItpZYCW9GkCaeB5OrPA/sZrA6GFkBsMx zHXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O7XAdhfqnK4iH4EoLafYbReQ6dbwtazRaihHUR1ZOE0=; b=z8tR6MCkAcp5M4NeKNZK3PVRGTYsLWbTfHsXTM6qCIQAua73S0Sxzd3nqfXjjHT0Gw h7nNp6mZsxG+pPOs9Cx5Eiew6d3tiKvDm+YbK3eMWw0rmLeaDfeT1YwTjhhg34Mx+vLc 1Q9lgwmt3SyfrBe61Oegpsh5v8DUfeWTXENf1i8W0C5MENP/LScCyS5l9IdOrNbA8bix elbHZJvNQBpRpUq8b4pg7D4cciTlf3Vgk8h7sNPTPt87I1HNRyXPMsrQuDLTPwIE/WNv 5YWSTr1YQvlcQfI+3WnhPjSjfjhVe6260lnLdpzoh0iVvzbk1Vz9wQNkaosN4QYv+Iqu 3bjw== X-Gm-Message-State: AOAM5309/4iX8bTjh56LBhmGEu2+anL72BCNBJhV5Zo1nAMyJ1A7MBoI exICTJ2t7LPef+saefKWfr84Oru6VISIlH88YjLHJLlgIv0= X-Received: by 2002:a17:902:ba96:b0:14c:8407:8e4b with SMTP id k22-20020a170902ba9600b0014c84078e4bmr3841382pls.135.1645122435705; Thu, 17 Feb 2022 10:27:15 -0800 (PST) MIME-Version: 1.0 References: <20220216220541.1635665-1-rajatja@google.com> In-Reply-To: From: Rajat Jain Date: Thu, 17 Feb 2022 10:26:39 -0800 Message-ID: Subject: Re: [PATCH v3] PCI: ACPI: Support Microsoft's "DmaProperty" To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Len Brown , linux-pci@vger.kernel.org, Mika Westerberg , Bjorn Helgaas , Bjorn Helgaas , ACPI Devel Maling List , Linux Kernel Mailing List , Rajat Jain , Dmitry Torokhov , Jesse Barnes , Jean-Philippe Brucker , Pavel Machek , "Oliver O'Halloran" , Joerg Roedel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Hello, On Wed, Feb 16, 2022 at 10:16 PM Greg Kroah-Hartman wrote: > > On Wed, Feb 16, 2022 at 02:05:41PM -0800, Rajat Jain wrote: > > The "DmaProperty" is supported and documented by Microsoft here: > > https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports > > They use this property for DMA protection: > > https://docs.microsoft.com/en-us/windows/security/information-protection/kernel-dma-protection-for-thunderbolt > > > > Support the "DmaProperty" with the same semantics. Windows documents the > > property to apply to PCIe root ports only. Extend it to apply to any > > PCI device. This is useful for internal PCI devices that do not hang off > > a PCIe rootport, but offer an attack surface for DMA attacks (e.g. > > internal network devices). > > > > Signed-off-by: Rajat Jain > > --- > > v3: * Use Microsoft's documented property "DmaProperty" > > * Resctrict to ACPI only > > > > drivers/pci/pci-acpi.c | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c > > index a42dbf448860..660baa60c040 100644 > > --- a/drivers/pci/pci-acpi.c > > +++ b/drivers/pci/pci-acpi.c > > @@ -1350,12 +1350,30 @@ static void pci_acpi_set_external_facing(struct pci_dev *dev) > > dev->external_facing = 1; > > } > > > > +static void pci_acpi_check_for_dma_protection(struct pci_dev *dev) > > +{ > > + u8 val; > > + > > + /* > > + * Microsoft Windows uses this property, and is documented here: > > + * https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports > > + * While Microsoft documents this property as only applicable to PCIe > > + * root ports, we expand it to be applicable to any PCI device. > > + */ > > + if (device_property_read_u8(&dev->dev, "DmaProperty", &val)) > > + return; > > Why not continue to only do this for PCIe devices like it is actually > being used for? Why expand it? Because devices hanging off of PCIe root ports are not the only ones that may need DMA protection. There may be internal PCI devices (that don't hang off a PCIe root port) that may need DMA protection. Examples include internal network controllers that may offer an attack surface by handling network data or running vendor firmware. > > And what driver/device is going to use this? This is already used by PCI subsystem to enforce stricter ACS settings, and IOMMU drivers to enforce stricter IOMMU settings. Thanks & Best Regards, Rajat > > thanks, > > greg k-h