From nobody Wed Nov 27 04:47:46 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=1700604659; cv=pass; d=zohomail.com; s=zohoarc; b=XWT1QL6z+Xr/1bWdPnuM1eNVxISspM9YTream1H22r1WAeDkpAjgrfk+B2q9e2k7nVOW0Km06N7SREpl14POi5/c34jtmVrLZwyNlbJ+yKnYsZKy327FXxK1ZIFhdZc9cwJDSgm688LDXI8Vinki7JXggOFZ3/VOxTyj7d8yEhM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604659; 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=YErD+LGkHLSIfKpC2tq04iqgbrsR/yANlnnAZGoF1mU=; b=BXLCwUlzXpS/P7LR71bgBs2QdakMQLfP8A5/7i893RkdJS6afW63hMcl84CYh3c32PzMnpkIfCpF2chBPqYPPsYoKAYZMfEFsD1HMXx0vdRYUThRunctALSqLICxPz8Gsqs/MbLZUutQaNu1cNMnbf//gYLaVqrISy4+0bbPCb0= 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 170060465901063.52623161094198; Tue, 21 Nov 2023 14:10:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.638302.994722 (Exim 4.92) (envelope-from ) id 1r5Yx8-0006Yl-84; Tue, 21 Nov 2023 22:10:42 +0000 Received: by outflank-mailman (output) from mailman id 638302.994722; Tue, 21 Nov 2023 22:10:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5Yx8-0006YV-5X; Tue, 21 Nov 2023 22:10:42 +0000 Received: by outflank-mailman (input) for mailman id 638302; Tue, 21 Nov 2023 22:10:40 +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 1r5Yx6-0006PS-PB for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 22:10:40 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cd2f4c23-88ba-11ee-98e1-6d05b1d4d9a1; Tue, 21 Nov 2023 23:10:39 +0100 (CET) Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1A031085; Tue, 21 Nov 2023 22:10:32 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:32 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:27 +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.7002.028; Tue, 21 Nov 2023 22:10:27 +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: cd2f4c23-88ba-11ee-98e1-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HByi4MtSScepWAnhzE8y+/4h0THflXulvTUFJqhAD+QSqN5zxAPOkl84Q/BkmjmQAKXN63K5LsYmfYlFqdCwSycK/QtRzTM8ZJV7/bUlXtiU87HNNJJ3dQUJy67rXh3KcxljQvmyVG0eWevis4xKDBysIC+W9Qamf1WvXkRnQnqiO5yAeaUht3AkASL64mNQWAfZgw5L9kVV6MvVVcRp6PdDM/Yp6La/Knmq5zbwJ7bu3iZhzgrGnzhMXV2QtHNoibRnh+c8uMCZnoyrNCqU0W3/GNakCREwPZ7rne6IR3DoNS/7ZfSyvH4Y2Dn0dhnEfwdb2JB3TG4W5FMraZ5PUw== 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=YErD+LGkHLSIfKpC2tq04iqgbrsR/yANlnnAZGoF1mU=; b=eN1PHoRE375H63c7Wsn8OtvDFl0XpEpT9ERhCx5Diohmcg2C6CmOwdRrjWBzfaP2GwOxx/ZDSgeMOaeeiFYxyrpMy+r7WsF4e/JdQ7WSS3tkuWsnLb2gQi0LrUorSYqFQOfgF+fNy6kOWfo9RcK2rGJ9uVSHfG6jzs6/96q+BLv1dMRj2TN9R8CWBFDcbAuBeZz4/3rU+I3MKI2aFNjedeaM4d6q58XtQhJ6o/TF8D2eEzDRcJ/M/hgmWnT248+AMmFlFmG4lYELSvGCwTL6CXefPVegIW/QnBThGz+dz/bdnOShPYswpzUgf8QHGM16lFLpCVWIMPIS6fnsR/1OGQ== 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=YErD+LGkHLSIfKpC2tq04iqgbrsR/yANlnnAZGoF1mU=; b=VkyrI6wPK2QBU/CpfXJUHHX6hFOg8xP8DREfZHfPhW7d9y/u47oWr2er43qSCWqemmnPNfWDWn5X60ykBt7KuCXhD46Rvou6fSHdzXp88i1IlU7IRYUcgUGGH10nOmobycqR+KnMZ2Ox7SYbEfOzsKVnTPdyOf9Hcjqe/G6n9NNcZfkAs9tbiW7fQO0wEJbpmqmcKZJDha0RCW1AQZdZc4Tt+hUfXCPjjuaiZhJCX5vFwovZWKifLfve6AKjl4jGMq34n4bhuLK2EfFULwoYSCVpSNUoMJuaeFtzQ6pK5PwdgzveVDEoFco4FouOs5Qdzu9lFYfqQCyJYLUTFBMrTA== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , 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 v2 1/6] hw/xen: Set XenBackendInstance in the XenDevice before realizing it Thread-Topic: [PATCH v2 1/6] hw/xen: Set XenBackendInstance in the XenDevice before realizing it Thread-Index: AQHaHMeI32LlpkxN1EiN6kyRHznaJg== Date: Tue, 21 Nov 2023 22:10:26 +0000 Message-ID: <20231121221023.419901-2-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-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_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: 31116187-0174-41d9-844a-08dbeadeab25 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1sL4Mkp3NnUFobtaE2EhfIOQQtT8YyOfGOTpmqFqIajGEeZSSlHpc2ItNIjyhri+WsNtmIRySM5SB1JfMdrLV6b5oWUq287YtEywmON8FurewElTrcv2RTjYTyW8cKl8erW4auG/YasfByrDpJqR3YdX82+6ZqCA0NnaHqYcgr/+HtoYGN0tvaVxvNPsIrQBi56CDbsLPtdcn4KS507nfDFZx5oDSQ3W0gda/s/Iwsx3YQFv9AS2lZDTci6hMdNeQBtpO2XwnwTMVT7vXOeh5OapnH1c0UIntcbcTjXMOm8D6W84SPCOqVqK1T8TwxskXQQu2HDgdcR47xeLijy0gzgmAR8P/+RORTj2h9pdoIpHMuDIn1LwmaL/dd/Rjjen81/4Rt5qv7CRgAJw8ri4P1JPtnqIg9NuBR5Fkug+YzZb+ZZyEDGFyrDh7qv8VNYAj6Zsovkw+nHOtI8Y586H/mTX47AT1WMSBQSK2GhoAci+2WtRpmLOBQeKkwr3WLeNOhR/BYgeA8CZJ8IFGL1gFHI8id5KVEpAP/ROZArRIA+DNLZeo48Tc/87bFARmUffMAbSTKA87VXZGzsMdj/t5T2Iyte1LxymabnyA95Tx5FHdDPjer2sbL+y1hfQAb1Z 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(7416002)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?JuLA2Hn7jFhlkk9wc7smzueOc0Lt4aKTk8KWY68kzpZxd80M60sEXISQWg?= =?iso-8859-1?Q?JfGVl7lqYO4mLVszCcZtOcEcbQD9B8NH0x7c+4it0sBWem9IKKmt7CqRMu?= =?iso-8859-1?Q?/RW8DZH9qhvnj3jC9zYEPk9mB6ni7P27EPVrnB0xvNTVZCLndh/J3WO0zV?= =?iso-8859-1?Q?S4Wt00oi5P7j7Wkj5huO/nmLi5JYEC7o5e8HWAyxv7bGtR6p/dHb2lK1+B?= =?iso-8859-1?Q?n0J2HlcmyOG0PiJ/xAVUupLObZUWM+KHJZz5DuMzUdskRNkWC1xRBo0N1v?= =?iso-8859-1?Q?BQ1EQCsrpq7uzgVMqd83mzfY1/1Hs1u91K6Mfal4gUhESrORThQUBDHdZS?= =?iso-8859-1?Q?g6HJbrJ2m3/m3Pq0vp6ptxJF2QZo3XB0+R/3/wVAyT2aDIBnDtGO8vnprB?= =?iso-8859-1?Q?3QWPCfipxEduxw9WVVd5sVrIbvirD33umYbVNe9YYD3NZuZwFyyr8/vTb5?= =?iso-8859-1?Q?5hsbuk9wSjehpFs5JyZ5DT7JdMTmnftPSUFFX8Qb+FdIsjqMNnsH4w9sEX?= =?iso-8859-1?Q?2FjQTywkvunjolMaPM3WYVXv8ZxB+rqnmMacO8zeKww18POYboDTYUa6xN?= =?iso-8859-1?Q?S6mULSRmIvJiggg6dWo2Nxd2pFNZMcsBn5JBpT/91wPhhJo4ErQZmmmCM2?= =?iso-8859-1?Q?J8pb2NLyoDfZk/Xk9NJhieYtkBIqppIFQ/ooVpykgVFKu+JfrDYwKuD6oI?= =?iso-8859-1?Q?5c7qFi2tzDWOBOQtQSUFcFxc4c+lKuz9Oear04gH5Ohp0Abt8rriibMlYz?= =?iso-8859-1?Q?n7xpOLHtqsWr9PAtsPxNy3g5W402AUnDQOrTh+99yjlCi8cQ/8gHhvxyLC?= =?iso-8859-1?Q?mjkv4cgrmb2419uVl/D4P7ctP1cjLx0w6L4r4xk6ofmjFbWOj4Vi987jiU?= =?iso-8859-1?Q?YMIs2M4BgCWh/EEgnmyPiUy4kSVnKh5xEy2L/DipE3fx5+/+uL5hNhiQfP?= =?iso-8859-1?Q?Ts3kqiykhnuczez8vnhSZMbFsAwtl/Eo0Z0Mfq3v3YFUDV8n2jDzEoFHuE?= =?iso-8859-1?Q?RFva/PrsgWUAz9l8Y60ojzOPACBm5bzPvwTAjzHqRKq8w5k38qfHiNL5Pa?= =?iso-8859-1?Q?RNPU1AbRgjUCMtTndJbOCO4lR2997Ai6n7XyCkBDqNuSTnVf1RRPPBnFzv?= =?iso-8859-1?Q?5CkOt1WI4bnxYGqy8XSHI7uXiLFh+i+eR/iaPbgZHYJVFOGO+EqJgpsF9A?= =?iso-8859-1?Q?xR4h9MmBYMo2KZomTZCwGQPtpgjvtPib+D0MRHU34ILllsab96SLGV0erV?= =?iso-8859-1?Q?zJBi0mfjrtJABQC9S4xFo3w23lYiNvJO8tnIZ3m5jRmHlbwRT1TG39AuR0?= =?iso-8859-1?Q?INqlQiakoROLbYmPqXBDj/15i5sYIXaN3V8hsu/f0JLyqSDMqjw6cQTMuk?= =?iso-8859-1?Q?ZAiZaulkjm2V6SD9vUMJYOYW30TFPGL2s/dW7BIlV9Sk/iU9YSqMGjv2sO?= =?iso-8859-1?Q?Kf6wZ05KCDSLGT5UE9ZTjk/arLaMiYYJtQXB0ZpRSR8WQcXTbrxMS1aSvQ?= =?iso-8859-1?Q?rLddiRDcoegewS4z79GUMx/UNHdo3ONpyTb3jbYWmwMpX9qXmcfOvYuooQ?= =?iso-8859-1?Q?ZsQb8YbWtbLUjPzaOwoaa0Fntc4DcCALn/HN4l9/acLUggsLOmkvE7gVIQ?= =?iso-8859-1?Q?+oxGdMaoXBAEq/Npm3ZV8UKx1TBtRsIsoXPni5XWyJPNoHbRR8VzvNYw?= =?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: 31116187-0174-41d9-844a-08dbeadeab25 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:26.9832 (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: 41t4TtKmBF8iKvvhz9tiMEGlIQqpEffeS3v/4MLxJ/nqkDzkREgINQ1N3tHPBnvbomqNMOcA5N/Sa3h2rIxdCAjMRjK8X3j7kHedx/2AImQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: PaMsyu57w84Zy9TsAHeKAC4aHDDWw3M6 X-Proofpoint-ORIG-GUID: PaMsyu57w84Zy9TsAHeKAC4aHDDWw3M6 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=482 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700604659762100001 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-bus.c | 4 ++++ include/hw/xen/xen-backend.h | 2 -- include/hw/xen/xen-bus.h | 2 ++ 6 files changed, 9 insertions(+), 6 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-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 04:47:46 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=1700604669; cv=pass; d=zohomail.com; s=zohoarc; b=KQpwT5PmUacijb1CfwHKpY+9y/N8W5boRqgOxG0A/muFgNpczIWlITflWBvDQCQwxWYlGWlnRCHvu8xgxKGdC2e23hu/5QJ1L3R+K66RPFoIIxwX6n9EVi6IPjmsbtOUF/9tBMyU6w5ec3IICWNf+hc9eoG2I4I4D3V/F51e2yg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604669; 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=zFvL92IcoplPsyb+IhBJ7P1+li1JaQbeI0VTPaCVCCg=; b=MWHBC6G9YvqjRLoeruYMAjb9yBaEIbVKyyf7yndD5xq4mZ21mdKVT2X/YWpKZfiNUDvn358uW+5OqAENn+E1B7kSVxgrmbvwzVKf9SPibDxoAGwpxQNzfSnTlp9nffCiZWyBJbNv2MXzKWUbXLONgSh7KLEE4djl0Qk2DbXG3Bk= 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 1700604669491318.2282424890021; Tue, 21 Nov 2023 14:11:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.638303.994732 (Exim 4.92) (envelope-from ) id 1r5YxA-0006qF-Mc; Tue, 21 Nov 2023 22:10:44 +0000 Received: by outflank-mailman (output) from mailman id 638303.994732; Tue, 21 Nov 2023 22:10:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5YxA-0006q4-Jm; Tue, 21 Nov 2023 22:10:44 +0000 Received: by outflank-mailman (input) for mailman id 638303; Tue, 21 Nov 2023 22:10:43 +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 1r5Yx9-0005zW-C7 for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 22:10:43 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ce2e17ca-88ba-11ee-9b0e-b553b5be7939; Tue, 21 Nov 2023 23:10:41 +0100 (CET) Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1B031085; Tue, 21 Nov 2023 22:10:33 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:33 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:28 +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.7002.028; Tue, 21 Nov 2023 22:10:28 +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: ce2e17ca-88ba-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kqD8g3kmSLyK4d2zD3OC0nRgxxwpsegsYvelEwZQ8SUbOIeneYQMjNEms5kFvMgPzKHUB6zEo/gIBAZT6y92jXQknT9XgKNKX4ij9+mP4CuwK80BjIIs4hil03QW2ypPHeIhAEfm2ASe217yDnV0uriDxVNHlumzyQDKkMZQ8uxh+VHvdU5qXRxNJYXVhiCehJJ2T5Gd/B1D6+Pg3RAtzih3uiB9B/9DN9+Gri1b+5gfvEi/LFwLgvHr7lKTzLSrzr0qFEr0vu//qIilwN6LJ7GWJGbAmGP3Zb2pKdk7i/Rma+VF1zoLDQgn73dmoZqIekHOu15yieEY18YVP5SaAw== 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=zFvL92IcoplPsyb+IhBJ7P1+li1JaQbeI0VTPaCVCCg=; b=T8t1w/V3+5+ZsY/Bg+3y3y0egwy+wQxNLXxRlk9BfFMAIY/IAqHDxad4uksVLOi4G5dnT1bDy7DCHgoohxnNpOnDyMkcAqhRaynd2V6v2oNyexbw6QSG9cqfUpxGOnfKZs8qktnnXrVtTOxuaxQbS+ZEKju2yHqP4YSM0jJhu4V9x5M69YGtpahbTmAklpYj8U0f/fsGsy4ZM0Cxkc5L4jEwvHNaNJAG0WyFw+RD4ikrp/uIiwUGcHC3gLI1j8f7tiXLqAp8LwF3+EZyVSYx8+Hs2zBG8D3wqHf0al1flG/8drDJECDLBzdbdEA20FnUNKUtuTVgeoDemVetJ8Mi7g== 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=zFvL92IcoplPsyb+IhBJ7P1+li1JaQbeI0VTPaCVCCg=; b=dvIeoRvoq1fJOUt/D1jJuWqaDym/E7I8E2mrWqU1LhAtMPso3ueno5C8n1/akkVp2JBYHS93q3nAN6pv0Eg2V7Ns/224TteFmDSeIfQLB6NaCbftAR0J9AXMWdABlRqhcdQHQ5Y/+yWbyUjxkgyplN3ysAlN25rqtF/76I1wRgt6TZT50wb+3WLeo6QaxyY0h1iNyOFu6Zzxs5s2HauUgXCICyBdUizdEm5OMq4aOTXKiwI2AZvPLHgRSh0eve5W1YjgsngACn1xHcIbUjwaATLKnZtoV1LnD7BO+2EagwDmO15obJN2xf0SiOkKsryplOFOv6JpSK/rhmaBSA3orw== 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 v2 2/6] xen: backends: touch some XenStore nodes only if device... Thread-Topic: [PATCH v2 2/6] xen: backends: touch some XenStore nodes only if device... Thread-Index: AQHaHMeI7KczK4z02kGE/beB6udNwg== Date: Tue, 21 Nov 2023 22:10:27 +0000 Message-ID: <20231121221023.419901-3-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-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_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: 5b371bf4-3d14-4840-959a-08dbeadeab57 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MAFD4wOPot0LeQgz+Y+W/txTYvQtn0TdqM2DhHslmzoGnA+wo43LdBitlj2fqiAT50+thIFk4mCdF01pxyFyjX7ugskRFwyTR9k6c+n+E93hAEX4eRB8Gs8tIS+YAruSTz7AAMeb6l7ciILZvdq/6TMI3hMuPt4ppsO7CCqyO3ApyWNlYXsjDNbySk9B+RaiX/xiuzLhmOnT0WMNs2wTXMuF4rgCiajb/d4340YC7LOI4Pfut77nP0QICQW7SlfsBUq8J6tSbHJVWriniayKNmadc0l8nZjfwUd+jO+OW0PmLE2GZhb3toebep8hlC9kD5RojliPJmPjlzozi2VAoiUYxuJdxjBamPC7Sc64n3mPy430seXD8LmTSLRWbxzgj8/stA4dxgeFPaQNIjph1xVihUjDHrME5xlnqB/Vh/O2RYohE8hPmiEparCMgi2R6vSocYFglA8n35uvG7sXSISWNauKKhkXC8QWJO2Efa3m4cvlJjT//9NId5CtHM7c4tj+/Xly19HUw5NLCjpuwOz3yfZp/cb+E9zpld9e3boMesJYZdQbasHPRPRjwA4+py3fHLmXTkLI/NraM1oMC2kXjcTbL8w1jAo7pfRURs1tP7TV2F4jQ6EYPL1Y+uIN 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(7416002)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?KWXIHuKvpmWQ2ZwtAt+v98nc4nReKWzxwVyg3uxPxddiID0KIy0etDTToV?= =?iso-8859-1?Q?p41Dv9wTHhFLX7bfJg+VQ56rvq+JgXmyXS7gn4cFtA6CXIwi/VeOAL/zSK?= =?iso-8859-1?Q?q8g+KOSY5Q9Bai0JgXX5l9K8+8vzPSk86l/klX6aSumnRl+QUjkQwkaTqJ?= =?iso-8859-1?Q?MSFV22QQdBvn4CRq+QCD2mQFd6O028TuOk0KpLq3mLhKmbL4HBUkA9JcrD?= =?iso-8859-1?Q?0ZcMJlQdZ708cibLPHEhWIq6jQk9nyDD90W4Rb/cmiC6sH9/dJq2190cLY?= =?iso-8859-1?Q?kGzjT401MaeZuHM/5aqmFlJMfemAvlSeTW828OlGwDvR7bfjq2wrtRR+5D?= =?iso-8859-1?Q?4xR/Cta33E6jLCVjJoLY+XYlgzw9+rIZjCMzVXXUxl97rE8eJnX8Jm6kVP?= =?iso-8859-1?Q?HmXLPhKPN7CEzgyWj6+N3PdWYiMwERfmnixJXAo9b35210BdMz4luFDYCQ?= =?iso-8859-1?Q?j0aC8wiyHEcoGkuY6vEaI6zu7mdvnkmntd86Dn8Kp4n3nQL+/aK58rEA6Z?= =?iso-8859-1?Q?YNGDKfDeO2/9zokQ+gkWdkYmZ3kiVsje/n1+Zx0rFyXK3HW7MYos91otKf?= =?iso-8859-1?Q?E/EuvKdLdzGsIsXdS9PLwn28n5Ki2Vy+K5NGofFMON0tk6uHYiVeGAhuG5?= =?iso-8859-1?Q?992gi4qcr+kpWQhAUmTJ08Tyz6SX1pa5rAYAWcdLVwV9KulnOag1p4rGn/?= =?iso-8859-1?Q?jInGabQWMlWyTcWHyUjPRINSdyYfVSVDYTcIEdAUYQNdkLaTPu3a5uSEDn?= =?iso-8859-1?Q?YZuS1aiu628FyCMH6ET5kJLUDY8K5dAH9kGGFFMadDUEe4WHniYlc7ouUW?= =?iso-8859-1?Q?0N24J3+yGfwv646UK6t1uDy4A1H+CpZZeOEWK68DPzDU3njZxKD7OFEG/f?= =?iso-8859-1?Q?kiPPKggVkG2IFVih63b71duNXsZ1DF52uR7gC1XOu891uCZVAIWnPgXL4r?= =?iso-8859-1?Q?NpWg936m9ekoBl3Z/riYPWwR0flBeoA7OPBt+Hd8ZJUghbK8Y1rcUIuPse?= =?iso-8859-1?Q?NCW1GIvsm4bi69uFlr40LMDoxa7UdwJaygFSCZHKOsq7Vv06k6zA2utO++?= =?iso-8859-1?Q?pKtgusjuweo3E1WOnehSSK+E7xozjPJxTlzWsso3ExcIp1eMuLD/FppJPv?= =?iso-8859-1?Q?K1GyfDMf8wpTmto59oSJg09hhai3GRGLKYKDdRnKXqJEfODHcGXUxJ25jj?= =?iso-8859-1?Q?wmDHE0lchAg/fIrUMjqpS+jF7vrF+o2ArELMWCZb5drk3eChJDs8orTIOe?= =?iso-8859-1?Q?g/iXW7bKiF9cfL3IAYvKg7kV/55UEBp/5huGDaWKYcBVCzNCGAgo+r/0vM?= =?iso-8859-1?Q?5AMpCZuq+5Qh1IHL8lJsRJUcgMiAmqPkzjzUu0LTxG76Xw6n5T05V5Blyw?= =?iso-8859-1?Q?ks2ph7VY11Bw0hBHwlkynW6eAV0oZPEguUVwAfgxw3XQKL5q3zRCkEhoSm?= =?iso-8859-1?Q?PPv/3up5O1XvUXLkmtlqsGTO9EXURkTM4TtEw7rgh1cF3vgO02AmJDngD4?= =?iso-8859-1?Q?5HA3lN+B98zSgSqUEQ3Q7E86d4dToZWICLQSaVZGQ3BzqULbLSR08x5lJm?= =?iso-8859-1?Q?9rd44Gm/c5sLyfrkCQyvEZKguOXulKkP0Y+/emGgaE9WmqrzNRrC5+30jU?= =?iso-8859-1?Q?EuoM/MA2E6gXij5aJPWEEWgIupn/IxGGLxSamFQZfoAQ+7HnQnihdBNA?= =?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: 5b371bf4-3d14-4840-959a-08dbeadeab57 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:27.4220 (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: +ISod+EsVypTm/werNxj3/BT+ZxuKzwUDvtZGaeivXT3Ee7NHpGOY7GhmMLV/uzc9qsErugmMSdlakrxTDwCsaljqpV+lv8NI2sCpT8zCp4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: tFZ2s2ZHAOtMNhJXcFHDga0jlcMu7mQa X-Proofpoint-ORIG-GUID: tFZ2s2ZHAOtMNhJXcFHDga0jlcMu7mQa 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700604669952100001 Content-Type: text/plain; charset="utf-8" was created by QEMU 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 is acting as a backend (i.e. it 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 --- 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 04:47:46 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=1700604673; cv=pass; d=zohomail.com; s=zohoarc; b=e6IaJV8lD9gnmnmsAp1T22u4H5pktdfOcopw9pwO9Is4ydBjP7Om2uObtuDjpHP5w7u5UF0FgWswmlKzdCeSghkDzJ+RjpaFEZ3yAZYhm51v0SqvnqLYQh2acBXCkDrJPVkAhHFxSk8f9y/uNXZX0bgBGME2Djhnuour8Y+9yRE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604673; 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=ffYRx7XuJDukcGSWHJ7JKVQ+d8C2usuIHgJipHrngZ4=; b=CzvtmEymgi8u3yydY1cl22FJpJSQWq0ovsh3d2VxIL6MrK6L7NzqnlAbJ9UJ5z2N7qFxr0pmH5JDJYzpRGirS52BO7Aru51I6LNu3c9umn2bsPcW9gNyngpSm7dRco2o7PktQSjJKADNyorhrg7h0IsTqjFEfvseNvuN12CCOQM= 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 1700604672979351.71786867997946; Tue, 21 Nov 2023 14:11:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.638306.994763 (Exim 4.92) (envelope-from ) id 1r5YxH-0007jF-Rl; Tue, 21 Nov 2023 22:10:51 +0000 Received: by outflank-mailman (output) from mailman id 638306.994763; Tue, 21 Nov 2023 22:10:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5YxH-0007j2-NG; Tue, 21 Nov 2023 22:10:51 +0000 Received: by outflank-mailman (input) for mailman id 638306; Tue, 21 Nov 2023 22:10:50 +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 1r5YxG-0006PS-Qg for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 22:10:50 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d37d086d-88ba-11ee-98e1-6d05b1d4d9a1; Tue, 21 Nov 2023 23:10:49 +0100 (CET) Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1C031085; Tue, 21 Nov 2023 22:10:34 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:34 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:28 +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.7002.028; Tue, 21 Nov 2023 22:10:28 +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: d37d086d-88ba-11ee-98e1-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+oTrug03bO6QMDVE2fZb4n6QkQkiYtc7LUvlIWe6QIW4Q7Morj3kHkdflWv/WRoC1fRSGUeA6PmLyZfchw7sjECTyimw/dfx6eKOoA5mzG8BkJNRSeZXgAyj9dzBs8RKpj66iuzVN0tvs9T5y9xXG23STbeWXmNva+pQp6QW48H1EUC0GD4HGzdYceEJcZcTDDG0mtR4zDPFidDk3ud7LhoFkoazm+hu/4aviKZmly9MXqa/bBdLOAUMJtUxSHLO4Uae8gH8DjjmLmB2nCkdgaRITi5lHcfq1i6pW719RLUU+u2dhXy4xzYBeLATprh64ELMG3V8JRyhdCnVnEk9Q== 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=ffYRx7XuJDukcGSWHJ7JKVQ+d8C2usuIHgJipHrngZ4=; b=YEtTuGWyIcbvsJ9f0YRazOenepm2HF8GQmFy2d59F/JiyCY8ccDv33vq20lJeSO33rh/rctmuioIrLl+v1Hrvh/yzP4OE3ePJdbo6YHAzRrcCiyuvA2Jh1I06Q3LEzbPLtgPEK0bvV+6ybT+intalSzDibrETMKfcH+tKWOBb7mAUIzrOmDxt3SrhQD83Ixz2LfKIjWJlAnLz/Aunkxq0qKtl6GIoX0zoYCQ3kh/6rDNHJPJvzMtvKSAluodt2fMqdQRSVPK9PZStWDNydhSUFSiXyS+/Ug4CodR9+fKOjj0fzbsRzjfz3BIo7/JAm5cthFyTQPF56QkzUK6JMDmww== 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=ffYRx7XuJDukcGSWHJ7JKVQ+d8C2usuIHgJipHrngZ4=; b=gKASjAqHwMmv0ZXPeRtLBFyp5DC6FQBknfHiNZKoUIzQGWyYnRZa+Pw8YED71UM16CzEY8g9wB4boMhDLfAUe+Kp1q76qRoGontVHfbXF5hu1AKCg9U10D8H+lVrkbLfdBikI1ttjAlH8Dq8fuJCFLNt6blp0HoaK8YodQkiqKDtEcl+HirBTAzXdNNINp6MIz5jJMlbrsSyaAm78P+1A6wQK4wTJiZdXdZP2Mjk3kU03B5YAvYFIKi8MPSr6EwxtqvPMXnOO3xC/eXJ72CQq4OKvqGL1oNe+LzCZeOwVsOrtNMyUxmzX78tJZyTgzFLHOMD8EueMqlRYOUdtc1IAw== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , David Woodhouse , Paul Durrant , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Anthony Perard , "open list:X86 Xen CPUs" Subject: [PATCH v2 3/6] xen: xenstore: add possibility to preserve owner Thread-Topic: [PATCH v2 3/6] xen: xenstore: add possibility to preserve owner Thread-Index: AQHaHMeI3Gf8Xs6dHUOphRyadMs2ow== Date: Tue, 21 Nov 2023 22:10:27 +0000 Message-ID: <20231121221023.419901-4-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-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_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: 0b5b5819-1eae-4f49-92f7-08dbeadeab95 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8SyCokp/FW7dJRKCZQZyv9CgiMYc8TV9VtzrtN8Lg9XgIMamyC6+Yo/2/2xKYRziteRPrYXknLhsoU3of6ssWYlw11O98+Ukb+Dp3VUeDCdvyUxCrPk7ExEz5sv4iltZjYkk7zy4Jppr4yIsTJuAAJSQMIWHiOgv+rUD0lTH4JxpqpEnhhvpyYc7o+YTrvmvmNLWunq6CvOlw4Hpi63/525DfKrOhnc+2nVvFbDxaSSd4/ppquOE5XB5VnJxPZ0HmKaInRNk/rnQ8Dc337Q8SstdmG/pyK6DuEA/sb1Q4lKkdUmx5lfIrYEYgJ2ngDhKJAzsN9tullFhUTTmPBl8HiZ6iUKpQnCb6pCa42emnomi7Urni2C9Cyv8MICim91ersiBLCLQDk/fL0sIs590CE066ZlhckoUAe6TxWKwtwQtBToSMT0dQau3Z32/CUfAzjZpseh+9MYIF/UEPODsiktmut00YV1kWKDvGyNZNF0uS9WY3h5w2CNCF+xnYPnM2pPUVZhfd5P2yB7ExLi7ForBB5v1M8jeAru9kDLe3ooYYFr9/IAEUMqegwvM4zIpWuXV26Gvi5S7ZRz2xub8vQ1uT8rG8ykmXzrW14iE64/+NDQbAmDZ96POAGseZaOY 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(7416002)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?XUXoy6WLSuy2I/xwBQMOTplQFonOYjE+lTe4Lw0/Hv8WxpzFe3TT8R44l8?= =?iso-8859-1?Q?tBefqDfsdRaCs5rTSTM4Dc21cwj5ASiB/PR5CxiWv/JiAIXXX/nHSqQwSX?= =?iso-8859-1?Q?VQPjWttinkA+qEXxrnnEuJ93tG4QzCdQFEuotTwq18RkXyT5eLx9IIwLlP?= =?iso-8859-1?Q?0cGIr/zi3FTyFMtUwhMZyK4nzWKcyg7VOlXNGw7Dir76/EsLlGF4wMRHJ3?= =?iso-8859-1?Q?wMwb7XZ1dnaSH/SaR3/wgioPRJAC/YFdNTfaIHP9e6WElJhDR9KW1/Pmmh?= =?iso-8859-1?Q?lhsJjwiB400g3tWYP+zD8TwcYBRfOAglpULWc0pdQbYjHbMb/Cx8YYMpq7?= =?iso-8859-1?Q?AzTqZYhuZGcC+ru2hIY4GH39Z5AtDrnw2jbaFTdg3DZISAdRBBOfyX1iRu?= =?iso-8859-1?Q?qDmHcsskmCzDbgq2XmVHVbwpHA/2Mr37W0Gq7E93Wtn57XCBiQ/be/e5ZP?= =?iso-8859-1?Q?rCXfkPIENLXFu8REUWgEcKy1YZST/3vN9zGNE1W75RC4SoKYATVZtOm6CW?= =?iso-8859-1?Q?8RaJsjDIn1nYVdvqiPJJ17ky/rLNFrMbWP8B3/OEoe1dPqfj+F4SAEPSc2?= =?iso-8859-1?Q?ORhsbOCbYz3ERHdmm5/vQu+k/gIukuLvhOXGUSncJHQmC8uFDuJy+Ov2L3?= =?iso-8859-1?Q?UlDHhFSY1rkYWb64rk/USKy1d6MOKlUhtMc7eNcXFh+3F7hqK6PBa2xZFZ?= =?iso-8859-1?Q?6MQxCMe/oyvgD8lhdpqHbCiZPTKLgfwXVROgobqkWDfLOXOLupC9/LChij?= =?iso-8859-1?Q?yFR4pScCO03bm2CpUwHsFr++mKV1zwhgiUQryankVYeGlXvHkDf9hvB3hf?= =?iso-8859-1?Q?Uh54IAop4siQ4QF/NKaa8D6YcgjA9dl4gJIu43cJf63IBkTlm+S7hJEEnf?= =?iso-8859-1?Q?UJ+9apljErrTIYe2EPPasqNsGti8wffQhGiew6COBmCF6X45GU3WpbSC5N?= =?iso-8859-1?Q?KM42hpkecXckNzGwg+EaM3SpLnA7ZNa4u7YMrHVlb6vhgEXgR/xVCVk4ug?= =?iso-8859-1?Q?pEVbc1QDH/99Nl3S32PscN0tzVihujXkWKn1DCqsXO79XaZjA6DX2a2les?= =?iso-8859-1?Q?+ulgHz4Jhnj6RuifNtXbHTgUEcN7aWnGPSeA3weecNoI+GblsjR2GdVObm?= =?iso-8859-1?Q?ObGljcAFyWespgR4Qm3+LLX3GhZDqbxUM91b4YEDX7NgL4pYG1uXusYRP5?= =?iso-8859-1?Q?vu0O8YvBdkrz4ylrdUG6fJdeGPMthzwZLLMgQ7Fouh26NlHcFKx8Wa+TMg?= =?iso-8859-1?Q?H6dUmQunkEgM03IdjxOMMxs93NK8W/V9PUT8ryowi+6qdA7toyu/tCs4/O?= =?iso-8859-1?Q?1bIdUPGQD/XHk22gZTU6Kw5aW7p7/MkyDsHQlWB/wuA9Lu9jsqYQOSDTLv?= =?iso-8859-1?Q?I7f3GRXHP+Oy9YX14SpawBvhUwJzlPQ69AwMm7Zsi/UGdXAdhN9u7CNJ22?= =?iso-8859-1?Q?JH1sfOunSHtRfKveMWr9j9UMYVLz0X6da/ykpOG7VemJlYndRSS8m3naMG?= =?iso-8859-1?Q?QS4GC73AEQ1Gi2ee+fzVnxPPV8GdIYNqkR2lyzIHS39ODvQISz3NFFWXLy?= =?iso-8859-1?Q?wYyTC+Y5sGVZ5U6hsuB0epukWfKr8CTd1skeK/tslRYOzkp/ZzdVP1wqYm?= =?iso-8859-1?Q?4zlxcS0rV17krshRXJcw6T0DZwQLAhWpmXl57h22ug3aNlV0P04T/hiw?= =?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: 0b5b5819-1eae-4f49-92f7-08dbeadeab95 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:27.7937 (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: BEVgIfVgeiTu73ik19OyXyA8m6UD0BdLwEuXVifPPf8sfRMnihbq+VgcI+/RqiL6cWCoOzNPs/RmWKw61WvmxLfgUt0mX+OaSEPZU1zi1ac= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: W2bYEx-fBJEg5TRa3Y--B4-uviAGyo8_ X-Proofpoint-ORIG-GUID: W2bYEx-fBJEg5TRa3Y--B4-uviAGyo8_ 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700604674048100001 Content-Type: text/plain; charset="utf-8" Add option to preserve owner when creating an entry in Xen Store. This may be needed in cases when Qemu is working as device model in a domain that is Domain-0, e.g. in driver domain. "owner" parameter for qemu_xen_xs_create() function can have special value XS_PRESERVE_OWNER, which will make specific implementation to get original owner of an entry and pass it back to set_permissions() call. Please note, that XenStore inherits permissions, so even if entry is newly created by, it already has the owner set to match owner of entry at previous level. Signed-off-by: Volodymyr Babchuk -- In v2: - Pass transaction to xs_get_permissions() in libxenstore_create() - Added comment before XS_PRESERVE_OWNER defintion - Extended the commit message --- hw/i386/kvm/xen_xenstore.c | 18 ++++++++++++++++++ hw/xen/xen-operations.c | 12 ++++++++++++ include/hw/xen/xen_backend_ops.h | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 6e651960b3..d0fd5d4681 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1595,6 +1595,24 @@ static bool xs_be_create(struct qemu_xs_handle *h, x= s_transaction_t t, return false; } =20 + if (owner =3D=3D XS_PRESERVE_OWNER) { + GList *prev_perms; + char letter; + + err =3D xs_impl_get_perms(h->impl, 0, t, path, &prev_perms); + if (err) { + errno =3D err; + return false; + } + + if (sscanf(prev_perms->data, "%c%u", &letter, &owner) !=3D 2) { + errno =3D EFAULT; + g_list_free_full(prev_perms, g_free); + return false; + } + g_list_free_full(prev_perms, g_free); + } + perms_list =3D g_list_append(perms_list, xs_perm_as_string(XS_PERM_NONE, owner)); perms_list =3D g_list_append(perms_list, diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c index e00983ec44..ae8265635f 100644 --- a/hw/xen/xen-operations.c +++ b/hw/xen/xen-operations.c @@ -300,6 +300,18 @@ static bool libxenstore_create(struct qemu_xs_handle *= h, xs_transaction_t t, return false; } =20 + if (owner =3D=3D XS_PRESERVE_OWNER) { + struct xs_permissions *tmp; + unsigned int num; + + tmp =3D xs_get_permissions(h->xsh, t, path, &num); + if (tmp =3D=3D NULL) { + return false; + } + perms_list[0].id =3D tmp[0].id; + free(tmp); + } + return xs_set_permissions(h->xsh, t, path, perms_list, ARRAY_SIZE(perms_list)); } diff --git a/include/hw/xen/xen_backend_ops.h b/include/hw/xen/xen_backend_= ops.h index 90cca85f52..79021538a3 100644 --- a/include/hw/xen/xen_backend_ops.h +++ b/include/hw/xen/xen_backend_ops.h @@ -266,6 +266,13 @@ typedef uint32_t xs_transaction_t; #define XS_PERM_READ 0x01 #define XS_PERM_WRITE 0x02 =20 +/* + * This is QEMU-specific special value used only by QEMU wrappers + * around XenStore. It can be passed to qemu_xen_xs_create() to + * inherit owner value from higher-level XS entry. + */ +#define XS_PRESERVE_OWNER 0xFFFE + struct xenstore_backend_ops { struct qemu_xs_handle *(*open)(void); void (*close)(struct qemu_xs_handle *h); --=20 2.42.0 From nobody Wed Nov 27 04:47:46 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=1700604663; cv=pass; d=zohomail.com; s=zohoarc; b=LaWNzZkWU1XywVp1q8wdRhj/unXiN+GWdd7JmcnQOT6ElZOIxbBjIzZtVMVGfcpiT3sUi+0DHy7POWjqn+q/3WukdRlX8fVTNPw+hlzk5uDKy1gz5HzlQGxMZfq+oP6EHI4EL5OaFYPzEbJo7EKG73emb67IjvDUYrVu3rCFMe0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604663; 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=8+d1SEM81t/9S27BacM21vX5GsG+JjE3MpWm4AA9xKg=; b=G/s6wtoVFQQvCSLFKuKhi5aM9fk2YPtEkWc33MsluZWvduUJHOD902pwZNZQVS9D80m8hT44KQCMNqgf+IsmPlOf0tFmF/8WCjifjtlAPwl8ciRmHaob3+inoDHGkv1BaKK/fnBtXIIQd7hY6aE3s9Jiar9glfzYT+NLjOGEm54= 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 1700604663268958.3628242143186; Tue, 21 Nov 2023 14:11:03 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.638304.994739 (Exim 4.92) (envelope-from ) id 1r5YxB-0006tT-2x; Tue, 21 Nov 2023 22:10:45 +0000 Received: by outflank-mailman (output) from mailman id 638304.994739; Tue, 21 Nov 2023 22:10:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5YxA-0006sm-SA; Tue, 21 Nov 2023 22:10:44 +0000 Received: by outflank-mailman (input) for mailman id 638304; Tue, 21 Nov 2023 22:10:43 +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 1r5Yx9-0006PS-Le for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 22:10:43 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cf526bfa-88ba-11ee-98e1-6d05b1d4d9a1; Tue, 21 Nov 2023 23:10:42 +0100 (CET) Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1E031085; Tue, 21 Nov 2023 22:10:36 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:35 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:29 +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.7002.028; Tue, 21 Nov 2023 22:10:28 +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: cf526bfa-88ba-11ee-98e1-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e/nCgCGfDFB+pyl2Msj2sfxyVSL0n32Dm8DxFyF2p0ObjzcPj8Lg6v5aWlUuyq5VT8fVd4UswncalgIrzw92R/7uUs4lcZpFmYcds+uppvGqW/KWmUWg8CJqV6ecCm4+WQhlSbLMU05AabCV/ztQjxcYk6xHr90XV7JJks+zHsTC4ptspemH2CFx5DAD4WvyZ8lPVbeYAn+WL3UXUv5sIWTX9cGCeqEgs98dxeYf0GPazrvuzzU5XnxP61oyiSb8DbhDG9tXzMVfOj1xj63bboAc9WydcqRRy/j5bqO4eoFP38Gme2fHiVOk87qrRwbddW5YNYi+lw0NnBbO3Swp4g== 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=8+d1SEM81t/9S27BacM21vX5GsG+JjE3MpWm4AA9xKg=; b=oZ8DOJx3Vvp8MG46/jrzRmCBKzeq8v5YxpsPsGpG6v4ygrz4GhviapdO/fuvfVTg+pBE2C9JpQf+hYCnYdf+raJ+rjkic+Cvj+YKu5K7yHFLGpqNp2uW1KvWSdw5lbvPRVHRcjP+qr4ZNIHxB/XROA7LVRJ9MVJ629R1NV8Hz1lIpU86P3m0VStqQRa308i8nbJkkfBCWeROJzqHNFovzHJ1naVdHRLcGe6DoTOxPwgT2cVYw56WWec5Vzemu4/BNSbrjfc7h2ZFib7r4742b6QN56JQErIqH4/xw3jtin4sczBfTYMiLSBGmwkP4aArDOiblYVIbM1QPTxjCtCblw== 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=8+d1SEM81t/9S27BacM21vX5GsG+JjE3MpWm4AA9xKg=; b=jxjQTw2fJojzkMJ+iXQhd6rUfoZPejwMN6y6/+dnTuTSgUOinNrZij7hYwdLjogCVG7qCpdvtAXAAFKBgIAYcS/k3Im5NZf7e/qS2zHX+6yAlBXqzBYG7YI9J8MOqYoKB2FQBYcPn+iDWUCIGso3e8zzCPMUS8/9IKPbzKwPbFkh/zOE+ewb6MPFYgagBnNr4kvCvA3lK4pGoa2jt6rjbLKCaBDWmbECmZAGkhzghEgkCFMAI/NwGJWfoYJ06uReEVslG8lGjJ+DbdDZLBG69MeMiVeCAxm4A4dM9O4B+sFpTkrPh91VJn0buMWgDT2Ki+Q3habrdhdZXX9/mmSyRw== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Oleksandr Tyshchenko , Volodymyr Babchuk , Anthony Perard , Paul Durrant , "open list:X86 Xen CPUs" Subject: [PATCH v2 4/6] xen_pvdev: Do not assume Dom0 when creating a directory Thread-Topic: [PATCH v2 4/6] xen_pvdev: Do not assume Dom0 when creating a directory Thread-Index: AQHaHMeIsCU+MAEGAkSnPoa9ThBNzw== Date: Tue, 21 Nov 2023 22:10:28 +0000 Message-ID: <20231121221023.419901-5-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-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_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: 545a00d4-deca-4314-2d77-08dbeadeabd1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cIHSB6AFD2DGneJBmtsW5+mDO6ubkuXeZx/61Yg/DQcHfi/ZGJxgb5SwMMnmcVjCHmzRKmVHTKyglKEm2lUkl1MQTefLh6UOJ/DBGTJgSDgELQv2mgEI1fnTvUX0HzD6xE+mQ8TKo6mSMZVZO2Z5uPo1y//EE4FJm2UnXrAD816+ngKA6v7ZqJTUEnBcEUNT3vW2LxeejMEbhing4ACKHjduUMW8ktbisJB13xshjD67HF7/BSa4ZK/dcz15YMZO1InyPbj9ox8HEeKVT+uZxihT0s5kAjpc1K/TzUEVURChGxfw8qQ8bgoVAi7cKehOxNoAqg1HsLlHtMnFLvF1K2VHj2tGrvmHMBlVJkPDiBcNVdVpUcIMxSqzvHqF01Ts01v7ANwKQTTVkx9FxzCnjtkArmtodbgzwMY34Y2cVo79sWzY12fE8/9qhEauZizOeRlF1SEULC5HeYuifjOOR+FHNE0JZq2h8Y0EQsXaCtUB9iCf4Fj46n+3Om/hvyXjsJCao2FpyYb9LIn0SrXDgFeblmMZUKUMVWga/7SNqYY2gezy9NX+poY0EO33pZfYQzrr7Yyxiy/t5NJSqfuDexPk7XOk/qyUort6K/nPBhM1h/IGcH61swxuUT12oPRd 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(4744005)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?G4Jv0XESz3TozlyoYvkV0ymZDP24gPbUsPL/Z0eJvav2WndcnaVdXxA+rT?= =?iso-8859-1?Q?BW7OcZ81/7qKmBnKvymh4sZ2bNQt8Y+l9kerXfpjXGpAZsgzOXG/GIWM3O?= =?iso-8859-1?Q?pButV0nFSyB0T8SQrxi61qMbx1XUEVRpjLPk6txiqtsPDcBEKUSV2tXTKY?= =?iso-8859-1?Q?U9h788j1iT3vy6EB1G8CoI/Yy0TYBuiE7kC0EhylLznD1cX6mlHhhC/3YC?= =?iso-8859-1?Q?48hkNe2tfVntJgG8Mhaq1XOXZXv0xrtLm/4dM3e05WUsbjWzS41xzG2ZzG?= =?iso-8859-1?Q?3lyBYmg/sSqShcFY7tSSIkfMyhyOT4IHdAUqcbZURNUGjhyaZtDQ9OGGqt?= =?iso-8859-1?Q?ORhETj0nio53802GQPs5HAcfTrEyxA0KpeJGKDXnBOR5bSy8moMn4bcnB2?= =?iso-8859-1?Q?86ClVwwuIkB6jibiKxmqhLRBLkz8nUJtdxHRq35l+767ffN9qQqLHrDrxR?= =?iso-8859-1?Q?fgc6zarRAgJg8tsq4kZJy4cnlJg4ZBJjTBw7wRGXKg53QekooJsr+YqA4u?= =?iso-8859-1?Q?v09qc7fxDDO0vTY4K5wxF5RKfclVThBbHOg+/9lqSYU2vOsbjESUpPE2XK?= =?iso-8859-1?Q?ez4zKQuKzcziAQ3aT7Bog6/HAyn4MCL63Dp8tMKZchh988UKtjgZcWjV04?= =?iso-8859-1?Q?zhPx5I9kqj01xdKW4MGhPdxicy8wamQ8c6ZZEkatWC7ECOy1vLBivEsD4h?= =?iso-8859-1?Q?22x2zHFzum1s4MTg84vqEHKgykE7zYwPAQO6gDj+YEfEJqPyKkrRmRKT09?= =?iso-8859-1?Q?G4bSJtwwmfQL/J58nIhsNGaF2gAQG/kTuqEV9go3X3ucRl3qMaDTGtv3RF?= =?iso-8859-1?Q?qD5k9b/YJV3bR8ZCxPkXNa5AksLPPBk/QF40WC2t2SO6PQ4wCbCi09GwPJ?= =?iso-8859-1?Q?zuEZ+3fGShDfPIcwfcATJfpDtDObWOY+pUQxl1mx9mfYrKeRWKU2NFAv3o?= =?iso-8859-1?Q?809sPYiuzTOpz/XwGQqQGHf8GvaSF84WNUhI2lP/3GcqkCoh+AnUDvv8y0?= =?iso-8859-1?Q?wHlG2DplClHlMzEwfKziwpBHazU1KM9XGOJXxfQLYmwTz/WS6ZdKpT9awO?= =?iso-8859-1?Q?1vVsgIU2xQ3IxvzNGsvhJX2HfONphuMQbOrYtp3tPO2/LpbW1dELnMnqis?= =?iso-8859-1?Q?5aMERlasr23+ISHGfDKfGDRNrWxYSr7PQQhoEeUF4WbpLh1kEkOm4I1Irv?= =?iso-8859-1?Q?0tEPVBC8tygZYx6HkO7itMYB7fOEDPFbxlfyHVflA0hKWAaoC/hmkluigt?= =?iso-8859-1?Q?apfW5cORQLz5VrKNYTt+tzM+Cbf1eF3fObvoFsfP0xnX4pVhnOyNwV233b?= =?iso-8859-1?Q?92wMwXlMnmQL4UK9k4+XI2jtIZVXzXUxfcLRfbScsdpL2gAj1d+l47SDv4?= =?iso-8859-1?Q?PxIoHC5ER4V7WAdOrAPN4MrieRDg6FnzS7EXfkV2bwPfOb+YWQdybDoHp1?= =?iso-8859-1?Q?V6BdFupayKmJmipgzD+HbEUc/mZwtKe2cCEMOX9U0xPyPBhETN8o7OSldq?= =?iso-8859-1?Q?hB3/ruhQMK3f0EDfraCBwZcM3SCXtk1B2F0ReR8Fl3uS52TTNJ+uLhVxtr?= =?iso-8859-1?Q?eGIRkLIlV1NKb44NgnIHwig9xw1U5HjYzp0E+Gl8I3MmiXH1NOIyOP44Sz?= =?iso-8859-1?Q?PkrXWMuPx25d+G/1XVT4S/UNni2GQmsdJxKePi15DehtvZcGRyXREhmQ?= =?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: 545a00d4-deca-4314-2d77-08dbeadeabd1 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:28.1210 (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: uW7UMPLSQQyji7xe6iFZORqUN6bSmHCUVn3iypn1D7SnJKcRFUufVAjZgj0QSB2t3lCuX4ZMqEB0rWUkeBtdMb34Uy5q+W89uSv6PYk06x8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: Qg0I4U_gvcCHDfg6Jlr6NmZzciR1x0UY X-Proofpoint-ORIG-GUID: Qg0I4U_gvcCHDfg6Jlr6NmZzciR1x0UY 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=624 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700604663758100001 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Instead of forcing the owner to domid 0, use XS_PRESERVE_OWNER to inherit the owner of the directory. Note that for other than Dom0 domain (non toolstack domain) the "driver_domain" property should be set in domain config file for the toolstack to create required directories in advance. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Volodymyr Babchuk --- hw/xen/xen_pvdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index c5ad71e8dc..42bdd4f6c8 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -60,7 +60,8 @@ void xen_config_cleanup(void) =20 int xenstore_mkdir(char *path, int p) { - if (!qemu_xen_xs_create(xenstore, 0, 0, xen_domid, p, path)) { + if (!qemu_xen_xs_create(xenstore, 0, XS_PRESERVE_OWNER, + xen_domid, p, path)) { xen_pv_printf(NULL, 0, "xs_mkdir %s: failed\n", path); return -1; } --=20 2.42.0 From nobody Wed Nov 27 04:47:46 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=1700604689; cv=pass; d=zohomail.com; s=zohoarc; b=WIyYbE2DXgg7FSgUexGaM1ijdibJhwcxUlaOVLnJgtu0+vlNx4Pt3S5pUxj4lLgb8PYIevxT+9lHT2GHD1QtWXHF2Qr4STNaWlRAjsJrvPudSzJKtM4CUjfCuSxpE+SYo9Rd6MJUMD7EYQdXIbo/7Rk/GEpnrTP0iufFsIgFGew= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604689; h=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=CaOBkFCMmuEScm/QQeDLhJOz4phbpzFdrHGi97vhBfA=; b=WPtWC1VLY3cU3qC6utkHRrWLgToKNuP932glPG4gq7//WQ79Y9Iddb1l9Jw3H3kTzjChlKY3zrH0jI2xvzpIHnYdyOAMCG3b2J3Xw7CcnokDrPBX+kUJmZ7xJEuLvXnW/U4OHl2P6IU0w3e5d7/mCMym24ZIleQe0gODLiIXUbM= 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 1700604689332547.0553494438543; Tue, 21 Nov 2023 14:11:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5YxF-0005Wq-Q4; Tue, 21 Nov 2023 17:10:49 -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 1r5YxD-0005S9-Hl; Tue, 21 Nov 2023 17:10:47 -0500 Received: from mx0a-0039f301.pphosted.com ([148.163.133.242]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5YxA-0001bK-9f; Tue, 21 Nov 2023 17:10:47 -0500 Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1F031085; Tue, 21 Nov 2023 22:10:37 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:36 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:29 +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.7002.028; Tue, 21 Nov 2023 22:10:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gKAcpyAEZXDE16zBn8ggH2w5dEMvrBkgdFvNLD2b4E+dxSPkPB7lpE+amKlUT+Y4ZB9fVgUWpTCkRENcRIOFGlo5n1Ed97r0GY45YcKDS2HsF1Gcll44smexJO7Sx3fT6J+g1X8bAa4tE0q9RJhlCC+ifskQD5qMQUrA4dQYvp4yOdO+0+gKPUmlk76aaAxPZ7+kr5dSm3obsngj7nHvsh9uWdfCO3eRDYNRvSjjaygG5GtRUqjwri3WtL6jneKrDP9M5AOm8UBXNlOps7f2zy8S5Y9mhn2hSov9FtETOSezWTh+SoPrbCOsBJY3IJ3IjyJyRAFN7/yZPrlzHS/KUg== 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=CaOBkFCMmuEScm/QQeDLhJOz4phbpzFdrHGi97vhBfA=; b=G/yWGX3OftUthpyj9GUQkcwShxm8YyJi68LqKIy3MPAPCxZcfV6I+pG0ZtCk7dtrsFWasE3rDh3hHDUPXIpvIjyBDaDukPJM45jMJR7Mhi6a9xBRbO3g/dC7Zvc+rBa20Z2D6oJNsDzhfa47gVPeX9CJXUmRlXXvhsAwvY/V1u1TNukCDFNRsSGWM722giyHYFQWJNw+lFOPKfIOsxImbFQTQfuSoMhi4d+/phF2+aZmVhYjNk/LYD9qePjf2/E/O55IfhR+iXzcRGTRD0JUztPX/WaUSQJp4vU+2mNHoSPAWWws2yj4moC2DD5lqYKbSdNXZO+b6PXEGOCkVGbyPQ== 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=CaOBkFCMmuEScm/QQeDLhJOz4phbpzFdrHGi97vhBfA=; b=mXIHPiTzVzKXyqgAWbpkLKhh7Kdz3CMEtxv7QjpnCIvArbG6cSgZ+fKBYGNA8PhDHdBbTBx6HQRlMwYP0IfWn1EGKN+8oNnD4pOf9NQPhOAwG3l7BPfT9a4u6wYvzNREiOrdYhhyNu7lxFQJ00x3OL9wHUVs7BRpDlOWNOrTerfmJru4u3ulHJQs3x+eBMN4isOKp1JciU4k0bTC4TXlANUCSoq2RcS1xlGbVjUghq4TdJtOi1QO1zXHDmGUoQvCMwTXSrHbJWFK2KoBVyh3rpYAg6mTN0yY+hXEG/XuHSPYQaxNQrYUgUfoJhlysT2Z8s8cThRzz5htbQWlnIMF8Q== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Oleksandr Tyshchenko , Volodymyr Babchuk , Peter Maydell , "open list:ARM TCG CPUs" Subject: [PATCH v2 5/6] xen_arm: Set mc->max_cpus to GUEST_MAX_VCPUS in xen_arm_init() Thread-Topic: [PATCH v2 5/6] xen_arm: Set mc->max_cpus to GUEST_MAX_VCPUS in xen_arm_init() Thread-Index: AQHaHMeJPOinN/4s8Ua2FsufYnZh4A== Date: Tue, 21 Nov 2023 22:10:28 +0000 Message-ID: <20231121221023.419901-6-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-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_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: cf6a73ab-b075-41e2-c84a-08dbeadeac0c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tZ0c6sTf1f0ONpg+Ms52egNa76AgDXSbLzbMYM4bqlh4ooToHYP1mb74EN5tw/gW1rP/pFCmGBj2xk6iT8tWTuT7BiotafC7qBDhZSAdUXERsGahPGujpm3p5HM8YHPz00frDYzCYNeORxWh2ZjHsh4wlmFg2YgWbyJobllkRWMMnQT8tWL8nPEBiIn100KANcWHsp+qTpQIHqlvt6jtRFl+6jJzML0PFSJ0cMg1mBZzuhp/xXROmohZG7kQWAKzHt9yJ7U1h9TlSsFfEsWZ37h2fTQC6LFJSzgco33+Ld+DR41irx1UWqFfnflnRxZ6weH8Dv9StyjMg0EKxL6l6I1AkMUZVIIBJfEwVwG1bVKE+9FCCDpqIsrlxgbIlteCsFAQNZU9pG1MINkiiFDPJPo5NBWPz0Io3rPTkp3ZZHuaRZFYI67axmJPp6PxXynU81qGcgAruu3gkjlw4Wwpyu/rNfUq9thbqqcADyV0tRnhHH93r3GGoW9fQFfwcyq5+o2U6Q9otxMrro90IIARRp8Wh5fMS6xSltmJa3iYyPzRBMPmzj+vc2rE2xmEvhQCSMM2LjhP0BG9M1OTm+3vJPxtCZuaFf/XdmdoIlMYBp/+PJi5K7UX0VJ+XEaPjBGi 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?uXpwSJVWgS01gHJc7j1HShLyJTjJVcx3NBppdhsHKtP0nLNZ8OY0Wkh10c?= =?iso-8859-1?Q?Z2gThefyfXgwpV6dGf7Qs/LOGErZ5VcdM1h/Zwkxga0rsCob51al4942Eo?= =?iso-8859-1?Q?ihSpLuA9ClBp+VPodnNsflSt4jOd1yU+Ow2V7WtDO6Um60YofZ8Ksulo59?= =?iso-8859-1?Q?G2JRTftIT8a/HcsM0UodOhiouxcgE6UqGb0vR7PO5SlNA1A/9uoAU2IszF?= =?iso-8859-1?Q?wa6TAEfizAtyRNdiY1NCB06z4aTfmxSRKs6dtO/SlxlBbCFcCnj8KZSO/k?= =?iso-8859-1?Q?qsyvtvrDBb5SBDzpa6ptgma5WAUlepzgntlur1mIBKyPUl6bjS6gWl0Hwb?= =?iso-8859-1?Q?cE3hFuZsXPW3lg4jPqckDNF2y/QH5sNF4N1FlFNjapSmLuCrcP0v99MQ7Q?= =?iso-8859-1?Q?5ItMOB0Ih6VZNB6ZBZy6y4sXFx3i5jv6MZgWRVeAD1KnBs7hSyRGFUmo7s?= =?iso-8859-1?Q?HcwHZ77gUP1R7zVm0XR5bEx58EK20RjRXNOMsylIio0/TMG7rLbXue0aMG?= =?iso-8859-1?Q?oCFex+gGWJwFiH3eQBvpt6Mss1+s7CQS0OpwH3t7nQ+6mlih1UruKIFDiJ?= =?iso-8859-1?Q?jUYuc6W40GHVHppb7dpo6e0lARSjWeQXyRfUHDdelvICYUEmb0JK+wseEV?= =?iso-8859-1?Q?fEZ1LRLxg1bUUzY557iyfhBzdL5ZokyTwmVL8lQNGa0Zmc+uSG4ZsQbgBk?= =?iso-8859-1?Q?ozkMCpARdg5KvPPdTZaqJrzjMuGKyGPeFIURhsSTHuvw27n3uHy570JAb7?= =?iso-8859-1?Q?bIPEz41f6vgmJM+yq4ydh1c5rqqoYZLwjJpG4AO3o21tY6qbn+iy6PtTXi?= =?iso-8859-1?Q?bkJEz94e4M6SQ12veNWfpXw4zYdtgiJlJUbZJYEUW43VQ2N5RadUItloJ5?= =?iso-8859-1?Q?vB3i3Y7gJKMFnRstVl/1j7wKzs93oyunc/j3GqYtthX/C6mk8TTc+tOlGu?= =?iso-8859-1?Q?YXl9o0Yt7ZUNCiv/rHfojoO/B0Lfa4EVxfmbfk/M17KsNjaNxjRJF+yMwV?= =?iso-8859-1?Q?DY2a1CfV+TJJl6pzaJWoPw8PCz8++3eBs+pYXbmGvs849Fz6P9wT7MAHVm?= =?iso-8859-1?Q?jk+sRqz8R8rcuRjhbwQP6aZ/mHV+y/GQ4a3nZ3JD5KHniMRgFTnDvzhvid?= =?iso-8859-1?Q?myS/U0n3OBG4OjCfXHGwsfFRwYqw6HuRGj7b6Cftu/YReQVVGEQftFj+20?= =?iso-8859-1?Q?SCvkuoaKLYgO2LdA8R+88XYElGXkxycb3o5kzZv7vV+OqihcuY7A3B6987?= =?iso-8859-1?Q?DtAOenNaaAVUfN2GVEOrTuWA10goWdQMfbKh/CHT7JPYbK0WJ7DtmLJNhk?= =?iso-8859-1?Q?bqbkbpC6prrFKc+l89vLMMV3CYxMGHEmGorsr5y3y0Zs5DjabR1FFhI1kk?= =?iso-8859-1?Q?EP9FlSkTyovRjBF86I/0q0iGqGjg2T6E0gdDOxA6AePXVI0vEM0IqtePtN?= =?iso-8859-1?Q?la9WWwz0+7Rw8vyTc9txuxWziDy/zPT0sutRgIByzXbJ5WpFfQ2TyXRDv/?= =?iso-8859-1?Q?YPPM69pp06gprkHodwV6YbP3v97D4asbJJE+d5+1h+ZzSTUFN72QEB/cRu?= =?iso-8859-1?Q?Dxf2d9/lpTqD7bCH0zeXzLJbPTphldZ0HSU0fvcq1hP1Zwjg73kTraWSGh?= =?iso-8859-1?Q?Ld+cw0rBsNIdyNMzSSbpGvhnEWpHhX6ZaOQvOIZbIGlMOvr1Ir5OXV/Q?= =?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: cf6a73ab-b075-41e2-c84a-08dbeadeac0c X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:28.4682 (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: ij2NdnIf/X4e0quBWY/QuS4bRPK0Dj04HZtqxU0pSZYYGMDo8ZaKuxM6fecacZPhVpx1c4CmXev+yxLKSSKzooi/a388Oo5gLcQPiFU48H0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: jyXU3_qtO9KUIEeBKVo1c3iN_2BWT4-0 X-Proofpoint-ORIG-GUID: jyXU3_qtO9KUIEeBKVo1c3iN_2BWT4-0 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 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.133.242; envelope-from=prvs=5689374ac6=volodymyr_babchuk@epam.com; helo=mx0a-0039f301.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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: 1700604690089100005 Content-Type: text/plain; charset="utf-8" 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. And the toolstack should then pass max_vcpus using "-smp" arg. 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 04:47:46 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=1700604672; cv=pass; d=zohomail.com; s=zohoarc; b=a8x/qgdxah6AoDqBVkT5KmpwX6hRRn0ypvbMaeCO+Xdvd1dFICjgFiVfEBwOW+wr/sKLYF1gCeBDetTs3JZfviLlVIyDSQXsk2kNGEnPogiHnozN2ZhsW25yf2Tn64RoHXfg7Jli3ftqRP98IYaKdweiEBUOXHh7U7iuFTj5LZA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604672; 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=KT/fLYQ9fFiiDzgzvoIB754+ETMkPOQmFAJYlsPG/PY=; b=Yvis9AKyMbD1HwERPnjU1a3dgyAtLPxQuqf0qArZnIrgtIqkPFmFB8QHdju97zN12bZli7fI0cnd4jZzdkZrnJTDGamDEGw8M2sCjogR1spv70H7lkinz+hoNPItIeTTC7JfqAUeOFLFL+5pTkzDgalweOukwr+QpWewXZ8h3Ms= 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 1700604672981470.9037131756569; Tue, 21 Nov 2023 14:11:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.638305.994753 (Exim 4.92) (envelope-from ) id 1r5YxE-0007O8-AE; Tue, 21 Nov 2023 22:10:48 +0000 Received: by outflank-mailman (output) from mailman id 638305.994753; Tue, 21 Nov 2023 22:10:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5YxE-0007Nx-73; Tue, 21 Nov 2023 22:10:48 +0000 Received: by outflank-mailman (input) for mailman id 638305; Tue, 21 Nov 2023 22:10:47 +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 1r5YxC-0005zW-Ul for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 22:10:47 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d092cf49-88ba-11ee-9b0e-b553b5be7939; Tue, 21 Nov 2023 23:10:45 +0100 (CET) Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1G031085; Tue, 21 Nov 2023 22:10:37 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:37 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:29 +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.7002.028; Tue, 21 Nov 2023 22:10:29 +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: d092cf49-88ba-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QX3ln/gaH4iCkGvOG3Hg7dTzsgvUZNFdBN/XvUSAjS7bGgptkeiYtrG7rERiKhogUfCDmuNVuuQvuFJOaVSO1BD+HIVZOWnkPF+6tPquXE9+i4ApOa7NE/h7R6lhJr2dWMoH1+4YQ0QJb7cZIJl8pgrfpYadjxTo5t0c1ruM2UZ6svq34+M47JQXZtXz8ZMhDCY02L2E02AjvxHfFGmMM8qEeu4MLCEsVRNf48bZnE1fkZiLEGimB7Y8By1bRnSMx4vJE48dP36sR/4AC14yXOt4ftyx5GpU8jUOUQJuTnZDPhgwKyDym773zoneYQHtaNcxgEyThSBjbum4Q6Tc8g== 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=KT/fLYQ9fFiiDzgzvoIB754+ETMkPOQmFAJYlsPG/PY=; b=UFKwSUgz5lO5DLcVMa8pfV2bkHDgozrRmTuqqrFdd813w6o0B9pIrlyAn7JIZo8A+Ajl7IXs85i9arj7ESXrLQuhN4foHT7q442kJlUtMMbV1dsqt43LwEGP1sHXcpseljbg8iE4Gzn2RJ3boZJSH6d9hMi0iLW36KqzKHajPzSjHQySLN1RKntM/7OoAXAxsDwMHKPY99NAobQFCSXQm9AiaQx3LwXl5zzgqLdu4NS1XRnVHzF204ji61VMg7mMqbq1Edr96YoVN1w4k7N3T/pDJlsewlW4Yr1CkCnTK4XHgWxAgV56XD7Kshh4VazTYjbrMpd+oQ+qpdv6h6aHAA== 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=KT/fLYQ9fFiiDzgzvoIB754+ETMkPOQmFAJYlsPG/PY=; b=amevb7n8hxqYpFi6UwB5P94xDa484amZPMdBw35ylSAo+9xqr/HfXvL/UGthOpDZsFjocPrBttuBIqB7lX//Sd9A6ASgC05DRrAI15zK6rzA+Deom0LzY//Mh+rbXI48Vfu/7pc6uwJtGgrT9/AmkG99gz0veZoDtdZOZR33tCMJbYd3t5yfGfhM7xe5jmkS1L28QIN6pNMuQzFC+pmjAxCZC9yifWl56hRQ0rUcG9S5K0U8PVQFjAqp1w1ylMzWJ/OZ40zH98OUXqdKgt3qFsi+qXlKCwCt3L5Po2V2CgP/Ser1bu71OgguAkjaP/eoB0ZlMxST8Z7LCqN9K8EWhQ== 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 v2 6/6] xen_arm: Add virtual PCIe host bridge support Thread-Topic: [PATCH v2 6/6] xen_arm: Add virtual PCIe host bridge support Thread-Index: AQHaHMeJqHnam8LJkECFe490J2r1JA== Date: Tue, 21 Nov 2023 22:10:28 +0000 Message-ID: <20231121221023.419901-7-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-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_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: 48ecf155-e2c1-43b8-8a0d-08dbeadeac4f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PZ11tRi6O1zWULc0iNQLn3CLjxUwlfvAzP6sJOyI9HsEjI/5mJ6zK4Q9UIVmE2TFCpUN4fRKZQV2WOSV6J3V3LJD6LlS/5yOwsEKe+K9cVJwUHDkUVRQ0A+5RbKYJz3TIpWwlAdevd2Vq5J6ZkymfoxCPcrTimWRus5+AOf4Kn7WhHhojz7W9YZFPf7X1L/Tb0+hXsIDQm/37DGxcxlr3h1QNv0vQXWfGO3EOvY4uaJgMn852zjWKzze7J5GX+MD3dD/qS9ULbWq7W3mcopxk44qgMWAUA8dPVXX4947RuDHyGSBv13Vp1z8vJ66wLFPlrQCwVSY1apgozSkFgte+i+jC+PLWoW1hJ0MGhKG5ci+V4G5wj5dHyzD3lFCooJWuzwKcSGW59IqQ8WQBIsKpGF8ckz+VABgRYjlZiGSVxkyvgc48fj9wB0bP7ZjSOUeGofKXHoWZkjoXyvlwE5WDFaFINUs85iWhlwZ0Q7+BINhQkPGy6TaZ9Rp0Sm2zic5Jrl/Hz7PuZNMexQod4cS9f0RdLCBskcPjFU8VaBdAG9sQTumC3mjiP7b4JQz3+7Br0Z7uPcu4Evs4nJYMxR6PB2B71q7JauimVwMsqgG4hK2JTHok0pSxebLu1j+YSYu 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?4cjwrqnKrg8523Z5oL/N5GkkeLhyfkE9UbrwB+DEIVZaHKGUcUECobEtVa?= =?iso-8859-1?Q?xEZQZhebB85B3nuu4AUAwCQwcHTM7H8HCYOdetIq098rHbh3ApII26Yfko?= =?iso-8859-1?Q?rqpPc09rqYbElGB2Cc/7zPSrqXvb3hH7hxQNhFJrkNzDsyqp/d6vNgzHEd?= =?iso-8859-1?Q?4CSoTk04HEEYIglriXqoRHCNTng0ozLvwCZY+mp9CEJ8p8IIs8u3ZDqU+P?= =?iso-8859-1?Q?3hevZjj4B0MkFzBRxtX9eGRYnyJhYjATBFmhVfGCs+t+TZuzceP1pI6/M1?= =?iso-8859-1?Q?YzHs1nWe1szJx+CHhtq/XnGy4cLT5m/u7TM+Y5V+fbvjMimHmdfZZgstP2?= =?iso-8859-1?Q?e+0lZRgdpZ3NGvqNjhyz+2fkFxs/1krs16WHdBM1oDVzFvotegSnegth6h?= =?iso-8859-1?Q?RRS4afZJXWJRrWQ2pQoCVdvpGVbZ9pvd0eAks2pWVYUf73dhUX1+nsDjY6?= =?iso-8859-1?Q?cWnUl/isAz2G66YGhk0mIDiD667n4vrNyug/jLi5KHSSE8h9SBhhrITTp5?= =?iso-8859-1?Q?jmgI5b8LsIgi7qpcgpP9xo1o9E00cz73bnv1AjnhBeZgLkW0o/B4k8hlNW?= =?iso-8859-1?Q?oKiwXvj2mJcCf4/xiUJDx3giCvGvb4VcYVvhcckyyBtLRUkQB8EeDYQEzT?= =?iso-8859-1?Q?pa05VJ7d8Wp7MEVTo4gi/SaxWF9Agrs8g4A+h+LnYN7jh/zKcGFccALMOm?= =?iso-8859-1?Q?Vw4n8wmiI6YoG+cbXPDE1Ss9wNtLxXz9psgzflW0jGcsKKpYxI2BsPDX+e?= =?iso-8859-1?Q?/HHu5lrBhf0TwUxNYpFUtLFD/favdZbyeVc5TjT87wkRCZTE33UbeIRB3/?= =?iso-8859-1?Q?TQ6JedwxSueXdHUeh4GQU+D+vjE8lhy6cD1zl8Nx9N9dn9OQuN0RHXi6Y6?= =?iso-8859-1?Q?ezvGuEH0AuuUh/WIkUMWU/JnP6VuJ61yh/R/y0PqujcIw0P5+QnogoIOul?= =?iso-8859-1?Q?+Z4uiPviua+DUkwUds+dUR87ERad1+HUncSYjFPGIQ95tAj5oBmk67mxAA?= =?iso-8859-1?Q?c3lxDTC4VuM393zG8BBC6tHzPd1bA4QNAUq6ZPsA3pF6qLv2vBdShNIFup?= =?iso-8859-1?Q?ha4tAVkyFCMsnqDt4TK07F7WY27/yYP3WsSIWfrN8d+4vNsRLkTdNs2lPN?= =?iso-8859-1?Q?SNQuihIFIjCGYcb2x237DHF8ewdxjiaBhdCSwB1GbV9zNs5IvB8RWQOG7Z?= =?iso-8859-1?Q?EpEroAy96bIryj2RPjwu0VjmCPF8xUXkntJAJZSTWJ6VJsBAZPWhFZip3N?= =?iso-8859-1?Q?0Lh163mY5biJQfP6Qr65NJYGO9A9TUhnJvXbpgQlqkN0HrNYim9hwlKuqr?= =?iso-8859-1?Q?9tplYiKD0Bn24KNpuHxwMx63Vm4LQNrWamR2PsSl6GTiz7Fa1O//wzK1Pk?= =?iso-8859-1?Q?vN5kCHsOcfegRz7eDNebaJX9N4vwcgOBCzVpXaXG1KeMgUkUlMOJN7k5RX?= =?iso-8859-1?Q?fcxYhoZ8I/0Jub0KsEVbbDZZgktoykgB+rFd5jPKNOJytwVc/bG/uUbR37?= =?iso-8859-1?Q?DkPex4NTY1I89RTllZxDhSdaX4bJB+sxJm6Y2MiqIz1jSAsLr0YPiiNCB1?= =?iso-8859-1?Q?v9NMmBEkRKjGetijyFfeEI3R3QGOAfPhp66cBzaw1GivYQ4s75i8J6gGTN?= =?iso-8859-1?Q?jpMy3l4bJnfZx4TmJG+1YGQClBE+3ROILBKPdPZ9dAL+QnNYYrKM5kUA?= =?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: 48ecf155-e2c1-43b8-8a0d-08dbeadeac4f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:28.8471 (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: 7fbYNrbwYkBiGBLZzwcq02Hjyn6GknN7vHEKK3b3Dh4tWRLZyyvvSUNfPyTNYKQhB+XPV6A23/zRBxWHzIDvyC5Dcc9hYaQtPGlEHjAJYRU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: 71kriaRaYKayEQ3I8ucEsnwH5hDVrM_V X-Proofpoint-ORIG-GUID: 71kriaRaYKayEQ3I8ucEsnwH5hDVrM_V 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700604674065100002 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 brige resources with xenstore. 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 from v1: - 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 | 186 ++++++++++++++++++++++++++++++++++++ hw/xen/xen-hvm-common.c | 9 +- include/hw/xen/xen_native.h | 8 +- 3 files changed, 200 insertions(+), 3 deletions(-) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index b9c3ae14b6..d506d55d0f 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -22,6 +22,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qapi/qapi-commands-migration.h" #include "qapi/visitor.h" @@ -34,6 +35,9 @@ #include "hw/xen/xen-hvm-common.h" #include "sysemu/tpm.h" #include "hw/xen/arch_hvm.h" +#include "exec/address-spaces.h" +#include "hw/pci-host/gpex.h" +#include "hw/virtio/virtio-pci.h" =20 #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) @@ -58,6 +62,11 @@ struct XenArmState { struct { uint64_t tpm_base_addr; } cfg; + + MemMapEntry pcie_mmio; + MemMapEntry pcie_ecam; + MemMapEntry pcie_mmio_high; + int pcie_irq; }; =20 static MemoryRegion ram_lo, ram_hi; @@ -73,6 +82,7 @@ static MemoryRegion ram_lo, ram_hi; #define NR_VIRTIO_MMIO_DEVICES \ (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) =20 +/* 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 +139,176 @@ static void xen_init_ram(MachineState *machine) } } =20 +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->pcie_ecam.size); + memory_region_add_subregion(get_system_memory(), xam->pcie_ecam.base, + 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->pcie_mmio.base, + xam->pcie_mmio.size); + memory_region_add_subregion(get_system_memory(), xam->pcie_mmio.base, + 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->pcie_mmio_high.base, + xam->pcie_mmio_high.size); + memory_region_add_subregion(get_system_memory(), xam->pcie_mmio_high.b= ase, + 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->pcie_irq + i); + + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); + gpex_set_irq_num(GPEX_HOST(dev), i, xam->pcie_irq + i); + } + + DPRINTF("Created PCIe host bridge\n"); +} + +static bool xen_read_pcie_prop(XenArmState *xam, unsigned int xen_domid, + const char *prop_name, unsigned long *data) +{ + char path[128], *value =3D NULL; + unsigned int len; + bool ret =3D true; + + snprintf(path, sizeof(path), "device-model/%d/pcie_host/%s", + xen_domid, prop_name); + value =3D xs_read(xam->state->xenstore, XBT_NULL, path, &len); + + if (qemu_strtou64(value, NULL, 16, data)) { + error_report("xenpv: Failed to get 'pcie_host/%s' prop", + prop_name); + ret =3D false; + } + + free(value); + + return ret; +} + +static int xen_get_pcie_params(XenArmState *xam) +{ + char path[128], *value =3D NULL, **entries =3D NULL; + unsigned int len, tmp; + int rc =3D -1; + + snprintf(path, sizeof(path), "device-model/%d/pcie_host", + xen_domid); + entries =3D xs_directory(xam->state->xenstore, XBT_NULL, path, &len); + if (entries =3D=3D NULL) { + error_report("xenpv: 'pcie_host' dir is not present"); + return -1; + } + free(entries); + if (len !=3D 9) { + error_report("xenpv: Unexpected number of entries in 'pcie_host' d= ir"); + goto out; + } + + snprintf(path, sizeof(path), "device-model/%d/pcie_host/id", + xen_domid); + value =3D xs_read(xam->state->xenstore, XBT_NULL, path, &len); + if (qemu_strtoui(value, NULL, 10, &tmp)) { + error_report("xenpv: Failed to get 'pcie_host/id' prop"); + goto out; + } + free(value); + value =3D NULL; + if (tmp > 0xffff) { + error_report("xenpv: Wrong 'pcie_host/id' value %u", tmp); + goto out; + } + xen_pci_segment =3D tmp; + + if (!xen_read_pcie_prop(xam, xen_domid, "ecam_base", + &xam->pcie_ecam.base)) { + goto out; + } + + if (!xen_read_pcie_prop(xam, xen_domid, "ecam_size", + &xam->pcie_ecam.size)) { + goto out; + } + + if (!xen_read_pcie_prop(xam, xen_domid, "mem_base", + &xam->pcie_mmio.base)) { + goto out; + } + + if (!xen_read_pcie_prop(xam, xen_domid, "mem_size", + &xam->pcie_mmio.base)) { + goto out; + } + + if (!xen_read_pcie_prop(xam, xen_domid, "prefetch_mem_base", + &xam->pcie_mmio_high.base)) { + goto out; + } + + if (!xen_read_pcie_prop(xam, xen_domid, "prefetch_mem_size", + &xam->pcie_mmio_high.size)) { + goto out; + } + + snprintf(path, sizeof(path), "device-model/%d/pcie_host/irq_first", + xen_domid); + value =3D xs_read(xam->state->xenstore, XBT_NULL, path, &len); + if (qemu_strtoi(value, NULL, 10, &xam->pcie_irq)) { + error_report("xenpv: Failed to get 'pcie_host/irq_first' prop"); + goto out; + } + free(value); + value =3D NULL; + DPRINTF("PCIe host bridge: irq_first %u\n", xam->pcie_irq); + + snprintf(path, sizeof(path), "device-model/%d/pcie_host/num_irqs", + xen_domid); + value =3D xs_read(xam->state->xenstore, XBT_NULL, path, &len); + if (qemu_strtoui(value, NULL, 10, &tmp)) { + error_report("xenpv: Failed to get 'pcie_host/num_irqs' prop"); + goto out; + } + free(value); + value =3D NULL; + if (tmp !=3D GPEX_NUM_IRQS) { + error_report("xenpv: Wrong 'pcie_host/num_irqs' value %u", tmp); + goto out; + } + DPRINTF("PCIe host bridge: num_irqs %u\n", tmp); + + rc =3D 0; +out: + if (value) { + free(value); + } + + return rc; +} + void arch_handle_ioreq(XenIOState *state, ioreq_t *req) { hw_error("Invalid ioreq type 0x%x\n", req->type); @@ -189,6 +369,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_get_pcie_params(xam)) { + xen_create_pcie(xam); + } else { + DPRINTF("PCIe host bridge is not available," + "only virtio-mmio can be used\n"); + } =20 #ifdef CONFIG_TPM if (xam->cfg.tpm_base_addr) { diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 565dc39c8f..0f78f15057 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