From nobody Wed Nov 27 02:23:36 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1700868315; cv=pass; d=zohomail.com; s=zohoarc; b=bThx5LLbgQB48PxInLYxmYHKRSfrV7Y++RjNu2n23FsoSES0ZMb357uWKj/YXVElw3JLtYkqwuVzgEh0JTxLcvzEMccMBLtmj1G5ZO8OlEf1tsSFbQbqxtYex2M/a1khRc+hiPShWo0LpNFhfSvYForwnsvjng9XxJ97AybmYQk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700868315; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xHbTU4afcP4VPCt7c5t9HdrtExRFqhrJyZbbFA7antU=; b=f5HOQBWPVTZ07xzhznfp+g2fEwGKODCcbiJS20oRLLAn4bZn+JGYbhgtCsJIOfD/tJovMkAg6/Nkg6nTSjiH6rNes7mzXbh/zZSmK488iAnACnQ8/XT8/LoZR7tg1NezUZG/imHJzT2IBvRD+GcnAXz5dn8yIN6CnCJcJ7Nyp68= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1700868315426201.07276884667738; Fri, 24 Nov 2023 15:25:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.640983.999787 (Exim 4.92) (envelope-from ) id 1r6fXM-0001V9-2c; Fri, 24 Nov 2023 23:24:40 +0000 Received: by outflank-mailman (output) from mailman id 640983.999787; Fri, 24 Nov 2023 23:24:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXL-0001Ui-T9; Fri, 24 Nov 2023 23:24:39 +0000 Received: by outflank-mailman (input) for mailman id 640983; Fri, 24 Nov 2023 23:24:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXK-0001Rw-AD for xen-devel@lists.xenproject.org; Fri, 24 Nov 2023 23:24:38 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a140b6be-8b20-11ee-98e2-6d05b1d4d9a1; Sat, 25 Nov 2023 00:24:36 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOMwAPH014042; Fri, 24 Nov 2023 23:24:28 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uk2wmr6b0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 23:24:27 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8551.eurprd03.prod.outlook.com (2603:10a6:10:3e2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Fri, 24 Nov 2023 23:24:23 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7025.022; Fri, 24 Nov 2023 23:24:22 +0000 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: a140b6be-8b20-11ee-98e2-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TpeisnCGNsoilk3cGYa8Caj4IaklwZcUNyC+n2wWKAw5yc6wRmwJZIAx9c56FZk5q+6Ys7poOsY8pUVyuWYP3t6Ses1qAq5AVP0GAYl0kVb+nQb0HNcEuq8km5sYnMs/zh3LmbxAz9Tq8QtTzBEXPlu3RYAGTvVsTttS6QOscV3KVv19oyXpChmjEkdq6MHbWC6pnz7oZ0OcGt0WXIO/z5Je4XLoR9G//xLTrD5+xq40n+uMs4Cahdx+ebXJ3uxbXxoUCKbkGMHU/Q7u2NcC6HQg5ksIKhis9V0QEQi3bw3v3/u2TokBFm0sklLn6FqcyL2TBvZPSDQRSmPBFcGxtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xHbTU4afcP4VPCt7c5t9HdrtExRFqhrJyZbbFA7antU=; b=LKXOE4DBlEF+TWDHvKwomLlm2YVZyokt2Q93LX+x5hAkSnc5IxB7edN3umaJC568ZDOWmFLXoWzBO8lQznHcXYGZJ1D8FT2mCeDQ7OxbihVNgpnra7I7hestaewlqVkC9B2Q24dp9p3pic8bGUPEOp5Vo1bvG+hL3STVbwFxjyGEzq5vebchzv1IBcJce7CdvzmGw232r3pwaGOgtZNcewYVIuKec8ANeaTCttEDiwI/WrlPigQkR7cRTo/zzIUVDbysEXzgtT3HZkB7pwksQXvax0iZ8+YqEbcJe2fUwUZuCg2/KL3VlEt6KjtWaZ1yimON2U4rDF3K92g6FRZZ8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xHbTU4afcP4VPCt7c5t9HdrtExRFqhrJyZbbFA7antU=; b=f+L2mrMr2hKxvijMNlwg4y5oWE8Vlq/mikkbY+CAoTipigJu/3sK2TgZxSoY4fRTI/pl1lH8lEM8vyFK81OiO4qmDnpgDeLHrmmiE74fYDzbC1xBQIX9L9xuikpYNVyjdVxUehQeiRtYTcQht9gQFjB1CUYbmD+3LxJ2G1ilD5e0zukFsdmqXDiW0Woqa8TXgMHWBt0dyGRFqPZI2CP/kig75JXfx0I2UsfOCae62t8Uxj5EFdPvT0LnEas6qbZgR36vIkLPDaZEymzwO4c7YD28gfNIw7KMAi7PeiRTTpYv/IMZn6CLiI4tKCgLUAZIfeMZnWdJ8MR7pAjI8ajblA== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Paul Durrant , Anthony Perard , Kevin Wolf , Hanna Reitz , =?iso-8859-1?Q?Marc-Andr=E9_Lureau?= , Paolo Bonzini , Jason Wang , "open list:X86 Xen CPUs" , "open list:Block layer core" Subject: [PATCH v3 1/5] hw/xen: Set XenBackendInstance in the XenDevice before realizing it Thread-Topic: [PATCH v3 1/5] hw/xen: Set XenBackendInstance in the XenDevice before realizing it Thread-Index: AQHaHy1a8CXoLlgE4EukDzzCfLk4pQ== Date: Fri, 24 Nov 2023 23:24:22 +0000 Message-ID: <20231124232400.943580-2-volodymyr_babchuk@epam.com> References: <20231124232400.943580-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231124232400.943580-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DU0PR03MB8551:EE_ x-ms-office365-filtering-correlation-id: 69fa1008-ed93-496a-f94d-08dbed447deb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qK1f2fq4OS3pPkJfbqDAW93jxVfQuUwbPUok1NGHYsKfXviBJ0BbB+wNuQ2N2Rvbsp0SWNW1wRYj9bSV5KXPlS1Pd/odZKmnE1C2uCQ9xqT3GN0+fEJIHXTTCpg9g4FeeySn06rkRU1aJQHN8V99b2L/jMHPkznJI6A5i5wDxY9TRzmBkjL8f0yDhKj+GnjOQAX2e2ckMRJk5/vVNAVHNtFAwJeVT4wsiNaPowkU25P+Ct8sdTqYm00jgiMvoaVDSmouE3FomHuAQy121AgyH8E7SS2YbMwGTIxHtwUqLezr0r4wffDT17i09HSDxdjsh7YLrnSV7j4Fu45YQ2cnf8llJSKsV5SLAVVWrWrit3Ye3ZXHEN/ErzhJN6yUa58EAR+znQac/ZLhcyEMx2ZyaUUC1+Hz1gr6CoSdadJ3RQO8e1lmwza60zCz0QhGRSD9gUewYgW+rLvLH5wyOdHrAQ4tb+4tttUh+TUKA7W4bvHfxHZ6MV0+SRxcLDGXd/6ohmIqHycDSGFAR1A46+tsneCKEZL1JdLnFQ1NpVrIWZf55/cXiShSsipVg+x4ILDqpQIGV0Y9CrkijAa8xOrb6QQz9oS/Hohmwq9jpeEi0hLKE1fAMuk1UnMnNhiYuCpL x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(366004)(136003)(376002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(38100700002)(1076003)(6512007)(83380400001)(2616005)(6506007)(55236004)(71200400001)(41300700001)(8676002)(4326008)(5660300002)(8936002)(26005)(7416002)(478600001)(6486002)(2906002)(6916009)(316002)(91956017)(66476007)(66446008)(54906003)(64756008)(76116006)(66946007)(66556008)(86362001)(122000001)(36756003)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?CPvPHzxVoOOq6y3wA8LNBb+Kj/VUQx3X4aicVAeBC+Y+/wIriMwsz8Xy0P?= =?iso-8859-1?Q?3kdl24+1ibjZmifHuw0eV8c1BIIcqsnweBlHUVwJE1CZsn1zWx0t8m9W6/?= =?iso-8859-1?Q?IudXcE5l0hV43cvfxN3rm6itbaxbBPuXHXZ242fV+/1wLhUfmj1x+TTfSh?= =?iso-8859-1?Q?3nCZT7tjHsSXltSVbXh0UwB9gXxOIACvML3spqksfCQxGIAg44dbZAJ4kO?= =?iso-8859-1?Q?F+0EtIPvT2Oo0NZv1iZ+92zAmiAKFwcIADQdMHDVae64wRs7MK4SR/pVgx?= =?iso-8859-1?Q?x2k/VX0HUy0w9Q8u/djFYAoAmMJPH5Oc1joKTaDnbSKnslqiB2UWRJFVV4?= =?iso-8859-1?Q?r0LlzoAUC2TVMNAAvpqeEP9MmmypfTDU/xuRn0rlPN5Qioo3fdGjliRUCe?= =?iso-8859-1?Q?kdWbTqWDZckIfLxhfrYqg5tKbPNfb546KTvzYT1Esv3IboIn617ooDZ2sZ?= =?iso-8859-1?Q?WMLkbvspjy3mKvjEJS5vZdT/h6+DFQANlLffdLlTwrei8j0s0tIBQLWZ3B?= =?iso-8859-1?Q?LIl3ndSnvjgScRJFf/rSlzwLVyTxiiXKBcTXkzUypSQn7Q38CNyhpjsDbo?= =?iso-8859-1?Q?S/Fc4D4esTy1lQmDnB6umJ/0fcCvyN3lEZdlPhl8gefLcQsJvVr+fEvJIz?= =?iso-8859-1?Q?wHvoGC5HTcgjgf+Ej80RelmTEP3RXN+7FexI7Vw0in0ZwgaknAt8/Y5k6D?= =?iso-8859-1?Q?XVXe+cc1J+q0bqA7HWnZinSdCJ0Vys+X9ecEOOOMMxOsk92s+Yo+GOjKpt?= =?iso-8859-1?Q?iKAikwfB5hXXkWhtlPViHIohuPBCVfbLB0Wgwsm62KEKmegTtOjtvJDHiX?= =?iso-8859-1?Q?lnotSm0uUuRUi4WT2UFDb2XFv3cA1ZIRH0SSGmPvRoqc7MAjSOQ02oHgcW?= =?iso-8859-1?Q?O52NnaxQ95ETpBFLBYI8naP1Ps82/ql/Jcn9mVvITmTgsN5HlP1ECo8nc5?= =?iso-8859-1?Q?8t5F5yza4Fi/cAcQZxlrh2aIejq0cJgaSkEGHUMBw4wNmBq+KOgVkuNgNa?= =?iso-8859-1?Q?JJUhHC5ZRzs/GSrugkJDtBw+fLOdBpjI+0BGx39ejNFTG02fyg5vwViUzF?= =?iso-8859-1?Q?9Z3d/9dj0WC1Joo2b0iWKL2lzJUOGs1Or6RFGlEogdVdMiowOzRKtU+cN7?= =?iso-8859-1?Q?gnK9hR1E5Z0CQVppeSJhZdsATa2BfiTypqZMpxVfrKE3H//O9+9I4jaORj?= =?iso-8859-1?Q?BizT4xzXxyHPZkuCywxM828WDYU9Ivld8QUw1sWVFnhKUJeSBuyWmgnUCB?= =?iso-8859-1?Q?hK4snQAnGaS7HIOV7v2Lo9yZ0dU05J9HgcHCc4TswQjmnvUSZywad9XZ7f?= =?iso-8859-1?Q?mOvbJ4RexqJPQxsb0zJpaFm0xaYfcL1HxeBGrQLukeKW1Or0p1F3UzpxqK?= =?iso-8859-1?Q?SMStcfj91KPNtRn/xTj3D149qjJc9EUOXLvSqjl/Ji4nymzLJMfwn+oSy4?= =?iso-8859-1?Q?+bWVRS/siq6sqUdrRoxD3iayeI+vEiobJF0ke+E/2qbuFjopxNLv8phwMd?= =?iso-8859-1?Q?4xJBaaTyGGJdg7Q9uVkWiCVTIUYADNaull7vskyV09rGCSRLB0m3aUewBe?= =?iso-8859-1?Q?+SByiucRHu1Cdij4ZmeRUf9K16L5bA+X8J0wrrX6onzrEfw9O1ChIq9OnP?= =?iso-8859-1?Q?v4gZTGnGsZu5VtEWlnmxP7+S8hoW180+Gg1ZoTjWHr5sC3Ho27aLOVeg?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69fa1008-ed93-496a-f94d-08dbed447deb X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2023 23:24:22.1479 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: NqFn8c1v7QgxnmQsmu10+gzfcesFpT6DPX0SzaFgzoE2ENmkQiWy6CPH4u8XqXyBfar2p4HQ7lImIiou1gUh/CK0SthqkFQzGK5ew52I+lI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8551 X-Proofpoint-GUID: 9fDivZI2WYkH1c0SNc8NmrePuBQxUhPq X-Proofpoint-ORIG-GUID: 9fDivZI2WYkH1c0SNc8NmrePuBQxUhPq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-24_09,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=413 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240182 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700868317272100001 Content-Type: text/plain; charset="utf-8" From: David Woodhouse This allows a XenDevice implementation to know whether it was created by QEMU, or merely discovered in XenStore after the toolstack created it. This will allow us to create frontend/backend nodes only when we should, rather than unconditionally attempting to overwrite them from a driver domain which doesn't have privileges to do so. As an added benefit, it also means we no longer have to call the xen_backend_set_device() function from the device models immediately after calling qdev_realize_and_unref(). Even though we could make the argument that it's safe to do so, and the pointer to the unreffed device *will* actually still be valid, it still made my skin itch to look at it. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/block/xen-block.c | 3 +-- hw/char/xen_console.c | 2 +- hw/net/xen_nic.c | 2 +- hw/xen/xen-backend.c | 15 +-------------- hw/xen/xen-bus.c | 4 ++++ include/hw/xen/xen-backend.h | 2 -- include/hw/xen/xen-bus.h | 2 ++ 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 6d64ede94f..c2ac9db4a2 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -1081,13 +1081,12 @@ static void xen_block_device_create(XenBackendInsta= nce *backend, =20 blockdev->iothread =3D iothread; blockdev->drive =3D drive; + xendev->backend =3D backend; =20 if (!qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), errp)) { error_prepend(errp, "realization of device %s failed: ", type); goto fail; } - - xen_backend_set_device(backend, xendev); return; =20 fail: diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 5cbee2f184..bef8a3a621 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -600,8 +600,8 @@ static void xen_console_device_create(XenBackendInstanc= e *backend, goto fail; } =20 + xendev->backend =3D backend; if (qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), errp)) { - xen_backend_set_device(backend, xendev); goto done; } =20 diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index af4ba3f1e6..afa10c96e8 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -627,8 +627,8 @@ static void xen_net_device_create(XenBackendInstance *b= ackend, net->dev =3D number; memcpy(&net->conf.macaddr, &mac, sizeof(mac)); =20 + xendev->backend =3D backend; if (qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), errp)) { - xen_backend_set_device(backend, xendev); return; } =20 diff --git a/hw/xen/xen-backend.c b/hw/xen/xen-backend.c index b9bf70a9f5..b2e753ebc8 100644 --- a/hw/xen/xen-backend.c +++ b/hw/xen/xen-backend.c @@ -88,19 +88,6 @@ static void xen_backend_list_add(XenBackendInstance *bac= kend) QLIST_INSERT_HEAD(&backend_list, backend, entry); } =20 -static XenBackendInstance *xen_backend_list_find(XenDevice *xendev) -{ - XenBackendInstance *backend; - - QLIST_FOREACH(backend, &backend_list, entry) { - if (backend->xendev =3D=3D xendev) { - return backend; - } - } - - return NULL; -} - bool xen_backend_exists(const char *type, const char *name) { const XenBackendImpl *impl =3D xen_backend_table_lookup(type); @@ -170,7 +157,7 @@ XenDevice *xen_backend_get_device(XenBackendInstance *b= ackend) =20 bool xen_backend_try_device_destroy(XenDevice *xendev, Error **errp) { - XenBackendInstance *backend =3D xen_backend_list_find(xendev); + XenBackendInstance *backend =3D xendev->backend; const XenBackendImpl *impl; =20 if (!backend) { diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 4973e7d9c9..dd0171ab98 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -1079,6 +1079,10 @@ static void xen_device_realize(DeviceState *dev, Err= or **errp) } } =20 + if (xendev->backend) { + xen_backend_set_device(xendev->backend, xendev); + } + xendev->exit.notify =3D xen_device_exit; qemu_add_exit_notifier(&xendev->exit); return; diff --git a/include/hw/xen/xen-backend.h b/include/hw/xen/xen-backend.h index 0f01631ae7..ea080ba7c9 100644 --- a/include/hw/xen/xen-backend.h +++ b/include/hw/xen/xen-backend.h @@ -10,8 +10,6 @@ =20 #include "hw/xen/xen-bus.h" =20 -typedef struct XenBackendInstance XenBackendInstance; - typedef void (*XenBackendDeviceCreate)(XenBackendInstance *backend, QDict *opts, Error **errp); typedef void (*XenBackendDeviceDestroy)(XenBackendInstance *backend, diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h index 334ddd1ff6..7647c4c38e 100644 --- a/include/hw/xen/xen-bus.h +++ b/include/hw/xen/xen-bus.h @@ -14,9 +14,11 @@ #include "qom/object.h" =20 typedef struct XenEventChannel XenEventChannel; +typedef struct XenBackendInstance XenBackendInstance; =20 struct XenDevice { DeviceState qdev; + XenBackendInstance *backend; domid_t frontend_id; char *name; struct qemu_xs_handle *xsh; --=20 2.42.0 From nobody Wed Nov 27 02:23:36 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1700868308; cv=pass; d=zohomail.com; s=zohoarc; b=d8tLj9cPHNtUp9HfM0ToBtX8yG8AGrlk/yhWAXcdwt0hWCC0V2AAE60IWRwTkscalzS4/uO4hmLgU3gqQUx2Zec2DGdkuchzWPeBosSeqOBiqS5YTuYPe34b3YaZ50F3/JzH8aYeY9JITEu3WaqFJ8FseVOLc2AyJx93OFGe+G0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700868308; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y5NInDPYzynXk4olgXY22V4iJ6pK1OKa9T7IrkYRcgc=; b=itPbuAM8VpwX9jQywNXZkzeHGFW8SH4zID1+Kyca1zLdN4WO197Dk+N41o/A7zza24g/+ZvHsxTF4Q/2ga+R0TEUYU+zMZIlebucy9pDl8GIKCF11RWPx9+2hz/W0R8vkR+OfcVIlE4lXT47arpE/qCKRIvxz3hzw6vRDclUzjA= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1700868307918475.02144382848303; Fri, 24 Nov 2023 15:25:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.640982.999781 (Exim 4.92) (envelope-from ) id 1r6fXL-0001SJ-Pn; Fri, 24 Nov 2023 23:24:39 +0000 Received: by outflank-mailman (output) from mailman id 640982.999781; Fri, 24 Nov 2023 23:24:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXL-0001SC-M1; Fri, 24 Nov 2023 23:24:39 +0000 Received: by outflank-mailman (input) for mailman id 640982; Fri, 24 Nov 2023 23:24:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXJ-0001Rw-Mj for xen-devel@lists.xenproject.org; Fri, 24 Nov 2023 23:24:37 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a0c0b35b-8b20-11ee-98e2-6d05b1d4d9a1; Sat, 25 Nov 2023 00:24:35 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOMwAPI014042; Fri, 24 Nov 2023 23:24:29 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uk2wmr6b0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 23:24:28 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8551.eurprd03.prod.outlook.com (2603:10a6:10:3e2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Fri, 24 Nov 2023 23:24:23 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7025.022; Fri, 24 Nov 2023 23:24:23 +0000 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: a0c0b35b-8b20-11ee-98e2-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NbVatzfST7Db17RlJcewQWIWs4r66OEQ9LAUFhZ+QOzyjbdVsLxBIl5jD8KxYy+3MPODmsV2JB3UMYOPurzihF8M6I8Whs7x6bKL8+s7G+sQI6Gy3UskpCTZPNZF98XyhGYRACWbehJ7ynXGxy/z6E5/zPHyCcO+jipcZU8vj8g5+N4bUdDASP0tCtWyDansmLdVPLTVy0evDF/E+yzaAFHahDh2xMhDvBY4V8CY74O9puukCi7+XxmprHsywdv8+AcR7eKQIxvcqHu4yWbXKP0jOtKl6xmauESnkLpyNK4at/kQNLPYA2zicBXL6GTvOL51Nlk0Lp0V34ECOxjIow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y5NInDPYzynXk4olgXY22V4iJ6pK1OKa9T7IrkYRcgc=; b=QsY1WR92DT6I0UlUrcyjvYf+oWUR1aWUn0BxMGRKFhjXYy28SoVoSKHnmSGc8kL9OiuQ8GgjYvG8PVyjgpTXEKPAlPZFAl7dhJb2KOX88v2pt9gnUKWhZ0xvjNc9aj9RZIJhXHLL8Ay+a0xtVwzs+FR/dMVbvHJwawBbDjB1MwOWqovetrKB6uQ4r8dx5EpJfLdzuFO8WhsxtNY8TGxA5iYUCj+VCWeZuOqE0ZO/evmsuGEU72hktzLQSR32dqrz8GBkAjGZXhCfZ/B3LQno7igh/8hFP78VR9dTu31eRw26b4579sVH7d531YuyfgMtWbBf7LxHjOBirPBiGJieCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y5NInDPYzynXk4olgXY22V4iJ6pK1OKa9T7IrkYRcgc=; b=UNtw5F8wJ5FGYckK8d/sZr7L9+kItSpRlAWiK8+7Cr0g0fDdBfd/slCXyzbmeB5oUr/gy4UkxNCp9sgIZfQ6WPzKdJtse0DCvi6IDq2+gabQi1EhlKkABF7EhEXG8mp3ce9CBB9yB+HbVak0B11a0FIlLojTQfKgUyFLr7LXsNBASv2RaTfds9r/XnNibabRjRJl8dkS1bEy3/Ug/Frl8BiAZknkv65527jpbBArf1r9ddpONtG6NSyEEWOqT+AZL9NcV5eCNhJWhnGxjtjBFvS8Vf6lS084/Swz3F/x0fy/EtL9f+EzF2wb7gzCO2M+RMOMJ/XnY10JY5Cwx87sAQ== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Paul Durrant , Oleksandr Tyshchenko , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , =?iso-8859-1?Q?Marc-Andr=E9_Lureau?= , Paolo Bonzini , Jason Wang , "open list:X86 Xen CPUs" , "open list:Block layer core" Subject: [PATCH v3 2/5] xen: backends: don't overwrite XenStore nodes created by toolstack Thread-Topic: [PATCH v3 2/5] xen: backends: don't overwrite XenStore nodes created by toolstack Thread-Index: AQHaHy1b3EzvbBTaE06mm4g67YDmDQ== Date: Fri, 24 Nov 2023 23:24:22 +0000 Message-ID: <20231124232400.943580-3-volodymyr_babchuk@epam.com> References: <20231124232400.943580-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231124232400.943580-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DU0PR03MB8551:EE_ x-ms-office365-filtering-correlation-id: 79aa1d96-b998-457c-9410-08dbed447e27 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PX5QxQ/3/kiqNtjA8aiYBrNGyfixFZag0Y2G457JCoSybbEJ2X/zNH+bRXrInOiMY9CqtB5PRb6kkfTdZIPB969ikRwsx1gPkeSw99BkvQ6n3mkWdMDzGj7yUPV1rRBjv9ph1CKMXKBaeG45vMVGyn0DCA3aGALcZwVti1oor6BiNnblLqTclufjCY2q0A/9eF566Ho0Ww17Kj96H0om+CRZ/Qka1/kTznYVkRf//p1eYljH0duKe5nFbPCG+bwmER0g1I/+6Jfooc1CsjQQsTuz3Hf0Ty1xcMF3xfhG3Wc6rGE9kXQPFsUCJzx+EZGb8DY2I0fiN7mWarOygunie+1egNWw058y6IH6OfKB51rc8+w3x07K5WYpuBamq9ySmjIEY14n4Pr5d94m285x+s7/RDkPXDF2maSgUNNnXUdu4vApYt//y3xN+lCk8j77FFeF3WAHgQh51Bj6GvQknsVBbRY/ayDsHyioYp7YL9Jxf4hm5BJ93g4vU1HfDcwfzhU7sVaTNk4yQc/WZsjV50hvbubfhBs2wGla44EWR6TMLwilNp/R1/bDQbXxjbG3KotGZBLUuNWuXX8Og0ibAuD7m6bAYxjTzag5ptxAL20wEkEe8YhAt0ffUFKsxQGM x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(366004)(136003)(376002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(38100700002)(1076003)(6512007)(83380400001)(2616005)(6506007)(55236004)(71200400001)(41300700001)(8676002)(4326008)(5660300002)(8936002)(26005)(7416002)(478600001)(6486002)(2906002)(6916009)(316002)(91956017)(66476007)(66446008)(54906003)(64756008)(76116006)(66946007)(66556008)(86362001)(122000001)(36756003)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?P5Zk/L9SG8UthSFzLsCkHbt/S6WyBm8+U7I/ORZv+rPdcD9abqEQfjbBwh?= =?iso-8859-1?Q?XbhynglhgNPobt6+GYHck+kzZAQPzUOSw1b7Jg+/MmMnF4ayNxuQOgxdW7?= =?iso-8859-1?Q?WRQA6MOaxj3pwk6d5VZZPwIiPx5HM4+k5t0L/Qa9/RcHclCOWMUMAPWBHq?= =?iso-8859-1?Q?7FyHiig5can1lhcXjRmSHOhJBKbAeFBUUcijbnJFiCBx0jiRKI6uluzKDU?= =?iso-8859-1?Q?8/aLvdWyTC2n6tQikY4kmsrW3nmK/cf50+TucX7oegxUZKhP97oiQezPQC?= =?iso-8859-1?Q?W4OyPpKNmX1nW+4GUtzkxH9qGrrtl1PzDHBdyCGw37UAIpMjzx0LJPGkrE?= =?iso-8859-1?Q?dN8HKpK45ZS8bg125CCaCSZh5fumZl4/RF23LCtga3KFGekJ8EuKWV50Cj?= =?iso-8859-1?Q?EMusd4kMALvYLyRO3km0lL+pFVxtImkO46dJtNMMfj8v5gjvcH0V4YYgsh?= =?iso-8859-1?Q?lBfLpcfqttovs60xpakvXemoHlPr3koRVlAr6bTIGNxw3IRjT3MIdI4VxL?= =?iso-8859-1?Q?wqqSH+Ut3yIjHtUMg/aR8oPdxrcSXUAVeGrx0iEeoyV9NJDKEq+wj4Xjda?= =?iso-8859-1?Q?inwLj5cmmvd0uupUl+e8QyibMzCb2VEOIyoPx393RTfx6DvLtHaXiMkrK7?= =?iso-8859-1?Q?RNx65IPfzWxUuMNY3/uKwqE0O3aI6dGCUUtaJefMSxTKnQds2FhOAOioUc?= =?iso-8859-1?Q?NTggrNswn6lpKt8WTPRpnQyM6Fa2rP1n8Btd2ZlOGYZESdxMbtkcnt0JM7?= =?iso-8859-1?Q?86HEyqdh7gpO4QgbKMvtvIE/fwOezfjb9F6tnKKpIfHW0FIu/APPLaJCs/?= =?iso-8859-1?Q?Fd6I59M0Vo2guRTT5Bb9iQKkVScXQE3z7Hk20D3Nh/va4U1VyfkovqEoHb?= =?iso-8859-1?Q?Vfas4/KBszV08b1eL89Or5tLYrxngbG0tqzC2O3iAKhZC+vdIhuNNd5aZE?= =?iso-8859-1?Q?+Ht+uhzdSyHhuBi3YdgYacZPzXO7WgutJ22tutN3Jq82qpVjVYrB9C57wx?= =?iso-8859-1?Q?4js+n06l0phNUKKK0JVb4ItaXleiYtJp3N78+LMuWrnB4uzqFs8HTHuRdi?= =?iso-8859-1?Q?jP2WerCmaN/f+S5C0g4UWItIuF6En7Rx93yJFIRNzhUV0z/QE+5kxM27uG?= =?iso-8859-1?Q?0xgS0lLti7lk7rwQo3jSA+X0VYm7fLYIwrDDczxGTy15rzre2glOxT8yRA?= =?iso-8859-1?Q?lcO1x5gSK1luKZCzvO1NeeDcK/RK6kp2wd6yA46GpT8ajO93Hjraua6ssG?= =?iso-8859-1?Q?OmFBO7Gx1otGgiCrOOMC06g+kOykXowHRXdUtgYeBb4SDb9pta6oYBjYcY?= =?iso-8859-1?Q?CT+KEgpAnY35U6C6Bm7+aU89Cjx3ExVtQIlQarisBR3XOFqXhbCjtPSNNL?= =?iso-8859-1?Q?aT5Y6q7H/5N8PIZguSJ+1udV/mPvjVSfd2kaGdtWxVnjMppEKDwZFr/cXw?= =?iso-8859-1?Q?Ox6chBtAZAl5/V5c0grVobCx/zeMJxSufQ+cHvtos9fAvBKk87sHBEgQUx?= =?iso-8859-1?Q?F5fYz0z8Fb68m88pidzR6LCZkSXEGB9T+2PUIaqMySXyQMVyCOLI+VWjW5?= =?iso-8859-1?Q?qm+TYCytMgcfnKpRz69aF8wERw5VXiXV7cfGh69FoskZO6CFyTdUl65D3r?= =?iso-8859-1?Q?O0Qckf41XxgkveMjOn8nJK+VsbkZbZeyUBvJfhPWKn6r8/gwi6ummsMQ?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79aa1d96-b998-457c-9410-08dbed447e27 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2023 23:24:22.5517 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xNkyqKI4YT4IIdT+ljJO8sagcbRBqB2Fuv6M9yFz1v8iP/hdl/kWRESJTCJqW1KfiUgAMAUlMRepVUWpLavnOEXzKt9n2h9MOEmtMwUYtrI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8551 X-Proofpoint-GUID: 79EPq4XasLgjwOuPBklnjbU3ybtvPQIo X-Proofpoint-ORIG-GUID: 79EPq4XasLgjwOuPBklnjbU3ybtvPQIo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-24_09,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=971 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240182 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700868309292100001 Content-Type: text/plain; charset="utf-8" Xen PV devices in QEMU can be created in two ways: either by QEMU itself, if they were passed via command line, or by Xen toolstack. In the latter case, QEMU scans XenStore entries and configures devices accordingly. In the second case we don't want QEMU to write/delete front-end entries for two reasons: it might have no access to those entries if it is running in un-privileged domain and it is just incorrect to overwrite entries already provided by Xen toolstack, because toolstack manages those nodes. For example, it might read backend- or frontend- state to be sure that they are both disconnected and it is safe to destroy a domain. This patch checks presence of xendev->backend to check if Xen PV device was configured by Xen toolstack to decide if it should touch frontend entries in XenStore. Also, when we need to remove XenStore entries during device teardown only if they weren't created by Xen toolstack. If they were created by toolstack, then it is toolstack's job to do proper clean-up. Suggested-by: Paul Durrant Suggested-by: David Woodhouse Co-Authored-by: Oleksandr Tyshchenko Signed-off-by: Volodymyr Babchuk Reviewed-by: David Woodhouse --- Changes in v3: - Rephrased the commit message --- hw/block/xen-block.c | 16 +++++++++------- hw/char/xen_console.c | 2 +- hw/net/xen_nic.c | 18 ++++++++++-------- hw/xen/xen-bus.c | 14 +++++++++----- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index c2ac9db4a2..dac519a6d3 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -390,13 +390,15 @@ static void xen_block_realize(XenDevice *xendev, Erro= r **errp) =20 xen_device_backend_printf(xendev, "info", "%u", blockdev->info); =20 - xen_device_frontend_printf(xendev, "virtual-device", "%lu", - vdev->number); - xen_device_frontend_printf(xendev, "device-type", "%s", - blockdev->device_type); - - xen_device_backend_printf(xendev, "sector-size", "%u", - conf->logical_block_size); + if (!xendev->backend) { + xen_device_frontend_printf(xendev, "virtual-device", "%lu", + vdev->number); + xen_device_frontend_printf(xendev, "device-type", "%s", + blockdev->device_type); + + xen_device_backend_printf(xendev, "sector-size", "%u", + conf->logical_block_size); + } =20 xen_block_set_size(blockdev); =20 diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index bef8a3a621..b52ddddabf 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -450,7 +450,7 @@ static void xen_console_realize(XenDevice *xendev, Erro= r **errp) =20 trace_xen_console_realize(con->dev, object_get_typename(OBJECT(cs))); =20 - if (CHARDEV_IS_PTY(cs)) { + if (CHARDEV_IS_PTY(cs) && !xendev->backend) { /* Strip the leading 'pty:' */ xen_device_frontend_printf(xendev, "tty", "%s", cs->filename + 4); } diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index afa10c96e8..27442bef38 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -315,14 +315,16 @@ static void xen_netdev_realize(XenDevice *xendev, Err= or **errp) =20 qemu_macaddr_default_if_unset(&netdev->conf.macaddr); =20 - xen_device_frontend_printf(xendev, "mac", "%02x:%02x:%02x:%02x:%02x:%0= 2x", - netdev->conf.macaddr.a[0], - netdev->conf.macaddr.a[1], - netdev->conf.macaddr.a[2], - netdev->conf.macaddr.a[3], - netdev->conf.macaddr.a[4], - netdev->conf.macaddr.a[5]); - + if (!xendev->backend) { + xen_device_frontend_printf(xendev, "mac", + "%02x:%02x:%02x:%02x:%02x:%02x", + netdev->conf.macaddr.a[0], + netdev->conf.macaddr.a[1], + netdev->conf.macaddr.a[2], + netdev->conf.macaddr.a[3], + netdev->conf.macaddr.a[4], + netdev->conf.macaddr.a[5]); + } netdev->nic =3D qemu_new_nic(&net_xen_info, &netdev->conf, object_get_typename(OBJECT(xendev)), DEVICE(xendev)->id, netdev); diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index dd0171ab98..d0f17aeb27 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -599,8 +599,10 @@ static void xen_device_backend_destroy(XenDevice *xend= ev) =20 g_assert(xenbus->xsh); =20 - xs_node_destroy(xenbus->xsh, XBT_NULL, xendev->backend_path, - &local_err); + if (!xendev->backend) { + xs_node_destroy(xenbus->xsh, XBT_NULL, xendev->backend_path, + &local_err); + } g_free(xendev->backend_path); xendev->backend_path =3D NULL; =20 @@ -764,8 +766,10 @@ static void xen_device_frontend_destroy(XenDevice *xen= dev) =20 g_assert(xenbus->xsh); =20 - xs_node_destroy(xenbus->xsh, XBT_NULL, xendev->frontend_path, - &local_err); + if (!xendev->backend) { + xs_node_destroy(xenbus->xsh, XBT_NULL, xendev->frontend_path, + &local_err); + } g_free(xendev->frontend_path); xendev->frontend_path =3D NULL; =20 @@ -1063,7 +1067,7 @@ static void xen_device_realize(DeviceState *dev, Erro= r **errp) xen_device_backend_set_online(xendev, true); xen_device_backend_set_state(xendev, XenbusStateInitWait); =20 - if (!xen_device_frontend_exists(xendev)) { + if (!xen_device_frontend_exists(xendev) && !xendev->backend) { xen_device_frontend_printf(xendev, "backend", "%s", xendev->backend_path); xen_device_frontend_printf(xendev, "backend-id", "%u", --=20 2.42.0 From nobody Wed Nov 27 02:23:36 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1700868320; cv=pass; d=zohomail.com; s=zohoarc; b=OJoQ9/dWd3bqjfia+YxHepTziRIAwxFSio7jjgA4eZSt/Yg7/k7BuLgFcD46/SdTKi0LWbtFzm3Lm7cShg3oFfjkWevDcYh5wDdGb39H+jkxltyNlsVehZ0H216pVs2BYvo6iFf+wZ3/9rcAmcZeizU5U/txzbBW8jnJenl0lrY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700868320; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b6piVTLnT/ePWflf79oGCnWyoOwmQ+YDU+WgRfEz16g=; b=D7tKXbI2rA4CTrGtMVl6aj1hBsglGZrOSGPenrw6TfDMnaRLFLWaBPGWnjsiBcBLkmKEh2ZE4Os7Z35YlQ5LL1VO1TzwbkE7yti/D0zcRp9zYtibOjidUS5i4g1CbZWGAKM77L8m2/lySogWlcGbN2VTuCk7XIJOwpucJZzkouc= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1700868320941713.5683348001908; Fri, 24 Nov 2023 15:25:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.640985.999811 (Exim 4.92) (envelope-from ) id 1r6fXY-0002Ja-Pa; Fri, 24 Nov 2023 23:24:52 +0000 Received: by outflank-mailman (output) from mailman id 640985.999811; Fri, 24 Nov 2023 23:24:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXY-0002JP-Lb; Fri, 24 Nov 2023 23:24:52 +0000 Received: by outflank-mailman (input) for mailman id 640985; Fri, 24 Nov 2023 23:24:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXX-0002IJ-8Q for xen-devel@lists.xenproject.org; Fri, 24 Nov 2023 23:24:51 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a8bd7e5d-8b20-11ee-9b0e-b553b5be7939; Sat, 25 Nov 2023 00:24:48 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOMwAPM014042; Fri, 24 Nov 2023 23:24:30 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uk2wmr6b0-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 23:24:30 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8551.eurprd03.prod.outlook.com (2603:10a6:10:3e2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Fri, 24 Nov 2023 23:24:23 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7025.022; Fri, 24 Nov 2023 23:24:23 +0000 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: a8bd7e5d-8b20-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DXrjT/OSbqCjCpOs+hua40bK0JiB+R5QMjusa1WIU7HUUjmQDPLh0jyQ1jAY64p8WxHtRciXlA0aKAR2MQmtXg7k2//V+f/d3WrOy+KxOY8tyAYoHPNyBRTFMY3JxtP5Hb7ONFiyEOUepuv6ew2W5e/OPL+apKVUYXw5oU6KPh78A3JVgHKc1es0wj6os+5Y9HM65cW9vD8N2FayfCK77KBag4678+qfJoeQ2WMBIe9PN8+3kZwDVA2Ii5lj0DHcir5uxTClOrYKHYkSL21SGp2VN+MbvQafErec+N7HxKluByhg5v4EE/t8tkHewcJhmeccAZtvUn6tFy3KEl3mJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b6piVTLnT/ePWflf79oGCnWyoOwmQ+YDU+WgRfEz16g=; b=Equg6HOhNI7IS3F1ZmTcXV5CbT94DgymC+zi3P8mlBD9dGp9akTnJ0uGPTTAqnXW9IwGoxrSwPYrjN9gHpQJhN9DtbPEOqz3uB3FMVV7cCw21E0MSUnc9wR3sVaWCQAzFH+s6SsCA9cyPJL9e/ZQsOWCYVHvfWUlBGq5jz6Y1KScuhlVQdmMdtrYDQLCZ9Vqj0q9xSfa641PUPZh3TduIRnlPC1uPdtjFfj7Xz6AsEDA7BdhFbBMuqrqbyYRL6Nocj0nMe5Kg7iltfQjpcS3ouwgfGf+uK/4u2Q2+PwjfDCjfwqMMxTqdu7ztWesfoqUbaJfWrvoh2ylO/2BHZRuBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b6piVTLnT/ePWflf79oGCnWyoOwmQ+YDU+WgRfEz16g=; b=FJOtKXMsJT+sDYZgZLPCgVA40qKATrAf7BkHyT5zbOLrPKqXPgWzaYAhJtSDduMhb5Q6rfhZG7x4EGD0kamHH5CpxYFJRqNbQBCK7qS6MI6b0LQFzC/SYZssicAjjM2kzcQPUm2wmGPmn/gihdkmX/gCDoz28ZVRox8+8ljxcYXZpq52xCm5nC314xk3KQXuUFHcvGPq0Up9PtGHW3rZIBqgdCtokMjRbbZ+ZxTufisa3WeX4paD2ZHCJfPZkoHtUJ+mbffJVn3twck+f0/2XsJ0HQW8A+WSGL7DFxUKxgPMQMEvDwu6Slzt8NwzEdUiJHKKeDqswuQNdTRheh6Wtg== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Anthony Perard , Paul Durrant , Greg Kurz , Christian Schoenebeck , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Gerd Hoffmann , =?iso-8859-1?Q?Marc-Andr=E9_Lureau?= , =?iso-8859-1?Q?Daniel_P=2E_Berrang=E9?= , Thomas Huth , =?iso-8859-1?Q?Philippe_Mathieu-Daud=E9?= , "open list:X86 Xen CPUs" Subject: [RFC PATCH v3 3/5] xen: add option to disable legacy backends Thread-Topic: [RFC PATCH v3 3/5] xen: add option to disable legacy backends Thread-Index: AQHaHy1b1vaaoDkYtEa69hkezixH/A== Date: Fri, 24 Nov 2023 23:24:22 +0000 Message-ID: <20231124232400.943580-4-volodymyr_babchuk@epam.com> References: <20231124232400.943580-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231124232400.943580-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DU0PR03MB8551:EE_ x-ms-office365-filtering-correlation-id: a26c1ac4-9949-4445-914b-08dbed447e65 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BS9SMTgN7qWvPu4x/QLjqGjpfS0uZc1mAeFoJPD7arR0WqyJkyDSJrNE74udiMp5HYr5Sz/gt+aHmNHnaAfICV6ieso20mTIiHZ4ciiacccZV5S9Hp9rKgSmINtpSUsARY/bQMv9GyT51Czn7dpl4PR3QTAYZ4xWOofCrHRAvgdw3Jy2+u4q0jLQQ+uz33q0PBRzRD51sRs/sKFDKjHlG9NzRe+UkAfaLHVvBOpsfJvlwYTI0KWOKNiZJ6iSiYzJsWrMT3VEUwuaICv97n4otId+p+x4+VoPAtl5Qyo/MFi41ZvBgxDIoWRA+zpJCP63/Gggu4NUZ2Uk6Hmjc1/cQPiEn91POJ6YMDRStIAnfKy5o+GlKMZunEPu0KGSq9cYpbl0PDuUlVKn6mRgw5koq62PEz3KDPtzHegJst4h5heOqyrNqBQ/OXD0RL7HgqjmJrBvOd7vPK7FcCuO7Mx6xMmBsX+J6R+K13rGmbHoaeb45KLlApJskhDLhnPppZVa45potgH6YIELa9Z3GnQ3nVJtc7dTrTvo5WKwMaPzZofJumTP696KMyR4rOqjgQ2Jwe+lLrHxkiWMycKwSxp3r7Uog8YCC2Y3KkOJsjmIhCdWnOXJGbTqAzOLe7hAKnkvOj6HJ0s44lqOldlHI6wS3w== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(366004)(136003)(376002)(39860400002)(230173577357003)(230273577357003)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(38100700002)(1076003)(6512007)(83380400001)(2616005)(6506007)(55236004)(71200400001)(41300700001)(8676002)(4326008)(5660300002)(8936002)(26005)(7416002)(478600001)(966005)(6486002)(2906002)(6916009)(316002)(91956017)(66476007)(66446008)(54906003)(64756008)(76116006)(66946007)(66556008)(86362001)(122000001)(36756003)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?w+NFI1LLHpWcCY/2EDoaqaSIeAiQLjXogpLtFnvqsBIpDAIhiLXyHwA2Jk?= =?iso-8859-1?Q?5+kQOBOdViWuWv/TsfH2fB5g2Rz4mfkyV4mzU8dubGfD9R4NCl4X97Yz0e?= =?iso-8859-1?Q?hs/g01w6GUlJ1UBmDRvR+tGFnCtL0bfeJflB4h/gVaeDq8nHhbm+1rdOPl?= =?iso-8859-1?Q?w+LB7RtApnMxTVKCnhinOCZak3eErKzMhy5V0ySxMOhfEmxpkbffrk0399?= =?iso-8859-1?Q?VDUAXMwJSpdyiSeG32U4tEu138U1mixoTqUk3KJcFD/XzgVcd55dt62MnO?= =?iso-8859-1?Q?ZBBuovWU8gXfGF2/MPFe/bnrJxcVBN+/GdVN1JYaj7xX8Oln7rmgcqvu+B?= =?iso-8859-1?Q?SR3tyOivr9qXSGESEZSdrDKJhuSW895MuLZdTC2lj7XWfMB8h81DdD2bBY?= =?iso-8859-1?Q?ijnaiNnRzrRtPQEKiS3widQ8coPtcJCIUOUxVhCNXVo6chB6YPQyiSr4/v?= =?iso-8859-1?Q?ivJkqiDliYtBjk+HcPIJIPeJs4jyTMiviD3CyVsishcqsPF9CdDA7Jm0TW?= =?iso-8859-1?Q?ZG2oHnw2ZGw0i+TXdwI7Tp0hpuH5kTxKwFmDdInM1xq7jNrwRIc+Yv5vch?= =?iso-8859-1?Q?kDtskKdY+IdHCzUrJPdZNdrKXGPSigcr5h2A7HBEaUiJk4aMIS6NYRbr84?= =?iso-8859-1?Q?c/Iq6du/bRQJts53HuzQBYqApL0X2kRVMZkY00fY4hzltZUV5UD0lUOrnT?= =?iso-8859-1?Q?Kbl/xIUv6nKhIZrKiSLGfkiovqzczW6P+R6v+SJRjw1k5hzK1/SB8ZrwqQ?= =?iso-8859-1?Q?HcFyj/hx5zg40Sp2Lhq0is3cSr80WNi8P82mrS4VJcJenMmUq6LQO/pr7J?= =?iso-8859-1?Q?oZA7I11zF8v0YTaQ13McShUZLhrpZLtfTgdoTXUX1Mo9b17dUA/gOMGD3H?= =?iso-8859-1?Q?rIO41saRbExsH6rtYvHhsbyXu5Pnhg4nOPMHyW97cCnRtQD7URCdxpnIha?= =?iso-8859-1?Q?IYno0GjWV4obAn1SUrr0sRijn2VOuUL8eLDzvNTCbL+s7Oj6itugXnZnxI?= =?iso-8859-1?Q?jlazoHdaK+lKYLdykpgCd8GTKiN7qJrzKjsBRxrEPY1mmxXwVHh5CfN9Ao?= =?iso-8859-1?Q?mx+QRjEv9DFUseX3drXXASt0Syy6sBE38DCGrNDvdbJlB1axW8O0cV1I5h?= =?iso-8859-1?Q?wWX5xZb6JA1UOZs9TT12ctw/rvdA6hXzRIpyVEoy8yQxXj4JWZWD3DL73B?= =?iso-8859-1?Q?uafximKjLUf5xf2uXK70TPH7/m+LMGz/FBCE/ubEpZ/bWfLprxeR4FUTFD?= =?iso-8859-1?Q?hLkgN8H77C4+z64qTaU1JWKHuUmBZkVDWtCNMC0iTcUwwVJuBRCN2a8nmq?= =?iso-8859-1?Q?Om3wgzvCVmmnHzZaS4t4Qgo4O1ncPiMLolX+aLL0KGRqb+HnsrNRB4CxWW?= =?iso-8859-1?Q?HxJ8C952hbht3UW4IxRaI0v3LG4xa95jFORlB3xyU5B/zU3MUs/17P7HQt?= =?iso-8859-1?Q?r9SiGQTH+Wp2Lg6cHaALZ8rq404vzwM1jWCVRy5inOwJhlzvGb8Xm7zxLJ?= =?iso-8859-1?Q?N/XiUJHY7UeAu6qXU64WSCUWQQlnTw4N8ZZiJxC60fhBQkt+Kv6IlF3T9A?= =?iso-8859-1?Q?dwNGx8AVL1ODbjelz9QcqduXWyeil6ivo4frNtyenX4VEYAx/Jc/kqI5Wd?= =?iso-8859-1?Q?I3MAiAXkCVdXwqAoAw7z09f8BJZKsEsX8x2r1mdoIWtAhGH/iw2t4FDA?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a26c1ac4-9949-4445-914b-08dbed447e65 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2023 23:24:22.9990 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Bp4r+fFxW0tQiM20XqIGK26wOvHcgYGA99OqOszjpaMRhpXUd1bSRvrtgJHdAZAe3IWDhFDu72EVPwFmLwOSKOToWVuKL/ZehwBqYuh0NrM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8551 X-Proofpoint-GUID: 7SIitNEDAyqQ4I0uP2sdQqI9RpRxPv6u X-Proofpoint-ORIG-GUID: 7SIitNEDAyqQ4I0uP2sdQqI9RpRxPv6u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-24_09,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240182 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700868321326100001 Content-Type: text/plain; charset="utf-8" This patch makes legacy backends optional. As was discussed at [1] this is a solution to a problem when we can't run QEMU as a device model in a non-privileged domain. This is because legacy backends assume that they are always running in domain with ID =3D 0. Actually, this may prevent running QEMU in a privileged domain with ID not equal to zero. To be able to disable legacy backends we need to alter couple of source files that unintentionally depend on them. For example xen-all.c used xen_pv_printf to report errors, while not providing any additional like xendev pointer. Also, we need to move xenstore structure from xen-legacy-backend.c, because it is apparently used in xen-all.c. With this patch it is possible to provide "--disable-xen-legacy-backends" configure option to get QEMU binary that can run in a driver domain. With price of not be able to use legacy backends of course. [1] https://lists.gnu.org/archive/html/qemu-devel/2023-11/msg05022.html Signed-off-by: Volodymyr Babchuk --- I am not sure if I made correct changes to the build system, thus this patch is tagged as RFC. Changes in v3: - New patch in v3 --- accel/xen/xen-all.c | 13 ++++++++++--- hw/9pfs/meson.build | 4 +++- hw/display/meson.build | 4 +++- hw/i386/pc.c | 2 ++ hw/usb/meson.build | 5 ++++- hw/xen/meson.build | 11 ++++++++--- hw/xen/xen-hvm-common.c | 2 ++ hw/xen/xen-legacy-backend.c | 7 ------- hw/xenpv/xen_machine_pv.c | 2 ++ meson.build | 5 +++++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 4 ++++ 12 files changed, 45 insertions(+), 16 deletions(-) diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 5ff0cb8bd9..188b29597f 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -29,6 +29,7 @@ bool xen_allowed; xc_interface *xen_xc; xenforeignmemory_handle *xen_fmem; xendevicemodel_handle *xen_dmod; +struct qemu_xs_handle *xenstore; =20 static void xenstore_record_dm_state(const char *state) { @@ -78,20 +79,26 @@ static int xen_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 + xenstore =3D qemu_xen_xs_open(); + if (!xenstore) { + error_report("can't connect to xenstored\n"); + exit(1); + } + xen_xc =3D xc_interface_open(0, 0, 0); if (xen_xc =3D=3D NULL) { - xen_pv_printf(NULL, 0, "can't open xen interface\n"); + error_report("can't open xen interface\n"); return -1; } xen_fmem =3D xenforeignmemory_open(0, 0); if (xen_fmem =3D=3D NULL) { - xen_pv_printf(NULL, 0, "can't open xen fmem interface\n"); + error_report("can't open xen fmem interface\n"); xc_interface_close(xen_xc); return -1; } xen_dmod =3D xendevicemodel_open(0, 0); if (xen_dmod =3D=3D NULL) { - xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n"); + error_report("can't open xen devicemodel interface\n"); xenforeignmemory_close(xen_fmem); xc_interface_close(xen_xc); return -1; diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 2944ea63c3..e8306ba8d2 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -15,7 +15,9 @@ fs_ss.add(files( )) fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) -fs_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-9p-backend.c')) +if have_xen_legacy_backends + fs_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-9p-backend.c')) +endif system_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) =20 specific_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device= .c')) diff --git a/hw/display/meson.build b/hw/display/meson.build index 344dfe3d8c..18d657f6b3 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -14,7 +14,9 @@ system_ss.add(when: 'CONFIG_PL110', if_true: files('pl110= .c')) system_ss.add(when: 'CONFIG_SII9022', if_true: files('sii9022.c')) system_ss.add(when: 'CONFIG_SSD0303', if_true: files('ssd0303.c')) system_ss.add(when: 'CONFIG_SSD0323', if_true: files('ssd0323.c')) -system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xenfb.c')) +if have_xen_legacy_backends + system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xenfb.c')) +endif =20 system_ss.add(when: 'CONFIG_VGA_PCI', if_true: files('vga-pci.c')) system_ss.add(when: 'CONFIG_VGA_ISA', if_true: files('vga-isa.c')) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 29b9964733..91857af428 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1263,7 +1263,9 @@ void pc_basic_device_init(struct PCMachineState *pcms, pci_create_simple(pcms->bus, -1, "xen-platform"); } pcms->xenbus =3D xen_bus_init(); +#ifdef CONFIG_XEN_LEGACY_BACKENDS xen_be_init(); +#endif } #endif =20 diff --git a/hw/usb/meson.build b/hw/usb/meson.build index e94149ebde..8d395745b2 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -84,6 +84,9 @@ if libusb.found() hw_usb_modules +=3D {'host': usbhost_ss} endif =20 -system_ss.add(when: ['CONFIG_USB', 'CONFIG_XEN_BUS', libusb], if_true: fil= es('xen-usb.c')) +if have_xen_legacy_backends + system_ss.add(when: ['CONFIG_USB', 'CONFIG_XEN_BUS', libusb], + if_true: files('xen-usb.c')) +endif =20 modules +=3D { 'hw-usb': hw_usb_modules } diff --git a/hw/xen/meson.build b/hw/xen/meson.build index d887fa9ba4..964c3364f2 100644 --- a/hw/xen/meson.build +++ b/hw/xen/meson.build @@ -2,11 +2,16 @@ system_ss.add(when: ['CONFIG_XEN_BUS'], if_true: files( 'xen-backend.c', 'xen-bus-helper.c', 'xen-bus.c', - 'xen-legacy-backend.c', - 'xen_devconfig.c', - 'xen_pvdev.c', )) =20 +if have_xen_legacy_backends + system_ss.add(when: ['CONFIG_XEN_BUS'], if_true: files( + 'xen_pvdev.c', + 'xen-legacy-backend.c', + 'xen_devconfig.c', + )) +endif + system_ss.add(when: ['CONFIG_XEN', xen], if_true: files( 'xen-operations.c', )) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 565dc39c8f..2e7897dbd2 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -869,7 +869,9 @@ void xen_register_ioreq(XenIOState *state, unsigned int= max_cpus, =20 xen_bus_init(); =20 +#ifdef CONFIG_XEN_LEGACY_BACKENDS xen_be_init(); +#endif =20 return; =20 diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c index 124dd5f3d6..717d5efc06 100644 --- a/hw/xen/xen-legacy-backend.c +++ b/hw/xen/xen-legacy-backend.c @@ -39,7 +39,6 @@ BusState *xen_sysbus; /* ------------------------------------------------------------- */ =20 /* public */ -struct qemu_xs_handle *xenstore; const char *xen_protocol; =20 /* private */ @@ -605,12 +604,6 @@ static void xen_set_dynamic_sysbus(void) =20 void xen_be_init(void) { - xenstore =3D qemu_xen_xs_open(); - if (!xenstore) { - xen_pv_printf(NULL, 0, "can't connect to xenstored\n"); - exit(1); - } - if (xen_evtchn_ops =3D=3D NULL || xen_gnttab_ops =3D=3D NULL) { xen_pv_printf(NULL, 0, "Xen operations not set up\n"); exit(1); diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c index 9f9f137f99..03a55f345c 100644 --- a/hw/xenpv/xen_machine_pv.c +++ b/hw/xenpv/xen_machine_pv.c @@ -37,7 +37,9 @@ static void xen_init_pv(MachineState *machine) setup_xen_backend_ops(); =20 /* Initialize backend core & drivers */ +#ifdef CONFIG_XEN_LEGACY_BACKENDS xen_be_init(); +#endif =20 switch (xen_mode) { case XEN_ATTACH: diff --git a/meson.build b/meson.build index ec01f8b138..c8a43dd97d 100644 --- a/meson.build +++ b/meson.build @@ -1749,6 +1749,9 @@ have_xen_pci_passthrough =3D get_option('xen_pci_pass= through') \ error_message: 'Xen PCI passthrough not available on this platf= orm') \ .allowed() =20 +have_xen_legacy_backends =3D get_option('xen-legacy-backends').require(xen= .found(), + error_message: 'Xen legacy backends requested but Xen not enabl= ed').allowed() + =20 cacard =3D not_found if not get_option('smartcard').auto() or have_system @@ -2219,6 +2222,7 @@ config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_disp= lay) config_host_data.set('CONFIG_CFI', get_option('cfi')) config_host_data.set('CONFIG_SELINUX', selinux.found()) config_host_data.set('CONFIG_XEN_BACKEND', xen.found()) +config_host_data.set('CONFIG_XEN_LEGACY_BACKENDS', have_xen_legacy_backend= s) config_host_data.set('CONFIG_LIBDW', libdw.found()) if xen.found() # protect from xen.version() having less than three components @@ -3049,6 +3053,7 @@ config_all +=3D config_targetos config_all +=3D config_all_disas config_all +=3D { 'CONFIG_XEN': xen.found(), + 'CONFIG_XEN_LEGACY_BACKENDS': have_xen_legacy_backends, 'CONFIG_SYSTEM_ONLY': have_system, 'CONFIG_USER_ONLY': have_user, 'CONFIG_ALL': true, diff --git a/meson_options.txt b/meson_options.txt index c9baeda639..91dd677257 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -77,6 +77,8 @@ option('nvmm', type: 'feature', value: 'auto', description: 'NVMM acceleration support') option('xen', type: 'feature', value: 'auto', description: 'Xen backend support') +option('xen-legacy-backends', type: 'feature', value: 'auto', + description: 'Xen legacy backends (9pfs, fb, qusb) support') option('xen_pci_passthrough', type: 'feature', value: 'auto', description: 'Xen PCI passthrough support') option('tcg', type: 'feature', value: 'enabled', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 680fa3f581..b5acef008f 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -218,6 +218,8 @@ meson_options_help() { printf "%s\n" ' werror Treat warnings as errors' printf "%s\n" ' whpx WHPX acceleration support' printf "%s\n" ' xen Xen backend support' + printf "%s\n" ' xen-legacy-backends' + printf "%s\n" ' Xen legacy backends (9pfs, fb, qusb) su= pport' printf "%s\n" ' xen-pci-passthrough' printf "%s\n" ' Xen PCI passthrough support' printf "%s\n" ' xkbcommon xkbcommon support' @@ -556,6 +558,8 @@ _meson_option_parse() { --disable-whpx) printf "%s" -Dwhpx=3Ddisabled ;; --enable-xen) printf "%s" -Dxen=3Denabled ;; --disable-xen) printf "%s" -Dxen=3Ddisabled ;; + --enable-xen-legacy-backends) printf "%s" -Dxen-legacy-backends=3Denab= led ;; + --disable-xen-legacy-backends) printf "%s" -Dxen-legacy-backends=3Ddis= abled ;; --enable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=3Denab= led ;; --disable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=3Ddis= abled ;; --enable-xkbcommon) printf "%s" -Dxkbcommon=3Denabled ;; --=20 2.42.0 From nobody Wed Nov 27 02:23:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1700868375; cv=pass; d=zohomail.com; s=zohoarc; b=kKFVpSVsVHU9thhyXo8UVjazIdNfNBlxe/hDbDA48chHQAzPb843ioWoV0gYP2EGKFmvE9kKmrKHXFt9PCiKkYSNAY90uQ0ZkRAhTjF4nYMfIAkrHiGRssnkbeAsvNhqQMk6zBiodFztTVWqmaNA8IQDr7ulFuIbSle9Vlr6I30= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700868375; h=Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=602dKa1VR8fPvQHqtVLjjZVu2RbSyKF63LAUWSpxQ3M=; b=OjMOVNIXiolQ8F4MJHLgSBfJ70/xXPEjBx8HbYySf5Wa7/F210wWd3x6exFD+/xvLdIakqGZoM5SFsaI9cnVWxoLvB1JQbj9VgwErCusl6I5Bwm8cYxQX7WvsfJbIZTwBespTTIEmZwtEY8FRZ10wOFUv2i1Gl8i8CEkrgfDiEI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700868375274850.2744641001726; Fri, 24 Nov 2023 15:26:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6fXL-00039C-5q; Fri, 24 Nov 2023 18:24:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6fXJ-00038e-K9; Fri, 24 Nov 2023 18:24:37 -0500 Received: from mx0b-0039f301.pphosted.com ([148.163.137.242]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6fXI-0003dN-05; Fri, 24 Nov 2023 18:24:37 -0500 Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOMwAPK014042; Fri, 24 Nov 2023 23:24:29 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uk2wmr6b0-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 23:24:29 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8551.eurprd03.prod.outlook.com (2603:10a6:10:3e2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Fri, 24 Nov 2023 23:24:24 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7025.022; Fri, 24 Nov 2023 23:24:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8iqL1p9hM7JDy2vjcS3+1q4pA+KmyXHAtyotsorzKcIDmP0ob6nfvSX98zid0DvMR7l3y99NX8mOLLl3E6SofGhenTPj4Nq++3yGMttJ6TKvg+aBaXu7G+qT6TDR9c/xQPQaO7RnxJY211ZdPehy7emA8sBir+Jdk53GWOSaCDfSeIIEERvfaM05moYKoqEu4PRMnVsO/oxyr8jPGNVBjFf23yK3BcqdDpthtOMfqEax8lnMFEG1Qvzbu1Ou1cyCp1BndSb57n0h4K6yAZxIGfUKe2aYD1KxkRBDPaY3RYalU7wBf0Q8ObbdRf+v5fN9S1zQEDkDtZxUB59DkVIZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=602dKa1VR8fPvQHqtVLjjZVu2RbSyKF63LAUWSpxQ3M=; b=f3noakK5BBcEGsFSEA4/mYkq28nqi+1gu/pWV3cW4jkG4J+2SGwE02wsHbkp77/8iOH70KkJd32iDQYl7Rcp8DnTc3BTpmyg3ovgiubT3dzhRUZUDxXtaXik21cb//uemCkw1VI8SIjDozKIFQqUUha+h49QUhHMAY8XMtOjUt8QwFqllVhkjmbydEZI2gY77Y+qYkH7v0A1NxrnTAUMfhh9GCMflwbO2WnBYKFTe2o5GLMz5zTEDSKt3WH5hBbtJlzVOD9fBI7eTdEUKaEdYQC0/esY3ZysGsSGGyXbkEb7Jh1tihmrq4f2bWT18Fucpq8s1AXRiYSUDA+yRcJNOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=602dKa1VR8fPvQHqtVLjjZVu2RbSyKF63LAUWSpxQ3M=; b=VPagikpJskYrT0a3uKTUr3+4rPtVZIGg8v1bTdj2NahSnqbUbqcrPLbpuZFj2uJOmvR/06Yi89vGgT1u5EDyymtoWS+tM5NIE/X+Gv1X5hjLofM8R/MXueedBat4KFXyEiz3Czo3YM7nSnuix5j/vxKw9qlKa8TyF+c4oWMcjDCtKCEfTszBe77od5W2MyFXzoNU8x4zDqzA1fRAVlOfXRTmPPwt6aObNN1vaUwy3d+Y0qd1fudcoPfYuzRb2tt5nyyEUb0sLvFEJPJufaDh/C3WFWOyycZeoQAfQ/dxuiYlco8sTFTTg3So7VNCpgpQ5Yp/hcyIkoIDtlB9w3C7uQ== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Oleksandr Tyshchenko , Volodymyr Babchuk , =?utf-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= , Peter Maydell , "open list:ARM TCG CPUs" Subject: [PATCH v3 4/5] xen_arm: set mc->max_cpus to GUEST_MAX_VCPUS Thread-Topic: [PATCH v3 4/5] xen_arm: set mc->max_cpus to GUEST_MAX_VCPUS Thread-Index: AQHaHy1bXZxItaI7lEWj7O2d5pS3Rw== Date: Fri, 24 Nov 2023 23:24:23 +0000 Message-ID: <20231124232400.943580-5-volodymyr_babchuk@epam.com> References: <20231124232400.943580-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231124232400.943580-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DU0PR03MB8551:EE_ x-ms-office365-filtering-correlation-id: 0abb95d0-583f-42ef-b57a-08dbed447eaa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wV+C2ZR05VHyKijt+4qVUF8aa+iE89gLOX4tmsASRtMPT+0Nz8wS9qJTZ+aXj6jOhMFYSy+qO3FmEq+b5iXH88fmE2v7he8IcZsZZf9cwPbG/L/rtL28XjhniMm2p2XQPkIcAxKZPGzod7Qc1+xb/BCAhQySb6GIHh6EZHEUZTdlW8uKfk4wx0ee8hy/r4RX+6Lo5QkJPphxaC8PZmowkN94tm+rfMpNYCS2e1TAqq+D2RDFwaecSlr3lEIJs8U83FvIe0yoeeSlUJDfBKYoW66aIgBnijByUf3qUWAM58QQ4bOJOUvZr+ud4gqkLMLxe4zsUstsnkZ0Cu2QcBIA9SYRvzqSCtEO6MPnFzDzjcSsJ8MlSQxlCkW7mqdXiRhTOUFkVjaTsjwBxItjDu1GGVr0ZNVFbn28xDNO/itxDbGG3UL75R1J4S7QIM0nAutbrPY8eEGMP5e21IHjBIesaUYnoPjR0MpRrsqJqHJvzhgMlIk0DMfbii870Sjt8VTLBbMyNbTyKpvpGdnDSDx9fhN8A9i1qgbuE3tDekNczNc7l/nwj0PdgSsOUprZBlMvlafaQDLAkozBNDu6uVEMP8dEC5VE6GUGZuaacsrj9/Pcqi8a6PeZpWrVz/M0Zeh5 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR03MB3710.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(346002)(366004)(136003)(376002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(38100700002)(1076003)(6512007)(83380400001)(2616005)(6506007)(55236004)(71200400001)(41300700001)(8676002)(4326008)(5660300002)(8936002)(26005)(478600001)(6486002)(2906002)(6916009)(316002)(91956017)(66476007)(66446008)(54906003)(64756008)(76116006)(66946007)(66556008)(86362001)(122000001)(36756003)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?B?eVFKVjFMYnpidDMyT0IyNm5RK0xIUnkydldSVFhxMmlxLzN3RjZPanVCRFRV?= =?utf-8?B?TGtVcS9xY2dOTTBmeDZ2RElRcXRobXlXcitRWXhhZ3dLZ2V0TW5TeVRnaDVL?= =?utf-8?B?S09HYWJsYnBaNlc5S2llRDJQY1RxUExjcTJNcWZJRS9oSzYxejVDVFZrNHUv?= =?utf-8?B?dlVabzdHTmVOaUFHekk5ekJzdDhodGYvMHI3a2E3b0JPUXFEMndUZHhHOEJ1?= =?utf-8?B?ckhKejlGM0cxY21oQTJBUnFmMzE3VDNuaWs5RFhhVHJUcVNIdGdTeVd0SWdQ?= =?utf-8?B?SDY5YmJZVllUNlFmZUxPUlpYcWhlNUNuMi9zMG4yV0JpY1lqS29DUndtZGd0?= =?utf-8?B?MkRuS3BxSlZvRGI5NkxYQXAyaGo4N0krcjEyOE9GOUhyai9NZzMrV3lodGRM?= =?utf-8?B?bHFxaFYvTUkvSHhaclBrTGpWNGFQL3JHbUpIbVdjck9LVDAvUGorclcxV3ZU?= =?utf-8?B?TzFEYkZzcG1aNExNV3pTaHpsd0E0Y0V3WUVCdTZ2b3k0TUNKaHhaMjFPcEsz?= =?utf-8?B?SzF0Q3lPNldOMXBDcmtnWUFxVGFSQ2hSb1ROSGZ4R0lLR2xBaFZKbkUrWGxR?= =?utf-8?B?ZDdPVjBpU1NCVFlBWUpYK1creUpRUE1WaTVYTkpwQnM1V2RSRldSbGxVU3pI?= =?utf-8?B?TmNjcWhJVVE2d1BIRUtabVc2bU1hZ0gvc2VUMTFrREo4TW82M2srdi84Ykt5?= =?utf-8?B?aGwrUmwwVWo3byt1amlKQ2lzU1QxMkNWd3dvRjNydExsMDBPd1ZFZnN6WkVh?= =?utf-8?B?TFBBL0xqYWplT3U0KzJHUU1ZSWRmREV2SHRmTWNqbG9ycHRtUGRFeUFtb1Nu?= =?utf-8?B?SXJ6dHhPRUR3V0IyK1lvT1V1UXd0Q0hBR2FEYVpQSjhiR2RjeXIzTDJUa3o1?= =?utf-8?B?K1pHaGx5NElrNGFHay9BRzE0cTdsODJyaXZWZFVPS0t0M2JwRVdUMjd4NGJN?= =?utf-8?B?M2xTV0NHSEtuVHIrYU1wRGxiWERXaUo3d1NxRW4zdTFuMHBoRmJHazNkZzVS?= =?utf-8?B?TUs4QTM1aUpDZkkvVkFrVVZIM2tuUVRCaGdHWXFKS0tJQlVvZC9SOFM3WXA1?= =?utf-8?B?ZW1nRHU3RnhjQktUTUdHVXUxKzZOcnlSMjYyWGhYTVBVamljNVk4eStvSzRZ?= =?utf-8?B?Z0hiVkVsUGR3MXBqTFA5OFZvK3J1Z29EQUNZZzMySFpVcHJOR0FvVHhpaEx0?= =?utf-8?B?QkxFcWhLbUtudU1RRFIzeU1vcXY1VVJZSTh1SkhaRldIdXBnU2hWZW8xNnUz?= =?utf-8?B?VkJNSUlTZnFrbS9Dd3hoWUVwRzZpcjM5QnY1S1hNMjZOR2lJY3RhcEdBOUYv?= =?utf-8?B?eVdIN0RXb3FRWjM3R25mWUpoMWV0VForUVVwdXhET1l3Vnc3Y0F6N3RBYVR3?= =?utf-8?B?ekRyVEhLYjBSM2g4MXZEL2VyOFhIeXcxV1ZGU0l6cTNUcFBDWWl2QmJUYmQ3?= =?utf-8?B?TTdTUjNGRnIvaVhCT0xGanNOYnVKSko2bHZsVVIwTGI5VVoyRExNWjA2M1Js?= =?utf-8?B?cHloblh4cjNYRGt0dFFRWFdDN1d4VHgvdmFuVExyY2pSYWVtakc2WWYvWm16?= =?utf-8?B?WkxLM1RidVhuems5a0FLbWo4OEFtYkFhemkrZWNUQzdNdjJPRGVGWWYzTVdk?= =?utf-8?B?aHM1ejdsTXQyMGhFQXBhNUxXdFM2V01GQ1E1U2QxQUVnUzZ1SE9tMXFkTy95?= =?utf-8?B?UHM0OVIvZVp1Y1R4bGhiS1ZkZnlDY1pZUmZ1dHd4RnM0aWpGYlN6b2tPWkM4?= =?utf-8?B?SnluNzZRU0pBSEZyYjA0dHF2YUMyNTRnQWNkaFNSclN4WndRazNGQVJFcGFj?= =?utf-8?B?ajJoNDJjTEd2YW54QVNKWjBkOTl1cUdLcGovSmFqSVZTMCtCRDhiK2xjdTJR?= =?utf-8?B?SnNDbi9qc21OWVR6SDFiR21RL0xWN0J4V0FDZGRpQVpjM1ppSzBaNEVydE1v?= =?utf-8?B?MzdPWmx1ZlNHcXlueVRPRkFUYzY3ZkZLZmV6NFloTUxPaTBicEtjMFdRb3Aw?= =?utf-8?B?MFc0eFZkb2o0Z2lBYUhtb244a2VhMWY1elV0dDFyRWVMRTRrQk1oOS8vYW1t?= =?utf-8?B?L0E4WmRINzVMLzdKRi9HQnlPekJLWnFGSTlmaDV2U3V4M0JmV0QyTndwcVN3?= =?utf-8?B?YjViNGd2ZDhzS25SVzF5VS9PSE9QL2FLRHlxVUZaSkNKb3RGVVM2dXRZcWdo?= =?utf-8?B?d0E9PQ==?= Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0abb95d0-583f-42ef-b57a-08dbed447eaa X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2023 23:24:23.2961 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QSgrPViEY6YWF14a4pkIINtrXTP8B5lDYZPKwo/6VSzP5c6qyHyP7I3fqvS+u+biAsZ/+oFhTQkejFCkbSWObCTecV6OAe2akeUrNk4d8xA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8551 X-Proofpoint-GUID: wlrvwSBVyXrZHTBAcyzmz3LHI6wiypTr X-Proofpoint-ORIG-GUID: wlrvwSBVyXrZHTBAcyzmz3LHI6wiypTr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-24_09,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240182 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.137.242; envelope-from=prvs=569229df20=volodymyr_babchuk@epam.com; helo=mx0b-0039f301.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700868376595100001 From: Oleksandr Tyshchenko The number of vCPUs used for the IOREQ configuration (machine->smp.cpus) should really match the system value as for each vCPU we setup a dedicated evtchn for the communication with Xen at the runtime. This is needed for the IOREQ to be properly configured and work if the involved domain has more than one vCPU assigned. Set the number of current supported guest vCPUs here (128) which is defined in public header arch-arm.h. So when the toolstack pass max_vcpus using "-smp" arg, machine creation will not fail. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Volodymyr Babchuk Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/xen_arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index a5631529d0..b9c3ae14b6 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -231,7 +231,7 @@ static void xen_arm_machine_class_init(ObjectClass *oc,= void *data) MachineClass *mc =3D MACHINE_CLASS(oc); mc->desc =3D "Xen Para-virtualized PC"; mc->init =3D xen_arm_init; - mc->max_cpus =3D 1; + mc->max_cpus =3D GUEST_MAX_VCPUS; mc->default_machine_opts =3D "accel=3Dxen"; /* Set explicitly here to make sure that real ram_size is passed */ mc->default_ram_size =3D 0; --=20 2.42.0 From nobody Wed Nov 27 02:23:36 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1700868308; cv=pass; d=zohomail.com; s=zohoarc; b=Zof9BXm3Pn3gvgfIR8ueYuo+wojmpdiosF1At4IEpniUr85cBEFPLJiddM/6eV8HYl8n7xyT0AjDDG54/kJJceE78RFRrKCWRnmeb6oEgQDGWb33vpf+/ap5JwKEVOa/uf8+TpTpQbuKRj1IXbrmj0ixYIsCki4bx7bsqUqYe54= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700868308; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=D1sE3o7/1/WPykkUQrLgvygBnr35JJ7+xArB8a3+h6c=; b=C1c6zC/LBi1W0PnvfRaKb3UgxBjE8CWTW7IlJvhx7JKMk3OUwTtbQBmJNGBfwmrr9N4t86QpHsKQdu+Zyl7xvFHlnw+HVVR25pRnUT/6pg/iy9jpcBDBRFGoXSYNXa2VRCvlq/h63cnluwBX+wcSkxlkm36X3cq+QknsXRCpXig= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1700868308192924.3625020927861; Fri, 24 Nov 2023 15:25:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.640984.999797 (Exim 4.92) (envelope-from ) id 1r6fXM-0001js-JX; Fri, 24 Nov 2023 23:24:40 +0000 Received: by outflank-mailman (output) from mailman id 640984.999797; Fri, 24 Nov 2023 23:24:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXM-0001hJ-CH; Fri, 24 Nov 2023 23:24:40 +0000 Received: by outflank-mailman (input) for mailman id 640984; Fri, 24 Nov 2023 23:24:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6fXL-0001Rw-AY for xen-devel@lists.xenproject.org; Fri, 24 Nov 2023 23:24:39 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a1ddba27-8b20-11ee-98e2-6d05b1d4d9a1; Sat, 25 Nov 2023 00:24:37 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOMwAPN014042; Fri, 24 Nov 2023 23:24:31 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uk2wmr6b0-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 23:24:31 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8551.eurprd03.prod.outlook.com (2603:10a6:10:3e2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Fri, 24 Nov 2023 23:24:24 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7025.022; Fri, 24 Nov 2023 23:24:24 +0000 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: a1ddba27-8b20-11ee-98e2-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N5VkXAhLS1mC99Iq0T0NI3IIk8YiTMTNW7pmF+nOP677+Dr2gVnQcvhDXr7Zq9YRVCl2RgEjbf32VdHVx0jdtLVfG6Ug74rEbooZT0AQckFeBJE/0dd6G5HpYTGjvdpNt44TtlORQufKPibOqUsXoZBkAT9yy0WLjy78ykkE1sHWKd1YnFskvseOBjra18N1b96gAjpeR8HneYXdxoUiA7blJu6tgKucY1v/4r9SQWdn+X3zbbu6OjAgplYN002KLbE2pQUev+s+8vOcs4b9/R3uet71yFX8zCvRjfUbbdVrORwy+2BXp3INyhzWxMDzMcN4zvMNCUn7VRWOMJl1Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D1sE3o7/1/WPykkUQrLgvygBnr35JJ7+xArB8a3+h6c=; b=huE7CyX2ZEIq5Kf7JISLh6KglMfgR/pe1o1vGP6D6Zjkhl0rCcPbXlnb84Ycr/Fp+9XzkyvTjkOc6jhyJ8kpQ/88xV6RDNpPjdxbreVsvAx2bZXSS7Q2qk09/XgBFjSDsTzBr4VVKs+C1MDKg0t1lTmBePcqQ6c4kukYJQkQC2+x0+7Vc8iZt3Id200m3Vc6futN8G4Y3zDOBj4C9Xov3rioJ1hchxUXeNDF0wM7OmLmcN9zD5qRoWBvpA9EFsi21EqPEtk6Tvz2jmTRy6MSOIr8xEg000JnRds7RgvDp5460N1/QKy7tYZ9t2JCrlKXy61CJ7CwKqxEHYz42ex7gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D1sE3o7/1/WPykkUQrLgvygBnr35JJ7+xArB8a3+h6c=; b=rfFnJzc4Sh9CHT4pWcaokKQnKCfjoIl2rJY5c2gI9qRcKoiVDybsSsaW73GFlANfODsBiHuqf3zi2AusIuWknkFauxflpAqh2URsyApqDvwih8/X8r3w3ycXuOm5dordQib9NP+gJ7bqFlSJZOzO7qLIDggb3s4mRVxKAVMXcdCx7gyJRAmLeXjI8eQHQbjqPs5WF07fszMnZfqh6qK2J+K3Ltk+YgCjEj7LWMQrIXfuV5JsU0TGkoO2ApXZ+Lk31dXTElR39mFnPKh+OjwnUqFOJEGNYc2bNBbb5d69lLffgxpaRbs4uhslRUrKpitu4W3vjvsfZ55WEIuWhrMqdw== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Oleksandr Tyshchenko , Volodymyr Babchuk , Peter Maydell , Anthony Perard , Paul Durrant , "open list:ARM TCG CPUs" , "open list:X86 Xen CPUs" Subject: [PATCH v3 5/5] xen_arm: Add virtual PCIe host bridge support Thread-Topic: [PATCH v3 5/5] xen_arm: Add virtual PCIe host bridge support Thread-Index: AQHaHy1b0mzAt+6ABEigm2G74/KugQ== Date: Fri, 24 Nov 2023 23:24:23 +0000 Message-ID: <20231124232400.943580-6-volodymyr_babchuk@epam.com> References: <20231124232400.943580-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231124232400.943580-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DU0PR03MB8551:EE_ x-ms-office365-filtering-correlation-id: 2624485c-5b2f-4db5-647a-08dbed447eda x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0dw3QvhJzIeRch7/T2ifhNUsO8E5XgmhR9UXKqTvfhi1rT9ValVr5Ja5GfKyMIS0t5w23MF2ZTABrjFAeP6nT7+SgZMx/Ya8hsNd6e2Wjz8iJe7TJyuiyRsdvgBRH8qLboX3NXg1QeTUxSrVARFsHWZvq30JV7DjFxEAIyO//EDBU+cOTkhpTx1lTTKnwpPZVxc8m0vYzf5O35zZqbWgEqtO/6uMCAER6/y5fm3vA+yLwhBg1h4ZQxve/p0ewUEF+eIxbuHXXxBNpLP7UA0gNznWN2gOHaoUJ+bBRum36B6Yx7varMPSOPlBB5wax988zGpKj1ULWsXFAMEHe4CUeTw7BEZQdlrthpipKanbEPM8n3VIo0/0Rgz/i9rOJeLv8xkFa50J3i8DV2DVY3Ddnw5LApRKPWvVO9aMQhCH0eAQo2Y2RsFk0aniPIQsOxLzkyWTLZs3QdWBTkrnXA01fK0EneOCrwYAT5dxENMcjOTlDat193Pe4Gs++RzHeCKH1SM5y9z4U3rV3J22tybOSPyRwEDp+2XaTa2eg1TnLC41yuL+Jrxo3z8YxRlVtDvZcetgAB5wILL51/ddRif2aXslJ7PCA9ew/aSdxhdbAHyiX7bu57HvZRdfpRj8ggI+ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(366004)(136003)(376002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(38100700002)(1076003)(6512007)(83380400001)(2616005)(6506007)(55236004)(71200400001)(41300700001)(8676002)(4326008)(5660300002)(8936002)(26005)(478600001)(6486002)(30864003)(2906002)(6916009)(316002)(91956017)(66476007)(66446008)(54906003)(64756008)(76116006)(66946007)(66556008)(86362001)(122000001)(36756003)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?nc651D1DQsrI1tXHu4/DrE5IVnTVih62bIweyETHOzZ+OKb6OpDiYQp5Zx?= =?iso-8859-1?Q?skHzHMx+0hGC95uOyVgZv1GquHewkfNKCQVov4qMckhD0W1yZraRj6OCjC?= =?iso-8859-1?Q?bDtS/RZrNsIqFxdxhQJaAoWZjODRCKMVJfYCP+iq5SSIshI0tgXfp8o5Ik?= =?iso-8859-1?Q?8WaQywi1Dli+xdMMYF4VoWfwPx4HbhwAhtbdacYBaS61bhvmeJHfoqjuiB?= =?iso-8859-1?Q?5IWAsVRwNJjLW9DihTy3sZjcg3XbHsOWxzQoFrkAynbfPnlmT0eA1XUSPY?= =?iso-8859-1?Q?ZB3b4hrQzbr3sh+H1V5W4BfUvFCe458oovQWBf0nGV9KWt2BuD0vpW24hZ?= =?iso-8859-1?Q?zuUg+tqeMwPlj3xaxj1W23Kedst0z5/up5iQJPmicBpDnXXM0rV3wrLkfX?= =?iso-8859-1?Q?loZutFWuQi9KtXum4MhVFmtTRRcC/Rql+Fo5lo+MYIQoOYnQ/gAx1vvX6c?= =?iso-8859-1?Q?ViK9uWc8fjhbDusV0HkwXIEEUT7yV/+bm2FnCBThqNSAdyKfqE140WZAfm?= =?iso-8859-1?Q?koNH86Zbf21GFRD8szn5U6jfUSNHifLBFH40pte+LeeUOEwA/aycEARd+S?= =?iso-8859-1?Q?HNnSd4y+xAEiFRf4H8vKcn3jogabV9hiGOyMQ+bPXsHzjaSkf6rRZuD9Dc?= =?iso-8859-1?Q?I37StdfCK1n9R35LbLcuQs8VByI/JhP1rzYdHUxzZ82XMrKNGR7qzEi3Rb?= =?iso-8859-1?Q?m6FxEMlShdMfR8vyoMlaxHnNUGSfRm2qE7orzmoS1N/gCeTsSZ8DpTJVCM?= =?iso-8859-1?Q?KLH+WDdqX+XqSLN7fbB9YNOF85foIKmOn5xai900IeKC0aUgN+xB28Steq?= =?iso-8859-1?Q?bsYg+pQS4hR1tEtjpQtvJfakvSJm0ukgfIAtJ2Tl2lFDPSj0KgqvKDSQAQ?= =?iso-8859-1?Q?3Lf2sLOQr1XN55v7TDdy4OJiOj3CHRldy3HDawPGsfsy7etsx/IhTd6OEn?= =?iso-8859-1?Q?xbdNoipbeNiQ7w7TCatXCRveptdkrN3sy+a/oyjuPOiS/g7A/bqFqNQavu?= =?iso-8859-1?Q?6BklwEkeehDFuc8USdxxeGI0RZnc01cLPZew/OImvc/n/TRQ6wuWMTmFg4?= =?iso-8859-1?Q?JX1+VMAcfDk1LN/vCRB7HiWL4j6iMnLXd1Rc6JGRnzYKfdfg17EocNurKJ?= =?iso-8859-1?Q?q2IVdWebmoewCh7flmE5PXDKX7Y+R4wqLzLjcKU1KPGvAWM+tV7VJ9w7N+?= =?iso-8859-1?Q?xRBGp3kYgAeYavgbd+9Gx87pU58J80UeeKlpz2unH0vRtJ1HloBMPlegxW?= =?iso-8859-1?Q?6mEiLPY3Byp+42cPUoFTJXl1qtJpBoHrxCPKeBvc/VTxNxUFUYb3Dd2tL9?= =?iso-8859-1?Q?ngNEXtLlD9fDecdcc/dHV+w+K+YjfL7LQbTdkIMoIAeseL5FsusoYWH28l?= =?iso-8859-1?Q?OOArVNvo0/HRayJfyho0ASNtur2Wb2R1xckfXD3CCHkyJ7JO6naOTCSpdq?= =?iso-8859-1?Q?ab1Iu8yTmHpugKdHnPLLuJ0hPVf2pOMX/AG0oaFvI2Jl6J9FM0c9ZZlQH6?= =?iso-8859-1?Q?Zkxn6hSOJmWOQmYa/0q2lpIevyKc985995HiSoB/uaWFJcsnrBTtF2yPKY?= =?iso-8859-1?Q?5X5pFUbJiKFg69lrEO1LRHY2c4UycokjI1BK7ol8vlvqxfv6nBJDYqi+m/?= =?iso-8859-1?Q?zGLGaTw3wzzxH85lHvYepCSWCTmL/4LiQkR0CfxFxG6GZbWuayei0GaA?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2624485c-5b2f-4db5-647a-08dbed447eda X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2023 23:24:23.7566 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3VCbrezFxuhWwkrIzUou/D+DEh5gK8wwvmULD316tIvxCmOdQ+BrReAnns9YNlDGUi5O2qIfHdMlpdWAJJoUGf9367lrJWV+CuKagPpg8fY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8551 X-Proofpoint-GUID: IuhptZD8j7yZJTKtZiqN36M2VDN9hsRh X-Proofpoint-ORIG-GUID: IuhptZD8j7yZJTKtZiqN36M2VDN9hsRh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-24_09,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240182 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700868309348100003 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko The bridge is needed for virtio-pci support, as QEMU can emulate the whole bridge with any virtio-pci devices connected to it. This patch provides a flexible way to configure PCIe bridge resources using QEMU machine properties. We made this for several reasons: - We don't want to clash with vPCI devices, so we need information from Xen toolstack on which PCI bus to use. - The guest memory layout that describes these resources is not stable and may vary between guests, so we cannot rely on static resources to be always the same for both ends. - Also the device-models which run in different domains and serve virtio-pci devices for the same guest should use different host bridge resources for Xen to distinguish. The rule for the guest device-tree generation is one PCI host bridge per backend domain. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Volodymyr Babchuk --- Changes in v3: - Use QOM properties instead of reading from XenStore - Remove unneeded includes - Move pcie_* fields into "struct cfg" Changes in v2: - Renamed virtio_pci_host to pcie_host entries in XenStore, because there is nothing specific to virtio-pci: any PCI device can be emulated via this newly created bridge. --- hw/arm/xen_arm.c | 226 ++++++++++++++++++++++++++++++++++++ hw/xen/xen-hvm-common.c | 9 +- include/hw/xen/xen_native.h | 8 +- 3 files changed, 240 insertions(+), 3 deletions(-) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index b9c3ae14b6..dc6d3a1d82 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -34,6 +34,7 @@ #include "hw/xen/xen-hvm-common.h" #include "sysemu/tpm.h" #include "hw/xen/arch_hvm.h" +#include "hw/pci-host/gpex.h" =20 #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) @@ -57,6 +58,10 @@ struct XenArmState { =20 struct { uint64_t tpm_base_addr; + MemMapEntry pcie_mmio; + MemMapEntry pcie_ecam; + MemMapEntry pcie_mmio_high; + int pcie_irq_base; } cfg; }; =20 @@ -73,6 +78,15 @@ static MemoryRegion ram_lo, ram_hi; #define NR_VIRTIO_MMIO_DEVICES \ (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) =20 +#define XEN_ARM_PCIE_ECAM_BASE "pcie-ecam-base" +#define XEN_ARM_PCIE_ECAM_SIZE "pcie-ecam-size" +#define XEN_ARM_PCIE_MEM_BASE "pcie-mem-base" +#define XEN_ARM_PCIE_MEM_SIZE "pcie-mem-size" +#define XEN_ARM_PCIE_PREFETCH_BASE "pcie-prefetch-mem-base" +#define XEN_ARM_PCIE_PREFETCH_SIZE "pcie-prefetch-mem-size" +#define XEN_ARM_PCIE_IRQ_BASE "pcie-irq-base" + +/* TODO It should be xendevicemodel_set_pci_intx_level() for PCI interrupt= s. */ static void xen_set_irq(void *opaque, int irq, int level) { if (xendevicemodel_set_irq_level(xen_dmod, xen_domid, irq, level)) { @@ -129,6 +143,89 @@ static void xen_init_ram(MachineState *machine) } } =20 +static bool xen_validate_pcie_config(XenArmState *xam) +{ + if (xam->cfg.pcie_ecam.base =3D=3D 0 && + xam->cfg.pcie_ecam.size =3D=3D 0 && + xam->cfg.pcie_mmio.base =3D=3D 0 && + xam->cfg.pcie_mmio.size =3D=3D 0 && + xam->cfg.pcie_mmio_high.base =3D=3D 0 && + xam->cfg.pcie_mmio_high.size =3D=3D 0 && + xam->cfg.pcie_irq_base =3D=3D 0) { + + /* It's okay, user just don't want PCIe brige */ + + return false; + } + + if (xam->cfg.pcie_ecam.base =3D=3D 0 || + xam->cfg.pcie_ecam.size =3D=3D 0 || + xam->cfg.pcie_mmio.base =3D=3D 0 || + xam->cfg.pcie_mmio.size =3D=3D 0 || + xam->cfg.pcie_mmio_high.base =3D=3D 0 || + xam->cfg.pcie_mmio_high.size =3D=3D 0 || + xam->cfg.pcie_irq_base =3D=3D 0) { + + /* User provided some PCIe options, but not all of them */ + + error_printf("Incomplete PCIe bridge configuration\n"); + + exit(1); + } + + return true; +} + +static void xen_create_pcie(XenArmState *xam) +{ + MemoryRegion *mmio_alias, *mmio_alias_high, *mmio_reg; + MemoryRegion *ecam_alias, *ecam_reg; + DeviceState *dev; + int i; + + dev =3D qdev_new(TYPE_GPEX_HOST); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + /* Map ECAM space */ + ecam_alias =3D g_new0(MemoryRegion, 1); + ecam_reg =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); + memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam", + ecam_reg, 0, xam->cfg.pcie_ecam.size); + memory_region_add_subregion(get_system_memory(), xam->cfg.pcie_ecam.ba= se, + ecam_alias); + + /* Map the MMIO space */ + mmio_alias =3D g_new0(MemoryRegion, 1); + mmio_reg =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); + memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio", + mmio_reg, + xam->cfg.pcie_mmio.base, + xam->cfg.pcie_mmio.size); + memory_region_add_subregion(get_system_memory(), xam->cfg.pcie_mmio.ba= se, + mmio_alias); + + /* Map the MMIO_HIGH space */ + mmio_alias_high =3D g_new0(MemoryRegion, 1); + memory_region_init_alias(mmio_alias_high, OBJECT(dev), "pcie-mmio-high= ", + mmio_reg, + xam->cfg.pcie_mmio_high.base, + xam->cfg.pcie_mmio_high.size); + memory_region_add_subregion(get_system_memory(), + xam->cfg.pcie_mmio_high.base, + mmio_alias_high); + + /* Legacy PCI interrupts (#INTA - #INTD) */ + for (i =3D 0; i < GPEX_NUM_IRQS; i++) { + qemu_irq irq =3D qemu_allocate_irq(xen_set_irq, NULL, + xam->cfg.pcie_irq_base + i); + + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); + gpex_set_irq_num(GPEX_HOST(dev), i, xam->cfg.pcie_irq_base + i); + } + + DPRINTF("Created PCIe host bridge\n"); +} + void arch_handle_ioreq(XenIOState *state, ioreq_t *req) { hw_error("Invalid ioreq type 0x%x\n", req->type); @@ -189,6 +286,12 @@ static void xen_arm_init(MachineState *machine) xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener= ); =20 xen_create_virtio_mmio_devices(xam); + if (xen_validate_pcie_config(xam)) { + xen_create_pcie(xam); + } else { + DPRINTF("PCIe host bridge is not configured," + " only virtio-mmio can be used\n"); + } =20 #ifdef CONFIG_TPM if (xam->cfg.tpm_base_addr) { @@ -225,6 +328,90 @@ static void xen_arm_set_tpm_base_addr(Object *obj, Vis= itor *v, } #endif =20 +static void xen_arm_get_pcie_prop(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam =3D XEN_ARM(obj); + hwaddr *target; + + if (!strcmp(name, XEN_ARM_PCIE_ECAM_BASE)) { + target =3D &xam->cfg.pcie_ecam.base; + } else if (!strcmp(name, XEN_ARM_PCIE_ECAM_SIZE)) { + target =3D &xam->cfg.pcie_ecam.size; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_BASE)) { + target =3D &xam->cfg.pcie_mmio.base; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_SIZE)) { + target =3D &xam->cfg.pcie_mmio.size; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_BASE)) { + target =3D &xam->cfg.pcie_mmio_high.base; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_SIZE)) { + target =3D &xam->cfg.pcie_mmio_high.size; + } else { + /* Unreachable */ + assert(false); + return; + } + + visit_type_uint64(v, name, target, errp); +} + +static void xen_arm_set_pcie_prop(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam =3D XEN_ARM(obj); + uint64_t value; + hwaddr *target; + + if (!strcmp(name, XEN_ARM_PCIE_ECAM_BASE)) { + target =3D &xam->cfg.pcie_ecam.base; + } else if (!strcmp(name, XEN_ARM_PCIE_ECAM_SIZE)) { + target =3D &xam->cfg.pcie_ecam.size; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_BASE)) { + target =3D &xam->cfg.pcie_mmio.base; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_SIZE)) { + target =3D &xam->cfg.pcie_mmio.size; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_BASE)) { + target =3D &xam->cfg.pcie_mmio_high.base; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_SIZE)) { + target =3D &xam->cfg.pcie_mmio_high.size; + } else { + /* Unreachable */ + assert(false); + return; + } + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + *target =3D value; +} + +static void xen_arm_get_pcie_irq_base(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam =3D XEN_ARM(obj); + int64_t value =3D xam->cfg.pcie_irq_base; + + visit_type_int(v, name, &value, errp); +} + +static void xen_arm_set_pcie_irq_base(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam =3D XEN_ARM(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + xam->cfg.pcie_irq_base =3D value; +} + static void xen_arm_machine_class_init(ObjectClass *oc, void *data) { =20 @@ -246,6 +433,45 @@ static void xen_arm_machine_class_init(ObjectClass *oc= , void *data) =20 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); #endif + + object_class_property_add(oc, XEN_ARM_PCIE_ECAM_BASE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_ECAM_BASE, + "Base address for ECAM range of virtual PCIe host bridge"); + object_class_property_add(oc, XEN_ARM_PCIE_ECAM_SIZE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_ECAM_SIZE, + "Size of ECAM range of virtual PCIe host bridge"); + + object_class_property_add(oc, XEN_ARM_PCIE_MEM_BASE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_MEM_BASE, + "Base address for non-prefetchable memory of virtual PCIe host bri= dge"); + object_class_property_add(oc, XEN_ARM_PCIE_MEM_SIZE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_MEM_SIZE, + "Size of non-prefetchable memory of virtual PCIe host bridge"); + + object_class_property_add(oc, XEN_ARM_PCIE_PREFETCH_BASE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_PREFETCH_BASE, + "Base address for prefetchable memory of virtual PCIe host bridge"= ); + object_class_property_add(oc, XEN_ARM_PCIE_PREFETCH_SIZE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_PREFETCH_SIZE, + "Size of prefetchable memory of virtual PCIe host bridge"); + + object_class_property_add(oc, XEN_ARM_PCIE_IRQ_BASE, "int", + xen_arm_get_pcie_irq_base, + xen_arm_set_pcie_irq_base, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_IRQ_BASE, + "Number of first PCI legacy interrupt for PCIe host bridge"); } =20 static const TypeInfo xen_arm_machine_type =3D { diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 2e7897dbd2..19fcccdb16 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -47,6 +47,8 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, = MemoryRegion *mr, g_free(pfn_list); } =20 +uint16_t xen_pci_segment; + static void xen_set_memory(struct MemoryListener *listener, MemoryRegionSection *section, bool add) @@ -382,7 +384,12 @@ static void cpu_ioreq_config(XenIOState *state, ioreq_= t *req) } =20 QLIST_FOREACH(xendev, &state->dev_list, entry) { - if (xendev->sbdf !=3D sbdf) { + /* + * As we append xen_pci_segment just before forming dm_op in + * xen_map_pcidev() we need to check with appended xen_pci_segment + * here as well. + */ + if ((xendev->sbdf | (xen_pci_segment << 16)) !=3D sbdf) { continue; } =20 diff --git a/include/hw/xen/xen_native.h b/include/hw/xen/xen_native.h index 6f09c48823..2b1debaff4 100644 --- a/include/hw/xen/xen_native.h +++ b/include/hw/xen/xen_native.h @@ -431,6 +431,8 @@ static inline void xen_unmap_io_section(domid_t dom, 0, start_addr, end_add= r); } =20 +extern uint16_t xen_pci_segment; + static inline void xen_map_pcidev(domid_t dom, ioservid_t ioservid, PCIDevice *pci_dev) @@ -441,7 +443,8 @@ static inline void xen_map_pcidev(domid_t dom, =20 trace_xen_map_pcidev(ioservid, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn= )); - xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, 0, + xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, + xen_pci_segment, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)); @@ -457,7 +460,8 @@ static inline void xen_unmap_pcidev(domid_t dom, =20 trace_xen_unmap_pcidev(ioservid, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->dev= fn)); - xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid,= 0, + xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid, + xen_pci_segment, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)= ); --=20 2.42.0