From patchwork Thu Feb 21 18:13:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Knut Omang X-Patchwork-Id: 10824461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 200B6922 for ; Thu, 21 Feb 2019 18:15:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CE4E319E2 for ; Thu, 21 Feb 2019 18:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EEF0319EE; Thu, 21 Feb 2019 18:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E5AE319E2 for ; Thu, 21 Feb 2019 18:15:04 +0000 (UTC) Received: from localhost ([127.0.0.1]:36343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwssB-0000pG-PT for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Feb 2019 13:15:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwsqz-0008Jm-Mz for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:13:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwsqx-0005Me-Rt for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:13:49 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:52680) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwsqx-0005CJ-KG for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:13:47 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1LI8wac187961; Thu, 21 Feb 2019 18:13:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=GqwUh279WOL/ePpHnRUGQtDUVSMNZsaT7pi2CsSy+w4=; b=0e7r1jE9MzqGGoplSPmXDiWH72KeFpzqmefPdiqRxJA4w/gssNsNmpu2sbwQ5UG7wAcq OZiRlfSxLXF8pJvykQF+IG751JrH0rMoO4vvo9kBGA7WKQ40DXTFWgLrSTBfIWt/DfWT AFg/MYQJXMejNSyEEe9PlcTxMC7c0wF1727yKCpLo/iSxXY2XyzlNjSImkRGdoogB2R9 ZnKEguYnTTHHZF3E3/GZdYMqpFx2xCoi6Ri0cBAD8A0m4vspoz4NtBeBulKAUducFQYk QrYBwGSt9KgdumBOgt9nxjhDkg6lQ/oImYQTqBpiUrqI/htq2QWgfcRF0PtSBJ9hPPWs gw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2qp81ehy62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Feb 2019 18:13:36 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1LIDZVv002357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Feb 2019 18:13:35 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1LIDZ31006850; Thu, 21 Feb 2019 18:13:35 GMT Received: from abi.no.oracle.com (/10.172.144.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Feb 2019 10:13:35 -0800 From: Knut Omang To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 19:13:21 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9174 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902210128 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v6 0/2] pcie: Add simple ACS "support" to the generic PCIe root port X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" , Tal Attaly , Knut Omang , Alex Williamson , Elijah Shakkour , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP These two patches together implements a PCIe capability config space header for Access Control Services (ACS) for the new Qemu specific generic root port. ACS support in the associated root port is needed for passing individual functions of a device populating the port through to an L2 guest from an unmodified kernel. Without this, the IOMMU group the device belongs to will also include the root port itself, and all functions the device provides. ACS is thus necessary to support SR/IOV where the primary purpose is to be able to share out individual VFs to different guests, which will not be permitted by VFIO or the Windows Hyper-V equivalent unless ACS is supported by the root port. These patches can also be found as part of an updated version of my SR/IOV emulation patch set at https://github.com/knuto/qemu/tree/sriov_patches_v12 The patches' basic operation with VFIO and iommu groups have been tested with the above patch set and a rebased version of an in progress igb ethernet device, which needs some more care before I can let it go out. Changes from v5: ---------------- - Fix comment on cap.bits Changes from v4: ---------------- - Set the DT bit for downstream ports - Fix the assertion guard against uses violating the spec - Use pci_is_express_downstream_port() instead of type casts for discrimination. Changes from v3: ---------------- - rebased to the latest qemu master - Revised commit message and comments for patch #1 to make it clearer that VFIO works for single function devices even without ACS. - Improved checking for valid endpoints for ACS. - Fixed comment style issue - Co-locate the pci_acs_init and _reset functions and rename pci_cap_acs_reset to pci_acs_reset to adhere to the naming conventions that _cap_ functions in pcie is for changing state in the main pcie capability and not the individual extended capabilities. - Added Marcel's r-b to patch 2, which did not change Changes from v2: ---------------- - rebased to the latest qemu master Incorporated further feedback from Alex: - Make sure slot/downstream capability bits are only set for slots. - Make acs reset callback do nothing if no acs capability exists - Set correct acs version - div simplification Changes from v1: ---------------- Incorporated feedback from Alex Williamson: - Make commit messages reflect a more correct understanding of how this affects VFIO operation. - Implemented the CTRL register properly (reset callback + making non-implemented capabilities RO, default value 0) - removed the egress ctrl vector parameter to the init function - Fixed some whitespace issues Knut Omang (2): pcie: Add a simple PCIe ACS (Access Control Services) helper function gen_pcie_root_port: Add ACS (Access Control Services) capability hw/pci-bridge/gen_pcie_root_port.c | 4 +++- hw/pci-bridge/pcie_root_port.c | 4 +++- hw/pci/pcie.c | 38 +++++++++++++++++++++++++++++++- include/hw/pci/pcie.h | 6 +++++- include/hw/pci/pcie_port.h | 1 +- include/hw/pci/pcie_regs.h | 4 +++- 6 files changed, 57 insertions(+) base-commit: 0b5e750bea635b167eb03d86c3d9a09bbd43bc06