From nobody Fri Nov 22 18:25:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1716591356; cv=pass; d=zohomail.com; s=zohoarc; b=EyAgAwJ9xrMnd0Gf3oWU+V9sUgHOerhyt5IwDx+Z2Az7n0q7VkpkYGs2OZfO6OpbaeJqL5B8um0diTjexqV09qsXN5VR0NuQf934BM+0jEYwId/dUZnc8O7Xyc1KApriAa+3TlfeWLULRjnFMAdLgnsHXHF6S5K8lv/jPXEQcFY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716591356; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kGJKl+YgAt+elTNKQCErwYXKgmqb2xKN/qNfttPWbAw=; b=WCqljTPtIhjFNyUzhJPg0gwFdsfyjuji+SjLVjPjri/lfh+QfF72YyFOtZa/hQIuW8ZJfbJW9gmM05rEqKOm582mWXLxyIb4KPJBJykokNAu2TkmspjBZpskPHr38Tp3SN7r/r2NY19vzdG4xg1Uh/0wF+VDa493hHfPBTR/Wek= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716591356346896.6670539170589; Fri, 24 May 2024 15:55:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.729966.1135340 (Exim 4.92) (envelope-from ) id 1sAdp4-0004ot-IV; Fri, 24 May 2024 22:55:38 +0000 Received: by outflank-mailman (output) from mailman id 729966.1135340; Fri, 24 May 2024 22:55:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdp4-0004og-Ec; Fri, 24 May 2024 22:55:38 +0000 Received: by outflank-mailman (input) for mailman id 729966; Fri, 24 May 2024 22:55:36 +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 1sAdp2-0003hQ-Po for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:55:36 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20601.outbound.protection.outlook.com [2a01:111:f403:2416::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b9ee1500-1a20-11ef-b4bb-af5377834399; Sat, 25 May 2024 00:55:34 +0200 (CEST) Received: from DS0PR17CA0007.namprd17.prod.outlook.com (2603:10b6:8:191::14) by DS0PR12MB6534.namprd12.prod.outlook.com (2603:10b6:8:c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Fri, 24 May 2024 22:55:30 +0000 Received: from DS3PEPF0000C37B.namprd04.prod.outlook.com (2603:10b6:8:191:cafe::fa) by DS0PR17CA0007.outlook.office365.com (2603:10b6:8:191::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36 via Frontend Transport; Fri, 24 May 2024 22:55:25 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF0000C37B.mail.protection.outlook.com (10.167.23.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 22:55:25 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 24 May 2024 17:55:24 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 24 May 2024 17:55:24 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 24 May 2024 17:55:23 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b9ee1500-1a20-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H0ZwdWwFHgIU2CPMt51i20GT77LOt4RDg0m3ViVoe+VbLR2+nwy2hqJMwpFO2IuUd6Ca/FGhpyHnEbjp1ogHiQPr7vB7SP8LWqc+AEkoMXGuJJorunMj/W7SP+9ekbG0L2wefMc3Rm/7qxWosBX/3fQ/F+sasNMBA6i9vNMc3EBLaKHRc4/uIN+9Gg5D+HNiSrt3TsoL8alcUa+yFJVOMGxBpUbRpK3WguMej4o/RJxNyG7A5fdAHmVYAB9dya0Zy9/OzECyRiqluOb3QtYtkbhPW6tA0CX1ch5rF7UkH3FEfZOE47NMfSu5CTtm8J4yrlL7hOtMDHGYp+L3NMhKfg== 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=kGJKl+YgAt+elTNKQCErwYXKgmqb2xKN/qNfttPWbAw=; b=Gt6IeM3OQ9OlNsZBJvR/YroCFBRM8YlaVUHqhTkdhLh9kI0G3RBF47rZlNUg7prCjaKDS0f27DJzOd8V72B/B2Gi+E79GY2NcGCzhwZ15s5+zrySnGA10L/NzsRLdtUX382X2hMeynof0XJUxhBLuxCbhRDiZE60JjxQA8m3O6+t1/M5u1Mihns8SFSsCN9IRWZnV47XE1xrPvorMUboTSvkfFNeaNmxO8g+vVtJwdmWpR2l4RX3l0+hQ8PmKzoQtTusOgrHks9ZE2HtLFYqoHrJQHiwgtK6IExDffab3tjVtiYbTcOz0f6SE7cfWvgA2Zc9SAGl9MXUXIFe/4UFhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGJKl+YgAt+elTNKQCErwYXKgmqb2xKN/qNfttPWbAw=; b=Kss64V5TJPeoTcxFJKrTeGpbOWUFId2KMI6M+sZsx5WXqRgqyQUu/GkXmFjVtywU99TzzsXOqWuPubE5lJlB0CuwpIhcvF7ImB5j05dr/34yTwK75zUOalGvL3Y4bbk8svTsNHNuhxJSPtsBgV1vWW2bLlEgTYVkLuXTIEOm6XM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Stefano Stabellini To: CC: , , , , , Henry Wang , Alec Kwapis , "Daniel P . Smith" , Stefano Stabellini Subject: [PATCH v4 2/4] xen/arm: Alloc XenStore page for Dom0less DomUs from hypervisor Date: Fri, 24 May 2024 15:55:20 -0700 Message-ID: <20240524225522.2878481-2-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C37B:EE_|DS0PR12MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b482132-61e9-491c-4234-08dc7c44996c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?b9wWaVUXtHuKsJimiwJE+gdixTUTt56rWyUww7V5ZOSjdNSw832v/fKtmPVp?= =?us-ascii?Q?saMupljRZ4Ou4H6ufSNAv7VOQEYsRSGM4VSwJC8gY5MWWf4ggYh3q4GTg9sK?= =?us-ascii?Q?zDZGWLrZ+wTB5BF5aURYCi38Gizq1drsgHNjzRKqaIDCSXWrSLFCPDaIWOt9?= =?us-ascii?Q?z0KfPI6XidMECWoYSyqHSKG1wkkJ5qNPrMiJEdld6eSLWLqfe0muqXHuzf2O?= =?us-ascii?Q?7/2Zx9B4SQqWstFaNernwQ4hil2zn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XWWyHqHYkx0Yph5tuJBblmtEzWF65PVxBVVn6uYVlZoKKGGedX6uIYknuqO?= =?us-ascii?Q?RrPkhwb8NJl86a1mgCk1fy5/FsZAb0I0sz7tBxpvSr3sP7oh9th7anzmlhtx?= =?us-ascii?Q?pOoppul0kdT/pdHSE75JhHt3+klpFcNtDoSf9JbialTPdnGooU+DDQtKgQgo?= =?us-ascii?Q?+AjB0/KOljPRli71sBwuIYOJ3brYMmnZg/ep6B9OeQMcXHT+VEQtJY7/hjw0?= =?us-ascii?Q?t5gfU+ko4gb8UD/iabrRIiG173er?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:55:25.2459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b482132-61e9-491c-4234-08dc7c44996c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF0000C37B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6534 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716591358393100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang There are use cases (for example using the PV driver) in Dom0less setup that require Dom0less DomUs start immediately with Dom0, but initialize XenStore later after Dom0's successful boot and call to the init-dom0less application. An error message can seen from the init-dom0less application on 1:1 direct-mapped domains: ``` Allocating magic pages memory.c:238:d0v0 mfn 0x39000 doesn't belong to d1 Error on alloc magic pages ``` The "magic page" is a terminology used in the toolstack as reserved pages for the VM to have access to virtual platform capabilities. Currently the magic pages for Dom0less DomUs are populated by the init-dom0less app through populate_physmap(), and populate_physmap() automatically assumes gfn =3D=3D mfn for 1:1 direct mapped domains. This cannot be true for the magic pages that are allocated later from the init-dom0less application executed in Dom0. For domain using statically allocated memory but not 1:1 direct-mapped, similar error "failed to retrieve a reserved page" can be seen as the reserved memory list is empty at that time. Since for init-dom0less, the magic page region is only for XenStore. To solve above issue, this commit allocates the XenStore page for Dom0less DomUs at the domain construction time. The PFN will be noted and communicated to the init-dom0less application executed from Dom0. To keep the XenStore late init protocol, set the connection status to XENSTORE_RECONNECT. Reported-by: Alec Kwapis Suggested-by: Daniel P. Smith Signed-off-by: Henry Wang Signed-off-by: Stefano Stabellini Reviewed-by: Michal Orzel --- xen/arch/arm/dom0less-build.c | 55 ++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 74f053c242..2963ecc0b3 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -10,6 +11,8 @@ #include #include =20 +#include + #include #include #include @@ -739,6 +742,53 @@ static int __init alloc_xenstore_evtchn(struct domain = *d) return 0; } =20 +#define XENSTORE_PFN_OFFSET 1 +static int __init alloc_xenstore_page(struct domain *d) +{ + struct page_info *xenstore_pg; + struct xenstore_domain_interface *interface; + mfn_t mfn; + gfn_t gfn; + int rc; + + if ( (UINT_MAX - d->max_pages) < 1 ) + { + printk(XENLOG_ERR "%pd: Over-allocation for d->max_pages by 1 page= .\n", + d); + return -EINVAL; + } + d->max_pages +=3D 1; + xenstore_pg =3D alloc_domheap_page(d, MEMF_bits(32)); + if ( xenstore_pg =3D=3D NULL && is_64bit_domain(d) ) + xenstore_pg =3D alloc_domheap_page(d, 0); + if ( xenstore_pg =3D=3D NULL ) + return -ENOMEM; + + mfn =3D page_to_mfn(xenstore_pg); + if ( !mfn_x(mfn) ) + return -ENOMEM; + + if ( !is_domain_direct_mapped(d) ) + gfn =3D gaddr_to_gfn(GUEST_MAGIC_BASE + + (XENSTORE_PFN_OFFSET << PAGE_SHIFT)); + else + gfn =3D gaddr_to_gfn(mfn_to_maddr(mfn)); + + rc =3D guest_physmap_add_page(d, gfn, mfn, 0); + if ( rc ) + { + free_domheap_page(xenstore_pg); + return rc; + } + + d->arch.hvm.params[HVM_PARAM_STORE_PFN] =3D gfn_x(gfn); + interface =3D map_domain_page(mfn); + interface->connection =3D XENSTORE_RECONNECT; + unmap_domain_page(interface); + + return 0; +} + static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { @@ -839,7 +889,10 @@ static int __init construct_domU(struct domain *d, rc =3D alloc_xenstore_evtchn(d); if ( rc < 0 ) return rc; - d->arch.hvm.params[HVM_PARAM_STORE_PFN] =3D ~0ULL; + + rc =3D alloc_xenstore_page(d); + if ( rc < 0 ) + return rc; } =20 return rc; --=20 2.25.1