From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672567; cv=none; d=zohomail.com; s=zohoarc; b=QWsn1iywGIvoLdPtDVLDDIS48ThPBy/jHFt31oCM4SJES4L2hT4l8U+FcCtZEBvJHmp8Dn/VJxSsbrLXZZkrqHvho2sjUIBEK0Gq2Ooq9YtR2kJC7S/3Qnfv9GzmOl3dkIcs2SYFAUvR7KqPYRvl8WqPmEy4CFMGZZZhAvZ0nKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672567; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iLqP26L1DNQh23hvf3ZfjEuWpTgHuOxZ20uNYqB0XcE=; b=EhQl0tEfvrp/Paf96Lnx88pShek2M+6BSo3zrGM/aBx/xy6vT9iIole9zWbNUDFBe0ta5BmkwYf1nkbefFxq56OUBdiK7LKj9yLElTbOQZvRj0njcb6VQXH5/lGq0GhuZ2gT1e+DURPtHhQzxphjNX0SVy/J3CHNNxvW2vcSQbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672567477606.0111610819627; Thu, 7 Oct 2021 22:56:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204329.359471 (Exim 4.92) (envelope-from ) id 1mYirD-0007tX-Ca; Fri, 08 Oct 2021 05:55:47 +0000 Received: by outflank-mailman (output) from mailman id 204329.359471; Fri, 08 Oct 2021 05:55:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirD-0007tQ-7g; Fri, 08 Oct 2021 05:55:47 +0000 Received: by outflank-mailman (input) for mailman id 204329; Fri, 08 Oct 2021 05:55:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirB-0007cA-JT for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:55:45 +0000 Received: from mail-lf1-x12b.google.com (unknown [2a00:1450:4864:20::12b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9c5fd5ab-ae37-4376-a47b-316c2d53de2d; Fri, 08 Oct 2021 05:55:40 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id n8so32760045lfk.6 for ; Thu, 07 Oct 2021 22:55:40 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:38 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9c5fd5ab-ae37-4376-a47b-316c2d53de2d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iLqP26L1DNQh23hvf3ZfjEuWpTgHuOxZ20uNYqB0XcE=; b=MpsgDz2EDklsRLAuSDOWbiLR2VcxNJfHrA1tPUE77ucY8NSWsdjwS232cIqwIv9ApH xByv1hatc1R5qgBJZl8k9Z7m4YO6/hx03bEQg5Mzyg2IWneJ7zKAKkaoPw0gk9EV4R+q /UKQPKvhR7JEbLk02CtVl4XfOET53qbP9M0y8btSG54wkOVeVNCb/4KRq4Ow5tQxzh9z qUbmPk1m1pURzrSiuqqv72QUl2bW8qtjFMOJ20wkGKiu2361pFFX8CG82Hw/MNjwEGjD +guf5faGJ7o0QuFI9xcKSGufriKNqDGGW7Xy4pGcIUEQZ9fBdJ6S5WB791/w8PoJYuC3 EuyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iLqP26L1DNQh23hvf3ZfjEuWpTgHuOxZ20uNYqB0XcE=; b=Re0aZr4QJhRlEiOpkfRXpMHIDKOmsM7ykM80g/EpWS0XTlrgUVy/L/CVsSHuGgrCIO O+M1s77r5NuZwUkcorkepYYljm8iCjjmjwXJraCPB4ZSsVCKUvdit2IAYTbNq4vYnzfQ LKguPl87z2bXge0NPowLWeufDtaJQORriIdyC+8cmR4OFA5D4oT+fkCqQUelGGUsSVza 4RtE7sA9omNVr97WEiwhC+xPumLlRck5ZHPYV6fxpwwb35aAL+5JqyxqBhEQ/rMwHnTW akvyAGrxBHWSoHpD5qs78VaplEU17IaR1NK6VY01h8QKmnjcM6vQQsiZW4uKS1Zo3zEc GuBA== X-Gm-Message-State: AOAM533cfEGcuc1zd6QipzFiknZd4uigyvJKgQquq7zmJuFneLHDRbqm 5O/+RHego0ubgDi9Lv1993l1pXgfGIU= X-Google-Smtp-Source: ABdhPJwShR3k/lP8Rgo+01PGGhT/UN3c9l9R0/Ub8JvsYOoalRg2/nRh9l9MlQ/Q6g7h9FgEiPO9kA== X-Received: by 2002:a05:6512:20b:: with SMTP id a11mr8675587lfo.179.1633672539392; Thu, 07 Oct 2021 22:55:39 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 01/10] xen/arm: Add new device type for PCI Date: Fri, 8 Oct 2021 08:55:26 +0300 Message-Id: <20211008055535.337436-2-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672570088100002 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Add new device type (DEV_PCI) to distinguish PCI devices from platform DT devices, so some drivers, like IOMMU, can handle PCI devices differently. Also add a helper which is when given a struct device returns the corresponding struct pci_dev which this device is a part of. Because of the header cross-dependencies, e.g. we need both struct pci_dev and struct arch_pci_dev at the same time, this cannot be done with an inline. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v2: - !! dropped Stefano's r-b because of the changes - simplified dev_to_pci to use a single container_of(dev, struct pci_dev, arch.dev) (Jan) Since v1: - Folded new device type (DEV_PCI) into this patch. --- xen/arch/arm/pci/pci.c | 7 +++++++ xen/include/asm-arm/device.h | 4 ++-- xen/include/asm-arm/pci.h | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c index 73540045d187..138da19284ab 100644 --- a/xen/arch/arm/pci/pci.c +++ b/xen/arch/arm/pci/pci.c @@ -27,6 +27,13 @@ int arch_pci_clean_pirqs(struct domain *d) return 0; } =20 +struct pci_dev *dev_to_pci(struct device *dev) +{ + ASSERT(dev->type =3D=3D DEV_PCI); + + return container_of(dev, struct pci_dev, arch.dev); +} + static int __init dt_pci_init(void) { struct dt_device_node *np; diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index ebe84ea853cd..7bf040560363 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -4,6 +4,7 @@ enum device_type { DEV_DT, + DEV_PCI, }; =20 struct dev_archdata { @@ -25,8 +26,7 @@ typedef struct device device_t; =20 #include =20 -/* TODO: Correctly implement dev_is_pci when PCI is supported on ARM */ -#define dev_is_pci(dev) ((void)(dev), 0) +#define dev_is_pci(dev) ((dev)->type =3D=3D DEV_PCI) #define dev_is_dt(dev) ((dev)->type =3D=3D DEV_DT) =20 enum device_class diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index f99356af1eba..7a91ebbdaf0c 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -26,6 +26,13 @@ struct arch_pci_dev { struct device dev; }; =20 +/* + * Because of the header cross-dependencies, e.g. we need both + * struct pci_dev and struct arch_pci_dev at the same time, this cannot be + * done with an inline here. Macro can be implemented, but looks scary. + */ +struct pci_dev *dev_to_pci(struct device *dev); + /* Arch-specific MSI data for vPCI. */ struct vpci_arch_msi { }; --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672570; cv=none; d=zohomail.com; s=zohoarc; b=aPQWDx4fQbP8HfGPalvr8o0tMhnJKhmfccwu9NzLtJGJxBg+E6MlgeCMl5m0J6/F+Xg0NCUX2Pm/ZLRtcJ75H/GiXJvADvkmoWZNu/uzvF6u4Pa7bhR0TQ8x7NFpo8hFY2I9f+OOHMcy1bPiToiDWmFNcCRKgkctk9au/YUgjIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672570; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EUxyn0W/J9FSEJt/oYDsZ4o/QnKV7HT+djJUv5IJGRI=; b=XxNzSdW5HkcrIcAdWE1Z+AJZ7ZItxwi7f5GBNjb94g71SyQEmFybyBKnjt3akx9ncoYuuT+SAUgHH1Ilijjl1q9NaahUmzG0LlnpDB6P/EWgID28oIEm6UU/DnKH//FOUaC0oPBQxDPy7OKf+Lq22cFlg9a0JxHtPHX+B7LdGkM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672570470131.45079939679658; Thu, 7 Oct 2021 22:56:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204330.359482 (Exim 4.92) (envelope-from ) id 1mYirH-0008Ca-JH; Fri, 08 Oct 2021 05:55:51 +0000 Received: by outflank-mailman (output) from mailman id 204330.359482; Fri, 08 Oct 2021 05:55:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirH-0008CN-Fz; Fri, 08 Oct 2021 05:55:51 +0000 Received: by outflank-mailman (input) for mailman id 204330; Fri, 08 Oct 2021 05:55:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirG-0007cA-Jm for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:55:50 +0000 Received: from mail-lf1-x12f.google.com (unknown [2a00:1450:4864:20::12f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ed7e8cc1-4239-4f45-8045-5b34d893a9a8; Fri, 08 Oct 2021 05:55:41 +0000 (UTC) Received: by mail-lf1-x12f.google.com with SMTP id y26so34944528lfa.11 for ; Thu, 07 Oct 2021 22:55:41 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ed7e8cc1-4239-4f45-8045-5b34d893a9a8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EUxyn0W/J9FSEJt/oYDsZ4o/QnKV7HT+djJUv5IJGRI=; b=FOHeQrPpZjYnooNZoJwcDT+3DsxC7jSXr0W62SmV6caWCd9lQwvAm+woeZ84HrSy8C wcj5F9sgXkqc2rQqDAxnc0LAj5WNybYKIIJxPsCffDMF0/UqdzXIxbyNLU9Us5OnhOE/ F38tNM5+VU7HjSAxwtMytOdTgqLiTfRoDuUS8ORW5yjmm13zkM2bHWAMBVznfRVfkjl3 rpJBF+8o18GItAHoAmDNdWYYxvthFdd9ZGPJCTGqhR5J3j6UExtc06qbyKnFfoSQkgZL 71JFOK4QDeIQy/KkM4FiO48iayIr0i4m2VYfLp1HJyu108kte47sfl+1vs2rloZD/2tN Uh7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EUxyn0W/J9FSEJt/oYDsZ4o/QnKV7HT+djJUv5IJGRI=; b=WcPvAzEwT5u3Pz/Q424gWlNqlFSglK7ReC0sGZmEE/ObbGFEmTm6k47iWjOI8UOdC2 X49jTVDc2buAuvkzAadUuDm9qKTAZZcAHyhYc/+p6eJ3eyUOR37zcxzooA2B47ibIk6U cEXIEDwUwNySkl95z6QaohyozizNqaOA2SDAL4uj9RPoK4t3+v1K8vbclEfLTxHc6QLM Ec71BP6XkJBekf0uL+ghlMOUp1+ooX3YeN3hatx0yPqpdhUIsNwG6+DFoJNBx7+3Gnlq wbvr9dGdPTacRNPPQCQd4m3mLDYVYlW3UPHqCU+1P/6+J8llWuphatDDUh+f+PLTTWll oqGA== X-Gm-Message-State: AOAM530H8xeW39bUdrssGL66EcpmbEiFJAbUBXmkd8V02/yH28ePM3pK sE2m3qvNK6V0j/eyTEZTfPcCwRWkpIU= X-Google-Smtp-Source: ABdhPJzpgP/E37Fhmrcnp+lC6oW8HAGf4BnPXjfohPryrmrhNQPYI3/Cf15FFhtcGNbKCrjKVfxDgg== X-Received: by 2002:a05:6512:3502:: with SMTP id h2mr8706956lfs.415.1633672540556; Thu, 07 Oct 2021 22:55:40 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 02/10] xen/arm: Introduce pci_find_host_bridge_node helper Date: Fri, 8 Oct 2021 08:55:27 +0300 Message-Id: <20211008055535.337436-3-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672571867100006 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Get host bridge node given a PCI device attached to it. This helper will be re-used for adding PCI devices by the subsequent patches. Signed-off-by: Oleksandr Andrushchenko Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v2: - !! dropped Stefano's r-b because of the changes - s/PRI_pci/%pp after rebase onto Arm series --- xen/arch/arm/pci/pci-host-common.c | 16 ++++++++++++++++ xen/include/asm-arm/pci.h | 1 + 2 files changed, 17 insertions(+) diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host= -common.c index 593beeb48ce4..592c01aae5bb 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -276,6 +276,22 @@ int pci_get_host_bridge_segment(const struct dt_device= _node *node, return -EINVAL; } =20 +/* + * Get host bridge node given a device attached to it. + */ +struct dt_device_node *pci_find_host_bridge_node(struct device *dev) +{ + struct pci_host_bridge *bridge; + struct pci_dev *pdev =3D dev_to_pci(dev); + + bridge =3D pci_find_host_bridge(pdev->seg, pdev->bus); + if ( unlikely(!bridge) ) + { + printk(XENLOG_ERR "Unable to find PCI bridge for %pp\n", &pdev->sb= df); + return NULL; + } + return bridge->dt_node; +} /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 7a91ebbdaf0c..9aa8eca53175 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -99,6 +99,7 @@ void __iomem *pci_ecam_map_bus(struct pci_host_bridge *br= idge, struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus= ); int pci_get_host_bridge_segment(const struct dt_device_node *node, uint16_t *segment); +struct dt_device_node *pci_find_host_bridge_node(struct device *dev); =20 static always_inline bool is_pci_passthrough_enabled(void) { --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672569; cv=none; d=zohomail.com; s=zohoarc; b=MvrJannWg4B75asb3wRp0csAkqzp9u29VQyfFT3wlfLQRBedC78x+QP7PIXdpGFEVOP9zP63mjDVqfIvIfVKOQB6ew4Mjp67bS2Qv8t+bQ1iTAWenNBit3Phd9rioAZOrFnDVrcQD620bmEvaUdndvgnlmwaqyWbdkX4SrwZM4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672569; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i+5xYEIb/HFPwhli6DC0XzWGZZlF9uvm17LAFke7DVg=; b=h/RTVpmqGib5VSknHXUSwaAqVo9ZC9yM0+GtA/Ic9BUrYNCoWY3XvweiVcPRMlUxCsjf6IhDjd6uSSEDJ34L+Wd71TiiY08Xf9DQTyLqZOZo63EDUdIvV6lIUE+2CyZiWKjG1QgZ3i59ygfd/iTH3hCVbxih+jU3s9z2o9Qay1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672569639946.9786383559259; Thu, 7 Oct 2021 22:56:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204331.359493 (Exim 4.92) (envelope-from ) id 1mYirM-00009G-UX; Fri, 08 Oct 2021 05:55:56 +0000 Received: by outflank-mailman (output) from mailman id 204331.359493; Fri, 08 Oct 2021 05:55:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirM-00008v-PS; Fri, 08 Oct 2021 05:55:56 +0000 Received: by outflank-mailman (input) for mailman id 204331; Fri, 08 Oct 2021 05:55:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirL-0007cA-K2 for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:55:55 +0000 Received: from mail-lf1-x133.google.com (unknown [2a00:1450:4864:20::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 90c4cf70-19b2-48f6-9e40-8cadf5208682; Fri, 08 Oct 2021 05:55:42 +0000 (UTC) Received: by mail-lf1-x133.google.com with SMTP id y26so34944657lfa.11 for ; Thu, 07 Oct 2021 22:55:42 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:41 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 90c4cf70-19b2-48f6-9e40-8cadf5208682 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i+5xYEIb/HFPwhli6DC0XzWGZZlF9uvm17LAFke7DVg=; b=hpYqLI7plP5qH91EWtG+D9aX04Y6LRpU3DZFsjpYQgeYsKI2j/2su1CTssUSk8KGWN OvGcyCem5ovg1JTYQ1CqUITJam7LGBNj1MGUU6cW5nE6OIoLvs/gpmrUv4vOq7RycgiF zTRrz7JwqH3Geb/HOlgFjhjwR6JW7b7WZqYQrVaJagGJJ0I0plKNljDSL+jXhPECbGxU /KRWvy8upzo0c4BUA5+cx19afGxQf/qX9mW9pw5MhFswdfv4AdC3gSLYcB+99BcxHp8f 46Z+ekb67TK3FZ4/QMXeH0DmpTwrOInfee0lESXwnVM1UJRl629tyvKMaPvBam4R09Fo kHvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i+5xYEIb/HFPwhli6DC0XzWGZZlF9uvm17LAFke7DVg=; b=Dud2ikU6soUYs1rOdQAiOgzjmJyE2C+j7VgfsQy8SPhFWEBbe04KFiTTo3dZAkvk/E o9o60u4uW9zWRu1fDBWN52ZheCCaHw02xvsj/Z++3kM9wfiN1UU1NfMqY1hyulNVBjox Pdf48KBqg5QIg6+jJO8HkzTI1FCcDaEsmFiYKjmkffUJVYux+V5DRPO8Tg/yK8GJYRv+ j7tyfdWc/bVb3j+yZTWyF8Rj3r42kQM1fQJ5eToI1vvZY2zfHDW469wro8e6pPMFoRd3 ziB6e3WUJGj+7QHju404zxr3erudrNU9WzaeYMX+thwfvFWstXur0AmttJKZHWGzcWwT XM+g== X-Gm-Message-State: AOAM530W9Kgg4WBbXxFUNp8CMnUyTXImJyVe5KEVpD8W3VR72gfzJ0vU 6oCCvnTWPY4NvjObgITScGnf3IsPC2Y= X-Google-Smtp-Source: ABdhPJzot14ubwqEzFWSPCYc/moe+/KXUuMlro56Giypeef3N7rKA3JUcaJ3ZqVpmF8VHsmY/HRH9A== X-Received: by 2002:a05:651c:169c:: with SMTP id bd28mr1466459ljb.476.1633672541674; Thu, 07 Oct 2021 22:55:41 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 03/10] xen/device-tree: Make dt_find_node_by_phandle global Date: Fri, 8 Oct 2021 08:55:28 +0300 Message-Id: <20211008055535.337436-4-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633673474470100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Make dt_find_node_by_phandle globally visible, so it can be re-used by other frameworks. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- xen/common/device_tree.c | 2 +- xen/include/xen/device_tree.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index ea93da1725f6..4aae281e89bf 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1047,7 +1047,7 @@ int dt_for_each_range(const struct dt_device_node *de= v, * * Returns a node pointer. */ -static struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle) +struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle) { struct dt_device_node *np; =20 diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 2297c59ce66d..fd6cd00b433a 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -849,6 +849,8 @@ int dt_count_phandle_with_args(const struct dt_device_n= ode *np, */ int dt_get_pci_domain_nr(struct dt_device_node *node); =20 +struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle); + #ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args) --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672577; cv=none; d=zohomail.com; s=zohoarc; b=TE93a9WFQasteeaFyjTzFO/uEraEfgupcDoHiavn/RUYOcn9ksVKD3ek5YF//EjjN/3LqhsfuECt1+Fx5X7nkfAKaWQGDLiQ2fUINGx5hOesIGUw+iqeg/DoCC8AP5hfz/wUBiR0TCX2r/FMGVxpOMRjMoPyD82uaFahAl15j3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672577; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kBaCDB1jQf5kZrJ+C9TzIUopo/UW+RufCsCBCZcFZhQ=; b=akyEcLJm6nYO8fC1xf/awDhrprlMAZXLu6JFLuZF/xPNmjbI9GVWhrxq1jhUzIe+yRIK38sWwi4SCWUlnc2zu8VrsLjMTPuU/s7FPgNUwC0vj7BDJX8eK4RvnO5mtDZIE70ZTOKlMi5Xkcz9X2X2ozyq0gcuKuM/AuRE9Prp+0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672577104996.5855201610855; Thu, 7 Oct 2021 22:56:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204332.359504 (Exim 4.92) (envelope-from ) id 1mYirS-0000ig-7Q; Fri, 08 Oct 2021 05:56:02 +0000 Received: by outflank-mailman (output) from mailman id 204332.359504; Fri, 08 Oct 2021 05:56:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirS-0000i0-3j; Fri, 08 Oct 2021 05:56:02 +0000 Received: by outflank-mailman (input) for mailman id 204332; Fri, 08 Oct 2021 05:56:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirQ-0007cA-KE for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:00 +0000 Received: from mail-lf1-x12f.google.com (unknown [2a00:1450:4864:20::12f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b9308316-49c6-416a-9af9-45f1a05d2721; Fri, 08 Oct 2021 05:55:44 +0000 (UTC) Received: by mail-lf1-x12f.google.com with SMTP id t9so33577352lfd.1 for ; Thu, 07 Oct 2021 22:55:43 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:42 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b9308316-49c6-416a-9af9-45f1a05d2721 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kBaCDB1jQf5kZrJ+C9TzIUopo/UW+RufCsCBCZcFZhQ=; b=AdHvna/o6jg3eodxk+IR/WwNFV5s5aQlphltA0H3ObfsdkpSqDi/xT+d6K2H5owUYO Vyg7zHOfG+cmfBXt9AMqqLWUuGNBcl62D1oXFsli1B9xmkOweMH4SS5wNXsY1VINoDer IbtJwYG45/Gdih9ianuT1GZuuBI9n1kJPZvMFTg4ZDam12jk9AFgO7SeduxOms33jr+M J4boOrt+EK1Ug5oScVE/+VLbgidaq7PcnOoiC/q/j/4ZdzKWHQt7wjof57Vlm766/Vv5 JNv771Bo+9kCND0z5UCRap0WykZeQZ4rZVeGb1AhdomIG5FXwhKFOzTERXoOtsx6Yjq1 XHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kBaCDB1jQf5kZrJ+C9TzIUopo/UW+RufCsCBCZcFZhQ=; b=6SOz4HKY7qtLwmz6/tNHYt9TNjaAQutxJ/5q5Qh1HnLQGG9Rk6frb/iJJY8lAO/Jp3 TB6rQlypR6qvWKdmU5uOYwcd5r6UBSccNpB4NMCq3iPY+fFhuyFLag5Xj1tSLbQ2vC/q 2Lo3AABF4ZoEYbg+Nl9fnTQ3WFtJYLnKbPSQjI5nJ7wUkVu57Rrqhq/HH4ZU7JZ3uHn2 UV7KkYKRsuntJ907pHokG0klmEETBlR14uc6NmEBwEsSdNJgWkLbLFt0SQNFYK14ARww Oq5nTX8QUF+aZW+Y2nhDy+Z1F2eoEp2lrrW7l3FYLw7elyA3WGfnPxqNLwspryWRtKHY FGyg== X-Gm-Message-State: AOAM533ztV8vICMYYgu6Mhdo/gPHr6Rq7vAuVM/BzEORI57azROvUZVp KEgYR9eoz0iVhinuGHaldTIhUUc3Mnc= X-Google-Smtp-Source: ABdhPJxh8orDP66nDG63AjGag7W745tT+yg4DFTW8P7aAuYsgvYGCDXxaCJQV2aL2G7HiK0kq3rzLg== X-Received: by 2002:a05:6512:2393:: with SMTP id c19mr8840366lfv.518.1633672542822; Thu, 07 Oct 2021 22:55:42 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 04/10] xen/arm: Mark device as PCI while creating one Date: Fri, 8 Oct 2021 08:55:29 +0300 Message-Id: <20211008055535.337436-5-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672578203100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko While adding a PCI device mark it as such, so other frameworks can distinguish it from DT devices. For that introduce an architecture defined helper which may perform additional initialization of the newly created PCI device. Signed-off-by: Oleksandr Andrushchenko [applicable parts] Acked-by: Jan Beulich Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Cc: Andrew Cooper Cc: Paul Durrant Since v3: - fixed Arm build without CONFIG_HAS_PCI Since v2: - !! dropped Stefano's r-b because of the changes - introduced arch_pci_init_pdev (Jan) Since v1: - moved the assignment from iommu_add_device to alloc_pdev --- xen/arch/arm/pci/pci.c | 5 +++++ xen/drivers/passthrough/pci.c | 2 ++ xen/include/asm-arm/pci.h | 7 +++++++ xen/include/asm-x86/pci.h | 2 ++ 4 files changed, 16 insertions(+) diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c index 138da19284ab..082c14e127a8 100644 --- a/xen/arch/arm/pci/pci.c +++ b/xen/arch/arm/pci/pci.c @@ -34,6 +34,11 @@ struct pci_dev *dev_to_pci(struct device *dev) return container_of(dev, struct pci_dev, arch.dev); } =20 +void arch_pci_init_pdev(struct pci_dev *pdev) +{ + pci_to_dev(pdev)->type =3D DEV_PCI; +} + static int __init dt_pci_init(void) { struct dt_device_node *np; diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index b36d5a481162..9e6246afeef5 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -329,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg,= u8 bus, u8 devfn) *((u8*) &pdev->devfn) =3D devfn; pdev->domain =3D NULL; =20 + arch_pci_init_pdev(pdev); + rc =3D pdev_msi_init(pdev); if ( rc ) { diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 9aa8eca53175..98cb22d39ef1 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -105,6 +105,9 @@ static always_inline bool is_pci_passthrough_enabled(vo= id) { return pci_passthrough_enabled; } + +void arch_pci_init_pdev(struct pci_dev *pdev); + #else /*!CONFIG_HAS_PCI*/ =20 struct arch_pci_dev { }; @@ -121,5 +124,9 @@ static inline int pci_get_host_bridge_segment(const str= uct dt_device_node *node, return -EINVAL; } =20 +struct pci_dev; + +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {} + #endif /*!CONFIG_HAS_PCI*/ #endif /* __ARM_PCI_H__ */ diff --git a/xen/include/asm-x86/pci.h b/xen/include/asm-x86/pci.h index c4a4fdcbc239..443f25347d08 100644 --- a/xen/include/asm-x86/pci.h +++ b/xen/include/asm-x86/pci.h @@ -36,4 +36,6 @@ static always_inline bool is_pci_passthrough_enabled(void) return true; } =20 +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {} + #endif /* __X86_PCI_H__ */ --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672582; cv=none; d=zohomail.com; s=zohoarc; b=fI9+QHrLoUJ4nAVbuWC3aflIjlD84F6327x+ThjtAHDlRaBHvXf16381w8L4tSwm9Pg3O9GU2h4VyvAeXkgFP06U9u8Tk3oL+TuPPLl6iEsGAiLfMyF1wVVxHHDYcLVrs4gunYIFvsv1QZtBkIjwPtL5F4rhsVIjO60nL4KMYqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672582; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZCJvktk62euiFf93z8Os38uZoCLuGeAveKltg5+4Wtc=; b=GotD0/hZpUsCqK8mfbrMIZdOAZMvXb+OYrifKDrAmAHUiZamOqGDTjCP58OQNuEhfOesBwCGnAGkW0mQO2+QS4AjNWGS91/8/cwkezKVM0AUtZCeVoaqpU5Vkb+205tkccw4dUv2/Cq5H2G3f5g7Sy+Fe53bUI5whK5Lc4u7suA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163367258202977.28272371532535; Thu, 7 Oct 2021 22:56:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204337.359515 (Exim 4.92) (envelope-from ) id 1mYirX-0001Gi-LP; Fri, 08 Oct 2021 05:56:07 +0000 Received: by outflank-mailman (output) from mailman id 204337.359515; Fri, 08 Oct 2021 05:56:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirX-0001GV-Fp; Fri, 08 Oct 2021 05:56:07 +0000 Received: by outflank-mailman (input) for mailman id 204337; Fri, 08 Oct 2021 05:56:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirV-0007cA-KS for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:05 +0000 Received: from mail-lf1-x130.google.com (unknown [2a00:1450:4864:20::130]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c27177f6-bd7e-4306-9d47-72ef149989c9; Fri, 08 Oct 2021 05:55:45 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id b20so35071654lfv.3 for ; Thu, 07 Oct 2021 22:55:45 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:43 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c27177f6-bd7e-4306-9d47-72ef149989c9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZCJvktk62euiFf93z8Os38uZoCLuGeAveKltg5+4Wtc=; b=egTWtj0yY2eScJ0OlKXABb4G+bmYSWosMoQG8sskJ0bDLAxynVAbBUO8ze901KLgN0 4gqvEwhbUTVm208gisrRZccw+DN3KtwxHFLyd8flxas7Ycqm/3zEiyS8Dx9szsY1EcGi ZWHuONWzcP7cVazxts2zgCR9c7Q1iNo66m4ToAgHhR2czvdLDM10zJhvEN27t/GNccFB 2DlhzvXQQ7SW8x4QxwVeSKdnvDGhOG4QWoiXidYssrdLd3vP5rzZFZvDKeCckMDcvjrN dSziPh6BixoMhXDrhzHEUAKwoIPF+4fIEt77zMy+CwhChFtedX4g3nMk7dRAfpC/ij5w DWkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZCJvktk62euiFf93z8Os38uZoCLuGeAveKltg5+4Wtc=; b=2FXGFiXo91/qts9DiPO7VRuwE8PH/7EsoGP7xdCJTlV+Y2CwZrmt7GI8FOw1jQsWzX +hti109Weu5TDnTsGPaR2eqgHPl4lJda/SGRHTb+FTabDh68WldbxDWBB0JWC5EN5E+u bo/mmYToWWAXOditBmzlLG/Dm+7jnuPvB6vqdaoPU9jA/P7igYttLZHNgB95KTCrp1/O iI0vvFyxClCaITjJfOuZwYx9sBbA9SJEnf0ZpxQhq8d1k2l8l98RZMarGtMR/JBNMGqq q4a10wLJdVTbUN4yvq/XR7KRkdywgyuYkLweIrfMw1Iz5TTOTeXTeCinhznK+fPt3WVS C/Ag== X-Gm-Message-State: AOAM53221HWOBaM5sQzSvERpE9qcN6f9Lsz3gdl5Mj9WF+hk407zJzjb geRqmg3JYpmsxq9RC2WxUtTMsp4tgwA= X-Google-Smtp-Source: ABdhPJw3iseSMLF5rjaGBAlP//RiQcLo4485Bz93gG+h/Km/Hsavi6PicqSrSmsmdebz/ACX9Ate4g== X-Received: by 2002:a05:6512:3b94:: with SMTP id g20mr8678129lfv.119.1633672543928; Thu, 07 Oct 2021 22:55:43 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 05/10] xen/domain: Call pci_release_devices() when releasing domain resources Date: Fri, 8 Oct 2021 08:55:30 +0300 Message-Id: <20211008055535.337436-6-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672582663100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko This is the very same that we already do for DT devices. Moreover, x86 already calls pci_release_devices(). Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v1: - re-wording in the commit message --- xen/arch/arm/domain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index fbb52f78f1a6..79012bf77757 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -985,7 +985,8 @@ static int relinquish_memory(struct domain *d, struct p= age_list_head *list) * function which may return -ERESTART. */ enum { - PROG_tee =3D 1, + PROG_pci =3D 1, + PROG_tee, PROG_xen, PROG_page, PROG_mapping, @@ -1022,6 +1023,12 @@ int domain_relinquish_resources(struct domain *d) #ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all(d); #endif +#ifdef CONFIG_HAS_PCI + PROGRESS(pci): + ret =3D pci_release_devices(d); + if ( ret ) + return ret; +#endif =20 PROGRESS(tee): ret =3D tee_relinquish_resources(d); --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672584; cv=none; d=zohomail.com; s=zohoarc; b=lwMJ4GdeEtYxwtOODo4fb5G3oJd78/kTo9jkpWLFkg9IEOcFmhrRljTTteaxchi4skvzsd7SKidz3N0+upwGDxmMAJ82sSFNSgEHCcdDUm6sHj0e/V1Axcr/+HC8Yq2eyLCtTNKNJG5m69X1TkIoPz+1uCPDUE05rc/qROBFkmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672584; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gze8iYmqiF2cMvijBG4Ld8cLztnOhc60UjeRzFilfH0=; b=D+J3p3mUBwV+dDR8W9L6hYCgWRSxH4pMEQJ3Mw+6Tau/0QhgseJZR+Im3UmotoI7ekZD6d6jlduBEvCRfRudL+4WalG3lbwTZ+CGFkVsPq/v4J5hSG+VjjWP5mnjRKkIBB1sTCoeSnctga+ti37YSwMl04dR/0cyUx0feAzn2HY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672584785179.4113013474049; Thu, 7 Oct 2021 22:56:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204341.359526 (Exim 4.92) (envelope-from ) id 1mYirc-0001pC-5a; Fri, 08 Oct 2021 05:56:12 +0000 Received: by outflank-mailman (output) from mailman id 204341.359526; Fri, 08 Oct 2021 05:56:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirc-0001ok-11; Fri, 08 Oct 2021 05:56:12 +0000 Received: by outflank-mailman (input) for mailman id 204341; Fri, 08 Oct 2021 05:56:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYira-0007cA-Kd for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:10 +0000 Received: from mail-lf1-x12e.google.com (unknown [2a00:1450:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1aee4013-3614-4fc5-b8e1-57dc7b49f9fe; Fri, 08 Oct 2021 05:55:46 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id x27so34677426lfu.5 for ; Thu, 07 Oct 2021 22:55:46 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:44 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1aee4013-3614-4fc5-b8e1-57dc7b49f9fe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gze8iYmqiF2cMvijBG4Ld8cLztnOhc60UjeRzFilfH0=; b=S5cKZo3IYyM/uvuPtHNfJ0qEZUbg4C2bKsgzSnRxa5gX2KNUsUPpivR/rpdGo5P022 LSH383eq4HAUrIrekVaRgj7JZ0jT3drDXxPyVVWrF08ePLpdS4TnUQlq1/3vFO9DUFjq CFhDu7XaIAsGmjjL93CtYXUaop8JJ3qR/ns6hdlYgmvJlBG8Qe9Ul6ZodP8uKhMVDhvG d9UcWLsRhuvSkMNwcPLXbLvIv/ndFgTHGkzV7QMGENGQ3Ix03r+JKLFQx38dEaFTGD57 /Bdon7kFwOJT5/lZrdk21Bg+R+y8p4PFOzbfm2aI3In0PhHdbDqIPKd97X3MnZRzVBO+ t6LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gze8iYmqiF2cMvijBG4Ld8cLztnOhc60UjeRzFilfH0=; b=Ty0G4ML6IOTCw8QBqIxsvzC98/9sqHX0Sf2evOJF3N5d/kLheQMMYAx+Zf2t3zjv8j eRslQytOUa2hf96xtU722UGfsDHHU68CuMku7qeUyTB5Ux2MCjW4LiADG25DsnTzOrjw yFmHRXDaJTGFBUBtJJ8knrpFSySNwPFlPJ/ccvOvy4tKr0PSq4FALlzpfPuGaaAxd4S1 NnuJvaVc1VvuWFCLS4wcw48T/VbxAWF4hxMWabCkPerjWTiYTyeP1gYx43LD2t9o38ZW u2BcVLnUC8OzmZ5Ty8aw4epKwgPKUI/aB0rUe+GBEAiKtokUw7OEfM2UuazgJvZmN+gI 6cVg== X-Gm-Message-State: AOAM530p00wNumqjPPmcRQF3kubYVfKGQXsOnMWg/cZKWt446RzntbJi maeAxNrd4MswFCRjcq4eyGW9YDlOQDA= X-Google-Smtp-Source: ABdhPJwmcEvN71rOOpBhumTj6iAvUbtG04zcFvN4XV0h/MXlqBNJpABcP9VxDYwCcBTXd7RmlCpWlQ== X-Received: by 2002:a05:6512:398c:: with SMTP id j12mr8483974lfu.631.1633672545224; Thu, 07 Oct 2021 22:55:45 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH v5 06/10] libxl: Allow removing PCI devices for all types of domains Date: Fri, 8 Oct 2021 08:55:31 +0300 Message-Id: <20211008055535.337436-7-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672586886100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko The PCI device remove path may now be used by PVH on ARM, so the assert is no longer valid. Signed-off-by: Oleksandr Andrushchenko Acked-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh Acked-by: Anthony PERARD --- Cc: Ian Jackson Cc: Juergen Gross --- tools/libs/light/libxl_pci.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 1a1c2630803b..59f3686fc85e 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -1947,8 +1947,6 @@ static void do_pci_remove(libxl__egc *egc, pci_remove= _state *prs) goto out_fail; } } else { - assert(type =3D=3D LIBXL_DOMAIN_TYPE_PV); - char *sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource",= pci->domain, pci->bus, pci->dev, pci->func); FILE *f =3D fopen(sysfs_path, "r"); --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672589; cv=none; d=zohomail.com; s=zohoarc; b=fLkQa5xssxsYE4HtdOBeqfottknbuWoiZPzsL5MXHgsauLNiY7wAfnRFg7GzRYhJ9GurNkMq5cBzacmH17hXXtH3o42dnCowiNg4F4VQ4whocl4clA33wsBwuhopKFjDgJGkx/bysFrqb6C4OuADCvnmDtyMx/aCutHFoVApOAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672589; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=goBcPmRp2ohWna+/gXXwyGZm/zW9wdOzUquFDTCwT10=; b=e8tUzIuBj3JlgX/6j0EfjOOVx8A9G96bjnp+Rif5I3pQS6/we/LJEWoeqRtIKchM84hyBMlASqQXVXpRcRcWnBIGvfjZTXA5WVB7cmpoB1SVI71lk9K/5crbZr53KgLiB7TMbhhXcJDV56OLUJMCGH1JfYuWuZXXGnZXp3NubZs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672589617311.37477538047176; Thu, 7 Oct 2021 22:56:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204345.359537 (Exim 4.92) (envelope-from ) id 1mYirh-0002PS-Df; Fri, 08 Oct 2021 05:56:17 +0000 Received: by outflank-mailman (output) from mailman id 204345.359537; Fri, 08 Oct 2021 05:56:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirh-0002PD-9A; Fri, 08 Oct 2021 05:56:17 +0000 Received: by outflank-mailman (input) for mailman id 204345; Fri, 08 Oct 2021 05:56:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirf-0007cA-Kt for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:15 +0000 Received: from mail-lf1-x12e.google.com (unknown [2a00:1450:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7695a0a1-c5b1-4e65-894c-89d7bfc211df; Fri, 08 Oct 2021 05:55:47 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id y15so34649433lfk.7 for ; Thu, 07 Oct 2021 22:55:47 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:46 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7695a0a1-c5b1-4e65-894c-89d7bfc211df DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=goBcPmRp2ohWna+/gXXwyGZm/zW9wdOzUquFDTCwT10=; b=cX19K/TYDn8vW4HwKU48r0qTiY6u4hpHnfe75SOv2g6lg/739OtMcTs1VfZi56IOFb 3Sb2UyHnVpDICH/QwOqqye9oXXlZI8ZHwPpd7qi1QaS5PgGhgCZ7nVokYO5eQrU908se z2IgC4WDRpO9ynOqGMyb4llqr8LSzbgz83sb/QjiT+/yCrx8ZibjSSuMLHGcNTdo7Ap2 NL3In+YVGcZjcJd2JXTVjB1ji5V9UdsoWNFxJlJQk10i86BwrJnExqD0gwgG+JZ+caI4 LlA+aqvTcHVtPAEjICb/D/piDO/0Secv8r2Lxw2yNGhZCZQyeMVmUadsEVpVgY/jb1lp 6lqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=goBcPmRp2ohWna+/gXXwyGZm/zW9wdOzUquFDTCwT10=; b=NZZxQYoZLxsd7+tU8tlhRUfDYj1rABt6q+TnTDDxqoZcGW5auX8xqc3cyt83U+IQ/v /X1GMmjb31jlsype/oQTyT1Js6FzozxG+QxEABcs2iCtZ2iOxSuRu6Z5hR3dGiztLggk K9rWe1A8NWEMvMlK3kPE6WPly44fufKFodPk8KDHxunabE2ftxVYqulLDTiYPkFQeNlP VIVTPIepwWf+aCRHxpfehuUyU/JVF01N0mOOptx8EtAEnn+Ipni454qsRBmDAhFNFhps IzRzZ/iScAqqj06MvWGcJS2THralEvU+N/O9nLRLg4uR3iEGKA+UigK3ukBnF/S5flYR rXrg== X-Gm-Message-State: AOAM533RrB7OzlzhiLoPlHtg5E4KEh2sFqwq429roAt7FOM+gqoO9Ou1 AFlxL1Zb0wii9nwpIBYfrXtneyYXDgA= X-Google-Smtp-Source: ABdhPJwlTn/wOzkXL/qlTPFqV3Ub7ABbU4xc8mOsh6FwPIjRr3AZzSK+WsDY1a4okJWcWyHdVrYwYQ== X-Received: by 2002:a05:6512:31e:: with SMTP id t30mr8361782lfp.82.1633672546470; Thu, 07 Oct 2021 22:55:46 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko , Ian Jackson , Juergen Gross Subject: [PATCH v5 07/10] libxl: Only map legacy PCI IRQs if they are supported Date: Fri, 8 Oct 2021 08:55:32 +0300 Message-Id: <20211008055535.337436-8-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672591216100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko Arm's PCI passthrough implementation doesn't support legacy interrupts, but MSI/MSI-X. This can be the case for other platforms too. For that reason introduce a new CONFIG_PCI_SUPP_LEGACY_IRQ and add it to the CFLAGS and compile the relevant code in the toolstack only if applicable. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh Acked-by: Anthony PERARD --- Cc: Ian Jackson Cc: Juergen Gross Since v1: - Minimized #idefery by introducing pci_supp_legacy_irq function for relevant checks --- tools/libs/light/Makefile | 4 ++++ tools/libs/light/libxl_pci.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index 7d8c51d49242..bd3f6be2a183 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -46,6 +46,10 @@ CFLAGS +=3D -Wno-format-zero-length -Wmissing-declaratio= ns \ -Wno-declaration-after-statement -Wformat-nonliteral CFLAGS +=3D -I. =20 +ifeq ($(CONFIG_X86),y) +CFLAGS +=3D -DCONFIG_PCI_SUPP_LEGACY_IRQ +endif + SRCS-$(CONFIG_X86) +=3D libxl_cpuid.c SRCS-$(CONFIG_X86) +=3D libxl_x86.c SRCS-$(CONFIG_X86) +=3D libxl_psr.c diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 59f3686fc85e..4c2d7aeefbb2 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -1364,6 +1364,15 @@ static void pci_add_timeout(libxl__egc *egc, libxl__= ev_time *ev, pci_add_dm_done(egc, pas, rc); } =20 +static bool pci_supp_legacy_irq(void) +{ +#ifdef CONFIG_PCI_SUPP_LEGACY_IRQ + return true; +#else + return false; +#endif +} + static void pci_add_dm_done(libxl__egc *egc, pci_add_state *pas, int rc) @@ -1434,6 +1443,8 @@ static void pci_add_dm_done(libxl__egc *egc, } } fclose(f); + if (!pci_supp_legacy_irq()) + goto out_no_irq; sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); @@ -1983,6 +1994,8 @@ static void do_pci_remove(libxl__egc *egc, pci_remove= _state *prs) } fclose(f); skip1: + if (!pci_supp_legacy_irq()) + goto skip_irq; sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domai= n, pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672595; cv=none; d=zohomail.com; s=zohoarc; b=FYaX0R0fDSdVbznFHx/7aw1V4PzvGgbMFk3WjvPMRa2SDLmyNjqVACLh1JQPWIGJyojZuFRGxDcrfdK6pZA7GdZIZDpTOthOWRtO9JxOANSszh6Bu7gEECKzTIqjxD5el5Bo1ubVuc8o14KFN6XRkWcYyel9jxlqZkl4gO9G7jQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672595; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vUC5D9zEKV/jAgD73pTREAGOQdOnzNJSZwkzfwspuNk=; b=Gt7GUaod4Ozi7SUWNXzsaFL6oDxgKdXr7+k6BzpHDCyjAd8ZKo42xhRhoCJ/zyaOAnWol/MOVle23yMrmUQfnmaAAK5pC+ypv4pKylHFUWoF4lQKfDKcWh1kAr4JlGlBJMv5ggqfaZfpxXO7K0Iu94YZa3HbTI3F5zzY9Bng9Uc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672595117244.7807064871456; Thu, 7 Oct 2021 22:56:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204348.359548 (Exim 4.92) (envelope-from ) id 1mYirm-00031R-Me; Fri, 08 Oct 2021 05:56:22 +0000 Received: by outflank-mailman (output) from mailman id 204348.359548; Fri, 08 Oct 2021 05:56:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirm-00031D-Ja; Fri, 08 Oct 2021 05:56:22 +0000 Received: by outflank-mailman (input) for mailman id 204348; Fri, 08 Oct 2021 05:56:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirk-0007cA-L0 for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:20 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f5954495-a0ca-4fe0-b2cd-34b6d81c89a3; Fri, 08 Oct 2021 05:55:48 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id m3so34761580lfu.2 for ; Thu, 07 Oct 2021 22:55:48 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:47 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f5954495-a0ca-4fe0-b2cd-34b6d81c89a3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vUC5D9zEKV/jAgD73pTREAGOQdOnzNJSZwkzfwspuNk=; b=btx7oai46Hsj7sP/cha3qJ3x9r8kcGUjfyCmfdEk44+qTEZcYDyycvw5eL6MD8MAh0 St6VY3ebKsjwyliy4IxBKxtEIq5d1jHrf8CtR67T+DClevPS93sGP0qOyUygQy7voKb2 xVTFNr4oKHDQz/RX0AbTPPiUgWUvMDmWuEHApGcpEvVK0ZxOVF/10e/bNxg8O85DbC1P ww0VF2qCkncREg1UR9IyQOjDjGcYA8oiLA6wot4kgDQJyx8/1nX8QRyGGO4I0M5bSLNI Akpu47x7THgh9GCLEpZOPMHhoj8TeMYEOknD3CCVfOsabt55irOSWYSkUbVxTJn1t+S9 GjLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vUC5D9zEKV/jAgD73pTREAGOQdOnzNJSZwkzfwspuNk=; b=dI4ZFDkIJs08PBdw9H3OgKKAk301yZGYrutVD7xjC3ZrXnuamdw1HlRku1bKhswSWr MKhfLNf/6yNclqldN5cmd8wwetl/jHhuEMNgliwlxj+Eo49FK3M9A66wagEYtDnWcz3q x5cVG15w2/VO8Wud4b3wrsdvub9O2QxsaJUcGXY/Lnp4IePY+aR6+NEMcWor+OVBsFQF LnB9IWt5GF/BoHD2TOoAvKchQ26Ej97jVse/FEzcRQ0jTqoHy4O3uEzcAeuAsSv+CUdt liaz9J7X7oJLZGegBVez0/HUAxq29evFT8uJS6Q0uLWJ+5URCZnFv5EtS6eAReSSGKaf DPFA== X-Gm-Message-State: AOAM533k3F/bHLmpc5+TWb55Lv6sEN6LAUx/0YshgbSk4SR9MhwBRNsu BiqJJJ1RuluKMLB3/hQJJKmtY3djPbY= X-Google-Smtp-Source: ABdhPJyuSbpU0STi1lKVUx508Xiu5O+z312hu9KPeQtMDgnailV2dI8p2Obn72TAS3BJAyZFr7SHXw== X-Received: by 2002:a05:6512:2396:: with SMTP id c22mr8686787lfv.55.1633672547618; Thu, 07 Oct 2021 22:55:47 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 08/10] xen/arm: Setup MMIO range trap handlers for hardware domain Date: Fri, 8 Oct 2021 08:55:33 +0300 Message-Id: <20211008055535.337436-9-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672595560100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko In order for vPCI to work it needs to maintain guest and hardware domain's views of the configuration space. For example, BARs and COMMAND registers require emulation for guests and the guest view of the registers needs to be in sync with the real contents of the relevant registers. For that ECAM address space needs to also be trapped for the hardware domain, so we need to implement PCI host bridge specific callbacks to properly setup MMIO handlers for those ranges depending on particular host bridge implementation. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Since v3: - fixed comment formatting Since v2: - removed unneeded assignment (count =3D 0) - removed unneeded header inclusion - update commit message Since v1: - Dynamically calculate the number of MMIO handlers required for vPCI and update the total number accordingly - s/clb/cb - Do not introduce a new callback for MMIO handler setup --- xen/arch/arm/domain.c | 2 ++ xen/arch/arm/pci/pci-host-common.c | 28 ++++++++++++++++++++++++ xen/arch/arm/vpci.c | 34 ++++++++++++++++++++++++++++++ xen/arch/arm/vpci.h | 6 ++++++ xen/include/asm-arm/pci.h | 5 +++++ 5 files changed, 75 insertions(+) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 79012bf77757..fa6fcc5e467c 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -733,6 +733,8 @@ int arch_domain_create(struct domain *d, if ( (rc =3D domain_vgic_register(d, &count)) !=3D 0 ) goto fail; =20 + count +=3D domain_vpci_get_num_mmio_handlers(d); + if ( (rc =3D domain_io_init(d, count + MAX_IO_HANDLER)) !=3D 0 ) goto fail; =20 diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host= -common.c index 592c01aae5bb..1eb4daa87365 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -292,6 +292,34 @@ struct dt_device_node *pci_find_host_bridge_node(struc= t device *dev) } return bridge->dt_node; } + +int pci_host_iterate_bridges(struct domain *d, + int (*cb)(struct domain *d, + struct pci_host_bridge *bridge)) +{ + struct pci_host_bridge *bridge; + int err; + + list_for_each_entry( bridge, &pci_host_bridges, node ) + { + err =3D cb(d, bridge); + if ( err ) + return err; + } + return 0; +} + +int pci_host_get_num_bridges(void) +{ + struct pci_host_bridge *bridge; + int count =3D 0; + + list_for_each_entry( bridge, &pci_host_bridges, node ) + count++; + + return count; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c index 76c12b92814f..6e179cd3010b 100644 --- a/xen/arch/arm/vpci.c +++ b/xen/arch/arm/vpci.c @@ -80,17 +80,51 @@ static const struct mmio_handler_ops vpci_mmio_handler = =3D { .write =3D vpci_mmio_write, }; =20 +static int vpci_setup_mmio_handler(struct domain *d, + struct pci_host_bridge *bridge) +{ + struct pci_config_window *cfg =3D bridge->cfg; + + register_mmio_handler(d, &vpci_mmio_handler, + cfg->phys_addr, cfg->size, NULL); + return 0; +} + int domain_vpci_init(struct domain *d) { if ( !has_vpci(d) ) return 0; =20 + if ( is_hardware_domain(d) ) + return pci_host_iterate_bridges(d, vpci_setup_mmio_handler); + + /* Guest domains use what is programmed in their device tree. */ register_mmio_handler(d, &vpci_mmio_handler, GUEST_VPCI_ECAM_BASE, GUEST_VPCI_ECAM_SIZE, NULL= ); =20 return 0; } =20 +int domain_vpci_get_num_mmio_handlers(struct domain *d) +{ + int count; + + if ( is_hardware_domain(d) ) + /* For each PCI host bridge's configuration space. */ + count =3D pci_host_get_num_bridges(); + else + /* + * VPCI_MSIX_MEM_NUM handlers for MSI-X tables per each PCI device + * being passed through. Maximum number of supported devices + * is 32 as virtual bus topology emulates the devices as embedded + * endpoints. + * +1 for a single emulated host bridge's configuration space. + */ + count =3D VPCI_MSIX_MEM_NUM * 32 + 1; + + return count; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vpci.h b/xen/arch/arm/vpci.h index d8a7b0e3e802..27a2b069abd2 100644 --- a/xen/arch/arm/vpci.h +++ b/xen/arch/arm/vpci.h @@ -17,11 +17,17 @@ =20 #ifdef CONFIG_HAS_VPCI int domain_vpci_init(struct domain *d); +int domain_vpci_get_num_mmio_handlers(struct domain *d); #else static inline int domain_vpci_init(struct domain *d) { return 0; } + +static inline int domain_vpci_get_num_mmio_handlers(struct domain *d) +{ + return 0; +} #endif =20 #endif /* __ARCH_ARM_VPCI_H__ */ diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index 98cb22d39ef1..a71b0eea8cb9 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -108,6 +108,11 @@ static always_inline bool is_pci_passthrough_enabled(v= oid) =20 void arch_pci_init_pdev(struct pci_dev *pdev); =20 +int pci_host_iterate_bridges(struct domain *d, + int (*clb)(struct domain *d, + struct pci_host_bridge *bridge)); +int pci_host_get_num_bridges(void); + #else /*!CONFIG_HAS_PCI*/ =20 struct arch_pci_dev { }; --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672601; cv=none; d=zohomail.com; s=zohoarc; b=Jb85MXjSyriXgCg4E2hRVcRusevM/wbeOAMTwWKoQaNNmJ7GwpD2WnoOB362SI37zJXsuagr3V5svqerBt+MS7UJ9vvxAnJ6er/SJP7ziAvT4KEMywJbILsVatX60lmHE0TkNHX0Fd88RaaMQApOfS0AUjS5WhI9Nq6xYFRtK5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672601; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IBIe+xmJSKoC5wk/f52I/okgcUqP7yS1O1mJBjhKVo4=; b=Cek52w1aBj8FnCQmrXMkOVDpumFD1VcdTBcsstyH4b/XV4xKqle1abf9q0TOQT+BQ2P5cnDbVamJQCr6ewP5I+1Nfqvr8IsyLNDybkoxaCHx1e0oaOBIBg2gCePiB1NmqrT1Mrpm2ulnE9KwZkA+4kohtP7CdXOT4Mb2h57GLd4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672601114717.3409771020424; Thu, 7 Oct 2021 22:56:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204353.359559 (Exim 4.92) (envelope-from ) id 1mYirr-0003Vp-0r; Fri, 08 Oct 2021 05:56:27 +0000 Received: by outflank-mailman (output) from mailman id 204353.359559; Fri, 08 Oct 2021 05:56:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirq-0003Vb-TU; Fri, 08 Oct 2021 05:56:26 +0000 Received: by outflank-mailman (input) for mailman id 204353; Fri, 08 Oct 2021 05:56:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirp-0007cA-LA for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:25 +0000 Received: from mail-lf1-x130.google.com (unknown [2a00:1450:4864:20::130]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3fb278fd-d89a-42b3-b97b-c7b4138f0516; Fri, 08 Oct 2021 05:55:50 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id i24so33118840lfj.13 for ; Thu, 07 Oct 2021 22:55:50 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:48 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3fb278fd-d89a-42b3-b97b-c7b4138f0516 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IBIe+xmJSKoC5wk/f52I/okgcUqP7yS1O1mJBjhKVo4=; b=M7AbQomva+/0jN7STkOUTyvIZLHd0drEcCIKbE1mwmCYgQUcKKPgQbaBPfmzBr6Yp2 YktsOVRFi/4v2E8OerHhRzCeVzkys8aWH5k+sh9C6dt9PWBAtK2sz3fYE8R3tRpFGDL+ sT8t/GW/v2/sSyw7fWTl6rO9JNja4wivMGxROpb5rVjO0RJHKyE+YLxkdAIt2KVM1cmd aJnXHecU2fWzRh7WbJU57jpsI1urk81Z0MULXXugVUVvOPbD0YGJZ2aAPig3I9LsHpz4 gwuGXyqm960fkMQzzfO6MeWC9SeWavYTZ3hYLUSZJJSK2Y5JRy4RPuT5+nnxsYZlH+ba U0fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IBIe+xmJSKoC5wk/f52I/okgcUqP7yS1O1mJBjhKVo4=; b=Oii9W7sFT/1UsTw23IvePDHUVeqWbGjkZ9Mzeg1jsCy79JTI3i6Kc0654mpPcs2Vj/ jh/uRDyQVBj3Ue72EvhgkvIt3qfYlQdwcEGs/dVq/yjANl/pwW7+erSmMhW/CQAZFiFo SM3hrokbAIVn9eWE3SwDqdzwn/KYF34zoqKyBfzaBgq6fJ0VXYhvorZy3QBf2JXg/feu sSpvA9Gn1MbNUQps4QxxwhLiGTOATTlVm8wfvbjuBgKFo2ze2an2yLy1fFtAp4Ots49C q1Oc/PPiS1KueHzBBPi9jL8v5MTeiAkVpWB0qDJ9Z9/EqzAQzlK5Vxczw+PKL119ZWfE I5dw== X-Gm-Message-State: AOAM531l+WQRpXmANH0cJuY/LHjqdULMGcV2Eb0Ke5iHHmAfrgjJ3ATF IBTkRaUDG/hh6yvDANSe1cv3iK4TBLs= X-Google-Smtp-Source: ABdhPJx1phls3JyqynXlWEBWaMOXDx/I3DFcPeZGPq8G5xcWbLKDFuGC629QB7VYjvZ3zW/2TJ5yEA== X-Received: by 2002:a05:6512:39ca:: with SMTP id k10mr8335145lfu.571.1633672548758; Thu, 07 Oct 2021 22:55:48 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 09/10] xen/arm: Do not map PCI ECAM and MMIO space to Domain-0's p2m Date: Fri, 8 Oct 2021 08:55:34 +0300 Message-Id: <20211008055535.337436-10-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672601903100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko PCI host bridges are special devices in terms of implementing PCI passthrough. According to [1] the current implementation depends on Domain-0 to perform the initialization of the relevant PCI host bridge hardware and perform PCI device enumeration. In order to achieve that one of the required changes is to not map all the memory ranges in map_range_to_domain as we traverse the device tree on startup and perform some additional checks if the range needs to be mapped to Domain-0. The generic PCI host controller device tree binding says [2]: - ranges: As described in IEEE Std 1275-1994, but must provide at least a definition of non-prefetchable memory. One or both of prefetchable Memory and IO Space may also be provided. - reg : The Configuration Space base address and size, as accessed from the parent bus. The base address corresponds to the first bus in the "bus-range" property. If no "bus-range" is specified, this will be bus 0 (the default). From the above none of the memory ranges from the "ranges" property needs to be mapped to Domain-0 at startup as MMIO mapping is going to be handled dynamically by vPCI as we assign PCI devices, e.g. each device assigned to Domain-0/guest will have its MMIOs mapped/unmapped as needed by Xen. The "reg" property covers not only ECAM space, but may also have other then the configuration memory ranges described, for example [3]: - reg: Should contain rc_dbi, config registers location and length. - reg-names: Must include the following entries: "rc_dbi": controller configuration registers; "config": PCIe configuration space registers. This patch makes it possible to not map all the ranges from the "ranges" property and also ECAM from the "reg". All the rest from the "reg" property still needs to be mapped to Domain-0, so the PCI host bridge remains functional in Domain-0. [1] https://lists.xenproject.org/archives/html/xen-devel/2020-07/msg00777.h= tml [2] https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/host-g= eneric-pci.txt [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/hisili= con-pcie.txt Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Stefano Stabellini --- Since v4: - update skip_mapping comment - add comment why we need to map interrupts to Dom0 Since v3: - pass struct map_range_data to map_dt_irq_to_domain - remove redundant check from map_range_to_domain - fix handle_device's .skip_mapping Since v2: - removed check in map_range_to_domain for PCI_DEV and moved it to handle_device, so the code is simpler - s/map_pci_bridge/skip_mapping - extended comment in pci_host_bridge_mappings - minor code restructure in construct_dom0 - s/.need_p2m_mapping/.need_p2m_hwdom_mapping and related callbacks - unsigned int i; in pci_host_bridge_mappings Since v1: - Added better description of why and what needs to be mapped into Domain-0's p2m and what doesn't - Do not do any mappings for PCI devices while traversing the DT - Walk all the bridges and make required mappings in one go --- xen/arch/arm/domain_build.c | 57 ++++++++++++++++++------------ xen/arch/arm/pci/ecam.c | 14 ++++++++ xen/arch/arm/pci/pci-host-common.c | 49 +++++++++++++++++++++++++ xen/arch/arm/pci/pci-host-zynqmp.c | 1 + xen/include/asm-arm/pci.h | 10 ++++++ xen/include/asm-arm/setup.h | 13 +++++++ 6 files changed, 121 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index b51176b31bef..0d673b06a2f3 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -51,12 +50,6 @@ static int __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); =20 -struct map_range_data -{ - struct domain *d; - p2m_type_t p2mt; -}; - /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfn #define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) @@ -1663,10 +1656,11 @@ static int __init map_dt_irq_to_domain(const struct= dt_device_node *dev, const struct dt_irq *dt_irq, void *data) { - struct domain *d =3D data; + struct map_range_data *mr_data =3D data; + struct domain *d =3D mr_data->d; unsigned int irq =3D dt_irq->irq; int res; - bool need_mapping =3D !dt_device_for_passthrough(dev); + bool need_mapping =3D !mr_data->skip_mapping; =20 if ( irq < NR_LOCAL_IRQS ) { @@ -1690,13 +1684,12 @@ static int __init map_dt_irq_to_domain(const struct= dt_device_node *dev, return 0; } =20 -static int __init map_range_to_domain(const struct dt_device_node *dev, - u64 addr, u64 len, - void *data) +int __init map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data) { struct map_range_data *mr_data =3D data; struct domain *d =3D mr_data->d; - bool need_mapping =3D !dt_device_for_passthrough(dev); + bool need_mapping =3D !mr_data->skip_mapping; int res; =20 /* @@ -1748,23 +1741,21 @@ static int __init map_range_to_domain(const struct = dt_device_node *dev, * then we may need to perform additional mappings in order to make * the child resources available to domain 0. */ -static int __init map_device_children(struct domain *d, - const struct dt_device_node *dev, - p2m_type_t p2mt) +static int __init map_device_children(const struct dt_device_node *dev, + struct map_range_data *mr_data) { - struct map_range_data mr_data =3D { .d =3D d, .p2mt =3D p2mt }; - int ret; - if ( dt_device_type_is_equal(dev, "pci") ) { + int ret; + dt_dprintk("Mapping children of %s to guest\n", dt_node_full_name(dev)); =20 - ret =3D dt_for_each_irq_map(dev, &map_dt_irq_to_domain, d); + ret =3D dt_for_each_irq_map(dev, &map_dt_irq_to_domain, mr_data); if ( ret < 0 ) return ret; =20 - ret =3D dt_for_each_range(dev, &map_range_to_domain, &mr_data); + ret =3D dt_for_each_range(dev, &map_range_to_domain, mr_data); if ( ret < 0 ) return ret; } @@ -1845,6 +1836,20 @@ static int __init handle_device(struct domain *d, st= ruct dt_device_node *dev, int res; u64 addr, size; bool need_mapping =3D !dt_device_for_passthrough(dev); + /* + * For PCI passthrough we only need to remap to Dom0 the interrupts + * and memory ranges from "reg" property which cover controller's + * configuration registers and such. PCIe configuration space registers + * of the PCIe Root Complex and PCIe aperture should not be mapped + * automatically to Dom0. + */ + struct map_range_data mr_data =3D { + .d =3D d, + .p2mt =3D p2mt, + .skip_mapping =3D !need_mapping || + (is_pci_passthrough_enabled() && + (device_get_class(dev) =3D=3D DEVICE_PCI)) + }; =20 naddr =3D dt_number_of_address(dev); =20 @@ -1884,7 +1889,6 @@ static int __init handle_device(struct domain *d, str= uct dt_device_node *dev, /* Give permission and map MMIOs */ for ( i =3D 0; i < naddr; i++ ) { - struct map_range_data mr_data =3D { .d =3D d, .p2mt =3D p2mt }; res =3D dt_device_get_address(dev, i, &addr, &size); if ( res ) { @@ -1898,7 +1902,7 @@ static int __init handle_device(struct domain *d, str= uct dt_device_node *dev, return res; } =20 - res =3D map_device_children(d, dev, p2mt); + res =3D map_device_children(dev, &mr_data); if ( res ) return res; =20 @@ -3056,7 +3060,14 @@ static int __init construct_dom0(struct domain *d) return rc; =20 if ( acpi_disabled ) + { rc =3D prepare_dtb_hwdom(d, &kinfo); + if ( rc < 0 ) + return rc; +#ifdef CONFIG_HAS_PCI + rc =3D pci_host_bridge_mappings(d, p2m_mmio_direct_c); +#endif + } else rc =3D prepare_acpi(d, &kinfo); =20 diff --git a/xen/arch/arm/pci/ecam.c b/xen/arch/arm/pci/ecam.c index 602d00799c8d..b81620074a91 100644 --- a/xen/arch/arm/pci/ecam.c +++ b/xen/arch/arm/pci/ecam.c @@ -40,6 +40,19 @@ void __iomem *pci_ecam_map_bus(struct pci_host_bridge *b= ridge, return base + (PCI_DEVFN2(sbdf.bdf) << devfn_shift) + where; } =20 +bool pci_ecam_need_p2m_hwdom_mapping(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr) +{ + struct pci_config_window *cfg =3D bridge->cfg; + + /* + * We do not want ECAM address space to be mapped in Domain-0's p2m, + * so we can trap access to it. + */ + return cfg->phys_addr !=3D addr; +} + /* ECAM ops */ const struct pci_ecam_ops pci_generic_ecam_ops =3D { .bus_shift =3D 20, @@ -47,6 +60,7 @@ const struct pci_ecam_ops pci_generic_ecam_ops =3D { .map_bus =3D pci_ecam_map_bus, .read =3D pci_generic_config_read, .write =3D pci_generic_config_write, + .need_p2m_hwdom_mapping =3D pci_ecam_need_p2m_hwdom_mapping, } }; =20 diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host= -common.c index 1eb4daa87365..085f08e23e0c 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -18,6 +18,7 @@ =20 #include #include +#include #include #include #include @@ -320,6 +321,54 @@ int pci_host_get_num_bridges(void) return count; } =20 +int __init pci_host_bridge_mappings(struct domain *d, p2m_type_t p2mt) +{ + struct pci_host_bridge *bridge; + struct map_range_data mr_data =3D { + .d =3D d, + .p2mt =3D p2mt, + .skip_mapping =3D false + }; + + /* + * For each PCI host bridge we need to only map those ranges + * which are used by Domain-0 to properly initialize the bridge, + * e.g. we do not want to map ECAM configuration space which lives in + * "reg" or "assigned-addresses" device tree property, but we want to + * map other regions of the host bridge. The PCI aperture defined by + * the "ranges" device tree property should also be skipped. + */ + list_for_each_entry( bridge, &pci_host_bridges, node ) + { + const struct dt_device_node *dev =3D bridge->dt_node; + unsigned int i; + + for ( i =3D 0; i < dt_number_of_address(dev); i++ ) + { + uint64_t addr, size; + int err; + + err =3D dt_device_get_address(dev, i, &addr, &size); + if ( err ) + { + printk(XENLOG_ERR + "Unable to retrieve address range index=3D%u for %s= \n", + i, dt_node_full_name(dev)); + return err; + } + + if ( bridge->ops->need_p2m_hwdom_mapping(d, bridge, addr) ) + { + err =3D map_range_to_domain(dev, addr, size, &mr_data); + if ( err ) + return err; + } + } + } + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/pci/pci-host-zynqmp.c b/xen/arch/arm/pci/pci-host= -zynqmp.c index 61a9807d3d58..6ad2b31e810d 100644 --- a/xen/arch/arm/pci/pci-host-zynqmp.c +++ b/xen/arch/arm/pci/pci-host-zynqmp.c @@ -34,6 +34,7 @@ const struct pci_ecam_ops nwl_pcie_ops =3D { .map_bus =3D pci_ecam_map_bus, .read =3D pci_generic_config_read, .write =3D pci_generic_config_write, + .need_p2m_hwdom_mapping =3D pci_ecam_need_p2m_hwdom_mapping, } }; =20 diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h index a71b0eea8cb9..b5b85ccd0937 100644 --- a/xen/include/asm-arm/pci.h +++ b/xen/include/asm-arm/pci.h @@ -17,6 +17,8 @@ =20 #ifdef CONFIG_HAS_PCI =20 +#include + #define pci_to_dev(pcidev) (&(pcidev)->arch.dev) =20 extern bool pci_passthrough_enabled; @@ -73,6 +75,9 @@ struct pci_ops { uint32_t reg, uint32_t len, uint32_t *value); int (*write)(struct pci_host_bridge *bridge, pci_sbdf_t sbdf, uint32_t reg, uint32_t len, uint32_t value); + bool (*need_p2m_hwdom_mapping)(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr); }; =20 /* @@ -96,6 +101,9 @@ int pci_generic_config_write(struct pci_host_bridge *bri= dge, pci_sbdf_t sbdf, uint32_t reg, uint32_t len, uint32_t value); void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge, pci_sbdf_t sbdf, uint32_t where); +bool pci_ecam_need_p2m_hwdom_mapping(struct domain *d, + struct pci_host_bridge *bridge, + uint64_t addr); struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus= ); int pci_get_host_bridge_segment(const struct dt_device_node *node, uint16_t *segment); @@ -113,6 +121,8 @@ int pci_host_iterate_bridges(struct domain *d, struct pci_host_bridge *bridge)); int pci_host_get_num_bridges(void); =20 +int pci_host_bridge_mappings(struct domain *d, p2m_type_t p2mt); + #else /*!CONFIG_HAS_PCI*/ =20 struct arch_pci_dev { }; diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 95da0b7ab9cd..88d9673db817 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -2,6 +2,8 @@ #define __ARM_SETUP_H_ =20 #include +#include +#include =20 #define MIN_FDT_ALIGN 8 #define MAX_FDT_SIZE SZ_2M @@ -77,6 +79,14 @@ struct bootinfo { #endif }; =20 +struct map_range_data +{ + struct domain *d; + p2m_type_t p2mt; + /* Set if mapping of the memory ranges must be skipped. */ + bool skip_mapping; +}; + extern struct bootinfo bootinfo; =20 extern domid_t max_init_domid; @@ -124,6 +134,9 @@ void device_tree_get_reg(const __be32 **cell, u32 addre= ss_cells, u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); =20 +int map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data); + #endif /* * Local variables: --=20 2.25.1 From nobody Thu Apr 25 22:18:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1633672666; cv=none; d=zohomail.com; s=zohoarc; b=SiE7W2mpkivqjkDNlU3BhfFYAFXMkqGOkxHZhdrUIZLgy9TTUo3DtZGr/M1b7yWx+ym7AIAbwKWScKDQP6BdaII4x3B7zbSZMQMODAb4CX51dO1UuvovJdi4adAHaorTPjSg43WI/+sAjwCLhrXAyuMpm6ctJpO5j8p7obDXJEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633672666; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QzbdatLhIl735gEkyVNBitnIXpDdRUzSTDD+uCEX6MU=; b=kOfzsSuAetyOCGV/eixUqLbXgHVXG3pLCsIFsgW/6XLW/lZum98KpBOLY22hDmVZKzMUchMZJfbV3FBNekIleuRrDdNqoO5JezwpUO4I1tz9Z+WIx9WJyk1zwzVCIPd+M5cH59X74oxZCTL1XqQGGffJFI+w8pJS7Qf8GVtllfY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633672666921303.9517926388089; Thu, 7 Oct 2021 22:57:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.204382.359569 (Exim 4.92) (envelope-from ) id 1mYisv-0005A9-JS; Fri, 08 Oct 2021 05:57:33 +0000 Received: by outflank-mailman (output) from mailman id 204382.359569; Fri, 08 Oct 2021 05:57:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYisv-0005A2-GU; Fri, 08 Oct 2021 05:57:33 +0000 Received: by outflank-mailman (input) for mailman id 204382; Fri, 08 Oct 2021 05:57:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mYirz-0007cA-LU for xen-devel@lists.xenproject.org; Fri, 08 Oct 2021 05:56:35 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e1a5985e-d9d4-4899-ba40-1f09609fc514; Fri, 08 Oct 2021 05:55:51 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id x27so34444531lfa.9 for ; Thu, 07 Oct 2021 22:55:51 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id f8sm151147lfq.168.2021.10.07.22.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 22:55:49 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e1a5985e-d9d4-4899-ba40-1f09609fc514 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QzbdatLhIl735gEkyVNBitnIXpDdRUzSTDD+uCEX6MU=; b=delfA489Q6cYlsvzBgsyUqfs6iLyZQojMZXOZNSwi//ru9d8tTsLGXpsmknxxB7Jsf ZUbfObRS5KNvOd0qpW50+0TYPDWbbXEkauxVwusgL44a1sXP3EZlokGC61Psf69fHkxI 39zJKW1KlmMq4vHyErctSXOFuIlT7QNFKk+R5UEd9UvzB3L98tGOi6BcpGi2kORktaV7 y0Mx8B7/9qD8/kkLtxr2O1PoKrhMHPt7xRghBTTQKocHOX/cNsQfaVD/mfz029w3OJLM ZjvEU0ieFo+XXapzq2iTxW9nOs1E3nddcNmGPs0TERFn/Ile/6ay43Rc+JAGrIo3jNG/ XqSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QzbdatLhIl735gEkyVNBitnIXpDdRUzSTDD+uCEX6MU=; b=wFLPl5hpKafF3mI+jT7U61Lvn+2Wnt4tEnEZbJrHdn+XgBgZ5XSzd/N7o/4NuD6/4Z cMONh+NJJpsw1PPf8rhN/FjXJhMi4IETC8mYUPNvpGA0gILPNMDNFn1S5tAMBtYMroLh CLwqZ/Nurl8yD+3i52mJvo9fr5MD5hxBozrIano8cboZjsm1O4Oo6aU156IITclu7zJR rALpPPnZQLRI26VozeUB2S5XxFSppIxKY+BxY34z0AOM89pCeuFy2s6NUDx5DALehnyy MkXbKkFuCXgW0R2aVpTNvsBHluFXKRlhGDxTmU68WQ02VKP5yxlrvFe5g5v7YDlpPExf 41+Q== X-Gm-Message-State: AOAM530arnUNA4HC2NVQTEJwlPtFg7sLOOe8Hl54rDX0Tj8HbhtdWVTy WYkyOx30ITbwvCVKgyQUz9cOR9V5UYc= X-Google-Smtp-Source: ABdhPJywjRTSBxfY5U+W2M3mS/L+w/EHBGcH55u4Oms0eFyTgaDV5BEqEg7Hc9R8uhCncZW9thfM2w== X-Received: by 2002:ac2:5506:: with SMTP id j6mr8519664lfk.91.1633672549926; Thu, 07 Oct 2021 22:55:49 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v5 10/10] xen/arm: Process pending vPCI map/unmap operations Date: Fri, 8 Oct 2021 08:55:35 +0300 Message-Id: <20211008055535.337436-11-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008055535.337436-1-andr2000@gmail.com> References: <20211008055535.337436-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1633672667686100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Andrushchenko vPCI may map and unmap PCI device memory (BARs) being passed through which may take a lot of time. For this those operations may be deferred to be performed later, so that they can be safely preempted. Currently this deferred processing is happening in common IOREQ code which doesn't seem to be the right place for x86 and is even more doubtful because IOREQ may not be enabled for Arm at all. So, for Arm the pending vPCI work may have no chance to be executed if the processing is left as is in the common IOREQ code only. For that reason make vPCI processing happen in arch specific code. Please be aware that there are a few outstanding TODOs affecting this code path, see xen/drivers/vpci/header.c:map_range and xen/drivers/vpci/header.c:vpci_process_pending. Signed-off-by: Oleksandr Andrushchenko [x86 changes] Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini Reviewed-by: Rahul Singh Tested-by: Rahul Singh --- Cc: Andrew Cooper Cc: Paul Durrant Since v2: - update commit message with more insight on x86, IOREQ and Arm - restored order of invocation for IOREQ and vPCI processing (Jan) Since v1: - Moved the check for pending vpci work from the common IOREQ code to hvm_do_resume on x86 - Re-worked the code for Arm to ensure we don't miss pending vPCI work --- xen/arch/arm/traps.c | 13 +++++++++++++ xen/arch/x86/hvm/hvm.c | 6 ++++++ xen/common/ioreq.c | 9 --------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 219ab3c3fbde..b246f51086e3 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -34,6 +34,7 @@ #include #include #include +#include =20 #include #include @@ -2304,6 +2305,18 @@ static bool check_for_vcpu_work(void) } #endif =20 + if ( has_vpci(v->domain) ) + { + bool pending; + + local_irq_enable(); + pending =3D vpci_process_pending(v); + local_irq_disable(); + + if ( pending ) + return true; + } + if ( likely(!v->arch.need_flush_to_ram) ) return false; =20 diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index aa418a3ca1b7..c491242e4b8b 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -546,6 +546,12 @@ void hvm_do_resume(struct vcpu *v) =20 pt_restore_timer(v); =20 + if ( has_vpci(v->domain) && vpci_process_pending(v) ) + { + raise_softirq(SCHEDULE_SOFTIRQ); + return; + } + if ( !vcpu_ioreq_handle_completion(v) ) return; =20 diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c index d732dc045df9..689d256544c8 100644 --- a/xen/common/ioreq.c +++ b/xen/common/ioreq.c @@ -25,9 +25,7 @@ #include #include #include -#include #include -#include =20 #include #include @@ -212,19 +210,12 @@ static bool wait_for_io(struct ioreq_vcpu *sv, ioreq_= t *p) =20 bool vcpu_ioreq_handle_completion(struct vcpu *v) { - struct domain *d =3D v->domain; struct vcpu_io *vio =3D &v->io; struct ioreq_server *s; struct ioreq_vcpu *sv; enum vio_completion completion; bool res =3D true; =20 - if ( has_vpci(d) && vpci_process_pending(v) ) - { - raise_softirq(SCHEDULE_SOFTIRQ); - return false; - } - while ( (sv =3D get_pending_vcpu(v, &s)) !=3D NULL ) if ( !wait_for_io(sv, get_ioreq(s, v)) ) return false; --=20 2.25.1