From nobody Fri Nov 22 19:52:30 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+eThX0zJ8FJ39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DuO?= =?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