From patchwork Tue Nov 21 22:10:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13463686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6EBADC61D97 for ; Tue, 21 Nov 2023 22:10:50 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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?JuLA2Hn7jFhlkk9wc7smzue?= =?iso-8859-1?q?Oc0Lt4aKTk8KWY68kzpZxd80M60sEXISQWgJfGVl7lqYO4mLVszCcZtOcEcb?= =?iso-8859-1?q?QD9B8NH0x7c+4it0sBWem9IKKmt7CqRMu/RW8DZH9qhvnj3jC9zYEPk9mB6n?= =?iso-8859-1?q?i7P27EPVrnB0xvNTVZCLndh/J3WO0zVS4Wt00oi5P7j7Wkj5huO/nmLi5JYE?= =?iso-8859-1?q?C7o5e8HWAyxv7bGtR6p/dHb2lK1+Bn0J2HlcmyOG0PiJ/xAVUupLObZUWM+K?= =?iso-8859-1?q?HJZz5DuMzUdskRNkWC1xRBo0N1vBQ1EQCsrpq7uzgVMqd83mzfY1/1Hs1u91?= =?iso-8859-1?q?K6Mfal4gUhESrORThQUBDHdZSg6HJbrJ2m3/m3Pq0vp6ptxJF2QZo3XB0+R/?= =?iso-8859-1?q?3/wVAyT2aDIBnDtGO8vnprB3QWPCfipxEduxw9WVVd5sVrIbvirD33umYbVN?= =?iso-8859-1?q?e9YYD3NZuZwFyyr8/vTb55hsbuk9wSjehpFs5JyZ5DT7JdMTmnftPSUFFX8Q?= =?iso-8859-1?q?b+FdIsjqMNnsH4w9sEX2FjQTywkvunjolMaPM3WYVXv8ZxB+rqnmMacO8zeK?= =?iso-8859-1?q?ww18POYboDTYUa6xNS6mULSRmIvJiggg6dWo2Nxd2pFNZMcsBn5JBpT/91wP?= =?iso-8859-1?q?hhJo4ErQZmmmCM2J8pb2NLyoDfZk/Xk9NJhieYtkBIqppIFQ/ooVpykgVFKu?= =?iso-8859-1?q?+JfrDYwKuD6oI5c7qFi2tzDWOBOQtQSUFcFxc4c+lKuz9Oear04gH5Ohp0Ab?= =?iso-8859-1?q?t8rriibMlYzn7xpOLHtqsWr9PAtsPxNy3g5W402AUnDQOrTh+99yjlCi8cQ/?= =?iso-8859-1?q?8gHhvxyLCmjkv4cgrmb2419uVl/D4P7ctP1cjLx0w6L4r4xk6ofmjFbWOj4V?= =?iso-8859-1?q?i987jiUYMIs2M4BgCWh/EEgnmyPiUy4kSVnKh5xEy2L/DipE3fx5+/+uL5hN?= =?iso-8859-1?q?hiQfPTs3kqiykhnuczez8vnhSZMbFsAwtl/Eo0Z0Mfq3v3YFUDV8n2jDzEoF?= =?iso-8859-1?q?HuERFva/PrsgWUAz9l8Y60ojzOPACBm5bzPvwTAjzHqRKq8w5k38qfHiNL5P?= =?iso-8859-1?q?aRNPU1AbRgjUCMtTndJbOCO4lR2997Ai6n7XyCkBDqNuSTnVf1RRPPBnFzv5?= =?iso-8859-1?q?CkOt1WI4bnxYGqy8XSHI7uXiLFh+i+eR/iaPbgZHYJVFOGO+EqJgpsF9AxR4?= =?iso-8859-1?q?h9MmBYMo2KZomTZCwGQPtpgjvtPib+D0MRHU34ILllsab96SLGV0erVzJBi0?= =?iso-8859-1?q?mfjrtJABQC9S4xFo3w23lYiNvJO8tnIZ3m5jRmHlbwRT1TG39AuR0INqlQia?= =?iso-8859-1?q?koROLbYmPqXBDj/15i5sYIXaN3V8hsu/f0JLyqSDMqjw6cQTMukZAiZaulkj?= =?iso-8859-1?q?m2V6SD9vUMJYOYW30TFPGL2s/dW7BIlV9Sk/iU9YSqMGjv2sOKf6wZ05KCDS?= =?iso-8859-1?q?LGT5UE9ZTjk/arLaMiYYJtQXB0ZpRSR8WQcXTbrxMS1aSvQrLddiRDcoegew?= =?iso-8859-1?q?S4z79GUMx/UNHdo3ONpyTb3jbYWmwMpX9qXmcfOvYuooQZsQb8YbWtbLUjPz?= =?iso-8859-1?q?aOwoaa0Fntc4DcCALn/HN4l9/acLUggsLOmkvE7gVIQ+oxGdMaoXBAEq/Npm?= =?iso-8859-1?q?3ZV8UKx1TBtRsIsoXPni5XWyJPNoHbRR8VzvNYw=3D=3D?= 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 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(XenBackendInstance *backend, blockdev->iothread = iothread; blockdev->drive = drive; + xendev->backend = backend; 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; 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(XenBackendInstance *backend, goto fail; } + xendev->backend = backend; if (qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), errp)) { - xen_backend_set_device(backend, xendev); goto done; } 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 *backend, net->dev = number; memcpy(&net->conf.macaddr, &mac, sizeof(mac)); + xendev->backend = backend; if (qdev_realize_and_unref(DEVICE(xendev), BUS(xenbus), errp)) { - xen_backend_set_device(backend, xendev); return; } 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, Error **errp) } } + if (xendev->backend) { + xen_backend_set_device(xendev->backend, xendev); + } + xendev->exit.notify = 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 @@ #include "hw/xen/xen-bus.h" -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" typedef struct XenEventChannel XenEventChannel; +typedef struct XenBackendInstance XenBackendInstance; struct XenDevice { DeviceState qdev; + XenBackendInstance *backend; domid_t frontend_id; char *name; struct qemu_xs_handle *xsh; From patchwork Tue Nov 21 22:10:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13463688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13FB1C61D98 for ; Tue, 21 Nov 2023 22:11:01 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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+v98n?= =?iso-8859-1?q?c4nReKWzxwVyg3uxPxddiID0KIy0etDTToVp41Dv9wTHhFLX7bfJg+VQ56rv?= =?iso-8859-1?q?q+JgXmyXS7gn4cFtA6CXIwi/VeOAL/zSKq8g+KOSY5Q9Bai0JgXX5l9K8+8v?= =?iso-8859-1?q?zPSk86l/klX6aSumnRl+QUjkQwkaTqJMSFV22QQdBvn4CRq+QCD2mQFd6O02?= =?iso-8859-1?q?8TuOk0KpLq3mLhKmbL4HBUkA9JcrD0ZcMJlQdZ708cibLPHEhWIq6jQk9nyD?= =?iso-8859-1?q?D90W4Rb/cmiC6sH9/dJq2190cLYkGzjT401MaeZuHM/5aqmFlJMfemAvlSeT?= =?iso-8859-1?q?W828OlGwDvR7bfjq2wrtRR+5D4xR/Cta33E6jLCVjJoLY+XYlgzw9+rIZjCM?= =?iso-8859-1?q?zVXXUxl97rE8eJnX8Jm6kVPHmXLPhKPN7CEzgyWj6+N3PdWYiMwERfmnixJX?= =?iso-8859-1?q?Ao9b35210BdMz4luFDYCQj0aC8wiyHEcoGkuY6vEaI6zu7mdvnkmntd86Dn8?= =?iso-8859-1?q?Kp4n3nQL+/aK58rEA6ZYNGDKfDeO2/9zokQ+gkWdkYmZ3kiVsje/n1+Zx0rF?= =?iso-8859-1?q?yXK3HW7MYos91otKfE/EuvKdLdzGsIsXdS9PLwn28n5Ki2Vy+K5NGofFMON0?= =?iso-8859-1?q?tk6uHYiVeGAhuG5992gi4qcr+kpWQhAUmTJ08Tyz6SX1pa5rAYAWcdLVwV9K?= =?iso-8859-1?q?ulnOag1p4rGn/jInGabQWMlWyTcWHyUjPRINSdyYfVSVDYTcIEdAUYQNdkLa?= =?iso-8859-1?q?TPu3a5uSEDnYZuS1aiu628FyCMH6ET5kJLUDY8K5dAH9kGGFFMadDUEe4WHn?= =?iso-8859-1?q?iYlc7ouUW0N24J3+yGfwv646UK6t1uDy4A1H+CpZZeOEWK68DPzDU3njZxKD?= =?iso-8859-1?q?7OFEG/fkiPPKggVkG2IFVih63b71duNXsZ1DF52uR7gC1XOu891uCZVAIWnP?= =?iso-8859-1?q?gXL4rNpWg936m9ekoBl3Z/riYPWwR0flBeoA7OPBt+Hd8ZJUghbK8Y1rcUIu?= =?iso-8859-1?q?PseNCW1GIvsm4bi69uFlr40LMDoxa7UdwJaygFSCZHKOsq7Vv06k6zA2utO+?= =?iso-8859-1?q?+pKtgusjuweo3E1WOnehSSK+E7xozjPJxTlzWsso3ExcIp1eMuLD/FppJPvK?= =?iso-8859-1?q?1GyfDMf8wpTmto59oSJg09hhai3GRGLKYKDdRnKXqJEfODHcGXUxJ25jjwmD?= =?iso-8859-1?q?HE0lchAg/fIrUMjqpS+jF7vrF+o2ArELMWCZb5drk3eChJDs8orTIOeg/iXW?= =?iso-8859-1?q?7bKiF9cfL3IAYvKg7kV/55UEBp/5huGDaWKYcBVCzNCGAgo+r/0vM5AMpCZu?= =?iso-8859-1?q?q+5Qh1IHL8lJsRJUcgMiAmqPkzjzUu0LTxG76Xw6n5T05V5Blywks2ph7VY1?= =?iso-8859-1?q?1Bw0hBHwlkynW6eAV0oZPEguUVwAfgxw3XQKL5q3zRCkEhoSmPPv/3up5O1X?= =?iso-8859-1?q?vUXLkmtlqsGTO9EXURkTM4TtEw7rgh1cF3vgO02AmJDngD45HA3lN+B98zSg?= =?iso-8859-1?q?SqUEQ3Q7E86d4dToZWICLQSaVZGQ3BzqULbLSR08x5lJm9rd44Gm/c5sLyfr?= =?iso-8859-1?q?kCQyvEZKguOXulKkP0Y+/emGgaE9WmqrzNRrC5+30jUEuoM/MA2E6gXij5aJ?= =?iso-8859-1?q?PWEEWgIupn/IxGGLxSamFQZfoAQ+7HnQnihdBNA=3D=3D?= 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 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, Error **errp) xen_device_backend_printf(xendev, "info", "%u", blockdev->info); - 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); + } xen_block_set_size(blockdev); 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, Error **errp) trace_xen_console_realize(con->dev, object_get_typename(OBJECT(cs))); - 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, Error **errp) qemu_macaddr_default_if_unset(&netdev->conf.macaddr); - 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]); - + 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 = 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 *xendev) g_assert(xenbus->xsh); - 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 = NULL; @@ -764,8 +766,10 @@ static void xen_device_frontend_destroy(XenDevice *xendev) g_assert(xenbus->xsh); - 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 = NULL; @@ -1063,7 +1067,7 @@ static void xen_device_realize(DeviceState *dev, Error **errp) xen_device_backend_set_online(xendev, true); xen_device_backend_set_state(xendev, XenbusStateInitWait); - 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", From patchwork Tue Nov 21 22:10:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13463689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE509C61D85 for ; Tue, 21 Nov 2023 22:11:04 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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/xwBQMOTpl?= =?iso-8859-1?q?QFonOYjE+lTe4Lw0/Hv8WxpzFe3TT8R44l8tBefqDfsdRaCs5rTSTM4Dc21c?= =?iso-8859-1?q?wj5ASiB/PR5CxiWv/JiAIXXX/nHSqQwSXVQPjWttinkA+qEXxrnnEuJ93tG4?= =?iso-8859-1?q?QzCdQFEuotTwq18RkXyT5eLx9IIwLlP0cGIr/zi3FTyFMtUwhMZyK4nzWKcy?= =?iso-8859-1?q?g7VOlXNGw7Dir76/EsLlGF4wMRHJ3wMwb7XZ1dnaSH/SaR3/wgioPRJAC/YF?= =?iso-8859-1?q?dNTfaIHP9e6WElJhDR9KW1/PmmhlhsJjwiB400g3tWYP+zD8TwcYBRfOAglp?= =?iso-8859-1?q?ULWc0pdQbYjHbMb/Cx8YYMpq7AzTqZYhuZGcC+ru2hIY4GH39Z5AtDrnw2jb?= =?iso-8859-1?q?aFTdg3DZISAdRBBOfyX1iRuqDmHcsskmCzDbgq2XmVHVbwpHA/2Mr37W0Gq7?= =?iso-8859-1?q?E93Wtn57XCBiQ/be/e5ZPrCXfkPIENLXFu8REUWgEcKy1YZST/3vN9zGNE1W?= =?iso-8859-1?q?75RC4SoKYATVZtOm6CW8RaJsjDIn1nYVdvqiPJJ17ky/rLNFrMbWP8B3/OEo?= =?iso-8859-1?q?e1dPqfj+F4SAEPSc2ORhsbOCbYz3ERHdmm5/vQu+k/gIukuLvhOXGUSncJHQ?= =?iso-8859-1?q?mC8uFDuJy+Ov2L3UlDHhFSY1rkYWb64rk/USKy1d6MOKlUhtMc7eNcXFh+3F?= =?iso-8859-1?q?7hqK6PBa2xZFZ6MQxCMe/oyvgD8lhdpqHbCiZPTKLgfwXVROgobqkWDfLOXO?= =?iso-8859-1?q?LupC9/LChijyFR4pScCO03bm2CpUwHsFr++mKV1zwhgiUQryankVYeGlXvHk?= =?iso-8859-1?q?Df9hvB3hfUh54IAop4siQ4QF/NKaa8D6YcgjA9dl4gJIu43cJf63IBkTlm+S?= =?iso-8859-1?q?7hJEEnfUJ+9apljErrTIYe2EPPasqNsGti8wffQhGiew6COBmCF6X45GU3Wp?= =?iso-8859-1?q?bSC5NKM42hpkecXckNzGwg+EaM3SpLnA7ZNa4u7YMrHVlb6vhgEXgR/xVCVk?= =?iso-8859-1?q?4ugpEVbc1QDH/99Nl3S32PscN0tzVihujXkWKn1DCqsXO79XaZjA6DX2a2le?= =?iso-8859-1?q?s+ulgHz4Jhnj6RuifNtXbHTgUEcN7aWnGPSeA3weecNoI+GblsjR2GdVObmO?= =?iso-8859-1?q?bGljcAFyWespgR4Qm3+LLX3GhZDqbxUM91b4YEDX7NgL4pYG1uXusYRP5vu0?= =?iso-8859-1?q?O8YvBdkrz4ylrdUG6fJdeGPMthzwZLLMgQ7Fouh26NlHcFKx8Wa+TMgH6dUm?= =?iso-8859-1?q?QunkEgM03IdjxOMMxs93NK8W/V9PUT8ryowi+6qdA7toyu/tCs4/O1bIdUPG?= =?iso-8859-1?q?QD/XHk22gZTU6Kw5aW7p7/MkyDsHQlWB/wuA9Lu9jsqYQOSDTLvI7f3GRXHP?= =?iso-8859-1?q?+Oy9YX14SpawBvhUwJzlPQ69AwMm7Zsi/UGdXAdhN9u7CNJ22JH1sfOunSHt?= =?iso-8859-1?q?RfKveMWr9j9UMYVLz0X6da/ykpOG7VemJlYndRSS8m3naMGQS4GC73AEQ1Gi?= =?iso-8859-1?q?2ee+fzVnxPPV8GdIYNqkR2lyzIHS39ODvQISz3NFFWXLywYyTC+Y5sGVZ5U6?= =?iso-8859-1?q?hsuB0epukWfKr8CTd1skeK/tslRYOzkp/ZzdVP1wqYm4zlxcS0rV17krshRX?= =?iso-8859-1?q?Jcw6T0DZwQLAhWpmXl57h22ug3aNlV0P04T/hiw=3D=3D?= 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 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, xs_transaction_t t, return false; } + if (owner == XS_PRESERVE_OWNER) { + GList *prev_perms; + char letter; + + err = xs_impl_get_perms(h->impl, 0, t, path, &prev_perms); + if (err) { + errno = err; + return false; + } + + if (sscanf(prev_perms->data, "%c%u", &letter, &owner) != 2) { + errno = EFAULT; + g_list_free_full(prev_perms, g_free); + return false; + } + g_list_free_full(prev_perms, g_free); + } + perms_list = g_list_append(perms_list, xs_perm_as_string(XS_PERM_NONE, owner)); perms_list = 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; } + if (owner == XS_PRESERVE_OWNER) { + struct xs_permissions *tmp; + unsigned int num; + + tmp = xs_get_permissions(h->xsh, t, path, &num); + if (tmp == NULL) { + return false; + } + perms_list[0].id = 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 +/* + * 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); From patchwork Tue Nov 21 22:10:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13463687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30959C61D85 for ; Tue, 21 Nov 2023 22:10:53 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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?G4Jv0XESz3TozlyoYvkV0ym?= =?iso-8859-1?q?ZDP24gPbUsPL/Z0eJvav2WndcnaVdXxA+rTBW7OcZ81/7qKmBnKvymh4sZ2b?= =?iso-8859-1?q?NQt8Y+l9kerXfpjXGpAZsgzOXG/GIWM3OpButV0nFSyB0T8SQrxi61qMbx1X?= =?iso-8859-1?q?UEVRpjLPk6txiqtsPDcBEKUSV2tXTKYU9h788j1iT3vy6EB1G8CoI/Yy0TYB?= =?iso-8859-1?q?uiE7kC0EhylLznD1cX6mlHhhC/3YC48hkNe2tfVntJgG8Mhaq1XOXZXv0xrt?= =?iso-8859-1?q?Lm/4dM3e05WUsbjWzS41xzG2ZzG3lyBYmg/sSqShcFY7tSSIkfMyhyOT4IHd?= =?iso-8859-1?q?AUqcbZURNUGjhyaZtDQ9OGGqtORhETj0nio53802GQPs5HAcfTrEyxA0KpeJ?= =?iso-8859-1?q?GKDXnBOR5bSy8moMn4bcnB286ClVwwuIkB6jibiKxmqhLRBLkz8nUJtdxHRq?= =?iso-8859-1?q?35l+767ffN9qQqLHrDrxRfgc6zarRAgJg8tsq4kZJy4cnlJg4ZBJjTBw7wRG?= =?iso-8859-1?q?XKg53QekooJsr+YqA4uv09qc7fxDDO0vTY4K5wxF5RKfclVThBbHOg+/9lqS?= =?iso-8859-1?q?YU2vOsbjESUpPE2XKez4zKQuKzcziAQ3aT7Bog6/HAyn4MCL63Dp8tMKZchh?= =?iso-8859-1?q?988UKtjgZcWjV04zhPx5I9kqj01xdKW4MGhPdxicy8wamQ8c6ZZEkatWC7EC?= =?iso-8859-1?q?Oy1vLBivEsD4h22x2zHFzum1s4MTg84vqEHKgykE7zYwPAQO6gDj+YEfEJqP?= =?iso-8859-1?q?yKkrRmRKT09G4bSJtwwmfQL/J58nIhsNGaF2gAQG/kTuqEV9go3X3ucRl3qM?= =?iso-8859-1?q?aDTGtv3RFqD5k9b/YJV3bR8ZCxPkXNa5AksLPPBk/QF40WC2t2SO6PQ4wCbC?= =?iso-8859-1?q?i09GwPJzuEZ+3fGShDfPIcwfcATJfpDtDObWOY+pUQxl1mx9mfYrKeRWKU2N?= =?iso-8859-1?q?FAv3o809sPYiuzTOpz/XwGQqQGHf8GvaSF84WNUhI2lP/3GcqkCoh+AnUDvv?= =?iso-8859-1?q?8y0wHlG2DplClHlMzEwfKziwpBHazU1KM9XGOJXxfQLYmwTz/WS6ZdKpT9aw?= =?iso-8859-1?q?O1vVsgIU2xQ3IxvzNGsvhJX2HfONphuMQbOrYtp3tPO2/LpbW1dELnMnqis5?= =?iso-8859-1?q?aMERlasr23+ISHGfDKfGDRNrWxYSr7PQQhoEeUF4WbpLh1kEkOm4I1Irv0tE?= =?iso-8859-1?q?PVBC8tygZYx6HkO7itMYB7fOEDPFbxlfyHVflA0hKWAaoC/hmkluigtapfW5?= =?iso-8859-1?q?cORQLz5VrKNYTt+tzM+Cbf1eF3fObvoFsfP0xnX4pVhnOyNwV233b92wMwXl?= =?iso-8859-1?q?MnmQL4UK9k4+XI2jtIZVXzXUxfcLRfbScsdpL2gAj1d+l47SDv4PxIoHC5ER?= =?iso-8859-1?q?4V7WAdOrAPN4MrieRDg6FnzS7EXfkV2bwPfOb+YWQdybDoHp1V6BdFupayKm?= =?iso-8859-1?q?JmipgzD+HbEUc/mZwtKe2cCEMOX9U0xPyPBhETN8o7OSldqhB3/ruhQMK3f0?= =?iso-8859-1?q?EDfraCBwZcM3SCXtk1B2F0ReR8Fl3uS52TTNJ+uLhVxtreGIRkLIlV1NKb44?= =?iso-8859-1?q?NgnIHwig9xw1U5HjYzp0E+Gl8I3MmiXH1NOIyOP44SzPkrXWMuPx25d+G/1X?= =?iso-8859-1?q?VT4S/UNni2GQmsdJxKePi15DehtvZcGRyXREhmQ=3D=3D?= 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 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) 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; } From patchwork Tue Nov 21 22:10:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13463690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4274AC61D97 for ; Tue, 21 Nov 2023 22:11:05 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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/N5Gk?= =?iso-8859-1?q?keLhyfkE9UbrwB+DEIVZaHKGUcUECobEtVaxEZQZhebB85B3nuu4AUAwCQwc?= =?iso-8859-1?q?HTM7H8HCYOdetIq098rHbh3ApII26YfkorqpPc09rqYbElGB2Cc/7zPSrqXv?= =?iso-8859-1?q?b3hH7hxQNhFJrkNzDsyqp/d6vNgzHEd4CSoTk04HEEYIglriXqoRHCNTng0o?= =?iso-8859-1?q?zLvwCZY+mp9CEJ8p8IIs8u3ZDqU+P3hevZjj4B0MkFzBRxtX9eGRYnyJhYjA?= =?iso-8859-1?q?TBFmhVfGCs+t+TZuzceP1pI6/M1YzHs1nWe1szJx+CHhtq/XnGy4cLT5m/u7?= =?iso-8859-1?q?TM+Y5V+fbvjMimHmdfZZgstP2e+0lZRgdpZ3NGvqNjhyz+2fkFxs/1krs16W?= =?iso-8859-1?q?HdBM1oDVzFvotegSnegth6hRRS4afZJXWJRrWQ2pQoCVdvpGVbZ9pvd0eAks?= =?iso-8859-1?q?2pWVYUf73dhUX1+nsDjY6cWnUl/isAz2G66YGhk0mIDiD667n4vrNyug/jLi?= =?iso-8859-1?q?5KHSSE8h9SBhhrITTp5jmgI5b8LsIgi7qpcgpP9xo1o9E00cz73bnv1AjnhB?= =?iso-8859-1?q?eZgLkW0o/B4k8hlNWoKiwXvj2mJcCf4/xiUJDx3giCvGvb4VcYVvhcckyyBt?= =?iso-8859-1?q?LRUkQB8EeDYQEzTpa05VJ7d8Wp7MEVTo4gi/SaxWF9Agrs8g4A+h+LnYN7jh?= =?iso-8859-1?q?/zKcGFccALMOmVw4n8wmiI6YoG+cbXPDE1Ss9wNtLxXz9psgzflW0jGcsKKp?= =?iso-8859-1?q?YxI2BsPDX+e/HHu5lrBhf0TwUxNYpFUtLFD/favdZbyeVc5TjT87wkRCZTE3?= =?iso-8859-1?q?3UbeIRB3/TQ6JedwxSueXdHUeh4GQU+D+vjE8lhy6cD1zl8Nx9N9dn9OQuN0?= =?iso-8859-1?q?RHXi6Y6ezvGuEH0AuuUh/WIkUMWU/JnP6VuJ61yh/R/y0PqujcIw0P5+Qnog?= =?iso-8859-1?q?oIOul+Z4uiPviua+DUkwUds+dUR87ERad1+HUncSYjFPGIQ95tAj5oBmk67m?= =?iso-8859-1?q?xAAc3lxDTC4VuM393zG8BBC6tHzPd1bA4QNAUq6ZPsA3pF6qLv2vBdShNIFu?= =?iso-8859-1?q?pha4tAVkyFCMsnqDt4TK07F7WY27/yYP3WsSIWfrN8d+4vNsRLkTdNs2lPNS?= =?iso-8859-1?q?NQuihIFIjCGYcb2x237DHF8ewdxjiaBhdCSwB1GbV9zNs5IvB8RWQOG7ZEpE?= =?iso-8859-1?q?roAy96bIryj2RPjwu0VjmCPF8xUXkntJAJZSTWJ6VJsBAZPWhFZip3N0Lh16?= =?iso-8859-1?q?3mY5biJQfP6Qr65NJYGO9A9TUhnJvXbpgQlqkN0HrNYim9hwlKuqr9tplYiK?= =?iso-8859-1?q?D0Bn24KNpuHxwMx63Vm4LQNrWamR2PsSl6GTiz7Fa1O//wzK1PkvN5kCHsOc?= =?iso-8859-1?q?fegRz7eDNebaJX9N4vwcgOBCzVpXaXG1KeMgUkUlMOJN7k5RXfcxYhoZ8I/0?= =?iso-8859-1?q?Jub0KsEVbbDZZgktoykgB+rFd5jPKNOJytwVc/bG/uUbR37DkPex4NTY1I89?= =?iso-8859-1?q?RTllZxDhSdaX4bJB+sxJm6Y2MiqIz1jSAsLr0YPiiNCB1v9NMmBEkRKjGeti?= =?iso-8859-1?q?jyFfeEI3R3QGOAfPhp66cBzaw1GivYQ4s75i8J6gGTNjpMy3l4bJnfZx4TmJ?= =?iso-8859-1?q?G+1YGQClBE+3ROILBKPdPZ9dAL+QnNYYrKM5kUA=3D=3D?= 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 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 @@ */ #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" #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; }; 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) +/* TODO It should be xendevicemodel_set_pci_intx_level() for PCI interrupts. */ 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) } } +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 = qdev_new(TYPE_GPEX_HOST); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + /* Map ECAM space */ + ecam_alias = g_new0(MemoryRegion, 1); + ecam_reg = 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 = g_new0(MemoryRegion, 1); + mmio_reg = 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 = 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.base, + mmio_alias_high); + + /* Legacy PCI interrupts (#INTA - #INTD) */ + for (i = 0; i < GPEX_NUM_IRQS; i++) { + qemu_irq irq = 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 = NULL; + unsigned int len; + bool ret = true; + + snprintf(path, sizeof(path), "device-model/%d/pcie_host/%s", + xen_domid, prop_name); + value = 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 = false; + } + + free(value); + + return ret; +} + +static int xen_get_pcie_params(XenArmState *xam) +{ + char path[128], *value = NULL, **entries = NULL; + unsigned int len, tmp; + int rc = -1; + + snprintf(path, sizeof(path), "device-model/%d/pcie_host", + xen_domid); + entries = xs_directory(xam->state->xenstore, XBT_NULL, path, &len); + if (entries == NULL) { + error_report("xenpv: 'pcie_host' dir is not present"); + return -1; + } + free(entries); + if (len != 9) { + error_report("xenpv: Unexpected number of entries in 'pcie_host' dir"); + goto out; + } + + snprintf(path, sizeof(path), "device-model/%d/pcie_host/id", + xen_domid); + value = 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 = NULL; + if (tmp > 0xffff) { + error_report("xenpv: Wrong 'pcie_host/id' value %u", tmp); + goto out; + } + xen_pci_segment = 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 = 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 = 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 = 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 = NULL; + if (tmp != 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 = 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); 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"); + } #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); } +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) } QLIST_FOREACH(xendev, &state->dev_list, entry) { - if (xendev->sbdf != 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)) != sbdf) { continue; } 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_addr); } +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, 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, trace_xen_unmap_pcidev(ioservid, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)); - 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));