From patchwork Sat Dec 2 01:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13476722 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 D8529C07E97 for ; Sat, 2 Dec 2023 01:41:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.645876.1008412 (Exim 4.92) (envelope-from ) id 1r9F0g-000736-Pb; Sat, 02 Dec 2023 01:41:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 645876.1008412; Sat, 02 Dec 2023 01:41:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r9F0g-00072z-LK; Sat, 02 Dec 2023 01:41:34 +0000 Received: by outflank-mailman (input) for mailman id 645876; Sat, 02 Dec 2023 01:41:33 +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 1r9F0f-00072l-0t for xen-devel@lists.xenproject.org; Sat, 02 Dec 2023 01:41:33 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id eaa68380-90b3-11ee-98e5-6d05b1d4d9a1; Sat, 02 Dec 2023 02:41:31 +0100 (CET) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 3B21X1Qm015641; Sat, 2 Dec 2023 01:41:26 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uqa3aucrx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 02 Dec 2023 01:41:26 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by AS8PR03MB7285.eurprd03.prod.outlook.com (2603:10a6:20b:2ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Sat, 2 Dec 2023 01:41:21 +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.7046.027; Sat, 2 Dec 2023 01:41:21 +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: eaa68380-90b3-11ee-98e5-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Al0hqmWcJ5SVYym2QD9l6trDde0nES0K+LUnxEcDfZ0dE+piyaYEJh6mMMezzU9cmSizQLheQIGWrte5zqc/4l3VU+9vhp60KS2DCgJr+wRoe1GulOc45J6h+4AgdwsGP44I2Nk2U/9Hs5nIvhg9J1HFu0G0kbKNGgaBuutF+6rVIZ0iUVstJqqVos3e91ytgMyuaB7paDtCcVKlYFhBRILsVv3EWUgofUwPc6h3hMcFWEoyzrIrx+XvtoXth+z5o8DJRP7NevNTRTq8Yp/8lDAKqCu9Exy6vkh7NGEHIlYswOKsIGnIkCoo+cCPJtHHlrWHesR9+c8lwJXDHjL0tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xHbTU4afcP4VPCt7c5t9HdrtExRFqhrJyZbbFA7antU=; b=LXYNTES626N6WVrrtUj8y2tH9yuJhV+u7CWfoXGN5SsTJ4zj0TK/70X/+HLFhBSbJFRARGXp5YClMKw8mYN90+lrjBOrzw+K58n9sO/gKUAgKldjLmhdc9u5gFQj7ccEg8dlj/rmLFuqHDR2i1JSLRxraAaYeDrB0CNFML2C6GnHf5jS9U1dhx0M3uBS3YAgkDY1a4gwJ4/kQtnqnn5KqlKJ9yLnqCGCvH6XC2SfAvswRvHcwtApAmRXxQWx649SZ8Z088t6gfve1V7FMjPHSZ+m0Uf24PCcyuO+5vk1lmTLizdFNl1jS0s56YSSFHelywo3G3TN9VMY7mAN3LJohg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xHbTU4afcP4VPCt7c5t9HdrtExRFqhrJyZbbFA7antU=; b=PtHfUbJaDc5STELSmfCJq0P8LXFjcTdBkb3y2rmA93rEaP9PJ4KF6Qac6dC3hcDP+cdlYqxN84cJzW06sVFdqSnpqMR9JA+dukqUFdMs4fBsOFK7QfXFNpyYIc7t7Zd1sQgp6TGBfG6044mgx5q8lGYtZMElEqBpZeVaMZIofr3M5l5sWS/Pj+41U1TvQU0y43bqFCWI27GrbglVUAYzhxENHcrgE7F747dhH5mxYUrrRkWe2GbUanEW+iIHSlZ3xQ3cvtwiXOIayiVpS5Gj7Vc0p4IjfbQ5U4A1T6xfK4H8XRG39FXJYM2PmIrTOFP1uZNrxIIqy3jDvF1GI//bdQ== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Paul Durrant , Anthony Perard , Kevin Wolf , Hanna Reitz , =?iso-8859-1?q?Marc-Andr=E9_Lureau?= , Paolo Bonzini , Jason Wang , "open list:X86 Xen CPUs" , "open list:Block layer core" Subject: [PATCH v4 1/6] hw/xen: Set XenBackendInstance in the XenDevice before realizing it Thread-Topic: [PATCH v4 1/6] hw/xen: Set XenBackendInstance in the XenDevice before realizing it Thread-Index: AQHaJMCmNcy1jH3c30+hdicFpfwJ+Q== Date: Sat, 2 Dec 2023 01:41:21 +0000 Message-ID: <20231202014108.2017803-2-volodymyr_babchuk@epam.com> References: <20231202014108.2017803-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231202014108.2017803-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_|AS8PR03MB7285:EE_ x-ms-office365-filtering-correlation-id: 55de17d1-f2c3-49db-c873-08dbf2d7c995 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SEmRHbAvkOF1F+M92scRmJda/E2LKTScNWl3z+dwwicVp9uQcdr+2iVtygauYY69ujsvNQ8fDDLrg+hZfMy0hbGE2xC2ir/I8syyhAqBgzqxb0YCEFfHEtDWjxKregYsAm5ozxD8c/4L5H545pnKuXOH3PGF+eWJYkO272X6ZyIg5EoKkjsJCQ9QIYtUXq9vz/ZQJkTuqeu+lTc0Wsh073ytOdtVkKGbc+8mzzmECRDHBMk4vtvAhcs068WR74F4iZJ/tDThkH9letr9MyxUHxzgjXH3vYqzdYvmLZX3J7DA1LBXfvZswojXSVITZBpTyNPbHe3T1ts5YLk0Wk1Lwi77EQAJKEYb7lgdOfsgS6P3NvyCd8ZTmqBl4MRXmmlJnM5HZ3rxIAPfm0QnqrsNZgaLV0y8KJbCQ+/s3FIokXDQzVmNa85lLjjX7xqmYDf+WJvpY8mjxgnjVFfct7z+TfLYX5d0cxYhNaAfUoeKU3fcu5bMpeocUvU3ZvN0gGQV+iSHsZZ+mfB6mjZS15U50wfosfVbTXhjTv0FdJIP6AkvkzsMdSygxR0M6yrYjBn21/rTZP1uOjjOTH6JhfYGCk4fbzEnO7XGRwAXGEAtZdFKgFuBGS5g4tPJk2PDPOW8 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)(39860400002)(376002)(396003)(366004)(346002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(122000001)(38070700009)(41300700001)(2906002)(7416002)(5660300002)(83380400001)(71200400001)(55236004)(38100700002)(6506007)(6512007)(1076003)(2616005)(26005)(66556008)(478600001)(91956017)(6486002)(36756003)(76116006)(66946007)(64756008)(66446008)(8936002)(6916009)(54906003)(86362001)(66476007)(4326008)(316002)(8676002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?a7Qj4f9DRmURavv37ag2UMa?= =?iso-8859-1?q?tMN5hyNgP8Z7r55nTOXOvP97FvNHsSE4rnd8kWS7yXkUo6ngjiKMiuu4Xc7u?= =?iso-8859-1?q?9Ek3dWG9oz22Bld/rVcOQf2/z1CcX2ZKgoRErpsyVYit/08RSKW5zrFC2XXa?= =?iso-8859-1?q?Lb6+Rt8oP4AvjpnOusvvChMrw2+CpCVztscTZaLvYU4JTMvXUClaeSMWcCr1?= =?iso-8859-1?q?jo/0ftUvcQq+py4IJMw4j6XZ0eCRbJu8opI9MfTZQkO36v/MEEdA2vxyX/py?= =?iso-8859-1?q?hOCqbzChz4emeKs0Zy7lTd5+TRaxTZ6jaHeTqm8Jca9ZBO9KQZnBEfikqs51?= =?iso-8859-1?q?X5HwhzDJUwBD6tRZewSdiLKajxnIt+nRJ0TVmlTNIr4kRcO0LwkUmPKcUet8?= =?iso-8859-1?q?6uarcAQPuC6egtszvMCIUDh2RBb2CFE9LhzDtQDCX3VcmcZzuFrYcJltrtRz?= =?iso-8859-1?q?/qSySq4eHJ7YfXBw/J28Qd9cw89STJk7wR7dMDmSQS3mKeq+Lh9oDI/jRljC?= =?iso-8859-1?q?OzXnl33VSFRbmxLYNDmu5zBan9DGWNuqju1zNn3cp+caWkx0H5vD09MYK81d?= =?iso-8859-1?q?BWVwFnme6MGzQW7BtdSfqpwI49JsZ5QpgSFvm3s9PTYBBfdPc+3Z+kWa8hRw?= =?iso-8859-1?q?VtZOoX7KTc+BOdusw3NZ6NZnQ6V79afHbr8z/HZhn8f+cq/x2p4L7HP50rZm?= =?iso-8859-1?q?wBLzC1n4BKJ/0TNLTvCFS+woyXbtwmW7ERZieFT57lUQIrfhfJdNZajITUkJ?= =?iso-8859-1?q?Y8DqOCKpwzkeFfKSPyMW3N2xvGtXwoRG1Qdx6XJ79xeqBM01f0RvLeG8j9Cp?= =?iso-8859-1?q?F6AUSZXDK5MAv0mvogyK4Wc55/rhMmzuiw/CYdDF/ocasUEGiU78U+tu9oJv?= =?iso-8859-1?q?cNoTrr6XWkrZYA8IfdLlqW3KHL4tLvd/1mDk4W5k5iP0Mo0Y8TilucpdGan/?= =?iso-8859-1?q?J+ct1a6HNuJXx3j7zYjeUgQ+pDM+uMK08bD+CdJL1dGcGsE+GKHmJ6Lc6Z5c?= =?iso-8859-1?q?A5QuNgwB/cl9TPaHkKWbZ4eR5Hzi992wxMBqyhrZLgG0oBBTQ5pgAJpG0+cE?= =?iso-8859-1?q?unGCiOSspgqef70yEZhZLk6yKqKmJOKC//n+EXZeSN9G6evxLkhDXM4p8flt?= =?iso-8859-1?q?6hDhrisnOHFsqE872s3SWiLRvjRJiwtiofzCeljUGCmLvjusAxruCX5itgrZ?= =?iso-8859-1?q?fP8badv/l+56Gtc/dAxL7Ghh/6E71Lx62aLMUf2vT5kOaf7MBM0DCD+9rPQ2?= =?iso-8859-1?q?AZqzG8ytYzRgeWgQZg546nKUG96hTqeugm0uWBS+pUaI9qT7KSVd826Rp/yo?= =?iso-8859-1?q?cBvWEPF5h9PSdUo/N0GRUWXA7QY4kqNeR7TP6yV6jYZ20xWSqRsToGtOQoJr?= =?iso-8859-1?q?Yp++EXAMjrtH1PAsjYIwfJLr2dHQYEvTf1aJV7Aq/h++uJRm81GTatKPZcLP?= =?iso-8859-1?q?1B8kvq065kzAZ1uKKoguuyneolgBXulrpcl3IYVPHd0ZduLDILV8nHaVs5AE?= =?iso-8859-1?q?ak6MFaSjnHFW4M1bPIITB2qs8oepSjmj2+NVYvL/J6fZFra2nrHkFN/pARed?= =?iso-8859-1?q?FLTC6eCmNFuXMlfHxNSF3wTspQzafiAP6xKwVcTjxKItSjq/l/MQon7RjonE?= =?iso-8859-1?q?VWNN6FRp/noaZjHEeT5Gu+kW3YLfMNPrLNZjlCA=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: 55de17d1-f2c3-49db-c873-08dbf2d7c995 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Dec 2023 01:41:21.4747 (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: OlIU3njXmpGSqJXQCcZYXlAx7K8RNyQRla0IH1J9p5qpS3pMlSPmWdjKjFd0KoFuLc82GOF8QnZx85xzSAJckddQmurvz+W4CcJRzUILGik= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7285 X-Proofpoint-ORIG-GUID: NY1ySJ2ni0D9wvujoIJInK0EAWdhitnJ X-Proofpoint-GUID: NY1ySJ2ni0D9wvujoIJInK0EAWdhitnJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-01_24,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=412 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 impostorscore=0 clxscore=1015 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312020009 From: David Woodhouse This allows a XenDevice implementation to know whether it was created by QEMU, or merely discovered in XenStore after the toolstack created it. This will allow us to create frontend/backend nodes only when we should, rather than unconditionally attempting to overwrite them from a driver domain which doesn't have privileges to do so. As an added benefit, it also means we no longer have to call the xen_backend_set_device() function from the device models immediately after calling qdev_realize_and_unref(). Even though we could make the argument that it's safe to do so, and the pointer to the unreffed device *will* actually still be valid, it still made my skin itch to look at it. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/block/xen-block.c | 3 +-- hw/char/xen_console.c | 2 +- hw/net/xen_nic.c | 2 +- hw/xen/xen-backend.c | 15 +-------------- hw/xen/xen-bus.c | 4 ++++ include/hw/xen/xen-backend.h | 2 -- include/hw/xen/xen-bus.h | 2 ++ 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 6d64ede94f..c2ac9db4a2 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -1081,13 +1081,12 @@ static void xen_block_device_create(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-backend.c b/hw/xen/xen-backend.c index b9bf70a9f5..b2e753ebc8 100644 --- a/hw/xen/xen-backend.c +++ b/hw/xen/xen-backend.c @@ -88,19 +88,6 @@ static void xen_backend_list_add(XenBackendInstance *backend) QLIST_INSERT_HEAD(&backend_list, backend, entry); } -static XenBackendInstance *xen_backend_list_find(XenDevice *xendev) -{ - XenBackendInstance *backend; - - QLIST_FOREACH(backend, &backend_list, entry) { - if (backend->xendev == xendev) { - return backend; - } - } - - return NULL; -} - bool xen_backend_exists(const char *type, const char *name) { const XenBackendImpl *impl = xen_backend_table_lookup(type); @@ -170,7 +157,7 @@ XenDevice *xen_backend_get_device(XenBackendInstance *backend) bool xen_backend_try_device_destroy(XenDevice *xendev, Error **errp) { - XenBackendInstance *backend = xen_backend_list_find(xendev); + XenBackendInstance *backend = xendev->backend; const XenBackendImpl *impl; if (!backend) { diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 4973e7d9c9..dd0171ab98 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -1079,6 +1079,10 @@ static void xen_device_realize(DeviceState *dev, 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 Sat Dec 2 01:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13476721 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 8C590C4167B for ; Sat, 2 Dec 2023 01:41:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.645878.1008431 (Exim 4.92) (envelope-from ) id 1r9F0i-0007XY-BP; Sat, 02 Dec 2023 01:41:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 645878.1008431; Sat, 02 Dec 2023 01:41:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r9F0i-0007Wl-8l; Sat, 02 Dec 2023 01:41:36 +0000 Received: by outflank-mailman (input) for mailman id 645878; Sat, 02 Dec 2023 01:41:34 +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 1r9F0g-00072l-LZ for xen-devel@lists.xenproject.org; Sat, 02 Dec 2023 01:41:34 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ebe81143-90b3-11ee-98e5-6d05b1d4d9a1; Sat, 02 Dec 2023 02:41:33 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B21Xj1F026535; Sat, 2 Dec 2023 01:41:28 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uqt8mg21a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 02 Dec 2023 01:41:28 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by AS8PR03MB7285.eurprd03.prod.outlook.com (2603:10a6:20b:2ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Sat, 2 Dec 2023 01:41:22 +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.7046.027; Sat, 2 Dec 2023 01:41:22 +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: ebe81143-90b3-11ee-98e5-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SEAmJw/RfgQlQetNGPXo4byxBirZelVMJD5WPeHgSFmJUwbhNzYy5i9cdd7y333i6TR7fB5xFPJPAvkM1jPqYR5YHa2iyNNTd9mcoDbs8QBO9lcV/O0TxMnt+THk7htiA+aJRr12XbdlOROacR4Qhjrf6wZoEAPrsdWuJ8o9XowXuc9YNI/mv3q8PP411fM0tl3fv207rGUJAW6CtjPBLNjmi5+jsqqis9wwX+TVvOFRwgOaz8gSVhdYYV/NCwqseqEYTmmp1ozhtWkxysdnsi+TeICxVJo8sCKXblgvp74/4DCzvXWRnaqlMm/PseJbNx6q+Xsap42b7UvG9J+A/Q== 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=e1n55VDPs3q/qzv0KviJW7OAskEpl6y9Jb0QmGMv7BY=; b=H14uBLZ9SV8COi0sLNJoH9JCpr2imtKK7egkdqVmpFf35Rxh+r5LlHDoQbfM61YSB2pOrEnhOZUKyc4kGWEIkvap2ImddRXuXfPjy2d/e2rZs2ccuoHFBnKxWe0a3FW5tEMgPhj+WDScFR1E0Ibr4n62c7WubZBkxGFlb3GNfS6rfPRIZIlznjdpNODp+KkvK4WYpG7orhpeONQZ+72QeY1oV4n2v+Ip4q6NBj8dzfm9qUosI9IcRQpq/4u7SFhKgQICxMN2tMZkMUdLQQ4rm2SdOTEmjLLB/sHhASvcF984IPEKl/cVMCMn+0jhPodBNMdcXXX11c3oSuO4eKLnYg== 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=e1n55VDPs3q/qzv0KviJW7OAskEpl6y9Jb0QmGMv7BY=; b=cCkpiFp+kXiGriRoI8mV6kMEJOnSJtDNVWy2iCabs7WeOdbpPOd2/mAAG2Q5U1dD+Ta9bTEQcj53B0ijvxqCNzn3PviFqluGOAdV/z2KTrJ9zDURaIEdOk/Q1+xP2XZG/uoR1MJ0T5pzKOdidB5+t8oyzwQny7kt0L57fGpVUh4Be/N9j0C/EBCZeBTLnazDXzQyid3SvNh7DPp9iCzepSdpI70tQPqFiMPZHbGmzEzu3wWTtNLMeh9+bLT/6S0yJ8efWxy2A8Zb5P2kkFnp+YJ1ySLYmFvIEvV2VPH9R0xCQdf7gg0t96VJcTvm/9YRUG/kMJIPkNmb2OLVJ1lCEA== 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 , Jason Wang , "open list:X86 Xen CPUs" , "open list:Block layer core" Subject: [PATCH v4 2/6] xen: backends: don't overwrite XenStore nodes created by toolstack Thread-Topic: [PATCH v4 2/6] xen: backends: don't overwrite XenStore nodes created by toolstack Thread-Index: AQHaJMCnWt9mOmaDRU+ewbw5BkugTg== Date: Sat, 2 Dec 2023 01:41:21 +0000 Message-ID: <20231202014108.2017803-3-volodymyr_babchuk@epam.com> References: <20231202014108.2017803-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231202014108.2017803-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_|AS8PR03MB7285:EE_ x-ms-office365-filtering-correlation-id: 2d1ede76-dd9d-4e19-7f6d-08dbf2d7c9c3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MMThguZxYyc2qA1XGKMz68EIW9kBjMLwXgX1YRmjswg5MpXuBZMFqz4530j4qTmvGfEzf4QpvDgn/ZGqW2ETHypnn2BcQho5f1rD3ECd795v8+XuB7jrOAmJxPkooUBrMKz7qHqpk8g0N5x+cAZJz0+BmnFMg2y+/kbMU8AR/IqKs34JbBTlCZ0McssgU2gp10rCPLkn6EehBP9CjJKxXwde8qG22pBVtINOaTOi+WaaRY71TYSs5O0Fhf4iWbWRCw7dPk00VHowuHpQv+3ax1C8lpSAZ/2ejsn/iv+RKYuip/Nn3rTqT9Zwp44W8fJXH2Q1lvxcBjJ1feEQtENMU7i506AbhuIxBqV4s6Sw2bfLNg0YUwF1WLQK9+4GHrE/bp8/AzonGKIy8ymzvoFP71cAQorIg2P3MueX5DaMWeiUiYlBBesRcDCzfOLBIAC/TynUCvHuc20pw69qwkEd3u7RD2lzskg1zaP1YnMCKkgnrZUqOceiJnOCYcIqUc17xJDvtGLD2TQLB/FsjdqeVb/EXJHXw5ZHmj5pvzniU6sKsg0p/R6kXA0HffwGtitOX40aPKkAGWMZNfUuSD9+45NWMDCfTIyjRGTKLXffsTU3bqhPFSeLuXr1mduZOgma 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)(39860400002)(376002)(396003)(366004)(346002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(122000001)(38070700009)(41300700001)(2906002)(7416002)(5660300002)(83380400001)(71200400001)(55236004)(38100700002)(6506007)(6512007)(1076003)(2616005)(26005)(66556008)(478600001)(91956017)(6486002)(36756003)(76116006)(66946007)(64756008)(66446008)(8936002)(6916009)(54906003)(86362001)(66476007)(4326008)(316002)(8676002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?51HpuABsT+tbpDbgqyY9AbO?= =?iso-8859-1?q?xSV3pOA+yo7ZIgcKPxX3+Yl3xlM+Vbh+7BRXYv4jUYUkebgveC2lO21EB41J?= =?iso-8859-1?q?r5YTve61LB+pxcCCSlhdMzGf0aQsoEhDFFvJOxUkVM4EsfgSN2fMJPybvwzn?= =?iso-8859-1?q?2GsQtC8E8uyDiR/lHutVXVqDrAMQSfexQ6WzSOv5NUj7lOtIX6cr5JEkkzXH?= =?iso-8859-1?q?YyOnpjQ92ux7FEYPBvNXmBR6cBAMFnnfV5wBs4jLtyahgH8ko1lx1oXHMxyP?= =?iso-8859-1?q?Dd4Q5FxwqrU3MkzlxkhN8jU6httcF4GlEdWrRiEr41xMrYETpOC3MQnnx+ik?= =?iso-8859-1?q?NPlTKTDOU2tU3HQZihVIJOLSD6nXP0FoNwiYu7KxOlR+Lik4T4bbnbPWrOrO?= =?iso-8859-1?q?CrCQl4VQp+76Y0bjO5maDB6vNFd2ypi4InVFYGWifRbN3gwvh0JzhlUsbRIe?= =?iso-8859-1?q?wwvVqFmAtKaDjhsHu8E8Y839dLGyN4unOoUouWTUVFiwX8q1l5nCcyF6PdQ3?= =?iso-8859-1?q?lW8tbV3WUgVwWCDyR+frVmPzX9cPBop8WyTrH32xdcPnfTodRDQDt06Thpl9?= =?iso-8859-1?q?S3WV3sO20J83XhRNUQKVLwujHjgxg2aNQ2cy2fB7vzVRkLIqBOahgE8r/AC/?= =?iso-8859-1?q?CTHI4aYFMcY5302EGxV0F4AsBKz08TKx/NQXmEWS59XgX6QhJAAO+dD8x8Ma?= =?iso-8859-1?q?V7g2vZ53JvSbXX4xtl/j8W0mAm8RkmUJACAAJHT04dQEGNtE1b6NGZCnpST6?= =?iso-8859-1?q?oAfz1Y5DUU7L8SpGkOpH3RXieHaLIdSF1rTeBeo4VlGNaUGFad9GfReksU4P?= =?iso-8859-1?q?4JkBrFPxT2Le1rzzGswcfJNsOblU4GNuwa3f9RMQ5ztY3zGp33xfBTQQ0KiT?= =?iso-8859-1?q?A6PCELuOJDn7a3QfEg90voMtLBRCy7fAvcUpCuVoBu3OuqAHVoqFYHd6kw0h?= =?iso-8859-1?q?toH3WcziwFFfg2Bg07YlqkX6oaeiA/jbH0ism9ogZpHAxQeaeorK9OnE32CX?= =?iso-8859-1?q?UsBWAh6dcgySAahJ3ujvVhQybOQk6iW4Fa7Or0uhIT3QJAxOKyM6N9/jEl9d?= =?iso-8859-1?q?OYyQ03bLk1pqACIgT2hMA+547J22FgmGpC2850M4guwbP30lXN1vcPgRagHc?= =?iso-8859-1?q?gmsEwuc1L8GY+vzkGHkOpf9fb5XI2+RHoZkjJFKZlvqZ+b9OgoeAby4K0iSR?= =?iso-8859-1?q?qWyCRfNwh9lyypwXwYPlrlCgYj3UGiWr9grCTXgkUqCrPVn6PI/aNBIoq1Qr?= =?iso-8859-1?q?+29RfYBqfbGw52YqTcSrisxnbTHA0GC+dcm43bXVQHX9XsYjF9GLY9NIJR1L?= =?iso-8859-1?q?WsiWZ/D7O733mnUp9qnPf7kAI7acAK/adUOXXdZw6mBQvV+mqjgqzZDdYAVu?= =?iso-8859-1?q?jc4yoyHUDacRewipRBz9hblr8xMtH9nFYmxQ6TKLd7YvfjBHvwVTqXVVgCTH?= =?iso-8859-1?q?+KIlFa8dxkourpkmKKQqKVjFwk/8AAysb2uMFyOe7VrpyHkbCIpSg8dCkcA9?= =?iso-8859-1?q?vsk3URnSn0wxZUee/zfXd7ZzLur08dAkA4+Qh9MUNB1ILZydfq0x1+ubuKDb?= =?iso-8859-1?q?WQwEir4+KU6Iqn8TfrkdnaJNUkgFcngs8RbnkvuzvUs1yfrMF32EWwJ1zCgl?= =?iso-8859-1?q?8cFKuCRt6o7rbYfq1HT/UCYDEQnyqvAlYBq3aCg=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: 2d1ede76-dd9d-4e19-7f6d-08dbf2d7c9c3 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Dec 2023 01:41:21.8562 (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: cMQRk7WlMAfSNsVqy3636sGywGbOhKOh16PGYpKJeoRjC0y1+tJpdgxeO5Gr7PVYuecS2oLks5jbrBk0WCeJBQlTiBHDGHyfDKTPiZzLWgc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7285 X-Proofpoint-ORIG-GUID: vAFYO3NAXhPymQwhKxackEVEJwcDayWJ X-Proofpoint-GUID: vAFYO3NAXhPymQwhKxackEVEJwcDayWJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-01_24,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 mlxscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312020009 Xen PV devices in QEMU can be created in two ways: either by QEMU itself, if they were passed via command line, or by Xen toolstack. In the latter case, QEMU scans XenStore entries and configures devices accordingly. In the second case we don't want QEMU to write/delete front-end entries for two reasons: it might have no access to those entries if it is running in un-privileged domain and it is just incorrect to overwrite entries already provided by Xen toolstack, because toolstack manages those nodes. For example, it might read backend- or frontend- state to be sure that they are both disconnected and it is safe to destroy a domain. This patch checks presence of xendev->backend to check if Xen PV device was configured by Xen toolstack to decide if it should touch frontend entries in XenStore. Also, when we need to remove XenStore entries during device teardown only if they weren't created by Xen toolstack. If they were created by toolstack, then it is toolstack's job to do proper clean-up. Suggested-by: Paul Durrant Suggested-by: David Woodhouse Co-Authored-by: Oleksandr Tyshchenko Signed-off-by: Volodymyr Babchuk Reviewed-by: David Woodhouse --- Changes in v4: - don't touch "tty" entry in the console backend Changes in v3: - Rephrased the commit message --- hw/block/xen-block.c | 16 +++++++++------- hw/net/xen_nic.c | 18 ++++++++++-------- hw/xen/xen-bus.c | 14 +++++++++----- 3 files changed, 28 insertions(+), 20 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/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 Sat Dec 2 01:41:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13476723 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 4AD7EC10DC1 for ; Sat, 2 Dec 2023 01:41:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.645877.1008416 (Exim 4.92) (envelope-from ) id 1r9F0h-00076W-1v; Sat, 02 Dec 2023 01:41:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 645877.1008416; Sat, 02 Dec 2023 01:41:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r9F0g-00075R-U6; Sat, 02 Dec 2023 01:41:34 +0000 Received: by outflank-mailman (input) for mailman id 645877; Sat, 02 Dec 2023 01:41:33 +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 1r9F0f-00072l-LF for xen-devel@lists.xenproject.org; Sat, 02 Dec 2023 01:41:33 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id eb1aacd0-90b3-11ee-98e5-6d05b1d4d9a1; Sat, 02 Dec 2023 02:41:32 +0100 (CET) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 3B21X1Qn015641; Sat, 2 Dec 2023 01:41:27 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uqa3aucrx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 02 Dec 2023 01:41:26 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by AS8PR03MB7285.eurprd03.prod.outlook.com (2603:10a6:20b:2ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Sat, 2 Dec 2023 01:41:22 +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.7046.027; Sat, 2 Dec 2023 01:41:22 +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: eb1aacd0-90b3-11ee-98e5-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZGD0e7m4fHO7rrIi7b57NDXGrXsJOiVyUOQy6QMj+OD4PhtJTsbeq7/+d/zTjTRUPF7J3+tk9+sNb3ouWuBfhogPutkQ6w4rAXeGdyWfKymZFICKlvB3Tq3M4ZKHJeFE8s1mvFB2H+j7au+M/J3NbyuZiJzcl0U6U1Pli9m3kd7LFWF6aEOMf+EGOSSNJbvJAq+4DKFAppxDZAKy4mj/0tm6BXoD9EtTIVUNsN0uUKbErO5ibGLO5m+98HjcvW8hOipaEqt7xNy3IRq1Um0FJNVsZhsiN7hvZUr1bnX1FbAN4eegDQ3oDqrg2e+gKaCPfO1g5afqe/RSaV7cZmffvQ== 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=HQ7QrNqUdBOnC13Grzj8pxJaSJ4ipHc7/EE49RhGldU=; b=cX1rfShD156QCdWssHvQjWQ7exwpWXv6TaVaMioyH5dszq/Q4n9GMbR2Iyi7+F2QJyTjBijmtwwrymT2/GOLtb2RryrEaXo6yeMydfeZNgyNgc9M5BZ/IgZ9p+0lPbAwQAkMgQ/RsZVZ3gpCcmKa6jmS0xz2dc7iEFncOqivbv0xpSEukmBuV6f2N3jgkuEuQkDFhNcN5sys1+Nje7ztQkbuJJDeQcX8TrIBeC4aOmITYofa3Ib40sIyivAS5NSfdNKyJ4zml15AGhii06+hrpXIYQC/g15cxUWgey41y+RGxjFeJqIiU4AbRMZVYHZjjQ1JJXgbQf35wzJibQC57w== 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=HQ7QrNqUdBOnC13Grzj8pxJaSJ4ipHc7/EE49RhGldU=; b=SZkF2URPDxzMOTe+isYiG4g0ofM5LAgNufi560Af0UXCpvs9tZdW5XLdSdyyGvAdY7FZwO0Y1nph6TUADDpbYt83VSRVmLUUw5lG6YV5tDlpGd0jZmseM/zWZHU9G7b6Jxuo/04uQVRJ/aqJSmEIWvBqSAUNFrfV7a9m4i7dSUiw/mUp47wB3YjTUqiSjTFsm8Szx3hWHf2IlyuB8qA8oLeJC0qNJXhbUJyfQylHjwij0rNMFSWjJAwTLvb5FWb5Gzw+7z/MKjFey1GhZnQq5rYZSiCAmKn2tPNV+0qikesvN4oPtWf4ppe3Z+dK54wffSiy93YiC6+LlKENP0IGuQ== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Anthony Perard , Paul Durrant , "open list:X86 Xen CPUs" Subject: [PATCH v4 3/6] xen: decouple generic xen code from legacy backends codebase Thread-Topic: [PATCH v4 3/6] xen: decouple generic xen code from legacy backends codebase Thread-Index: AQHaJMCnSKd/ZWVB1UiEphLKoDVW4A== Date: Sat, 2 Dec 2023 01:41:22 +0000 Message-ID: <20231202014108.2017803-4-volodymyr_babchuk@epam.com> References: <20231202014108.2017803-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231202014108.2017803-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_|AS8PR03MB7285:EE_ x-ms-office365-filtering-correlation-id: 7c35c8ea-f2f4-4658-e979-08dbf2d7ca0f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8E8Asu8bD+G16EADm3fUcQycwlOIrVhUcCRzC37BVbITNdVpHuLU+Y1/OhqQUTzMdWX+dE7tExnWIskackhmE8NBm99p50SZx8RQR6VgBq2apabHh5is15YC8lqFje/BzSDhablref1oErRtUQUGTnwtOonmhw0iYT6Sxmnm59pC7k81mwuybGzQE5oOmyIUE/NUrQ2Ea/ed9iIuzNcUrG0r9cBIPd3PYwx7ov/I2PY9vob4hSalcT5n/u6tDPGvD5tcJmqTJRWr7P0ITNg4Fr/PtKUf53pUI7A/ZUIglRiAQWBhoppMdq7lgSMDGfOTfC6J1jt+d5nWm2kPct8Hn4rDgGnTyaJZ8RqecIx/n2HWRfDp9UPtru2vRA9YNiqEHFsh6se9i3GDHU4la5szy74LBvwvsUzLBK3V8CC3B/LZzvuD0VRkT9xMr2Sj6jM8mrp5kdwdu4GWKsN/7GaOijgS5X5wmiqNSsQrMF87Z5PKpKwPjvmJN/iznnxzhZ7VKiRSJ+qirlKXTk+g8sU2tW6o5J9RVfwLgderNPKtPRQ0WV5f1LnKhDZXbUuaQRMeVVDpf7DC6CTHEC2i9CDXl/mC01s3DC1o90rU5DYfZZ8N3e03XyfxRI7PRx/hl6HSH4KohYopgiGLvFKHs3OCLg== 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)(39860400002)(376002)(396003)(366004)(346002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(122000001)(38070700009)(41300700001)(2906002)(5660300002)(83380400001)(71200400001)(55236004)(38100700002)(6506007)(6512007)(1076003)(2616005)(26005)(66556008)(478600001)(91956017)(6486002)(36756003)(76116006)(66946007)(64756008)(66446008)(8936002)(6916009)(54906003)(86362001)(66476007)(4326008)(316002)(8676002)(41533002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?w85TDjIJhgU03SEmx2jVb22?= =?iso-8859-1?q?I8cG9cEEElvfMr5gAeeyBTrb6jR9xlwXV4sx/kArsPOEZXSGDKjieueNpchi?= =?iso-8859-1?q?7CDqwYN53vFzSVJKNvhYK3ylnar3zgzIJ9Q4yJNcEcXe0g0qRS6QWNyOvYEu?= =?iso-8859-1?q?dotb/TVzLWgh0/f/zrBjiHNc50CxdyKzp7QihUKZvQsci/7IMfA29/C25mAZ?= =?iso-8859-1?q?h5uyGACmvnhge4j64jXh847rjbbTqC14ogDLdEH262Cu8QuRH+5tdKuk2oqv?= =?iso-8859-1?q?c/PKDdWgv6UIQV/23pvRcM4H8Kkomt5UIuqVBrkBWf7LFXsXnfVUwpbXdfaF?= =?iso-8859-1?q?L9l4MJRorvDV8hz7UYlxEE19AWMPhiCnUXVa9lrZ6BuudL8KHTXB7fHmmCKM?= =?iso-8859-1?q?yXNwIsU275ffj/x5Dyv4OpEA+13Bn9Pm7jfJY1UwinlgUlqWQhES1g5jTj5X?= =?iso-8859-1?q?3dGm0t513KyN44sHLe8jtaPbu/Fo1rONqvVonSAA9BlMUVaZ0gWyzZvXaHDU?= =?iso-8859-1?q?MyZlGmqkaG11RDKgOKE0BX3fq0fh5jbuHDYsWEVOvvfs9/Hskwgzgyw04V0X?= =?iso-8859-1?q?dNADxWkrBZrT2EqCXhAz1ZoLIGdKjuWJhuktJK0GcqwYmasgR8sK80eqvEah?= =?iso-8859-1?q?FmJoNxgRkubiktA2qllMkYiU/7P6jKjKNwBAmELs28bz82otcAhuYj/lhgya?= =?iso-8859-1?q?3E5dM0jO2CNcdM3Hs81vBHlugsWR8e1XiTNxu+JSPmbbKCTJhDRgMqgwsOBk?= =?iso-8859-1?q?gRCvIlHntKDykp/QjUmhDmS92Lux/Rjcc3vOKjCXm1mUHCqYixSqZBJpjOWz?= =?iso-8859-1?q?SC58vLL366s5Tz61D8CL90bgszowyi7KuwOk8zXDPqzNWggSBvL4r9vaZM2d?= =?iso-8859-1?q?eEKf1rkQFfgk2bubFUTL6dr/Z3Y1FnsjEBQNeGNWDuQUKHDkHG/iPAkrgHhD?= =?iso-8859-1?q?Tijhe+6uSVPH33Siz96IlObP2ji11m96TpMyphq0qhqeKkXLVzolySMBTG5N?= =?iso-8859-1?q?Ff6mPe6JtBzOO700ThldhBZKvtPMvY2DvhLRYkLBK4kS92CubQ5zUDiLtALK?= =?iso-8859-1?q?nZ2vVzF/MlRW9bsGILRBFg2nuRbFxKCE79ZZlOBqYNM2vohgyZdemmUVSVQd?= =?iso-8859-1?q?d0dOWOF7tFHHs3BJk2SZnJK9R59u+m4YMnMka7k+giNBxf/LRllu4JfiJhyR?= =?iso-8859-1?q?JUTUCceFK5eOk5/2WLutx1jlAIE0jETgJKH/ucjfPdZjDqIkArjei04mNmZw?= =?iso-8859-1?q?HoQwIEB1GmqyTsxzsGR72jN5lv3sHvDVreKP0JgT8yLIpG6BjixNj6uR6yUL?= =?iso-8859-1?q?BNK9POoc+1EMR/7rkxRlbrsnh2dC4seIJICCdbn9GoaK1irh2hNCDLzId6Xf?= =?iso-8859-1?q?sADZx0/VFmnSxlZDu1HHBBeVfcnEJuJHuy7rG6xOhgMSKd9PbuGlmgNeL0FN?= =?iso-8859-1?q?Ul/zwhADltHda7vS8GLVoy2A9JhFoPT+E+05As9FnyjB8Zll7Ei9IUhGpzpr?= =?iso-8859-1?q?xwODIrF/md5fziur2RMTngmLbGB5UzazltyduOdBMeNgopOWedCd/uFmzoqI?= =?iso-8859-1?q?gxtMtDoWcwwvKpo2mH8z9zdiS/1gQ2Eat2p4jUZW/XQBS5KgT+z46iFdfFn2?= =?iso-8859-1?q?aZZIojiRVJJUOeVjD8WPXwSk6MY7MqJMMBAKOow=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: 7c35c8ea-f2f4-4658-e979-08dbf2d7ca0f X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Dec 2023 01:41:22.4783 (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: yRvAfL4Bfj9hEDUmG8q06hammh8xmttkHjqlkeXanvuPrlqCG2gm4xwfpUXyWQipmk0+E6qKtJ+FIu7I1Nn+HCAdepHfhvR+Uz2c5R6B7SM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7285 X-Proofpoint-ORIG-GUID: kWKuNfjc1JuJ-6sL3MVA_lOQrCrkuJ_e X-Proofpoint-GUID: kWKuNfjc1JuJ-6sL3MVA_lOQrCrkuJ_e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-01_24,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=851 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 impostorscore=0 clxscore=1015 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312020009 In xen-all.c there are unneeded dependencies on xen-legacy-backend.c: - xen_init() uses xen_pv_printf() to report errors, but it does not provide a pointer to the struct XenLegacyDevice, so it is kind of useless, we can use standard error_report() instead. - xen-all.c has function xenstore_record_dm_state() which uses global variable "xenstore" defined and initialized in xen-legacy-backend.c It is used exactly once, so we can just open a new connection to the xenstore, update DM state and close connection back. Those two changes allows us to remove xen-legacy-backend.c at all, what should be done in the future anyways. But right now this patch moves us one step close to have QEMU build without legacy Xen backends. Signed-off-by: Volodymyr Babchuk Reviewed-by: Paul Durrant --- In v4: - New in v4, previous was part of "xen: add option to disable legacy backends" - Do not move xenstore global variable from xen-legacy-backend.c, instead use a local variable. --- accel/xen/xen-all.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 5ff0cb8bd9..6c2342581f 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -33,12 +33,20 @@ xendevicemodel_handle *xen_dmod; static void xenstore_record_dm_state(const char *state) { char path[50]; + struct qemu_xs_handle *xsh = qemu_xen_xs_open(); + + if (!xsh) { + error_report("error opening xenstore"); + exit(1); + } snprintf(path, sizeof (path), "device-model/%u/state", xen_domid); - if (!qemu_xen_xs_write(xenstore, XBT_NULL, path, state, strlen(state))) { + if (!qemu_xen_xs_write(xsh, XBT_NULL, path, state, strlen(state))) { error_report("error recording dm state"); exit(1); } + + qemu_xen_xs_close(xsh); } @@ -80,18 +88,18 @@ static int xen_init(MachineState *ms) xen_xc = xc_interface_open(0, 0, 0); if (xen_xc == NULL) { - xen_pv_printf(NULL, 0, "can't open xen interface\n"); + error_report("can't open xen interface\n"); return -1; } xen_fmem = xenforeignmemory_open(0, 0); if (xen_fmem == NULL) { - xen_pv_printf(NULL, 0, "can't open xen fmem interface\n"); + error_report("can't open xen fmem interface\n"); xc_interface_close(xen_xc); return -1; } xen_dmod = xendevicemodel_open(0, 0); if (xen_dmod == NULL) { - xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n"); + error_report("can't open xen devicemodel interface\n"); xenforeignmemory_close(xen_fmem); xc_interface_close(xen_xc); return -1; From patchwork Sat Dec 2 01:41:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13476725 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 D4FF8C4167B for ; Sat, 2 Dec 2023 01:42:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.645880.1008452 (Exim 4.92) (envelope-from ) id 1r9F0w-0008MS-7c; Sat, 02 Dec 2023 01:41:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 645880.1008452; Sat, 02 Dec 2023 01:41:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r9F0w-0008MD-2S; Sat, 02 Dec 2023 01:41:50 +0000 Received: by outflank-mailman (input) for mailman id 645880; Sat, 02 Dec 2023 01:41:48 +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 1r9F0u-00072l-4D for xen-devel@lists.xenproject.org; Sat, 02 Dec 2023 01:41:48 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f42cf6f0-90b3-11ee-98e5-6d05b1d4d9a1; Sat, 02 Dec 2023 02:41:47 +0100 (CET) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 3B21X1Qp015641; Sat, 2 Dec 2023 01:41:28 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uqa3aucrx-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 02 Dec 2023 01:41:28 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by AS8PR03MB7285.eurprd03.prod.outlook.com (2603:10a6:20b:2ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Sat, 2 Dec 2023 01:41:23 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7046.027; Sat, 2 Dec 2023 01:41:22 +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: f42cf6f0-90b3-11ee-98e5-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=evgsby7gz/Ac8GwTIfqoRFTRzPmH0hKPD7MXGciMQApj+h6bzr+qiBXDrqvdOeHSOTiAOCf2dDrxrwVXvoQH2IwR9hYCNEtrMDpbhs+TPIl9H8bPeGpytNIkv+Fm9myvomwhMI4W3O2Z35Po3s5jzalZqSjsgNFrvDLuBhNhLc2MFXD9daFmSvZ9OV4QLAl0AwZ9WJ4zE49kMCvnxG6f+qPb21O8K0pXLZW1pRnVBaCZW2ULZGqycTE77OZBnEoW+2cV6iKY4eD85YYh9eCBlbpnVTyzKRTttn/21GDgqQ4roTIW2cwVV1lVoDSyYUnJX1aVprKUchrIzYA6Wj4PoA== 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=Fd2GMMSSgW+cobh8ZFxigRxf9cE6MrLzy6vrJfU+U7k=; b=H8nppiCDopCEb4w4RFLyg5fnqD7n2zxU61EBUWHbI7dOQh95DbaHny/Xn1hZZNUwFC0mYifREFd4Iw5RFHXhyUVHFHxJ44akhw/vcxBpPynz5yrZSqdfpxXlaVdnDUxwqkuhrRabjGIOgGpfEJpEBBCnhI3qhOf+i55FriY0wLlvogGnlKshgNzpr3hExRwz+G0s0iEop5NBxNSOM5wY5fZMnV+KAc2QJ7x+Qr4lrJYK7AIhIMHXF6DDuqY+Vh7cH3Ix/+iuKp0UelppDyWDOGJYuhF0t6KYH06xbG5YCVL77dyJsp/OkLmEtdDDaV8hJXK7P0iRBeETrtmadSi+Nw== 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=Fd2GMMSSgW+cobh8ZFxigRxf9cE6MrLzy6vrJfU+U7k=; b=fhiCsy4UcIdXcJzerKHyeBvLKrFvEnwvUEo38J+B4dtHk+/M0ljwut9yWBYxVk6Jx5thkuLPhrNCj+uVumXUltzf0wyiv2bDAAmONj/xUVfLA6SHIohdh4Jo3ojqh6vgEXP4EYfes49mYNtWDb2oMDOhZ+K8q5gSL3yXyovbKPaAX7kgGrwth4C5Zre7fUmYyeiL4+rYcVXyW5VLE79psW3zhB0NlqOkdqYYCRFRTdXLvJkPCJ5RiU6qBvy6f5FuBL/adjNxjD9R0dublAjDDtZmL3TSHf7wmss6mU7w1wmgVbgPeotG+WbWQeDQpsIkBvI289drc5/Fh2CtdRPAbA== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Greg Kurz , Christian Schoenebeck , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Gerd Hoffmann , Anthony Perard , Paul Durrant , =?iso-8859-1?q?Marc-Andr=E9_Lureau?= , =?iso-8859-1?q?Daniel_P=2E_Berrang=E9?= , Thomas Huth , =?iso-8859-1?q?Philippe_Mathieu-Daud=E9?= , "open list:X86 Xen CPUs" Subject: [RFC PATCH v4 4/6] xen: add option to disable legacy backends Thread-Topic: [RFC PATCH v4 4/6] xen: add option to disable legacy backends Thread-Index: AQHaJMCn9jPeta/9M0OenQld9P6brA== Date: Sat, 2 Dec 2023 01:41:22 +0000 Message-ID: <20231202014108.2017803-5-volodymyr_babchuk@epam.com> References: <20231202014108.2017803-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231202014108.2017803-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_|AS8PR03MB7285:EE_ x-ms-office365-filtering-correlation-id: 5480e286-e83e-4782-b3d8-08dbf2d7ca52 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CerkD+0MuaBOyAz3p6g74xYtIv9wM49imDVSzEdH3vDYnA3TKQ/rNAsW0LPMKG2ffUlv06Q57NdqD3EpzEKMz8vy3FIRgSoDx+DhZMgyFyoBG6TW6H0nM7cTgy62y6VMkZJ9ZajZcnR9PxjPt8PAz5jMfFSb405akum1WdBgRwO/YQIB9I4Op/hoxpX2y6JeoVlnOT3/yAQ20IfICBWtxzrBuVyHzXj40KVqrll+/M5y+dF44MJPbwoK6uL9SH3DMfSTearFMsNZK+cU1xxZApcKmJhn8fr12Of3W3ymCod57+SqXYdV+5yy9IIgk3onppc1a2VuUOa0NyCgPKHm/HqY7iD+ujZEMihs6ULLDYjjJUlanHg3feVXsHFFbvB9URV5LpF1k6C8wdYwET+c7vxVL6EUWuFpFsbPdDQDHaZBmN5zAO8mYfAYCFfxmWV2/YC3BH3+x/jOy+G0KcvnNI1me00rPnUj7yRGROwETs6zWApkW4d0xoxPkMaLZkj6bH2EMo+J65TN2YbQKyDw+pObl2U2wSh51xdBDYdwf1VqF6/VjKo/ZyECydhc5AQtw3bL0C174OpevwPOjB5QoWTbTnGrz2/4XsB4OBx3tHz7q84SohuyZcBZuUZg9m3lME+XxSEEs5Jf+l3O1d4e1Q== 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)(39860400002)(376002)(396003)(366004)(346002)(136003)(230173577357003)(230273577357003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(122000001)(38070700009)(41300700001)(2906002)(7416002)(5660300002)(83380400001)(71200400001)(55236004)(38100700002)(6506007)(6512007)(1076003)(2616005)(26005)(66556008)(478600001)(91956017)(966005)(6486002)(36756003)(76116006)(66946007)(64756008)(66446008)(8936002)(6916009)(54906003)(86362001)(66476007)(4326008)(316002)(8676002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?VDaAzlQx3V58HmlzhgqPi4l?= =?iso-8859-1?q?oXNjVAuABbd53jLxEG/sNIsj1WGzNiNpctKFL4qcwfYU4+IhSAJIoibLF/26?= =?iso-8859-1?q?qGFCTR6P0y42LaVa+xFOTHVMqnHoEljHYrSbjUGyHnuii5/9CSYRNybCv2OZ?= =?iso-8859-1?q?vXAwIy7LQ0+BY3l/zK5ynrZ1ZMVPyw2EwqBxFymhHzeyl73w11KcSTM4wWa8?= =?iso-8859-1?q?nlbn63FJt594XHO5bhlaz/AZUIB8ucECmvxGZUmUkE/2fBnn1O1VMbl/l/Vx?= =?iso-8859-1?q?XQtyzKqvNtudp4TW5BYwB7ZHPli/hd3BtrdgAI/hsPNEBQQfSBqDmYyeLTRx?= =?iso-8859-1?q?HRguGQyesEUeOBoVQYISsdSkDqlzuR32seLeic430mKHMbfu2J3DSkZyrPNt?= =?iso-8859-1?q?/2LnOmKSwSCYF2OtQpNtqxxDsE5suCT/6HyQ96r4wLu4K45XuY56fK6lHPZT?= =?iso-8859-1?q?kQnFZdxioBojyqpN3pZGHJfAzs6HFYBGhBGpNGt1qQ3R6ywKoekdZaZD5MOJ?= =?iso-8859-1?q?pnMyE1cnDGyHhVEwzNswnDc0i5dRf9UAmhgbpPVxZ/kZjLx0Nl3E6JdtmLiQ?= =?iso-8859-1?q?2Zu38+AAgKKd19LVCWjkLyHoEr2FA5iu6YJEHy577zVd8k2WPPlVPRhXpKWO?= =?iso-8859-1?q?4LOHNPh03fV9qCC97tQexVsPoaRADIiXwIAMxNtbpKVbkNPCk1RHbbhFQqtC?= =?iso-8859-1?q?pi1fiKGuJaBFXovPBoQcu0/3uTY+giBx7oXKn5Q83yGPUooNUng7Jpa780Ds?= =?iso-8859-1?q?pH1nsfuPoA7YkaMDtZx5QFslBoKPu+w5FxIgZqQBcCjVWW9LFSAq8ftEESM9?= =?iso-8859-1?q?xjRy+ehJsmVVZCnrP5apO8SQNqIYONFXL0mf9r72aU+jyRxWp3aDhU+Jiyek?= =?iso-8859-1?q?p3HVEzNRD2NGz/S5iHUjpRAIVdPEaQzEf8ACQ0CjfW+JkCArc0gUiEIpLlsu?= =?iso-8859-1?q?04S69kr1xYdeUrlS25qTrI6GbSg+fWORhg77+Ec3b9xyMrkcBqPOgR0UPGdn?= =?iso-8859-1?q?F60pZXvosrul2U1G0/woR5Mvw6PaXeHziDD7xtcKMblvCkDPyEFRXS1TuyTo?= =?iso-8859-1?q?6HJGpcgUslb1mFGviemRbzgPUI/JiCgktF1DNqEoUUqLGNTLD2rXJ/FNuzJQ?= =?iso-8859-1?q?GcouD1Tho6q/u2B2UuoIHlugSCbOSLoSqtIJ2OXSauxMoeK3gmD9aQbz6uQi?= =?iso-8859-1?q?XLN+HBCn1BHhfHoKMuLtuEnf0AVEHoJ2dYaUGN2IKCXKtaEtZMDaVyrekNm2?= =?iso-8859-1?q?0vVcEuc4NDMB1y4aMV+ZWhfukcj+oRYWD2talnCwBu7E7hq3meRF0slRHEGs?= =?iso-8859-1?q?nUaoh9TkhKlnIq7W1JLa0RmL4WWeoKm8laDNUZleYgHu19250Kqecon0iUM3?= =?iso-8859-1?q?gR+uGe+CAsudp4nvvIThbVpT9F0oWGmYHumKGVyOcADDAYmK9GsT1e/XXAZJ?= =?iso-8859-1?q?7m7v4UEpUYp7T8dNKY602XQUzryzseRRKx8FkqJN+UpXeX/T8TCrPQ7dDpKY?= =?iso-8859-1?q?s9og019SVfsrLF9kp+wxY1As0VPNwha1KloYAj0shqjhiSyLLUF59TssiwtD?= =?iso-8859-1?q?gjUCmMuyH1FIVy/UWGNhWj9qP7sgOzAd3VmEWs0BUydHt3yGMgc1SsgaAmsK?= =?iso-8859-1?q?YcjOK0s7Cdk5NAOWxaj81VEEUbMjVPLHQy3Udog=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: 5480e286-e83e-4782-b3d8-08dbf2d7ca52 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Dec 2023 01:41:22.9033 (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: a1qj5xIyQoXDsKFOo/VQUNU3VnUIgQn/vGUHu79TGShyRiwd+nswyBKKUDkz/0BPoZL9hhI5/tGNHz4LNnnRRAwhsgUl9SDAlUdoZwZBejE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7285 X-Proofpoint-ORIG-GUID: auP1DLL3KenOzM_fnUodKFyRiOKe1i-B X-Proofpoint-GUID: auP1DLL3KenOzM_fnUodKFyRiOKe1i-B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-01_24,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 impostorscore=0 clxscore=1015 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312020009 This patch makes legacy backends optional. As was discussed at [1] this is a solution to a problem when we can't run QEMU as a device model in a non-privileged domain. This is because legacy backends assume that they are always running in domain with ID = 0. Actually, this may prevent running QEMU in a privileged domain with ID not equal to zero. With this patch it is possible to provide "--disable-xen-legacy-backends" configure option to get QEMU binary that can run in a driver domain. With price of not be able to use legacy backends of course. [1] https://lists.gnu.org/archive/html/qemu-devel/2023-11/msg05022.html Signed-off-by: Volodymyr Babchuk --- I am not sure if I made correct changes to build system, so this patch is tagged as RFC. Changes in v3: - New patch in v3 --- hw/9pfs/meson.build | 4 +++- hw/display/meson.build | 4 +++- hw/i386/pc.c | 2 ++ hw/usb/meson.build | 5 ++++- hw/xen/meson.build | 11 ++++++++--- hw/xen/xen-hvm-common.c | 2 ++ hw/xenpv/xen_machine_pv.c | 2 ++ meson.build | 5 +++++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 4 ++++ 10 files changed, 35 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 2944ea63c3..e8306ba8d2 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -15,7 +15,9 @@ fs_ss.add(files( )) fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) -fs_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-9p-backend.c')) +if have_xen_legacy_backends + fs_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-9p-backend.c')) +endif system_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) specific_ss.add(when: 'CONFIG_VIRTIO_9P', if_true: files('virtio-9p-device.c')) diff --git a/hw/display/meson.build b/hw/display/meson.build index 344dfe3d8c..18d657f6b3 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -14,7 +14,9 @@ system_ss.add(when: 'CONFIG_PL110', if_true: files('pl110.c')) system_ss.add(when: 'CONFIG_SII9022', if_true: files('sii9022.c')) system_ss.add(when: 'CONFIG_SSD0303', if_true: files('ssd0303.c')) system_ss.add(when: 'CONFIG_SSD0323', if_true: files('ssd0323.c')) -system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xenfb.c')) +if have_xen_legacy_backends + system_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xenfb.c')) +endif system_ss.add(when: 'CONFIG_VGA_PCI', if_true: files('vga-pci.c')) system_ss.add(when: 'CONFIG_VGA_ISA', if_true: files('vga-isa.c')) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 29b9964733..91857af428 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1263,7 +1263,9 @@ void pc_basic_device_init(struct PCMachineState *pcms, pci_create_simple(pcms->bus, -1, "xen-platform"); } pcms->xenbus = xen_bus_init(); +#ifdef CONFIG_XEN_LEGACY_BACKENDS xen_be_init(); +#endif } #endif diff --git a/hw/usb/meson.build b/hw/usb/meson.build index e94149ebde..8d395745b2 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -84,6 +84,9 @@ if libusb.found() hw_usb_modules += {'host': usbhost_ss} endif -system_ss.add(when: ['CONFIG_USB', 'CONFIG_XEN_BUS', libusb], if_true: files('xen-usb.c')) +if have_xen_legacy_backends + system_ss.add(when: ['CONFIG_USB', 'CONFIG_XEN_BUS', libusb], + if_true: files('xen-usb.c')) +endif modules += { 'hw-usb': hw_usb_modules } diff --git a/hw/xen/meson.build b/hw/xen/meson.build index d887fa9ba4..964c3364f2 100644 --- a/hw/xen/meson.build +++ b/hw/xen/meson.build @@ -2,11 +2,16 @@ system_ss.add(when: ['CONFIG_XEN_BUS'], if_true: files( 'xen-backend.c', 'xen-bus-helper.c', 'xen-bus.c', - 'xen-legacy-backend.c', - 'xen_devconfig.c', - 'xen_pvdev.c', )) +if have_xen_legacy_backends + system_ss.add(when: ['CONFIG_XEN_BUS'], if_true: files( + 'xen_pvdev.c', + 'xen-legacy-backend.c', + 'xen_devconfig.c', + )) +endif + system_ss.add(when: ['CONFIG_XEN', xen], if_true: files( 'xen-operations.c', )) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 565dc39c8f..2e7897dbd2 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -869,7 +869,9 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, xen_bus_init(); +#ifdef CONFIG_XEN_LEGACY_BACKENDS xen_be_init(); +#endif return; diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c index 9f9f137f99..03a55f345c 100644 --- a/hw/xenpv/xen_machine_pv.c +++ b/hw/xenpv/xen_machine_pv.c @@ -37,7 +37,9 @@ static void xen_init_pv(MachineState *machine) setup_xen_backend_ops(); /* Initialize backend core & drivers */ +#ifdef CONFIG_XEN_LEGACY_BACKENDS xen_be_init(); +#endif switch (xen_mode) { case XEN_ATTACH: diff --git a/meson.build b/meson.build index ec01f8b138..c8a43dd97d 100644 --- a/meson.build +++ b/meson.build @@ -1749,6 +1749,9 @@ have_xen_pci_passthrough = get_option('xen_pci_passthrough') \ error_message: 'Xen PCI passthrough not available on this platform') \ .allowed() +have_xen_legacy_backends = get_option('xen-legacy-backends').require(xen.found(), + error_message: 'Xen legacy backends requested but Xen not enabled').allowed() + cacard = not_found if not get_option('smartcard').auto() or have_system @@ -2219,6 +2222,7 @@ config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display) config_host_data.set('CONFIG_CFI', get_option('cfi')) config_host_data.set('CONFIG_SELINUX', selinux.found()) config_host_data.set('CONFIG_XEN_BACKEND', xen.found()) +config_host_data.set('CONFIG_XEN_LEGACY_BACKENDS', have_xen_legacy_backends) config_host_data.set('CONFIG_LIBDW', libdw.found()) if xen.found() # protect from xen.version() having less than three components @@ -3049,6 +3053,7 @@ config_all += config_targetos config_all += config_all_disas config_all += { 'CONFIG_XEN': xen.found(), + 'CONFIG_XEN_LEGACY_BACKENDS': have_xen_legacy_backends, 'CONFIG_SYSTEM_ONLY': have_system, 'CONFIG_USER_ONLY': have_user, 'CONFIG_ALL': true, diff --git a/meson_options.txt b/meson_options.txt index c9baeda639..91dd677257 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -77,6 +77,8 @@ option('nvmm', type: 'feature', value: 'auto', description: 'NVMM acceleration support') option('xen', type: 'feature', value: 'auto', description: 'Xen backend support') +option('xen-legacy-backends', type: 'feature', value: 'auto', + description: 'Xen legacy backends (9pfs, fb, qusb) support') option('xen_pci_passthrough', type: 'feature', value: 'auto', description: 'Xen PCI passthrough support') option('tcg', type: 'feature', value: 'enabled', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 680fa3f581..b5acef008f 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -218,6 +218,8 @@ meson_options_help() { printf "%s\n" ' werror Treat warnings as errors' printf "%s\n" ' whpx WHPX acceleration support' printf "%s\n" ' xen Xen backend support' + printf "%s\n" ' xen-legacy-backends' + printf "%s\n" ' Xen legacy backends (9pfs, fb, qusb) support' printf "%s\n" ' xen-pci-passthrough' printf "%s\n" ' Xen PCI passthrough support' printf "%s\n" ' xkbcommon xkbcommon support' @@ -556,6 +558,8 @@ _meson_option_parse() { --disable-whpx) printf "%s" -Dwhpx=disabled ;; --enable-xen) printf "%s" -Dxen=enabled ;; --disable-xen) printf "%s" -Dxen=disabled ;; + --enable-xen-legacy-backends) printf "%s" -Dxen-legacy-backends=enabled ;; + --disable-xen-legacy-backends) printf "%s" -Dxen-legacy-backends=disabled ;; --enable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=enabled ;; --disable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=disabled ;; --enable-xkbcommon) printf "%s" -Dxkbcommon=enabled ;; From patchwork Sat Dec 2 01:41:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13476724 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 739DFC4167B for ; Sat, 2 Dec 2023 01:41:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.645879.1008441 (Exim 4.92) (envelope-from ) id 1r9F0k-0007qM-KU; Sat, 02 Dec 2023 01:41:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 645879.1008441; Sat, 02 Dec 2023 01:41:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r9F0k-0007qD-H4; Sat, 02 Dec 2023 01:41:38 +0000 Received: by outflank-mailman (input) for mailman id 645879; Sat, 02 Dec 2023 01:41:37 +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 1r9F0j-0007jp-Cq for xen-devel@lists.xenproject.org; Sat, 02 Dec 2023 01:41:37 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ec9ee78c-90b3-11ee-9b0f-b553b5be7939; Sat, 02 Dec 2023 02:41:34 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B21Xj1G026535; Sat, 2 Dec 2023 01:41:29 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3uqt8mg21a-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 02 Dec 2023 01:41:28 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by AS8PR03MB7285.eurprd03.prod.outlook.com (2603:10a6:20b:2ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Sat, 2 Dec 2023 01:41:23 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7046.027; Sat, 2 Dec 2023 01:41:23 +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: ec9ee78c-90b3-11ee-9b0f-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jGCrxnIg0hx0I3TroprqXEzfV37pt5UBN3qgZ6sHOIaLco2UI05WeDf63axAmzWBd1/ijxxnXvwdweK6tu5lvhRh/RE+9pTP2G8+adDlbIglzwzWlrTAlXvLTdZlxluGQ6Y1HzLvDwnDhEB8ENNjyYSYxPvSOUkniY/a3CuaElP/XImGEWNw0iSULnK7yu/eBtZxzuVRHG/G5bmTujZrKe+OJUMebD51rhRpp84UM8e0B2xjpe2Fhud/cZHFe6Y1fkUB5U4ajOPBpH1CRtfn8WnhO2XXDt6pAmEm8SEW2xDdI+WpUZb9hS/MfkXt2A72Suhg93v+zVj28YGEBXjprA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D1sE3o7/1/WPykkUQrLgvygBnr35JJ7+xArB8a3+h6c=; b=Ga0bvfX1781S5oJ36DK+txA+SIru21JrwNvdbJA++aWoarOvheBw3/tnmIdU3JzvffKVBSpIia+uHH61hAwwglTylple+AMST8z7oAkwrzW2ibFejJznUTSYEN5FtcOq7I0/lMpJYLb9M/CPIYx/DZbJBRlhgPNE5DkCQxpPFoBxh7ea2kdd7SSl7eyTNIKnDT68F8tRAFQuccw+7QsZNEungjBazOEbRkq4ZJIMR/rrbzn+O+uTGdroywaErbZfvQhCCmzU8R4oDUe7C/Rr432dZZrVs5UqFN8M05jvU5CFuUBYzdlbIAdOvMjKhv3P2YRytKx9gF5pumb4nO8DPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D1sE3o7/1/WPykkUQrLgvygBnr35JJ7+xArB8a3+h6c=; b=cjla2c6sIf2gY0Bk6CbEMrhNTKF/v206Un2TND/fDyd7GBqGM9BxXmgrjtap7b76z5p5VYirm4ZhY0wE4wZ4sLdXsK59MAizaW7YcDyO/+7wFvrWq7dWYQ+ChqVtKV2ONVmyrYpPVocNre63zSwgptZAe9iVX8HhLdRqaQKMOTggMCqfgUkQHp9cKzEfBOfJdWkGNjajtuSm9uRDMYpqVbbmPO7xM+ZcZGFWNuX7eTU0GU0CfH9tOgRPJuKvvqCVO4/XDZhNsshIicso3duyWw5XUa5F75C1xTOq/oG17RfziQxRg4nCcjGKaRKHg7/G6pnwDjsogErtABe/RCOJYg== 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 v4 6/6] xen_arm: Add virtual PCIe host bridge support Thread-Topic: [PATCH v4 6/6] xen_arm: Add virtual PCIe host bridge support Thread-Index: AQHaJMCo0BornjVbl0aSaRGzaWWdGA== Date: Sat, 2 Dec 2023 01:41:23 +0000 Message-ID: <20231202014108.2017803-7-volodymyr_babchuk@epam.com> References: <20231202014108.2017803-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231202014108.2017803-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_|AS8PR03MB7285:EE_ x-ms-office365-filtering-correlation-id: 949ee9dc-8a24-4199-2fba-08dbf2d7cad8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KjcoTtbcWIF5OI9JMph43mydcyPVte4s3LMDrNx5qdhvPSNe0/0WYy66kIGdvXPRsG1OII0xO4bQtscefMIdVX1GLtLX9HiNsE6VNylJ28AQEVf/qwoqky8TFmL7sFI4IjznsGXRT/Z31s3w7mFvDPTdiaDZoTIPaXP3PvF2hH9308KG+blQiApKyMSaUkaWxroEdgnkK0L3oWAwUuBBvH8SVOMbhrYs+3KWV4hM1P8eZZzxbbG/s5RVQXM6L8/1aKNEHxaCRhfIUxH2HNIKPnjqiPB0l3xror0VlAV31QJigvn6CsheyKvdMmPccdjCy9NDSoY3IxD1HTaaQZnW9wpkYb7GJYeEuFmqoY2CffJY+RjvBCnnsT8gXGloDrIn5fjk8OPtVu/6QzJsMXG9OdRG06CscvbvNfginu52f/g2u8tmgq3Nnq7okFaMEmYkjYx9OgF74oNmhl+VjUnFH2ciraxSmirBoAr3IHLPvVkwkT5VKizaXLIJ8+G/qUjOky2BX/tti/DDu0VgFutkR7eiYujXkLr1zad/X1Q4aJ+SK9ujG7CjYuQVFCB2Hmi8AaTQV15Y6lXTeEV+45w9UaDxv8Zl4KXDfPvJMeBKrraK2pxBuZtiZ6S2gEXFYYYr 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)(39860400002)(376002)(396003)(366004)(346002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(122000001)(38070700009)(41300700001)(2906002)(30864003)(5660300002)(83380400001)(71200400001)(55236004)(38100700002)(6506007)(6512007)(1076003)(2616005)(26005)(66556008)(478600001)(91956017)(6486002)(36756003)(76116006)(66946007)(64756008)(66446008)(8936002)(6916009)(54906003)(86362001)(66476007)(4326008)(316002)(8676002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?VhgFjOw+sealzzey+FGUtYx?= =?iso-8859-1?q?94cTDA3Fwtvwmq16SmwvPTlWgX5H3ssFwFL0Fosjv3h/vxxmJmoZXu9zVwy3?= =?iso-8859-1?q?1vbYcKHiR5dQ08rEMxG7izt6aAlNsTG1kWp7NLi6lmjzElnlT1FH+1W7Bh8x?= =?iso-8859-1?q?cgqT7TXyV3Wq76j3GPSNwslqNI6ICMlqYewA6FbZ+PbXTJw6nt98MtcsvsaA?= =?iso-8859-1?q?huRFGxmfZ2KxEvjIAurslCK+tHa9XAiBNsmGB47HQH36nDPL9pyNfUfXU7nZ?= =?iso-8859-1?q?aM56c1OojZqxCmWuxqjaVBV52kPKmGhZ0RCPCQwmbz7Xz0XyZpHoIQ3iZ+8b?= =?iso-8859-1?q?eBJE3TwuMVqZ7NOJJnxBrcApO8p3Ux6bwxtbXP5htXiqyWxeYkJ6Mfk+635x?= =?iso-8859-1?q?CpJIROSScArkQq+TAOLHxGkzceKiRNevznDa9wLalBJYdQ2whq105PF/ddDJ?= =?iso-8859-1?q?Wm2c+k1pTf09p+Ya14eeO4ICz7qvhdzlYlK750kqsNdzI08MkhhXYbwoZ9wI?= =?iso-8859-1?q?fVCpfbhOoRwTjYZptnGcKx7YZbWVny7y/ftvuhcb+I/LGfNSPW+S9KFOQVzL?= =?iso-8859-1?q?vQ+UBlQvVbA6tMY4UtkOTzdWRKecrUvNw9wBMN883xslrNE2Tnav1A7oGvcx?= =?iso-8859-1?q?OGuWVRp48NMYt1vQEW9FSELaWS13fkGoJ7RfPfXT9DWcGDwaCtV7ORvjjFNt?= =?iso-8859-1?q?DUseseL67fv2SFLYnQ2nUpSWRQg5pUdY6zZSdegViUWjxrnQz3x4fkniSozT?= =?iso-8859-1?q?ynM8wQi2zMpW1zLJi/Nj7/88/kin6ARaxEBjymdb11E3N4PnidqHP1TonsV6?= =?iso-8859-1?q?V44WaVyx3R2LR6pDh58b+DDkMluWTaO9VpFVQsCQNp9JmbUly/azjNtK+GBo?= =?iso-8859-1?q?CUyoy0upLJTEF9D/V02rNYvpvfYVKi0m22cXrvQx+HRwvEjaxfo/T/w6UBuJ?= =?iso-8859-1?q?qwkb8fNA6C2fhZ9H/gcFCW1PqiOlKidG1CuYhAF+0CZkn+GY2RR9jlKT03Yb?= =?iso-8859-1?q?eZfqBrXSuBifypJswmMCgvcTY1RaWE3fz0I0xKY3kRV9E9EXcq+HcyoQBqmI?= =?iso-8859-1?q?/aSYhrTr0c0fmMg9E53DHYYdC6kOet5T/UvahnLJrAIgxcoyOCzcSeIkm43p?= =?iso-8859-1?q?6Pi47OMb9KNR71cqcoa16Wrwr9XtX/ib0dDmL9sM9vz9QzpyfIMQoZQ6pK35?= =?iso-8859-1?q?griJGW7/Ct2S+wPhd4Z8ezmc3dqkQkiNBeruRoOlpGBE/1L/1TxNi4lAWvLx?= =?iso-8859-1?q?MlcJdWDOR0tsGT3RtBjnK6knZfXiYm8frb5cqAG74njybQDIsAYP4Hmx3TPX?= =?iso-8859-1?q?6pmHmzh1Grnu0uX7hUHhZ31PbUoj2UfVt8wNCqSr5LfphHVJ6uOmdMq2fLw7?= =?iso-8859-1?q?nA3JjWLWe0J/jeV8Zz0r+Dxs+6fvDodPxdT08VWYRCezs5f5BX0izHYqIxbh?= =?iso-8859-1?q?UcYsYRMSMgGxw5EzF4U8Z9VxBaOIkGNNwPXbua2HRWXm0mAYPspzzGL2IlgK?= =?iso-8859-1?q?MuuBbyy3Tp63gvqZu/BMLL/uMP5T9lRq+Ohl+dsr7R4O/XRwlG8s3yMhTUD3?= =?iso-8859-1?q?ScLcf+wvbzh5O+Ai7yxOOvxZNpEoeSM7/tQJY1YdvWS2aazPX28x5hKi7u0r?= =?iso-8859-1?q?88hOWWSRgeAZeKlox4+osPF3zv6V29n0QFQ5pow=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: 949ee9dc-8a24-4199-2fba-08dbf2d7cad8 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Dec 2023 01:41:23.7697 (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: K5v7ptYctR9rW7ZhsrwIHjfqXwoq44w6D1no8yvkruzTXjGGCP8BfZJENombVT6PWoRF/fHWT/9E7P7bBxmCDTJNraWf7drlA2uQX0A819I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7285 X-Proofpoint-ORIG-GUID: zPLSo3Bgabl3StRLPmaNAY-xl3gPbGSz X-Proofpoint-GUID: zPLSo3Bgabl3StRLPmaNAY-xl3gPbGSz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-01_24,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 mlxscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312020009 From: Oleksandr Tyshchenko The bridge is needed for virtio-pci support, as QEMU can emulate the whole bridge with any virtio-pci devices connected to it. This patch provides a flexible way to configure PCIe bridge resources using QEMU machine properties. We made this for several reasons: - We don't want to clash with vPCI devices, so we need information from Xen toolstack on which PCI bus to use. - The guest memory layout that describes these resources is not stable and may vary between guests, so we cannot rely on static resources to be always the same for both ends. - Also the device-models which run in different domains and serve virtio-pci devices for the same guest should use different host bridge resources for Xen to distinguish. The rule for the guest device-tree generation is one PCI host bridge per backend domain. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Volodymyr Babchuk --- Changes in v3: - Use QOM properties instead of reading from XenStore - Remove unneeded includes - Move pcie_* fields into "struct cfg" Changes in v2: - Renamed virtio_pci_host to pcie_host entries in XenStore, because there is nothing specific to virtio-pci: any PCI device can be emulated via this newly created bridge. --- hw/arm/xen_arm.c | 226 ++++++++++++++++++++++++++++++++++++ hw/xen/xen-hvm-common.c | 9 +- include/hw/xen/xen_native.h | 8 +- 3 files changed, 240 insertions(+), 3 deletions(-) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index b9c3ae14b6..dc6d3a1d82 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -34,6 +34,7 @@ #include "hw/xen/xen-hvm-common.h" #include "sysemu/tpm.h" #include "hw/xen/arch_hvm.h" +#include "hw/pci-host/gpex.h" #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) @@ -57,6 +58,10 @@ struct XenArmState { struct { uint64_t tpm_base_addr; + MemMapEntry pcie_mmio; + MemMapEntry pcie_ecam; + MemMapEntry pcie_mmio_high; + int pcie_irq_base; } cfg; }; @@ -73,6 +78,15 @@ static MemoryRegion ram_lo, ram_hi; #define NR_VIRTIO_MMIO_DEVICES \ (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) +#define XEN_ARM_PCIE_ECAM_BASE "pcie-ecam-base" +#define XEN_ARM_PCIE_ECAM_SIZE "pcie-ecam-size" +#define XEN_ARM_PCIE_MEM_BASE "pcie-mem-base" +#define XEN_ARM_PCIE_MEM_SIZE "pcie-mem-size" +#define XEN_ARM_PCIE_PREFETCH_BASE "pcie-prefetch-mem-base" +#define XEN_ARM_PCIE_PREFETCH_SIZE "pcie-prefetch-mem-size" +#define XEN_ARM_PCIE_IRQ_BASE "pcie-irq-base" + +/* TODO It should be xendevicemodel_set_pci_intx_level() for PCI 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 +143,89 @@ static void xen_init_ram(MachineState *machine) } } +static bool xen_validate_pcie_config(XenArmState *xam) +{ + if (xam->cfg.pcie_ecam.base == 0 && + xam->cfg.pcie_ecam.size == 0 && + xam->cfg.pcie_mmio.base == 0 && + xam->cfg.pcie_mmio.size == 0 && + xam->cfg.pcie_mmio_high.base == 0 && + xam->cfg.pcie_mmio_high.size == 0 && + xam->cfg.pcie_irq_base == 0) { + + /* It's okay, user just don't want PCIe brige */ + + return false; + } + + if (xam->cfg.pcie_ecam.base == 0 || + xam->cfg.pcie_ecam.size == 0 || + xam->cfg.pcie_mmio.base == 0 || + xam->cfg.pcie_mmio.size == 0 || + xam->cfg.pcie_mmio_high.base == 0 || + xam->cfg.pcie_mmio_high.size == 0 || + xam->cfg.pcie_irq_base == 0) { + + /* User provided some PCIe options, but not all of them */ + + error_printf("Incomplete PCIe bridge configuration\n"); + + exit(1); + } + + return true; +} + +static void xen_create_pcie(XenArmState *xam) +{ + MemoryRegion *mmio_alias, *mmio_alias_high, *mmio_reg; + MemoryRegion *ecam_alias, *ecam_reg; + DeviceState *dev; + int i; + + dev = 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->cfg.pcie_ecam.size); + memory_region_add_subregion(get_system_memory(), xam->cfg.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->cfg.pcie_mmio.base, + xam->cfg.pcie_mmio.size); + memory_region_add_subregion(get_system_memory(), xam->cfg.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->cfg.pcie_mmio_high.base, + xam->cfg.pcie_mmio_high.size); + memory_region_add_subregion(get_system_memory(), + xam->cfg.pcie_mmio_high.base, + mmio_alias_high); + + /* Legacy PCI interrupts (#INTA - #INTD) */ + for (i = 0; i < GPEX_NUM_IRQS; i++) { + qemu_irq irq = qemu_allocate_irq(xen_set_irq, NULL, + xam->cfg.pcie_irq_base + i); + + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); + gpex_set_irq_num(GPEX_HOST(dev), i, xam->cfg.pcie_irq_base + i); + } + + DPRINTF("Created PCIe host bridge\n"); +} + void arch_handle_ioreq(XenIOState *state, ioreq_t *req) { hw_error("Invalid ioreq type 0x%x\n", req->type); @@ -189,6 +286,12 @@ static void xen_arm_init(MachineState *machine) xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener); xen_create_virtio_mmio_devices(xam); + if (xen_validate_pcie_config(xam)) { + xen_create_pcie(xam); + } else { + DPRINTF("PCIe host bridge is not configured," + " only virtio-mmio can be used\n"); + } #ifdef CONFIG_TPM if (xam->cfg.tpm_base_addr) { @@ -225,6 +328,90 @@ static void xen_arm_set_tpm_base_addr(Object *obj, Visitor *v, } #endif +static void xen_arm_get_pcie_prop(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam = XEN_ARM(obj); + hwaddr *target; + + if (!strcmp(name, XEN_ARM_PCIE_ECAM_BASE)) { + target = &xam->cfg.pcie_ecam.base; + } else if (!strcmp(name, XEN_ARM_PCIE_ECAM_SIZE)) { + target = &xam->cfg.pcie_ecam.size; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_BASE)) { + target = &xam->cfg.pcie_mmio.base; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_SIZE)) { + target = &xam->cfg.pcie_mmio.size; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_BASE)) { + target = &xam->cfg.pcie_mmio_high.base; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_SIZE)) { + target = &xam->cfg.pcie_mmio_high.size; + } else { + /* Unreachable */ + assert(false); + return; + } + + visit_type_uint64(v, name, target, errp); +} + +static void xen_arm_set_pcie_prop(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam = XEN_ARM(obj); + uint64_t value; + hwaddr *target; + + if (!strcmp(name, XEN_ARM_PCIE_ECAM_BASE)) { + target = &xam->cfg.pcie_ecam.base; + } else if (!strcmp(name, XEN_ARM_PCIE_ECAM_SIZE)) { + target = &xam->cfg.pcie_ecam.size; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_BASE)) { + target = &xam->cfg.pcie_mmio.base; + } else if (!strcmp(name, XEN_ARM_PCIE_MEM_SIZE)) { + target = &xam->cfg.pcie_mmio.size; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_BASE)) { + target = &xam->cfg.pcie_mmio_high.base; + } else if (!strcmp(name, XEN_ARM_PCIE_PREFETCH_SIZE)) { + target = &xam->cfg.pcie_mmio_high.size; + } else { + /* Unreachable */ + assert(false); + return; + } + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + *target = value; +} + +static void xen_arm_get_pcie_irq_base(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam = XEN_ARM(obj); + int64_t value = xam->cfg.pcie_irq_base; + + visit_type_int(v, name, &value, errp); +} + +static void xen_arm_set_pcie_irq_base(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + XenArmState *xam = XEN_ARM(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + xam->cfg.pcie_irq_base = value; +} + static void xen_arm_machine_class_init(ObjectClass *oc, void *data) { @@ -246,6 +433,45 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data) machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); #endif + + object_class_property_add(oc, XEN_ARM_PCIE_ECAM_BASE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_ECAM_BASE, + "Base address for ECAM range of virtual PCIe host bridge"); + object_class_property_add(oc, XEN_ARM_PCIE_ECAM_SIZE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_ECAM_SIZE, + "Size of ECAM range of virtual PCIe host bridge"); + + object_class_property_add(oc, XEN_ARM_PCIE_MEM_BASE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_MEM_BASE, + "Base address for non-prefetchable memory of virtual PCIe host bridge"); + object_class_property_add(oc, XEN_ARM_PCIE_MEM_SIZE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_MEM_SIZE, + "Size of non-prefetchable memory of virtual PCIe host bridge"); + + object_class_property_add(oc, XEN_ARM_PCIE_PREFETCH_BASE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_PREFETCH_BASE, + "Base address for prefetchable memory of virtual PCIe host bridge"); + object_class_property_add(oc, XEN_ARM_PCIE_PREFETCH_SIZE, "uint64_t", + xen_arm_get_pcie_prop, + xen_arm_set_pcie_prop, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_PREFETCH_SIZE, + "Size of prefetchable memory of virtual PCIe host bridge"); + + object_class_property_add(oc, XEN_ARM_PCIE_IRQ_BASE, "int", + xen_arm_get_pcie_irq_base, + xen_arm_set_pcie_irq_base, NULL, NULL); + object_class_property_set_description(oc, XEN_ARM_PCIE_IRQ_BASE, + "Number of first PCI legacy interrupt for PCIe host bridge"); } static const TypeInfo xen_arm_machine_type = { diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 2e7897dbd2..19fcccdb16 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -47,6 +47,8 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, g_free(pfn_list); } +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));