From nobody Fri Nov 22 18:55:46 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+un0Y5stM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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