From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343262; cv=pass; d=zohomail.com; s=zohoarc; b=a5HUqMznnad320xwR+hckUQyH5pjzPdCVcq50hZUHjRtDjlAPHluXc4j+NVp/0tmVVA0yPNfGdGZAvCnJojn7vpJP/7xTGJissnOEKamVQ6HpRMPqBt5WE5PTz3NooDDaiOYF4QVZ5RBe4YOj5zf0VLgQmHl9ZSfBqdNpn7OovA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343262; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zp886fdenazy8I4uy4JOrrugnDLYw+4E5d77d3IGdYU=; b=EDk75XComxwXKAlhzFWlypZs+JvI7VFEwlk86VO8ofgZWY+3cC3KrDLxPvkhUorZykM+7obOO5SOwY4OuTAPhBCIm29tNou63JKaFsN7v9NG/SJVV4GicYSwGih1Cp1uPFBEt1OAKSDoKPZmIyoEDBZj9BnEn2a29rLsq1FJwsY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644343262393671.6875831022961; Tue, 8 Feb 2022 10:01:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268491.462331 (Exim 4.92) (envelope-from ) id 1nHUmo-00068d-Cc; Tue, 08 Feb 2022 18:00:18 +0000 Received: by outflank-mailman (output) from mailman id 268491.462331; Tue, 08 Feb 2022 18:00:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmo-00068W-9f; Tue, 08 Feb 2022 18:00:18 +0000 Received: by outflank-mailman (input) for mailman id 268491; Tue, 08 Feb 2022 18:00:17 +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 1nHUmn-00068K-3w for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:17 +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 f67cc8ae-8908-11ec-8f75-fffcc8bd4f1a; Tue, 08 Feb 2022 19:00:14 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrT2015757; Tue, 8 Feb 2022 18:00:12 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:11 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:06 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f67cc8ae-8908-11ec-8f75-fffcc8bd4f1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YiwDlP3vRAbBoMjwRE1DEMeNzuy/z4yOtYj+6mxRiCegonEQ01woy2anuIGi+cFAXjJMO4Pg4pF+S4t+6IdDlC3/lSAnJOqa7u9CnlJ61t3dYeNlmCxB8vYc+6kuBb6IsJgMh0QK3yL0moIsm0xypelXrtCZ4nrx0rk/rS1A4a0Uck07r/4VKwXSO398sTnvbTnFOCk4OIP7TGTvkfH70nms7uC8bqTyXhP0D/A6DChg8SETmd4WKiJ/YtyGlDmRKy6CiWRHqpChsceAFjjTuCB+9Ure1ZTkVZQbQjMaykuUralkABpHyWVj7V5qT9/6cx6XA8dEVYHu/wL2Peymaw== 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=Zp886fdenazy8I4uy4JOrrugnDLYw+4E5d77d3IGdYU=; b=QUxMC3tOWqSmKH7p+bAsfGvJGbup8DmnObj4KIOwZIF2F+Mtdh0XLM6Zwx0w0RnBgk/1EQAsraDfij8WoGQzkfEH1i7uoNnZPkpWldyfLhcTyYilWdiQEd5c9fgmjP9GGYjpUFEbHiiR3o3jueECbmiLLp3wNorJciPK7AmufAesPXxOwDEiTIs4gSqhihxhCuDkL5cAZWZ7Kmb29WUZCFWrIrGM195PWV1pCu3lw9aLSjNpnG0J99die9vW6XgyoGLNRbFX5iwbN/yg3lY23W4683ctxUQPs5/ReapKsQyTzBtZeU6zsHD7QeuxiDcOW5fh6nlnEukpeFi7KSZkUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=Zp886fdenazy8I4uy4JOrrugnDLYw+4E5d77d3IGdYU=; b=eC+n5fSTp8riCSmttv9a7mw1RZaur//zyuhK2meAE9XVyTLuXMkeQGGDBDpszNmcRA3f5M17PVhKNeYdIv1Zasz6TBKbsS9pcWAcNkxZU6Llx2xO39thw2aufY8hq1JB9j24XPvZ1vYqEQR2lHl3ZiSFardLrUImfQvFIoTpHY9LOHm6ZU8F99uX1kugrJqgy54JteK6JOhJyuYU7cW/Sk9x7IxCkCcdWi9Bz8dRkJPFlRR6bP4/ZQgW6do6ErVF1ov9puWknlEQd83cL01bZeBTEiZ1DRBaDtBfa667pcMKygoqfEwd/rLhAqDuZ3H9UwAzITSg5/Yq48sfSwuWjg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Juergen Gross Subject: [RFC v2 1/8] xen/hypfs: support fo nested dynamic hypfs nodes Thread-Topic: [RFC v2 1/8] xen/hypfs: support fo nested dynamic hypfs nodes Thread-Index: AQHYHRW07SkrMxyT/k6/hhSCHW7Rmg== Date: Tue, 8 Feb 2022 18:00:06 +0000 Message-ID: <8ab7e9ffd5f041c2631f754c7c596874cf6a99c1.1644341635.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ec53d40c-2a59-49f2-c7b6-08d9eb2cd6e4 x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: M925godofpc/lzkYZpjCxO5Z3+hNdtDE0Aeme/XmzDf6pgAQe9GTjMproVG2AhJNtKXKbTwUK+92SQ54Xb9DXbpdd6+nkygZncTMbuzsLn8hBxnI2dXKggeIR6p+Oy9RpS8hX7RWFZo/d6zLJQI4mfAczAxRXzQqh/71a17jHCVRyVG6YP8L7ZEFXhMpupR1l4eTAgqDpg9TVeHgVcYU2RO6fhfrZDnVYn5AP0NHQ071H1UouXsxbCNmcuZ2E3JWi+4EL7vVf8CinOFEsqtpMbIDNCHHNWXDS0Ng/KOb4EagJdnzRvVwghATY/sFJAVm9xSBbm4qb+y2QynfQAbSh/TewpcGIXCCUjPc4kVNs+rPQgexC2g6FtExTpl89wfWLNS3hRezjt6sK7N6BottTQOm0MQ5qtbubqfh53lzsX369HQUEYkoH7U98VcP7iMMMdO6ZSkqM+3ebaTdTqIBTSOWTuxQ1WeuTOtgAhacY2kIU4YSMklFm5H2viWCmfXDcsNq6xVpIuJbbNHLCnc3OTzWczBgf7R2BLop+oNVQF+mfg5gBeK2W4qWiBnOFY75v9g6fcZhDFzNNd7G+6UQfWD4IMZI25KKjXUp1cQANZFS5Mf7MOBKz0n01/9Hj5nhAKcu9yFp5ZTgv8rZ9zBoJYAu6kV5gEkWmejTbd7UnO3AalCtplUcZTQiWjYnidUY4v6ei0AOC2OLMzf3QJCkiA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(4326008)(83380400001)(54906003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?xKkU+ob0B1OPUwigD9emPoDS22D1O39Rrg3DSS1fWHxhAr7Y5bEU8WvzIY?= =?iso-8859-1?Q?6JV9Vu9BPWYuTzB58EqKnJdHFFeamOqTMBvHTw4gRaRptlonfOS07/fYBl?= =?iso-8859-1?Q?XduE9KQ43rx7C31uy42IlKFTopeIp9W4naazv4wlpMftuZuA1Ugb8nUpFU?= =?iso-8859-1?Q?nCgwrt3vWeSY1tGOPw4CoiL7Vxpl4wzT1sjZX0AC7p8P1GxJxRdMIZDgvB?= =?iso-8859-1?Q?5nJf1pw9zBlYUArzGRQ70kt4Ol1bUYmD12+hg7GseRojRfiDf3ixylX47e?= =?iso-8859-1?Q?96iRC5x1cNVgMI9W1bDovGT9QV4DjCFTmoww5tkAhWsrUTg7i32POmWDGe?= =?iso-8859-1?Q?Oy0+wX8WkrSUao6AFrQJZtWXrK+da+PwJckxk5M0rStf70sNoraF4Xiplb?= =?iso-8859-1?Q?3RWs8McyG5Pq0O6QWvBs7eUUS4Zg83Mdzs+5or5UXij1BRGg3o5lZi40u2?= =?iso-8859-1?Q?BWcDA9eYuyJP/DGb6gXn2zOnoJArqpHZiWmM1CIJP92tj60yncpK5bVh/f?= =?iso-8859-1?Q?V4QUzF+8ELuDrXvv0DT+hPW/77GzrTjyK/ox4EfbBhOvYDJil3vY9YSGTz?= =?iso-8859-1?Q?OUVHLVb2zb4M+DqlBSJhcotbmFz+F32LcJrGMJdEBL4LbKlAd9/WRnRHqA?= =?iso-8859-1?Q?C+h9r1RTqNIKjao8IDhyEfWu/7TVVNxdGFLvTWdcYLUiKrgsNKdXrsXz82?= =?iso-8859-1?Q?ZSzuOqXlmi6EMnT8ZHTCOiFA4k2bkHJKB4OTJLnOKw4YIj9LibBLZdjpou?= =?iso-8859-1?Q?xe25t8ybXI8AgmCr6Cbcf2KCmwwpDGHwyDHn//wtwXzQRLdQHi6QDASL4Y?= =?iso-8859-1?Q?dCY1iap4wGNMNES0hJT6v4f1PHk9qYVGkzBa6NqJRIj5qfahl+tgyzmTSr?= =?iso-8859-1?Q?kf7zbEsb9XdrieItx7hTDfnt0qhZz4eyjh3u0CyuqUdfHM3ZoQxZFqi4Pk?= =?iso-8859-1?Q?+u719DmVaWS6QDY0wzGZVIqzEVtZEh+xGW9v3Hqk6umg1txClUApWlZV/U?= =?iso-8859-1?Q?Jx7rk6oG9V3n9VoQoQ641Qxj4YIkfC2Rbo65s+uBn/BnxHYKunNeW7FQOT?= =?iso-8859-1?Q?ddoib8eAB7AQ/30VPf00pZ0Om5oCMPq9PGjKmrUzCxRonNjOUF57tjhxjn?= =?iso-8859-1?Q?yXaJumqLFI6b+ztYicmFxwzM5Dt2LvIQSaVqrU2OBDENTSvjin6eLW7K0o?= =?iso-8859-1?Q?C04qvWRzPvH0fRkSSQl9+LGsLx9ZzRmJ7B24SVPjVwv/A5NhCz8u4r5jxw?= =?iso-8859-1?Q?f4YSK9sO2pskpNvdHC+6hcSlaOvgnTgqMn1Jvz9lxS1CzUJxYLJLgJ/nLe?= =?iso-8859-1?Q?AlB1iWB0o5Xzp+2jfXyLVsRosZubEhg53+iC71Yo8rdgpll6+/awQtKsh6?= =?iso-8859-1?Q?04r+a4wzZBmTM75QaUl6vgelYYjsBOQ239Ov1I1x0/2dWnt0MgGaBAtaqk?= =?iso-8859-1?Q?dhNs4xAfyatIVHetWo/wrzlGMIzHKYvTY/AiKZrw/ilIOnxYpj7NSzGG8m?= =?iso-8859-1?Q?9PXtwhvZzLR34GD8ts3edyDzAyW1dUwqu6QDovxltcH0JUYuOr/L2QXUlD?= =?iso-8859-1?Q?1wxKCIRVxbs3/+ruDLDy4xHm8WrCpixfqS2G9SLFvtSHTt7kiQmIb+TV7J?= =?iso-8859-1?Q?DN7/RppWhHk/wxKQFd9d26T2zKRD3fx8bB/3VNcdFWUlZ3VOJOjziM5iAj?= =?iso-8859-1?Q?mZiNaooPznVGIVAPuiyJFZIcOvnHGZC9KGMMNKumBpwl/Q3QuG2oqdXv+s?= =?iso-8859-1?Q?8B+aYYPArPFJKrdmBRyJDP3hc=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec53d40c-2a59-49f2-c7b6-08d9eb2cd6e4 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:06.5573 (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: gM2gdTx06HrrtJ3eII21MiAK5rjeTo34Opxb3ACRe6fNYG4RBMTkmvsByH5gx1qItsN1kNDrWrxfPX40aUvAKSnxNWBbXhGIA2CfjSSszks= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: xlpRPLEwV6HuY1SOqqNURSozi-PfZpJB X-Proofpoint-ORIG-GUID: xlpRPLEwV6HuY1SOqqNURSozi-PfZpJB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343264046100009 Content-Type: text/plain; charset="utf-8" Add new api: - hypfs_read_dyndir_entry - hypfs_gen_dyndir_entry which are the extension of the dynamic hypfs nodes support, presented in 0b3b53be8cf226d947a79c2535a9efbb2dd7bc38. This allows nested dynamic nodes to be added. Also input parameter is hypfs_entry, so properties can also be generated dynamically. Generating mixed list of dirs and properties is also supported. Same as to the dynamic hypfs nodes, this is anchored in percpu pointer, which can be retriewed on any level of the dynamic entries. This handle should be allocated on enter() callback and released on exit() callback. When using nested dynamic dirs and properties handle should be allocated on the first enter() call and released on the last exit() call. Signed-off-by: Oleksii Moisieiev --- xen/common/hypfs.c | 83 +++++++++++++++++++++++++++++++++-------- xen/include/xen/hypfs.h | 14 ++++++- 2 files changed, 79 insertions(+), 18 deletions(-) diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c index e71f7df479..6901f5e311 100644 --- a/xen/common/hypfs.c +++ b/xen/common/hypfs.c @@ -367,28 +367,27 @@ unsigned int hypfs_getsize(const struct hypfs_entry *= entry) =20 /* * Fill the direntry for a dynamically generated entry. Especially the - * generated name needs to be kept in sync with hypfs_gen_dyndir_id_entry(= ). + * generated name needs to be kept in sync with hypfs_gen_dyndir_entry(). */ -int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template, - unsigned int id, bool is_last, +int hypfs_read_dyndir_entry(const struct hypfs_entry *template, + const char *name, unsigned int namelen, + bool is_last, XEN_GUEST_HANDLE_PARAM(void) *uaddr) { struct xen_hypfs_dirlistentry direntry; - char name[HYPFS_DYNDIR_ID_NAMELEN]; - unsigned int e_namelen, e_len; + unsigned int e_len; =20 - e_namelen =3D snprintf(name, sizeof(name), template->e.name, id); - e_len =3D DIRENTRY_SIZE(e_namelen); + e_len =3D DIRENTRY_SIZE(namelen); direntry.e.pad =3D 0; - direntry.e.type =3D template->e.type; - direntry.e.encoding =3D template->e.encoding; - direntry.e.content_len =3D template->e.funcs->getsize(&template->e); - direntry.e.max_write_len =3D template->e.max_size; + direntry.e.type =3D template->type; + direntry.e.encoding =3D template->encoding; + direntry.e.content_len =3D template->funcs->getsize(template); + direntry.e.max_write_len =3D template->max_size; direntry.off_next =3D is_last ? 0 : e_len; if ( copy_to_guest(*uaddr, &direntry, 1) ) return -EFAULT; if ( copy_to_guest_offset(*uaddr, DIRENTRY_NAME_OFF, name, - e_namelen + 1) ) + namelen + 1) ) return -EFAULT; =20 guest_handle_add_offset(*uaddr, e_len); @@ -396,6 +395,22 @@ int hypfs_read_dyndir_id_entry(const struct hypfs_entr= y_dir *template, return 0; } =20 +/* + * Fill the direntry for a dynamically generated entry. Especially the + * generated name needs to be kept in sync with hypfs_gen_dyndir_id_entry(= ). + */ +int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template, + unsigned int id, bool is_last, + XEN_GUEST_HANDLE_PARAM(void) *uaddr) +{ + char name[HYPFS_DYNDIR_ID_NAMELEN]; + unsigned int e_namelen; + + e_namelen =3D snprintf(name, sizeof(name), template->e.name, id); + return hypfs_read_dyndir_entry(&template->e, name, e_namelen, is_last,= uaddr); +} + + static const struct hypfs_entry *hypfs_dyndir_enter( const struct hypfs_entry *entry) { @@ -404,7 +419,7 @@ static const struct hypfs_entry *hypfs_dyndir_enter( data =3D hypfs_get_dyndata(); =20 /* Use template with original enter function. */ - return data->template->e.funcs->enter(&data->template->e); + return data->template->funcs->enter(data->template); } =20 static struct hypfs_entry *hypfs_dyndir_findentry( @@ -415,7 +430,7 @@ static struct hypfs_entry *hypfs_dyndir_findentry( data =3D hypfs_get_dyndata(); =20 /* Use template with original findentry function. */ - return data->template->e.funcs->findentry(data->template, name, name_l= en); + return data->template->funcs->findentry(&data->dir, name, name_len); } =20 static int hypfs_read_dyndir(const struct hypfs_entry *entry, @@ -426,7 +441,36 @@ static int hypfs_read_dyndir(const struct hypfs_entry = *entry, data =3D hypfs_get_dyndata(); =20 /* Use template with original read function. */ - return data->template->e.funcs->read(&data->template->e, uaddr); + return data->template->funcs->read(data->template, uaddr); +} + +/* + * Fill dyndata with a dynamically generated entry based on a template + * and a name. + * Needs to be kept in sync with hypfs_read_dyndir_entry() regarding the + * name generated. + */ +struct hypfs_entry *hypfs_gen_dyndir_entry( + const struct hypfs_entry *template, const char *name, + void *data) +{ + struct hypfs_dyndir_id *dyndata; + + dyndata =3D hypfs_get_dyndata(); + + dyndata->template =3D template; + dyndata->data =3D data; + memcpy(dyndata->name, name, strlen(name)); + dyndata->dir.e =3D *template; + dyndata->dir.e.name =3D dyndata->name; + + dyndata->dir.e.funcs =3D &dyndata->funcs; + dyndata->funcs =3D *template->funcs; + dyndata->funcs.enter =3D hypfs_dyndir_enter; + dyndata->funcs.findentry =3D hypfs_dyndir_findentry; + dyndata->funcs.read =3D hypfs_read_dyndir; + + return &dyndata->dir.e; } =20 /* @@ -442,12 +486,13 @@ struct hypfs_entry *hypfs_gen_dyndir_id_entry( =20 dyndata =3D hypfs_get_dyndata(); =20 - dyndata->template =3D template; + dyndata->template =3D &template->e; dyndata->id =3D id; dyndata->data =3D data; snprintf(dyndata->name, sizeof(dyndata->name), template->e.name, id); dyndata->dir =3D *template; dyndata->dir.e.name =3D dyndata->name; + dyndata->dir.e.funcs =3D &dyndata->funcs; dyndata->funcs =3D *template->e.funcs; dyndata->funcs.enter =3D hypfs_dyndir_enter; @@ -457,6 +502,12 @@ struct hypfs_entry *hypfs_gen_dyndir_id_entry( return &dyndata->dir.e; } =20 +unsigned int hypfs_dyndir_entry_size(const struct hypfs_entry *template, + const char *name) +{ + return DIRENTRY_SIZE(strlen(name)); +} + unsigned int hypfs_dynid_entry_size(const struct hypfs_entry *template, unsigned int id) { diff --git a/xen/include/xen/hypfs.h b/xen/include/xen/hypfs.h index e9d4c2555b..5d2728b963 100644 --- a/xen/include/xen/hypfs.h +++ b/xen/include/xen/hypfs.h @@ -79,8 +79,8 @@ struct hypfs_entry_dir { struct hypfs_dyndir_id { struct hypfs_entry_dir dir; /* Modified copy of template. = */ struct hypfs_funcs funcs; /* Dynamic functions. */ - const struct hypfs_entry_dir *template; /* Template used. */ -#define HYPFS_DYNDIR_ID_NAMELEN 12 + const struct hypfs_entry *template; /* Template used. */ +#define HYPFS_DYNDIR_ID_NAMELEN 32 char name[HYPFS_DYNDIR_ID_NAMELEN]; /* Name of hypfs entry. */ =20 unsigned int id; /* Numerical id. */ @@ -197,13 +197,23 @@ void *hypfs_alloc_dyndata(unsigned long size); #define hypfs_alloc_dyndata(type) ((type *)hypfs_alloc_dyndata(sizeof(type= ))) void *hypfs_get_dyndata(void); void hypfs_free_dyndata(void); +int hypfs_read_dyndir_entry(const struct hypfs_entry *template, + const char *name, unsigned int namelen, + bool is_last, + XEN_GUEST_HANDLE_PARAM(void) *uaddr); int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template, unsigned int id, bool is_last, XEN_GUEST_HANDLE_PARAM(void) *uaddr); +struct hypfs_entry *hypfs_gen_dyndir_entry( + const struct hypfs_entry *template, const char *name, + void *data); struct hypfs_entry *hypfs_gen_dyndir_id_entry( const struct hypfs_entry_dir *template, unsigned int id, void *data); unsigned int hypfs_dynid_entry_size(const struct hypfs_entry *template, unsigned int id); +unsigned int hypfs_dyndir_entry_size(const struct hypfs_entry *template, + const char *name); + #endif =20 #endif /* __XEN_HYPFS_H__ */ --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343259; cv=pass; d=zohomail.com; s=zohoarc; b=FHHi1t1rFq3SU3UqKDloDPXiE2AoMCXO569//DSdVQU4dYAv/qYtFKO73wsO0lVwmhK6gXMnIvsPlgWl3mMtTz8Rz+a1h82K+iItrcx1nd1BlxE0nFEASljsTswE+b6kiaQAyGcdI1sHftUsAHEw9Zx+1O744FLsK6gLeoqAbBY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343259; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s+Pd6wDqIcFv+WQby17OvQO3c7K+c3WVoYLWvGL3Img=; b=aYe7yHo20j/CsCjHAvLkU6ezyMpLh9CEfICdgqLkMq39Z7BQeiDxJgvKdBVit1tZb3RNrgK8yhO2yZX119YU5CY+OFt1oT7pmUxGd9Elrg0dm8ZLUGI+V84NgX+yB9JN/yAK/nqTS/FO4e3eE1FxZMcAU6BM8W+DmkHl8MBpFhs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644343259090886.8415547163527; Tue, 8 Feb 2022 10:00:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268492.462338 (Exim 4.92) (envelope-from ) id 1nHUmo-0006CC-OB; Tue, 08 Feb 2022 18:00:18 +0000 Received: by outflank-mailman (output) from mailman id 268492.462338; Tue, 08 Feb 2022 18:00:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmo-0006B9-Hq; Tue, 08 Feb 2022 18:00:18 +0000 Received: by outflank-mailman (input) for mailman id 268492; Tue, 08 Feb 2022 18:00:17 +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 1nHUmn-00068L-ED for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:17 +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 f6c000f5-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:14 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrT3015757; Tue, 8 Feb 2022 18:00:13 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:12 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:07 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f6c000f5-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jK2NgxUrslRzWeTpvLeTDGIt5K8UoM/KgoaY35I8p6o4UQlvj1aZ2iKi4bJGbCSRUmwJ3oaHzccn8Lr5GIW+YxcjL68rFVAQ4XwERbQhJcmLmM2jhbgaHqscKLHDdO2MyGu/KjvECTPwqrkIHsOXs6efvi5MqtXHkI2zYDtAMt2Ts0dVAbMA4SmKGwpbmIqCDvAX4ftUsqN5T6BVcGKdd3GOXcOjZAlww+Mw9nPRgVnp8Z4BmM3dZ/5Ho+CAEihm2OxWt6/myc+N8ks103SlvzzVn8G2ZiF6jQo1mswzdtdkQJx6yth2UQbuLe9V07t4y0NE0pSvUcLfaGAdfcnnVQ== 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=s+Pd6wDqIcFv+WQby17OvQO3c7K+c3WVoYLWvGL3Img=; b=OaIqooaCQ48+ZcNhTZy3IOTwfIbDqjVskgGKEOAEh6F5zg+WvHi4932WuJDLOuUpsWo9V/ccBodoy6pT7hiIYcVB5YnFZdrI+CPIM+6FO7cIodMZ6ecB50/RqZN2X3geuyy1aIEXxjvJLKo4qnK+eS7Iry3oMt/LD40nLVqDC7ValgN2o5rieTR4IO0tdLyKUgEP2f3Qe4D/37Ea2WHqANz0Kz7c8iVHG6durJ8rzoP9lMjE2BXpzo9b6NHkBSjL3c3Z8PynXqQ9vHc90A2YI7+3BK5HCjdb5TrQ+M8wNNSXTqUAAp/1AsvdcPWkhB3elnr+32TANfllBvP0wgYEZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=s+Pd6wDqIcFv+WQby17OvQO3c7K+c3WVoYLWvGL3Img=; b=NKRI602rr+89pwZBu1o2KxvfP8dZTc3kYH6jB0oXp278uzs677VAHqCv6/SCR772ky+ak+NZ8CQv7jSgErHpMbrSZvWqR7L9Jg+/C5GuVsg9Rl3m+OfF2MxzW87CoMqwEXNgcnh6m6JbTwVOXU5+QCk8crXq3m3yNYdGYsFPUZRx3fmfLGu00FHFKXP7/le2xUK56rrwxtNVtMAWRyuPL0BBF2C5xCWJHMls1KRL3zFmJt/xz73TcubRkUqivD3od3NxBsIofFr52VaCMtJQaUwRFzLdqnG6BpkyXQ8nXlc/28TuPpnMHLsdi7yRWr3PiMjOBuBl+7JLr4e00MbREg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Juergen Gross , Wei Liu Subject: [RFC v2 2/8] libs: libxenhypfs - handle blob properties Thread-Topic: [RFC v2 2/8] libs: libxenhypfs - handle blob properties Thread-Index: AQHYHRW0gTNwRxUA1k2bknae2DocAw== Date: Tue, 8 Feb 2022 18:00:07 +0000 Message-ID: <069eb801bc999ea85c529fa5033121e96b9df06f.1644341635.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d5209da9-18ed-42a0-e3ca-08d9eb2cd786 x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: P7TW0UFCVr6XYzH45vY4lkwUMvmuQkNRNnz/bpFB9QYbMTMHuQ7wHnjDEpNF49tF+0YTlP/aKQjYK6W+JjM+Y+aR3bmQ2yY2GWhxAdWWihqmL0mANMKO6zaDCnHpkUNzd4SiZ4e0Y4c7Bmrr42uGU31oNU6VCPsoL5VGez00bUaRxgfofr3tG7JbRgfZaLYqhhqp6it6aSUnGu1DdwgRX0N0j0TOsM+uD+S3pD0mbt7xPc9C56LoerOZgz+vNYlt0ymwgd3zdYPdSb8S9q6wQ/Vc37QnJpD29UILf1NkQ0JIyitWc/tsHq9kkWGV0E3c/gMPwkdlktOxsFSrUCjLssZPkpJuWYEoI6XPwULiE8ZeM1Y8YeeQTTNG3iIWSHAaclUqHKK1z2bmKBE62RQALisvn+16ALWOKybAfa7nX/92LjPnMksNA1GpAzo0PbXWYNgB9SkfkSg1fHkl3b8C6m7xKSK9mJUpzaaDs5YRLMNwgoS9vyqcBijFpS+oPjwtjv/WRmBnRmFkMzrNG8xdk29qryFvYpXSAVQzmlcWizGeknQablPHi4bAn82LypzJg/bNMRy/hvsX0GUDgkkbVmGyuTgYy4tTWKX6dkEOnTMpLAvzMxKke3IQacl7H3NU+8NAIJVLOf2JBaPNrQcOZyEIzNn8ffOw1GLzUC4HGSeqC6hinp2LrnzYz/h4Hi2s0zpNq4e+0UsuiRI1r7/33A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(4326008)(83380400001)(54906003)(4744005)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?LvvhPleD4XcuZ6FqzOy/tU6O3SeYh08wd7gkaw0UYP7HST1DluQeMBwcsd?= =?iso-8859-1?Q?VK5XIRVPAojBQo5fJuMzddIDf2li3Y7dN9nJlFuxzPOKZvHlVs5odutLMX?= =?iso-8859-1?Q?VAhbIodQwgOh3/iIbCQ4fGYwS41mhdmz2gk1C3NGs3Vr5JstgP3jylxHKD?= =?iso-8859-1?Q?1HPNV2eM2lhdV5b43irrof4BQWRcy82U6Ry4MGPuLRCSIFSEfRsRwi2cRB?= =?iso-8859-1?Q?qgI9cNNckXWVOPLrlGG2Et5wdNmNHR3h7OjQQ2y5IEAavHQ5vJBVRb+MeR?= =?iso-8859-1?Q?CpPbFEHbVgmRy61pzLFjLOtGCnGkyrFKJMIzDLVvKbU8v0RxhEpzcTNAC+?= =?iso-8859-1?Q?s4SSL1SiUSdQQ6sljXiEuDvLmjmKuImjxtflTOkgS1H8W4rCVc184ysvJ3?= =?iso-8859-1?Q?pfPISH1tEwoY3T1BhOWBseaffH+4vuAiIM1y02IOEXsCRkpueqvUXAwWkR?= =?iso-8859-1?Q?AR7fvrwgaCoAfdI4RBkEJUZP5VAsj25kjgneEkAzceebL77aEjLYk8u+33?= =?iso-8859-1?Q?qGrGAO+8cTgavvo7/WoIOlo/44ZllNnl6RlzjIe58mCb3cKoZukgMbSxPN?= =?iso-8859-1?Q?MKp2VbF3GiUd0BOdbm9146fm68/78zzq5IoX87pw/9EDqz8NY2XkVsCG2J?= =?iso-8859-1?Q?pKn5oD3w4e/+yg/mhd+V7c3lMf4NDySkLgIlxc/YLVc2uyG8TdQ4b3tdsi?= =?iso-8859-1?Q?fuLAIBYI4DCUOq+RrQQLOkP/0LJZYU3iOW0YMutU04rFZzfgNUsh1ZSQVO?= =?iso-8859-1?Q?61/JCrGPpkXD9Re9upLGgW2sNHsf97HiOs+N8f0V8AVQjun06cJdTwnLwt?= =?iso-8859-1?Q?yn1H+jnPiED4hgGwbc1XQgYuVNWIn73BmS0E4jx1CtdcaVEBgVvU3a6fVH?= =?iso-8859-1?Q?u6Xlsz/EYEtZKP18EMr982kmwWqSDluCAjZVnSBGGeJRisNpJNdKwVZCtm?= =?iso-8859-1?Q?EssnlOormJVhdVQTfaVS5sAU8zILb9tCgBYEgT8Wxp5N63+NsIehBP49Ab?= =?iso-8859-1?Q?Q4HXNQ8ea6zuR4/BzrL7kZyo7HhOamxa+QVlVsv19TIvbWn7eHUjKgTc7m?= =?iso-8859-1?Q?TGoC8vSQIRWFfDvxkhrPt1qnFMTp7UMcPCbah89JzeYyLFahHTsvvcFJsR?= =?iso-8859-1?Q?WHHi0xsbCk48O+vvAm/jj9L7saUa9XA+38Pidtx+c1/r0VIROOwL/YAlqL?= =?iso-8859-1?Q?SFFhWqU8jx6CUwKx2Ho68Ba5XSWXa8x8LqDAcvVJHop/85yX+huYUJXaLb?= =?iso-8859-1?Q?xs7vwTlv6FKnaYvUx2iRt0j5ZCJMCQ2+175UM4fNlsINjPvxPCc0K9FCiS?= =?iso-8859-1?Q?qUQ3Ac9rmqTWExg8yAKRyy778GuLcBtVHWi8wddHhgvZrOY7ZdhAIJzdW5?= =?iso-8859-1?Q?m1nwCcEMhJMDirU6F8ls1rmEXqhhZPRwsEQgcqM5J4yTgk42HGZH5eQ5zn?= =?iso-8859-1?Q?gBoyrXTjPek+d4Uu87JgK03IcziJA0ZhkE06CTK9/Zc9RBNAn43YItIX0C?= =?iso-8859-1?Q?pxyrn4iDVCo4loio7LuZWSVQE9l56GtO/t5d36uSV09L3ro3L2zIE3CwGx?= =?iso-8859-1?Q?4jjlRPCMko/HFzbzlpm4Nz1qCeVYUC8lf88wtjp17rxFftS1IYx9UJ71fs?= =?iso-8859-1?Q?DPtOhVcyCeiMOwiy5Jxe2fADV1Kf0+9RycrOsN0MNYft3T9zw/1YXj7tT+?= =?iso-8859-1?Q?mm+YHXBela8wqB1vFXTfNABWcCfozrfij4r+cfkAo+/3LVkxn1o747nKS9?= =?iso-8859-1?Q?VqBhyGnDXMPHQ6HBzhE7ynnLg=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5209da9-18ed-42a0-e3ca-08d9eb2cd786 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:07.5727 (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: K+t9JbjMlj32GLMoocgkFrLadeNOO/AALJ2g91HJJm7hjH8uS8hwxHO9SUanaIcx2dOn1qmdjaJuzSTy23qeleYPOfAjDSHv0rU+fUQK/Mk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: Yrdh4-iaXSekn28dL7blLXf5-oqSC9QH X-Proofpoint-ORIG-GUID: Yrdh4-iaXSekn28dL7blLXf5-oqSC9QH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=740 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343260863100001 Content-Type: text/plain; charset="utf-8" libxenhypfs will return blob properties as is. This output can be used to retrieve information from the hypfs. Caller is responsible for parsing property value. Signed-off-by: Oleksii Moisieiev Reviewed-by: Juergen Gross --- tools/libs/hypfs/core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/libs/hypfs/core.c b/tools/libs/hypfs/core.c index 52b30db8d7..d09bba7d8c 100644 --- a/tools/libs/hypfs/core.c +++ b/tools/libs/hypfs/core.c @@ -307,8 +307,6 @@ char *xenhypfs_read(xenhypfs_handle *fshdl, const char = *path) errno =3D EISDIR; break; case xenhypfs_type_blob: - errno =3D EDOM; - break; case xenhypfs_type_string: ret_buf =3D buf; buf =3D NULL; --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343264; cv=pass; d=zohomail.com; s=zohoarc; b=c9QPz98az50s4Nu4QT/A/NFYuFBTJVZgN/t02bgQPfT7PVtmC7SrDZHFBhg+4kUq50KOGSAEKU8bwNEFRsj0OIp11KwB30SdkI+SqyOQ2Tzbp08fNqqeBa08ni40xkVyHKHvd84V97oeYM8huslP+WoDlRoc6+z+AkSaVfvLHJ0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343264; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GBlPOd7AiAkwGUmUKcL/QkLE6uduuCKGhZ0NfYwPn7M=; b=lrUyBJuBCOTezOLDRbXjLZL/eB/1gLVbfJL26uq6GeeRm6dnIQ9qJBxYDwfcRDinRa/1kholHovvbJRSyqRASOGtcc7rQTlo4X2pa/BTN/zKF/jstNWxTp+zwrR2QwxRVd//ISAZVmsWXbWdgf0ok9pU/rkfqRFuUjHoFWT4rxs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644343264365799.4225203747442; Tue, 8 Feb 2022 10:01:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268493.462354 (Exim 4.92) (envelope-from ) id 1nHUmr-0006e9-3z; Tue, 08 Feb 2022 18:00:21 +0000 Received: by outflank-mailman (output) from mailman id 268493.462354; Tue, 08 Feb 2022 18:00:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmr-0006e0-0W; Tue, 08 Feb 2022 18:00:21 +0000 Received: by outflank-mailman (input) for mailman id 268493; Tue, 08 Feb 2022 18:00:19 +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 1nHUmp-00068L-6w for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:19 +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 f8c5c876-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:17 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrT5015757; Tue, 8 Feb 2022 18:00:14 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:14 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:08 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f8c5c876-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hJatYUoZ25ZGt2oDLyOR456gPcza8CxVxTUEUiLehTYZbReiV+7+miEDeDULVwEZOAhCkxspH4VHkkyofEon3fFNxoz/JQ+CSM/ltwK7pyFw0XIDv4sX5i+jPZSLPbBFaEfOOZH8MM6cLqm7JS+q8cJT1+a/ZcrhJOYsCmn6V0AmO5cfRrpf0HDDmLcfiGM8oONcmSePFjOd7iA1qLejHjl/CYHEtQ1rj1gcW+XqQM/Uym97m3RMew8wQ7uLoX8e41FtZH157VKtBX+zQStgIQe/yIrgIPfJEjMWGFwyJmH6/uE0u3dItdyuooa1HJ2SQDDt4vaJqQp4b0Mm7heIPQ== 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=GBlPOd7AiAkwGUmUKcL/QkLE6uduuCKGhZ0NfYwPn7M=; b=LoKqjkgnR+M19b2SLCE6GoUtfurG989VOjPipe0G4qYNEGAp1D7f+F0OqZnSRVrtBGDHdnmxyzBdrOAzuNr3zLPZyBYDCfmBCqbGMQsddQKZvU5ccfXbbKvfeXSBE+gMmfV6HPVB7OdTCN3DRXmij27QTE01HqTZiWwYnZl6inLSNOAqxL5yx3/1pHHK5sK77brWPX8r28GME9A+QhQxCHX76VhvpcQ1U9VPc3uduczaWLvVD41razb7MMuBH+iNei//h/M/NRW3qegTB3QxqCSONoVuJ3P34CaF9TqVZD5N4gTER+TQB+aDQ7CFy0xwxJOQp0NanwvxQPb5Oufzhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=GBlPOd7AiAkwGUmUKcL/QkLE6uduuCKGhZ0NfYwPn7M=; b=fqDyvnbU2oGQp07LJhzRLyhP8xpdrYoQ3GYBsASMp2ND34jB7f789eSbt68CP6WNWKujVCF6KaNzD/Enl1jCEBpEoxLdZal96rpK5z8ak02wb1HgyTLWeYTtPKhgUJRhKO5nVziaXyCv6Wxq7NCUXDhah7qQrZIs1ylA6rM+dIrwuGi7hy/EdcnE92xuJsuiZXQb7BerK+j13PbUPaYi3h3yKaywLIUkBI+BTd2dR710ICfnJTs0ryqniJrVjUltlEzs2T5v2Lun4SdcZVRBS5PaiRgx8xHX0KQitAi9KRHNd4zb4Tl6m4vbvTAJ2y4SecZRts99IU8W2S6jf+xYng== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC v2 3/8] xen/arm: Export host device-tree to hypfs Thread-Topic: [RFC v2 3/8] xen/arm: Export host device-tree to hypfs Thread-Index: AQHYHRW1S717SraA0Ui+K6wc2/TNAA== Date: Tue, 8 Feb 2022 18:00:08 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7fd82e46-c221-4ff7-f460-08d9eb2cd813 x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eA0bzCYb7I/TEDiUeMjBIZ9YbX9Gnvap787CBuvVmndKbQC9Jyvjxhig/DUtnLgqoLSEzU0nApyueZUHwfI6UcfVLG3O6AA+g+qGVTg/H+idT0AhoQ6grg0f17Jp3iSS8ACcKnCDJyhrP3fozmJ7EAuxwgR//O9YG+NP1PFNlqQy0asIZYovdA8cEL+5vlszoDQhsXPXXEMqImZ9FB2vVp/4UMshkjNtYQ0vrr7hdN6G03FKCydow88FeptxJbNVLMiKT6JKUeh0tHrWIqSgPKiDktIcbGBD0qLyIYCZXFsM34zHVtvgp0aWK+NdsPEOi5iM9CGmf0XnspS341usE0u5J/Vl+v5qE+3eRh0pvkAa8bHOSAaB+A0ehQrboIRNJoLxOJLChd/t2e7+bxGJYLy/j6CWpQbWLFdhgXwnHUxgeWfEY7fNLe7An9+Xjv30svx8KYMTSFYmgvG9965h9ZIlgybZokx4pEEK4WaCYN0vFnz63XnceZ961H4V78SfnI3LaukL1gQsqjSO+RALABTgUnRjU4Suwv6UMEiz7muQG6J6lB1WK2UUMK8kSQs/cvPgtpqzmfOXd8v8lZWJYnm5gnB6fSQ4WqJYGPoT7CBQs9EkPi7dhowime74eXEyrrcCjjJEnqXioFdROtQa8Ii1G8DvIAF0BbuXSf+g3eNqt5j4Dy4nxpyfPhULh1H3+buGE6PPSwy9iK6PcVVpgkvYln78Gyx/UpbSEo/CSPc= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(4326008)(83380400001)(54906003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017)(2004002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?MGivsezwHpKlmbUPj+y2rFPN/epMygpIkmEZrDULehdMMH4VSwnZ4UABmx?= =?iso-8859-1?Q?B2IHFOGuCkTS4iuBv3yI1QJySnn+PHFJYKlKrClXeMwxSNRl1wOMvmL1/j?= =?iso-8859-1?Q?ogUYDk4mZYVQCcs8VeSjo2cB5VZNfjz4YhyDL0ldvn4NNrlUCLHx1ESF5u?= =?iso-8859-1?Q?BPDqQw91+qCy5+toRV2Q0/inPJWpPNJuugSyYQa6U/aEMlZS0lFJ64MJMp?= =?iso-8859-1?Q?DUBLR1VLYrCaT5mM8mnz1RYMKhci9TYHkcn7+nDGNLi1IbOo2K/AO20zvc?= =?iso-8859-1?Q?jADwbz51mtkh/k96TaJGoj2522tcGEcH941IEimuGlLZuehljgQ1OssHdc?= =?iso-8859-1?Q?BG3/mORWjVUKF7QXmhRA5th8UddVZH4CjEI/tW8+pcqlfzPZviwxv7HzKS?= =?iso-8859-1?Q?pVJ8AK6quBCRRH6xkcy91AKBiNf45sJcd5xp+JKTc2dw3xfpOFCYahFuqw?= =?iso-8859-1?Q?hKFgPtft4rKzhiJ/XmSHZgthnZWpNAw6Hz3/pW2Le6rXLaZprkt/eTsCLP?= =?iso-8859-1?Q?OFk7xB8ZLZyBkTl/lLLVOVdM1PaxNRxrYtX8mlOH8IkTngdhjWelzpqw/H?= =?iso-8859-1?Q?3zDHSht1tAVoevUVvj3BTpwj3pkIKTr0mzK2uOj2BtCrkQ6dYeUDBeCTff?= =?iso-8859-1?Q?QQvbp8GrM0FqCIY4IXbo8RfhB0RCq+ZJdivuKVRL5W81AqEXhkycZZVOdc?= =?iso-8859-1?Q?fDCW4HkexBFfDOtG55owKsZk/Xs5VrCFxgTaZu7lH4cmDpf09npiCUNtyS?= =?iso-8859-1?Q?8kGQX3rsXlEOHh60TG4F5Fl+nfwEvDKKQCRmwMmRoLkuS0H+Oo6af92WEq?= =?iso-8859-1?Q?Y34MITOET8U6k4h+wSjnUR+xirhoqwpnpX1FWwC9BeLtqAr7fkASlyOYnj?= =?iso-8859-1?Q?rCyns5hHmfiIvOIHvb297yez/VWhDSiV/qnONy+N+1Q2rgRZTdsD4HVUcU?= =?iso-8859-1?Q?X/9TzSQFR5zhFNW+MY7f1uKYqbmR12PHxJgSRA2zCBTrEUF54TteWU2/Z5?= =?iso-8859-1?Q?5gQB3nPX4RkQ45Crpiu2vyUE09v6t1fOF9Z5ct7FJsJpYuAsQHJlzYTA3Q?= =?iso-8859-1?Q?zVqvRtNFIgw7q4vhYMocwVwENKPwNoN0/Mkih2jsulWmieIfAhujwPzJFZ?= =?iso-8859-1?Q?dsWyocAcjp26OsJvRMJh0QFbox3xhtrn6RTPxTeggTg7EmAcePXUDI382T?= =?iso-8859-1?Q?Mlu8JeG+f6HGE9phQGYJvxBE0EbDpEMWMZ0j7bOIpBfveIUDxQyvsi6J9A?= =?iso-8859-1?Q?QmJ4UsFI5L+MfqWpt/jQ0jHvUT3zKqqPFd3NA+gO0RSkHUV01OK5WRayve?= =?iso-8859-1?Q?/t324Br0x2ot82AEsUiFskkKAtM2wRJ1c+N1yjpF+E9OTcT7qcML+EzXdE?= =?iso-8859-1?Q?HaeJ+wIJxOyF7w6yAX+BwvNEtXOMDCSG+OQGyRBkTfIv39w3m2MgGJQjkd?= =?iso-8859-1?Q?zGdyxiAjGGambWEEgtVXl4I7ednBhwD1fGA+MfhtOVfA9kw7108S0nGAUx?= =?iso-8859-1?Q?b2zyv1ublqpYrXGUqbnHIVur6uqgFhrfQCiddkrwohphfH4TloA5ey2t1S?= =?iso-8859-1?Q?z8O1brDtaLmQe1Lw0xEwuNMgw/5KHr21ZeVYd0KFknm43ROfnHVKDyevCn?= =?iso-8859-1?Q?1cyI1yeTJwc+b5VrYUQzeQ7yYirSNF9zZZTdxm2q6/ZiaBogqNtMmOYyY5?= =?iso-8859-1?Q?Vruy8MaFcp9Pjh3eq9NaCzcMBapmXlmY1ctRZz5YrYkTThWbVfhJqdFZWv?= =?iso-8859-1?Q?shNxhqUd/CRGwp2nHVTK+eBvE=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fd82e46-c221-4ff7-f460-08d9eb2cd813 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:08.4817 (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: nR6P7OcxH3Ms+uUSS9wpHiky5/5XPGfj7C+riLQE1Xt0LxMxgbb8RIFIeFrUU4cNJTLV+4s7ng27vBTm3TvAfJiRfuf+dpNRGjgIea+dxTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: 9x9RmyYBt--bIgC7LHnu8maOWqKwhB8o X-Proofpoint-ORIG-GUID: 9x9RmyYBt--bIgC7LHnu8maOWqKwhB8o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343266720100001 Content-Type: text/plain; charset="utf-8" If enabled, host device-tree will be exported to hypfs and can be accessed through /devicetree path. Exported device-tree has the same format, as the device-tree exported to the sysfs by the Linux kernel. This is useful when XEN toolstack needs an access to the host device-tree. Signed-off-by: Oleksii Moisieiev --- xen/arch/arm/Kconfig | 8 + xen/arch/arm/Makefile | 1 + xen/arch/arm/host_dtb_export.c | 307 +++++++++++++++++++++++++++++++++ 3 files changed, 316 insertions(+) create mode 100644 xen/arch/arm/host_dtb_export.c diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index ecfa6822e4..895016b21e 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -33,6 +33,14 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64. =20 +config HOST_DTB_EXPORT + bool "Export host device tree to hypfs if enabled" + depends on ARM && HYPFS && !ACPI + ---help--- + + Export host device-tree to hypfs so toolstack can have an access for the + host device tree from Dom0. If you unsure say N. + config GICV3 bool "GICv3 driver" depends on ARM_64 && !NEW_VGIC diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 07f634508e..0a41f68f8c 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -8,6 +8,7 @@ obj-y +=3D platforms/ endif obj-$(CONFIG_TEE) +=3D tee/ obj-$(CONFIG_HAS_VPCI) +=3D vpci.o +obj-$(CONFIG_HOST_DTB_EXPORT) +=3D host_dtb_export.o =20 obj-$(CONFIG_HAS_ALTERNATIVE) +=3D alternative.o obj-y +=3D bootfdt.init.o diff --git a/xen/arch/arm/host_dtb_export.c b/xen/arch/arm/host_dtb_export.c new file mode 100644 index 0000000000..794395683c --- /dev/null +++ b/xen/arch/arm/host_dtb_export.c @@ -0,0 +1,307 @@ +/* + * xen/arch/arm/host_dtb_export.c + * + * Export host device-tree to the hypfs so toolstack can access + * host device-tree from Dom0 + * + * Oleksii Moisieiev + * Copyright (C) 2021, EPAM Systems. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include + +#define HOST_DT_DIR "devicetree" + +static int host_dt_dir_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr); +static unsigned int host_dt_dir_getsize(const struct hypfs_entry *entry); + +static const struct hypfs_entry *host_dt_dir_enter( + const struct hypfs_entry *entry); +static void host_dt_dir_exit(const struct hypfs_entry *entry); + +static struct hypfs_entry *host_dt_dir_findentry( + const struct hypfs_entry_dir *dir, const char *name, unsigned int name= _len); + +static const struct hypfs_funcs host_dt_dir_funcs =3D { + .enter =3D host_dt_dir_enter, + .exit =3D host_dt_dir_exit, + .read =3D host_dt_dir_read, + .write =3D hypfs_write_deny, + .getsize =3D host_dt_dir_getsize, + .findentry =3D host_dt_dir_findentry, +}; + +static int host_dt_prop_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr); + +static unsigned int host_dt_prop_getsize(const struct hypfs_entry *entry); + +const struct hypfs_funcs host_dt_prop_ro_funcs =3D { + .enter =3D host_dt_dir_enter, + .exit =3D host_dt_dir_exit, + .read =3D host_dt_prop_read, + .write =3D hypfs_write_deny, + .getsize =3D host_dt_prop_getsize, + .findentry =3D hypfs_leaf_findentry, +}; + +static HYPFS_DIR_INIT_FUNC(dt_dir, "node_template", &host_dt_dir_funcs); + +#define HYPFS_PROPERTY_MAX_SIZE 256 +static HYPFS_VARSIZE_INIT(dt_prop, XEN_HYPFS_TYPE_BLOB, "prop_template", + HYPFS_PROPERTY_MAX_SIZE, &host_dt_prop_ro_func= s); + +static const char *get_name_from_path(const char *path) +{ + const char *name =3D strrchr(path, '/'); + if ( !name ) + name =3D path; + else + { + name++; + if ( !*name ) + name--; + } + + return name; +} + +static char *get_root_from_path(const char *path, char *name) +{ + const char *nm =3D strchr(path, '/'); + if ( !nm ) + nm =3D path + strlen(path); + else + { + if ( !*nm ) + nm--; + } + + return memcpy(name, path, nm - path); +} + +static int host_dt_dir_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + int ret =3D 0; + struct dt_device_node *node; + struct dt_device_node *child; + const struct dt_property *prop; + struct hypfs_dyndir_id *data; + + data =3D hypfs_get_dyndata(); + if ( !data ) + return -EINVAL; + + node =3D data->data; + if ( !node ) + return -EINVAL; + + dt_for_each_property_node( node, prop ) + { + ret =3D hypfs_read_dyndir_entry(&dt_prop.e, prop->name, + strlen(prop->name), + !prop->next && !node->child, + &uaddr); + + if ( ret ) + break; + } + + for ( child =3D node->child; child !=3D NULL; child =3D child->sibling= ) + { + const char *parsed_name =3D get_name_from_path(child->full_name); + data->data =3D child; + + ret =3D hypfs_read_dyndir_entry(&dt_dir.e, parsed_name, + strlen(parsed_name), + child->sibling =3D=3D NULL, + &uaddr); + + if ( ret ) + break; + } + + return ret; +} + +static unsigned int host_dt_dir_getsize(const struct hypfs_entry *entry) +{ + struct dt_device_node *node; + struct dt_device_node *child; + struct hypfs_dyndir_id *data; + const struct dt_property *prop; + unsigned int size =3D 0; + + data =3D hypfs_get_dyndata(); + if ( !data ) + return -EINVAL; + + node =3D data->data; + if ( !node ) + return -EINVAL; + + dt_for_each_property_node( node, prop ) + { + size +=3D hypfs_dyndir_entry_size(entry, prop->name); + } + + for ( child =3D node->child; child !=3D NULL; child =3D child->sibling= ) + { + const char *parsed_name =3D get_name_from_path(child->full_name); + size +=3D hypfs_dyndir_entry_size(entry, parsed_name); + } + + return size; +} + +static DEFINE_PER_CPU(bool, data_alloc); + +static inline bool data_is_alloc(void) +{ + unsigned int cpu =3D smp_processor_id(); + return per_cpu(data_alloc, cpu); +} + +static inline void set_data_alloc(void) +{ + unsigned int cpu =3D smp_processor_id(); + ASSERT(!per_cpu(data_alloc, cpu)); + + this_cpu(data_alloc) =3D true; +} + +static inline void unset_data_alloc(void) +{ + this_cpu(data_alloc) =3D false; +} + +static const struct hypfs_entry *host_dt_dir_enter( + const struct hypfs_entry *entry) +{ + struct hypfs_dyndir_id *data; + + if ( !data_is_alloc() ) + { + data =3D hypfs_alloc_dyndata(struct hypfs_dyndir_id); + if ( !data ) + return ERR_PTR(-ENOMEM); + + set_data_alloc(); + } + + if ( strcmp(entry->name, HOST_DT_DIR) =3D=3D 0 ) + { + data =3D hypfs_get_dyndata(); + data->data =3D dt_host; + } + + return entry; +} + +static void host_dt_dir_exit(const struct hypfs_entry *entry) +{ + if ( !data_is_alloc() ) + return; + + hypfs_free_dyndata(); + unset_data_alloc(); +} + +static struct hypfs_entry *host_dt_dir_findentry( + const struct hypfs_entry_dir *dir, const char *name, unsigned int name= _len) +{ + struct dt_device_node *node; + char root_name[HYPFS_DYNDIR_ID_NAMELEN]; + struct dt_device_node *child; + struct hypfs_dyndir_id *data; + struct dt_property *prop; + + data =3D hypfs_get_dyndata(); + if ( !data ) + return ERR_PTR(-EINVAL); + + node =3D data->data; + if ( !node ) + return ERR_PTR(-EINVAL); + + memset(root_name, 0, sizeof(root_name)); + get_root_from_path(name, root_name); + + for ( child =3D node->child; child !=3D NULL; child =3D child->sibling= ) + { + if ( strcmp(get_name_from_path(child->full_name), root_name) =3D= =3D 0 ) + return hypfs_gen_dyndir_entry(&dt_dir.e, + get_name_from_path(child->full_name), ch= ild); + } + + dt_for_each_property_node( node, prop ) + { + + if ( dt_property_name_is_equal(prop, root_name) ) + return hypfs_gen_dyndir_entry(&dt_prop.e, prop->name, prop); + } + + return ERR_PTR(-ENOENT); +}; + +static int host_dt_prop_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + const struct dt_property *prop; + struct hypfs_dyndir_id *data; + + data =3D hypfs_get_dyndata(); + if ( !data ) + return -EINVAL; + + prop =3D data->data; + if ( !prop ) + return -EINVAL; + + return copy_to_guest(uaddr, prop->value, prop->length) ? -EFAULT : 0; +} + +static unsigned int host_dt_prop_getsize(const struct hypfs_entry *entry) +{ + const struct hypfs_dyndir_id *data; + const struct dt_property *prop; + + data =3D hypfs_get_dyndata(); + if ( !data ) + return -EINVAL; + + prop =3D data->data; + if ( !prop ) + return -EINVAL; + + return prop->length; +} + +static HYPFS_DIR_INIT_FUNC(host_dt_dir, HOST_DT_DIR, &host_dt_dir_funcs); + +static int __init host_dtb_export_init(void) +{ + ASSERT(dt_host && (dt_host->sibling =3D=3D NULL)); + unset_data_alloc(); + + hypfs_add_dir(&hypfs_root, &host_dt_dir, true); + hypfs_add_dyndir(&hypfs_root, &dt_dir); + return 0; +} +__initcall(host_dtb_export_init); --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343261; cv=pass; d=zohomail.com; s=zohoarc; b=YIO15Ser9dNJ4zZ6R7n3A4xdK5WQfkrEFgmdo44IkJZwIQcHeRqQ7VVWcPRn4m+x5NNbPGnjvcrpAsUsRbD+Av8TBu09E9JrISwauve1y/QZfL2lEpuKrPPQczA+0L3TultmH8ZWy4CAXqVhkq4Gk+0OITR3CUTKslkZaNOUg5U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343261; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FDKbwCjLZ0DanLs0acIscY6UBZ+tUS318cgSdULOaTg=; b=oBcWwvH843RknZXhw5AHExi/POT+9AZpcg78TmOlUTzjr8zMvLw/FL/zzNrZXfdLNtSkar705SF8LPSqg32rUYdaPyUhrOK5TN6RFzm8cIzaRwRawVxOi1jbp6nU+80SYswoxygIB0lhBbavthSg9/hHYaF2bFwzMcWJ90kP2u0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644343261498414.40550181559763; Tue, 8 Feb 2022 10:01:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268497.462393 (Exim 4.92) (envelope-from ) id 1nHUmv-0007Xz-Uh; Tue, 08 Feb 2022 18:00:25 +0000 Received: by outflank-mailman (output) from mailman id 268497.462393; Tue, 08 Feb 2022 18:00:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmv-0007Xg-MN; Tue, 08 Feb 2022 18:00:25 +0000 Received: by outflank-mailman (input) for mailman id 268497; Tue, 08 Feb 2022 18:00:24 +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 1nHUmt-00068L-Uq for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:24 +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 fb07cd74-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:21 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrT8015757; Tue, 8 Feb 2022 18:00:17 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:16 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:09 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fb07cd74-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mY+RaWVddAkBShMK2W/v2hY4BXTUyA7H5kj+8oORo432vKYFcOFXIA8npCiDdWiKWDXEkkmyEvQTiD+q2DF3rFED0OTA7pQewOKDDy0/kuflsNwMezKsvLhxD9OUwQSwR/nJEgdUDgaB5iMolp4jIWm/VsL9SufaYm91b/kjp3pe8ZgnJTgggHgGO6k2J4ia5DfBqwCnSFHL444BV5Sr/JVT9H6BNVSJ0dalb5pQ2eUwzCofUjKMkFtf0QSOTb/M5q6wgprDYI/hxZcjx0xoEMekKK2bJY89ytjZ2//3uUpg5Z3omI7d+CFayreG1MMuyR72zXFVSUkaVT8t87n3qg== 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=FDKbwCjLZ0DanLs0acIscY6UBZ+tUS318cgSdULOaTg=; b=FhC4vSwd/EHlw2WOgLDGBVWKU+o/GodGP5omeA/sR57/LrY4MbJsKNgcgonyzMGdVBa20hgnGe7hHOg4On01ZVpOQlFKVhkpthzI1LpA4SvvEPqnC8ohTWkeYbOSHNRwXI9K6Y1zorSR0waI2TSMBq5iu2IjPNmvr7KAAbQRVkEjRGhvXfTOKQATec6BH+GT8z72KPwWohfhXSj/EH6tA+s+CITgppFH/Dtt5HqKVmXaTaX2ElNKjlYa8bIsGDjYeZHfVOjgkTN/X3SoxLQStmgefmJj6aGyTTY2BMtnbIZqsrzz7FwFV+qU4HfBDhK7xsdsvLOevd2AS8meXKx7ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=FDKbwCjLZ0DanLs0acIscY6UBZ+tUS318cgSdULOaTg=; b=rFaqhDGBTGz4gKZ4MhsIX+kLwWEk+26jQSFZU03NjW34KeTzNt8ztxbuA78xADTTnk2MpcvGi2Rk6RIMR8PJ+us8NAtQpYTz7LbqCK0M7XZI5u+wtJJ08GxSaBX4F9F7k2i09jsqrmIBy3pxph1EbC1Z7j539/u25OpzhLjWQgYNhvNfwMsbM2eC8CPFn9vDqeGYTBVTpQZGg94fOvaI3hNIHJndSphh/iY27ePZ93gg8yMUGk+/fv8X8bgPhFnNetf1EfBODF1Ta0V38n/clzxEALZN9zrds1U42aSVN3ZK1mXhV2yMTfHMFSNRh2M+tumXgwBWtlnmW5qaMgX1mA== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC v2 4/8] xen/arm: add generic SCI mediator framework Thread-Topic: [RFC v2 4/8] xen/arm: add generic SCI mediator framework Thread-Index: AQHYHRW2uVlYW22dYk+LMpDDmAXomw== Date: Tue, 8 Feb 2022 18:00:09 +0000 Message-ID: <83ecc9060352952bad547ad42c335ee979bf53c3.1644341635.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1001ae67-d63f-437f-d2b7-08d9eb2cd8ba x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GySFz62y0pVP20BKAldSaWT1FG+Kvk6Yc3QdhUZf7v6cVXTnKJ2cXMq1Nwj7/6Y2XPRorMHhEvDAE1m3iLRmnewtczBxD0vmRtgCZP34hSUm6jXvNLL9SOQQEdbc0mhCfnDHzclXkwnc+WxGuHbtetkZJmqoRTEaqGm9rBGNE2wP1KWgq91AOHbDHocX46rgtSvdyLjbDNX2+REyicV7gKD9q0OEMwyUxQduvNIvrOA2mzGqlRAhCoFU6XTXyvrjXq+oZUQUX70Vmtgf6b+QohRJ6o8XslBWcuehz8NpQeP/1udZ2VXlbKycn1r73bN+NPboJH7UVWp9Zb45nVtJD2ipfa0agtwkwv40R2ejDXZBOxGD6WizbXzOiOn5e+RwW40BixkcbjKYXBRcNj/VXEj1QCXzo9US07CgYvuRHewkNqvlNTGQLmte6nrjbm8hDt6tVZaHzn/W/+Bte89wG2YajlqvZmokrDvEg6NvYbTsvsptRuQKNm1KXUq/Mt6SWbYJFKj2EM/HoqHtiDRDDhBP/IEROlgFiUMEamf9xUoXu96KbO94FTL2BMhgEITTNOw7irpYrP8wpY7PEbZQLuMi0X4DWfcYQuOj8Fe/zePYdxJ849qnvarN/x/Llm9wTYldqH16hz72v0jjB880oXxONhDnjQFtFT1ruDbhSAf9fLGRPLi19Pm+MqywZDEklb4srA6F7GRsUz2OI2hu/OS5T7C3GC2cwk0KdcLq7eOIR8i9jcPRe+levxRtU011uZ6DrLisoEc2e8b3zeiFZa55jsMOxD2Jr2e4fOy4Tqs= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(4326008)(83380400001)(54906003)(30864003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017)(41533002)(2004002)(21314003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?L2WYFMsGfGar/YWPAkdWTw/gWc9uUoGI7y+Fs2AeVK3Df9Jc2pHx3MKwSr?= =?iso-8859-1?Q?aFIfwrjW/BJUTK+MNMDWcchQ2xP324ATL3+qazqPYLa3W/swfHJ6R3APlN?= =?iso-8859-1?Q?LMsRfRtvWme3uzWOCl5ULXVPMMDntaf4MYv3NdLftHJoWzEqfFLIB/KOZX?= =?iso-8859-1?Q?D5jKkf5QEXzewOgWvp8X+I44gcgNnAa7tAAlc47Y+FXZb0xQ/3w34QAj6C?= =?iso-8859-1?Q?4/R9F4gDPPr7a8L/w5pFvrDm0saMI0JBdQaZkWA+e9CKJysYOaj7SSLXsl?= =?iso-8859-1?Q?UvmV6hlHahK8zIsG2o+gzVy9zUDn38hIEZe23cFU5Mg0SFL2jbgKVYtF6t?= =?iso-8859-1?Q?6payt0NL3rUjrotra+eNiGR7qK5gJJI8eqg20bsQJMgQGuYEN16fdW9Pan?= =?iso-8859-1?Q?404UGUeYeShUyq0tz3ekHfpcongyoPUrlbhnj2n/hyjxtl7C4aCr5nnuU4?= =?iso-8859-1?Q?o9f90258Bo9I7C0Apgkff+NeNBdNreRglEPCIxmJB+fZsqa97rbzTSPt2V?= =?iso-8859-1?Q?doqqJY3ln1vnenivgeSpbr3QxgMRsSEafTHYUbynfEajVuO0FGHVSNzc+w?= =?iso-8859-1?Q?GLMtGJmy6RRb3Rmo/nTf1FsWo7JL4JqM/AS3Tk/o6pOYmlTLc3ColwFts4?= =?iso-8859-1?Q?By5k5tQyS599F4Ogs5oXbxgAyMH5ws92Qw7bhBHgTA0V1i/Xz/bVMam2SJ?= =?iso-8859-1?Q?wwyAJnoSWiQcztjNjGU9OzZIaKo+z/24rFHfF183T8e27EefKmTPnI9K2H?= =?iso-8859-1?Q?gwqvQ2mlx/lm7JJMnz3rA0yNtLxCw+Xqso5mtzgyPkZw1Y0Xf5ZidURayH?= =?iso-8859-1?Q?IzKUOpjkYxxESLirCcziv08K/eLBc50Ak8tLRgB4cCeV4JuYIVHi067q3c?= =?iso-8859-1?Q?ZJvikyrANj2HGVqtoQtmWAe2QFhy698kh/SKxBOhHSkA9YJ+DtRLMJ0pmM?= =?iso-8859-1?Q?+PIUldOIdawwysCZtFogeaaqZx7DO/hJ+Jt+uiQc4gi6Ox8QE93oBKm2Oy?= =?iso-8859-1?Q?BXY7ls/iq9dbVNjZgFkU1m3R/P0E+hEWI0oNN3FdJgroCXGelxGvTLm6XX?= =?iso-8859-1?Q?BJ+/L1r8ku2WppU86tQqbkmkN0w4DkrO5nrOLLxRM5un5/fR9EtJvQLkg0?= =?iso-8859-1?Q?pJS9YtpHVI2AzEhyvBkjX8QWqAnbAxXc6bPNTFUEEOpgPZkjaOcNG35FJ6?= =?iso-8859-1?Q?qbMVq4Eon+PoKLppMrxNUsOZ6de/ChvEJ7lH+WG9NQkfJ8Hg+6IsYKuaUg?= =?iso-8859-1?Q?iehs7NP8djwNbbdSzr2qWc9s2B/zsW7AYu8Zb6hKsAFR1lkdmY5VsyQdvS?= =?iso-8859-1?Q?9BjW01H5kNU31yiTX+FW4ojDtBsykDqmt+rZPrAW0oC8aTL/mGwKkVSva8?= =?iso-8859-1?Q?oYkvsPMX5t95nAkKEDp+1/rVV2xfvyU8HCIVKjs5YaW3ZByvk4qntJ8tKu?= =?iso-8859-1?Q?va+TDUw3Z8MuhIGjkJBqfTflIItoKo3g8xKCcSm+xoIk6wzWHupP678loE?= =?iso-8859-1?Q?0eDi6aMZXkvJRqPw5zhePlt2vmos0Q6Jr7k95SyYOxIaNizIB6udmNl55U?= =?iso-8859-1?Q?zF6BtRWP5uzjnlB1mAqoN4rj02ktrjrtICbJtPJcV/2ER+QLzQv6Vdlium?= =?iso-8859-1?Q?8luUn18PFV5M4LcfTv5XMJ8Cqak41bVaFaadoBH5/tQSmNnauT+8E32YKF?= =?iso-8859-1?Q?DnZeUp9QIMkb0WbIt9yfKIs+fmcLapPmerNe/RU65F1valgnih+OSol4Yj?= =?iso-8859-1?Q?AHe29gtmVKWhNhwfPwo2g/cg8=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1001ae67-d63f-437f-d2b7-08d9eb2cd8ba X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:09.5908 (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: Fvz0XaV4ZZ14C1yQBR08IJaqI0CoZ4i2HYY2Zt52ID3ARkWDmS8hUoXsdyY5kj6QjLE/F7n0V0wegxhE6BwhO7QQiLQlxC9sSYElKgUGOtg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: cA5HE8dSeDrbPlw6Q8YLP4RcCfN2Sp5M X-Proofpoint-ORIG-GUID: cA5HE8dSeDrbPlw6Q8YLP4RcCfN2Sp5M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343263755100005 Content-Type: text/plain; charset="utf-8" This patch adds the basic framework for SCI mediator. SCI is System Control Interface, which is designed to redirect requests from the Domains to Firmware. This will allow the devices, passed-through to the different Domains, to access to the System Controls (such as clocks/resets etc) by sending requests to the firmware. Xen mediates requests between the Domains and the Firmware, also it is responsible for permission handling during Domain crateion. SCI mediator register itself with REGISTER_SCI_MEDIATOR() macro. At run-time, during initialization, framework calls probe for the first matching device in the device-tree. When no device-tree is present - the first registered mediator should be probed. Signed-off-by: Oleksii Moisieiev --- MAINTAINERS | 6 ++ xen/arch/arm/Kconfig | 9 ++ xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 22 +++++ xen/arch/arm/domain_build.c | 11 +++ xen/arch/arm/sci/Makefile | 2 + xen/arch/arm/sci/sci.c | 152 +++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 1 + xen/arch/arm/vsmc.c | 5 +- xen/arch/arm/xen.lds.S | 7 ++ xen/include/asm-arm/domain.h | 4 + xen/include/asm-arm/sci/sci.h | 162 ++++++++++++++++++++++++++++++++++ xen/include/public/arch-arm.h | 15 ++++ 13 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/sci/Makefile create mode 100644 xen/arch/arm/sci/sci.c create mode 100644 xen/include/asm-arm/sci/sci.h diff --git a/MAINTAINERS b/MAINTAINERS index e43dc0edce..5f96ea35ba 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -512,6 +512,12 @@ S: Supported F: xen/arch/arm/tee/ F: xen/include/asm-arm/tee =20 +SCI MEDIATORS +M: Oleksii Moisieiev +S: Supported +F: xen/arch/arm/sci +F: xen/include/asm-arm/sci + TOOLSTACK M: Wei Liu S: Supported diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 895016b21e..ab07833582 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -114,6 +114,15 @@ config TEE =20 source "arch/arm/tee/Kconfig" =20 +config ARM_SCI + bool "Enable ARM_SCI mediators support" + depends on ARM + default n + help + This option enables generic ARM_SCI (System Control Interface) mediators + support. It allows guests to control system resourcess via one of + ARM_SCI mediators implemented in XEN. + endmenu =20 menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 0a41f68f8c..f071d912aa 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -8,6 +8,7 @@ obj-y +=3D platforms/ endif obj-$(CONFIG_TEE) +=3D tee/ obj-$(CONFIG_HAS_VPCI) +=3D vpci.o +obj-$(CONFIG_ARM_SCI) +=3D sci/ obj-$(CONFIG_HOST_DTB_EXPORT) +=3D host_dtb_export.o =20 obj-$(CONFIG_HAS_ALTERNATIVE) +=3D alternative.o diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 96e1b23550..607ea8c3a8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -688,6 +689,13 @@ int arch_sanitise_domain_config(struct xen_domctl_crea= tedomain *config) return -EINVAL; } =20 + if ( config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE && + config->arch.arm_sci_type !=3D sci_get_type() ) + { + dprintk(XENLOG_INFO, "Unsupported ARM_SCI type\n"); + return -EINVAL; + } + return 0; } =20 @@ -764,6 +772,13 @@ int arch_domain_create(struct domain *d, /* At this stage vgic_reserve_virq should never fail */ if ( !vgic_reserve_virq(d, GUEST_EVTCHN_PPI) ) BUG(); + + if ( config->arch.arm_sci_type !=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE= ) + { + if ( (rc =3D sci_domain_init(d, config->arch.arm_sci_type, + &config->arch)) !=3D 0) + goto fail; + } } =20 /* @@ -796,6 +811,7 @@ void arch_domain_destroy(struct domain *d) domain_vgic_free(d); domain_vuart_free(d); free_xenheap_page(d->shared_info); + sci_domain_destroy(d); #ifdef CONFIG_ACPI free_xenheap_pages(d->arch.efi_acpi_table, get_order_from_bytes(d->arch.efi_acpi_len)); @@ -996,6 +1012,7 @@ enum { PROG_xen, PROG_page, PROG_mapping, + PROG_sci, PROG_done, }; =20 @@ -1056,6 +1073,11 @@ int domain_relinquish_resources(struct domain *d) if ( ret ) return ret; =20 + PROGRESS(sci): + ret =3D sci_relinquish_resources(d); + if ( ret ) + return ret; + PROGRESS(done): break; =20 diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d02bacbcd1..05afd3e8e7 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1894,6 +1895,10 @@ static int __init handle_device(struct domain *d, st= ruct dt_device_node *dev, return res; } } + + res =3D sci_add_dt_device(d, dev); + if ( res < 0 ) + return res; } =20 res =3D handle_device_interrupts(d, dev, need_mapping); @@ -3075,6 +3080,10 @@ static int __init construct_dom0(struct domain *d) if ( rc < 0 ) return rc; =20 + rc =3D sci_domain_init(d, sci_get_type(), NULL); + if ( rc < 0 ) + return rc; + if ( acpi_disabled ) rc =3D prepare_dtb_hwdom(d, &kinfo); else @@ -3109,6 +3118,8 @@ void __init create_dom0(void) dom0_cfg.arch.tee_type =3D tee_get_type(); dom0_cfg.max_vcpus =3D dom0_max_vcpus(); =20 + dom0_cfg.arch.arm_sci_type =3D sci_get_type(); + if ( iommu_enabled ) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 diff --git a/xen/arch/arm/sci/Makefile b/xen/arch/arm/sci/Makefile new file mode 100644 index 0000000000..67f2611872 --- /dev/null +++ b/xen/arch/arm/sci/Makefile @@ -0,0 +1,2 @@ +obj-y +=3D sci.o +obj-$(CONFIG_SCMI_SMC) +=3D scmi_smc.o diff --git a/xen/arch/arm/sci/sci.c b/xen/arch/arm/sci/sci.c new file mode 100644 index 0000000000..05c948a071 --- /dev/null +++ b/xen/arch/arm/sci/sci.c @@ -0,0 +1,152 @@ +/* + * xen/arch/arm/sci/sci.c + * + * Generic part of SCI mediator driver + * + * Oleksii Moisieiev + * Copyright (C) 2021, EPAM Systems. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include + +#include + +extern const struct sci_mediator_desc _sscimediator[], _escimediator[]; +static const struct sci_mediator_desc __read_mostly *cur_mediator; + +bool sci_handle_call(struct domain *d, void *args) +{ + if ( unlikely(!cur_mediator) ) + return false; + + return cur_mediator->ops->handle_call(d, args); +} + +int sci_domain_init(struct domain *d, uint16_t sci_type, + struct xen_arch_domainconfig *config) +{ + if ( sci_type =3D=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE ) + return 0; + + if ( !cur_mediator ) + return -ENODEV; + + if ( cur_mediator->sci_type !=3D sci_type ) + return -EINVAL; + + return cur_mediator->ops->domain_init(d, config); +} + +void sci_domain_destroy(struct domain *d) +{ + if ( !cur_mediator ) + return; + + cur_mediator->ops->domain_destroy(d); +} + +int sci_relinquish_resources(struct domain *d) +{ + if ( !cur_mediator ) + return 0; + + return cur_mediator->ops->relinquish_resources(d); +} + + +int sci_add_dt_device(struct domain *d, struct dt_device_node *dev) +{ + if ( !cur_mediator ) + return 0; + + return cur_mediator->ops->add_dt_device(d, dev); +} + +uint16_t sci_get_type(void) +{ + if ( !cur_mediator ) + return XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + + return cur_mediator->sci_type; +} + +int sci_do_domctl( + struct xen_domctl *domctl, struct domain *d, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) +{ + int rc =3D -EINVAL; + struct dt_device_node *dev; + + switch ( domctl->cmd ) + { + case XEN_DOMCTL_assign_device: + if ( domctl->u.assign_device.dev !=3D XEN_DOMCTL_DEV_DT ) + break; + + rc =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, + domctl->u.assign_device.u.dt.size, + &dev); + if ( rc ) + return rc; + + rc =3D sci_add_dt_device(d, dev); + + break; + default: + rc =3D -ENOSYS; + break; + } + + return rc; +} + +static int __init sci_init(void) +{ + const struct sci_mediator_desc *desc; + struct dt_device_node *dt =3D NULL; + + + for ( desc =3D _sscimediator; desc !=3D _escimediator; desc++ ) + { + if ( acpi_disabled ) + { + dt =3D dt_find_matching_node(dt_host, desc->dt_match); + if ( !dt ) + continue; + } + + if ( desc->ops->probe(dt) ) + { + printk(XENLOG_INFO "Using SCI mediator for %s\n", desc->name); + cur_mediator =3D desc; + return 0; + } + } + + return 0; +} + +__initcall(sci_init); + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index d5d0792ed4..201de01411 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c index a36db15fff..c68482fbd8 100644 --- a/xen/arch/arm/vsmc.c +++ b/xen/arch/arm/vsmc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -275,7 +276,9 @@ static bool vsmccc_handle_call(struct cpu_user_regs *re= gs) handled =3D handle_sssc(regs); break; case ARM_SMCCC_OWNER_SIP: - handled =3D platform_smc(regs); + handled =3D sci_handle_call(current->domain, regs); + if ( !handled ) + handled =3D platform_smc(regs); break; case ARM_SMCCC_OWNER_TRUSTED_APP ... ARM_SMCCC_OWNER_TRUSTED_APP_E= ND: case ARM_SMCCC_OWNER_TRUSTED_OS ... ARM_SMCCC_OWNER_TRUSTED_OS_END: diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 08016948ab..3683f4821f 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -142,6 +142,13 @@ SECTIONS _eteemediator =3D .; } :text =20 + . =3D ALIGN(8); + .scimediator.info : { + _sscimediator =3D .; + *(.scimediator.info) + _escimediator =3D .; + } :text + . =3D ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin =3D .; .init.text : { diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 9b3647587a..11c8db8db1 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -89,6 +89,10 @@ struct arch_domain #ifdef CONFIG_TEE void *tee; #endif + +#ifdef CONFIG_ARM_SCI + void *sci; +#endif } __cacheline_aligned; =20 struct arch_vcpu diff --git a/xen/include/asm-arm/sci/sci.h b/xen/include/asm-arm/sci/sci.h new file mode 100644 index 0000000000..075e11bc16 --- /dev/null +++ b/xen/include/asm-arm/sci/sci.h @@ -0,0 +1,162 @@ +/* + * xen/include/asm-arm/sci/sci.h + * + * Generic part of the SCI (System Control Interface) subsystem. + * + * Oleksii Moisieiev + * Copyright (C) 2021, EPAM Systems. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __ASM_ARM_SCI_H +#define __ASM_ARM_SCI_H + +#include +#include +#include +#include + +#ifdef CONFIG_ARM_SCI + +struct sci_mediator_ops { + + /* + * Probe for SCI. Should return true if SCI found and + * mediator is initialized. + */ + bool (*probe)(struct dt_device_node *scmi_node); + + /* + * Called during domain construction if toolstack requests to enable + * SCI support so mediator can inform SCP-firmware about new + * guest and create own structures for the new domain. + */ + int (*domain_init)(struct domain *d, struct xen_arch_domainconfig *con= fig); + + /* + * Called during domain destruction, releases all resources, that + * were allocated by the mediator. + */ + void (*domain_destroy)(struct domain *d); + + /* + * Called during parsing partial device-sci for the domain. + * Passing device_node so mediator could process the device and + * mark the device as related to the domain if needed. + */ + int (*add_dt_device)(struct domain *d, struct dt_device_node *dev); + + /* + * Called during domain destruction to relinquish resources used + * by mediator itself. This function can return -ERESTART to indicate + * that it does not finished work and should be called again. + */ + int (*relinquish_resources)(struct domain *d); + + /* Handle call for current domain */ + bool (*handle_call)(struct domain *d, void *regs); +}; + +struct sci_mediator_desc { + /* Printable name of the SCI. */ + const char *name; + + /* Mediator callbacks as described above. */ + const struct sci_mediator_ops *ops; + + /* + * ID of SCI. Corresponds to xen_arch_domainconfig.sci_type. + * Should be one of XEN_DOMCTL_CONFIG_ARM_SCI_xxx + */ + uint16_t sci_type; + + /* Match structure to init mediator */ + const struct dt_device_match *dt_match; + +}; + +int sci_domain_init(struct domain *d, uint16_t sci_type, + struct xen_arch_domainconfig *config); +void sci_domain_destroy(struct domain *d); +int sci_add_dt_device(struct domain *d, struct dt_device_node *dev); +int sci_relinquish_resources(struct domain *d); +bool sci_handle_call(struct domain *d, void *args); +uint16_t sci_get_type(void); +int sci_do_domctl( + struct xen_domctl *domctl, struct domain *d, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl); + +#define REGISTER_SCI_MEDIATOR(_name, _namestr, _type, _match, _ops) \ +static const struct sci_mediator_desc __sci_desc_##_name __used \ +__section(".scimediator.info") =3D { \ + .name =3D _namestr, \ + .ops =3D _ops, \ + .sci_type =3D _type, \ + .dt_match =3D _match \ +} + +#else + +static inline int sci_domain_init(struct domain *d, uint16_t sci_type, + struct xen_arch_domainconfig *config) +{ + if ( likely(sci_type =3D=3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE) ) + return 0; + + return -ENODEV; +} + +static inline void sci_domain_destroy(struct domain *d) +{ +} + +static inline int sci_add_dt_device(struct domain *d, + struct dt_device_node *dev) +{ + return 0; +} + +static inline int sci_relinquish_resources(struct domain *d) +{ + return 0; +} + +static inline bool sci_handle_call(struct domain *d, void *args) +{ + return false; +} + +static inline uint16_t sci_get_type(void) +{ + return XEN_DOMCTL_CONFIG_ARM_SCI_NONE; +} + +static inline int sci_do_domctl( + struct xen_domctl *domctl, struct domain *d, + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) +{ + return -ENOSYS; +} + + +#endif /* CONFIG_ARM_SCI */ + +#endif /* __ASM_ARM_SCI_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 94b31511dd..a6131ab1fd 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -314,12 +314,17 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_TEE_NONE 0 #define XEN_DOMCTL_CONFIG_TEE_OPTEE 1 =20 +#define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 +#define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1 + struct xen_arch_domainconfig { /* IN/OUT */ uint8_t gic_version; /* IN */ uint16_t tee_type; /* IN */ + uint16_t arm_sci_type; + /* IN */ uint32_t nr_spis; /* * OUT @@ -335,6 +340,12 @@ struct xen_arch_domainconfig { * */ uint32_t clock_frequency; + + /* Sets shared address to sw domains. + * This information is needed to set correct channel in Domain partial + * device-tree + */ + uint64_t arm_sci_agent_paddr; }; #endif /* __XEN__ || __XEN_TOOLS__ */ =20 @@ -429,6 +440,10 @@ typedef uint64_t xen_callback_t; #define GUEST_ACPI_BASE xen_mk_ullong(0x20000000) #define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000) =20 +/* SCMI shared memory address */ +#define GUEST_SCI_SHMEM_BASE xen_mk_ullong(0x05ff0000) +#define GUEST_SCI_SHMEM_SIZE xen_mk_ullong(0x01000) + /* PL011 mappings */ #define GUEST_PL011_BASE xen_mk_ullong(0x22000000) #define GUEST_PL011_SIZE xen_mk_ullong(0x00001000) --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343260; cv=pass; d=zohomail.com; s=zohoarc; b=cladX037OV9jIOvN1Q6Ua+XA4FvqrPNBmslJ1VPh0e1Urkvl8DNnWUZ6xONzon7oKU2nW4AtI/DdT85oTUkvjaeQmRhjc9qNv/VGl8brUnB00lF/trJf9HGEEnnfxWa2WE/Or5TzX+idK1alWVJRytVGQ4sqMzbmSRwPsn/gFW0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343260; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lwBesdAFpbbKcuHszwtd+zJh3/6ZoEfXGDzAO3r/9m0=; b=U86SPqWnYr0romISxjC1OjQV8p/FyfslPTPMNEuSY6F3geAgtC8k9A6nK1YIe/RIO16lQ3BIYYq53EDNIn9FJCbsWaQbf7MmK39C7EWsuNMBCN8qwdxPo1jTAxqgnPcBgJBeT9M3aL6ZxxpuKAxy8708wuwnIWSD/I/M624H/qo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 164434326096481.07562625192281; Tue, 8 Feb 2022 10:01:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268498.462409 (Exim 4.92) (envelope-from ) id 1nHUmy-000873-Gj; Tue, 08 Feb 2022 18:00:28 +0000 Received: by outflank-mailman (output) from mailman id 268498.462409; Tue, 08 Feb 2022 18:00:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmy-00086h-CE; Tue, 08 Feb 2022 18:00:28 +0000 Received: by outflank-mailman (input) for mailman id 268498; Tue, 08 Feb 2022 18:00:25 +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 1nHUmv-00068L-Ec for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:25 +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 fc1d3e92-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:23 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrTB015757; Tue, 8 Feb 2022 18:00:19 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:19 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:11 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fc1d3e92-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cfCuyyHlgadn8j+UYBWok7zac+2TzkmJ2j4bLiiwMg/1466/pTjVETa0HtAMQgCX6cP9eE38ZogXqstamqH9eMUEjNkVPPyYXYdT1ssz2XUI7SStubRZ6gK6dHtCLNTow3okq52G/65e7l5Nl1pU6kl5gRnNJO7zNoSn5POOb9NSgYuvrFzqTpQ4Hp5WJURa1yhZr7BlfL5IEGlldsB0UzjeuNO8SGZ79S1tvBEhC3dBFW/sGy8rMQVfSui47Y/t3vPrz3cpYqIDPOMaJeqpWoUFIQm3aJmeNi3GuBlNPp8vduMDNWNioSN8rf8An7t/+ad4+URTw87Sx+FsoztLjw== 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=lwBesdAFpbbKcuHszwtd+zJh3/6ZoEfXGDzAO3r/9m0=; b=c9UB4kZlMfSoZTWEqbYQtbmDVnhLxbrEoh7pFvdu3KrQVuIUpifU4fvwgvA4PCOACWI4/E9rJ4YbyYP+Sav2geTt0wo8lwiLdm7s0PWb/XpzM/d3hE1EWlJnl2ky+fTyBpLUKq1+SYUuvpYBsInuxWahFpzdB1CptNIAQAtN9f7m6ZemBaRdL4jVDKxc/sF86xBIYx/npPnQ3/5WJ1RJmCC1LircLrRxBVTDcjb+SrY4dle68TCnGWjNrz4/SEgpzXVGKuEj8kaipWb5uaRFKY3XoHG6CyhaxcThdQiyWw46XcHA2q8A44ccnA03U4eBXcgd3JkbeLAlxBHahS1Wlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=lwBesdAFpbbKcuHszwtd+zJh3/6ZoEfXGDzAO3r/9m0=; b=TpPGHIgG0FILxJtDzG9X/2roEE4dC+yowbSQLihWnwBIa58Vxaox+kKNBXECiiMi0+zHo5/WCHAH7LmHan1uV3rCG7RvJU3XYUlHhQE7Bi1+pMYwFr7BUPrl2a5mCdnjSdswDBqQPBeYqyRa50FA88d88YBTRNk/WFIBXJmLvEnRXNdde0BnLv1UHhZsNTF7Hi5KHc+Q56U6DNxrz3maZGwFEb8hROHs24qqDClriSNR/pYX8V6omfFJWmUGhX0ej0gfamIirroEorjHMu/AOP6/kBpbeqNMnjxPahtiSwElORDQZZWsONJUbyj878Rek0JbTKiungZgMMxVeDWzPA== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC v2 5/8] xen/arm: introduce SCMI-SMC mediator driver Thread-Topic: [RFC v2 5/8] xen/arm: introduce SCMI-SMC mediator driver Thread-Index: AQHYHRW24Dmb0qV8ZkqAv39Pf6/nVQ== Date: Tue, 8 Feb 2022 18:00:10 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 51fb966e-0e48-4ba5-d203-08d9eb2cd9cc x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3383; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UIoCAc8+AFzUwByPeHaDyknesucUZr0veB6PMzgQPBSlzEC/jxCZtvOTDmZgLQS9/plIDRB8EgieFRTqpmk/Cb3hQSllfDvAa0oUTr9XWq7o63zOHA/FUwNjtm7MZrkcOMFumx7go/DPaF8VydGHITziojEhKtzmYPUDPaeTP4n/jXiLglRvATiVs2oxh7ChV1ZT+DYn3S8MA9Iq2gIXNqgaBQeF7A0S8w45Kyi06KMmnATsIT/5zAFihScY7mFTZuQ5iABLKr1NL/kFquWAMGPPTOHR6L4XaBZ+5qJed+c/onnuukx3vtk9xS623MRihgXecUjZgePD9RBq7HY9CGPby3nOoMa9IU35pMDoHVEL5R+bNwLI6bLlpZXfXjDF1CoqFJ3cpJLDhhooHaNry5vdQUwh/cDwZEFAQxHdO6SxMteaa2q11+eslAD47pZ2Ev005FLn159csA1mybXCanmX7OhRdMFfUTUkBZcaGeqod7snfxC+q8Q3Tm/dn+7kK3r/om10s00OIr05elF10KIKae1xafdg8qtMMJD05X34oPzNa/jlssN5HI0Zq9kIe3qMO8nHLdSCHF/xsdgQa3B2fbUTq0zFieEh1I+HNZWzEx07lQrwveRyqFY6z8UQWsUkX1XsMFPcSIF9tYMR7C6ijWv7KgoO8NBpN64F101YR0CD+4Owxt7LpmYwJwzUCOePc+qpzFz+0/JZonijGrJKIQN4FFgrvKtjCT13p+Q= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(4326008)(83380400001)(54906003)(30864003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017)(2004002)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?7DKeJTm3R0sBtYj9VngbEwbgcb5SIqliGCV12ylc/tO668jfbZOrRSzw+E?= =?iso-8859-1?Q?1Z/neW3FLRW5d+c910kMbSJX4+uLPOWWcytJ5LdYCihdf1/zkEaNqzOJZz?= =?iso-8859-1?Q?cfUJGlr0j4+AigdBafZQkytDsDLqVUW85HYqEpKO4muG50nlxedLxe8al5?= =?iso-8859-1?Q?rMcJBEvFyS1/jgINlNpjMVgjForVFpjCzNtuUr7iT3NVGSdluu+GS5E+GM?= =?iso-8859-1?Q?s/oWSdc6wAl+N0zqkg68GmCzwI9wdG+cpcnZaLNDh+0LJC3bdHnIN3KGDi?= =?iso-8859-1?Q?cXkM7eZPNqAGU8sIRZVaknfDt9NY/zpopRYzDSvAvPeEPgjy0XuQxef0ZZ?= =?iso-8859-1?Q?G/Zs6tbr3zCk7tqv/1bnbkjxeNrajadymc0GYu+qk0/KOERXj9G6LVWT2v?= =?iso-8859-1?Q?FlqJOqYlQUoKC6u9Qjj89sz9rOGdbdZz8H3N390p6J+awqd1zOGxtDJ8Me?= =?iso-8859-1?Q?qAtsZZIpSxeOX/QNoxxvUX6b2V+tm6MeQiEUAjXG+aoy0tKUKZdvn/yygt?= =?iso-8859-1?Q?Iyd6wk6texgJJ+OKFjQTEbFA3ANG6/QwJgToEhbHm+ogEUuruOpiSRRGRs?= =?iso-8859-1?Q?0Njnco3DoEA/JJSFt1tr7TBgtcx+nAODiEbAGhHVMqUvzuMfvITa2GzxBS?= =?iso-8859-1?Q?vOo5PxFSIFS87jBCbQnjAm3oJWibkfGnrgH/7UfqSOUU6gXYV5SDkLDBDq?= =?iso-8859-1?Q?h9gyj9JiOnFi5vRQ/m/A649vKCaBx3NLFPIBvqSm7wMhhE9mMc2z10pXNB?= =?iso-8859-1?Q?808No95b3MCIrUqVZ/h8EMU0X26XyvBFipfNuDlgXkR9YakfW6C+izOs0C?= =?iso-8859-1?Q?A8cjx6i75n95CAfOv4uO0zy4lkYsG/f8RQr0nEub+87JMgFvJQ2ViV1e8q?= =?iso-8859-1?Q?JgYMO8hv0FNkazdMPfGG5tfJqlWbKeMCLJ+zY4OvBm4mFJauU/wjn5PDxh?= =?iso-8859-1?Q?A2EyMyACgtDkC724wE+zDWglZwiBN19h4xY70yP4KZtpjD/bn3nhbVemnr?= =?iso-8859-1?Q?VTMaK/ib7IUkGUjefqUEpO9cOL7uZc7AGr0ZZ5jr2TqB1ebrvsRat/HLAB?= =?iso-8859-1?Q?T3Edh0d8cyQBm5LjqP0DJj14VTGNGW0LKpLEUhe7JicSJ3nmPnCdsMv4T7?= =?iso-8859-1?Q?p+5ThbvWuCje220ZCNvGGkNgjBznAkl+nYhXnzMfSEonlra53xWJFKb1ta?= =?iso-8859-1?Q?gKHK2pL1hJnJN9ZHDMi4cgy8jJVZeLrUZI+x37IYWo3jRMqwNmJw7Rw/4m?= =?iso-8859-1?Q?swWubhIkf1v9i/dV/PY4s2f+rr26o0GSaA/cVX+3AIP4VAoSSMGIvscR4h?= =?iso-8859-1?Q?ODArtzf8fl4A3gMJ3XP67dwkVpPMyJGlUfp1LHE8NJcitE3kgRLEp/vsX4?= =?iso-8859-1?Q?tilCyolk/h0mbfdO3LfKrpIA7dMLL49FF8Zq7ioFYPvc9giHMN4UehdWNU?= =?iso-8859-1?Q?XuDIsg9vhFj+aA9yPCrBMFkcjNvUpBqVrW5BXeJVOpyPOLr/jSWE7u3iJJ?= =?iso-8859-1?Q?3OV5jK6ulnyG7s9+iZkpuf913wckfhoPMIM0umtGUTMBg6jqeHez4Kcs5H?= =?iso-8859-1?Q?kx0gzCWDg0VxWRkgT0LMZbso0oFT3XBBHPkSAsQIEMcMt0rg5nkz7HYJOI?= =?iso-8859-1?Q?wIKBcuJe0ZVM+qpw8VNpquKMZUbLupwui7rIZiZnmFZR/i9VaEsNCVZ9cV?= =?iso-8859-1?Q?yJ/cVyNvwjxxbREyVL0uMCuEIU/9fj6udtcprz7VEX8usMovdyOfkY5/vV?= =?iso-8859-1?Q?toQ+yK6uQMTvEHpECIztpiMTM=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51fb966e-0e48-4ba5-d203-08d9eb2cd9cc X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:10.4983 (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: yGu9sE7NDwwHGwOdYtqFBcUWXZU6xbwMnEwcDmw6QdQtZf+MQmFrAVyteEg6ZK7w8OPd9EycTMTHfJ3GO25CjPWelkClig20eXRgIZOyTm4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: Xjku0kQnLWwAjadQoLtDOOfoMLBUmhBS X-Proofpoint-ORIG-GUID: Xjku0kQnLWwAjadQoLtDOOfoMLBUmhBS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343263557100001 Content-Type: text/plain; charset="utf-8" This is the implementation of SCI interface, called SCMI-SMC driver, which works as the mediator between XEN Domains and Firmware (SCP, ATF etc). This allows devices from the Domains to work with clocks, resets and power-domains without access to CPG. Originally, cpg should be passed to the domain so it can work with power-domains/clocks/resets etc. Considering that cpg can't be split between the Domains, we get the limitation that the devices, which are using power-domains/clocks/resets etc, couldn't be split between the domains. The solution is to move the power-domain/clock/resets etc to the Firmware (such as SCP firmware or ATF) and provide interface for the Domains. XEN should have an entity, caled SCI-Mediator, which is responsible for messages redirection between Domains and Firmware and for permission handling. The following features are implemented: - request SCMI channels from ATF and pass channels to Domains; - set device permissions for Domains based on the Domain partial device-tree. Devices with permissions are able to work with clocks, resets and power-domains via SCMI; - redirect scmi messages from Domains to ATF. Signed-off-by: Oleksii Moisieiev --- xen/arch/arm/Kconfig | 2 + xen/arch/arm/sci/Kconfig | 10 + xen/arch/arm/sci/scmi_smc.c | 959 ++++++++++++++++++++++++++++++++++++ 3 files changed, 971 insertions(+) create mode 100644 xen/arch/arm/sci/Kconfig create mode 100644 xen/arch/arm/sci/scmi_smc.c diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index ab07833582..3b0dfc57b6 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -123,6 +123,8 @@ config ARM_SCI support. It allows guests to control system resourcess via one of ARM_SCI mediators implemented in XEN. =20 + source "arch/arm/sci/Kconfig" + endmenu =20 menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/sci/Kconfig b/xen/arch/arm/sci/Kconfig new file mode 100644 index 0000000000..10b634d2ed --- /dev/null +++ b/xen/arch/arm/sci/Kconfig @@ -0,0 +1,10 @@ +config SCMI_SMC + bool "Enable SCMI-SMC mediator driver" + default n + depends on ARM_SCI && HOST_DTB_EXPORT + ---help--- + + Enables mediator in XEN to pass SCMI requests from Domains to ATF. + This feature allows drivers from Domains to work with System + Controllers (such as power,resets,clock etc.). SCP is used as transport + for communication. diff --git a/xen/arch/arm/sci/scmi_smc.c b/xen/arch/arm/sci/scmi_smc.c new file mode 100644 index 0000000000..103529dfab --- /dev/null +++ b/xen/arch/arm/sci/scmi_smc.c @@ -0,0 +1,959 @@ +/* + * xen/arch/arm/sci/scmi_smc.c + * + * SCMI mediator driver, using SCP as transport. + * + * Oleksii Moisieiev + * Copyright (C) 2021, EPAM Systems. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SCMI_BASE_PROTOCOL 0x10 +#define SCMI_BASE_PROTOCOL_ATTIBUTES 0x1 +#define SCMI_BASE_SET_DEVICE_PERMISSIONS 0x9 +#define SCMI_BASE_RESET_AGENT_CONFIGURATION 0xB +#define SCMI_BASE_DISCOVER_AGENT 0x7 + +/* SCMI return codes. See section 4.1.4 of SCMI spec (DEN0056C) */ +#define SCMI_SUCCESS 0 +#define SCMI_NOT_SUPPORTED (-1) +#define SCMI_INVALID_PARAMETERS (-2) +#define SCMI_DENIED (-3) +#define SCMI_NOT_FOUND (-4) +#define SCMI_OUT_OF_RANGE (-5) +#define SCMI_BUSY (-6) +#define SCMI_COMMS_ERROR (-7) +#define SCMI_GENERIC_ERROR (-8) +#define SCMI_HARDWARE_ERROR (-9) +#define SCMI_PROTOCOL_ERROR (-10) + +#define DT_MATCH_SCMI_SMC DT_MATCH_COMPATIBLE("arm,scmi-smc") + +#define SCMI_SMC_ID "arm,smc-id" +#define SCMI_SHARED_MEMORY "arm,scmi-shmem" +#define SCMI_SHMEM "shmem" +#define SCMI_SHMEM_MAPPED_SIZE PAGE_SIZE + +#define HYP_CHANNEL 0x0 + +#define HDR_ID GENMASK(7,0) +#define HDR_TYPE GENMASK(9, 8) +#define HDR_PROTO GENMASK(17, 10) + +/* SCMI protocol, refer to section 4.2.2.2 (DEN0056C) */ +#define MSG_N_AGENTS_MASK GENMASK(15, 8) + +#define FIELD_GET(_mask, _reg)\ + ((typeof(_mask))(((_reg) & (_mask)) >> (ffs64(_mask) - 1))) +#define FIELD_PREP(_mask, _val)\ + (((typeof(_mask))(_val) << (ffs64(_mask) - 1)) & (_mask)) + +typedef struct scmi_msg_header { + uint8_t id; + uint8_t type; + uint8_t protocol; +} scmi_msg_header_t; + +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE BIT(0, UL) +#define SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR BIT(1, UL) + +#define SCMI_ALLOW_ACCESS BIT(0, UL) + +struct scmi_shared_mem { + uint32_t reserved; + uint32_t channel_status; + uint32_t reserved1[2]; + uint32_t flags; + uint32_t length; + uint32_t msg_header; + uint8_t msg_payload[]; +}; + +struct dt_channel_addr { + u64 addr; + u64 size; + struct list_head list; +}; + +struct scmi_channel { + int chan_id; + int agent_id; + uint32_t func_id; + domid_t domain_id; + uint64_t paddr; + uint64_t len; + struct scmi_shared_mem *shmem; + spinlock_t lock; + struct list_head list; +}; + +struct scmi_data { + struct list_head channel_list; + spinlock_t channel_list_lock; + bool initialized; +}; + +static struct scmi_data scmi_data; + + +/* + * pack_scmi_header() - packs and returns 32-bit header + * + * @hdr: pointer to header containing all the information on message id, + * protocol id and type id. + * + * Return: 32-bit packed message header to be sent to the platform. + */ +static inline uint32_t pack_scmi_header(scmi_msg_header_t *hdr) +{ + return FIELD_PREP(HDR_ID, hdr->id) | + FIELD_PREP(HDR_TYPE, hdr->type) | + FIELD_PREP(HDR_PROTO, hdr->protocol); +} + +/* + * unpack_scmi_header() - unpacks and records message and protocol id + * + * @msg_hdr: 32-bit packed message header sent from the platform + * @hdr: pointer to header to fetch message and protocol id. + */ +static inline void unpack_scmi_header(uint32_t msg_hdr, scmi_msg_header_t = *hdr) +{ + hdr->id =3D FIELD_GET(HDR_ID, msg_hdr); + hdr->type =3D FIELD_GET(HDR_TYPE, msg_hdr); + hdr->protocol =3D FIELD_GET(HDR_PROTO, msg_hdr); +} + +static inline int channel_is_free(struct scmi_channel *chan_info) +{ + return ( chan_info->shmem->channel_status + & SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE ) ? 0 : -EBUSY; +} + +/* + * Copy data from IO memory space to "real" memory space. + */ +void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t c= ount) +{ + while (count && !IS_ALIGNED((unsigned long)from, 4)) { + *(u8 *)to =3D __raw_readb(from); + from++; + to++; + count--; + } + + while (count >=3D 4) { + *(u32 *)to =3D __raw_readl(from); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + while (count) { + *(u8 *)to =3D __raw_readb(from); + from++; + to++; + count--; + } +} + +/* + * Copy data from "real" memory space to IO memory space. + */ +void __memcpy_toio(volatile void __iomem *to, const void *from, size_t cou= nt) +{ + while (count && !IS_ALIGNED((unsigned long)to, 4)) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } + + while (count >=3D 4) { + __raw_writel(*(u32 *)from, to); + from +=3D 4; + to +=3D 4; + count -=3D 4; + } + + while (count) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } +} + +static int send_smc_message(struct scmi_channel *chan_info, + scmi_msg_header_t *hdr, void *data, int len) +{ + struct arm_smccc_res resp; + int ret; + + if ( (len + sizeof(chan_info->shmem->msg_header)) > + SCMI_SHMEM_MAPPED_SIZE ) + { + printk(XENLOG_ERR + "scmi: Wrong size of smc message. Data is invalid\n"); + return -EINVAL; + } + + printk(XENLOG_DEBUG "scmi: status =3D%d len=3D%d\n", + chan_info->shmem->channel_status, len); + printk(XENLOG_DEBUG "scmi: header id =3D %d type =3D %d, proto =3D %d\= n", + hdr->id, hdr->type, hdr->protocol); + + ret =3D channel_is_free(chan_info); + if ( IS_ERR_VALUE(ret) ) + return ret; + + chan_info->shmem->channel_status =3D 0x0; + /* Writing 0x0 right now, but SCMI_SHMEM_FLAG_INTR_ENABLED can be set = */ + chan_info->shmem->flags =3D 0x0; + chan_info->shmem->length =3D sizeof(chan_info->shmem->msg_header) + le= n; + chan_info->shmem->msg_header =3D pack_scmi_header(hdr); + + printk(XENLOG_DEBUG "scmi: Writing to shmem address %p\n", + chan_info->shmem); + if ( len > 0 && data ) + __memcpy_toio((void *)(chan_info->shmem->msg_payload), data, len); + + arm_smccc_smc(chan_info->func_id, 0, 0, 0, 0, 0, 0, chan_info->chan_id, + &resp); + + printk(XENLOG_DEBUG "scmi: scmccc_smc response %d\n", (int)(resp.a0)); + + if ( resp.a0 ) + return -EOPNOTSUPP; + + return 0; +} + +static int check_scmi_status(int scmi_status) +{ + if ( scmi_status =3D=3D SCMI_SUCCESS ) + return 0; + + printk(XENLOG_DEBUG "scmi: Error received: %d\n", scmi_status); + + switch ( scmi_status ) + { + case SCMI_NOT_SUPPORTED: + return -EOPNOTSUPP; + case SCMI_INVALID_PARAMETERS: + return -EINVAL; + case SCMI_DENIED: + return -EACCES; + case SCMI_NOT_FOUND: + return -ENOENT; + case SCMI_OUT_OF_RANGE: + return -ERANGE; + case SCMI_BUSY: + return -EBUSY; + case SCMI_COMMS_ERROR: + return -ENOTCONN; + case SCMI_GENERIC_ERROR: + return -EIO; + case SCMI_HARDWARE_ERROR: + return -ENXIO; + case SCMI_PROTOCOL_ERROR: + return -EBADMSG; + default: + return -EINVAL; + } +} + +static int get_smc_response(struct scmi_channel *chan_info, + scmi_msg_header_t *hdr, void *data, int len) +{ + int recv_len; + int ret; + + printk(XENLOG_DEBUG "scmi: get smc responce msgid %d\n", hdr->id); + + if ( len >=3D SCMI_SHMEM_MAPPED_SIZE - sizeof(chan_info->shmem) ) + { + printk(XENLOG_ERR + "scmi: Wrong size of input smc message. Data may be invalid= \n"); + return -EINVAL; + } + + ret =3D channel_is_free(chan_info); + if ( IS_ERR_VALUE(ret) ) + return ret; + + recv_len =3D chan_info->shmem->length - sizeof(chan_info->shmem->msg_h= eader); + + if ( recv_len < 0 ) + { + printk(XENLOG_ERR + "scmi: Wrong size of smc message. Data may be invalid\n"); + return -EINVAL; + } + + if ( recv_len > len ) + { + printk(XENLOG_ERR + "scmi: Not enough buffer for message %d, expecting %d\n", + recv_len, len); + return -EINVAL; + } + + unpack_scmi_header(chan_info->shmem->msg_header, hdr); + + if ( recv_len > 0 ) + { + __memcpy_fromio(data, chan_info->shmem->msg_payload, recv_len); + } + + return 0; +} + +static int do_smc_xfer(struct scmi_channel *channel, scmi_msg_header_t *hd= r, void *tx_data, int tx_size, + void *rx_data, int rx_size) +{ + int ret =3D 0; + + ASSERT( channel && channel->shmem); + + if ( !hdr ) + return -EINVAL; + + spin_lock(&channel->lock); + + ret =3D send_smc_message(channel, hdr, tx_data, tx_size); + if ( ret ) + goto clean; + + ret =3D get_smc_response(channel, hdr, rx_data, rx_size); +clean: + spin_unlock(&channel->lock); + + return ret; +} + +static struct scmi_channel *get_channel_by_id(uint8_t chan_id) +{ + struct scmi_channel *curr; + bool found =3D false; + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + { + if ( curr->chan_id =3D=3D chan_id ) + { + found =3D true; + break; + } + } + + spin_unlock(&scmi_data.channel_list_lock); + if ( found ) + return curr; + + return NULL; +} + +static struct scmi_channel *aquire_scmi_channel(domid_t domain_id) +{ + struct scmi_channel *curr; + bool found =3D false; + + ASSERT(domain_id !=3D DOMID_INVALID && domain_id >=3D 0); + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + { + if ( curr->domain_id =3D=3D DOMID_INVALID ) + { + curr->domain_id =3D domain_id; + found =3D true; + break; + } + } + + spin_unlock(&scmi_data.channel_list_lock); + if ( found ) + return curr; + + return NULL; +} + +static void relinquish_scmi_channel(struct scmi_channel *channel) +{ + ASSERT(channel !=3D NULL); + + spin_lock(&scmi_data.channel_list_lock); + channel->domain_id =3D DOMID_INVALID; + spin_unlock(&scmi_data.channel_list_lock); +} + +static int map_channel_memory(struct scmi_channel *channel) +{ + ASSERT( channel && channel->paddr ); + channel->shmem =3D ioremap_cache(channel->paddr, SCMI_SHMEM_MAPPED_SIZ= E); + if ( !channel->shmem ) + return -ENOMEM; + + channel->shmem->channel_status =3D SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE; + printk(XENLOG_DEBUG "scmi: Got shmem after vmap %p\n", channel->shmem); + return 0; +} + +static void unmap_channel_memory(struct scmi_channel *channel) +{ + ASSERT( channel && channel->shmem ); + iounmap(channel->shmem); + channel->shmem =3D NULL; +} + +static struct scmi_channel *smc_create_channel(uint8_t chan_id, + uint32_t func_id, uint64_t = addr) +{ + struct scmi_channel *channel; + + channel =3D get_channel_by_id(chan_id); + if ( channel ) + return ERR_PTR(EEXIST); + + channel =3D xmalloc(struct scmi_channel); + if ( !channel ) + return ERR_PTR(ENOMEM); + + channel->chan_id =3D chan_id; + channel->func_id =3D func_id; + channel->domain_id =3D DOMID_INVALID; + channel->shmem =3D NULL; + channel->paddr =3D addr; + spin_lock_init(&channel->lock); + spin_lock(&scmi_data.channel_list_lock); + list_add(&channel->list, &scmi_data.channel_list); + spin_unlock(&scmi_data.channel_list_lock); + return channel; +} + +static int mem_permit_access(struct domain *d, uint64_t addr, uint64_t len) +{ + return iomem_permit_access(d, paddr_to_pfn(addr), + paddr_to_pfn(PAGE_ALIGN(addr + len -1))); +} + +static int mem_deny_access(struct domain *d, uint64_t addr, + uint64_t len) +{ + return iomem_deny_access(d, paddr_to_pfn(addr), + paddr_to_pfn(PAGE_ALIGN(addr + len -1))); +} + +static int dt_update_domain_range(uint64_t addr, uint64_t size) +{ + struct dt_device_node *shmem_node; + __be32 *hw_reg; + const struct dt_property *pp; + uint32_t len; + + shmem_node =3D dt_find_compatible_node(NULL, NULL, SCMI_SHARED_MEMORY); + if ( !shmem_node ) + { + printk(XENLOG_ERR "scmi: Unable to find %s node in DT\n", SCMI_SHM= EM); + return -EINVAL; + } + + pp =3D dt_find_property(shmem_node, "reg", &len); + if ( !pp ) + { + printk(XENLOG_ERR "scmi: Unable to find regs entry in shmem node\n= "); + return -ENOENT; + } + + hw_reg =3D pp->value; + dt_set_range(&hw_reg, shmem_node, addr, size); + + return 0; +} + +static void free_channel_list(void) +{ + struct scmi_channel *curr, *_curr; + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry_safe (curr, _curr, &scmi_data.channel_list, list) + { + list_del(&curr->list); + xfree(curr); + } + + spin_unlock(&scmi_data.channel_list_lock); +} + +static struct dt_device_node *get_dt_node_from_property( + struct dt_device_node *node, const char * p_name) +{ + const __be32 *prop; + + ASSERT( node ); + + prop =3D dt_get_property(node, p_name, NULL); + if ( !prop ) + return ERR_PTR(-EINVAL); + + return dt_find_node_by_phandle(be32_to_cpup(prop)); +} + +static int get_shmem_regions(struct list_head *head, u64 hyp_addr) +{ + struct dt_device_node *node; + int ret; + struct dt_channel_addr *lchan; + u64 laddr, lsize; + + node =3D dt_find_compatible_node(NULL, NULL, SCMI_SHARED_MEMORY); + if ( !node ) + return -ENOENT; + + while ( node ) + { + ret =3D dt_device_get_address(node, 0, &laddr, &lsize); + if ( ret ) + return ret; + + if ( laddr !=3D hyp_addr ) + { + lchan =3D xmalloc(struct dt_channel_addr); + if ( !lchan ) + return -ENOMEM; + lchan->addr =3D laddr; + lchan->size =3D lsize; + + list_add_tail(&lchan->list, head); + } + + node =3D dt_find_compatible_node(node, NULL, SCMI_SHARED_MEMORY); + } + + return 0; +} + +static int read_hyp_channel_addr(struct dt_device_node *scmi_node, + u64 *addr, u64 *size) +{ + struct dt_device_node *shmem_node; + shmem_node =3D get_dt_node_from_property(scmi_node, "shmem"); + if ( IS_ERR_OR_NULL(shmem_node) ) + { + printk(XENLOG_ERR + "scmi: Device tree error, can't parse reserved memory %ld\n= ", + PTR_ERR(shmem_node)); + return PTR_ERR(shmem_node); + } + + return dt_device_get_address(shmem_node, 0, addr, size); +} + +static void free_shmem_regions(struct list_head *addr_list) +{ + struct dt_channel_addr *curr, *_curr; + + list_for_each_entry_safe (curr, _curr, addr_list, list) + { + list_del(&curr->list); + xfree(curr); + } +} + +static __init bool scmi_probe(struct dt_device_node *scmi_node) +{ + u64 addr, size; + int ret, i; + struct scmi_channel *channel, *agent_channel; + int n_agents; + scmi_msg_header_t hdr; + struct rx_t { + int32_t status; + uint32_t attributes; + } rx; + struct dt_channel_addr *entry; + struct list_head addr_list; + + uint32_t func_id; + + ASSERT(scmi_node !=3D NULL); + + INIT_LIST_HEAD(&scmi_data.channel_list); + spin_lock_init(&scmi_data.channel_list_lock); + + if ( !dt_property_read_u32(scmi_node, SCMI_SMC_ID, &func_id) ) + { + printk(XENLOG_ERR "scmi: Unable to read smc-id from DT\n"); + return false; + } + + ret =3D read_hyp_channel_addr(scmi_node, &addr, &size); + if ( IS_ERR_VALUE(ret) ) + return false; + + if ( !IS_ALIGNED(size, SCMI_SHMEM_MAPPED_SIZE) ) + { + printk(XENLOG_ERR "scmi: Reserved memory is not aligned\n"); + return false; + } + + INIT_LIST_HEAD(&addr_list); + + ret =3D get_shmem_regions(&addr_list, addr); + if ( IS_ERR_VALUE(ret) ) + goto out; + + channel =3D smc_create_channel(HYP_CHANNEL, func_id, addr); + if ( IS_ERR(channel) ) + goto out; + + ret =3D map_channel_memory(channel); + if ( ret ) + goto out; + + spin_lock(&scmi_data.channel_list_lock); + channel->domain_id =3D DOMID_XEN; + spin_unlock(&scmi_data.channel_list_lock); + + hdr.id =3D SCMI_BASE_PROTOCOL_ATTIBUTES; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + ret =3D do_smc_xfer(channel, &hdr, NULL, 0, &rx, sizeof(rx)); + if ( ret ) + goto error; + + ret =3D check_scmi_status(rx.status); + if ( ret ) + goto error; + + n_agents =3D FIELD_GET(MSG_N_AGENTS_MASK, rx.attributes); + printk(XENLOG_DEBUG "scmi: Got agent count %d\n", n_agents); + + i =3D 1; + list_for_each_entry(entry, &addr_list, list) + { + uint32_t tx_agent_id =3D 0xFFFFFFFF; + struct { + int32_t status; + uint32_t agent_id; + char name[16]; + } da_rx; + + agent_channel =3D smc_create_channel(i, func_id, + entry->addr); + if ( IS_ERR(agent_channel) ) + { + ret =3D PTR_ERR(agent_channel); + goto error; + } + + ret =3D map_channel_memory(agent_channel); + if ( ret ) + goto error; + + hdr.id =3D SCMI_BASE_DISCOVER_AGENT; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + ret =3D do_smc_xfer(agent_channel, &hdr, &tx_agent_id, + sizeof(tx_agent_id), &da_rx, sizeof(da_rx)); + if ( ret ) + { + unmap_channel_memory(agent_channel); + goto error; + } + + unmap_channel_memory(agent_channel); + + ret =3D check_scmi_status(da_rx.status); + if ( ret ) + goto error; + + printk(XENLOG_DEBUG "scmi: status=3D0x%x id=3D0x%x name=3D%s\n", + da_rx.status, da_rx.agent_id, da_rx.name); + + agent_channel->agent_id =3D da_rx.agent_id; + + if ( i =3D=3D n_agents ) + break; + + i++; + } + + scmi_data.initialized =3D true; + goto out; + +error: + unmap_channel_memory(channel); + free_channel_list(); +out: + free_shmem_regions(&addr_list); + return ret =3D=3D 0; +} + +static int scmi_domain_init(struct domain *d, + struct xen_arch_domainconfig *config) +{ + struct scmi_channel *channel; + int ret; + + if ( !scmi_data.initialized ) + return 0; + + printk(XENLOG_INFO "scmi: domain_id =3D %d\n", d->domain_id); + + channel =3D aquire_scmi_channel(d->domain_id); + if ( IS_ERR_OR_NULL(channel) ) + return -ENOENT; + +#ifdef CONFIG_ARM_32 + printk(XENLOG_INFO + "scmi: Aquire SCMI channel id =3D 0x%x , domain_id =3D %d paddr= =3D 0x%llx\n", + channel->chan_id, channel->domain_id, channel->paddr); +#else + printk(XENLOG_INFO + "scmi: Aquire SCMI channel id =3D 0x%x , domain_id =3D %d paddr= =3D 0x%lx\n", + channel->chan_id, channel->domain_id, channel->paddr); +#endif + + if ( is_hardware_domain(d) ) + { + ret =3D mem_permit_access(d, channel->paddr, PAGE_SIZE); + if ( IS_ERR_VALUE(ret) ) + goto error; + + ret =3D dt_update_domain_range(channel->paddr, PAGE_SIZE); + if ( IS_ERR_VALUE(ret) ) + { + int rc =3D mem_deny_access(d, channel->paddr, PAGE_SIZE); + if ( rc ) + printk(XENLOG_ERR "Unable to mem_deny_access\n"); + + goto error; + } + } + + d->arch.sci =3D channel; + if ( config ) + config->arm_sci_agent_paddr =3D channel->paddr; + + return 0; +error: + relinquish_scmi_channel(channel); + + return ret; +} + +static int scmi_add_device_by_devid(struct domain *d, uint32_t scmi_devid) +{ + struct scmi_channel *channel, *agent_channel; + scmi_msg_header_t hdr; + struct scmi_perms_tx { + uint32_t agent_id; + uint32_t device_id; + uint32_t flags; + } tx; + struct rx_t { + int32_t status; + uint32_t attributes; + } rx; + int ret; + + if ( !scmi_data.initialized ) + return 0; + + printk(XENLOG_DEBUG "scmi: scmi_devid =3D %d\n", scmi_devid); + + agent_channel =3D d->arch.sci; + if ( IS_ERR_OR_NULL(agent_channel) ) + return PTR_ERR(agent_channel); + + channel =3D get_channel_by_id(HYP_CHANNEL); + if ( IS_ERR_OR_NULL(channel) ) + return PTR_ERR(channel); + + hdr.id =3D SCMI_BASE_SET_DEVICE_PERMISSIONS; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + tx.agent_id =3D agent_channel->agent_id; + tx.device_id =3D scmi_devid; + tx.flags =3D SCMI_ALLOW_ACCESS; + + ret =3D do_smc_xfer(channel, &hdr, &tx, sizeof(tx), &rx, sizeof(&rx)); + if ( IS_ERR_VALUE(ret) ) + return ret; + + ret =3D check_scmi_status(rx.status); + if ( IS_ERR_VALUE(ret) ) + return ret; + + return 0; +} + +static int scmi_add_dt_device(struct domain *d, struct dt_device_node *dev) +{ + uint32_t scmi_devid; + + if ( (!scmi_data.initialized) || (!d->arch.sci) ) + return 0; + + if ( !dt_property_read_u32(dev, "scmi_devid", &scmi_devid) ) + return 0; + + printk(XENLOG_INFO "scmi: dt_node =3D %s\n", dt_node_full_name(dev)); + + return scmi_add_device_by_devid(d, scmi_devid); +} + +static int scmi_relinquish_resources(struct domain *d) +{ + int ret; + struct scmi_channel *channel, *agent_channel; + scmi_msg_header_t hdr; + struct reset_agent_tx { + uint32_t agent_id; + uint32_t flags; + } tx; + uint32_t rx; + + if ( !d->arch.sci ) + return 0; + + agent_channel =3D d->arch.sci; + + spin_lock(&agent_channel->lock); + tx.agent_id =3D agent_channel->agent_id; + spin_unlock(&agent_channel->lock); + + channel =3D get_channel_by_id(HYP_CHANNEL); + if ( !channel ) + { + printk(XENLOG_ERR + "scmi: Unable to get Hypervisor scmi channel for domain %d\= n", + d->domain_id); + return -EINVAL; + } + + hdr.id =3D SCMI_BASE_RESET_AGENT_CONFIGURATION; + hdr.type =3D 0; + hdr.protocol =3D SCMI_BASE_PROTOCOL; + + tx.flags =3D 0; + + ret =3D do_smc_xfer(channel, &hdr, &tx, sizeof(tx), &rx, sizeof(rx)); + if ( ret ) + return ret; + + ret =3D check_scmi_status(rx); + + return ret; +} + +static void scmi_domain_destroy(struct domain *d) +{ + struct scmi_channel *channel; + + if ( !d->arch.sci ) + return; + + channel =3D d->arch.sci; + spin_lock(&channel->lock); + + relinquish_scmi_channel(channel); + printk(XENLOG_DEBUG "scmi: Free domain %d\n", d->domain_id); + + d->arch.sci =3D NULL; + + mem_deny_access(d, channel->paddr, PAGE_SIZE); + spin_unlock(&channel->lock); +} + +static bool scmi_handle_call(struct domain *d, void *args) +{ + bool res =3D false; + struct scmi_channel *agent_channel; + struct arm_smccc_res resp; + struct cpu_user_regs *regs =3D args; + + if ( !d->arch.sci ) + return false; + + agent_channel =3D d->arch.sci; + spin_lock(&agent_channel->lock); + + if ( agent_channel->func_id !=3D regs->r0 ) + { + res =3D false; + goto unlock; + } + + arm_smccc_smc(agent_channel->func_id, 0, 0, 0, 0, 0, 0, + agent_channel->chan_id, &resp); + + set_user_reg(regs, 0, resp.a0); + set_user_reg(regs, 1, resp.a1); + set_user_reg(regs, 2, resp.a2); + set_user_reg(regs, 3, resp.a3); + res =3D true; +unlock: + spin_unlock(&agent_channel->lock); + + return res; +} + +static const struct dt_device_match scmi_smc_match[] __initconst =3D +{ + DT_MATCH_SCMI_SMC, + { /* sentinel */ }, +}; + +static const struct sci_mediator_ops scmi_ops =3D +{ + .probe =3D scmi_probe, + .domain_init =3D scmi_domain_init, + .domain_destroy =3D scmi_domain_destroy, + .add_dt_device =3D scmi_add_dt_device, + .relinquish_resources =3D scmi_relinquish_resources, + .handle_call =3D scmi_handle_call, +}; + +REGISTER_SCI_MEDIATOR(scmi_smc, "SCMI-SMC", XEN_DOMCTL_CONFIG_ARM_SCI_SCMI= _SMC, + scmi_smc_match, &scmi_ops); + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343259; cv=pass; d=zohomail.com; s=zohoarc; b=W5/iZmO7NVnv2hdApqQR1nECnOeNGpJ/qHyMuGsUB1PAOwzTfvT6i5EwXpmlA9yqP317FxH7ttfrgqWRL7Pk7OPOFmiueIkUGH/v3sg/BPtz8v4hR4X44+NYU9w9Ndq0AADOTtUTYkmz2cj4xPs0MBPKHsf34YTvYRuTM8Mnqxo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343259; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HALhPv+64kbkAOfpSs3FqZOqYi5IDheOGLf5PgXphVE=; b=OSO/AeF+drO2pP1dtDm/LMTlj6ynqO9T1lfoDbbsTiYjqaipjixFTUowig7kl4g37LWkHshcZDmxoPprZPVl+XjHn5Ak2eBMKLiYejsKF10thXSdlSPCs/XXYMALaShakSwUuPcZSSvzAU5zqf8oXdxLzApclWy56mxbN29H5eE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644343259674764.9802988841101; Tue, 8 Feb 2022 10:00:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268495.462375 (Exim 4.92) (envelope-from ) id 1nHUmt-0007BO-Tn; Tue, 08 Feb 2022 18:00:23 +0000 Received: by outflank-mailman (output) from mailman id 268495.462375; Tue, 08 Feb 2022 18:00:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmt-0007BF-Q6; Tue, 08 Feb 2022 18:00:23 +0000 Received: by outflank-mailman (input) for mailman id 268495; Tue, 08 Feb 2022 18:00:22 +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 1nHUmr-00068L-Uj for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:22 +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 fa4697a8-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:20 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrT7015757; Tue, 8 Feb 2022 18:00:16 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:15 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:12 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fa4697a8-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h2KNhFxlgCVQ3hz6aHDPUNPiLYciaW/Wx82wVBnPSTn9Glspe4Pvd752Yhup5TeOWcEarzDyeZ8JH+S9nLgSfODgcCeuXYnE/pm/3TP68wgaXif26CW9PGeHXpil9dBdE+Y+ksydH8sO2MUg07mCqpnQ6ku/kKKkClNX0z8BqQodUK4Ax4HL2+SdIv688PiQkyWkGoR84mg2aYba18FflVp75FCmVzmRFYq3BCXdB9Kk66wM6lNw6JAEq/uNB6AlCKRNvLSgeqKPOIMvcIO4yDtfQcZlKpVsppn5tghhbGNDTdX/8qa62BEzlJubYRqQqnM8m0dcU5Aq5EpxU1BBEg== 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=HALhPv+64kbkAOfpSs3FqZOqYi5IDheOGLf5PgXphVE=; b=ccvM4G7+MTrS7txnx2sAe5VH+pF/x2c/AzFZz1U6sVlCWvmGc+kPWEYtWT5l1h5kD4jEzUPfy9JiyLraxAqIFHOANtGq7UJsUF+551WYEDKsiyBPFW1DdYJAqwUYbTgcHF5zAKYtBzU85KFcYbYD6dnCg+uEsNF8RFk1smy5K8FuO/dmrN3/L6CTV9ofMJz0IXDiINl6MZhXfzkURBUv/2YpgnL9HaUdrHWEcv4WRREwHZrhAKcr3aSqAN+2rKpcRQ9uW0/CyrD9aFwE5ejiSWvKOchkxINP8jKSzpRsBpJnXNOrojeZ3mNiNenxY7sRudlw83bV/IThXVtcsA07Rw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=HALhPv+64kbkAOfpSs3FqZOqYi5IDheOGLf5PgXphVE=; b=ieLdGr4y1e7909uSLGz0HjamxFFs996NCd0HBilnPNN3C4vpjB8MWumuTRXf7qf0BAMKkOoDQHabEX9cZWJW7tSqcGXopofHS4nVPtRiEhYFduhpTO6b752KBb7plNHPJAuGp0lW/0RZaqjnrC2zswJtLC30tSZvzqOhU3Ba7W4V1GdmX4ueU2YugSEBX4BJkjHulIifGYOFhZ+se6BshIXAYIzEFDlY1PEdj56z5qKAIOU1jBCfAbBmaoUjr+r/p86XyOhQr+l1L2jnHt+gVPnAYCUX+NBOb/w78rHPxf3mocV8P3vLmTKC+sU4+SWlFUobNpTRbZg0Xz+gt4vOiw== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Wei Liu , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Nick Rosbrook , Anthony PERARD , Juergen Gross , Paul Durrant Subject: [RFC v2 6/8] tools/arm: Introduce force_assign_without_iommu option to xl.cfg Thread-Topic: [RFC v2 6/8] tools/arm: Introduce force_assign_without_iommu option to xl.cfg Thread-Index: AQHYHRW3O86755dYV0qSgPdVO9oeMQ== Date: Tue, 8 Feb 2022 18:00:12 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1406799b-d4c3-4d19-7fe5-08d9eb2cda71 x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2733; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 593+KpeE3vja2YgkOiTpjRnUJLKsUnuEshoh2Z+V4mqsiSo09+3zRaS1Vrpv8dZ1iF/MqnsrWN/6uJj3IPvFXeyHgMPPFhyLjYLtQdCHGvz3x5MiTEdThKVlcsWcAOBYCm70PN/BkdRouDMixd5PCS6IYkW6v0vjahDLiDE9ZZwKve/jGlk2h7pfJp6pgQ3x5deUnaR+GPL7KbZsW53Jre8is0NkCBSmdLjMjk0FXgej+AILfM8vZFYtTPg23/1ci2UDpCHDNLGlWw/rIPAsYNvNyIXnLKKQDX5LVvQ09PhoGojoAHPRVhrbaCXc/l93tIS1rMB2FEc/lJruP+iKuym+aaruKVbACuzf4dVe98myH+NmviMnY3WtQ7EaDurHQvEz7xd7LZX30lJE9LbMVziWg2Jycy3yyIGOFNrff7HgxmMc4F4OBJFidDNLokEjZyBS3hU/GlkvugonmB/eXwyAouXPctx4J6XtcUnhOls9BBKDwNgun5ZY9DroINfjiWFDy8hq1Xjcm/eKoMVBsFovONlsF88xcVB5UJLSV8Cs2tGeOepWnfYDHEOXzi595m3+Y2qsHkCBbtXSDTK9nEcY7SW/nWEOMdBqzEs7nrThcYj63kObyzkok3T/66q3MddGajmE+q9iww35HLMfC8Aoyfhfrt9HIfGHyg+iOUjaAJXJXp5EHL2oNK11D/wzlvO8BRKM9VsrZijYDtwKSw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(7416002)(4326008)(83380400001)(54906003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?H5luS7cGOqtky8dqBSfDdIBF46ch9LNqepgA9GrqaX4ojMAXig0k8+s4qo?= =?iso-8859-1?Q?f5lKGI9tUPDokXwTEGqrRhc2ZBpIKSOO2/P560SJXgreqWgV27tF0ReiU1?= =?iso-8859-1?Q?+qF9up8uSuYejI2F8a0sO9Zv6AxP3ijoB8mrmZ/VsCw68+c/tSmyEeHezX?= =?iso-8859-1?Q?ib09zKso5FC5Aa8vibGerdJVaaz9MmIr5TjbxzQJ4llz/Y2GOk5Bx8gyLN?= =?iso-8859-1?Q?2cxMhw/FQF2HTsHrtKW8spAgwjJNYhHAotUKsZBNxbgsvqUak67wtc3VFX?= =?iso-8859-1?Q?x1TCx+H7WEkSfH5Vs3SoGdOvEVqIWsEgh6O61XSPNO3IC9prDEbqFLKECo?= =?iso-8859-1?Q?MaiTb2NvgBgFoK+EcBSvVBr4Q4CEIdUQ3CehkEcW22ruuLu6bADw7Ourfy?= =?iso-8859-1?Q?uIaTITO97i8FtNa39qQJ8G/IoxF4nwU03NMfn5z/6tJaelToWW0c06rfkG?= =?iso-8859-1?Q?1t2dKwIdKNgulenR6CNB+lMNb6PSW4KeZpcnUVsjtMo7Z1rqihaAxx/D3P?= =?iso-8859-1?Q?6mBf5iV/sukO9xCu/VSkSMnUaIhEXphzPaIVHkHc6HHfbJCjZy5xDDcqf9?= =?iso-8859-1?Q?ZwADwtD66UiXcZe/oVJtQGyaN5258jhSDzDcDGRnmHl0N0uEOQlHhb/zbl?= =?iso-8859-1?Q?sUBQaAGZRlpdvlbuJbN8Myp6UovCN5VctfPlJmbQPAHp+M5BE6RO0EQaCx?= =?iso-8859-1?Q?+Im/m1o+VHxofRcAKlbaUZnKb/X4tXjpl5S2kcSrRXddJza2hmXPaZaPmu?= =?iso-8859-1?Q?o/douwHmz2iK5LO8aCFNy67JzrnG1UUJB/+9d5dtJfDb9Q5eXAoNuvZKVp?= =?iso-8859-1?Q?lEHt2Fq7+w5NRDVZnEbpSLkDBV6AwfYnU0CR6kQrYKut7BIULwCk+D7b+Z?= =?iso-8859-1?Q?fuwr77PA62dO+U9UJviqXtYIEX+ROh9Pp87puCa8M0KAHuYuTua/oh7Shr?= =?iso-8859-1?Q?2HpC8Z/mUq7gMG2edV07HWNE+AaYGFSSXKo7mycjJwn2w+z6dM+VVbcSFT?= =?iso-8859-1?Q?d/auZ/4pDKBctfoO9tkZU2rPN5tjwdnoFWNyKu48bnlvJk6BwNpksZDK+v?= =?iso-8859-1?Q?QZaMTgJMoBA4HMLj989wUEK+10FJ2B9R8wfJ6CggN13udtavg7XZq5j9nn?= =?iso-8859-1?Q?ab1tKkS7GSn54N9SVnKPMyM6sr2JJQt+wvV115FFS71vchWfq1dE00dBAT?= =?iso-8859-1?Q?2s4wbDT3+vRzGM6Ws2BheIoql9OqOdmxbHqCOceS/4XA3PwMun56ytPN0i?= =?iso-8859-1?Q?4AOsTvQUcRGCGaCWhoje2F1GeePOgoFVCYQiLIjWCMUljubHbWh5CUHbDa?= =?iso-8859-1?Q?NOhuLPmvKiQ13AhvBX/nczL7sJ3KjAgWxVa10NdKwQs2L4sx+COje5FPsz?= =?iso-8859-1?Q?hxS5hl61VR8utIanAezbLu/SCv4omYchkh9jU2lVbBxdprOsC0V4C3Elll?= =?iso-8859-1?Q?TtaXvbzCZF2VCvgcbk+YYDwZEmI2jLq0jXINdRulSET2eJg9akGcOO4Sgc?= =?iso-8859-1?Q?LgK2xh7NUGvKZ9eS8YqFZfGUC8tgVByzxa9iLzfgHmgREV2dSc+s2ic+mP?= =?iso-8859-1?Q?BAAzWx9+6ORWxRpX5Wnpc9lJdPlL4A8/s7KWFi/TQb5g53HCJpn+s2ep2v?= =?iso-8859-1?Q?56INYeOXeg2/paMEIgURJsTJYfvRkuu3FbZzSibmroOAVcVsPi5CFgtFrc?= =?iso-8859-1?Q?XpXJS/MPfRNIino0QqhCITWz8X1Oqe2SOabs/Idumn9HLtJdwiJAqz1tZy?= =?iso-8859-1?Q?20zcihE3kJaDurxmiq2s2QCDo=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1406799b-d4c3-4d19-7fe5-08d9eb2cda71 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:12.4970 (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: 5DOSt7gwUuwIgKy6ZRyHgGtHxhKXNGVsOzC7tpi3/KuMPnoQfP0vUyJNjT1bel8QlNHtM6Avhi8jw+8ypNYye3goNyRILoMTWNdhNh7rJAA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: bzJlSQfioNgt_-ErlNy4ipphN0IvOoPY X-Proofpoint-ORIG-GUID: bzJlSQfioNgt_-ErlNy4ipphN0IvOoPY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343261117100005 Content-Type: text/plain; charset="utf-8" If set, Xen is allowed to assign the devices even if they are not under IOMMU. Can be confugired from dom.cfg in the following format: force_assign_without_iommu =3D 1 This parameter has the same purpose as xen,force-assign-without-iommu property in dom0less archtecture. Signed-off-by: Oleksii Moisieiev --- docs/man/xl.cfg.5.pod.in | 9 +++++++++ tools/golang/xenlight/helpers.gen.go | 5 +++++ tools/golang/xenlight/types.gen.go | 1 + tools/libs/light/libxl_arm.c | 3 +++ tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 3 +++ xen/common/domain.c | 2 +- xen/drivers/passthrough/device_tree.c | 19 +++++++++++++++++-- xen/drivers/passthrough/iommu.c | 5 ++++- xen/include/public/domctl.h | 5 ++++- xen/include/xen/iommu.h | 3 +++ 11 files changed, 51 insertions(+), 5 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index b98d161398..ddf82cb3bc 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1614,6 +1614,15 @@ This feature is a B. =20 =3Dback =20 +=3Dover 4 + +=3Ditem B + +If set, Xen allows to assign a devices even if it is not behind an IOMMU. +This renders your platform *unsafe* if the device is DMA-capable. + +=3Dback + =3Dback =20 =3Dhead2 Paravirtualised (PV) Guest Specific Options diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index b746ff1081..664933bbb8 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1091,6 +1091,11 @@ if err :=3D x.DmRestrict.fromC(&xc.dm_restrict);err = !=3D nil { return fmt.Errorf("converting field DmRestrict: %v", err) } x.Tee =3D TeeType(xc.tee) + +if err :=3D x.ForceAssignWithoutIommu.fromC(&xc.force_assign_without_iommu= );err !=3D nil { +return fmt.Errorf("converting field ForceAssignWithoutIommu: %v", err) +} + x.Type =3D DomainType(xc._type) switch x.Type{ case DomainTypeHvm: diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index b1e84d5258..2f7a088c3b 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -512,6 +512,7 @@ NestedHvm Defbool Apic Defbool DmRestrict Defbool Tee TeeType +ForceAssignWithoutIommu Defbool Type DomainType TypeUnion DomainBuildInfoTypeUnion ArchArm struct { diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index eef1de0939..c5090e2b32 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -101,6 +101,9 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } =20 + if (libxl_defbool_val(d_config->b_info.force_assign_without_iommu)) + config->iommu_opts |=3D XEN_DOMCTL_IOMMU_force_iommu; + return 0; } =20 diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 2a42da2f7d..1080966c33 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -564,6 +564,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ ("apic", libxl_defbool), ("dm_restrict", libxl_defbool), ("tee", libxl_tee_type), + ("force_assign_without_iommu", libxl_defbool), ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), ("bios", libxl_bios_typ= e), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 117fcdcb2b..67fa96d949 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2747,6 +2747,9 @@ skip_usbdev: } } =20 + xlu_cfg_get_defbool(config, "force_assign_without_iommu", + &b_info->force_assign_without_iommu, 0); + parse_vkb_list(config, d_config); =20 xlu_cfg_get_defbool(config, "xend_suspend_evtchn_compat", diff --git a/xen/common/domain.c b/xen/common/domain.c index 093bb4403f..f1f19bf711 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -512,7 +512,7 @@ static int sanitise_domain_config(struct xen_domctl_cre= atedomain *config) =20 if ( iommu ) { - if ( config->iommu_opts & ~XEN_DOMCTL_IOMMU_no_sharept ) + if ( config->iommu_opts >> XEN_DOMCTL_IOMMU_MAX ) { dprintk(XENLOG_INFO, "Unknown IOMMU options %#x\n", config->iommu_opts); diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index 98f2aa0dad..103608dec1 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -198,6 +198,7 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struc= t domain *d, { int ret; struct dt_device_node *dev; + struct domain_iommu *hd =3D dom_iommu(d); =20 switch ( domctl->cmd ) { @@ -238,6 +239,16 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, stru= ct domain *d, return -EINVAL; =20 ret =3D iommu_add_dt_device(dev); + + /* + * iommu_add_dt_device returns 1 if iommu is disabled or device do= n't + * have iommus property + */ + if ( (ret =3D=3D 1) && (hd->force_assign_iommu) ) { + ret =3D -ENOSYS; + break; + } + if ( ret < 0 ) { printk(XENLOG_G_ERR "Failed to add %s to the IOMMU\n", @@ -275,10 +286,14 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, =20 ret =3D iommu_deassign_dt_device(d, dev); =20 - if ( ret ) - printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign \"%s\= "" + if ( ret ) { + if ( hd->force_assign_iommu ) + ret =3D -ENOSYS; + else + printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign \= "%s\"" " to dom%u failed (%d)\n", dt_node_full_name(dev), d->domain_id, ret); + } break; =20 default: diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iomm= u.c index 6334370109..216a9058c0 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -193,6 +193,8 @@ int iommu_domain_init(struct domain *d, unsigned int op= ts) hd->node =3D NUMA_NO_NODE; #endif =20 + hd->force_assign_iommu =3D opts & XEN_DOMCTL_IOMMU_force_iommu; + ret =3D arch_iommu_domain_init(d); if ( ret ) return ret; @@ -534,6 +536,7 @@ int iommu_do_domctl( { int ret =3D -ENODEV; =20 + if ( !is_iommu_enabled(d) ) return -EOPNOTSUPP; =20 @@ -542,7 +545,7 @@ int iommu_do_domctl( #endif =20 #ifdef CONFIG_HAS_DEVICE_TREE - if ( ret =3D=3D -ENODEV ) + if ( ret =3D=3D -ENOSYS ) ret =3D iommu_do_dt_domctl(domctl, d, u_domctl); #endif =20 diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index b85e6170b0..bf5f8c5b6b 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -81,8 +81,11 @@ struct xen_domctl_createdomain { #define _XEN_DOMCTL_IOMMU_no_sharept 0 #define XEN_DOMCTL_IOMMU_no_sharept (1U << _XEN_DOMCTL_IOMMU_no_sharept) =20 +#define _XEN_DOMCTL_IOMMU_force_iommu 1 +#define XEN_DOMCTL_IOMMU_force_iommu (1U << _XEN_DOMCTL_IOMMU_force_iommu) + /* Max XEN_DOMCTL_IOMMU_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_IOMMU_MAX XEN_DOMCTL_IOMMU_no_sharept +#define XEN_DOMCTL_IOMMU_MAX XEN_DOMCTL_IOMMU_force_iommu =20 uint32_t iommu_opts; =20 diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 6b2cdffa4a..a9cf2334af 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -330,6 +330,9 @@ struct domain_iommu { * necessarily imply this is true. */ bool need_sync; + + /* Do not return error if the device without iommu is assigned */ + bool force_assign_iommu; }; =20 #define dom_iommu(d) (&(d)->iommu) --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343259; cv=pass; d=zohomail.com; s=zohoarc; b=i83AAexkamFiB4QTci8oyKNKGpcmZNKsYXKIuY/kt6ERYdVZM/vptvcArtb+oxaXuE8upDpN2Bf3VpUpyF06kGXOdFZhjbGkRjtpuV5BOX7CBHbK79D1xZJSSVPuubtUl1bwnLqPkkICpILbS9WA6bmSliuXtFd6vgQmiEz2iPQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343259; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oz8ls5jYpEH0zZ1iaWsjgXWp+zE0wyLWSst1sUoOmY8=; b=ieqqS4SkcD8jjxKrhrCPz6ZGAnUx8JaKRjooO3SkhX3vv2YiZCRs9ClpJD2UBKac4SbzLRlSFTSWB0zxa/myf8OARuzMbcY58rE2WQFW9J8BG+vUn2gpgiTwY4xWbIbMORBaveqziThtTxCLnRiglbCL5FNhBZSnBoNclf50zEk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16443432595978.379375761482493; Tue, 8 Feb 2022 10:00:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268496.462387 (Exim 4.92) (envelope-from ) id 1nHUmv-0007T5-FB; Tue, 08 Feb 2022 18:00:25 +0000 Received: by outflank-mailman (output) from mailman id 268496.462387; Tue, 08 Feb 2022 18:00:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmv-0007SF-94; Tue, 08 Feb 2022 18:00:25 +0000 Received: by outflank-mailman (input) for mailman id 268496; Tue, 08 Feb 2022 18:00:23 +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 1nHUms-00068L-Uo for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:23 +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 fa8cc221-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:20 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrT9015757; Tue, 8 Feb 2022 18:00:17 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:17 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:13 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fa8cc221-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n/yYMu60zNdIqp3sIYHiLLxW1iQ/mMJaFpQBJySVIVjKMjBnhzHxjm54TPOJnd3ZPmFVnNT76N4UT0svt+78YJmj+8RBxO9dJ9iRxFP3rKZIWIwr0uBbAjgGbgQEnd37bVP+WaeJBGSSN9NjjqVDdLwIuGkih7cKK3UIb2by1ffvKgOcdcJvosNLDc6WNkrq+d4GU9R8Stp+3T9fXUTk1FhqENNvfHHK11ns2z7p9ubXN08loLkXw/AuTMw2/pAoOEfpoaI+MSxxAv4xfwfYIMKz/cxjhUypAEgPf5hM2vML8ib/kPl7xvuBIqXaCYOCSVW61zA5lte23YDD64CBYw== 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=oz8ls5jYpEH0zZ1iaWsjgXWp+zE0wyLWSst1sUoOmY8=; b=kU5YxXUpypTXS2Y6t5ar77Tg26uMcyuIAgFQfI9W8hC5HFQwNyNJB45Em15meaaelKZrG3uVBzqFrRnaHVFkc6JXsrKtjyxe4HyvmO2p0LxqufrAMbjOidziZb2Aemg78/YvogTJOblW6e4F/5IvSs9Qdb8mac8NBm2CT178kM1PKmIQDG12u2QlZJFFhXMTQ3VZ/96m400SbMQ1ixhtC+qEcO9/EAkYuCGqIlAgOfsmfKOFo1Rg6aIyPKi3VCC+oa1pFfBheefWd4shlxO/o7f4moswcqGqJKx20oc5poYPh9y3z2YnjgP//+3nkUgTMVzThvu+IExB9ucFhXKYQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=oz8ls5jYpEH0zZ1iaWsjgXWp+zE0wyLWSst1sUoOmY8=; b=X+MsHsSczOmM7yw5IvGR0V8nO1anPEWIiCIV7Pk5vJqCuWEb4Paj5n/pSUD9PCEsLr+td6iDfu3/Vqh8STpjLKvrUUuApSGjSkvRxmZNpuFuWJjtiFuTMA+zGwq9vwqzbI1y7epa6PHyxLVrvoNdAYqt5qJ95fFGV2AKfiN9RUdBn1gPojbefyuK+MJr15ZhIzGc6qsBAy0/mK/5CVWMhfOyBR7/jr+Mm+WsdUd+42TZ8UPTkKnmZKv2ZwmtENWrvMkuCGisz2dAn5aCi7+Je62gxalZoamRKuou1qbFqjMF4koZ5eCTJr4Y7PWOlPA28B76lpNYWfF+RWe2ibNHag== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Wei Liu , George Dunlap , Nick Rosbrook , Anthony PERARD , Juergen Gross Subject: [RFC v2 7/8] tools/arm: add "arm_sci" option to xl.cfg Thread-Topic: [RFC v2 7/8] tools/arm: add "arm_sci" option to xl.cfg Thread-Index: AQHYHRW421V3hDnhNU+uBIx9/PfKVg== Date: Tue, 8 Feb 2022 18:00:13 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c86fd87-1051-4555-8660-08d9eb2cdb00 x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CbIDa937LpIp4Ccm27Vusw4GZKDrT1VrjSsF3RQDM2BjY7MwjS+hTBbgbwW427+OIA8V3T0TLGomFsNhBmOE4gMR+fYmdCO97nan4Lvh/eLS8Pgr7vckkrtlq0M7e17Tr9FI4uqXdMmGrQLhTQmSNlKi3LLrQ9A/t/lvSaY8eq/vu5hCldLpPAU1wXFOsS2LnCl/SdZj/l5vHdC/YJc5K4nOeZ1xVJtvlJIqZod+gLKyqlXh6Oa5VTf3sF92rhFyb9eqFouW7tgxvfD3P38DpSvhTTfYfaaZGKfOQaqkm7IX2oPm9DlhZ1DeDtqYcFZQheS8RfZF65bpLt4VzXJlJYCtNZTB+dbVmmhvQ6xmz4hQM0vmx6HJLShJ7rkxmvhVq6NH91L5XuqERMnrfa/WiFBAz1oUqCTUvuDYP2Cno4DK/b6mJTJWJxJcH176vHXO90za7nN7Lo8/QS/Wvy+J4urPlxFASzs6eALbmvZBmdkwz8F7JS0u0hfsL1BLfCQNCti+jJGAYrIQbEUdQYL3HrNkec1LyBfX1H6/iGHzFQr4IXrnnMSfN4enqnLI42kI5mMHK9+ykUx5b5qvhTtAtAIipaxrAJTF6xDutjsoVbdISpGJ4ohGCILMklzzSx0at3Qn6Ln+w36WWSbpvgSXt3Iqd5yDJjrJ/zl0G5dc4tINb49VV3A+V7Bu0gISPrDQCled6fkQ3iRUOyfF5mZvKQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(4326008)(83380400001)(54906003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?TjbVxtzLqxZNS/MSNWTT5fjduI0TtmR5B4Yx3MNKLMIiNlZQx/wFlV6Z83?= =?iso-8859-1?Q?PgzvMb6SS3dZlqTy8UrYuEh44zw91KPmwV9zn2Rqo+uw09rp3WijSC3jjZ?= =?iso-8859-1?Q?uBtMyTs2MQ+/dm0QM+K/+K91vuLP2yNzNxkVNiu6Y9RZwnuqiOORqaVQ88?= =?iso-8859-1?Q?MpJ0f8ahMikD5FIhThq9uCDOebXFAHb8DHLp6oiEx8jhHY0Ht8Bpvl0Ape?= =?iso-8859-1?Q?5i1tNCWRDsbX+mX5M7gfwEkrCyQQ6sXXoKt12o/5qYZ5SNEv2ctMP/p2Od?= =?iso-8859-1?Q?v8sntBB+jrRJkazT3Es3jsYJ56fY9rupKFWvSKSClHf9PiWjd4mjX4kXJk?= =?iso-8859-1?Q?2fPECHxu9nm1PIQEHr4ELP6iLzJwJfMv3GC1wp2sMFzKO8hGiMUCKttWId?= =?iso-8859-1?Q?BByxnE9NoeX06l3YvQ6HRjtxPzq0iJDnaxav4q97xNN5lU8cpVZymExWcp?= =?iso-8859-1?Q?QvjfpJ/dwkWRZyG0i7BRX5v24nR36bHLE63anmvsms2yWGb63lji2HyYB4?= =?iso-8859-1?Q?W6kyLBLhoQ1Cw0UEMzPNAvN43N58B7ntSCcAjU5q6qyw3sDCjRRIygCzD2?= =?iso-8859-1?Q?yK5vkk3IjYrVWbZX5AJmIhESOD4gxji0BHyQOZRsF8AcTLSITdDOJ18jl/?= =?iso-8859-1?Q?VTG6C64eLlzict/mxDPUKwJGEAykwrT9lDNtJhsN9J4UnXMlLW/R+0SaO1?= =?iso-8859-1?Q?NiwmYY6ZvkAXh/wLQVOaou0wqwIvf+TRKkmvVaCHrKQfOHabYOUIkcmeol?= =?iso-8859-1?Q?EEs4IoKK4ZS8QJ1Qnadoyu3HleJXXoPOCMq7ApxxYBuRzpZNjagX2bIs7C?= =?iso-8859-1?Q?Vrtvfgo59AfmKH2vs1ky6p9btOxhdtPqLKKAk4cgQK7mFdmlbPUhjX48pA?= =?iso-8859-1?Q?ozvcffU761QdfOrOvWGfIbWIwuTTqbZblxtyFXTshaBrVr1uTMUw5O0v5c?= =?iso-8859-1?Q?XBFT0J5mN/0CS/y/qcRXQFg1vfdw2bcuK9eSPzq6TjCIRneZOP//SC03IX?= =?iso-8859-1?Q?uq7rPAJkaNJzLIMbklJPb6oJu3BrjgkJFJUg8XATuHnDwvDcpMbEoR+4Bg?= =?iso-8859-1?Q?Ft5dQIggHPdOSGUhF7sydjV5V7LluD3EmIKQHFH3ZDmJPCwET5cq0qOSNF?= =?iso-8859-1?Q?ZVWsJvfbytXRzFsJPN3xw8RUlY4pS9bWrgD8WnZQVephIT6SZulx6w/69t?= =?iso-8859-1?Q?4qXYUVnYB2htQk6z6fl8ZY4J6mZDh0UX8X6zslto/XW3JYMYYf68/Vb6OZ?= =?iso-8859-1?Q?o3fBceN6ojjRlTm5ZiSOFwCGEo64V4j/yYLNZQzFzCH/mks+vZG8D3K/IH?= =?iso-8859-1?Q?/MUBVdeMJk+29XGB9OWyg7WXIUkgDmVrDWKsCg4sASuvUmdF3FhAMQT3ug?= =?iso-8859-1?Q?4qX3GUcJPuydvwPUkpZJMKazypFUFBNbF3qFKYI26jNrkKem2TRpf6eDF/?= =?iso-8859-1?Q?/auB+FLWG/kj9TjpmtsHrca7zkCdN+x4xTqPbvDX7S2jSa8JomiiNN7ttd?= =?iso-8859-1?Q?UIATiRvjtLkuh5j95uwl5eKQ2nL153st4pW2Jg/9qSh2qeOpbWWinm9S4f?= =?iso-8859-1?Q?3E9JiDcqM+CC103SxYkE+d1tvYTzjpgX1NMP5duGqZrLv14qUmvAoyWnIe?= =?iso-8859-1?Q?HkT7foWOHVhf9z9aEQnToRAvcRW0a3mQbhWcOnqLKW+apnqJsHCwLQku1b?= =?iso-8859-1?Q?fWo/HxjkAfizp2bSNd/elUhdrTj7fUAK1G3Jr0NnjWfua3BcHO6YPKkU+U?= =?iso-8859-1?Q?sNdpK9AN/dtmzNGm7kL9Kz4nY=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c86fd87-1051-4555-8660-08d9eb2cdb00 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:13.4188 (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: SWz4WbBiq1w8dOgLA0CkLEWHTc2hMe5VjUbHhGRJk/6+7HKr8dyrMXgh+RKMYbbF+gnvpHfKnW+Z2dSYO7WbzvT1x3y2Qt2vdpKI3vjaKzA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: wz6TY2sipT9sV7lH3pXo29mw_x7eIvka X-Proofpoint-ORIG-GUID: wz6TY2sipT9sV7lH3pXo29mw_x7eIvka X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644343260983100003 Content-Type: text/plain; charset="utf-8" This enumeration sets SCI type for the domain. Currently there is two possible options: either 'none' or 'scmi_smc'. 'none' is the default value and it disables SCI support at all. 'scmi_smc' enables access to the Firmware from the domains using SCMI protocol and SMC as transport. Signed-off-by: Oleksii Moisieiev --- docs/man/xl.cfg.5.pod.in | 20 ++++++++++++++++++++ tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 7 +++++++ tools/include/libxl.h | 5 +++++ tools/libs/light/libxl_types.idl | 6 ++++++ tools/xl/xl_parse.c | 9 +++++++++ 6 files changed, 49 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index ddf82cb3bc..f960e367c4 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1614,8 +1614,28 @@ This feature is a B. =20 =3Dback =20 +=3Ditem B + +B Set ARM_SCI type for the guest. ARM_SCI is System Control Prot= ocol +allows domain to manage various functions that are provided by HW platform. + =3Dover 4 =20 +=3Ditem B + +Don't allow guest to use ARM_SCI if present on the platform. This is the +default value. + +=3Ditem B + +Enables SCMI_SMC support for the guest. SCMI is System Control Management +Inferface - allows domain to manage various functions that are provided by= HW +platform, such as clocks, resets and power-domains. Xen will mediate acces= s to +clocks, power-domains and resets between Domains and ATF. Disabled by defa= ult. +SCP is used as transport. + +=3Dback + =3Ditem B =20 If set, Xen allows to assign a devices even if it is not behind an IOMMU. diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 664933bbb8..6cf7725735 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1091,6 +1091,7 @@ if err :=3D x.DmRestrict.fromC(&xc.dm_restrict);err != =3D nil { return fmt.Errorf("converting field DmRestrict: %v", err) } x.Tee =3D TeeType(xc.tee) +x.ArmSci =3D ArmSciType(xc.arm_sci) =20 if err :=3D x.ForceAssignWithoutIommu.fromC(&xc.force_assign_without_iommu= );err !=3D nil { return fmt.Errorf("converting field ForceAssignWithoutIommu: %v", err) @@ -1439,6 +1440,7 @@ if err :=3D x.DmRestrict.toC(&xc.dm_restrict); err != =3D nil { return fmt.Errorf("converting field DmRestrict: %v", err) } xc.tee =3D C.libxl_tee_type(x.Tee) +xc.arm_sci =3D C.libxl_arm_sci_type(x.ArmSci) xc._type =3D C.libxl_domain_type(x.Type) switch x.Type{ case DomainTypeHvm: diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 2f7a088c3b..3b5c959215 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -443,6 +443,12 @@ TeeTypeNone TeeType =3D 0 TeeTypeOptee TeeType =3D 1 ) =20 +type ArmSciType int +const( +ArmSciTypeNone ArmSciType =3D 0 +ArmSciTypeScmi ArmSciType =3D 1 +) + type RdmReserve struct { Strategy RdmReserveStrategy Policy RdmReservePolicy @@ -512,6 +518,7 @@ NestedHvm Defbool Apic Defbool DmRestrict Defbool Tee TeeType +ArmSci ArmSciType ForceAssignWithoutIommu Defbool Type DomainType TypeUnion DomainBuildInfoTypeUnion diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 2bbbd21f0b..30e5aee119 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -278,6 +278,11 @@ */ #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_TEE 1 =20 +/* + * libxl_domain_build_info has the arch_arm.sci field. + */ +#define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SCI 1 + /* * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing * 'soft reset' for domains and there is 'soft_reset' shutdown reason diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 1080966c33..1878c115c3 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -480,6 +480,11 @@ libxl_tee_type =3D Enumeration("tee_type", [ (1, "optee") ], init_val =3D "LIBXL_TEE_TYPE_NONE") =20 +libxl_arm_sci_type =3D Enumeration("arm_sci_type", [ + (0, "none"), + (1, "scmi_smc") + ], init_val =3D "LIBXL_ARM_SCI_TYPE_NONE") + libxl_rdm_reserve =3D Struct("rdm_reserve", [ ("strategy", libxl_rdm_reserve_strategy), ("policy", libxl_rdm_reserve_policy), @@ -564,6 +569,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ ("apic", libxl_defbool), ("dm_restrict", libxl_defbool), ("tee", libxl_tee_type), + ("arm_sci", libxl_arm_sci_type), ("force_assign_without_iommu", libxl_defbool), ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 67fa96d949..d53c9b1271 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2747,6 +2747,15 @@ skip_usbdev: } } =20 + if (!xlu_cfg_get_string (config, "arm_sci", &buf, 1)) { + e =3D libxl_arm_sci_type_from_string(buf, &b_info->arm_sci); + if (e) { + fprintf(stderr, + "Unknown arm_sci \"%s\" specified\n", buf); + exit(-ERROR_FAIL); + } + } + xlu_cfg_get_defbool(config, "force_assign_without_iommu", &b_info->force_assign_without_iommu, 0); =20 --=20 2.27.0 From nobody Wed May 15 13:33:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1644343261; cv=pass; d=zohomail.com; s=zohoarc; b=aZ2swIUQEkzVsyJD7acYyDoPjERZAIiQRywyPM0cC/85HCIeiBLKT28MEQaa6EM6dOSq55Fyjzi1TSt5pMLtwNSLDP3g61wLlpIf5cAZoyo6O7MOBaeG7Rtw4QC9IDck33D7ggEq56iKo6Iu1hkz2NqJ8vYmV1qOMBkkNBgvLRA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644343261; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jayupWuWbjhOz7yWgZER6E30JTnHsZKWIQYO2oKaWWE=; b=VjaUR0lqpx/kB1MEAPPOp8UtPBXOtKnJ1XnbepYgHbPKPKPR+cUPFCvKnaN5EAzaPz2nTwxbgZk+rLhv74a80RzP1nlSrjY4KobF9UGv5ZaKAkDhDTdszLz+oIrlI8Zu2TJ5UpZoRzbsn68MxOXm3vtTEENiC0McFiEpzaNxxyc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 164434326166953.31515256081377; Tue, 8 Feb 2022 10:01:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.268499.462415 (Exim 4.92) (envelope-from ) id 1nHUmz-0008Aq-5t; Tue, 08 Feb 2022 18:00:29 +0000 Received: by outflank-mailman (output) from mailman id 268499.462415; Tue, 08 Feb 2022 18:00:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHUmy-00089X-Ol; Tue, 08 Feb 2022 18:00:28 +0000 Received: by outflank-mailman (input) for mailman id 268499; Tue, 08 Feb 2022 18:00:26 +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 1nHUmw-00068L-7U for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 18:00:26 +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 fce3a86e-8908-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 19:00:24 +0100 (CET) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 218EgrTD015757; Tue, 8 Feb 2022 18:00:21 GMT Received: from eur02-he1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3e3t5xrs6q-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 18:00:21 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by VE1PR03MB5613.eurprd03.prod.outlook.com (2603:10a6:803:12a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Tue, 8 Feb 2022 18:00:14 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::c1c:f98:9dd:86e0%6]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 18:00:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fce3a86e-8908-11ec-8eb8-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYO9MKfe3IgWmXp7lo+Bl4ljmMGi1ae0L+UWUR0qgoRpJaNT7rSRNjgXUvM+ryHMd0aUQ5tSg8M+jTHvnwuWWIdO2It7fMXrYmRMIp60U2nJlHsiruGdC70p2Z8E2WvYgA6iRhpk+gzdPuZsLvFZZTtF8nUiSn4cE54I5NCgH5VwzrmBCvca65BsMp+SuU5/j6Au3YrRv0JfynDFvxk/eh/WjsJ2dG/QvyLZIjsqG3YORnYoxNxDQUAFYEJ/t4R7Vu2RCqMdFNwBoRkmF9EyGRL/3/bItFEGhWiAL/zyWdbIG358Jp9ZozEeg/NuwdGVlse5suyRG581NEIC/f7t5A== 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=jayupWuWbjhOz7yWgZER6E30JTnHsZKWIQYO2oKaWWE=; b=bH+qApmhRzaaPMNJqomFxCloTOyKpsTwMCjgekox1CZpv83ogBXgTHBDGWtb0Ld1zZDCaTPZ4AbKW6C87DBxvi9bI84IiwzgZ53o5mit3cjQjYrm7LjQCiQ4Ogg1bp8ZqJi4PMgnEYcOErksjNFQ54I0i1vXbUS07dyxD7bfQBqs7kwOVzKLEj3V6qZq6aWjmBhmiA7YeMe8vkBXb4M4C8wleEWSUR5bi+qQMTHpfT1BZv8ek9fxIsBAWmU6gnwyNYEY50fTOJHS/Shg+Gh0tddW9rClAfJdIeCj1yOuDb5vz18xVIhNrHqXbFvuhrc9bCfBQs4UhBFTBxmPDb25pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=jayupWuWbjhOz7yWgZER6E30JTnHsZKWIQYO2oKaWWE=; b=SQ1KDkkWJX3kuq861ElC+WSGwMK7a6K9OsAr9YIq2ojajYWjVRCCD6OTyt4zpGrBGV3pV1Un14Ui5RS6coscRW4zBBjBABw9ddEE/KDqvnt2l/xOOn8/8gpYAELttIHcDzzN03wRGYZ0pGNK6awLhz9BTgYAfRWA1FvUTlyRZBAbKkUOQ87Nf03QPBgipuokh+EmDJ27TKfnmAOLQEgMRsTAM5mp+VyhmGXixwyCJIXhN31Vk+Buke8qCkrNaf/jykHKkubicVgppXgivFKrBDyoZxuZTu5XIm84x3tss9LPewENFhkJT6e7y6/Ki6OQWsgo+fDbcfHAe1pqsOIveA== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Wei Liu , Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Anthony PERARD , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC v2 8/8] xen/arm: add SCI mediator support for DomUs Thread-Topic: [RFC v2 8/8] xen/arm: add SCI mediator support for DomUs Thread-Index: AQHYHRW5DNy0UeL9wEisMLPQvzYWsg== Date: Tue, 8 Feb 2022 18:00:14 +0000 Message-ID: <8aaab52f54841ebcf31a8f5fc6f1f8fd0b778e49.1644341635.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1d8aa3d6-94a8-4c12-78de-08d9eb2cdbd2 x-ms-traffictypediagnostic: VE1PR03MB5613:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:538; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rqxqne92tNVg0gXi1RQ1NO7eQOSv0cZvEyQLrHBW9kvSdYIC9sC5usBbMqoaUOMHYXnIChGrP+Z/YOGYqZSnIJTvlhoqtlp8r5QM+af1SG63r5aiCo1xGMTWOmreJsUj/+a/6RaEw8OCAqfhRCNRv2OQSdhrLux3S0K9365kjWktmT8ZbrVLNTfwnU3XGajHMFUV1BEID+Y2pxTRgl9OAmuGOHuBgJqhAJRqogQ7I2gHAmA3ptmhAD+5CgvGh88GWFno+tE7YlImDxEWah1hV0w0Omj3DaDC00JYTYpkDqn6HhzrvokzfwL2t8zrml7yy2DQXGwM3LwxNGe96NIntdifnsdDCCzJ4BERLjjouamm2idzO42yRcx90SPMETs9zFrhGBtMTQKtgoPyMVpCccYuBHPlJxg9ELJqsRcEGsHLG6K25aHXp9BOWDg5QuRzur+E5N5WA329PEpkWwJSo1ZoUJ3xY/uoC4MpCm+oeQDzbuPG3QzDOK0y3s3gdelU8V5tv7gDlptP39BQ4Rz57oQ+Kghg0j6K3q/z3y/5uQ5XPaEkSXz+HxoQz5yjONOt94jkZ3ajIcPAMn4EXfLVjMoSpX6+Sm3xfZRYlhT5QvpLa0Ha8Ag2wf84dDytbT+2DcdENjeTG5I1LZs7V54DDfN6zwY6N5Nq2kOO7cPtWY5kKUjyRZd2iwl5Paj38QmEVzgFliEhzHMHc9poEKV8/Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38070700005)(71200400001)(6486002)(508600001)(66476007)(64756008)(86362001)(66556008)(316002)(122000001)(6916009)(6506007)(2616005)(5660300002)(6512007)(7416002)(4326008)(83380400001)(54906003)(30864003)(2906002)(26005)(186003)(8676002)(76116006)(38100700002)(66446008)(66946007)(8936002)(36756003)(91956017);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Bb/o0zHOWJ4lAaakLRPPxROrgldRXBN4eTiPjo7EFECHkHlUv7I2bquMf4?= =?iso-8859-1?Q?RHIj+oA3bvv7OVD6Z/eKzuHwTdmaOaLGdT+G8moFqV/zHH5SbSMr3oEoGP?= =?iso-8859-1?Q?a0qoq+kRYbA+mETGE/MScrGaX3V/KPraHR0cetjYVUQv8t/llDXuUs4hGw?= =?iso-8859-1?Q?JQR4J+ybvPDB/ayJkcONjs1sRRerHcxcdHCWoDrdufIAN5gdoqnovhhMFS?= =?iso-8859-1?Q?xiIAJ8NBu5U9p+zV3CDH9WZwSkt8uaoyNALUsgVTJ9kafXiSEoIveQV6EQ?= =?iso-8859-1?Q?5S3h7UvVC9UsUw1hYOtr71nLQbd1Ri1ZoIXiuxZujZvBDnBTy+z8mtrx7g?= =?iso-8859-1?Q?Vtbnqjvj8V2tZ3KWFpH56xuqxvyPqoK7YZQhCAv4uGLhjNWXebO16pEquZ?= =?iso-8859-1?Q?a/zhfOpYY5hFC3IQsQd2sYoYyiQ2XGSSMBtqRqUL4FTQ4XQy5yhRVZcWbV?= =?iso-8859-1?Q?lrGcaCagkE5GK7R+pDC7LuED6OSXde0xpVAfdKParxIgytJsXpTeL1SQgU?= =?iso-8859-1?Q?c67E+MDAPJRol0v2KU2bsH7vt6pjieS/XXVpvOSY2plf+yRi3H1wd983YB?= =?iso-8859-1?Q?IR1uAxAnIv/hN/AnIdIn1BauRERwnQYSuLCJU45+/ZYB2jvnca5XB4m7o4?= =?iso-8859-1?Q?jfRBTwt/98C14/u0tVZp3nH11fnqdCUZCrHWCfohvPD5NJ9JqDIF535T79?= =?iso-8859-1?Q?ycsAdV38Zu2NfmKxTCCWiT7q/EAQU7FeM2QR+QlBebNhdboXObypNi8X7L?= =?iso-8859-1?Q?d/GoLGXpgT5mdYxFjaQWRWW5WpnQgeHDmZWWooBZunk+beXWoXoSgoZ4qg?= =?iso-8859-1?Q?kwj8U4VKIbA45w5HDU67/v0utBaekfV4W5MkJqik8d7xXMpxw/a9WDxGPR?= =?iso-8859-1?Q?fwvt1cM2ETs7GuFIO0A+qyQQ+wdnzSNUtkQpXYY49ji6C9CGxPthTBXb3t?= =?iso-8859-1?Q?TEnu7UpMygcbyuXJWGdu9dJL5NZBXWZF5uXcpIJkrTSmnNyWWLFH0u/hBt?= =?iso-8859-1?Q?xFg2PFIAM0ftVJSpc2kfbv/y3K2jYZMZJRJitn7FDF8GOD2dWsVm0o9ovJ?= =?iso-8859-1?Q?7zUHjcMFbSf2Gc5pl+t+1dShYxUia4Ja84r3LlUljHx7LzAa1E2AiUEKxW?= =?iso-8859-1?Q?yfVtLj1etsCcD2YhVEuecIaRt0+Ao3aGt49APiSOyYCh8K5EIKJ+h8KO8y?= =?iso-8859-1?Q?tbq3TWy15iKGSO/Swt+z7D0U/ON5t5eCJYHDFkFi4X8BgcIhnYYJXgFNud?= =?iso-8859-1?Q?Wq1vnN9mdhdxFAXshIsZ0L7nrlpbiKn+x2iOnf3GgH3QMbdNdvANQtgnKl?= =?iso-8859-1?Q?+2BZMhiTiWNHfOcL1lod4Gcey1TUEt8EE41g2ORe+SQCEhB3ywL9+ml61Y?= =?iso-8859-1?Q?mfh3O5im86xH+J2DdyXgTMebsxlEyiNDuJYu+64iY9jr6CXVRnHoGeb+KF?= =?iso-8859-1?Q?GDdjBJiFSQJkmuxRnnCaWFEtykHY9Cyn2fbXtvih54jJ4wVWHuiELNIDfT?= =?iso-8859-1?Q?Yrw+4Jlik2wwZsEWR+13TZysjbbuiqSu+A5n4hTDqZtZdlyG+65WrpEEvR?= =?iso-8859-1?Q?GNr+71Rvlvi5m5WWXtDlKZydZip+goQB0EnMGm639cGxRoQJJjqzI0Eexc?= =?iso-8859-1?Q?G3yUkVJerzh5Q1m9UXC48/tuOKRq4uKCRMx89J5W95bx/DHy/coIGQ40+l?= =?iso-8859-1?Q?PZMnFGc3MEfInrpdP6FtmKRPkwS1wIyy62IGwJTP+KqhOSTm6SQ3vN7VvH?= =?iso-8859-1?Q?uLFoSlulh/JzWYEgreF8caZ5k=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d8aa3d6-94a8-4c12-78de-08d9eb2cdbd2 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 18:00:14.7791 (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: +r2E2QNZzlRK0MqL9DH03hTokkOFLMJtHCnQo2oVW6lsQyVQyOFTMrOHzsqjPm2whFJIbDef/fL2Md+FQIPYWX4VR8MFAYVVVaFZkR3WVyU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5613 X-Proofpoint-GUID: rMgEuywUpIi_Qn8ShMUDtOToY64rSaIr X-Proofpoint-ORIG-GUID: rMgEuywUpIi_Qn8ShMUDtOToY64rSaIr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_06,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080106 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1644344165357100003 Content-Type: text/plain; charset="utf-8" Integration of the SCMI mediator with xen libs: - add hypercalls to aquire SCI channel and set device permissions for DomUs; - add SCMI_SMC nodes to DomUs device-tree based on partial device-tree; - SCI requests redirection from DomUs to Firmware. Signed-off-by: Oleksii Moisieiev --- tools/include/xenctrl.h | 3 + tools/libs/light/libxl_arm.c | 214 ++++++++++++++++++++++++-- tools/libs/light/libxl_create.c | 44 +++++- tools/libs/light/libxl_internal.h | 3 + xen/arch/arm/domctl.c | 7 + xen/include/public/device_tree_defs.h | 1 + 6 files changed, 260 insertions(+), 12 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 07b96e6671..cdd14f465f 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1238,6 +1238,9 @@ int xc_domain_getvnuma(xc_interface *xch, int xc_domain_soft_reset(xc_interface *xch, uint32_t domid); =20 +int xc_domain_add_sci_device(xc_interface *xch, + uint32_t domid, char *path); + #if defined(__i386__) || defined(__x86_64__) /* * PC BIOS standard E820 types and structure. diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index c5090e2b32..106ff33c84 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -7,6 +7,12 @@ #include #include #include +#include + +#define SCMI_NODE_PATH "/firmware/scmi" +#define SCMI_NODE_COMPATIBLE "arm,scmi-smc" +#define SCMI_SHMEM_COMPATIBLE "arm,scmi-shmem" +#define HYPFS_DEVICETREE_PATH "/devicetree" =20 static const char *gicv_to_string(libxl_gic_version gic_version) { @@ -101,6 +107,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } =20 + switch (d_config->b_info.arm_sci) { + case LIBXL_ARM_SCI_TYPE_NONE: + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_NONE; + break; + case LIBXL_ARM_SCI_TYPE_SCMI_SMC: + config->arch.arm_sci_type =3D XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC; + break; + default: + LOG(ERROR, "Unknown ARM_SCI type %d", + d_config->b_info.arm_sci); + return ERROR_FAIL; + } + if (libxl_defbool_val(d_config->b_info.force_assign_without_iommu)) config->iommu_opts |=3D XEN_DOMCTL_IOMMU_force_iommu; =20 @@ -125,6 +144,7 @@ int libxl__arch_domain_save_config(libxl__gc *gc, } =20 state->clock_frequency =3D config->arch.clock_frequency; + state->arm_sci_agent_paddr =3D config->arch.arm_sci_agent_paddr; =20 return 0; } @@ -505,9 +525,6 @@ static int make_optee_node(libxl__gc *gc, void *fdt) int res; LOG(DEBUG, "Creating OP-TEE node in dtb"); =20 - res =3D fdt_begin_node(fdt, "firmware"); - if (res) return res; - res =3D fdt_begin_node(fdt, "optee"); if (res) return res; =20 @@ -520,9 +537,6 @@ static int make_optee_node(libxl__gc *gc, void *fdt) res =3D fdt_end_node(fdt); if (res) return res; =20 - res =3D fdt_end_node(fdt); - if (res) return res; - return 0; } =20 @@ -905,10 +919,9 @@ static int copy_node(libxl__gc *gc, void *fdt, void *p= fdt, return 0; } =20 -static int copy_node_by_path(libxl__gc *gc, const char *path, - void *fdt, void *pfdt) +static int get_path_nodeoff(const char *path, void *pfdt) { - int nodeoff, r; + int nodeoff; const char *name =3D strrchr(path, '/'); =20 if (!name) @@ -928,12 +941,189 @@ static int copy_node_by_path(libxl__gc *gc, const ch= ar *path, if (strcmp(fdt_get_name(pfdt, nodeoff, NULL), name)) return -FDT_ERR_NOTFOUND; =20 + return nodeoff; +} + +static int copy_node_by_path(libxl__gc *gc, const char *path, + void *fdt, void *pfdt) +{ + int nodeoff, r; + + nodeoff =3D get_path_nodeoff(path, pfdt); + if (nodeoff < 0) + return nodeoff; + r =3D copy_node(gc, fdt, pfdt, nodeoff, 0); if (r) return r; =20 return 0; } =20 +static int make_scmi_shmem_node(libxl__gc *gc, void *fdt, void *pfdt) +{ + int res; + char buf[64]; + +#ifdef CONFIG_ARM_32 + snprintf(buf, sizeof(buf), "scp-shmem@%lx", + GUEST_SCI_SHMEM_BASE); +#else + snprintf(buf, sizeof(buf), "scp-shmem@%llx", + GUEST_SCI_SHMEM_BASE); +#endif + + res =3D fdt_begin_node(fdt, buf); + if (res) return res; + + res =3D fdt_property_compat(gc, fdt, 1, SCMI_SHMEM_COMPATIBLE); + if (res) return res; + + res =3D fdt_property_regs(gc, fdt, GUEST_ROOT_ADDRESS_CELLS, + GUEST_ROOT_SIZE_CELLS, 1, + GUEST_SCI_SHMEM_BASE, GUEST_SCI_SHMEM_SIZE); + if (res) return res; + + res =3D fdt_property_cell(fdt, "phandle", GUEST_PHANDLE_SCMI); + if (res) return res; + + res =3D fdt_end_node(fdt); + if (res) return res; + + return 0; +} + +static int create_hypfs_property(struct xenhypfs_handle *hdl, void *fdt, + char *path, char *name) +{ + char *p, *result; + int ret =3D 0; + struct xenhypfs_dirent *ent; + + if (strcmp(name, "shmem") =3D=3D 0) + return fdt_property_cell(fdt, name, GUEST_PHANDLE_SCMI); + + ret =3D asprintf(&p, "%s%s", HYPFS_DEVICETREE_PATH, path); + result =3D xenhypfs_read_raw(hdl, p, &ent); + free(p); + if (!result) + return -EINVAL; + + ret =3D fdt_property(fdt, name, result, ent->size); + free(result); + free(ent); + + return ret; +} +static int create_hypfs_subnode(struct xenhypfs_handle *hdl, void *fdt, + const char *path, const char *name) +{ + struct xenhypfs_dirent *ent; + unsigned int n, i; + char *p, *p_sub; + int res =3D 0; + + res =3D asprintf(&p, "%s%s", HYPFS_DEVICETREE_PATH, path); + if (res < 0) + return -ENOMEM; + + ent =3D xenhypfs_readdir(hdl, p, &n); + free(p); + if (!ent) + return -EINVAL; + + res =3D fdt_begin_node(fdt, name); + if (res) return res; + + for (i =3D 0; i < n; i++) { + res =3D asprintf(&p_sub,"%s/%s", path, ent[i].name); + if (res < 0) + break; + + if (ent[i].type =3D=3D xenhypfs_type_dir) + res =3D create_hypfs_subnode(hdl, fdt, p_sub, ent[i].name); + else + res =3D create_hypfs_property(hdl, fdt, p_sub, ent[i].name); + + free(p_sub); + if (res) + break; + } + + res =3D fdt_end_node(fdt); + free(ent); + return res; +} + +static int create_scmi_from_hypfs(void *fdt, const char *path) +{ + struct xenhypfs_handle *hdl; + int res; + hdl =3D xenhypfs_open(NULL, 0); + if (!hdl) + return -EINVAL; + + res =3D create_hypfs_subnode(hdl, fdt, path, "scmi"); + xenhypfs_close(hdl); + + return res; +} + +static int set_shmem_phandle(void *fdt, const char *scmi_node_copmat) +{ + uint32_t val; + int nodeoff =3D fdt_node_offset_by_compatible(fdt, 0, scmi_node_copmat= ); + if (nodeoff < 0) + return -EINVAL; + + val =3D cpu_to_fdt32(GUEST_PHANDLE_SCMI); + return fdt_setprop_inplace(fdt, nodeoff, "shmem", &val, sizeof(val)); +} + +static int make_scmi_node(libxl__gc *gc, void *fdt, void *pfdt) +{ + int res =3D 0; + int nodeoff =3D + fdt_node_offset_by_compatible(pfdt, 0, SCMI_NODE_COMPATIBLE); + if (nodeoff > 0) { + res =3D copy_node(gc, fdt, pfdt, nodeoff, 0); + if (res) return res; + + res =3D set_shmem_phandle(fdt, SCMI_NODE_COMPATIBLE); + if (res) return res; + } + else + res =3D create_scmi_from_hypfs(fdt, SCMI_NODE_PATH); + + return res; +} + +static int make_firmware_node(libxl__gc *gc, void *fdt, void *pfdt, int te= e, + int sci) +{ + int res; + + if ((tee =3D=3D LIBXL_TEE_TYPE_NONE) && (sci =3D=3D LIBXL_ARM_SCI_TYPE= _NONE)) + return 0; + + res =3D fdt_begin_node(fdt, "firmware"); + if (res) return res; + + if (tee =3D=3D LIBXL_TEE_TYPE_OPTEE) { + res =3D make_optee_node(gc, fdt); + if (res) return res; + } + + if (sci =3D=3D LIBXL_ARM_SCI_TYPE_SCMI_SMC) { + res =3D make_scmi_node(gc, fdt, pfdt); + if (res) return res; + } + + res =3D fdt_end_node(fdt); + if (res) return res; + + return 0; +} + /* * The partial device tree is not copied entirely. Only the relevant bits = are * copied to the guest device tree: @@ -1091,8 +1281,10 @@ next_resize: if (info->arch_arm.vuart =3D=3D LIBXL_VUART_TYPE_SBSA_UART) FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); =20 - if (info->tee =3D=3D LIBXL_TEE_TYPE_OPTEE) - FDT( make_optee_node(gc, fdt) ); + if (info->arm_sci =3D=3D LIBXL_ARM_SCI_TYPE_SCMI_SMC) + FDT( make_scmi_shmem_node(gc, fdt, pfdt) ); + + FDT( make_firmware_node(gc, fdt, pfdt, info->tee, info->arm_sci) ); =20 if (d_config->num_pcidevs) FDT( make_vpci_node(gc, fdt, ainfo, dom) ); diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index dcd09d32ba..f1f1e66275 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -596,6 +596,38 @@ out: return ret; } =20 +static int map_sci_page(libxl__gc *gc, uint32_t domid, uint64_t paddr, + uint64_t guest_addr) +{ + int ret; + uint64_t _paddr_pfn =3D paddr >> XC_PAGE_SHIFT; + uint64_t _guest_pfn =3D guest_addr >> XC_PAGE_SHIFT; + + assert(paddr && guest_addr); + LOG(DEBUG, "iomem %"PRIx64, _paddr_pfn); + + ret =3D xc_domain_iomem_permission(CTX->xch, domid, _paddr_pfn, 1, 1); + if (ret < 0) { + LOG(ERROR, + "failed give domain access to iomem page %"PRIx64, + _paddr_pfn); + return ret; + } + + ret =3D xc_domain_memory_mapping(CTX->xch, domid, + _guest_pfn, _paddr_pfn, + 1, 1); + if (ret < 0) { + LOG(ERROR, + "failed to map to domain iomem page %"PRIx64 + " to guest address %"PRIx64, + _paddr_pfn, _guest_pfn); + return ret; + } + + return 0; +} + int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, libxl__domain_build_state *state, uint32_t *domid, bool soft_reset) @@ -762,6 +794,16 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_con= fig *d_config, goto out; } =20 + if (d_config->b_info.arm_sci =3D=3D LIBXL_ARM_SCI_TYPE_SCMI_SMC) { + ret =3D map_sci_page(gc, *domid, state->arm_sci_agent_paddr, + GUEST_SCI_SHMEM_BASE); + if (ret < 0) { + LOGED(ERROR, *domid, "map scmi fail"); + rc =3D ERROR_FAIL; + goto out; + } + } + dom_path =3D libxl__xs_get_dompath(gc, *domid); if (!dom_path) { rc =3D ERROR_FAIL; @@ -1825,7 +1867,7 @@ static void libxl__add_dtdevs(libxl__egc *egc, libxl_= _ao *ao, uint32_t domid, LOGD(DEBUG, domid, "Assign device \"%s\" to domain", dtdev->path); rc =3D xc_assign_dt_device(CTX->xch, domid, dtdev->path); if (rc < 0) { - LOGD(ERROR, domid, "xc_assign_dtdevice failed: %d", rc); + LOGD(ERROR, domid, "xc_assign_dt_device failed: %d", rc); goto out; } } diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 0b4671318c..79f38b60d4 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -1407,6 +1407,9 @@ typedef struct { /* Whether this domain is being migrated/restored, or booting fresh. = Only * applicable to the primary domain, not support domains (e.g. stub QE= MU). */ bool restore; + + /* arm_sci channel paddr to be set to device-tree node */ + uint64_t arm_sci_agent_paddr; } libxl__domain_build_state; =20 _hidden void libxl__domain_build_state_init(libxl__domain_build_state *s); diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index 6245af6d0b..23c44f3a13 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -4,6 +4,7 @@ * Copyright (c) 2012, Citrix Systems */ =20 +#include #include #include #include @@ -182,7 +183,13 @@ long arch_do_domctl(struct xen_domctl *domctl, struct = domain *d, rc =3D subarch_do_domctl(domctl, d, u_domctl); =20 if ( rc =3D=3D -ENOSYS ) + { rc =3D iommu_do_domctl(domctl, d, u_domctl); + if ( (rc) && (rc !=3D -ENOSYS) ) + return rc; + + rc =3D sci_do_domctl(domctl, d, u_domctl); + } =20 return rc; } diff --git a/xen/include/public/device_tree_defs.h b/xen/include/public/dev= ice_tree_defs.h index 209d43de3f..f57684547b 100644 --- a/xen/include/public/device_tree_defs.h +++ b/xen/include/public/device_tree_defs.h @@ -7,6 +7,7 @@ * onwards. Reserve a high value for the GIC phandle. */ #define GUEST_PHANDLE_GIC (65000) +#define GUEST_PHANDLE_SCMI (67000) =20 #define GUEST_ROOT_ADDRESS_CELLS 2 #define GUEST_ROOT_SIZE_CELLS 2 --=20 2.27.0