From nobody Fri Nov 22 14:20:39 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=1715916222; cv=pass; d=zohomail.com; s=zohoarc; b=fBi+N8i5y1BNt0W2WGXntxJCoC8/XqEpoOCfu/04+xgybR+/XK9zNtbYgKlYthrT7Joq5r+Z33xW0Z7r5Q/Q/2BnLEEVxAUG01Bvrf4WVdJcz7fJKrwNOVIQXQ3eC3Dw/7aaQcC0M87+oC/P+5X5MP5HLM64DfcU863RqN7FNa0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715916222; 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=d07nHhnz+E2r01WFGPEt/6CKVIk3TuRy1RIwAxzVZg8=; b=P3qIg1i6Q6xl6+8Jgz59ezDIo8VPeDiyfXVto/jOvCy3IXvVYaeRzPeIHZlnLom4C7xzDZo2ChWtNCN1ix9+VpdLY7xOGaaQKM7kBB71i5+va9HQDd6e0ZwrS/IYtG5bvyfNreRKc/tgjCqsXvxpqW06qnlBagzXMElL4tFGjCo= 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 1715916222641563.1562481506164; Thu, 16 May 2024 20:23:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.723785.1128865 (Exim 4.92) (envelope-from ) id 1s7oBv-0006ql-MP; Fri, 17 May 2024 03:23:31 +0000 Received: by outflank-mailman (output) from mailman id 723785.1128865; Fri, 17 May 2024 03:23: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 1s7oBv-0006qe-Jf; Fri, 17 May 2024 03:23:31 +0000 Received: by outflank-mailman (input) for mailman id 723785; Fri, 17 May 2024 03:23:29 +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 1s7oBt-0006l6-I6 for xen-devel@lists.xenproject.org; Fri, 17 May 2024 03:23:29 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20601.outbound.protection.outlook.com [2a01:111:f403:2417::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d34aecf3-13fc-11ef-b4bb-af5377834399; Fri, 17 May 2024 05:23:28 +0200 (CEST) Received: from PH7PR03CA0003.namprd03.prod.outlook.com (2603:10b6:510:339::8) by CH3PR12MB9283.namprd12.prod.outlook.com (2603:10b6:610:1cd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.30; Fri, 17 May 2024 03:23:23 +0000 Received: from SN1PEPF000252A1.namprd05.prod.outlook.com (2603:10b6:510:339:cafe::4f) by PH7PR03CA0003.outlook.office365.com (2603:10b6:510:339::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.29 via Frontend Transport; Fri, 17 May 2024 03:23:23 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000252A1.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Fri, 17 May 2024 03:23:22 +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; Thu, 16 May 2024 22:22:45 -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; Thu, 16 May 2024 22:22:06 -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; Thu, 16 May 2024 22:22:04 -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: d34aecf3-13fc-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9e5/ovVTWjkuuRvPCpt/+SZKX1pA6iH5NwxqjN7Eqt9Nt9yOk7jUI6wYZgSB/loO8hslJCdDKWh7LTpBeG2aKtKYJaHJ0ItlkdbD76iKza/dlmY28J0bRomijpsvkrmK2TiIZw0VgIpZCnCFqjeNp2n3W7bT/dv+jd0X+xfRG1ohhLkOMPXiv/NVbQK3oUPsGZQZIhv4n7CE3w5YeYrB9DRNn8UT1I9MQwl7xRG0lS+UwBurs/szKjHH06zvuc2p19uiEWb6RMLJ35ZCRlW45GfQCAsuxOTNeh6p6qdNiGf1ZXGPxf61UPjeX1oXCNV/Xc/Bi9pk61YpVM7fDHCkA== 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=d07nHhnz+E2r01WFGPEt/6CKVIk3TuRy1RIwAxzVZg8=; b=NZvFQIvZKZIPVK7wUXoqVgCJf3IxmM2cLNB8VZDkPZQByKcyfuKcNW6XJMIRSc5L/MJlS3Iu6q0Q9I/DG0Qn+vR+S4ErIZlMCfoGUsmuK8T5yNTGpiUtKxj3/oWzaeno9hfTrDGxacR93qGMs2mkZf4Q5Na6RQCFQblh9aJb/h1U6YKmArS+U+gmhuOwi8lpXgqvbfgFTbIrxFxlsr//Z2MQfspV24ZDFIa3FbWKlgs9gO/tFkLA1YUUCJCJ9op8HWTsI+RNuiEUIvXF12bQ/tK3SGiufPRYeGFHkRcQLHhQkga2QP9ixKjvGoBJ5YAitsA+UU58G1paTqvplPNjSg== 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=d07nHhnz+E2r01WFGPEt/6CKVIk3TuRy1RIwAxzVZg8=; b=0agY+9cxmafoZu2T+FJeoPF8TsVf7XQ0Ruu8n39kIikZjOkbIWcfELta3NPO4Ok3nqSfXw9bnmcEGyG1xKWPIhL8PMaEVoAj0z/lnfISGvE6g9ZEMLwf7M1TUKTI6cWYX7FvO/a0iAqA5uCIytmYksR4WVgwWXYeYfa7WHTRcOo= 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: Henry Wang To: CC: Henry Wang , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" Subject: [PATCH v3 1/4] xen/arm/static-shmem: Static-shmem should be direct-mapped for direct-mapped domains Date: Fri, 17 May 2024 11:21:53 +0800 Message-ID: <20240517032156.1490515-2-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517032156.1490515-1-xin.wang2@amd.com> References: <20240517032156.1490515-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: SN1PEPF000252A1:EE_|CH3PR12MB9283:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cc80ec2-fb9c-48ee-4b07-08dc7620b527 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|82310400017|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0DvRM6rtOlsUc+yQyPL4++Ekav5HIZAl2PAdG83t4QVeqdODU3IDqyYVQVRf?= =?us-ascii?Q?GdGRrkXADLwEVljkA7fDmVoM5W2BqdAbpa1VhbqRh0mxoJuRdHaleFAM+4yC?= =?us-ascii?Q?H66jOMTehHN+eThX0zJ8FJ39ZCL2cfa/tleae6iwK7qvscIZtZ3jKblPqlRG?= =?us-ascii?Q?HYZF3Do1vYD8Mta0XM5KFpU5D4yp6ohjOYbjP/fmmlwIWFtXIbs4N6YnE5G9?= =?us-ascii?Q?5PIk9hfGP73Y/zfNc7wDN1VVhYEN3fWtk/R18BdrdsPGEm0z0zWCvuoifSSm?= =?us-ascii?Q?kZnzVE97tgV8rfRDLy1ld5ojXgARLCqzZGcIXUvUag6k1q6AWlO+H5vGH7jS?= =?us-ascii?Q?MSmnuWx/2BvUWkkGE4cDOtxT8Uwsgz8+yyTXi/We6nI4MomLpHiQ8LdBZfuw?= =?us-ascii?Q?OZyOrKV2sDWYlcivbk2zgWxKC+4Ha9rdozepOGR5L9hXoSw2FQ3QshD6RNxT?= =?us-ascii?Q?vNNG4uuEdQr5TngAmkzdcQnS94IhDhx8OaqT6ru4v75GC0q+75qwOXXPRa0C?= =?us-ascii?Q?z32ehEjopzgisILgkaBg5JLPxCJOd//COJ3Fj+twPt+7esB5VqSx/yRp8M1L?= =?us-ascii?Q?AdErgP1Oj2v6PHDCqNvvmyJ4Hu3JkU0tCkRDgG7Vkj2/jIuD0xT3JKiYxyiP?= =?us-ascii?Q?cuGrvn+tNVLzAYCYm3sB9b+PgYPwITRnqJnGkn0ESxxMp0A+6g3z3TrcuYDq?= =?us-ascii?Q?HTppdo334EZKES0qeyivc54bgT9Ld2z4spZSdT2zhAnUHb4gSejdyuLmAdOY?= =?us-ascii?Q?FKHhgv0ifBy8peOs7W4nUTzvWTT0BdhHBjKJV3FQsa/qVu2OixGzRnvKUrnY?= =?us-ascii?Q?1WIvWBPeLWk+7A9xLjVb2hOHRklI0wucgwSXTZJaW1pC64HOSzHXTGOlYEba?= =?us-ascii?Q?Qx2Xk9w1+0NQeWZ+hY0yBTsMm3rykKhs2AqrhW8LLzAi4VTsMwSdzHUaJ1ya?= =?us-ascii?Q?gKDIDKOD44oY41v6Dzt0a7zkJTkx/W6M45VbOe8JfCMaV++4qYnqZjmlmDuO?= =?us-ascii?Q?ldousSKri38eqFOnie5awiZNkirshQNvVT2z8rXPlTeq2EZR18zFeMYqbOwu?= =?us-ascii?Q?iU0BS6YuwTWtmBCq+nln6fWr4F+OJeHHNhuGuUGHm+58G0/n+MbEsE8egRTN?= =?us-ascii?Q?vdYN/ZgEA/FJ2XN24Zzzc0z7f0y7MGhKdH2Vn5OsS/8pcb3UwOUtZzZLkCh0?= =?us-ascii?Q?dIKZEMLQv00RjjcT8DImvCUDfMQXbx8EENxbdNJKaKblsi7hMOANtSdQ9KGG?= =?us-ascii?Q?MXayQmDfnBzf9CvRRsndu0myXPt/Gnxc2kYEaKOjAZDlPOS7bSNzw46etBxl?= =?us-ascii?Q?KAe9G6od+U+/7/MbyOO9NRbQ5b3oUlnsZP9A1l6l77LVSJNtVp0YoSot8Cyo?= =?us-ascii?Q?5p9fR1gtOGfewaMOoiJy4PiW3wC8?= 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)(36860700004)(1800799015)(82310400017)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 03:23:22.9425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cc80ec2-fb9c-48ee-4b07-08dc7620b527 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: SN1PEPF000252A1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9283 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1715916223491100001 Content-Type: text/plain; charset="utf-8" Currently, users are allowed to map static shared memory in a non-direct-mapped way for direct-mapped domains. This can lead to clashing of guest memory spaces. Also, the current extended region finding logic only removes the host physical addresses of the static shared memory areas for direct-mapped domains, which may be inconsistent with the guest memory map if users map the static shared memory in a non-direct-mapped way. This will lead to incorrect extended region calculation results. To make things easier, add restriction that static shared memory should also be direct-mapped for direct-mapped domains. Check the host physical address to be matched with guest physical address when parsing the device tree. Document this restriction in the doc. Signed-off-by: Henry Wang Acked-by: Michal Orzel --- v3: - New patch. --- docs/misc/arm/device-tree/booting.txt | 3 +++ xen/arch/arm/static-shmem.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index bbd955e9c2..c994e48391 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -591,6 +591,9 @@ communication. shared memory region in host physical address space, a size, and a gue= st physical address, as the target address of the mapping. e.g. xen,shared-mem =3D < [host physical address] [guest address] [siz= e] > + Note that if a domain is direct-mapped, i.e. the Dom0 and the Dom0less + DomUs with `direct-map` device tree property, the static shared memory + should also be direct-mapped (host physical address =3D=3D guest addre= ss). =20 It shall also meet the following criteria: 1) If the SHM ID matches with an existing region, the address range of= the diff --git a/xen/arch/arm/static-shmem.c b/xen/arch/arm/static-shmem.c index 78881dd1d3..b26fb69874 100644 --- a/xen/arch/arm/static-shmem.c +++ b/xen/arch/arm/static-shmem.c @@ -235,6 +235,12 @@ int __init process_shm(struct domain *d, struct kernel= _info *kinfo, d, psize); return -EINVAL; } + if ( is_domain_direct_mapped(d) && (pbase !=3D gbase) ) + { + printk("%pd: physical address 0x%"PRIpaddr" and guest address = 0x%"PRIpaddr" are not 1:1 direct-mapped.\n", + d, pbase, gbase); + return -EINVAL; + } =20 for ( i =3D 0; i < PFN_DOWN(psize); i++ ) if ( !mfn_valid(mfn_add(maddr_to_mfn(pbase), i)) ) --=20 2.34.1 From nobody Fri Nov 22 14:20:39 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=1715916254; cv=pass; d=zohomail.com; s=zohoarc; b=JlenUKAsAVe20GrIGU5tB53w04bfibNHs3g+K/RWC9OnZOWisKJclo2WKq2rBK6IO/Q5ad3RV+Gl1533wG1u6jjeegmfPJ2b0saX6Xkj+F6YrJrp2i5WGixpDU8dbYuuFBhpdrQVbP0/v2MStrdzNq4xXRl0JtDGnpQCd18nAak= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715916254; 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=fG1F9XegT/sJSYG6Fu85jzQtPZmim9YqynPLlOCoLeE=; b=duHTYn3QxVg41CwMRRBafvMs7mS7+N81C3nRX76txtANoHmchjsQ3DWXxTAm1q5ybyvCObH40kRzwIlx1ilU/NrG6mJmxy9kSHilgTqW3kmU7hLccNhdDSUN1QXKg8ei3Dq2pOqLjZFMIIPEjVojiCUmL/puiGjvYk5Fg+MthBI= 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 1715916254630220.15247952232392; Thu, 16 May 2024 20:24:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.723789.1128874 (Exim 4.92) (envelope-from ) id 1s7oCP-0007M4-1i; Fri, 17 May 2024 03:24:01 +0000 Received: by outflank-mailman (output) from mailman id 723789.1128874; Fri, 17 May 2024 03:24:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s7oCO-0007Lx-VK; Fri, 17 May 2024 03:24:00 +0000 Received: by outflank-mailman (input) for mailman id 723789; Fri, 17 May 2024 03:23:59 +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 1s7oCN-0007En-Mo for xen-devel@lists.xenproject.org; Fri, 17 May 2024 03:23:59 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20601.outbound.protection.outlook.com [2a01:111:f403:2416::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e5f63868-13fc-11ef-909e-e314d9c70b13; Fri, 17 May 2024 05:23:58 +0200 (CEST) Received: from CH0PR03CA0067.namprd03.prod.outlook.com (2603:10b6:610:cc::12) by CH3PR12MB7643.namprd12.prod.outlook.com (2603:10b6:610:152::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Fri, 17 May 2024 03:23:55 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:cc:cafe::43) by CH0PR03CA0067.outlook.office365.com (2603:10b6:610:cc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28 via Frontend Transport; Fri, 17 May 2024 03:23:55 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Fri, 17 May 2024 03:23:54 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 16 May 2024 22:23:02 -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; Thu, 16 May 2024 22:22:45 -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: e5f63868-13fc-11ef-909e-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cM3+el3unuMU10rud3w2f70OlJrNpEKvpi+Q+OTAguVkxqQy1EGeh/zPDVabehbt5UAYwVtDGzdoEVVs9f0pcAP3D1hiqLCsNp99Y95aQZCGNAoPLJngnq968MDZ8WtqUMGF8Dy36NhGvVgtDVLc2Fohu7KNgXgNDuvjxScGAQHP6e+3eYI66E/naS05C1kuGR0E9NcQ3+KQlU7v3F/3dA35TaQo3utrE+e9ck7aqNnU5Ro1UdTdFKAL9ZXwIe72WZ/mO/w+MKIL9IkfVX7gI67rZspCVlOPXLpUvBO1TflUNjSoODhOhDSd6Glj2pvhLP1NPYjipcglmkK9XXkxxw== 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=fG1F9XegT/sJSYG6Fu85jzQtPZmim9YqynPLlOCoLeE=; b=lgWrhr1X7NFphekaFNfrMFCNl6qK1tkr++mr4XDCxGz/A9km37nU5ngwIcy4HRirjmSGcR/82t8BwQO5yAm5Gi34Ixd8m70wBxb0eqgYZgFWME37+kjNhYnP6jA3qZ+PS5OvrI4LFBOCTJ748mBJIkbK8KyjVIpLP+th/bmGgaUZvlF//bFMQtGiGxXNI/vWQu0C2VJGdKfp2xNNr5ttIIylc6dQl6+xTRFMd3BGgvAuKY0TFN8xxl/SyR87G1UihkM/U0LqXQbFvaHEiL4K7QCT0fx1b01Ms5ypPxoROBPGODzpfhyAU/K3FQ9JHw/zMbeg//wymwnl/AWHf3a0VQ== 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=fG1F9XegT/sJSYG6Fu85jzQtPZmim9YqynPLlOCoLeE=; b=Ob/HghIMy4+7AuuOjEmwGtFEOFbtR+arb8ugrofvaFUDYX4Q7zHsZgp0ZD26xjdzy/d8tl6ZvG8kmokmblJrIErFGSl1toJi1mZr0/PUnVjqPal3KpA+D72UDpsrCuswIVWwlYo+lAY1FTU/0O3kK26juMiAVP3aHWScHWOcTnM= 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=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Henry Wang , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Alec Kwapis , "Daniel P . Smith" Subject: [PATCH v3 2/4] xen/arm: Alloc XenStore page for Dom0less DomUs from hypervisor Date: Fri, 17 May 2024 11:21:54 +0800 Message-ID: <20240517032156.1490515-3-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517032156.1490515-1-xin.wang2@amd.com> References: <20240517032156.1490515-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000146:EE_|CH3PR12MB7643:EE_ X-MS-Office365-Filtering-Correlation-Id: 36fbe1af-e58e-4651-de76-08dc7620c831 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6BiiqWCLmIwOmluOM5NDMDVRIN7urfuugWAcSQyiQ0feyxQjQz0D547Nrx+c?= =?us-ascii?Q?fDDrUjkgsaPtZLWsLfmRrJro4kedSrPWWvzZ7gmrPVvNRtDwf8SHJgGhufCA?= =?us-ascii?Q?bzhSF3snc4lHudZsCgAXIDKA9XlIVqQOOCdb4IZsmRUtKiXmFRG6mHXosxOn?= =?us-ascii?Q?RVGfnAM31COHLC374WOQI3aHQZP1hFHW0mIWDKbyKsxKsHpw6gDtqKxRzliK?= =?us-ascii?Q?3NgAonQs0coTkpQK2bCKlAHZgW7ppepzNkge7uqOcCkRqMmGdk45WYyj3HDe?= =?us-ascii?Q?fa3az5RZPG038L7hfXGubIYlbZB1F4gcDcrkIE07fAjUkoi/mPEIoPY1hEbb?= =?us-ascii?Q?Mi1b0c8ccUaVCFk8Kyi6wY0cEThitWh49/rD00nreMTNi+PVI5zYvKInWmMs?= =?us-ascii?Q?SWdpjMkymw22EcDEouqV9KTT5ZzQ6ZzF8JlfAvCrHvG9RxWnaXFaKhroPVri?= =?us-ascii?Q?9XlqpG4RKOdzNa5eUrA+zmgu/u7L5EsQ14ESPQUJPXk05wjiscZYCiG1t4kD?= =?us-ascii?Q?qQUp8GjxuDs3SrGRtwhhB0L8XYZrqpGVQDvzbC4+ZyKydD47hGaOA/BF4ouq?= =?us-ascii?Q?UjwwStoN++E0Mnqohm/9XSqXOI/SeLftAlCfNA5s4Is7klWNEZQsop6Mxhzq?= =?us-ascii?Q?zKsPDSX0TC01V2Q0muSDQdCLtpikVB8uL7Nk2YN/92FSwlVAdClET9fZF2p0?= =?us-ascii?Q?kC6Jd/SiFCcLItZbORi1fAS7aEjQFGfyTLqQL2hlLdevZAMwR8IFblCrpXfz?= =?us-ascii?Q?JiMEjNakq5sNJaN8lNbMaDMyrTUknxjj0p4IRciP9o2WP45DYman1h1j5T/O?= =?us-ascii?Q?Hj9yD6DcWlhGbQ5tmpu6lJb77YlEgQuBwAlu3OVG64uF/fT2gcdSpdV0jiWF?= =?us-ascii?Q?UarCr1botGRsIJI9nIwg/VfrF/k2is8WDKStDDtXRcqKPEuEWeZJtrGcKlO8?= =?us-ascii?Q?Mq3Ff3qAAibJd+1VEURPcGrDcCp3RlHmwMAlQpsfbQtoTlHtcRyYbxmVEonw?= =?us-ascii?Q?K1Lv6sfKoTa6obqoot/7BMGX3op7i08F7AC7WU+rHYC5M0z1uAKOcMj4EDgs?= =?us-ascii?Q?EYP4DG5wVwUWMUHGBJXrtifl7nhiDd95tyfVCy40qg8WB2+GYxegy+OvOF1W?= =?us-ascii?Q?ShNiHjHPe/qmgdrmu7SViAVT7dKFGGg9uOl6b5139+Q70hEKUkDMzmb+84XJ?= =?us-ascii?Q?5bx+sqxykFQAHw+ymxLIv3bL7xtmtKvxDF20KP8s+OvW1poTluKjG6HTOVy5?= =?us-ascii?Q?VuHmk+ro8sBgh7GZE/1E2ofPP9y5tu5FVGqEU5LzmZZMgKz6vJWCizv9H6zj?= =?us-ascii?Q?SyGmhL19W1KdxfbB5IqzxATi+gabUggCT/YXRv0XxEykT01ikJdCIh0Q7p+V?= =?us-ascii?Q?/mxshxz8mWkvQoYkmjNn2iHUw0U5?= 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)(376005)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 03:23:54.7635 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36fbe1af-e58e-4651-de76-08dc7620c831 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7643 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1715916255396100001 Content-Type: text/plain; charset="utf-8" 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 --- v3: - Only allocate XenStore page. (Julien) - Set HVM_PARAM_STORE_PFN and the XenStore connection status directly from hypervisor. (Stefano) 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) --- xen/arch/arm/dom0less-build.c | 44 ++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 74f053c242..95c4fd1a2d 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,42 @@ 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; + + d->max_pages +=3D 1; + xenstore_pg =3D alloc_domheap_page(d, 0); + if ( xenstore_pg =3D=3D NULL ) + return -ENOMEM; + + mfn =3D page_to_mfn(xenstore_pg); + 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 (struct xenstore_domain_interface *)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 +878,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.34.1 From nobody Fri Nov 22 14:20:39 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=1715916274; cv=pass; d=zohomail.com; s=zohoarc; b=ZG2cxXQCJ1TyxWxelTKzp55aOVmjSNBjW1cJJMyC/UZIYUnCsCVXbIno4DNUuywUJLVbUUt93ezgSfx4xJ1qeekKVu2VOrCySyY2BW2tbjkv4x4zVya2Z+dWUz0P+ltmfaa09sVRhyfV6fbUJhFyPw4nVw86XvqxlsoCoFx11Ho= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715916274; 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=GyKN4QF9fVjSu+AyjNRAOue0Obnrq0vCp9OkHGHQS+8=; b=Fy+9SiydlkqhsyeW9ROjfhHarKDFuXhzFqM0jdtra6MNHExk2gqQtdymhzCr4OSJ8+zmjsYW6bX5/V2x25iFJEqz5b5qRQfefkFAgd14YS4I0qTq+zz59M0dC6PLqxsE6GF05MaSpXvME1SmlFbAFndY9vpJ0rz9EspIvAnu8/c= 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 1715916274141150.3184545481405; Thu, 16 May 2024 20:24:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.723791.1128885 (Exim 4.92) (envelope-from ) id 1s7oCa-0007it-Ag; Fri, 17 May 2024 03:24:12 +0000 Received: by outflank-mailman (output) from mailman id 723791.1128885; Fri, 17 May 2024 03:24:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s7oCa-0007ij-6B; Fri, 17 May 2024 03:24:12 +0000 Received: by outflank-mailman (input) for mailman id 723791; Fri, 17 May 2024 03:24:11 +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 1s7oCZ-0006l6-CG for xen-devel@lists.xenproject.org; Fri, 17 May 2024 03:24:11 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20600.outbound.protection.outlook.com [2a01:111:f403:2009::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ec385ba3-13fc-11ef-b4bb-af5377834399; Fri, 17 May 2024 05:24:09 +0200 (CEST) Received: from CH2PR12CA0022.namprd12.prod.outlook.com (2603:10b6:610:57::32) by CYYPR12MB8701.namprd12.prod.outlook.com (2603:10b6:930:bf::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27; Fri, 17 May 2024 03:24:07 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:57:cafe::c5) by CH2PR12CA0022.outlook.office365.com (2603:10b6:610:57::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.30 via Frontend Transport; Fri, 17 May 2024 03:24:06 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Fri, 17 May 2024 03:24:06 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 16 May 2024 22:23:54 -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; Thu, 16 May 2024 22:23: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: ec385ba3-13fc-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1XYILrUxe22f+CO8p9a/Uy7Poo7DKsvyV4yI6p+LfGwfkcvdTz629vvLFTxr1DFF6TiKcTFOTJZtxCf6oyyB46z2sYsALR2xh8KbP1WeuPHzexdedS1dgZmMx9pYKGp96/q5Wq11teXco0VYDJ5m+F2pk7zqqx4nS7S2I6PhKZfQlxjqiFYXTyJDeG8n72xivvPXwvSjYOr0blm6B2fTtisdDOyawr918RW85ortydi/yLheM1Rhnmzz+B3L50shDv93LM0CVU2zatFp7z0RdtQOxA0ROyrinu1cz7XavlGlTOLpAPGF9FXUsfcHrD6NKqDeOp0LipiZY/1snYP9A== 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=GyKN4QF9fVjSu+AyjNRAOue0Obnrq0vCp9OkHGHQS+8=; b=Ug61W5mJiOquEseiazbkFBTgKoFK+ldvDyyduTys/YrB2fyr7lE6071VIb+AC/qvWz7WFQWfhhtJyNQtbZP5iRe/leSUyGTZcr2IPcktTMFl14NOqJyAh1+N78ONe102cVjBOSemqx71tYwE8dRqbKHRozqr9L8OV3w54YCro69/xoXx8Jk8+48h1ZgsOEAHoJTEePvhPVRDt69+UUE5QQSyH/Xb+l4ihFhQil+REdOL/hG8b/rgemRighaHDXbmtefLkoxg3onSu4x4XRoykuQXGO+sssHlJfKldXzlhDLqqCapS74Y7nGcoSbKrtHJ8WneiCWyqP6ijzAsh/NlcA== 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=GyKN4QF9fVjSu+AyjNRAOue0Obnrq0vCp9OkHGHQS+8=; b=sYZi1WHYB2b6gqIn9RpP/IkualfsU+zpIyCDPSH48beLXbRbQD43nsRagh9nOiSmitR1e04kG2n/aywDZ9DmAxGpGnnCeZUjBAyi56F6TB5nflicCUKW/Y1EJeCC5ijsnbv3nbZvZwNBLYz7IiJPqqt4q/biwnW8E8TWt7LLoFk= 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=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Henry Wang , Anthony PERARD , Alec Kwapis Subject: [PATCH v3 3/4] tools/init-dom0less: Avoid hardcoding GUEST_MAGIC_BASE Date: Fri, 17 May 2024 11:21:55 +0800 Message-ID: <20240517032156.1490515-4-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517032156.1490515-1-xin.wang2@amd.com> References: <20240517032156.1490515-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|CYYPR12MB8701:EE_ X-MS-Office365-Filtering-Correlation-Id: 2116035e-4bcf-482a-0f45-08dc7620cef4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NQHS6Ndpm0l2r0sHPBDXsEws8+31YWiTYLcnl8J9Clp6KfWkGctnT62XMdWa?= =?us-ascii?Q?IwuhBBtSkSGlwqfyl3aQHOan+O1NoX7XWNlQg+iU99pulfS+9rwMkbn9mqpP?= =?us-ascii?Q?zEOSCs8rUEtJOfbLlz0hqDwIbo4RCo+E79A4ERiH5SmqRQ/IahHmOTfTnsCf?= =?us-ascii?Q?7WIWjIrmoU+tQpl482hUG/x0HNEY/JywmtCKCJIwTGlDYothq++OS7E/q2PR?= =?us-ascii?Q?jAtLAwu1IHCHrh4tfaqvO/ZPxIIMnr12vnqvTRTlCPZ5T2kiI32x+scFXM0d?= =?us-ascii?Q?ajZauCGVbq2WWr7Ockv6mG3H24M2f3Tro82bIUHdNUR/okYuF0QOk0VDA2DG?= =?us-ascii?Q?DmMHYOKhMx2+4t/gQPdh0q5SHIR2b3x9wQXtBogvCYPyy55EkcR7jA4bnm4N?= =?us-ascii?Q?WHqCXI657Hp/Bbp6Cuf2UM2zKDGtA0JG1CxvP729vOGGb8zcJAzfsDlK/gRg?= =?us-ascii?Q?fO9mUzSs8eJI9H0JxBJCALtsP4bUeefUSGqdD8y313qu+k8KnxsjplDRhkfg?= =?us-ascii?Q?SY3iOgrdq4mOS4e0f80NTrYK1ffutG36H87uTsPQoBpbsvaISpjERprAMMp+?= =?us-ascii?Q?woxqR+owYpPWkqWlCbZCaQCVn8KSUjI9JHpMJPLM/6lXt115cPHbDKn4J/wu?= =?us-ascii?Q?2NJ7Yt9jl58f+BEnUbWuVzMpQzy/7n0dHg5NIcAHLvyXXWL2+jwAGDx5z8Is?= =?us-ascii?Q?JKcgxTvB1N3XcsRMExVaIDMEng3SDYULbrnC4m4Vs1aIx78onyAbv24GSQVH?= =?us-ascii?Q?vbh0XqI0SNJzdMQZ11pPOHIgLk3sYwciwkHQrkGH59HIpBlyIr3XNfoktood?= =?us-ascii?Q?StIqgVfai6X1ZR+Jx1fav38bJzwXIQrKG9rpx97q/AG06Jxrlx+YduqPL6Ko?= =?us-ascii?Q?W8fQoYMY5nYnrC0JMnUoA5wyh6A6YAcqbTz5tpdrzrUWu3kApmHrDVb1NOu9?= =?us-ascii?Q?FbRdcHQ4vYRJih16nnRcmbX83GiemIJOgh44R2WAbInoxoKPa104AZdT3H1Z?= =?us-ascii?Q?kQW79+bY7Ew+F/Lwgv87zm2tNtlMwRFQmSOAO/xk3R8UlScoJ4gzPavZl2+p?= =?us-ascii?Q?KHx0Y2AvdxkCu4QgHeIAe7QrNFtg1RmhEfw9JN1cCjOGlZUvgeZPscuPUHdt?= =?us-ascii?Q?wxP8/an7/qJOm3Kh6GvDrY09t7LqA4JOup1u5TeiQ77yE4b9YMwGgl7akhu8?= =?us-ascii?Q?zeNi3SO+XHsrmCWkbmpoWtQ75AOR84++yl0o7ZnOD7ZExJzhmmthWT5yzFe7?= =?us-ascii?Q?agtZZg8lgzHxnvaVkNrLjRl6oaHryNZtAdCIin60pLcdaxW17r+r2Pqt64e9?= =?us-ascii?Q?xVze7+DdsB2KZzYDRX4TvefDy+ra62cNAyPg9cZBKU6V3x1NAHEfLvcrtwGq?= =?us-ascii?Q?8B4zIJtapZlHnOY2J7XxCyT2Fs/3?= 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)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 03:24:06.2275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2116035e-4bcf-482a-0f45-08dc7620cef4 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8701 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1715916275539100001 Content-Type: text/plain; charset="utf-8" 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 allocation from init-dom0less is for XenStore, and the XenStore page is now allocated from the hypervisor, instead of hardcoding the guest magic pages region, use xc_hvm_param_get() to get the XenStore page PFN. Rename alloc_xs_page() to get_xs_page() to reflect the changes. With this change, some existing code is not needed anymore, including: (1) The definition of the XenStore page offset. (2) Call to xc_domain_setmaxmem() and xc_clear_domain_page() as we don't need to set the max mem and clear the page anymore. (3) Foreign mapping of the XenStore page, setting of XenStore interface status and HVM_PARAM_STORE_PFN from init-dom0less, as they are set by the hypervisor. Take the opportunity to do some coding style improvements when possible. Reported-by: Alec Kwapis Signed-off-by: Henry Wang Reviewed-by: Jason Andryuk Reviewed-by: Stefano Stabellini --- v3: - Only get the XenStore page. - Drop the unneeded code. v2: - Update HVMOP keys name. --- tools/helpers/init-dom0less.c | 58 +++++++++-------------------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index fee93459c4..2b51965fa7 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -16,30 +16,18 @@ =20 #include "init-dom-json.h" =20 -#define XENSTORE_PFN_OFFSET 1 #define STR_MAX_LENGTH 128 =20 -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 =3D GUEST_MAGIC_BASE >> XC_PAGE_SHIFT; - xen_pfn_t p2m =3D (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_O= FFSET; =20 - rc =3D xc_domain_setmaxmem(xch, info->domid, - info->max_memkb + (XC_PAGE_SIZE/1024)); - if (rc < 0) - return rc; - - rc =3D xc_domain_populate_physmap_exact(xch, info->domid, 1, 0, 0, &p2= m); - if (rc < 0) - return rc; - - *xenstore_pfn =3D base + XENSTORE_PFN_OFFSET; - rc =3D xc_clear_domain_page(xch, info->domid, *xenstore_pfn); - if (rc < 0) - return rc; + rc =3D xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_PFN, xenstor= e_pfn); + if (rc < 0) { + printf("Failed to get HVM_PARAM_STORE_PFN\n"); + return 1; + } =20 return 0; } @@ -100,6 +88,7 @@ static bool do_xs_write_vm(struct xs_handle *xsh, xs_tra= nsaction_t t, */ static int create_xenstore(struct xs_handle *xsh, libxl_dominfo *info, libxl_uuid uuid, + uint64_t xenstore_pfn, evtchn_port_t xenstore_port) { domid_t domid; @@ -145,8 +134,7 @@ static int create_xenstore(struct xs_handle *xsh, rc =3D snprintf(target_memkb_str, STR_MAX_LENGTH, "%"PRIu64, info->cur= rent_memkb); if (rc < 0 || rc >=3D STR_MAX_LENGTH) return rc; - rc =3D snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld", - (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSE= T); + rc =3D snprintf(ring_ref_str, STR_MAX_LENGTH, "%"PRIu64, xenstore_pfn); if (rc < 0 || rc >=3D STR_MAX_LENGTH) return rc; rc =3D snprintf(xenstore_port_str, STR_MAX_LENGTH, "%u", xenstore_port= ); @@ -230,7 +218,6 @@ static int init_domain(struct xs_handle *xsh, libxl_uuid uuid; uint64_t xenstore_evtchn, xenstore_pfn; int rc; - struct xenstore_domain_interface *intf; =20 printf("Init dom0less domain: %u\n", info->domid); =20 @@ -245,20 +232,11 @@ static int init_domain(struct xs_handle *xsh, if (!xenstore_evtchn) return 0; =20 - /* Alloc xenstore page */ - if (alloc_xs_page(xch, info, &xenstore_pfn) !=3D 0) { - printf("Error on alloc magic pages\n"); - return 1; - } - - intf =3D xenforeignmemory_map(xfh, info->domid, PROT_READ | PROT_WRITE= , 1, - &xenstore_pfn, NULL); - if (!intf) { - printf("Error mapping xenstore page\n"); + /* Get xenstore page */ + if (get_xs_page(xch, info, &xenstore_pfn) !=3D 0) { + printf("Error on getting xenstore page\n"); return 1; } - intf->connection =3D XENSTORE_RECONNECT; - xenforeignmemory_unmap(xfh, intf, 1); =20 rc =3D xc_dom_gnttab_seed(xch, info->domid, true, (xen_pfn_t)-1, xenstore_pfn, 0, 0); @@ -272,19 +250,11 @@ static int init_domain(struct xs_handle *xsh, if (rc) err(1, "gen_stub_json_config"); =20 - /* Now everything is ready: set HVM_PARAM_STORE_PFN */ - rc =3D xc_hvm_param_set(xch, info->domid, HVM_PARAM_STORE_PFN, - xenstore_pfn); - if (rc < 0) - return rc; - - rc =3D create_xenstore(xsh, info, uuid, xenstore_evtchn); + rc =3D create_xenstore(xsh, info, uuid, xenstore_pfn, xenstore_evtchn); if (rc) err(1, "writing to xenstore"); =20 - rc =3D xs_introduce_domain(xsh, info->domid, - (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET, - xenstore_evtchn); + rc =3D xs_introduce_domain(xsh, info->domid, xenstore_pfn, xenstore_ev= tchn); if (!rc) err(1, "xs_introduce_domain"); return 0; --=20 2.34.1 From nobody Fri Nov 22 14:20:39 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=1715916278; cv=pass; d=zohomail.com; s=zohoarc; b=lq8ni/syHJV4KraxZTkLjls04Om6kiF5mSYR+uACgg3tM/zhN0m4jR5v0gvOx9UPKOW25t0tkENRTkMBt3LwetIYrlJoTM6QvcCQ9elYIwXHA/aQ1dNQhuSZHOhZyUgxb7W2h3tt5A1nfQVixQyOJQ84vI8QgdEhYRfRO84PIeo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715916278; 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=1u+M1MpJUGmCneiJ6tyWezkJk2s1bMCTX2NWTZTsw/0=; b=EfJqrzn7qye8g3ezAqcG9OAe4eLzs+jC0+AHNxlkEy13oTzPd79UdcndbDNjMFKEyGkgV60tMBnJvpT2b8EotIRaeBOufB6LwXpd7k8VKxpl6ewyoI8419mT3Iw4uyQ6nE/kLYemlzSpGWBa4bzxlwyoTUvL6Elx9+t1M7qfod4= 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 1715916278114218.89340133682288; Thu, 16 May 2024 20:24:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.723792.1128895 (Exim 4.92) (envelope-from ) id 1s7oCe-000805-HK; Fri, 17 May 2024 03:24:16 +0000 Received: by outflank-mailman (output) from mailman id 723792.1128895; Fri, 17 May 2024 03:24:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s7oCe-0007zw-Dv; Fri, 17 May 2024 03:24:16 +0000 Received: by outflank-mailman (input) for mailman id 723792; Fri, 17 May 2024 03:24:14 +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 1s7oCc-0006l6-N9 for xen-devel@lists.xenproject.org; Fri, 17 May 2024 03:24:14 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20601.outbound.protection.outlook.com [2a01:111:f403:2408::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ee33ac71-13fc-11ef-b4bb-af5377834399; Fri, 17 May 2024 05:24:13 +0200 (CEST) Received: from CH2PR12CA0005.namprd12.prod.outlook.com (2603:10b6:610:57::15) by PH7PR12MB7209.namprd12.prod.outlook.com (2603:10b6:510:204::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Fri, 17 May 2024 03:24:09 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:57:cafe::62) by CH2PR12CA0005.outlook.office365.com (2603:10b6:610:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28 via Frontend Transport; Fri, 17 May 2024 03:24:08 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Fri, 17 May 2024 03:24:08 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Thu, 16 May 2024 22:23:56 -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; Thu, 16 May 2024 22:23:55 -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: ee33ac71-13fc-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n26oQiB3rqYQQhQY7AHV0S4Zl1cvg9yF0o0rMNei2YEX4kszHQevDgJy1nNlVNTBcFXhuCUH2OKzu7KVUd86vSRg/nn6BDu6PU8raGFGE//t3JgI5t06xjXABvIgSASX5WuXX8BqMQ0MqkMZdO+/L9Qou23lykiQB0jBwobPmvEbJfx/N/M/DIGsoipqNAthh2K6Q73PEJpjtCU9a54/CLR6NVjlBkUTgMKOWbFos8dSI7BTf481OjWXUpvAF9L6mi03aExjSrf5by/GwomtfFlLILwMa7xCu+qW0SDPNoGSgog24t3ICxD3iXQACzhXcNi9RNdAev/VG+zNQu0sVA== 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=1u+M1MpJUGmCneiJ6tyWezkJk2s1bMCTX2NWTZTsw/0=; b=mjtzhKxESPc/Tdud9EX0lppgwWM6CqqXKDwKDB0o2rdOv5fLb+sGJ75NdpWPRkUEe/TuF62plOkMv5DQ9SdBvPn2IGbLEuOcsauOemei2OjMFU/aGzWVLMn21LwKXGFxqInS6SlM+eiQ5iycuPJInirGImmwHLqv4y/e5amchorSSRG8S2+ul+l+8JtowR2/2OceZFqca4wgKqHu0gu8Vollo8NZVzZiG1PSAwPL7WsMItbn6nyk9FuVGdOfFiq0MgMZW+7GiBKiQUpW6nTPKDJUnfvVY9lt1fr2tUQ/SQ92piJt/2bZn2V/NuWmLJioDqVApK7PNThifD0eirVwhA== 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=1u+M1MpJUGmCneiJ6tyWezkJk2s1bMCTX2NWTZTsw/0=; b=zgCaMAMQCRubaJCTtqToLscyBF7EEpGybk7Jihnxcq4ykznbPD+4sonFC7B86G0gm+t34qgPVeYJajPoTTSfMjCgj2os35BwlU2JJWRFZoKcR9wetvRuWdciz/0qMtsgWrF0GAh8KujWHrUQ9JdNEirZ4G1k9XdAmYvRkR77oE8= 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=SATLEXMB03.amd.com; pr=C From: Henry Wang To: CC: Henry Wang , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v3 4/4] docs/features/dom0less: Update the late XenStore init protocol Date: Fri, 17 May 2024 11:21:56 +0800 Message-ID: <20240517032156.1490515-5-xin.wang2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517032156.1490515-1-xin.wang2@amd.com> References: <20240517032156.1490515-1-xin.wang2@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB03.amd.com: xin.wang2@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|PH7PR12MB7209:EE_ X-MS-Office365-Filtering-Correlation-Id: dd70f450-ec54-4c0f-c236-08dc7620d06c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|82310400017|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?X2ampRtCEEh65iOCTCHgF9XZPwfHtYMd3/m7SyaVaJ8i/dguyoN3bVymRiOR?= =?us-ascii?Q?7T4NAeRVBegjjh81/fppiX2zczUy068D2Gn6UHwtPBUJ2cJLICFmKYqtYBw1?= =?us-ascii?Q?RSRTgn276VawDMoBb1qqbSDGMLOeBQD+n2X0XqCvMKh5UENsxV0l9HgweVru?= =?us-ascii?Q?1FGrNmSffQ2yPXw8RBkVbynrkwURoL+IpCV9Pj+dM90RMkMLmHzwN3z90Hy0?= =?us-ascii?Q?xEPPSDrG09B5B5M/GMMR8r0HrtmLdMdYXg87jcpo1KoDeY9CqlxNqjxr/Q5y?= =?us-ascii?Q?jtD6SrEOzfh0bn5XOi5PQepQuGZSB6rAuyfxa7oY09itSF/4kQ7uw1pouool?= =?us-ascii?Q?2ROU7zRJTXWTrmKj8HwRrlxK7TB++4Kde9VXsPcWPhV+GeRkJPToCqhp12a9?= =?us-ascii?Q?M3w6IK8vPZx452riFs8aUcaJUqtnwthlEHvWjS1WzHafi0EEjw3oDIX/eFes?= =?us-ascii?Q?q5X9zLrdxlwltAkNfrxwtgJoWHlk5CJAM72l2wpYgafsdu+9hfnwjeEMXlTe?= =?us-ascii?Q?b4JHtgGtdndK4RE9GuCUG7HjBwZYp29YiG5f9z+/ti0HH1z9PHMr9tmBAUup?= =?us-ascii?Q?GvfQsS+/mmTOw0Qhd2KanLaeSb2SduNbG2Q9EC4X7GLnq6IxMgrdwYZip7yB?= =?us-ascii?Q?AcwB+nKpY69Euk8dPbYaW6XKhFfe5tTsqUceH6Fy9C+r0Lp8vNjAfBLQw3D5?= =?us-ascii?Q?E/MZNhSUMFVNtDNluWavL8VgLBFfRScaD4ePE2MBTbHjTZyIyUzLKLovuhbr?= =?us-ascii?Q?7OwKLjgQ7ph0NJuOJystpV5O8yBve14FHJp5sFibHUXcQZ7Q271i5QoSYPA0?= =?us-ascii?Q?NVos41CE+AlAztRLAevkk0BPE+190ckI1phcEJfhIdrs55HZzxuv9zYd1AY/?= =?us-ascii?Q?K/Bs2cxBYk9m7KHIBeiBJJOlhlcMHlbR+frmf1K61O4DNWCukwGpJ4v3qp9P?= =?us-ascii?Q?tN2NEGOzKhem5ZJ5azWXnRYM4hqrLKFiAHvo2wm6MRuIDZjmUFWeJtNdYdxM?= =?us-ascii?Q?A1xw/ENu1jQBpq/sYEdn06uCEdEcU+StQuBI0rWc8WD5ayXs5xsRgY9XifWo?= =?us-ascii?Q?PUAMHa2HGlptdEVwIXritzPH0uogOiIrntmBWCRizQvg5ePC2Emnzcnlr+74?= =?us-ascii?Q?YSulqRHTbJXzE+wIYp5nKpLBagm2/Ltle7gRzvzhRpfWrL97/31stIXhLb+n?= =?us-ascii?Q?gkxwj5KJSZAAEwCMu5UhXJxWGohYE36d35WKhYBYS9A8Y5jNBvy0zAInUZyS?= =?us-ascii?Q?e98tfIYpJNy704yJUyLok75QCOk1PTyD47z/WI71J3JpqFgt59Ds7cG/m8sM?= =?us-ascii?Q?Gou/uGZhHEx5YvPjyO/3mP1+tqMj3eV3n29S5K5CE9S4TqLM1YgyVVq6Cfiu?= =?us-ascii?Q?34Y60s+tGwAraZ9IQ2G4OcQq16q4?= 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)(376005)(82310400017)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 03:24:08.6806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd70f450-ec54-4c0f-c236-08dc7620d06c 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7209 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1715916279495100001 Content-Type: text/plain; charset="utf-8" With the new allocation strategy of Dom0less DomUs XenStore page, update the doc of the late XenStore init protocol accordingly. Signed-off-by: Henry Wang Reviewed-by: Stefano Stabellini --- v3: - Wording change. v2: - New patch. --- docs/features/dom0less.pandoc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/features/dom0less.pandoc b/docs/features/dom0less.pandoc index 725afa0558..8b178edee0 100644 --- a/docs/features/dom0less.pandoc +++ b/docs/features/dom0less.pandoc @@ -110,9 +110,10 @@ 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) -- Dom0less domU kernels check that HVM_PARAM_STORE_PFN is set to invalid +- Xen allocates the xenstore page and sets HVM_PARAM_STORE_PFN as well + as the connection status to XENSTORE_RECONNECT. +- Dom0less domU kernels check that HVM_PARAM_STORE_PFN is set to + ~0ULL (invalid) or the connection status is *not* XENSTORE_CONNECTED. - Old kernels will continue without xenstore support (Note: some old buggy kernels might crash because they don't check the validity of HVM_PARAM_STORE_PFN before using it! Disable "xen,enhanced" in @@ -121,13 +122,14 @@ 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_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 event channel (HVM_PARAM_STORE_EVTCHN) - The Linux domU kernel receives the event channel notification, checks - HVM_PARAM_STORE_PFN again and continue with the initialization + HVM_PARAM_STORE_PFN and the connection status again and continue with + the initialization =20 =20 Limitations --=20 2.34.1