From nobody Fri Nov 22 13:44:03 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=1716591347; cv=pass; d=zohomail.com; s=zohoarc; b=YK3QTbKUWmaHGVLDyufRpI+1njhx2+u4HVxgIYt5t8HS7tuz0Ut5va25ku7NF3aWRDly0Xv+YXRw7ap0KD6pRCBKYCUU2Q92OzIW1ux5ajarQt/jjcbpSH/+J351Wqodnc9wP95xOuua2XiQay3g8AckQjnyPF4UZ7G58mpBgAI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716591347; 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=lzV5nEyCRZZ9wvgQ5/ihrFl2ogjKMReVCJclNQHfPF0=; b=OH9xhMR4ikMdBy2DnG1/d4mo1ExWQvNfTJhE93lGyVIxDIe9P4HFk0hX3nS2UMhWyxSgTL0IkQMF0sUO5d0+4o3e1u3DjbjQxP3+M5Oygb1CLQdsWVnxyhJkPThQzgkaeSDo9IxCpfLHa+9yYP7O7jEP+ZgIWvwnFC+B2Yhhmdo= 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 1716591347483408.72775643389105; Fri, 24 May 2024 15:55:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.729962.1135310 (Exim 4.92) (envelope-from ) id 1sAdox-0003yz-Gg; Fri, 24 May 2024 22:55:31 +0000 Received: by outflank-mailman (output) from mailman id 729962.1135310; Fri, 24 May 2024 22:55: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 1sAdox-0003ys-Dh; Fri, 24 May 2024 22:55:31 +0000 Received: by outflank-mailman (input) for mailman id 729962; Fri, 24 May 2024 22:55: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 1sAdow-0003hQ-L7 for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:55:30 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20601.outbound.protection.outlook.com [2a01:111:f403:2412::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b661fd4d-1a20-11ef-b4bb-af5377834399; Sat, 25 May 2024 00:55:28 +0200 (CEST) Received: from BLAPR03CA0088.namprd03.prod.outlook.com (2603:10b6:208:329::33) by SA3PR12MB9177.namprd12.prod.outlook.com (2603:10b6:806:39d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 22:55:24 +0000 Received: from MN1PEPF0000ECD5.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::14) by BLAPR03CA0088.outlook.office365.com (2603:10b6:208:329::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.27 via Frontend Transport; Fri, 24 May 2024 22:55:24 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by MN1PEPF0000ECD5.mail.protection.outlook.com (10.167.242.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 22:55: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, 24 May 2024 17:55:23 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 24 May 2024 17:55:23 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 24 May 2024 17:55:22 -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: b661fd4d-1a20-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KHKRq0WLq+gvjaSBU2cBm+tOtKgFYAloEbDoytH7ShGaisA+nWjqSHfCeR54E9z51o+0otJioyy62fZW4rXxvH/lpNs5lImuQzjkJbETUf0fIr63Nfw5nEqPNXQmEbPgyHjPQksjnVQpFFyEHXukn1PeBXJqzbMPjPcXVgMuxrz1jGWM5pFO1o7X+BI6xLVHu/PjXwdJu/o+9ZtDFEp49cvUNjx8vvVpJcU/1UtP8I4K8AtrpBFkNhl4fva+hg4j2ApAL6KYEwMvYfb1HHNkp/AvjXv6fsB9YkwGuarm1azj2CQKaGmfLoSaG4zFsXGT6+zQLq0ix+qKrC4PISoPXw== 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=lzV5nEyCRZZ9wvgQ5/ihrFl2ogjKMReVCJclNQHfPF0=; b=GhCUGIJsy+h6Eb2FQ9I//g+AqcFCWpvi7j0oR5TtapXwYD85Et/JA2s15vhOtA3+UzpdzqIScMYZMIojxo2PhzhtJXEnWUZlyJGT43KNwmFyVgPNHLxTFc+/rgCwuTJ+ZnWhn/+eaztYCKb0zTgQP+ZRj4blkXK6clOvgzjsL0yjRLnSzOTLy6FVMxeXp8VK9EBJaD71sAXHODeLah9ScqJYNycLz2gtEgJ85tzrCPSDUiA8kq81JH2HzjNFJUPstMIO8uENgU6IN7QmCfZTfGF1cPFkrra3D+a/NpkNi82Y8r8EJlsAgRRlS2THFI5RRWES+K0UvcOz41621+znig== 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=lzV5nEyCRZZ9wvgQ5/ihrFl2ogjKMReVCJclNQHfPF0=; b=Lr3XcTWlRaOLU2k/CYK7CGyJJuzf+av0wIXQUNYkNc0Y47kDqDnMeap1EfWmPqrzyEMff8fR5kgPFXvkwsaOrkPwa9xhsFls14jfA7l49un8LixuCTTXkwqVupkwgiGw9UHbwwpSZra5BwdtwNi92XFBnK/MPN/zKNXG1dSS1+k= 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: Stefano Stabellini To: CC: , , , , , Henry Wang , Stefano Stabellini Subject: [PATCH v4 1/4] xen/arm/static-shmem: Static-shmem should be direct-mapped for direct-mapped domains Date: Fri, 24 May 2024 15:55:19 -0700 Message-ID: <20240524225522.2878481-1-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD5:EE_|SA3PR12MB9177:EE_ X-MS-Office365-Filtering-Correlation-Id: 2be1aaed-b1e3-49ab-7fd0-08dc7c4498bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CKxoSez6zEGXESf2xzEkSlkhtrjlI6zvRjKJYtL8eGwP0v6qqkZKAGzs6Ys5?= =?us-ascii?Q?2zcXcYWc5qresS26+ofH7GV4O9vn/upHrWsS+/Xd9JF/fVC7ziLH1rxJnfHb?= =?us-ascii?Q?4d2IZNNFZkYJWDRWn+l2zUWr1VYS1owaKF9SyQ+DSmXKDil6VVEi8glSxByF?= =?us-ascii?Q?sxy03qaif6k0OiYEcFsWw4rbI4X46IdaxPD18oQVou8UNSw6g9kk9UV4vWLL?= =?us-ascii?Q?rNFRvR4GUmvn5LCGXMFSLI+un0Y5stMgTrgznUUzZdtMxtPnBgN03GHsRwhN?= =?us-ascii?Q?Q1cu/w8zK+xa82hVILrqVLh8xYoR4j5Til655Cr45JqhM2wtqFkcMMPTqn0Y?= =?us-ascii?Q?tzHxeJAc3RYpkn9Wrh6MEO1F8I1MxX9gG/F43BKTOFVJGDABF9wLm9LTJ3vA?= =?us-ascii?Q?+FOEP5n5AmhdsLyWmaHIjbTid/o1URydnIH4lcpjk/OX5T3yPpXg2vGnf0kA?= =?us-ascii?Q?Psf1Hy3p6+wmNQaC/KXjy9Ye/mPwNGAsvmybVvVCcuwHulxQqUyrFDwMqHnS?= =?us-ascii?Q?ZMtVT3iiJsW3U/Y1rEGONxjU5tBl6BCbqCSfhIqlB/DO89wUP+wr8ZuAxqty?= =?us-ascii?Q?TQ/Nd4bp/Q+D6h+hn3b1ipHAPDhZpDlvuemZZTplHl+LQVmLeMkcBJq3hsTZ?= =?us-ascii?Q?5vDgmNbldgAijnhx1lfPYaOXmy0tQZxwImskua2FvwLF28sS5BCzIqGAxNlH?= =?us-ascii?Q?YZG8te5lf36YMnKBXD1FYx/3IrMHIFvUu06woQD8sxYXLXlzlPrriGu+CG1o?= =?us-ascii?Q?pY5W6ZmUYKRFmaRVJF460Z0KQ+0HmfaxO2V56uBB7La9kYQFl5BmPReLWMfh?= =?us-ascii?Q?NGmQHelKF8NatsFEILBsubdc4Zv8MMYhyL00xGRRKe+jtO8uGYRttolp/fgH?= =?us-ascii?Q?tmj/VmwS+gvIEson5Vl5gCpiKZCGuV8sGi2erPVWtqhOBGvciqPoHxbwFwCW?= =?us-ascii?Q?W4fegxvZUzcpM43FQ3cpkUl6BZ65eY/+1SgeUC+Ne+XBKTikD2I8sKmhJuiV?= =?us-ascii?Q?vKUMNb6f1gg6yzL31qktbT7YBZNQuPkyUEKrBT2YU2W2SwXjzSBPicl+WrOM?= =?us-ascii?Q?XxfHORJWceML6j5G/daih+HEVUA73DO6v9Eh31qLFbiAfz++Wv8Zf6dZmaag?= =?us-ascii?Q?LBpZE6ef95uG7VoDeXpfZdeaILE1+eJ0OEJ96UhQDP2Iq+QyUWrCoXg71o99?= =?us-ascii?Q?VExruOf/gNJPNNyiTWrpkuuYtDnh3xO461SilVw/6TJ85vng/KDba4CFdR4i?= =?us-ascii?Q?HM/2KRPlC1JcgtiIIkZN5x85UgRAHAGXOYjweV82J5oJL4Q4N1GJvSf/YhHc?= =?us-ascii?Q?rYydJArzOyCXEX1ydqjpXh+MLAUVRatdYnLQaky5nm4KBdJzjqhP+Mt8OQZf?= =?us-ascii?Q?byLolmwvURxK3f9Y4EDI8vSGecqw?= 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)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:55:24.1344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2be1aaed-b1e3-49ab-7fd0-08dc7c4498bb 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: MN1PEPF0000ECD5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9177 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716591348392100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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 Signed-off-by: Stefano Stabellini Acked-by: Michal Orzel --- 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..5bf1916e5e 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 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.25.1 From nobody Fri Nov 22 13:44:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1716591356; cv=pass; d=zohomail.com; s=zohoarc; b=EyAgAwJ9xrMnd0Gf3oWU+V9sUgHOerhyt5IwDx+Z2Az7n0q7VkpkYGs2OZfO6OpbaeJqL5B8um0diTjexqV09qsXN5VR0NuQf934BM+0jEYwId/dUZnc8O7Xyc1KApriAa+3TlfeWLULRjnFMAdLgnsHXHF6S5K8lv/jPXEQcFY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716591356; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kGJKl+YgAt+elTNKQCErwYXKgmqb2xKN/qNfttPWbAw=; b=WCqljTPtIhjFNyUzhJPg0gwFdsfyjuji+SjLVjPjri/lfh+QfF72YyFOtZa/hQIuW8ZJfbJW9gmM05rEqKOm582mWXLxyIb4KPJBJykokNAu2TkmspjBZpskPHr38Tp3SN7r/r2NY19vzdG4xg1Uh/0wF+VDa493hHfPBTR/Wek= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1716591356346896.6670539170589; Fri, 24 May 2024 15:55:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.729966.1135340 (Exim 4.92) (envelope-from ) id 1sAdp4-0004ot-IV; Fri, 24 May 2024 22:55:38 +0000 Received: by outflank-mailman (output) from mailman id 729966.1135340; Fri, 24 May 2024 22:55:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdp4-0004og-Ec; Fri, 24 May 2024 22:55:38 +0000 Received: by outflank-mailman (input) for mailman id 729966; Fri, 24 May 2024 22:55:36 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdp2-0003hQ-Po for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:55:36 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20601.outbound.protection.outlook.com [2a01:111:f403:2416::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b9ee1500-1a20-11ef-b4bb-af5377834399; Sat, 25 May 2024 00:55:34 +0200 (CEST) Received: from DS0PR17CA0007.namprd17.prod.outlook.com (2603:10b6:8:191::14) by DS0PR12MB6534.namprd12.prod.outlook.com (2603:10b6:8:c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Fri, 24 May 2024 22:55:30 +0000 Received: from DS3PEPF0000C37B.namprd04.prod.outlook.com (2603:10b6:8:191:cafe::fa) by DS0PR17CA0007.outlook.office365.com (2603:10b6:8:191::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36 via Frontend Transport; Fri, 24 May 2024 22:55:25 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF0000C37B.mail.protection.outlook.com (10.167.23.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 22:55:25 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 24 May 2024 17:55:24 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 24 May 2024 17:55:24 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 24 May 2024 17:55:23 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b9ee1500-1a20-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H0ZwdWwFHgIU2CPMt51i20GT77LOt4RDg0m3ViVoe+VbLR2+nwy2hqJMwpFO2IuUd6Ca/FGhpyHnEbjp1ogHiQPr7vB7SP8LWqc+AEkoMXGuJJorunMj/W7SP+9ekbG0L2wefMc3Rm/7qxWosBX/3fQ/F+sasNMBA6i9vNMc3EBLaKHRc4/uIN+9Gg5D+HNiSrt3TsoL8alcUa+yFJVOMGxBpUbRpK3WguMej4o/RJxNyG7A5fdAHmVYAB9dya0Zy9/OzECyRiqluOb3QtYtkbhPW6tA0CX1ch5rF7UkH3FEfZOE47NMfSu5CTtm8J4yrlL7hOtMDHGYp+L3NMhKfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kGJKl+YgAt+elTNKQCErwYXKgmqb2xKN/qNfttPWbAw=; b=Gt6IeM3OQ9OlNsZBJvR/YroCFBRM8YlaVUHqhTkdhLh9kI0G3RBF47rZlNUg7prCjaKDS0f27DJzOd8V72B/B2Gi+E79GY2NcGCzhwZ15s5+zrySnGA10L/NzsRLdtUX382X2hMeynof0XJUxhBLuxCbhRDiZE60JjxQA8m3O6+t1/M5u1Mihns8SFSsCN9IRWZnV47XE1xrPvorMUboTSvkfFNeaNmxO8g+vVtJwdmWpR2l4RX3l0+hQ8PmKzoQtTusOgrHks9ZE2HtLFYqoHrJQHiwgtK6IExDffab3tjVtiYbTcOz0f6SE7cfWvgA2Zc9SAGl9MXUXIFe/4UFhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGJKl+YgAt+elTNKQCErwYXKgmqb2xKN/qNfttPWbAw=; b=Kss64V5TJPeoTcxFJKrTeGpbOWUFId2KMI6M+sZsx5WXqRgqyQUu/GkXmFjVtywU99TzzsXOqWuPubE5lJlB0CuwpIhcvF7ImB5j05dr/34yTwK75zUOalGvL3Y4bbk8svTsNHNuhxJSPtsBgV1vWW2bLlEgTYVkLuXTIEOm6XM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Stefano Stabellini To: CC: , , , , , Henry Wang , Alec Kwapis , "Daniel P . Smith" , Stefano Stabellini Subject: [PATCH v4 2/4] xen/arm: Alloc XenStore page for Dom0less DomUs from hypervisor Date: Fri, 24 May 2024 15:55:20 -0700 Message-ID: <20240524225522.2878481-2-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C37B:EE_|DS0PR12MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b482132-61e9-491c-4234-08dc7c44996c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?b9wWaVUXtHuKsJimiwJE+gdixTUTt56rWyUww7V5ZOSjdNSw832v/fKtmPVp?= =?us-ascii?Q?saMupljRZ4Ou4H6ufSNAv7VOQEYsRSGM4VSwJC8gY5MWWf4ggYh3q4GTg9sK?= =?us-ascii?Q?zDZGWLrZ+wTB5BF5aURYCi38Gizq1drsgHNjzRKqaIDCSXWrSLFCPDaIWOt9?= =?us-ascii?Q?z0KfPI6XidMECWoYSyqHSKG1wkkJ5qNPrMiJEdld6eSLWLqfe0muqXHuzf2O?= =?us-ascii?Q?7/2Zx9B4SQqWstFaNernwQ4hil2zn69EbU7y3hs/1r4Led1BHaCKAfl4slMN?= =?us-ascii?Q?6nKucpsshlZWNS+Jg1zvjTy5aNGkFHu1vpX1fNFwG8ItGJrQxIG43DzfmdbY?= =?us-ascii?Q?jNZu2wzzb2BDrrpmC+4P6rZ+RMDKYd9FTDGdwLHpqWOjujlz8QzAQtGHseaN?= =?us-ascii?Q?mQOdqgFfMDPOQ9PljvyF8BywXBOS7F0Ep2yiHfXmKvsyuiNq+D+BiGRrVjPa?= =?us-ascii?Q?l5TpPq3iXgEKZC1E+UNpd/QM+dIH3TDm9uXsgFlpA38ifyWE7kCdDS2jvaG3?= =?us-ascii?Q?TUifqczF7gOZdStPQlEyqVAO7610RRsS90EVwVB/jN+bfTi2FEokN6sTo8eD?= =?us-ascii?Q?o1WHskQSSuFsBK9EZiYKft2mdDdQvS+Lo5Iz8p2DN8J7062Wz/FKZi0Gko0Z?= =?us-ascii?Q?uGyqM2j1ghFCNuMtKwakH9FHBSbYVR1R9E5vlsKB4CZUN0xRmbAQHXIvfPBj?= =?us-ascii?Q?hV811+pc/Hnn+3oJXeqNTe0L25sPVuRIx5jV6/pnzZwLzFKc1MlPpyQV4tkC?= =?us-ascii?Q?8NGIlqFwkTu1yfoCjlTtAq1vY6gWWAAziNOiDaCuEUmphKajq/SjXLeFBYHm?= =?us-ascii?Q?06qZJfmqqKNEUj0KsdgKVq+TbbEmV9pF9mheXMsSvhn2HS4c6fplev6DMKAX?= =?us-ascii?Q?k2OsPo/CtvThgIp01OknEy4SicbpoGCZbJfj2QR4HMBPF8vvvzJEPlaSd/+V?= =?us-ascii?Q?3NjEOCNi4JOYL9ClVobtb6e4XfyxWHTOCtWpLzUaWdQj85lo5IvEUODc6/mS?= =?us-ascii?Q?VCgwyVsLpGz6os6x87M875A89ylPhOquj5CYeGHDnnRvAZMrqPRij4u09hiM?= =?us-ascii?Q?uF4It7aNBYNbrxxvha47DLZ/loF4qLNh2X3trWeN6KdvhZDfdE+Za3d/rdmA?= =?us-ascii?Q?oXWWyHqHYkx0Yph5tuJBblmtEzWF65PVxBVVn6uYVlZoKKGGedX6uIYknuqO?= =?us-ascii?Q?RrPkhwb8NJl86a1mgCk1fy5/FsZAb0I0sz7tBxpvSr3sP7oh9th7anzmlhtx?= =?us-ascii?Q?pOoppul0kdT/pdHSE75JhHt3+klpFcNtDoSf9JbialTPdnGooU+DDQtKgQgo?= =?us-ascii?Q?+AjB0/KOljPRli71sBwuIYOJ3brYMmnZg/ep6B9OeQMcXHT+VEQtJY7/hjw0?= =?us-ascii?Q?t5gfU+ko4gb8UD/iabrRIiG173er?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:55:25.2459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b482132-61e9-491c-4234-08dc7c44996c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF0000C37B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6534 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716591358393100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang There are use cases (for example using the PV driver) in Dom0less setup that require Dom0less DomUs start immediately with Dom0, but initialize XenStore later after Dom0's successful boot and call to the init-dom0less application. An error message can seen from the init-dom0less application on 1:1 direct-mapped domains: ``` Allocating magic pages memory.c:238:d0v0 mfn 0x39000 doesn't belong to d1 Error on alloc magic pages ``` The "magic page" is a terminology used in the toolstack as reserved pages for the VM to have access to virtual platform capabilities. Currently the magic pages for Dom0less DomUs are populated by the init-dom0less app through populate_physmap(), and populate_physmap() automatically assumes gfn =3D=3D mfn for 1:1 direct mapped domains. This cannot be true for the magic pages that are allocated later from the init-dom0less application executed in Dom0. For domain using statically allocated memory but not 1:1 direct-mapped, similar error "failed to retrieve a reserved page" can be seen as the reserved memory list is empty at that time. Since for init-dom0less, the magic page region is only for XenStore. To solve above issue, this commit allocates the XenStore page for Dom0less DomUs at the domain construction time. The PFN will be noted and communicated to the init-dom0less application executed from Dom0. To keep the XenStore late init protocol, set the connection status to XENSTORE_RECONNECT. Reported-by: Alec Kwapis Suggested-by: Daniel P. Smith Signed-off-by: Henry Wang Signed-off-by: Stefano Stabellini Reviewed-by: Michal Orzel --- xen/arch/arm/dom0less-build.c | 55 ++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 74f053c242..2963ecc0b3 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -10,6 +11,8 @@ #include #include =20 +#include + #include #include #include @@ -739,6 +742,53 @@ static int __init alloc_xenstore_evtchn(struct domain = *d) return 0; } =20 +#define XENSTORE_PFN_OFFSET 1 +static int __init alloc_xenstore_page(struct domain *d) +{ + struct page_info *xenstore_pg; + struct xenstore_domain_interface *interface; + mfn_t mfn; + gfn_t gfn; + int rc; + + if ( (UINT_MAX - d->max_pages) < 1 ) + { + printk(XENLOG_ERR "%pd: Over-allocation for d->max_pages by 1 page= .\n", + d); + return -EINVAL; + } + d->max_pages +=3D 1; + xenstore_pg =3D alloc_domheap_page(d, MEMF_bits(32)); + if ( xenstore_pg =3D=3D NULL && is_64bit_domain(d) ) + xenstore_pg =3D alloc_domheap_page(d, 0); + if ( xenstore_pg =3D=3D NULL ) + return -ENOMEM; + + mfn =3D page_to_mfn(xenstore_pg); + if ( !mfn_x(mfn) ) + return -ENOMEM; + + if ( !is_domain_direct_mapped(d) ) + gfn =3D gaddr_to_gfn(GUEST_MAGIC_BASE + + (XENSTORE_PFN_OFFSET << PAGE_SHIFT)); + else + gfn =3D gaddr_to_gfn(mfn_to_maddr(mfn)); + + rc =3D guest_physmap_add_page(d, gfn, mfn, 0); + if ( rc ) + { + free_domheap_page(xenstore_pg); + return rc; + } + + d->arch.hvm.params[HVM_PARAM_STORE_PFN] =3D gfn_x(gfn); + interface =3D map_domain_page(mfn); + interface->connection =3D XENSTORE_RECONNECT; + unmap_domain_page(interface); + + return 0; +} + static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { @@ -839,7 +889,10 @@ static int __init construct_domU(struct domain *d, rc =3D alloc_xenstore_evtchn(d); if ( rc < 0 ) return rc; - d->arch.hvm.params[HVM_PARAM_STORE_PFN] =3D ~0ULL; + + rc =3D alloc_xenstore_page(d); + if ( rc < 0 ) + return rc; } =20 return rc; --=20 2.25.1 From nobody Fri Nov 22 13:44:03 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=1716591349; cv=pass; d=zohomail.com; s=zohoarc; b=E2JJClKcPKrB13wSlnOUwIGCkvEV8cac9fNKCwkYZ56n7yiGqaeyYe3r7Cuig1+nOV1xNqPGxXB691RHbW7KA2u7u0JzbjtLBi1l/Jal0ZScb3wvn+11holdL0rXab6SPas0CongfbMSn/h6M+QvSOdz+wCozqSrwC9qT2XYf1U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716591349; 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=FumphntemJECKnhgVYvneYgiginHtvLBa1WGte3c0qA=; b=gP9ywfogwIQ/NYCtmXC2qAVu/bYTO9+4AoUr0DlwxnUrONir49cTjXoDCO0R7CM7xdiMPRNKxo28UFiXH4Gx0DOtcALQzm2Nwe9vc1n6ErSSr2MsU3ErLtvtkplB8x6Mdnbbj99eLLhHSjUz3Xo+VmC5BRPvUQP+RnPq7kGg2CQ= 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 1716591349453127.79731278365648; Fri, 24 May 2024 15:55:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.729963.1135321 (Exim 4.92) (envelope-from ) id 1sAdoz-0004FQ-RY; Fri, 24 May 2024 22:55:33 +0000 Received: by outflank-mailman (output) from mailman id 729963.1135321; Fri, 24 May 2024 22:55: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 1sAdoz-0004FG-MY; Fri, 24 May 2024 22:55:33 +0000 Received: by outflank-mailman (input) for mailman id 729963; Fri, 24 May 2024 22:55:32 +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 1sAdoy-0003hQ-B1 for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:55:32 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f403:2414::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b7c3f78f-1a20-11ef-b4bb-af5377834399; Sat, 25 May 2024 00:55:30 +0200 (CEST) Received: from BL0PR05CA0026.namprd05.prod.outlook.com (2603:10b6:208:91::36) by MN0PR12MB6031.namprd12.prod.outlook.com (2603:10b6:208:3cd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 22:55:26 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:91:cafe::5a) by BL0PR05CA0026.outlook.office365.com (2603:10b6:208:91::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.9 via Frontend Transport; Fri, 24 May 2024 22:55:26 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 22:55:26 +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, 24 May 2024 17:55:25 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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, 24 May 2024 17:55:25 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 24 May 2024 17:55:24 -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: b7c3f78f-1a20-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PRdSxu+XN/ZW2GQ5HrLeUE2ojTfJtJP5H833elqm8+dCzt4nobooZ9enOSnLfx1sBhcK0z7NysVwM4nBWhx3KVhwTZBXSX83xRve4KoBun0wHFzxBcKB35N60jLpD4OfIrkVpomjqF0hvXt8loDlCGavuRXNXGVIKmeDMidkm4KQ8syCaKuFlfyMSnoU0SA/4BhgWLvV6IFUmnQVN9QQdPDv5M3yhnOpresV/ZovNonTqb+H9ns3igJnXUnVq62Qf0Tg9dNv0S2bthGfiU75PpARVeoIr+ojQWtQPXX3wUvefE/8totGVUOAoxywb10wwDoBdQ4vNn+pY+pWX7H5kw== 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=FumphntemJECKnhgVYvneYgiginHtvLBa1WGte3c0qA=; b=afGXK/5nfdz4FNrBl1zmsXjAqV0DNrafnleTKdh0nwANYSGWdpz6PAJ4HTo6D+m3CaGOCsF+rwIURAG8408/b5AbIT/+jGhu5MlMITDs8wOFqRdHcylWD0X7zhMVp0w7XiLYzybUoI9d5l7yChu77iZOmTFCHszaDlZvMLCJBEmIdn9911Lz+jic96WIyQxBC5hwqof7nMv1uj+q/3FW8gc1tPNJyUNzOCaGXiAf4KrhwbC3LzKNqMn5BI9P2zM6M1vNew8B4ZMDh0eDigbIbNDBXUFb1D3ejaad/k8VwhRcoGMDF5tDs1BFGM1L2EXWVr9NSe/CvvHlj6QWiY9aCQ== 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=FumphntemJECKnhgVYvneYgiginHtvLBa1WGte3c0qA=; b=fGBXjkIVv5++lnx8mqLMZJXu5BKMcnsT1Zk7j10NfC1qSTJpPkQOS65aHnIEjBOAzuJGpfRo0dQ1mD81C8BFg7AITkZeQ3BjcIicChOuJEN1px5RbOi/VRuKuTRheRN4oYbSzLfD2U30dWrm76wswsGVGNqvYsy0wcReCokSUIQ= 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: Stefano Stabellini To: CC: , , , , , Henry Wang , Alec Kwapis , Jason Andryuk , Subject: [PATCH v4 3/4] tools/init-dom0less: Avoid hardcoding GUEST_MAGIC_BASE Date: Fri, 24 May 2024 15:55:21 -0700 Message-ID: <20240524225522.2878481-3-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB05.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDA:EE_|MN0PR12MB6031:EE_ X-MS-Office365-Filtering-Correlation-Id: 309ceecc-faa3-4e74-3bbf-08dc7c4499e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KIxqkTzY8QQ85inv/yQ3OyXd+w3NONL2ZDLaH64xcnGIDqYEbhLNMVoLWc2Y?= =?us-ascii?Q?SwXHbgtNyLcicxUs5myfcVddrbXi533X5Mci20STU0Aqu/HcR8rFraGjiXnA?= =?us-ascii?Q?aa+dpqQYDuEqDpK4p1+sGe8CxJ8M7/Glt9Oa1jAXMGl+YUzKdGoiIZW/xn7g?= =?us-ascii?Q?mo1Xg8fcNj9OUJ5pxLqp0na2TrmtVjCnQpEVyV2VXAfQsBQozup7Qz1t4CPI?= =?us-ascii?Q?76QfEXhqUpBS6WLCBC5CQc4Vl7mAiHly55wibBY+ozJdxnO6YtHc/LJBM3R7?= =?us-ascii?Q?wosG6eN+RNcWOXGLWlP5IhZhPD1O4pXzkEgVAT7YnUGj+zd0NAZs4ubenZxo?= =?us-ascii?Q?rnqr3RFHr88dR8mmXOx/Zpom1xkTQAA3CH+jBQ1KHjvvH+H9olsLOeTs9Ol/?= =?us-ascii?Q?pBkIErNyCb6QOnsuCfcR9K64SogHHYJ3qhakRWseWHBJlCfvbsy+ScF1Ct5O?= =?us-ascii?Q?lifg5IisDeZ4QFhwmCrzs7RWjPIp7ZVB7q4Lsd4pf9YuYJ+S9V+pEh6jS7MI?= =?us-ascii?Q?o1sLzscU4jCt1jRFvbq904eHSB8Ogdq+KQI7yeSn0NugeoDmE/QuM90EP4de?= =?us-ascii?Q?NsoF3gN9Nob0WlqBOg47QOhrRng8ve+LHX/F63aDiWGwW8631/BeRacO2iAR?= =?us-ascii?Q?XQRScUGQsF58pM+k5q/Bw/FZ0IcvWAZqZTk1WlglXN+izXbGoLKnfpWFG1jq?= =?us-ascii?Q?A7oxxB2t4EOuOXaH2wSaDFn3LnKQ2LmXCNakMkTiMVm7bsgNcevsmlW1Y4+r?= =?us-ascii?Q?znm3xnXYmWj2VNpzuK3PMelvj8OZLgwk6MkSexLZimPYGJg3geoJ/CE/bR9c?= =?us-ascii?Q?6it/uiiPZLBaSXWBeGtg+rqZfFGMuauxkRL/uR/qQFsoizNrV4P00cfI8WSr?= =?us-ascii?Q?mAj0mP9Cozdj5w4hEjVwcE842i5GYVtakAcgeRNFRh4uKGvWyoVtywRS/hvt?= =?us-ascii?Q?fL3DpSP2b6ItJ8PeGlVl6FjcHZFL96p1zV6KQI+XKwtqWwrchaOipYU1sKEY?= =?us-ascii?Q?2xbykewpuOtAviGC1zECBwbCBFRQU9A3m7KfqtmOCoXiUyISxUecV4xjDeTm?= =?us-ascii?Q?ohxQu0P6RF/Ou5j6K33SZbcl9YtA5qMamCsJ6/fRy7SBMDxGzzPC957LSMVL?= =?us-ascii?Q?shh7nv27eJJ6a3Km8TUVozIZzLoAH9xHTN1Zbd7YMiyZrb8ewn4oJlj4Z9Po?= =?us-ascii?Q?eNTwVYFi6l7EXfhCwNZFthmlbHoMHh/xSvsNUqY6p6l+UGcdOSYm1uVenBdv?= =?us-ascii?Q?yZVayBquQ3O8lKbPRcaC8ZdLsoRNjXMQOoC95k6r1lyl/TaxJXqa7W8jjqfG?= =?us-ascii?Q?CEEZQpi/LoJImHsrNVrxRNtBTS5QHnKoN4WVPY0d2/vaayrJVkdu5bTBItIK?= =?us-ascii?Q?VLy6Vodm64w+Zy2HvsioqFewCo0R?= 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)(1800799015)(376005)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 22:55:26.0594 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 309ceecc-faa3-4e74-3bbf-08dc7c4499e1 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6031 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716591350370100003 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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 CC: anthony@xenproject.org Acked-by: Anthony PERARD --- 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.25.1 From nobody Fri Nov 22 13:44:03 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=1716591353; cv=pass; d=zohomail.com; s=zohoarc; b=AlT9rQP20hrZyWmvbPbqRc0fM6IgWo3FGp4l/m+ivycXwidru5IsMbnTNPHH5k52at9Q7m2qUIsLmXWNlmBCXcnK3B+hLCIMALRoBxUV6EkQiF8Q6RfnzokSFB+yb9X1lGdTszmEiSdnQVa6sg76V8BHOCJTKh8CNEt9Vzg32UM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716591353; 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=bm9n7d0lv39csuk5HxxqaBGOy78rYQuqOosnK5AZnWo=; b=Qxqv+V7ZXEk9pXcDQStf7IMjWSYEqeu1s9jPVfkID7haeIVlyTQQcaX5q438puW/7Dr8WhTZG3z9KBKgCcVjyozyH6NG+hOuR3ktVldg5QRMA3svHH2zulqmVCVKWXQGesqmJQsW242pMjJ9oCFCJDnW8KC/YObCTBdXZBFqOVA= 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 1716591353714191.63265188974128; Fri, 24 May 2024 15:55:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.729965.1135330 (Exim 4.92) (envelope-from ) id 1sAdp3-0004Xj-37; Fri, 24 May 2024 22:55:37 +0000 Received: by outflank-mailman (output) from mailman id 729965.1135330; Fri, 24 May 2024 22:55:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAdp2-0004XS-W3; Fri, 24 May 2024 22:55:36 +0000 Received: by outflank-mailman (input) for mailman id 729965; Fri, 24 May 2024 22:55:35 +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 1sAdp1-0003hQ-Pe for xen-devel@lists.xenproject.org; Fri, 24 May 2024 22:55:35 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20612.outbound.protection.outlook.com [2a01:111:f400:7e88::612]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b9b2213b-1a20-11ef-b4bb-af5377834399; Sat, 25 May 2024 00:55:34 +0200 (CEST) Received: from DS0PR17CA0010.namprd17.prod.outlook.com (2603:10b6:8:191::26) by CYYPR12MB8921.namprd12.prod.outlook.com (2603:10b6:930:c7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Fri, 24 May 2024 22:55:31 +0000 Received: from DS3PEPF0000C37B.namprd04.prod.outlook.com (2603:10b6:8:191:cafe::2a) by DS0PR17CA0010.outlook.office365.com (2603:10b6:8:191::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36 via Frontend Transport; Fri, 24 May 2024 22:55:31 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF0000C37B.mail.protection.outlook.com (10.167.23.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 22:55:31 +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, 24 May 2024 17:55:26 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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, 24 May 2024 17:55:26 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 24 May 2024 17:55:25 -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: b9b2213b-1a20-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dnrCBpNrmfHy7+Kd8KYhHEIbY0uedHDgUD5UuN6PTWYJGbhtzdX+pat6YhwZd8YhtS06+qszkr+qsqqKIUDqPNCHYmb3uReTcLly5PkDnH1p8tKGZeQ769VKEDUI7OW3bCuXkDYTE9LpfI6hqdNV6UuuWF1YdBg8Ydoh6tCFpyMZkebFMyNdW3qkJmHFfVzHoPSJcstujIDLcfsdbqJ6COqzth/yZzzeFfhEo5Xe7frSZySoa80F/eA2BL5rMVqemVsBSycna6Yb+882JTfPrpuCAvQCaMmHrP7FGyDcjy2Vjso5lv40CkhYjqnRK3dRqlLGNcsxWCof/mKppkfQUg== 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=bm9n7d0lv39csuk5HxxqaBGOy78rYQuqOosnK5AZnWo=; b=jDfES2qfzbdw9HZD2zYMxLw1k9YsFzQX4MTi0v6q2BGnyF3CXEj7u3lzhZsFCn1byxjzs2M1QF58ur8uEDOOmGhNcMwpQ2qIj2Z/4jNKdKS8amclzW4zoN8IQfsYXTM7Wp7+PGcGHXFSnlOmo3SrZ39/7/2a89r63+kBojiKRNFjYWivCLQOqKG5RMPld6BK9dhEOPNxNPLTbG9YUbXiAlDT1VB448cIgLX7VQW8vnnVWdpq6mlZb/3MqSdAX6yqnRhXW28/6ztOP0O3JUVnbXSEIeqvu8iagFZHXJhUOjoi5uvOzamy1XELIjCWwoI3rlWufWF3JDE6mGsWoMAjgg== 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=bm9n7d0lv39csuk5HxxqaBGOy78rYQuqOosnK5AZnWo=; b=IwQEMAv+Oe/Lx2FiUMjPDh28/vGS7kgI+uRC+EcE93yD+IXaOpvb7JGIRs/x9tf2FZ9c2QNa/FPAFtcpxwLruKZRVAvufSPIAnD3RFRFMh5MJ1FHhG6kqbAqsGgTxEdRqTt4Fx87RrfE33/osYpCg/8QpykRycCDZBGPALbudZY= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Stefano Stabellini To: CC: , , , , , Henry Wang Subject: [PATCH v4 4/4] docs/features/dom0less: Update the late XenStore init protocol Date: Fri, 24 May 2024 15:55:22 -0700 Message-ID: <20240524225522.2878481-4-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB05.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C37B:EE_|CYYPR12MB8921:EE_ X-MS-Office365-Filtering-Correlation-Id: 536ff34d-cb6c-4bc7-555f-08dc7c449cea 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?3ZTtasn9ADcl2gwGhIWw2r5zzUZzb2+JF2TMnHN/LUZ702OrTzcXGgC3LbqV?= =?us-ascii?Q?Lz2s2SG8RzBwXzZnDheg/6dP5ASdKx+yFOawIYRzjNXEMxSO4++6AUhPj9sK?= =?us-ascii?Q?9UH6lpSAfbuApknpQ1vpNC3R9pCQNa7wljFHsOKj8SaAP9F7si3CsW7yv5Lx?= =?us-ascii?Q?xiYekh+92jHeNOANh2iXVM1+E7dECzj2d15F6TAGuaa+VnH6rbpax5qU2Wo0?= =?us-ascii?Q?oW92xCC3mEnXLXHW5Sgt1IaEfgnK9PZakScP0fEOZYJn4dyKbICaRRU7kGWT?= =?us-ascii?Q?L9KkJl+0JTSmCwyt53mu25iAcdEtx1bxFq0vZwBzus6/gQ4mi2PXANOd1Fnt?= =?us-ascii?Q?qkoVuWDejpMTdHDcZ/8jEnpkhUTdOX1ojzZIaR6Wxqykom+SjnbZW4l0i031?= =?us-ascii?Q?JFZLtgE9SHHMQrow9KADZ0rmtyhjT2RCxLy5dUqsANYAHG7LBRAYVXhpst3x?= =?us-ascii?Q?bJJxeo3BBNTG86cAZTPYZ7yUwMQkXVY29Ebpd7Lf7ohGG/aKEwC/j7JBL3rD?= =?us-ascii?Q?S88uggv1/xdHToUPdQkQ5aoVI4AVMZy49emXOypRYCN+xGLlXKuWJBWVf6+c?= =?us-ascii?Q?bJVDFZYj93IycEm2mD2d8giq7Kb1A24Zgk1DWLmoONh/MT/lSvq1E9iW/9qg?= =?us-ascii?Q?9LQqzEQzyTXVFXlc5fHk8snClDJXmuEws1YNvoY7KHU0+ZUyvcLx/tFr9C2n?= =?us-ascii?Q?7VzwCdh+LXvFttB0opPW1U7mh7ZBiAI3LqWh8pM6cAyM3uFOPubp0pFPus4W?= =?us-ascii?Q?Dlrk8KSdUDy54s3EizePCRMY10yNLOJlklp1LQxkkYERDBuagctqcgobiI+g?= =?us-ascii?Q?2/DwuSRRNc/KWSkGD+gU5cpIf/vsSHBtvMlAxCkVon6XBH/R9XpjHIgfBk/G?= =?us-ascii?Q?15Qpds+H/20VFFXnEK9K8vQCEkGPaYI1nJNEmYwRFFznZeQ8z5NK4A5xnioF?= =?us-ascii?Q?Z3rNruJKrbWglZe4ij/PJBhIX/qLOVQ3xbt44h7A+sqHP050xqXQphFjB8nz?= =?us-ascii?Q?rfvbzHfNdIh0xQ2nns3Ojhe7RXG47J+ZH+tNJCNr0lXhrqAWpkq6S6JbySEg?= =?us-ascii?Q?GZuY9YiKGivY95QJ7dP5AR7MgryuMFzQJq0QqI3sU7fyUm5w7qgnm2IG7U4e?= =?us-ascii?Q?PESaZubfER1A07ByZIooYD39ww4s0ONrBUMxTokZERxOf5DBcLcb4PbEN5BC?= =?us-ascii?Q?NCV9rCNnu4A6hbJQ2Guk9uXlbG7TLhhTk/70X0l2X8WFOiCRHVjQo6dw97wS?= =?us-ascii?Q?bdrALJNd1Nb1YLIE5V7ZcUrv43CYWEdtCWMw0CXUAxrJAi1fR0zSsK9kJiTy?= =?us-ascii?Q?25R2K6mYbVZd6NV8dw64ux4IKTpn8HQd9E4ipF1M7niILpF9RdE+7ZFUDac5?= =?us-ascii?Q?zVYSsxFVx5/eON+mvSZXh9DSGRE9?= 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: 24 May 2024 22:55:31.1053 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 536ff34d-cb6c-4bc7-555f-08dc7c449cea X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF0000C37B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8921 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1716591354427100001 Content-Type: text/plain; charset="utf-8" From: Henry Wang 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: Michal Orzel --- 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.25.1