From patchwork Tue Dec 14 09:34:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 12675723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E0DBC4332F for ; Tue, 14 Dec 2021 09:34:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.246486.425103 (Exim 4.92) (envelope-from ) id 1mx4Co-0007hE-8t; Tue, 14 Dec 2021 09:34:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 246486.425103; Tue, 14 Dec 2021 09:34:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Co-0007gx-2K; Tue, 14 Dec 2021 09:34:42 +0000 Received: by outflank-mailman (input) for mailman id 246486; Tue, 14 Dec 2021 09:34:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Cm-0007DW-12 for xen-devel@lists.xenproject.org; Tue, 14 Dec 2021 09:34:40 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0dcb6d22-5cc1-11ec-9e60-abaf8a552007; Tue, 14 Dec 2021 10:34:38 +0100 (CET) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BE8mV6p004153; Tue, 14 Dec 2021 09:34:28 GMT Received: from eur03-am5-obe.outbound.protection.outlook.com (mail-am5eur03lp2053.outbound.protection.outlook.com [104.47.8.53]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3cxr338745-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 09:34:28 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PA4PR03MB6974.eurprd03.prod.outlook.com (2603:10a6:102:e1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.16; Tue, 14 Dec 2021 09:34:23 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6%9]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 09:34:23 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0dcb6d22-5cc1-11ec-9e60-abaf8a552007 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=enrWauorJnK5uwQhrawQwKjBFNAwCBs6TxAishYgWeaMlnWEBK5B88W6GIVukomqyWhA6PGuhEpQ9xRf+25k5UUTfZYGCBTaXIgWyIY+3r6q5smLixy1ngc0uUyXpAeWelNZTEuH0wfG14UAY0rGGckA/SiewfEac5dAt+tFklHb3Hq8MaymFMPZl4Yy67dHFeOEIFxUfW95BB+Ly9WDj00hYHzpDOg0CtBJni8AYWQZFUL18XxuZ0lCzNA323+o0x3Tspd75TU+btS5gOpF/LZkG5TbmsxaHYQZzlMusc9Su/8j2XNAwTlj0oBGEPRoDVrjfRgERjcbXRFmtBuAUw== 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=XcQmMVoAC0qvNEyr6vX6HHS2XVbpv968VA/fx82VqSA=; b=A+GM2DkHlK4tC1QvsieeSwkile4+UiRqcuyqssKAbgiyPYFwPl/xU80pPbWRHSSir3RjcIxql9uYlGcPNzcL8GfF7oCLAT3cA01k7vO5eHbQMlAf1yyjhqaXaJ109sz2tHGVoWAtqphWaM1Xcwnsw9wlnXbb9hhFOTKWm8CMnZluqJcPZWHNGZX3xjqObUqTFVF5miB9+9GlxV8mbvtSNJYiTjJIZDMwnwMJAXdyBMpDg7sIALxipC1rfy2CLLdx0nnSMEua4TgoWA1fZpQ6apc2IiaLRWFkicVHLNpFjzPiGP38V1QCGNU9Grkl3eP/6SDza+g+EQ15cUqd2yXufA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XcQmMVoAC0qvNEyr6vX6HHS2XVbpv968VA/fx82VqSA=; b=SXF9/50mobbK90OgrrmPFBK7zR2GeLLKcdbyfk62yxkgiF55c39Lf1myt+6X9j9IewHBcUtt34GDA3DOqjak9jihlRPLFzZFmSfmCC9rkh9DvMq0Zn1s5cN0ki+Mc4HMX2d2nJ3OEX5Z3H0HwVbppD44OJcTqlI0MQRzKhhfk/bS6hqNrJTun6kVcDA3+XiTQBRktv7jdpaqzIKXUXBJBIy1SNM8drqmeqCHMNGpgM1DtLl9BhtB7sQnY3wctEbekozG6bK35UB9d/mNYW4eTs8syEZ5k5BLQIQAiNdPYzKhxAEcBntkpLLO9uazb557KQRWhhBdSUFDijcWMAuyFQ== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC v1 1/5] xen/arm: add support for Renesas R-Car Gen3 platform Thread-Topic: [RFC v1 1/5] xen/arm: add support for Renesas R-Car Gen3 platform Thread-Index: AQHX8M3HLq8qFfw2eU2jxqbriRiMpQ== Date: Tue, 14 Dec 2021 09:34:23 +0000 Message-ID: <7ac8512b5479cf192b4aa399fa2501d0bccaaf48.1639472078.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: 4fc9096e-b8d8-4d87-db44-08d9bee4e9c1 x-ms-traffictypediagnostic: PA4PR03MB6974:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr 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: zJ6DATxATVzBRUU688EmLQpPBx4j3peZbO3HZcXd1u8PhHywKb1h4zcM+OdF64lEwHsZQ3mCZ+dQHUXV3/CMKf1OJtLatyRBefAurWv3uLxP2gVyY6ofqbPCfZ7UfvDDZld2rs8vfUPkSQBXSbXok3hPHxjY5NRu5seC5EeiZHW3Q1GpPsK9Qacb4w3iGcGBRSqbTu5PA+VtWR2IRXv/XAQAIS79j5TRPjaB2WKdRUnt00XHDLvVOBUFMyPCcz2elZEQ6ITDooV9PVXFxP6YbjtGyMUsMT2ZN1HRoGFSxgSdnFRxyU5cntH14GhERfCpUHzWXaNt6cAxL9sj19+DqAUDuEmdaD7qXlhx9IyxDK5ZGE/4Rdv1Kl8GuivpsxzFsKMFAJt+xLtkjo5LSEp4mZhd8F9zolqg1TtyF+B7/+zWaAXcvh9i43uRPsaEdjSG561a9gKxIxhDdGwYeIy/c03GvBefbF8A55F2L2yBAosDdSzs/O/eYhub6vPyI7CmOVSHUopAVMPP5ULZIbej3UHbfvmIaP1m7d1MK0Z2e6fbDMuNFLdoucqx0hTk9rONd7fs/nw8C93YZOBhPB6jvbOvD8vo0zMsu+hpS754YBmysUjIUkIZz/40TFSP2U3vSN8ong8g8vjbqEfN78iPGj7UVPsFvqsp7QXO3uMmEl4NIiPxJl3gAOVm9QT3nD1Th9orssyAuir4pUZ1jO+KpN1djglmN8/+xZmRiduL3FA= 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:(4636009)(366004)(8936002)(66556008)(36756003)(66476007)(316002)(38070700005)(64756008)(54906003)(122000001)(38100700002)(2906002)(91956017)(5660300002)(26005)(6512007)(186003)(4326008)(2616005)(71200400001)(8676002)(66946007)(6486002)(6506007)(86362001)(76116006)(6916009)(508600001)(66446008)(2004002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?sWxL27xWjsqJnZALrm+e6Up?= =?iso-8859-1?q?CnlJ0thLJAe11Qvz3mBjR96mFq4MjB6icJbbuHxkbH2f5v1+5zdDnEYSDs6Q?= =?iso-8859-1?q?jg+1znJ6UyYoTXSEw6XDxuMwyXJlPDAGC4LM29A01vjed92eQXYwloyQkw2R?= =?iso-8859-1?q?TtzDuzKnVpffcnscQtRrziruMZPM05LB9PMDiE0hdh40JkuRTbvLdJ3ckiD0?= =?iso-8859-1?q?KT7FR0Slb2r6D9x6S5o08krEDDAsXKwVR5XLbTtwlCZVaO0OjJ8iblkJX0xy?= =?iso-8859-1?q?yoSwQKElzyQdfR3RfXvPQkGlKwW2YJtNCXOWwxXbOxDVVXsVIY6y/J4OoeND?= =?iso-8859-1?q?L3PAmHsiw18Du0pfG5pcyOPMWQZ2n12VrBlsj/JaoOizN4kUwRIAFA+ASZao?= =?iso-8859-1?q?emZEc/C+fwxSMChAqfPZwAdEWcAfOfPbeCxVs4s0Ib38Q3qqghKxkAIdJwnr?= =?iso-8859-1?q?C8sWl9IdszeWb3DAxGloklRG2FNz/oCNiB9BmwKkfKXymeZFgZAFHcBELymS?= =?iso-8859-1?q?7bxA/i2WTYlQsX+8tWEkLL8xJgYow+aMKqd8NU9+yBd06Dau1l3i7Sn+KdN1?= =?iso-8859-1?q?xsLQwhAho6OWNUkPaC+snbz7S2/TVMnMY4BW3BqkWEzJaPvRw9c9KVAOisWq?= =?iso-8859-1?q?iWVFyAbNOm1BXdghqQ0gkz0Z6qjCJaNnSwA6wrYtFwDOLc/g8mkaCCw4vskR?= =?iso-8859-1?q?qfLnNUpG5uefOX2AjPVtTyC7Kgo9VfSenlseEAhn+xhRLfS0oqrJFFZ1tyzw?= =?iso-8859-1?q?mR56H/8o4Xwdjq+4lJmyJQ/9l0UyFoFc/fLZBy6T+Y+jc4dt0U6aL7Uch11z?= =?iso-8859-1?q?s/uKkWn0DcRG5psDyaA7WTc1S0EormlhSFkw1R+vQTiwJNmVoW52JaW2544V?= =?iso-8859-1?q?omDJiN9fB0fV3AwwasbiiXkIzyimHyalGddYSiGIcPJEi5+ViQXHkIoh91Fs?= =?iso-8859-1?q?vqe5cQU/8+BVgtK2FRkES8tL/NKXxv+FLEQKVT4+avlYKXFkN+JAbHnGkmTM?= =?iso-8859-1?q?YbbEgA0f/cEra+i1GH9G5zDu2u/NBZXxM20qvJ5TwkC8T5RSQ8Bcq4GdFcD4?= =?iso-8859-1?q?WFsCR6QmnybyFZo2hwbJOTMpGRDRc8tkosYsPiagFbcGWnZHVYV8/sIW8hHE?= =?iso-8859-1?q?Fsvm/TYRCuW3H5aDbbBJ2H1nHr4HmcCBK5ARUD2Ogh3LvBEfpX5+GsfZfhQI?= =?iso-8859-1?q?NgdbZrSzk68yH6OdJVLjFZsbOuWvoRp+6q37WwwPsX9ee3GuZS+bJ2U+ix7m?= =?iso-8859-1?q?2bKjpkyVAiQsHjonL+Cv/YYG+J7bbKY2wqH+V5wwmPBabqh2WqyNxrpcvqQg?= =?iso-8859-1?q?dW7vWvK6Qs6EhP3d7yQ6Z03jkSaID1rUYU1yDaNiof2SakqqgO2IMg5yD+M4?= =?iso-8859-1?q?khqSTWdOOSxp+ELnJkB18zYele2W3AqUvqjnJSWMNuc6QaEIX2pWWAK8kx8b?= =?iso-8859-1?q?4+rcSqHKmba9b8TObFNiUjXIRDGAr4BcXTegNqr8UkaIxfJ9WaaueHHaasa9?= =?iso-8859-1?q?TklNQNbFTk2Ka0O5Eu8rwqmr+Omj5+bMMN35zDLsosO0bik7oHAbRDDMiwEA?= =?iso-8859-1?q?nKm0XSqkHI20ytaVMrAXyO4GnzHkZvC6cVR6JFvctprFlm85RFwqmjdoTUSp?= =?iso-8859-1?q?9BCA8xuRlmkQtnUTLE7IIx1W6y516HSmAP6bU4ppyk6KVW9/cckVouW4Q9N1?= =?iso-8859-1?q?7FnI0DBy7JvNluOvCSpqr1cDdqVWWoEk9BTiVSUBHbdzOOerBmRE1GyCUwa4?= =?iso-8859-1?q?RwOw=3D?= 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: 4fc9096e-b8d8-4d87-db44-08d9bee4e9c1 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2021 09:34:23.2315 (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: YshgjBnYaHk/DTSfe6ga5fXofPo0uF1HfaHx1e3gNBtZcHiWRbsLbfp6zvv5pTe7lhxjWPk8QQt3ZJ3cXzgi5e2vtwc7IyTQ8GSbkSLc/mA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB6974 X-Proofpoint-ORIG-GUID: ONwttEhYqV61lRlxgB1qmhuOWAZqu6it X-Proofpoint-GUID: ONwttEhYqV61lRlxgB1qmhuOWAZqu6it X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-14_05,2021-12-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=945 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140054 Implementation includes platform-specific smc handler for rcar3 platform. Signed-off-by: Oleksii Moisieiev Reviewed-by: Oleksandr Andrushchenko --- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/rcar3.c | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 xen/arch/arm/platforms/rcar3.c diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makefile index 8632f4115f..b64c25de6c 100644 --- a/xen/arch/arm/platforms/Makefile +++ b/xen/arch/arm/platforms/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_ALL32_PLAT) += exynos5.o obj-$(CONFIG_ALL32_PLAT) += midway.o obj-$(CONFIG_ALL32_PLAT) += omap5.o obj-$(CONFIG_ALL32_PLAT) += rcar2.o +obj-$(CONFIG_RCAR3) += rcar3.o obj-$(CONFIG_ALL64_PLAT) += seattle.o obj-$(CONFIG_ALL_PLAT) += sunxi.o obj-$(CONFIG_ALL64_PLAT) += thunderx.o diff --git a/xen/arch/arm/platforms/rcar3.c b/xen/arch/arm/platforms/rcar3.c new file mode 100644 index 0000000000..d740145c71 --- /dev/null +++ b/xen/arch/arm/platforms/rcar3.c @@ -0,0 +1,46 @@ +/* + * xen/arch/arm/platforms/rcar3.c + * + * Renesas R-Car Gen3 specific settings + * + * 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 + +static bool rcar3_smc(struct cpu_user_regs *regs) +{ + return false; +} + +static const char *const rcar3_dt_compat[] __initconst = +{ + "renesas,r8a7795", + "renesas,r8a7796", + NULL +}; + +PLATFORM_START(rcar3, "Renesas R-Car Gen3") + .compatible = rcar3_dt_compat, + .smc = rcar3_smc +PLATFORM_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Tue Dec 14 09:34:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 12675727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 623A6C433FE for ; Tue, 14 Dec 2021 09:35:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.246488.425130 (Exim 4.92) (envelope-from ) id 1mx4Cr-0008VN-BL; Tue, 14 Dec 2021 09:34:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 246488.425130; Tue, 14 Dec 2021 09:34:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Cr-0008VC-6s; Tue, 14 Dec 2021 09:34:45 +0000 Received: by outflank-mailman (input) for mailman id 246488; Tue, 14 Dec 2021 09:34:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Cp-0007DW-9a for xen-devel@lists.xenproject.org; Tue, 14 Dec 2021 09:34:43 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 100e8040-5cc1-11ec-9e60-abaf8a552007; Tue, 14 Dec 2021 10:34:41 +0100 (CET) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BE8mM0e003673; Tue, 14 Dec 2021 09:34:31 GMT Received: from eur05-am6-obe.outbound.protection.outlook.com (mail-am6eur05lp2109.outbound.protection.outlook.com [104.47.18.109]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3cxr33874b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 09:34:31 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PR2PR03MB5162.eurprd03.prod.outlook.com (2603:10a6:101:26::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.16; Tue, 14 Dec 2021 09:34:25 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6%9]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 09:34:25 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 100e8040-5cc1-11ec-9e60-abaf8a552007 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UwMCwwQXqjdWHPoSIBNlXW/2kkQyifJHYa+QPpeSwcRB7t1lx1HlqFsJvsgv9vEakc7Pn2D1k6AMcs7G4T7tQBREewIztTHdaTCXm1yJIQa3xD5qs84q8Dy8hq1e7S27+LevN4pJeX0K7UeJz3bqSiq4fOiRn1UMqKO9RoaCd+gmTSLbf5kUCr2mLU7qzWGAaFOepjw3141inXlNv+BwSREZ7G3PdKv2b6cwMdqdf9dwa/VGMENLgUlcz0nANTlvrb8bRp6OyzL/gQo2cX69Bgt5g+GDnnn/oTaY4w7qBNCJ8C7/1bqcgiNY+MM756/Wf99Zami+PpXE1RGzJitFKw== 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=5HKrYB6SvkH+0z8vtwa49lxvxU4I58QQAwDDiPC1Yg8=; b=exkoGv/nni6YNhrwNCGwJa/o3/hHlAJYN99pZwxec5yZFjuKnQUqi8g4ZL95U//u2DlPJLzL/ePdBw702dvNDGB72jUrE4ne6x3vNgZEyxaaedYPvNTRCHxP8PP1v+y3XNUWbCzBMNaHStRjvWwSlt7QkjlCcSgurnMlFts/D1kzAsTlRPrRIJYtD31Zs7xIaag7ppbZYXfhHGdkitzVfN/5AYM6wEc15ZOEtXJl+dYjD/YXfHS8sQO55BMFSBx3q6VirlO4D2QqB3L2KubVFRiOtKKfXfksd246xhSngqncjEcryKLCNyVuXcE0XecbeVxSZfRpn8W4qLIDhJv+hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5HKrYB6SvkH+0z8vtwa49lxvxU4I58QQAwDDiPC1Yg8=; b=Ty4slgKMwrGKaBsjf+B2udHjXAv2RU8B5k6EkwDLHamKtqSEODDL5b3bUoRWtVngybn/pmeNvTWxqnUOyZKJffFkbrMPEjAa2GHZ6NfdQBiCF9Nk6CN27lE2vyPOyyrneR4e2x0T51wpOxObEu3j/xP4eyUPTsIGBqCTzyFvCFchGnkIKoobPOOT0GqaxoZ0OzBHDBLcQYnhh4x+7KYtudMvMxtTe1ZuWRlgXbV9EWJixgPCAncOuI+GBPX0F5l2f5iIN19HBm0gG3KeKLD6vGqzMm5QcguNXL2hr4KEomNF74by+Gd6HLrdFIgiC7Nd0hLK1BrEF682VnRApcdFOA== 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 v1 2/5] xen/arm: add generic SCI mediator framework Thread-Topic: [RFC v1 2/5] xen/arm: add generic SCI mediator framework Thread-Index: AQHX8M3IB9WR9OXgbE2xll7qsLGWCw== Date: Tue, 14 Dec 2021 09:34:24 +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: e8ab3c2b-0600-422c-935b-08d9bee4ead6 x-ms-traffictypediagnostic: PR2PR03MB5162:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Lr+EizdDW3+1EkhjMTkYs51YyfAHaFeV8ARQ6c+fXlL+W5JJQhTblV2bw7AnzpfyUfx41UUIxf6GErurKQLo9Jzu/NPGbJgf6r2sbmkytup6yZgeAkJ0O7Q3Gc8XsrWMDsXmP+PBTjaR9FPeS+RHbCRv6B5BJUPgxVoVPYwyI4mQ5wYK1MIGQ72tdvuWbLU1WbdAMEOXKyNJ5zgHanrralo3rxTSlxEMREUdSibc47aQzYdXc9kqcfAmBYEsAY8gmsnXjvbz3f4nDltil/oWnaDu6njSn5Zsr6PwnuyoeUEuteAPDE8nn7kskUz4I+UOv39croeIbcyJdG1UUEHA4+Nl0A/lcXIxpWbnufaaPkpxSLhQ8Sf7q2YCqXLF6aVcUtMRZnU/zWXZeT9HsVcXdm4sKIkE0sPfYZl8fkInpD4+7wddZxu9n62vky5PTlSrkktflv/2KI9dv6fXWu5CQxBsriGqi66e2e6dldRVLFPXr0PclJLkJLVR1M/4xAV1NuwgReDmqa3O30nsyJ1lGy3qNJpYdEOVaDbwIWzOxQAbw9GF13mZWTGcVwX/OF52pyNjD8VMspnJU00gxR6MM5db3TuGUjHIo/7Jzr/fB/09btyxbBAugnSYKifrhxu5Xyf305BcYpd3y+UXmEin7SrcUnSUd6U5Q6Gece7+oIlqLEdk6hbYxZcphNQbZXWxjYzUwfuAU5vMNfqVO72SOgrstYvOW8sy+R8V8rv0CGZiCgmvoXbQzFLB5s/I9pTpLJI6/gsaWOqQC2xZYrE3Yw== 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:(4636009)(366004)(508600001)(30864003)(5660300002)(38070700005)(38100700002)(8676002)(4326008)(316002)(122000001)(2616005)(36756003)(54906003)(6512007)(186003)(26005)(66476007)(66556008)(83380400001)(64756008)(66446008)(2906002)(6486002)(71200400001)(76116006)(6506007)(86362001)(8936002)(91956017)(66946007)(6916009)(41533002)(21314003)(2004002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?PF+a1wDPNITxYzO+CVWLhv6?= =?iso-8859-1?q?cupeYFD4x4az5b/Fw7baZ2ZiWdNurw3J+EdlrAyyuJXWs6Y3VcNxhNaqa70W?= =?iso-8859-1?q?J3sEUT60ejR8ifTplaf7Wjfz6AhnTQ/xkcCdt1NsnS1SG7EFASg6sPI5rnxU?= =?iso-8859-1?q?v/F8P2KoD4+QaosXvxiuias0h47hXraek90V8P/g8xk9xb6nJyIU7JfB9sTd?= =?iso-8859-1?q?6FXMDv0sH0Xb/DfNzqV1ctI6VKl4U+9yo94sfG2Z7CzjldJn8EdUxQbqv4tw?= =?iso-8859-1?q?+dfztT298LTsGsFoGjnqLvMk2T6okTp0Jj/VsE1VayD/jQNr7MJ+NIJ1stPO?= =?iso-8859-1?q?IPUf4qedLwSX0JWJdxlbzwiTtlxBlM0CFinxlqx91ZLoNlwNXg3l2GmYcOcj?= =?iso-8859-1?q?Y/kdxTKeRdEy8f6vqSwQWjTUYVVTyr8KDa6rWggn5PmL2r5mCRmPzIwfGLpP?= =?iso-8859-1?q?M7oPCmfLfe/0H2icE/rz2UJUkuX9SIZ98jnVf90yZc6WO8CV9BSK0ZXhk+i4?= =?iso-8859-1?q?zLfl7HG8sUALPQLNgRqStrvVwTTjxEjoZO3m8aj55jZ4/5wxz5rG+OqT6C0w?= =?iso-8859-1?q?DBDPQI0CEZLKCHwt6Prl+Px8JYf3aAyBqp11HnYaCT+O7LrzxJOS6KQyo+kU?= =?iso-8859-1?q?L3sRHwRr910oN5Fdkj0ibmB0LYPPUVitQIE8/1g2x4pwY7RcijVa16qPCkQe?= =?iso-8859-1?q?iXEuf8vkZaCOoH9+MrjEr2Vieo3FEuTRxmPBSOvOyRgZNTPKYNaxeAD4s+pe?= =?iso-8859-1?q?kQLd3uqOMvvL9+ztoAxveJRjp5fugJ8lMa1Wtz90ZHFVFCn/b06si7t7tQa4?= =?iso-8859-1?q?R36bienUS3/gt9UK5AkVjKzg/hQHKP6fDnpHLVYzrW4/p/6cdWxukSOxNXLp?= =?iso-8859-1?q?dTMsh17LIUh1Sa9LxYFf3rdIVuWKsaPaqYXCtlF9104StSkn4airCPuBo4vt?= =?iso-8859-1?q?2YdCIvR/vuJn8uCx0xSMmSoMhld8bzqzXva9iaIxfpL30WmjhxEn9AmhgLTI?= =?iso-8859-1?q?XxRbSK1X3s0ga8GUEIibzDwxfQiFvwxGkuSRHNtHnKD4NQjKmPWmFjYK8/IR?= =?iso-8859-1?q?zjoyifMIFtQ50GGHpxZkXBcrhJsv/DpgAdLN/pmYswnDH1QDsnsnTu0H8QmY?= =?iso-8859-1?q?M4mUm0r0z6xFzV/k1RLng6mEtQphDKM0mNyucYXVEjgkiur3Yr7IrPoxo1W3?= =?iso-8859-1?q?85XTfEFRCFHP5VrqfEuBNh+PZW8kTCCVPl3IjAkKP7WCubYIR4V6h7WuI0DZ?= =?iso-8859-1?q?C3WKTsDSqxw/Je6E/zeHLqlRIMypQe+35X6xykRKADwHvlS0YHV8/ZU9X3UO?= =?iso-8859-1?q?mpN1+zrbYp/z0t9ev47KJWtScb6ZNmFQxLRYjJqmJ3pnwDNi2YRoSncDe0rK?= =?iso-8859-1?q?2Qzw7GwW0jW+IXS1pIOSMjgvWTZEEcEft1V+q/mVizDo7XjTeELwTjkKM9Ws?= =?iso-8859-1?q?7RZem6j6lglK7btpg14EHPe5NqDrY5xKh0y+zVCRsI20MaZy2cfaAU5kU+Vw?= =?iso-8859-1?q?HOAgwEA7NV1+KLIXp2wx7XkD0a46F7YN6+tE2OX4JMNgSYvG7F5YvQlZh7Q5?= =?iso-8859-1?q?Wq9EfVkTwjYq1dTZG7DRNAKLsMQ2InWLRLjX3svkLmV9qiyG6bQtBtOBZsHj?= =?iso-8859-1?q?ppKiutPcunHtgmJXEQLChTuzlHGNan7/1/edF+tCOwQu2g7bfa68DLc53hz9?= =?iso-8859-1?q?7m2l7J0hJ1vCa+Hy/ZlTHa+wCRIpaZE2/v2bbBniG38K3872OWZzugmMthC7?= =?iso-8859-1?q?nJpY=3D?= 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: e8ab3c2b-0600-422c-935b-08d9bee4ead6 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2021 09:34:25.0294 (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: RfqdyPuxzpK6fVl6BWZCRh4B0qxyja2icLr2P17aFoi0M0sb2PDsGY4FW6M9rRx0f1R2uC9DFJUED9BG5sQ7NsCJzR2J7eSLsAKmmjESwPA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR03MB5162 X-Proofpoint-ORIG-GUID: wlhcHQlPM2w9Xz2Hror1NT-CP53P_nvL X-Proofpoint-GUID: wlhcHQlPM2w9Xz2Hror1NT-CP53P_nvL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-14_05,2021-12-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140054 This patch adds the basic framework for SCI mediator. SCI is System Control Interface, which is designed to redirect requests for the Hardware (such as power-domain/clock/resets etc) from the Domains to the firmware. 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 shoud have an entity, caled SCI-Mediator, which is responsible for messages redirection between Domains and Firmware and for permission handling. This is how it works: user can build XEN with multiple SCI mediators. See the next patches, where SCMI-SMC mediator is introduced. 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 | 8 ++ xen/arch/arm/Makefile | 1 + xen/arch/arm/domain.c | 24 +++++ xen/arch/arm/domain_build.c | 11 +++ xen/arch/arm/platforms/rcar3.c | 3 +- xen/arch/arm/sci/Makefile | 1 + xen/arch/arm/sci/sci.c | 128 ++++++++++++++++++++++++++ xen/arch/arm/setup.c | 1 + 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 | 10 ++ 13 files changed, 365 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 +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 ecfa6822e4..186e1db389 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -106,6 +106,14 @@ config TEE source "arch/arm/tee/Kconfig" +config SCI + bool "Enable SCI mediators support" + default n + help + This option enables generic SCI (System Control Interface) mediators + support. It allows guests to control system resourcess via one of + SCI mediators implemented in XEN. + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 07f634508e..6366ff55e5 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -8,6 +8,7 @@ obj-y += platforms/ endif obj-$(CONFIG_TEE) += tee/ obj-$(CONFIG_HAS_VPCI) += vpci.o +obj-$(CONFIG_SCI) += sci/ obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.o diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 96e1b23550..80d0a23767 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_createdomain *config) return -EINVAL; } + if ( config->arch.sci_type != XEN_DOMCTL_CONFIG_SCI_NONE && + config->arch.sci_type != sci_get_type() ) + { + dprintk(XENLOG_INFO, "Unsupported SCI type\n"); + return -EINVAL; + } + return 0; } @@ -764,6 +772,15 @@ 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.sci_type != XEN_DOMCTL_CONFIG_SCI_NONE ) + { + if ( (rc = sci_domain_init(d, config->arch.sci_type)) != 0) + goto fail; + + if ( (rc = sci_get_channel_info(d, &config->arch)) != 0) + goto fail; + } } /* @@ -796,6 +813,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 +1014,7 @@ enum { PROG_xen, PROG_page, PROG_mapping, + PROG_sci, PROG_done, }; @@ -1056,6 +1075,11 @@ int domain_relinquish_resources(struct domain *d) if ( ret ) return ret; + PROGRESS(sci): + ret = sci_relinquish_resources(d); + if ( ret ) + return ret; + PROGRESS(done): break; diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d02bacbcd1..38874615dd 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, struct dt_device_node *dev, return res; } } + + res = sci_add_dt_device(d, dev); + if ( res < 0 ) + return res; } res = handle_device_interrupts(d, dev, need_mapping); @@ -3075,6 +3080,10 @@ static int __init construct_dom0(struct domain *d) if ( rc < 0 ) return rc; + rc = sci_domain_init(d, sci_get_type()); + if ( rc < 0 ) + return rc; + if ( acpi_disabled ) rc = prepare_dtb_hwdom(d, &kinfo); else @@ -3109,6 +3118,8 @@ void __init create_dom0(void) dom0_cfg.arch.tee_type = tee_get_type(); dom0_cfg.max_vcpus = dom0_max_vcpus(); + dom0_cfg.arch.sci_type = sci_get_type(); + if ( iommu_enabled ) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; diff --git a/xen/arch/arm/platforms/rcar3.c b/xen/arch/arm/platforms/rcar3.c index d740145c71..a268b09454 100644 --- a/xen/arch/arm/platforms/rcar3.c +++ b/xen/arch/arm/platforms/rcar3.c @@ -18,10 +18,11 @@ */ #include +#include static bool rcar3_smc(struct cpu_user_regs *regs) { - return false; + return sci_handle_call(current->domain, regs); } static const char *const rcar3_dt_compat[] __initconst = diff --git a/xen/arch/arm/sci/Makefile b/xen/arch/arm/sci/Makefile new file mode 100644 index 0000000000..837dc7492b --- /dev/null +++ b/xen/arch/arm/sci/Makefile @@ -0,0 +1 @@ +obj-y += sci.o diff --git a/xen/arch/arm/sci/sci.c b/xen/arch/arm/sci/sci.c new file mode 100644 index 0000000000..5961b4cd5d --- /dev/null +++ b/xen/arch/arm/sci/sci.c @@ -0,0 +1,128 @@ +/* + * 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 + +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) +{ + if ( sci_type == XEN_DOMCTL_CONFIG_SCI_NONE ) + return 0; + + if ( unlikely(!cur_mediator) ) + return -ENODEV; + + if ( cur_mediator->sci_type != sci_type ) + return -EINVAL; + + return cur_mediator->ops->domain_init(d); +} + +void sci_domain_destroy(struct domain *d) +{ + if ( unlikely(!cur_mediator) ) + return; + + cur_mediator->ops->domain_destroy(d); +} + +int sci_relinquish_resources(struct domain *d) +{ + if ( unlikely(!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 ( unlikely(!cur_mediator) ) + return 0; + + return cur_mediator->ops->add_dt_device(d, dev); +} + +int sci_get_channel_info(struct domain *d, + struct xen_arch_domainconfig *config) +{ + if ( unlikely(!cur_mediator) ) + return 0; + + return cur_mediator->ops->get_channel_info(d->arch.sci, config); +} + +uint16_t sci_get_type(void) +{ + if ( unlikely(!cur_mediator) ) + return XEN_DOMCTL_CONFIG_SCI_NONE; + + return cur_mediator->sci_type; +} + +static int __init sci_init(void) +{ + const struct sci_mediator_desc *desc; + struct dt_device_node *dt = NULL; + + for ( desc = _sscimediator; desc != _escimediator; desc++ ) + { + if ( likely(dt_host) ) + { + dt = 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 = 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/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 = .; } :text + . = ALIGN(8); + .scimediator.info : { + _sscimediator = .; + *(.scimediator.info) + _escimediator = .; + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : { diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 9b3647587a..d9b164017f 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_SCI + void *sci; +#endif } __cacheline_aligned; 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..aeff689c72 --- /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 + +#ifdef CONFIG_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); + + /* + * 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); + + /* Gets channel configuration and store it in domainconfig */ + int (*get_channel_info)(void *sci_ops, + struct xen_arch_domainconfig *config); + +}; + +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_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); +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); +int sci_get_channel_info(struct domain *d, + struct xen_arch_domainconfig *config); +uint16_t sci_get_type(void); + +#define REGISTER_SCI_MEDIATOR(_name, _namestr, _type, _match, _ops) \ +static const struct sci_mediator_desc __sci_desc_##_name __used \ +__section(".scimediator.info") = { \ + .name = _namestr, \ + .ops = _ops, \ + .sci_type = _type, \ + .dt_match = _match \ +} + +#else +#include + +static inline int sci_domain_init(struct domain *d, uint16_t sci_type) +{ + if ( likely(sci_type == XEN_DOMCTL_CONFIG_SCI_NONE) ) + return 0; + + return -XEN_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 int sci_get_channel_info(struct domain *d, + struct xen_arch_domainconfig *config) +{ + return 0; +} + +static inline uint16_t sci_get_type(void) +{ + return XEN_DOMCTL_CONFIG_SCI_NONE; +} + +#endif /* CONFIG_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..9180be5e86 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -314,12 +314,16 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_TEE_NONE 0 #define XEN_DOMCTL_CONFIG_TEE_OPTEE 1 +#define XEN_DOMCTL_CONFIG_SCI_NONE 0 + struct xen_arch_domainconfig { /* IN/OUT */ uint8_t gic_version; /* IN */ uint16_t tee_type; /* IN */ + uint8_t sci_type; + /* IN */ uint32_t nr_spis; /* * OUT @@ -335,6 +339,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 sci_agent_paddr; }; #endif /* __XEN__ || __XEN_TOOLS__ */ From patchwork Tue Dec 14 09:34:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 12675725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBC6AC433EF for ; Tue, 14 Dec 2021 09:34:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.246487.425111 (Exim 4.92) (envelope-from ) id 1mx4Co-0007sx-Rw; Tue, 14 Dec 2021 09:34:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 246487.425111; Tue, 14 Dec 2021 09:34:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Co-0007p2-L7; Tue, 14 Dec 2021 09:34:42 +0000 Received: by outflank-mailman (input) for mailman id 246487; Tue, 14 Dec 2021 09:34:41 +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 1mx4Cm-0007JG-Ta for xen-devel@lists.xenproject.org; Tue, 14 Dec 2021 09:34:41 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 341575b3-5cc0-11ec-85d3-df6b77346a89; Tue, 14 Dec 2021 10:28:32 +0100 (CET) Received: from pps.filterd (m0174682.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BE943EG004675; Tue, 14 Dec 2021 09:34:35 GMT Received: from eur05-db8-obe.outbound.protection.outlook.com (mail-db8eur05lp2107.outbound.protection.outlook.com [104.47.17.107]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3cxraag3uw-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 09:34:35 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PA4PR03MB6976.eurprd03.prod.outlook.com (2603:10a6:102:e4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.17; Tue, 14 Dec 2021 09:34:27 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6%9]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 09:34:27 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 341575b3-5cc0-11ec-85d3-df6b77346a89 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UwnGUl9bX6i59s6B7qkAKXp2jvEk4m7FzejG+a51nPdxUmLM/UBuMP9Z4IyX3NzazUlxzRvPAm8CsE8l4BrWmg1ZC/s3ine+LIUY5e4ebh2wJ2jawc5NwvluPjX4ZBcrQQ3AwQHmPKTXRLR0CUFA1HYjBzVqE0HgkbwimfbmbDzWS4HubPke9bqMhXvUNKoCp2Sp3V3pgC/MwyvB7vQMJSK0d+9qfXL6xcETr6oxk6IqYKiqEggHDczWqoXFsYb7aXVwDHupBWznBoi+DKqtcjkvLCs0XNr2sUrASSHLyj3nyeJmzcj1ufzpkQRPxjFO4HEDgKN8luqIyxv3Hwbl/g== 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=RqDx/qBEgEJtOnIYy1d9FCWR8MG1fPXkQ1whSTJXTl0=; b=h5II6aVCW9LhIQ0pcInCCgzIW9lD0XJZ+6e/hPWM5IF7INA5AGmj6HMFZ1G/Kj2c/kqT6WpD7d94pbrxw2NeXtZnSGdqkEyS442DNNbK36HTJCo5ChJ71YBoR63M47dj0a6WpyBvWl63sFtMWQVppsp6JGI4sUD85eD7cJ/PwVjYDuUapESz2WUzs0piisObrveiAZqtZPeIFX8jZvY04rSFAQ/Na4JYL+10AE9wzKJK/2mG268hNdh6ggS91n4f6GrJ9COB8bKvB9r5KCANBmpj0dh1ipWxdz5veDCoUCf+oaB3rHup596GhKfbotFZ5AW/aF/OukbPhAgkNtq2TQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RqDx/qBEgEJtOnIYy1d9FCWR8MG1fPXkQ1whSTJXTl0=; b=S2qouYjWnD58sLL8Daum0iLSgcv0bumf18ECt3jQopfj51OJx+IdRDc5l7TDqryrN6YQbT//YHOVX4XY6znp+W72rdS2YgrbLKODk4AdOClSuhfu8aUnXRUmROER+T9N6DWU7PPduBmLAhcjowZzVIUuVKDsjsGFugj9wZq8wO4zL23gKfv6CWVA3MQ67XEUhyRgCynnS5SOgGDFwId4Io8+ZzsnoUzIPGROMSJ88dkja2JLX4bGKHHwdmoH/pP4+/lNzlu8bLxwlb4gIbLXhpyCc+eaQen8ppz4WzElGfi4dyYVb1M6qCU5i/+PlwX0Hs9mSdBRTQfC57s8Bk2oKw== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC v1 3/5] xen/arm: introduce SCMI-SMC mediator driver Thread-Topic: [RFC v1 3/5] xen/arm: introduce SCMI-SMC mediator driver Thread-Index: AQHX8M3JF7Ng56/tV0+8/7pODiaWfA== Date: Tue, 14 Dec 2021 09:34:27 +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: ca2bd1b1-d2d6-4e69-31af-08d9bee4ec24 x-ms-traffictypediagnostic: PA4PR03MB6976:EE_ x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2512; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QwNPoH92G8HviE3JqVCX0MMKrkRnBlo95OojdFpOxpxXsoVZb7ZxL7H/ygk4JxkgBoRJQ6b5pp1fIajW4hwT9UHWaXRp79JW9o8s8mMhhA0x0q+nOjdP27JF2ydYhvlnMqUuAGsTxxFFpuWIj+bxUtIK4cOU0a/EAkNUkaKoxPPndinnZod7nuM5MGRyKxsPKfYAiMsj3RhBgDmkJAhvPrRmPOQ3aIqG6px0u8lYeXT01LnNuctFRF9s2vcJPXPp8dIFKAwoWg6+Mnud2Nyz1ZEJtpzyXIn5PBKzpZdgv/0ZIfTBFzbWQftJRcsVuGW+iBZnsoku8ckB7tFedt6Qobjgynd5UYrSxiDF9VnpDwV1jt6Ce1lF4Q1KweMX0TeycvHNeCYKhWrCBBtE6xD7vUl0/68atdi1l/fxRd0porCLQUzR3R7fzNKtAhcJFEoXlL5o1OHB/LCfIfebEiqV5CkPNJOhu7E7sh39xzpCguWgkdJ7BkTtlNOTk8cyPJPhyEb/tWGiMz+5TtrS6CZQ11pvAJmFvyksYAOI1rSD2AI6B9uyD1wJgjylvsje4vEQJO9IFNXpwzOge8rLPJa9sUe3hBvsGkGazQ1BtXEAIVCcDNn5GHLz77CilsrZEFiSxkmFrMMWnzCDdY0OplHZQXWFFPz3qVzPqoAJSA89vcYq1bk5OrdUlzaYusbewIdGhz52t/HeTHHV95ll+m/DKHz0umTQN3PPopKikkk58z4= 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:(4636009)(366004)(66476007)(64756008)(66556008)(66946007)(26005)(66446008)(76116006)(5660300002)(91956017)(508600001)(86362001)(83380400001)(186003)(30864003)(6916009)(4326008)(2906002)(6486002)(38070700005)(8936002)(2616005)(36756003)(71200400001)(8676002)(38100700002)(122000001)(6512007)(6506007)(316002)(54906003)(2004002)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ACcJU8qchTVDnGm/rPhClN2?= =?iso-8859-1?q?2iecsD0+V2QbTOgNWdsKL/Cejigh3DRJ3PvXIyAesdLAQ6gDvzH5dsc3M5B0?= =?iso-8859-1?q?9HfVVXVq2T4De2gAktQYjykZS3ouW8P9Cg3opwMiO8C9wI86nQa1Hsj610D0?= =?iso-8859-1?q?9VQp6u2y41s0868gFLQHoxrar0d+zJ5WTMF5SZ2nPwC6ZJar178KTkDgSZom?= =?iso-8859-1?q?ff0FXmx0IUSH81VPkr/S21aECD2gSxMbf5JhrxndxZGaWCRXBNYhXRc1pK6t?= =?iso-8859-1?q?wGx160H221H7bhKd0R32MN7+4FgptuFuud3p1LXL5VjFV8WQijEGSIo2lP2d?= =?iso-8859-1?q?8TRlbZFthO5JjCzl+PtQpilvBGekbmuzL+C/7cw6AJZ4igt4KS7hYDo6NoXW?= =?iso-8859-1?q?HK7eBEuKNXZ4RhZUR7Bk6jk0+an3vCkO2hpJmy5WcKwLv64EN+Mpnb4YfPdc?= =?iso-8859-1?q?1sRDh2cND/rj3rSnlsjaJRG5N/SgJCO5eTgJYQBsEeedK7iofMmokZIXfQYx?= =?iso-8859-1?q?LNqqKxzoB7iF2dV8AzzryOAwfxiO7ck/enc79YIGzHWasu/3mZDGJeXg3uFC?= =?iso-8859-1?q?jYAWG/zWmoHdGTNmVJQceO4Ctzor8JEWchAR46xx0zFDGK80GGTjxQxgooIr?= =?iso-8859-1?q?7wjoszL26clKeemn01N+EVJxCKnVHn4iW4y4F1SlXDsDy7IsLIEoEfPBQ153?= =?iso-8859-1?q?Nn2g+1j41bfrYI2OrxFG1wvjWlUFAPurQetQ90BBx/qsTuTkChFxfFOwap/z?= =?iso-8859-1?q?M7HeKqjWvAW4dYXaos5V3w3mRtFxbzUXqIVNNtt9/31c0qvV1SJzoqbFiJg3?= =?iso-8859-1?q?wNzeJ3iAdmaRmhLjXfYuF46kVIROqaS4WgF1b+bLKfrymq4xn37XLLRPpvSw?= =?iso-8859-1?q?lztEtk65mfZ/YI0sGdL3VwvjqrOdOCS1tpRsLnENA97k4M5T8bWQSZH2ViiE?= =?iso-8859-1?q?vUsRn7KWsK9BgWSSfDhxXA+R1KYFQTLoy2PCzAUbJ3AUOBnmJNp43Cz8cBal?= =?iso-8859-1?q?s2Sxns2rLGKR0mkDpFXA2RWM5KqQc+pgBB2PXNVcGMnOZdk6rQOvOJEUDgdP?= =?iso-8859-1?q?8JhqaJPh9DwV4xCPABe+ivJTdajly+QRnhiDm0SsTKFs/ZJP2o6Jf6P8s7qy?= =?iso-8859-1?q?lNqom3IjOpXVPYj5R1DapIQBQJz2nsCs3nUhvqDgYhDMBGZhhDrK0BFySqYH?= =?iso-8859-1?q?9U7WWYyyoO721FXhD6nKGI2M6rlnT923RLwhQCSMGTLoxi2KFD7OzJsPVeQ3?= =?iso-8859-1?q?4ZQiHcCujPHSJxswAdOdy+8tvTCJbhom4105LCtw2YPidOHyydeT/gYh13GT?= =?iso-8859-1?q?2WevJCQZs2LkNmHC4XsmBXIIg3hDvJ8570DbLV8hjH0O1djQAXs+y2IxcCw0?= =?iso-8859-1?q?sFfUS286qR5uXRI8LWTdrA4ZkB5vRBatX3dBKpEhyipiLKfD/D0aWaI6PhWn?= =?iso-8859-1?q?IWpiPvFqPy71xCiqxYL/cLqu+YlEjMhDDrmSnWEV6CPSb9VtVZI4DPpX1+1T?= =?iso-8859-1?q?TBrNNul3Nu8xbZrtMpJ9ibs78QddRoFB333515WJLxsNepjYS9K0ZYxxCwTU?= =?iso-8859-1?q?4T2vwpDqNL0WmRspyklpgjw1fzEuyqy7w0ABT5XUm2Wn7GHZcyoqL/HD/rul?= =?iso-8859-1?q?G0TPuIKoLfw4L4yY2kVu4tbups7jSnp/NL0XhvYcTCEv61RpeMkN3x2y79sW?= =?iso-8859-1?q?+UVPdhdRy6VPTCNKwtz3ixXKk3JtuaGlJDoB/UNMrswuMkvL+lEVJEz9XlcB?= =?iso-8859-1?q?llJA=3D?= 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: ca2bd1b1-d2d6-4e69-31af-08d9bee4ec24 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2021 09:34:27.2470 (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: srjvjyhM4KXgTORbS998EPN9Xp8+YAyT1IeXfJ44QFbEe6qaThdp+G2XjhWMoXb460rZLmaCbQlIVi1SLiJl4vZglk82YAM1byWvxiop6NU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB6976 X-Proofpoint-ORIG-GUID: bnENPmIRLNVAf6yDf1GfFMAyvJYcr5gA X-Proofpoint-GUID: bnENPmIRLNVAf6yDf1GfFMAyvJYcr5gA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-14_05,2021-12-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140054 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. 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/Makefile | 1 + xen/arch/arm/sci/scmi_smc.c | 795 ++++++++++++++++++++++++++++++++++ xen/include/public/arch-arm.h | 1 + 5 files changed, 809 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 186e1db389..02d96c6cfc 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -114,6 +114,8 @@ config SCI support. It allows guests to control system resourcess via one of SCI mediators implemented in XEN. +source "arch/arm/sci/Kconfig" + endmenu 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..9563067ddc --- /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 SCI + ---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/Makefile b/xen/arch/arm/sci/Makefile index 837dc7492b..67f2611872 100644 --- a/xen/arch/arm/sci/Makefile +++ b/xen/arch/arm/sci/Makefile @@ -1 +1,2 @@ obj-y += sci.o +obj-$(CONFIG_SCMI_SMC) += scmi_smc.o diff --git a/xen/arch/arm/sci/scmi_smc.c b/xen/arch/arm/sci/scmi_smc.c new file mode 100644 index 0000000000..2eb01ea82d --- /dev/null +++ b/xen/arch/arm/sci/scmi_smc.c @@ -0,0 +1,795 @@ +/* + * 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 "linux,scmi_mem" +#define SCMI_SHMEM "shmem" + +#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; + +typedef struct scmi_perms_tx { + uint32_t agent_id; + uint32_t device_id; + uint32_t flags; +} scmi_perms_tx_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 scmi_channel { + int chan_id; + int agent_id; + uint32_t func_id; + int domain_id; + uint64_t paddr; + 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; + u64 shmem_addr, shmem_size; +}; + +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 = FIELD_GET(HDR_ID, msg_hdr); + hdr->type = FIELD_GET(HDR_TYPE, msg_hdr); + hdr->protocol = 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; +} + +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; + + printk(XENLOG_DEBUG "scmi: status =%d len=%d\n", + chan_info->shmem->channel_status, len); + printk(XENLOG_DEBUG "scmi: header id = %d type = %d, proto = %d\n", + hdr->id, hdr->type, hdr->protocol); + + ret = channel_is_free(chan_info); + if ( IS_ERR_VALUE(ret) ) + return ret; + + chan_info->shmem->channel_status = 0x0; + /* Writing 0x0 right now, but SCMI_SHMEM_FLAG_INTR_ENABLED can be set */ + chan_info->shmem->flags = 0x0; + chan_info->shmem->length = sizeof(chan_info->shmem->msg_header) + len; + chan_info->shmem->msg_header = pack_scmi_header(hdr); + + printk(XENLOG_DEBUG "scmi: Writing to shmem address %p\n", + chan_info->shmem); + if ( len > 0 && data ) + memcpy((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 == 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; + } + + 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); + + ret = channel_is_free(chan_info); + if ( IS_ERR_VALUE(ret) ) + return ret; + + recv_len = chan_info->shmem->length - sizeof(chan_info->shmem->msg_header); + + 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(data, chan_info->shmem->msg_payload, recv_len); + } + + return 0; +} + +static int do_smc_xfer(struct scmi_channel *channel, scmi_msg_header_t *hdr, void *tx_data, int tx_size, + void *rx_data, int rx_size) +{ + int ret = 0; + + if ( !hdr ) + return -EINVAL; + + spin_lock(&channel->lock); + + ret = send_smc_message(channel, hdr, tx_data, tx_size); + if ( ret ) + goto clean; + + ret = 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 = false; + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + if ( curr->chan_id == chan_id ) + { + found = true; + break; + } + + spin_unlock(&scmi_data.channel_list_lock); + if ( found ) + return curr; + + return NULL; +} + +static struct scmi_channel *get_channel_by_domain(uint8_t domain_id) +{ + struct scmi_channel *curr; + bool found = false; + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + if ( curr->domain_id == domain_id ) + { + found = true; + break; + } + + spin_unlock(&scmi_data.channel_list_lock); + if ( found ) + return curr; + + return NULL; +} + +static struct scmi_channel *aquire_scmi_channel(int domain_id) +{ + struct scmi_channel *curr; + bool found = false; + + ASSERT(domain_id != DOMID_INVALID && domain_id >= 0); + + spin_lock(&scmi_data.channel_list_lock); + list_for_each_entry(curr, &scmi_data.channel_list, list) + if ( (curr->domain_id == DOMID_INVALID) + && (curr->chan_id != HYP_CHANNEL) ) + { + curr->domain_id = domain_id; + found = true; + break; + } + + spin_unlock(&scmi_data.channel_list_lock); + if ( found ) + return curr; + + return NULL; +} + +static void relinquish_scmi_channel(struct scmi_channel *channel) +{ + spin_lock(&scmi_data.channel_list_lock); + ASSERT(channel != NULL); + channel->domain_id = DOMID_INVALID; + spin_unlock(&scmi_data.channel_list_lock); +} + +static struct scmi_channel *smc_create_channel(uint8_t chan_id, + uint32_t func_id, uint64_t addr) +{ + struct scmi_channel *channel; + mfn_t mfn; + + channel = get_channel_by_id(chan_id); + if ( channel ) + return ERR_PTR(EEXIST); + + channel = xmalloc(struct scmi_channel); + if ( !channel ) + return ERR_PTR(ENOMEM); + + channel->chan_id = chan_id; + channel->func_id = func_id; + channel->domain_id = DOMID_INVALID; + mfn = maddr_to_mfn(addr); + channel->shmem = vmap(&mfn, 1); + if ( !channel->shmem ) + { + xfree(channel); + return ERR_PTR(ENOMEM); + } + + printk(XENLOG_DEBUG "scmi: Got shmem after vmap %p\n", channel->shmem); + channel->paddr = addr; + channel->shmem->channel_status = SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE; + 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 map_memory_to_domain(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 unmap_memory_from_domain(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(struct domain *d, 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 = dt_find_compatible_node(NULL, NULL, "arm,scmi-shmem"); + + if ( !shmem_node ) + { + printk(XENLOG_ERR "scmi: Unable to find %s node in DT\n", SCMI_SHMEM); + return -EINVAL; + } + + pp = 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 = 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) + { + vunmap(curr->shmem); + list_del(&curr->list); + xfree(curr); + } + + spin_unlock(&scmi_data.channel_list_lock); +} + +static __init bool scmi_probe(struct dt_device_node *scmi_node) +{ + struct dt_device_node *shmem_node; + 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; + + uint32_t func_id; + + ASSERT(scmi_node != 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; + } + + shmem_node = dt_find_node_by_name(NULL, SCMI_SHARED_MEMORY); + if ( IS_ERR_OR_NULL(shmem_node) ) + { + printk(XENLOG_ERR + "scmi: Device tree error, can't parse shmem phandle %ld\n", + PTR_ERR(shmem_node)); + return false; + } + + ret = dt_device_get_address(shmem_node, 0, &scmi_data.shmem_addr, + &scmi_data.shmem_size); + if ( IS_ERR_VALUE(ret) ) + return false; + + channel = smc_create_channel(HYP_CHANNEL, func_id, scmi_data.shmem_addr); + if ( IS_ERR(channel) ) + return false; + + hdr.id = SCMI_BASE_PROTOCOL_ATTIBUTES; + hdr.type = 0; + hdr.protocol = SCMI_BASE_PROTOCOL; + + ret = do_smc_xfer(channel, &hdr, NULL, 0, &rx, sizeof(rx)); + if ( ret ) + goto clean; + + ret = check_scmi_status(rx.status); + if ( ret ) + goto clean; + + n_agents = FIELD_GET(MSG_N_AGENTS_MASK, rx.attributes); + printk(XENLOG_DEBUG "scmi: Got agent count %d\n", n_agents); + + n_agents = (n_agents > scmi_data.shmem_size / PAGE_SIZE) ? + scmi_data.shmem_size / PAGE_SIZE : n_agents; + + for ( i = 1; i < n_agents; i++ ) + { + uint32_t tx_agent_id = 0xFFFFFFFF; + struct { + int32_t status; + uint32_t agent_id; + char name[16]; + } da_rx; + + agent_channel = smc_create_channel(i, func_id, scmi_data.shmem_addr + + i * PAGE_SIZE); + if ( IS_ERR(agent_channel) ) + { + ret = PTR_ERR(agent_channel); + goto clean; + } + + hdr.id = SCMI_BASE_DISCOVER_AGENT; + hdr.type = 0; + hdr.protocol = SCMI_BASE_PROTOCOL; + + ret = do_smc_xfer(agent_channel, &hdr, &tx_agent_id, + sizeof(tx_agent_id), &da_rx, sizeof(da_rx)); + if ( ret ) + goto clean; + + ret = check_scmi_status(da_rx.status); + if ( ret ) + goto clean; + + printk(XENLOG_DEBUG "scmi: status=0x%x id=0x%x name=%s\n", + da_rx.status, da_rx.agent_id, da_rx.name); + + agent_channel->agent_id = da_rx.agent_id; + } + + scmi_data.initialized = true; + return true; + +clean: + free_channel_list(); + return ret == 0; +} + +static int scmi_domain_init(struct domain *d) +{ + struct scmi_channel *channel; + int ret; + + if ( !scmi_data.initialized ) + return 0; + + channel = aquire_scmi_channel(d->domain_id); + if ( IS_ERR_OR_NULL(channel) ) + return -ENOENT; + + printk(XENLOG_INFO "scmi: Aquire SCMI channel id = 0x%x , domain_id = %d" + "paddr = 0x%lx\n", channel->chan_id, channel->domain_id, + channel->paddr); + + if ( is_hardware_domain(d) ) + { + ret = map_memory_to_domain(d, scmi_data.shmem_addr, + scmi_data.shmem_size); + if ( IS_ERR_VALUE(ret) ) + goto error; + + ret = dt_update_domain_range(d, channel->paddr, PAGE_SIZE); + if ( IS_ERR_VALUE(ret) ) + { + int rc = unmap_memory_from_domain(d, scmi_data.shmem_addr, + scmi_data.shmem_size); + if ( rc ) + printk(XENLOG_ERR "Unable to unmap_memory_from_domain\n"); + + goto error; + } + } + + d->arch.sci = channel; + + 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; + scmi_perms_tx_t 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 = %d\n", scmi_devid); + + agent_channel = get_channel_by_domain(d->domain_id); + if ( IS_ERR_OR_NULL(agent_channel) ) + return PTR_ERR(agent_channel); + + channel = get_channel_by_id(HYP_CHANNEL); + if ( IS_ERR_OR_NULL(channel) ) + return PTR_ERR(channel); + + hdr.id = SCMI_BASE_SET_DEVICE_PERMISSIONS; + hdr.type = 0; + hdr.protocol = SCMI_BASE_PROTOCOL; + + tx.agent_id = agent_channel->agent_id; + tx.device_id = scmi_devid; + tx.flags = SCMI_ALLOW_ACCESS; + + ret = do_smc_xfer(channel, &hdr, &tx, sizeof(tx), &rx, sizeof(&rx)); + if ( IS_ERR_VALUE(ret) ) + return ret; + + ret = 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 = %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 = d->arch.sci; + + spin_lock(&agent_channel->lock); + tx.agent_id = agent_channel->agent_id; + spin_unlock(&agent_channel->lock); + + channel = 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 = SCMI_BASE_RESET_AGENT_CONFIGURATION; + hdr.type = 0; + hdr.protocol = SCMI_BASE_PROTOCOL; + + tx.flags = 0; + + ret = do_smc_xfer(channel, &hdr, &tx, sizeof(tx), &rx, sizeof(rx)); + if ( ret ) + return ret; + + ret = check_scmi_status(rx); + + return ret; +} + +static void scmi_domain_destroy(struct domain *d) +{ + struct scmi_channel *channel; + + if ( !d->arch.sci ) + return; + + channel = 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 = NULL; + + unmap_memory_from_domain(d, channel->paddr, PAGE_SIZE); + spin_unlock(&channel->lock); + return; +} + +static bool scmi_handle_call(struct domain *d, void *args) +{ + bool res = false; + struct scmi_channel *agent_channel; + struct arm_smccc_res resp; + struct cpu_user_regs *regs = args; + + if ( !d->arch.sci ) + return false; + + agent_channel = d->arch.sci; + spin_lock(&agent_channel->lock); + + if ( agent_channel->func_id != regs->x0 ) + { + printk(XENLOG_ERR "scmi: func_id mismatch, exiting\n"); + 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 = true; +unlock: + spin_unlock(&agent_channel->lock); + + return res; +} + +static int scmi_get_channel_paddr(void *scmi_ops, + struct xen_arch_domainconfig *config) +{ + struct scmi_channel *agent_channel = scmi_ops; + + if ( !agent_channel ) + return -EINVAL; + + config->sci_agent_paddr = agent_channel->paddr; + return 0; +} + +static const struct dt_device_match scmi_smc_match[] __initconst = +{ + DT_MATCH_SCMI_SMC, + { /* sentinel */ }, +}; + +static const struct sci_mediator_ops scmi_ops = +{ + .probe = scmi_probe, + .domain_init = scmi_domain_init, + .domain_destroy = scmi_domain_destroy, + .add_dt_device = scmi_add_dt_device, + .relinquish_resources = scmi_relinquish_resources, + .handle_call = scmi_handle_call, + .get_channel_info = scmi_get_channel_paddr +}; + +REGISTER_SCI_MEDIATOR(scmi_smc, "SCMI-SMC", XEN_DOMCTL_CONFIG_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: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 9180be5e86..a67237942d 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -315,6 +315,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_TEE_OPTEE 1 #define XEN_DOMCTL_CONFIG_SCI_NONE 0 +#define XEN_DOMCTL_CONFIG_SCI_SCMI_SMC 1 struct xen_arch_domainconfig { /* IN/OUT */ From patchwork Tue Dec 14 09:34:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 12675719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89FC5C433EF for ; Tue, 14 Dec 2021 09:34:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.246484.425086 (Exim 4.92) (envelope-from ) id 1mx4Cm-0007NC-La; Tue, 14 Dec 2021 09:34:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 246484.425086; Tue, 14 Dec 2021 09:34:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Cm-0007N5-HI; Tue, 14 Dec 2021 09:34:40 +0000 Received: by outflank-mailman (input) for mailman id 246484; Tue, 14 Dec 2021 09:34:39 +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 1mx4Ck-0007JG-RD for xen-devel@lists.xenproject.org; Tue, 14 Dec 2021 09:34:39 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 32c13a6e-5cc0-11ec-85d3-df6b77346a89; Tue, 14 Dec 2021 10:28:30 +0100 (CET) Received: from pps.filterd (m0174682.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BE943EF004675; Tue, 14 Dec 2021 09:34:35 GMT Received: from eur05-db8-obe.outbound.protection.outlook.com (mail-db8eur05lp2107.outbound.protection.outlook.com [104.47.17.107]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3cxraag3uw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 09:34:34 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PA4PR03MB6976.eurprd03.prod.outlook.com (2603:10a6:102:e4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.17; Tue, 14 Dec 2021 09:34:28 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6%9]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 09:34:28 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 32c13a6e-5cc0-11ec-85d3-df6b77346a89 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ioRt2ZPrDGCVT0oIn/POaFjHyH08hqjuqE8K7AQlE9ayLBu4LuBziJZz376LzDE8Jf/ONKzdiMIMZqaUCwPPe3KpaaowHxEyW/TwBmVzfNZECl+gGfxp25p7eUQsMV4DGWMkMOD62Y8o908hjWfBHArknZsY55aTqVxhOWBMOiia74m/3fLaLHpbcShE1MgqddUAPLtoSIPRytg2d4w0NqzWhPZ0HIP1f+UHmOqQZ2gBvz9SM1NUTtGnBsaOKQdicrdZLTQYYbqjDm6j2E1FXf6v87+uYMKJQ7ALvp/Bl7Nt1EljoNaT+KSXdWWMMdeGdG5HbBRaZAezQ2UZTG3nrA== 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=iaUWZPBTg2O+gyl1uMnhO6Ep5oxml8YVCINnTiUgzaw=; b=dABaXNHdHUTNEz9oop758mpIX/ug6s88TrCMljKHqgOeyJagwmq0EiZu1okpBIsBQfgKcTB1sA2Ik+Gr2GFJ9ceB/fEXdB9ubPorsIZs78hpEhbvLkd1EF+fAXtZIws6NrN/Q5Ls1BlLyCjA6i8GJ1mAqRcB+WEEv6W+5nTfiJFoUms30IRkCXWtmAtitbuEVyNkvLIs6qzvfIf2dj0a/ugoH61MK/SENrwEcgHWStQI8PDSfSmrHRm4jClLvneyzEBimSWUPUK2IqM3UDNo4dcPkheRn86WdhvCihBKxLXfnCC0Z+toDrvAS8iZCJ2QZ49piq8PBXTKpqHap4K1Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iaUWZPBTg2O+gyl1uMnhO6Ep5oxml8YVCINnTiUgzaw=; b=ADKHM96IC1fMqOM8lI/kVaRaXO7mlw5mSQfwMwdLQtvh86W/0dz3lasrfW6+lev+irLXGpGZIupnJUS+AsfS+WZGO1GDUBn0qV5hrvVaW07w/Fu1mWYWH8adH5t2WV2NE/XR73QlwjaDvPdJ2BkVyx/wnrc8Po1EKT8/tZTw39hEbyWF0H7lpmGOLgqNAidTua2zBg3ZiX0+8bG0vl8Hj20KDra/IUlWZpEFslP0Mao3PZsM8jH3gqfnXzEu3fXUwVFMAfbYsYfW9KSL4+TgCsjssQevvFbXBstA4+Fkui8POhRkEn55+Jkru9exjYR0h8/Z+1lSDEkHAaV33VvGZg== From: Oleksii Moisieiev To: "xen-devel@lists.xenproject.org" CC: Oleksii Moisieiev , Wei Liu , Anthony PERARD , Juergen Gross Subject: [RFC v1 4/5] tools/arm: add "scmi_smc" option to xl.cfg Thread-Topic: [RFC v1 4/5] tools/arm: add "scmi_smc" option to xl.cfg Thread-Index: AQHX8M3K+4k+NJRDpU6TSJ1TAn9Owg== Date: Tue, 14 Dec 2021 09:34:28 +0000 Message-ID: <7aa3e21a3285b3af92ad87a4b039b4bd7696ac88.1639472078.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: 0f4502bb-2d5e-491a-a663-08d9bee4ed06 x-ms-traffictypediagnostic: PA4PR03MB6976:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cIalWWULnWtDp2xml+AbZba8QPmRDeawiRzkuWRg1Ii115PWr3Cl85ZpuGwHFOOhslcqfAEupzuUG0WxWeOEzth2mmV0jo7jnBUtStORjVIGsMBly7bluZAZr7/6re0i02f5qpBxyHyug79rUAsaSDZHtnj7M3r8/jt0Nm2s8njNe1FhliMnahTD84mM4S+/MUqO/C2yUhxboTDg7xHg67CHixsjRybEEq25sp0vpzDOeyvKeI4Aw21aD6SjXBWrk/G1fLy6IzNh38rQYa1xMV+HIGNIcBNI41s9WY7bAMK5m7lhxKo3IlthLExLrLVuZR6NqA2JHP5JvAHoZzcbq7u643FwGsxqdikk1MnW2+2pFgzYBt78snO6IpoL1l/najT2esrg1aCQQaSeNSdSWPiEP3rYt98QXmWYMeDXK5JlA99yhgHdjyw2z+YCwQrBZjxx+PX9B+DJ7vsG9Hms6g19h9/Xnd0CpxXthTr5fn/19IoWqOg8zQOmHPpjWa5k0DtupRat3gbplqPm9Idw98CoKBmWIFIxB9AkyaizHH2+Y4Ieete6sIO/AwwnUzpN4eKk/9qwyq7WEbkh1kR88RcVjMB3H7vwFJiNH600BIIlC7NFax9Vd7T5OE6aSyntF/k7LMWpvGKAk2xrqonSu71L7AIWEUbiGswTCqJCMM1KBkt+ORgFJ8pXzAfx+nCxT8N6Hnep942uVTreprZ2fw== 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:(4636009)(366004)(66476007)(64756008)(66556008)(66946007)(26005)(66446008)(76116006)(5660300002)(91956017)(508600001)(86362001)(83380400001)(186003)(6916009)(4326008)(2906002)(6486002)(38070700005)(8936002)(2616005)(36756003)(71200400001)(8676002)(38100700002)(122000001)(6512007)(6506007)(316002)(54906003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?eOxrMUCJPjffCraXnBT9TP1?= =?iso-8859-1?q?oAwa0JFYeXrCeaC+qkGIWuQrmsGKeQ1b7hT6M1cJxCIFh//+WnE9T4oQBKLg?= =?iso-8859-1?q?+lyrDhNepW8KMugwFRtbQ0Mi/kr//ND/X+zHvEEMehTXdXwPwCOTstxpI/7/?= =?iso-8859-1?q?Skd0C4wZIyxlfoE6vrP7/be1WpGn3OIngog3jnBONmPtW4vCDBHrkdDhRsw3?= =?iso-8859-1?q?lT0Zjz9i6I1Pv8Ti8knmQ88JOy43BcHJBBBxXHGU1cpGNBWEmxkDQ7mVCv3X?= =?iso-8859-1?q?Z7DowVEdyrRwisp+4gitkdFuW3vI74HSaz5mk1D0UNgZ1OgX78PjHv3SYyfj?= =?iso-8859-1?q?52d/a1aCG6FqqHypeOziSKAk3pAha94+eFAXtS5kn4Oh9y456D4FqVpk+mex?= =?iso-8859-1?q?H6ZM5eflr0BdZFlNl2iunGX8KSo/Xz/vBEeutdUq9BcwZY2E4kEmxBMy2AJv?= =?iso-8859-1?q?WF974e+GcRmQ86p1GbCBQbL9CgoF8PkfwJ753pjUWaLw7vKt41ubkzHQ87KX?= =?iso-8859-1?q?Y15wvJlTuLxRjJuYTDa7TCV4vTVAB+VtfLHI8eOPIhEMXoLjTraYhqY2NVdv?= =?iso-8859-1?q?/5HfiiKJwBxawiGjaPoLSxZk68BFYEubxrRivjddyQD3KOm2Mldkt/Lfl+pP?= =?iso-8859-1?q?xSDTvjWq+o+KcdTlTM2WaYv6n9Ve9Pn9Kw4lixebyV2LWXVJmYooTd6k7zci?= =?iso-8859-1?q?/nY4IwgmNjxaVTTly39djEErUmAqq+dHethEU+B3iI9d7jcrpvgf6PxJX+ik?= =?iso-8859-1?q?ye0bPqvwYvHmEkoqEy6kT8wfa3h8R2WEmHYWRKlAm+HoIKq/BAUGcxMWVDxp?= =?iso-8859-1?q?K8gNFR/D6G21WsDeGYH/RM8Fg+kTxJxs3+4E3BeMD7pEf2IcUCZxT5QR3Yqj?= =?iso-8859-1?q?02+U8IOTwrZwzmNsSVJM4XmUWwUjqYRv+AKd+Io03ZvnyxOImOHKRS1KZnJ/?= =?iso-8859-1?q?PVyk142FT8oNi9vgdi0vMVnP96mX3lbFijcWWh4mbgHCZ+wkqNTFF0oqu7BH?= =?iso-8859-1?q?r9E380Px/2AU6HJlK/TTZ9f+bgAdBmXYYOV6MJAyjFco6BiE0sda1Ev63Dnv?= =?iso-8859-1?q?9eQ2/WpVvY5hQGaImXX5WBu04z4wiv17rLllJzeDhmhOnL4FE/NvdouMPBDQ?= =?iso-8859-1?q?7gxpTrvdi1Ae7ceYuepxZs4e2+6u4FJ26fF5QYNS6dNelwyiKpvgXaBFMxd1?= =?iso-8859-1?q?mTwxA5/q4qSozn9WE/nSzFBugmvEcscZxx6O/IO3NDArrPgctZRhI6KkRA7v?= =?iso-8859-1?q?Qw2C82Az3jBjDEbIbz+37Xxe/R+wyR177yj7qPWK0oYByz0Mt15vnUR3Q3ir?= =?iso-8859-1?q?PR54M5JvCfX2U7GohwXz6UUj+AgzrKF+vNRHkSShL3O3nUqUuN8G8J6HdicU?= =?iso-8859-1?q?HNTfA+RfGM1zHGKnP4QXS5xmmojJjJ2/koES02VHlobn6ya7MJjpE8iHCvlk?= =?iso-8859-1?q?kuS8sjQ88pTdyXq+QZWOeNaF84zPDBlUB+Tqr/Hm9Ir0MeUsn8/+bPVPESCW?= =?iso-8859-1?q?uIlXzNENJLp7Rsu9ybictygrivlcHptBhUR/6p9GeJ8dJ0QB2Gtudj/wTjrt?= =?iso-8859-1?q?UcodjgYluf74De1g0SdO8Nhjhmrf9ILQtYSTmfqwI/ST8gqVJ2Rq+XTaHXeZ?= =?iso-8859-1?q?UQHX8am8wFVxkDH1m04K67215K7v7NR3A7IX1qdT5WyLe8eE4K6FzPcSTB1p?= =?iso-8859-1?q?ev8VpCD5AjZyPqR3P7YMv8tk1xt3an0DBcLg5GIfqJj458lzwxCZcJji2E6/?= =?iso-8859-1?q?IECk=3D?= 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: 0f4502bb-2d5e-491a-a663-08d9bee4ed06 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2021 09:34:28.7467 (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: r7YxAtrBr9WWk+vi/f6p0876oeSKYUkkyMVot8BKyQm4wFjFqtC+Wd10LtwjYqKSMEMhAOe1rUOCFOL8THi6VPguFrXzB6lcx54nNaKwSKc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB6976 X-Proofpoint-ORIG-GUID: R9AhTlzDXLwOEHHLJle-r0h0shZq5sZ4 X-Proofpoint-GUID: R9AhTlzDXLwOEHHLJle-r0h0shZq5sZ4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-14_05,2021-12-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140054 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 | 22 ++++++++++++++++++++++ tools/include/libxl.h | 5 +++++ tools/libs/light/libxl_types.idl | 6 ++++++ tools/xl/xl_parse.c | 9 +++++++++ 4 files changed, 42 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index b98d161398..92d0593875 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1614,6 +1614,28 @@ This feature is a B. =back +=item B + +B Set SCI type for the guest. SCI is System Control Protocol - +allows domain to manage various functions that are provided by HW platform. + +=over 4 + +=item B + +Don't allow guest to use SCI if present on the platform. This is the default +value. + +=item 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 access to +clocks, power-domains and resets between Domains and ATF. Disabled by default. +SMC is used as transport. + +=back + =back =head2 Paravirtualised (PV) Guest Specific Options 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 +/* + * 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_types.idl index 2a42da2f7d..9067b509f4 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -480,6 +480,11 @@ libxl_tee_type = Enumeration("tee_type", [ (1, "optee") ], init_val = "LIBXL_TEE_TYPE_NONE") +libxl_sci_type = Enumeration("sci_type", [ + (0, "none"), + (1, "scmi_smc") + ], init_val = "LIBXL_SCI_TYPE_NONE") + libxl_rdm_reserve = Struct("rdm_reserve", [ ("strategy", libxl_rdm_reserve_strategy), ("policy", libxl_rdm_reserve_policy), @@ -564,6 +569,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("apic", libxl_defbool), ("dm_restrict", libxl_defbool), ("tee", libxl_tee_type), + ("sci", libxl_sci_type), ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), ("bios", libxl_bios_type), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 117fcdcb2b..c37bf6298b 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2747,6 +2747,15 @@ skip_usbdev: } } + if (!xlu_cfg_get_string (config, "sci", &buf, 1)) { + e = libxl_sci_type_from_string(buf, &b_info->sci); + if (e) { + fprintf(stderr, + "Unknown sci \"%s\" specified\n", buf); + exit(-ERROR_FAIL); + } + } + parse_vkb_list(config, d_config); xlu_cfg_get_defbool(config, "xend_suspend_evtchn_compat", From patchwork Tue Dec 14 09:34:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 12675729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BD73C433EF for ; Tue, 14 Dec 2021 09:35:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.246489.425134 (Exim 4.92) (envelope-from ) id 1mx4Cr-000089-Oh; Tue, 14 Dec 2021 09:34:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 246489.425134; Tue, 14 Dec 2021 09:34:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Cr-00006v-KT; Tue, 14 Dec 2021 09:34:45 +0000 Received: by outflank-mailman (input) for mailman id 246489; Tue, 14 Dec 2021 09:34:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mx4Cp-0007JG-CQ for xen-devel@lists.xenproject.org; Tue, 14 Dec 2021 09:34:43 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 35c0b5fa-5cc0-11ec-85d3-df6b77346a89; Tue, 14 Dec 2021 10:28:35 +0100 (CET) Received: from pps.filterd (m0174682.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BE943EJ004675; Tue, 14 Dec 2021 09:34:37 GMT Received: from eur05-db8-obe.outbound.protection.outlook.com (mail-db8eur05lp2107.outbound.protection.outlook.com [104.47.17.107]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3cxraag3uw-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 09:34:37 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PA4PR03MB6976.eurprd03.prod.outlook.com (2603:10a6:102:e4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.17; Tue, 14 Dec 2021 09:34:30 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::85d2:c8aa:2196:21c6%9]) with mapi id 15.20.4778.018; Tue, 14 Dec 2021 09:34:30 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 35c0b5fa-5cc0-11ec-85d3-df6b77346a89 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m48qyoYx/iKZFtFXfcW1CLJyzLSNIh10N2U8F/k9zetZl76mta/xpNhTPtUUvUnW/UM1bm0AtCecbJFMfHYPYl0LnNXU1kWOhDF+CzwQIu3I8EQi0GZcUNSFQr9GHB7qogksEZH+bMkuuf98UkxBlHFPU/NmMeo393wy+cyMx0AmDXcvi7rjq4yjrwmxrKlGwkfBgXcsH8/dB5cxZ9R8tFRTMeN5LTHzON1+v+0YpBoLWiINEy5+yi9rLUO1S6S7jG2Z2ZokwjytCFiASttz5tRkpa+dOn0610SRiz7aWV1DIzRoe49TS5eVl7AKjORGMveixsoNpjOcInSDySo3oQ== 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=NuMyjEbSpSIao6BH2oZdWuIEjdeXmzyuL/4oyil7Wmc=; b=NvSp+ny15CW+7+rDnu9OWE36EmkjdhLCqGkUvf3TCswiP4+yXAE7l+JWNYQxc3sBVMCpnMKcCLFDPIrcHi257/7MyuQjtMiDUvLU4YLNshkDU0//LAlilzUvY5z1tGPFavAbelF1snAe6hkhT37tsBYnxq3hXoXFn+O0xv+b3Mldq5BhUwq/lebVA8kF8/G2WNNl5FnoonPqbFKPFXHtJd/nsuKaiR0RRs8J0AYpdhcQB9piHDsPNxER94n6ySmMde/g2lZiQDVXHkdxJtXx7QrZiaD5dw6B6semlaneXCUckb/cKNHhKl2F4fzlPSyefihc6eqOn75C0TvSlb6eJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NuMyjEbSpSIao6BH2oZdWuIEjdeXmzyuL/4oyil7Wmc=; b=q6W53TiSH1KhwtgXlL9zuELN3xKU1FuvUx3zd4ah+8b+1FEYBquF3Jidii0wt7atZ8we6YSh1mGudUfqmh802rBc9qdLO2512AjDKg5CX/a2k3PTbzs6t/+DxV+JjENvd0LW6ToTWBNYQL1y/eiRkuUbHg2jiaeKqnJdrB5jM+FrsmxsW04GUTWelxloUoFE7YhMISmGKpbcWGZibfHSABu5lX89HYrzWEvrtG7VOuZyaVlilSMBYwxREXACmlA3wk+4YhZMK2RX3P+dzcEmHDLMjH28ZNpWsbvkh52+CRlUS8F8F7gx0J7FJz25wfZtydT6akVHvLY75w+iPJJgwA== 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 v1 5/5] xen/arm: add SCI mediator support for DomUs Thread-Topic: [RFC v1 5/5] xen/arm: add SCI mediator support for DomUs Thread-Index: AQHX8M3LpzWz4l8PQUiIA2nAUV0H+g== Date: Tue, 14 Dec 2021 09:34:30 +0000 Message-ID: <4469cdf05051bd691a8adff2657d27f6a5f0cefb.1639472078.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: d782d05e-9d15-4391-20f1-08d9bee4ee01 x-ms-traffictypediagnostic: PA4PR03MB6976: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: LXqwGYCnlvewmBDk77E+vGdGvpUzpOZ9C/YJ1AyI9p4PDaGITyjsMR+i1egcyXDuV6hRpM+Ui9Vesq6I0logEFjbCpFWsN2DHk5tdT/fW/sZ9ctGLPKG8ObJXsyfwuG2whxMhpxgJTp6Q00AkLwuEhW3P+rRFbvDH5iqVJDVNbKal67Fl7Y+8C7VnmpDyQQmWgHy6hSth8FH8LFiHb5lJFvVKSueH7Z94VeaZR3SbkHj2EjU4sDw9wuVN2X+pVUEq61wOLfC2LZtg5NWSAkI1ZriQcNaNjCTppRKbrXhVYQ6a0mb0SNQwWY4vh1SAqnIbg8aD0RqJHQ9kbUj0UkNOOPkpu/x/y681OMFow1rp5U1oPj/dCXICi2ScNfS3uCf9SmVr6H0fF3xlNuadXt6DsAm5HC89QfQNAsE7QnRlqkpzq6TzlgRTONEghEBkqsS92yD/c1+PjVUVz14BVFq0P32bFrdViL4OgleGM7hkFDq0hgfTKJgF0h3NXyakwpdaYUGF+K0Ld5e4igGAbT8BT3zITZnpXJ8oetlrQ7epXsWTB78SmKWt9lR01HXN+o+IFLyZLIlyWfmqrwM2foazkcaY0iktB+V9L3J7sLxlSQm+11vj1LqP9+Lx5sj19w0nX7vIoUHNNPc4nGpnEmb80cd7jJgwXNbL2fc+KywWNOVfor71mjfBl/0we3Y3LmuXjx/xJ31auT0v6/++Zpg+w== 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:(4636009)(366004)(66476007)(64756008)(66556008)(66946007)(26005)(66446008)(76116006)(5660300002)(91956017)(508600001)(86362001)(83380400001)(186003)(30864003)(7416002)(6916009)(4326008)(2906002)(6486002)(38070700005)(8936002)(2616005)(36756003)(71200400001)(8676002)(38100700002)(122000001)(6512007)(6506007)(316002)(54906003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?dUH0YfGfqSD0cghep/a3Yx/?= =?iso-8859-1?q?g38c+7tCWraVMq6y5vOSalZXuoa7MPNVTCufV41dQRKMDQEuoIaXP7sO2Vt3?= =?iso-8859-1?q?N/DgxF5KRmA/x9Kl9gz2uDPeRxCAiw2XGwmDRzr38TL/Np37HcwzOxOW0xsq?= =?iso-8859-1?q?k5ckIgoGFJogXAHuMjp3ZMQJVjBSbt2WEbxB+Cv4FALZaPDCN/03VEQfwRVz?= =?iso-8859-1?q?jAjn0xBgi6hagreJ9LSaTrIFC4c9PpoNcqZoeqzy8ZxWhhrAfnkcgmNFiqgi?= =?iso-8859-1?q?NgtUs/+izwbhdcp+jRF6RDxfhrSTQMCDyO08tn4zjwCXUlGpxRIJ5Ly3pamS?= =?iso-8859-1?q?OK9JdGMwOsr/z6ji39F6QGUU84xdf/E3lD5HDOKLCEUrUpbACTlC57fKIct2?= =?iso-8859-1?q?o6EVJzt0BQ9FWc+lLJKstYkWW9mlUKsKtZ2UJxWmnHcs1sOWc7sdYuzogHKE?= =?iso-8859-1?q?syphpVTW3ijugQcEiJR0Dz9LdBKp+0tkJeA72Q8GyzCSDrb562/bW4KfeBnb?= =?iso-8859-1?q?ZSnYmCYOIfFddw0cb1x6eQ3uciIAxh44P6Kk4EDqohq5F2tMqAbjeLW/v6gY?= =?iso-8859-1?q?SOtamDpS96qSyojo6GnP2pwsLgOe3JqptDQhxoAjn+hT/YNm6csmJB2O2W7Y?= =?iso-8859-1?q?qPWWvRMAOTFrJjs+uoIBtYII7vM8lYmWK3ulz1LWSZwQVeRB0Md8jW3G/7CY?= =?iso-8859-1?q?lPdfbbSc9YeD54iLZlBbgye6zqySXactSc7Vd0WLO3/9y8gDfG/tQwmxbY4N?= =?iso-8859-1?q?n9gp5FbrDD3lsLvQT+biZH/sedYdYV5+4zjXV9p8pbD1sDlo8XZ+KnO1DtWC?= =?iso-8859-1?q?8nrbiSomK7y9pGjuhlKpFIkuaqdYYDECq1P6YwsZDASPaLIVYYlm8Hnj0WI3?= =?iso-8859-1?q?1Jsisd5WN7y/RZKczxJl2Iw40Fa72nFioMeVIaNUGCy2ZWVFzDlIpJjRFnGU?= =?iso-8859-1?q?6ZUFFwBP3ysGFTfSPgyD/cjBti3IdDkJycUnF524HNPq12iKcZvOU9lu8t5b?= =?iso-8859-1?q?plyOkFTcwKUR3d3cyjAGWI7qmzK3dQg00fKZMvXbwzdhAcDRJldCsPiM7p85?= =?iso-8859-1?q?Fv32ktvnR40cwAV1g3EnHB2/se89V4PzGIlIJ14DB2hNNohLN785y8PqD/N/?= =?iso-8859-1?q?Tr/IcM7n0tuRWSIobZvzdSryVjZxI/CvVfEQ/YJc/TwxGZe83ZcqbLpLnZDV?= =?iso-8859-1?q?BoAHUxia1c/CQwzCDk/QWel1QxQi7TPXSwBrFc7tUoxRqsnU9fw4sTd+5DlZ?= =?iso-8859-1?q?4XX+3Y2YUyAmSiZsS7QXLLXDlpfZa3L10Vip1rVLBRYZdHTJnMQ3N9Tzei7+?= =?iso-8859-1?q?Hq1ICdGq0A8XJjUoQgQ0TdDisQyShdmvbz+qcN/eMAfgjnZd7Rq5qFsbLkQ6?= =?iso-8859-1?q?TXdkkj/24wtPvN3A5VSzZ5+YjMFQ5hEzo/9kbNcdnpY2HoD8+ynKnWwKWwkn?= =?iso-8859-1?q?g/wjwy1hsjxEo1BbcWxBKI8MGxwsRM5ctTMlEGXr0gJjScaCG5QW5VTN30DY?= =?iso-8859-1?q?PV8gT7grbBim9iwsSss98nkdiGGPHEFvEgVxjrczIXiVpdJeoMa5ResJL1Li?= =?iso-8859-1?q?s5SlcnTNr6FsWNWAAxeRncGMy3fi/G/iA0vZGL4GjTG2XpRsCiPgLOxhvm7F?= =?iso-8859-1?q?QqFFUfs9VN2empMe7H7DWyxLKJr8ruNOM0d5O+NhYnNb8NVPHfQtIbddH6JL?= =?iso-8859-1?q?WiMurq8H3CHIo38t92LLFGibbJUMazsfsaJKPjdmnUYjVZrmz50LRJfiJg0G?= =?iso-8859-1?q?RmaU=3D?= 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: d782d05e-9d15-4391-20f1-08d9bee4ee01 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2021 09:34:30.3570 (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: HtACawbFOb6DEVtIJacr+L0gGTFKQD12nO1+eYoQu5syS2t66Y4N8xRYYY2lV0eFlZ1b/syLOxZkOpPuL79k9WILjhr19RroMqKGW2jJL5A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB6976 X-Proofpoint-ORIG-GUID: CFOXjYvmOTrU-6BM0q3KoB0xKMi33wW- X-Proofpoint-GUID: CFOXjYvmOTrU-6BM0q3KoB0xKMi33wW- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-14_05,2021-12-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112140054 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/include/xenguest.h | 2 + tools/libs/ctrl/xc_domain.c | 23 ++++++ tools/libs/guest/xg_dom_arm.c | 5 +- tools/libs/light/libxl_arm.c | 122 +++++++++++++++++++++++++++--- tools/libs/light/libxl_create.c | 54 ++++++++++++- tools/libs/light/libxl_dom.c | 1 + tools/libs/light/libxl_internal.h | 4 + xen/arch/arm/domctl.c | 15 ++++ xen/include/public/domctl.h | 9 +++ 10 files changed, 223 insertions(+), 15 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); +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/include/xenguest.h b/tools/include/xenguest.h index 61d0a82f48..35c611ac73 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -242,6 +242,8 @@ struct xc_dom_image { /* Number of vCPUs */ unsigned int max_vcpus; + + xen_pfn_t sci_shmem_gfn; }; /* --- arch specific hooks ----------------------------------------- */ diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c index b155d6afd2..07bb390e17 100644 --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -2206,6 +2206,29 @@ int xc_domain_soft_reset(xc_interface *xch, domctl.domain = domid; return do_domctl(xch, &domctl); } + +int xc_domain_add_sci_device(xc_interface *xch, + uint32_t domid, char *path) +{ + size_t size = strlen(path); + int rc; + DECLARE_DOMCTL; + DECLARE_HYPERCALL_BOUNCE(path, size, XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( xc_hypercall_bounce_pre(xch, path) ) + return -1; + + domctl.cmd = XEN_DOMCTL_add_sci_device; + domctl.domain = domid; + domctl.u.sci_device_op.size = size; + set_xen_guest_handle(domctl.u.sci_device_op.path, path); + rc = do_domctl(xch, &domctl); + + xc_hypercall_bounce_post(xch, path); + + return rc; +} + /* * Local variables: * mode: C diff --git a/tools/libs/guest/xg_dom_arm.c b/tools/libs/guest/xg_dom_arm.c index 5e3b76355e..368a670c46 100644 --- a/tools/libs/guest/xg_dom_arm.c +++ b/tools/libs/guest/xg_dom_arm.c @@ -25,11 +25,12 @@ #include "xg_private.h" -#define NR_MAGIC_PAGES 4 +#define NR_MAGIC_PAGES 5 #define CONSOLE_PFN_OFFSET 0 #define XENSTORE_PFN_OFFSET 1 #define MEMACCESS_PFN_OFFSET 2 #define VUART_PFN_OFFSET 3 +#define SCI_SHMEM_OFFSET 4 #define LPAE_SHIFT 9 @@ -69,11 +70,13 @@ static int alloc_magic_pages(struct xc_dom_image *dom) dom->console_pfn = base + CONSOLE_PFN_OFFSET; dom->xenstore_pfn = base + XENSTORE_PFN_OFFSET; dom->vuart_gfn = base + VUART_PFN_OFFSET; + dom->sci_shmem_gfn = base + SCI_SHMEM_OFFSET; xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn); xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn); xc_clear_domain_page(dom->xch, dom->guest_domid, base + MEMACCESS_PFN_OFFSET); xc_clear_domain_page(dom->xch, dom->guest_domid, dom->vuart_gfn); + xc_clear_domain_page(dom->xch, dom->guest_domid, dom->sci_shmem_gfn); xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN, dom->console_pfn); diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index eef1de0939..73ef591822 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -8,6 +8,8 @@ #include #include +#define SCMI_NODE_PATH "/firmware/scmi" + static const char *gicv_to_string(libxl_gic_version gic_version) { switch (gic_version) { @@ -101,6 +103,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } + switch (d_config->b_info.sci) { + case LIBXL_SCI_TYPE_NONE: + config->arch.sci_type = XEN_DOMCTL_CONFIG_SCI_NONE; + break; + case LIBXL_SCI_TYPE_SCMI_SMC: + config->arch.sci_type = XEN_DOMCTL_CONFIG_SCI_SCMI_SMC; + break; + default: + LOG(ERROR, "Unknown SCI type %d", + d_config->b_info.sci); + return ERROR_FAIL; + } + return 0; } @@ -122,6 +137,7 @@ int libxl__arch_domain_save_config(libxl__gc *gc, } state->clock_frequency = config->arch.clock_frequency; + state->sci_agent_paddr = config->arch.sci_agent_paddr; return 0; } @@ -502,9 +518,6 @@ static int make_optee_node(libxl__gc *gc, void *fdt) int res; LOG(DEBUG, "Creating OP-TEE node in dtb"); - res = fdt_begin_node(fdt, "firmware"); - if (res) return res; - res = fdt_begin_node(fdt, "optee"); if (res) return res; @@ -517,9 +530,6 @@ static int make_optee_node(libxl__gc *gc, void *fdt) res = fdt_end_node(fdt); if (res) return res; - res = fdt_end_node(fdt); - if (res) return res; - return 0; } @@ -902,10 +912,9 @@ static int copy_node(libxl__gc *gc, void *fdt, void *pfdt, return 0; } -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 = strrchr(path, '/'); if (!name) @@ -925,12 +934,101 @@ static int copy_node_by_path(libxl__gc *gc, const char *path, if (strcmp(fdt_get_name(pfdt, nodeoff, NULL), name)) return -FDT_ERR_NOTFOUND; + return nodeoff; +} + +static int copy_node_by_path(libxl__gc *gc, const char *path, + void *fdt, void *pfdt) +{ + int nodeoff, r; + + nodeoff = get_path_nodeoff(path, pfdt); + if (nodeoff < 0) + return nodeoff; + r = copy_node(gc, fdt, pfdt, nodeoff, 0); if (r) return r; return 0; } +static int get_node_phandle(const char *path, void *pfdt, uint32_t *phandle) +{ + int nodeoff; + const char *name = strrchr(path, '/'); + + if (!name) + return -FDT_ERR_INTERNAL; + + name++; + nodeoff = fdt_path_offset(pfdt, path); + if (nodeoff < 0) + return nodeoff; + + *phandle = fdt_get_phandle(pfdt, nodeoff); + return 0; +} + +static int make_scmi_shmem_node(libxl__gc *gc, void *fdt, void *pfdt, + struct xc_dom_image *dom) +{ + int res; + char buf[64]; + uint32_t phandle = 0; + + res = get_node_phandle("/scp-shmem", pfdt, &phandle); + if (res) return res; + + snprintf(buf, sizeof(buf), "scp-shmem@%lx", + dom->sci_shmem_gfn << XC_PAGE_SHIFT); + res = fdt_begin_node(fdt, buf); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, "arm,scmi-shmem"); + if (res) return res; + + res = fdt_property_regs(gc, fdt, GUEST_ROOT_ADDRESS_CELLS, + GUEST_ROOT_SIZE_CELLS, 1, + dom->sci_shmem_gfn << XC_PAGE_SHIFT, XC_PAGE_SHIFT); + if (res) return res; + + LOG(DEBUG, "scmi: setting phandle = %u\n", phandle); + res = fdt_property_cell(fdt, "phandle", phandle); + if (res) return res; + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + +static int make_firmware_node(libxl__gc *gc, void *fdt, void *pfdt, int tee, + int sci) +{ + int res; + + if ((tee != LIBXL_TEE_TYPE_OPTEE) && (sci != LIBXL_SCI_TYPE_NONE)) + return 0; + + res = fdt_begin_node(fdt, "firmware"); + if (res) return res; + + if (tee == LIBXL_TEE_TYPE_OPTEE) { + res = make_optee_node(gc, fdt); + if (res) return res; + } + + if (sci == LIBXL_SCI_TYPE_SCMI_SMC) { + res = copy_node_by_path(gc, SCMI_NODE_PATH, fdt, pfdt); + if (res) return res; + } + + res = 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: @@ -1088,8 +1186,10 @@ next_resize: if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) FDT( make_vpl011_uart_node(gc, fdt, ainfo, dom) ); - if (info->tee == LIBXL_TEE_TYPE_OPTEE) - FDT( make_optee_node(gc, fdt) ); + FDT( make_firmware_node(gc, fdt, pfdt, info->tee, info->sci) ); + + if (info->sci == LIBXL_SCI_TYPE_SCMI_SMC) + FDT( make_scmi_shmem_node(gc, fdt, pfdt, dom) ); 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_create.c index dcd09d32ba..c7372fd344 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -596,6 +596,37 @@ out: return ret; } +static int map_sci_page(libxl__gc *gc, uint32_t domid, uint64_t paddr, + uint64_t guest_addr) +{ + int ret; + uint64_t _paddr_pfn = paddr >> XC_PAGE_SHIFT; + uint64_t _guest_pfn = guest_addr >> XC_PAGE_SHIFT; + + LOG(DEBUG, "iomem %"PRIx64, _paddr_pfn); + + ret = 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 = 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 +793,16 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, goto out; } + if (state->sci_agent_paddr != 0) { + ret = map_sci_page(gc, *domid, state->sci_agent_paddr, + state->sci_shmem_gfn << XC_PAGE_SHIFT); + if (ret < 0) { + LOGED(ERROR, *domid, "map SCI page fail"); + rc = ERROR_FAIL; + goto out; + } + } + dom_path = libxl__xs_get_dompath(gc, *domid); if (!dom_path) { rc = ERROR_FAIL; @@ -1817,17 +1858,24 @@ static void libxl__add_dtdevs(libxl__egc *egc, libxl__ao *ao, uint32_t domid, { AO_GC; libxl__ao_device *aodev = libxl__multidev_prepare(multidev); - int i, rc = 0; + int i, rc = 0, rc_sci = 0; for (i = 0; i < d_config->num_dtdevs; i++) { const libxl_device_dtdev *dtdev = &d_config->dtdevs[i]; LOGD(DEBUG, domid, "Assign device \"%s\" to domain", dtdev->path); rc = xc_assign_dt_device(CTX->xch, domid, dtdev->path); - if (rc < 0) { - LOGD(ERROR, domid, "xc_assign_dtdevice failed: %d", rc); + rc_sci = xc_domain_add_sci_device(CTX->xch, domid, dtdev->path); + + if ((rc < 0) && (rc_sci < 0)) { + LOGD(ERROR, domid, "xc_assign_dt_device failed: %d; " + "xc_domain_add_sci_device failed: %d", + rc, rc_sci); goto out; } + + if (rc) + rc = rc_sci; } out: diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c index fe9f760f71..b1d288a8b9 100644 --- a/tools/libs/light/libxl_dom.c +++ b/tools/libs/light/libxl_dom.c @@ -710,6 +710,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, state->console_mfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; state->vuart_gfn = dom->vuart_gfn; + state->sci_shmem_gfn = dom->sci_shmem_gfn; } else { state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_internal.h index 0b4671318c..f9f9cc633a 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -1407,6 +1407,10 @@ typedef struct { /* Whether this domain is being migrated/restored, or booting fresh. Only * applicable to the primary domain, not support domains (e.g. stub QEMU). */ bool restore; + + /* sci channel paddr to be set to device-tree node */ + uint64_t sci_agent_paddr; + xen_pfn_t sci_shmem_gfn; } libxl__domain_build_state; _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..ba200407da 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -4,6 +4,7 @@ * Copyright (c) 2012, Citrix Systems */ +#include #include #include #include @@ -175,6 +176,20 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d, return rc; } + case XEN_DOMCTL_add_sci_device: + { + int rc; + struct dt_device_node *dev; + + rc = dt_find_node_by_gpath(domctl->u.sci_device_op.path, + domctl->u.sci_device_op.size, + &dev); + if ( rc ) + return rc; + + return sci_add_dt_device(d, dev); + } + default: { int rc; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index b85e6170b0..671c72c3e8 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1177,6 +1177,13 @@ struct xen_domctl_vmtrace_op { #define XEN_DOMCTL_vmtrace_get_option 5 #define XEN_DOMCTL_vmtrace_set_option 6 }; + +/* XEN_DOMCTL_add_sci_device: set sci device permissions */ +struct xen_domctl_sci_device_op { + uint32_t size; /* Length of the path */ + XEN_GUEST_HANDLE_64(char) path; /* path to the device tree node */ +}; + typedef struct xen_domctl_vmtrace_op xen_domctl_vmtrace_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_vmtrace_op_t); @@ -1265,6 +1272,7 @@ struct xen_domctl { #define XEN_DOMCTL_get_cpu_policy 82 #define XEN_DOMCTL_set_cpu_policy 83 #define XEN_DOMCTL_vmtrace_op 84 +#define XEN_DOMCTL_add_sci_device 85 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1326,6 +1334,7 @@ struct xen_domctl { struct xen_domctl_psr_alloc psr_alloc; struct xen_domctl_vuart_op vuart_op; struct xen_domctl_vmtrace_op vmtrace_op; + struct xen_domctl_sci_device_op sci_device_op; uint8_t pad[128]; } u; };