From patchwork Sat May 11 00:56:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13662158 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 BB139C25B78 for ; Sat, 11 May 2024 00:56:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720146.1123231 (Exim 4.92) (envelope-from ) id 1s5b2P-00087j-9w; Sat, 11 May 2024 00:56:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720146.1123231; Sat, 11 May 2024 00:56:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5b2P-00086q-58; Sat, 11 May 2024 00:56:33 +0000 Received: by outflank-mailman (input) for mailman id 720146; Sat, 11 May 2024 00:56:31 +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 1s5b2N-0007p5-CT for xen-devel@lists.xenproject.org; Sat, 11 May 2024 00:56:31 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20601.outbound.protection.outlook.com [2a01:111:f403:2418::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4cb18fb0-0f31-11ef-909d-e314d9c70b13; Sat, 11 May 2024 02:56:29 +0200 (CEST) Received: from PH8PR07CA0047.namprd07.prod.outlook.com (2603:10b6:510:2cf::10) by DM6PR12MB4218.namprd12.prod.outlook.com (2603:10b6:5:21b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.54; Sat, 11 May 2024 00:56:22 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2cf:cafe::cb) by PH8PR07CA0047.outlook.office365.com (2603:10b6:510:2cf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.54 via Frontend Transport; Sat, 11 May 2024 00:56:21 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Sat, 11 May 2024 00:56:20 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 10 May 2024 19:56:19 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 10 May 2024 19:56:19 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 10 May 2024 19:56:16 -0500 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: 4cb18fb0-0f31-11ef-909d-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=To37Un+0ohRQslENSwZeF92zxH4tKGvRGUqkAK7QMpuiaE3ww8wTNQdl6gAYuUGNoRrHyvaRF9eaoigbFEes0iKz7VKzje1ujcd/ZGhQ/E33K3+2ZtUdignTBE2BlObDZ/8j1u0gn5fGCPg7hzPoj9RuRdjHfgwlj9h8zxXtrGEvOS6DDfXOGOTXk0DKY1bQnVWrReUKHKeTTJSQhjVgLyzl0F8M/A5D2Lz4arRsuWSwg/P41tdKayL4zBnd0e4/vN+G97p40aX6ai2bWw9H9VXoua8vIS3wiGWq+q98vvs77OU/X4sVLKQtdzVvPjIH75Z2ejmp9eu84Fq+5BLrZA== 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=Lk6GKSsCklZm9WOlSrI/19kZkT/LFQhP7ioFjW6GXdg=; b=ho15/4FRrUErZvFa9XSuYtv8qMWNnIgRZea+0B6lWGNZCm4AEOxAVez8He5LpGhOmCe/H6OCvY4e+I2w4noUA+8PQzN5SMQcue2/fxOtx6bH08jaH/tChSqNVd9xBAJdOKkvyr3cCbQtlonGgoqI+3n0REhc7JODKw6lL48MuCv7is/f9vkO/vRhhA91MCW8SK9hU6dFuwiFDR/qfWHPl6kHW5YWit7y8YpULPFua04sNnsPeAx6vFpKN5uRFUlit9FsOD5/4kKbXVBzAvwXJ5jZf7IAvPOiTj0vjjDoOzq9lbVRRKgMtPJhuVi4lNLaNrTcfxvC0Jq1IzL9nQuaHg== 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=Lk6GKSsCklZm9WOlSrI/19kZkT/LFQhP7ioFjW6GXdg=; b=qOt+r6YCYQKvqUsUzxef8ks0l12kYD4YzyMIDC2fMTcmn+umm3BUXrHppPcelQdDW81/o0crCaRHaFvfmPLDQHhu8VHWc/AkAOM9fOemuktnujdw18zqcBQp4nftz8aKntowp7VkjXmAWamf7INQjFhn5BKJ1qwB/p1g4p1rnK8= 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 (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=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Henry Wang , Anthony PERARD , Juergen Gross , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Alec Kwapis , "Daniel P . Smith" Subject: [PATCH v2 1/4] xen/arm: Alloc hypervisor reserved pages as magic pages for Dom0less DomUs Date: Sat, 11 May 2024 08:56:08 +0800 Message-ID: <20240511005611.83125-2-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511005611.83125-1-xin.wang2@amd.com> References: <20240511005611.83125-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|DM6PR12MB4218:EE_ X-MS-Office365-Filtering-Correlation-Id: 10690689-d50c-4993-d9fb-08dc71552bfc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|1800799015|376005; X-Microsoft-Antispam-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d7zcSjilQTul0UKQu7gHXBnSyC6CRqKjTzYvmJy3WU7fHzUGDy6uBZsLxSVTmufJ55aW+fRCdChfhCZQdf5hL6KtV1MCeKBAAce2UCnK9H/8vLcCdmRpzrEW3W/GhBKUe0A8NZygCnKDO2pMyviDPYGnvVfUt2o5aXPtnENUHtwAKgp7VXqRro/UjSgqPJhm56No8joZ12S0E5SBN7Yv/Fllcl48Q0z5xcE2z46SfgZkFc2ehXectRlpo2mUzEH7+z4nBRApbnhPtEmWsUByBNubAC7gmhm570OtqI06MNp0hWPfSCXszj1mdGKMx01mA/Zj2yEcC X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400017)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2024 00:56:20.2980 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10690689-d50c-4993-d9fb-08dc71552bfc 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4218 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 == 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. To solve above issue, this commit allocates hypervisor reserved pages (currently used as the magic pages) for Arm Dom0less DomUs at the domain construction time. The base address/PFN of the region will be noted and communicated to the init-dom0less application in Dom0. Reported-by: Alec Kwapis Suggested-by: Daniel P. Smith Signed-off-by: Henry Wang --- v2: - Reword the commit msg to explain what is "magic page" and use generic terminology "hypervisor reserved pages" in commit msg. (Daniel) - Also move the offset definition of magic pages. (Michal) - Extract the magic page allocation logic to a function. (Michal) --- tools/libs/guest/xg_dom_arm.c | 6 ------ xen/arch/arm/dom0less-build.c | 32 ++++++++++++++++++++++++++++++++ xen/include/public/arch-arm.h | 6 ++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/tools/libs/guest/xg_dom_arm.c b/tools/libs/guest/xg_dom_arm.c index 2fd8ee7ad4..8c579d7576 100644 --- a/tools/libs/guest/xg_dom_arm.c +++ b/tools/libs/guest/xg_dom_arm.c @@ -25,12 +25,6 @@ #include "xg_private.h" -#define NR_MAGIC_PAGES 4 -#define CONSOLE_PFN_OFFSET 0 -#define XENSTORE_PFN_OFFSET 1 -#define MEMACCESS_PFN_OFFSET 2 -#define VUART_PFN_OFFSET 3 - #define LPAE_SHIFT 9 #define PFN_4K_SHIFT (0) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 74f053c242..4b96ddd9ce 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -739,6 +739,34 @@ static int __init alloc_xenstore_evtchn(struct domain *d) return 0; } +static int __init alloc_magic_pages(struct domain *d) +{ + struct page_info *magic_pg; + mfn_t mfn; + gfn_t gfn; + int rc; + + d->max_pages += NR_MAGIC_PAGES; + magic_pg = alloc_domheap_pages(d, get_order_from_pages(NR_MAGIC_PAGES), 0); + if ( magic_pg == NULL ) + return -ENOMEM; + + mfn = page_to_mfn(magic_pg); + if ( !is_domain_direct_mapped(d) ) + gfn = gaddr_to_gfn(GUEST_MAGIC_BASE); + else + gfn = gaddr_to_gfn(mfn_to_maddr(mfn)); + + rc = guest_physmap_add_pages(d, gfn, mfn, NR_MAGIC_PAGES); + if ( rc ) + { + free_domheap_pages(magic_pg, get_order_from_pages(NR_MAGIC_PAGES)); + return rc; + } + + return 0; +} + static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { @@ -840,6 +868,10 @@ static int __init construct_domU(struct domain *d, if ( rc < 0 ) return rc; d->arch.hvm.params[HVM_PARAM_STORE_PFN] = ~0ULL; + + rc = alloc_magic_pages(d); + if ( rc < 0 ) + return rc; } return rc; diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 289af81bd6..186520d01f 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -476,6 +476,12 @@ typedef uint64_t xen_callback_t; #define GUEST_MAGIC_BASE xen_mk_ullong(0x39000000) #define GUEST_MAGIC_SIZE xen_mk_ullong(0x01000000) +#define NR_MAGIC_PAGES 4 +#define CONSOLE_PFN_OFFSET 0 +#define XENSTORE_PFN_OFFSET 1 +#define MEMACCESS_PFN_OFFSET 2 +#define VUART_PFN_OFFSET 3 + #define GUEST_RAM_BANKS 2 /* From patchwork Sat May 11 00:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13662155 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 5D72DC25B75 for ; Sat, 11 May 2024 00:56:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720145.1123227 (Exim 4.92) (envelope-from ) id 1s5b2P-00084W-15; Sat, 11 May 2024 00:56:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720145.1123227; Sat, 11 May 2024 00:56:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5b2O-00084N-Tt; Sat, 11 May 2024 00:56:32 +0000 Received: by outflank-mailman (input) for mailman id 720145; Sat, 11 May 2024 00:56:31 +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 1s5b2N-0007p5-3Y for xen-devel@lists.xenproject.org; Sat, 11 May 2024 00:56:31 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2416::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4c44d00c-0f31-11ef-909d-e314d9c70b13; Sat, 11 May 2024 02:56:29 +0200 (CEST) Received: from SJ0PR05CA0136.namprd05.prod.outlook.com (2603:10b6:a03:33d::21) by BL3PR12MB6452.namprd12.prod.outlook.com (2603:10b6:208:3bb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.49; Sat, 11 May 2024 00:56:24 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:a03:33d:cafe::e7) by SJ0PR05CA0136.outlook.office365.com (2603:10b6:a03:33d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.18 via Frontend Transport; Sat, 11 May 2024 00:56:23 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Sat, 11 May 2024 00:56:23 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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, 10 May 2024 19:56:22 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 10 May 2024 19:56:22 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 10 May 2024 19:56:19 -0500 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: 4c44d00c-0f31-11ef-909d-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M/GTqvrUh3lG7vVOODAiuRg5gsaArpYy5zp/D0mu5yZ1/RudkWsk9y5k/zKjMRuiVxcZmSdgpXQy1CP4vWIFnVGUAWMMDEbPxzeEJU9R9xk8XvG5R7zMxY96NOMJeI3BZzVECwJ90oQhCLJIWPFlvoKMt+EW5/QQCGQqhO1OsrKISo2mmoq2V1DfMcA+0WneXI6603qySECDsXZdR2lUTd+c3VbXgKRktzWrQc8SX/FVPE8brgVhvVThSxh6u5U3hVhS0NZX1G8H54k4WvBF5PHdqwvczry/eionr/HapQOTA1zJZ0SVndvbT0deQ/14iiXGi/t3hktVwywb+agAXQ== 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=8pDtPG/gwtKzswtOqvdxKDHnF7RDE7VlIypy2jSq22o=; b=B5lhSGdWmNKbjWDV7srQNFt4QaBPG/CT6c0Jweo5eJrSV/TJoeetYN9TzBDserlSrme+IfrdElCy72UPml+8iHA8Ox0sHBLtX1bvIfjmfuStkuty5daS4daEoJGRsYITSydE/T7zX5gUE/FylwSiskfgj9UH1fiR/3Va+S+Bmx/ih7HSLpOOg5OvJfHiy2wfutNY9/MgEM2vlIf3yEofoSoKVsE6bnHoO8mZ5NgNGH0d2ES1w2hKXXYk0nuctveeXpVBwYn1GZPPf1Mk+A8CFGM4r55FoVCPYB+Jh/VJ2S1e5yeYWTDg/HOi0Dr0CfgIQFlkEmVv9s4VGHOE3YGl6A== 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=8pDtPG/gwtKzswtOqvdxKDHnF7RDE7VlIypy2jSq22o=; b=Wfc0LLInNkZZiaLcaMQ4zg6Dh+CViHAkWJo87ZadO0j0kYBfrHMTGuPCqjm33V8nGegM4rhnyp+lVRTnVtmdIYiQbS5Uv0wcyObCYJi8qciSffhj+CC6hTHvsbkjYn5Irat/1IBmcir36FfQlggVH+aZ7294FaQx8QW0EN7uOGE= 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 (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: Henry Wang To: CC: Henry Wang , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , George Dunlap , "Jan Beulich" , Alec Kwapis Subject: [PATCH v2 2/4] xen/arm: Add new HVM_PARAM_HV_RSRV_{BASE_PFN,SIZE} keys in HVMOP Date: Sat, 11 May 2024 08:56:09 +0800 Message-ID: <20240511005611.83125-3-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511005611.83125-1-xin.wang2@amd.com> References: <20240511005611.83125-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001C8:EE_|BL3PR12MB6452:EE_ X-MS-Office365-Filtering-Correlation-Id: 74eccd9c-6c6b-419a-0958-08dc71552dcd 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: kg+ZdbpbSZavsTg+6Plfd2hHqc2S9v5hb4o/i4O/w9JNQtZEAEUipThT+/LlXFqH04Z3YJaQhY4aNs1da2EsVH2VIh/ESpYRrRgGLt9rQPW65/NZ5Juq/G7OXx/qfej/cmRnLXL2H8696v+RSAQV7J5b/CJanexpwb+s+N2XXf+vVbwmV1/SB8j2fsArazyY5INhq2KA+XX9k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yHmzsKr/MDMlCYEodmfGjuqf+D8nPOQ7hrXgWjIuLeYTwb6Iue24FTpHmQXBzCex6HyVtrjvANn8AEuMRWvv7jBWUdPEXj12l8q+UMv4w= 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: 11 May 2024 00:56:23.2932 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74eccd9c-6c6b-419a-0958-08dc71552dcd 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: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6452 For use cases such as Dom0less PV drivers, a mechanism to communicate Dom0less DomU's static data with the runtime control plane (Dom0) is needed. Since on Arm HVMOP is already the existing approach to address such use cases (for example the allocation of HVM_PARAM_CALLBACK_IRQ), add new HVMOP keys HVM_PARAM_HV_RSRV_{BASE_PFN,SIZE} for storing the hypervisor reserved pages region base PFN and size. Currently, the hypervisor reserved pages region is used as the Arm Dom0less DomU guest magic pages region. Therefore protect the HVMOP keys with "#if defined(__arm__) || defined(__aarch64__)". The values will be set at Dom0less DomU construction time after Dom0less DomU's magic pages region has been allocated. Reported-by: Alec Kwapis Signed-off-by: Henry Wang --- v2: - Rename the HVMOP keys to HVM_PARAM_HV_RSRV_{BASE_PFN,SIZE}. (Daniel) - Add comment on top of HVM_PARAM_HV_RSRV_{BASE_PFN,SIZE} to describe its usage. Protect them with #ifdef. (Daniel, Jan) --- xen/arch/arm/dom0less-build.c | 3 +++ xen/arch/arm/hvm.c | 2 ++ xen/include/public/hvm/params.h | 11 ++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 4b96ddd9ce..5bb53ebb47 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -764,6 +764,9 @@ static int __init alloc_magic_pages(struct domain *d) return rc; } + d->arch.hvm.params[HVM_PARAM_HV_RSRV_BASE_PFN] = gfn_x(gfn); + d->arch.hvm.params[HVM_PARAM_HV_RSRV_SIZE] = NR_MAGIC_PAGES; + return 0; } diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index 0989309fea..949d804f8b 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -55,6 +55,8 @@ static int hvm_allow_get_param(const struct domain *d, unsigned int param) case HVM_PARAM_STORE_EVTCHN: case HVM_PARAM_CONSOLE_PFN: case HVM_PARAM_CONSOLE_EVTCHN: + case HVM_PARAM_HV_RSRV_BASE_PFN: + case HVM_PARAM_HV_RSRV_SIZE: return 0; /* diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h index a22b4ed45d..337f5b0bf8 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -296,6 +296,15 @@ #define XEN_HVM_MCA_CAP_LMCE (xen_mk_ullong(1) << 0) #define XEN_HVM_MCA_CAP_MASK XEN_HVM_MCA_CAP_LMCE -#define HVM_NR_PARAMS 39 +/* + * Base PFN and number of pages of the hypervisor reserved pages region. + * Currently only used on Arm for Dom0less DomUs as guest magic pages region. + */ +#if defined(__arm__) || defined(__aarch64__) +#define HVM_PARAM_HV_RSRV_BASE_PFN 39 +#define HVM_PARAM_HV_RSRV_SIZE 40 +#endif + +#define HVM_NR_PARAMS 41 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ From patchwork Sat May 11 00:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13662154 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 DD3CBC25B10 for ; Sat, 11 May 2024 00:56:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720144.1123216 (Exim 4.92) (envelope-from ) id 1s5b2N-0007pW-LS; Sat, 11 May 2024 00:56:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720144.1123216; Sat, 11 May 2024 00:56:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5b2N-0007pP-ID; Sat, 11 May 2024 00:56:31 +0000 Received: by outflank-mailman (input) for mailman id 720144; Sat, 11 May 2024 00:56:30 +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 1s5b2M-0007ah-BE for xen-devel@lists.xenproject.org; Sat, 11 May 2024 00:56:30 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20601.outbound.protection.outlook.com [2a01:111:f403:2405::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4c0c8333-0f31-11ef-b4bb-af5377834399; Sat, 11 May 2024 02:56:28 +0200 (CEST) Received: from PH8P222CA0004.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:2d7::34) by DM4PR12MB5772.namprd12.prod.outlook.com (2603:10b6:8:63::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.49; Sat, 11 May 2024 00:56:25 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:510:2d7:cafe::2f) by PH8P222CA0004.outlook.office365.com (2603:10b6:510:2d7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.54 via Frontend Transport; Sat, 11 May 2024 00:56:24 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Sat, 11 May 2024 00:56:24 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 10 May 2024 19:56:24 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 10 May 2024 19:56:23 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 10 May 2024 19:56:22 -0500 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: 4c0c8333-0f31-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpPUu7rbvrb9YeD0Nu9zccpeG6gNCszERa4y0u9Gum8d+cSe8vR1tqI5L8Fo/aQE+EnlwQv1KKLfsmVArumYWjUJKeuC4/nRj03+JHFhCGihAY3xQn7UJX4Y6+y+l4Cv4RoBZopmYo1lZ3vKNIMpvS/x5IxZsTIMd2URAmR1IRk4l204//HLwJO3ktOHr5nOqBozmKSCjDeZ3tBH9Ng4SlI4ChBzy0Obuk8puIw1hGeT8qru5MStyFh9J5cZYpe3IBeDeZjQPviuEYT9+VggxaeAHdvM3cUE470QEUPIXB5958e004BY+fz5PI1Om+SXZI8oZObGOXIZp6d765KeYg== 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=L0sVjO8e/hTL6PfGKicWPBSowcKLwyxV2IFDm4hHQWE=; b=X27UtIozaBMJ0TTME8eUva2ZwMW1Fs1Ywm2Ar4GkqbxIY3vR29fo0tnZNH7AVX3eHqy7ZWxHSqjNk6UrboIWxQxvzIHvXLHnmInKIU3uWZY+3n5K7yBlZND12Fjf2BDhIxNxy5ztW7Wnlah5/JON46or+n7+tc6agbkCqhHvC4tJOhD3ddlQNMw+PwIhlpa96N9dx0M10ZDAXbAiFGxexmrV8JjVuTAfYi66h/61FLqrJDZjgpx2t+EYuot2w64+tZPvi2J7r/hfPXPrERI9ECb2rS98IhgDenw/3U0V36MTogI17u/srJP5JyHmRQ7puEt7nnFjFj16hynddfBzaA== 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=L0sVjO8e/hTL6PfGKicWPBSowcKLwyxV2IFDm4hHQWE=; b=WAvsK2mtMhjRbraEDoH6ipsMdT12LguyMwV0mRGl3WB4ritF6TX5VMapc5OvBZVoG6/40+AM2vZ4yqRy15NBk0MKjd3j/CYLJ7CdEF4JrQfkS7KBogzGaOWpKsWxBHMqcXdTbfpSmbpp1H/bnti/oKmDcEnmrc6dR1oYRiCA0aU= 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 (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=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Henry Wang , Anthony PERARD , Alec Kwapis Subject: [PATCH v2 3/4] tools/init-dom0less: Avoid hardcoding GUEST_MAGIC_BASE Date: Sat, 11 May 2024 08:56:10 +0800 Message-ID: <20240511005611.83125-4-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511005611.83125-1-xin.wang2@amd.com> References: <20240511005611.83125-1-xin.wang2@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|DM4PR12MB5772:EE_ X-MS-Office365-Filtering-Correlation-Id: eb9aa798-a039-41f7-ba48-08dc71552e9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|36860700004|1800799015|376005; X-Microsoft-Antispam-Message-Info: W/Odr8W15mADA2aUJJx+XWOBlnokmdylAOH5p0E6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eZeapwRcAxaZSiiXR3dOMbkG7x3ah6qY0lNB6gPfZIW31GIOhKkxUNjcPzH8P2ZnwPi0wqtr3/EF4aBnpxPS9qcaL12yxMvlSy0dTSZNjOTASqenbj3y+iIUIdjmddIxq/cDwzcPviSGUhnIdIgpobIJNgMGSjK0reYWWUVTP56ZgAHg20awFi3Ld74ZT5LLD0/jjAyMHrzoHCboyhWrJy3uB6pXt8v14QG+RqeTG7yCdxb5G1H8yMoqdPwyqJxCq12X+/JG5YjsNXZMcFW9lIZAaP X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2024 00:56:24.6921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb9aa798-a039-41f7-ba48-08dc71552e9d 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5772 Currently the GUEST_MAGIC_BASE in the init-dom0less application is hardcoded, which will lead to failures for 1:1 direct-mapped Dom0less DomUs. Since the guest magic region is now allocated from the hypervisor, instead of hardcoding the guest magic pages region, use xc_hvm_param_get() to get the guest magic region PFN, and based on that the XenStore PFN can be calculated. Also, we don't need to set the max mem anymore, so drop the call to xc_domain_setmaxmem(). Rename the alloc_xs_page() to get_xs_page() to reflect the changes. Take the opportunity to do some coding style improvements when possible. Reported-by: Alec Kwapis Signed-off-by: Henry Wang --- v2: - Update HVMOP keys name. --- tools/helpers/init-dom0less.c | 40 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index fee93459c4..04039a2a66 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -19,24 +19,20 @@ #define XENSTORE_PFN_OFFSET 1 #define STR_MAX_LENGTH 128 -static int alloc_xs_page(struct xc_interface_core *xch, - libxl_dominfo *info, - uint64_t *xenstore_pfn) +static int get_xs_page(struct xc_interface_core *xch, libxl_dominfo *info, + uint64_t *xenstore_pfn) { int rc; - const xen_pfn_t base = GUEST_MAGIC_BASE >> XC_PAGE_SHIFT; - xen_pfn_t p2m = (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET; + xen_pfn_t magic_base_pfn; - rc = xc_domain_setmaxmem(xch, info->domid, - info->max_memkb + (XC_PAGE_SIZE/1024)); - if (rc < 0) - return rc; - - rc = xc_domain_populate_physmap_exact(xch, info->domid, 1, 0, 0, &p2m); - if (rc < 0) - return rc; + rc = xc_hvm_param_get(xch, info->domid, HVM_PARAM_HV_RSRV_BASE_PFN, + &magic_base_pfn); + if (rc < 0) { + printf("Failed to get HVM_PARAM_HV_RSRV_BASE_PFN\n"); + return 1; + } - *xenstore_pfn = base + XENSTORE_PFN_OFFSET; + *xenstore_pfn = magic_base_pfn + XENSTORE_PFN_OFFSET; rc = xc_clear_domain_page(xch, info->domid, *xenstore_pfn); if (rc < 0) return rc; @@ -100,6 +96,7 @@ static bool do_xs_write_vm(struct xs_handle *xsh, xs_transaction_t t, */ static int create_xenstore(struct xs_handle *xsh, libxl_dominfo *info, libxl_uuid uuid, + xen_pfn_t xenstore_pfn, evtchn_port_t xenstore_port) { domid_t domid; @@ -145,8 +142,7 @@ static int create_xenstore(struct xs_handle *xsh, rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%"PRIu64, info->current_memkb); if (rc < 0 || rc >= STR_MAX_LENGTH) return rc; - rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld", - (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET); + rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%"PRIu_xen_pfn, xenstore_pfn); if (rc < 0 || rc >= STR_MAX_LENGTH) return rc; rc = snprintf(xenstore_port_str, STR_MAX_LENGTH, "%u", xenstore_port); @@ -245,9 +241,9 @@ static int init_domain(struct xs_handle *xsh, if (!xenstore_evtchn) return 0; - /* Alloc xenstore page */ - if (alloc_xs_page(xch, info, &xenstore_pfn) != 0) { - printf("Error on alloc magic pages\n"); + /* Get xenstore page */ + if (get_xs_page(xch, info, &xenstore_pfn) != 0) { + printf("Error on getting xenstore page\n"); return 1; } @@ -278,13 +274,11 @@ static int init_domain(struct xs_handle *xsh, if (rc < 0) return rc; - rc = create_xenstore(xsh, info, uuid, xenstore_evtchn); + rc = create_xenstore(xsh, info, uuid, xenstore_pfn, xenstore_evtchn); if (rc) err(1, "writing to xenstore"); - rc = xs_introduce_domain(xsh, info->domid, - (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET, - xenstore_evtchn); + rc = xs_introduce_domain(xsh, info->domid, xenstore_pfn, xenstore_evtchn); if (!rc) err(1, "xs_introduce_domain"); return 0; From patchwork Sat May 11 00:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13662156 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 B22CFC25B77 for ; Sat, 11 May 2024 00:56:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.720147.1123247 (Exim 4.92) (envelope-from ) id 1s5b2S-00009U-Ih; Sat, 11 May 2024 00:56:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 720147.1123247; Sat, 11 May 2024 00:56:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s5b2S-00009L-FX; Sat, 11 May 2024 00:56:36 +0000 Received: by outflank-mailman (input) for mailman id 720147; Sat, 11 May 2024 00:56:35 +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 1s5b2R-0007p5-Bz for xen-devel@lists.xenproject.org; Sat, 11 May 2024 00:56:35 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2414::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4fc6ea7f-0f31-11ef-909d-e314d9c70b13; Sat, 11 May 2024 02:56:34 +0200 (CEST) Received: from SJ0PR05CA0145.namprd05.prod.outlook.com (2603:10b6:a03:33d::30) by PH7PR12MB7282.namprd12.prod.outlook.com (2603:10b6:510:209::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.51; Sat, 11 May 2024 00:56:27 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:a03:33d:cafe::95) by SJ0PR05CA0145.outlook.office365.com (2603:10b6:a03:33d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.13 via Frontend Transport; Sat, 11 May 2024 00:56:27 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001CD.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Sat, 11 May 2024 00:56:26 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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, 10 May 2024 19:56:25 -0500 Received: from henry-MS-7D54.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 10 May 2024 19:56:24 -0500 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: 4fc6ea7f-0f31-11ef-909d-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f3Sxtlr7qzg+ofD7hAOzn8/acXan2BrrW+i0wY7aGB4z2jCyPnAo8+fGKtddzITFU+iHnCvYXEtXpZsdwHjB3KOK40XsMRMJHGVOIWO/TIdhvrsAxtZZYZ0rIsIAqbQC++1MiwrVh+v8Wvs6OrSIn1AmpWY4yACMQruCJ9KbTeOX6vEzpSytFCYBmLXXdRHKn8y9MduPA/JZvjA2+kgg/3UKqcdG5NzzD7lsIEJO00o3eJPvsLQgbRY/3FKEZpQHx4Po9tcJY1ALkfXgdILDAYJhaJQYkLduro95Xn2Ta+vIQNnrAExCERuzGJevpt4oOrseZqoWSYNbe4+YAcrsvw== 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=+g1Sl34/9TCXkY67P68n4Fomec7VFpUiwGKx0eZZ7xY=; b=MsnwKKF3OPBOKJ7brfJpSkEMUCJlEAdHCm7Wg5PILGLPbzgVNvd9veEms0tZ7RSyDjNurUHlQQ8kXiqHJ0O4mR9lsxCD6ZgkN6ZkNbQnHno6B/f8ZD2/zZRQrwDV/TbBjZmNGwD6ylHsdn/F7okvYwjEgUOgr1SZYigyiNuw1LdsNTPatiBCdegrwFRa5UDjkbd5mcTp3DLaHjJdQ35sfPU9cumAZteqNUoU5fcGdPmgkPEIjhj8LVk7bLMBnSgVwBTKBj7pJzj5Jg0capCLI6O5CbVp3IPuXI6DPsP9cXWOBmBkhN2Wz3BK3sZx5/uqg0vvhAXVwBSl46g8lvcRwQ== 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=+g1Sl34/9TCXkY67P68n4Fomec7VFpUiwGKx0eZZ7xY=; b=XPf8OZjnV0QsIPQ3m40wszIuwTDYYNdRazqqP3pjZ8kq/HDrzCJc79LPiSWNt0bapni7e6/eGFj4uvUG1rsqwTL/ZwqHwC0z8OSRE2jSqUpDX9/gIqP2k4EmJB2dmpZEwi/MFO9sjxreJNoK6Ch8JVbFK0JpT0owUN4ULaCid4o= 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 (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: Henry Wang To: CC: Henry Wang , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v2 4/4] docs/features/dom0less: Update the late XenStore init protocol Date: Sat, 11 May 2024 08:56:11 +0800 Message-ID: <20240511005611.83125-5-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511005611.83125-1-xin.wang2@amd.com> References: <20240511005611.83125-1-xin.wang2@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CD:EE_|PH7PR12MB7282:EE_ X-MS-Office365-Filtering-Correlation-Id: d4e71e78-47a3-48ec-c3b6-08dc71552fdd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|82310400017|376005; X-Microsoft-Antispam-Message-Info: iL5IOhV4p7cUoNSGwwrJPaPMZsYsgELpNwSHCUdF4oR08an2u887BiiX7zG+wiIV0t3ZBw9D1zzH6Mup4ehOCdXoGwAQq4W4CAcaYHM57rv77WeG6dV/pZ5udRhj56g7NhrJujfw3OSA85KlwdX66f1KGEA7d3UPSDxNKrvqAUTYEknaoxg+XH3pIFOD2bFE5Jf9C/HCX+KUAiOF2FmEv7Q8zaOphowPU+fRaQfUxDoY91Hz1nTLiNCqPl7uVXP+OLE5vLSYeTr48CviwEiXmc+YQ4U4E4nLWqGnluCRib+aw7Gw7A1zQvJof8JTyZpclC/gUyzUcZZ7c5+PZV1ZKGoJCTWtVzLw0MCAMfpN8GPenZhb7rJnHMLrj9pMyqDPVDjYnhoz0g9TKhxIMhFEsBh1zkejFq59nc+04fxEzyxkTf63ulGRrZUdb9gP61pQ99Yn1xSKwkpq3IT/l74Urx2ZYo/Op8C6wIOLQOcY3PwHdhY/2NfSjr+IBbV8oX01M/erVA1AOXF0zhyexLu5GauP/LqqK3qSj6CF707UcwFuCXklm0uXNICeerOFwn2hXmmFRTBHahsMAwZKZ0CLFtYTHBhUPQ2EfUiTDkyO/y5WzCO4K9oXKuLUPbrNoitToqaZgavq0Vjww9TP49+TqjigrUR/kybx7WhFlRy8gQrdFXA5Kuf/AQaQB2JuHI9lELoBl3IxQflXjJI46CknW3jGsw/74ivZsooFOwZMTnw6AWjcDoec64/8hIvLr4A6LRupJ+Aayw0jjRIvMDgtWvJzq+ks1Iv/2Fv8y6DlprZglKcwc/CFGcS3RtR5mVDhK8rw0wEtV1FeaGdRdNGHH/qZlYWk9o3iCIEFicd6YTolmAa6YIc6UPMDLdtWuIy5jGbz+yhikmBTfu0hl5dWevJjycMAJIdtr6T2QNiUxwF9nb6+Oky1vIpRUj9erWW0G7buIeeBjjfLgME79EK5KwDOzPe5wuYRw1WYdLrC4xeoKaUUnEpGhgfkCnOcF9tbE3mc+Shgy0OdxL+SsJBIXnHkpY9+dPtrJfaPlIPo699PIPrvL3ong02bu2sq2CIkrHLZ4upqyNHMnWWqifYWmQgalrLoPj9DhzzkdAIbz7CqYfw3Cy5yiVFQjPm9fEc/1QOyC+L7baILcjsHcanXpmpqWixnDL8GV4toymZwt7B0tx969JKH/X44XoDRLAX9ata+Or1CH9dB871YByHUUGcbaD/YL/j8dotuUDxMyMcuP36WJcWJQFnnnIXQYv14C8LYhauJEq1E7hMq799gDQ/wp1vuMols8/DchXr4FiU5evfjwJlgUeT9t/J6SukBbnmjQRST1Lh/wsEUmpUb8H6Wed99EdebPkgH4bGuYStkNoInVnWfCEqJID9ze1at 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)(1800799015)(36860700004)(82310400017)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2024 00:56:26.7739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4e71e78-47a3-48ec-c3b6-08dc71552fdd 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: SJ5PEPF000001CD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7282 With the new allocation strategy of Dom0less DomUs magic page region, update the documentation of the late XenStore init protocol accordingly. Signed-off-by: Henry Wang --- v2: - New patch. --- docs/features/dom0less.pandoc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/features/dom0less.pandoc b/docs/features/dom0less.pandoc index 725afa0558..137e6b618b 100644 --- a/docs/features/dom0less.pandoc +++ b/docs/features/dom0less.pandoc @@ -110,8 +110,9 @@ hotplug PV drivers to dom0less guests. E.g. xl network-attach domU. The implementation works as follows: - Xen allocates the xenstore event channel for each dom0less domU that has the "xen,enhanced" property, and sets HVM_PARAM_STORE_EVTCHN -- Xen does *not* allocate the xenstore page and sets HVM_PARAM_STORE_PFN - to ~0ULL (invalid) +- Xen allocates the hypervisor reserved pages region (the xenstore page + is part of it) and sets HVM_PARAM_HV_RSRV_{BASE_PFN,SIZE} accordingly. + Xen sets HVM_PARAM_STORE_PFN to ~0ULL (invalid). - Dom0less domU kernels check that HVM_PARAM_STORE_PFN is set to invalid - Old kernels will continue without xenstore support (Note: some old buggy kernels might crash because they don't check the validity of @@ -121,7 +122,8 @@ The implementation works as follows: channel (HVM_PARAM_STORE_EVTCHN) before continuing with the initialization - Once dom0 is booted, init-dom0less is executed: - - it allocates the xenstore shared page and sets HVM_PARAM_STORE_PFN + - it gets the xenstore shared page from HVM_PARAM_HV_RSRV_BASE_PFN + and sets HVM_PARAM_STORE_PFN - it calls xs_introduce_domain - Xenstored notices the new domain, initializes interfaces as usual, and sends an event channel notification to the domain using the xenstore