From patchwork Sat Feb 16 16:51:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Knut Omang X-Patchwork-Id: 10816311 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 57C351390 for ; Sat, 16 Feb 2019 16:54:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 451782B557 for ; Sat, 16 Feb 2019 16:54:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37AB62B5D9; Sat, 16 Feb 2019 16:54:36 +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 C24E92B557 for ; Sat, 16 Feb 2019 16:54:35 +0000 (UTC) Received: from localhost ([127.0.0.1]:57990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gv3EZ-000425-7d for patchwork-qemu-devel@patchwork.kernel.org; Sat, 16 Feb 2019 11:54:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gv3C0-0002sK-Rj for qemu-devel@nongnu.org; Sat, 16 Feb 2019 11:51:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gv3Bz-0000Dd-OO for qemu-devel@nongnu.org; Sat, 16 Feb 2019 11:51:56 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:34680) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gv3Bx-00008x-KI for qemu-devel@nongnu.org; Sat, 16 Feb 2019 11:51:55 -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 x1GGiqT3044485; Sat, 16 Feb 2019 16:51:45 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=wBouAu3ScOvURIQIoDrK2+Ttm1orsMa4l1jViU0Zs7Q=; b=YEb6DtL/MEHrDqlp2CQTmdPiU3lcd1Obd3BVXovgxoiEApyRJ359UZ52YeDf4suBaYNQ CoD40i4+XjMaN0d3ORB2fCWE8jUuJranthyK46PjBJHGtp1i35qrLVYGyO1VCez3QgrB q7cUbyYl9JiV4oykjveVkD6yJzw2hUXawHfZ22/lJdivcnBiJArBs7HwkqAdLIiTlyFs y/Z1oeqYK6VFRzUZMyvKLmy+PvoXE7eGeA0uRzjCUEH2ejDJd6AN7TMHRWoroA6XXbhT WzHC8r+ZN2rrT5Na/2OXyTNJspsorLu+INdCBuYh3Luq9Xwd3SIQWBi+wFtotNgALFf9 8Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2qp81dsc16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Feb 2019 16:51:44 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1GGpdA6024435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Feb 2019 16:51:39 GMT Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1GGpcga011440; Sat, 16 Feb 2019 16:51:38 GMT Received: from abi.no.oracle.com (/10.172.144.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 16 Feb 2019 08:51:37 -0800 From: Knut Omang To: qemu-devel@nongnu.org Date: Sat, 16 Feb 2019 17:51:10 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9169 signatures=668683 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-1902160125 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v5 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 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 | 39 +++++++++++++++++++++++++++++++- include/hw/pci/pcie.h | 6 +++++- include/hw/pci/pcie_port.h | 1 +- include/hw/pci/pcie_regs.h | 4 +++- 6 files changed, 58 insertions(+) base-commit: 0b5e750bea635b167eb03d86c3d9a09bbd43bc06