From nobody Tue May 14 08:36: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=1694440858; cv=pass; d=zohomail.com; s=zohoarc; b=hyCVXZFRmyLmzrckc30mrh6Sws+9z5usJj+vA0lQ13mPAQvLK2/mGxjCQN+mBcXK5aQ+vXQPSSvKqT5sm77I5eP1+e8CGivwwFmindZIiyvzi3r1A48vDMHyb3WX5bHTzSRMEdvqEIzti6dGXR8QjiWeg3OgdEr35x4SzHmr/e8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694440858; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RmqowAx24OOOJpsd+S0aluwjNaHIyEOrBq4/krDyslU=; b=mV2JQfBlbrrXNtG5n9IDrlL1s0l9rgi/g9PcZwTcArNn0Nkk7MsKw04KYJHipSqZ6ce6Q5PHOE5g31KXutFJ9xOGbjJYWd+C/pqktc5OkLE0ufCcjkbyG+tHsQPD25A0DSKAM9ZbaVzUkXvXamK7YvH7ekHdjz0DKd/t8ckHFEs= 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 1694440858531285.9495502861413; Mon, 11 Sep 2023 07:00:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.599435.934865 (Exim 4.92) (envelope-from ) id 1qfhSy-0005gw-5k; Mon, 11 Sep 2023 14:00:40 +0000 Received: by outflank-mailman (output) from mailman id 599435.934865; Mon, 11 Sep 2023 14:00:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfhSy-0005gp-2x; Mon, 11 Sep 2023 14:00:40 +0000 Received: by outflank-mailman (input) for mailman id 599435; Mon, 11 Sep 2023 14:00:38 +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 1qfhSw-0005N8-Na for xen-devel@lists.xenproject.org; Mon, 11 Sep 2023 14:00:38 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 957a18bc-50ab-11ee-8784-cb3800f73035; Mon, 11 Sep 2023 16:00:38 +0200 (CEST) Received: from CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) by PH8PR12MB6842.namprd12.prod.outlook.com (2603:10b6:510:1c9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Mon, 11 Sep 2023 14:00:33 +0000 Received: from DS2PEPF00003444.namprd04.prod.outlook.com (2603:10b6:610:58:cafe::ab) by CH2PR20CA0009.outlook.office365.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35 via Frontend Transport; Mon, 11 Sep 2023 14:00:33 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003444.mail.protection.outlook.com (10.167.17.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Mon, 11 Sep 2023 14:00:32 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.27; Mon, 11 Sep 2023 09:00:30 -0500 Received: from xcbayankuma40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 11 Sep 2023 09:00:27 -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: 957a18bc-50ab-11ee-8784-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hQATQon54Un8o115gnezS4f6Mh0PUs8zKbUxSeBVL1cHQjIHXyT9wKYbV6JpErgrEMux6N0z97OKgpeyWl1eUX51BLlqiuJeE9jOu+y6h9NMwdPrBm5ndZ7PUIsaXPcZc9bPa7oI3T/5FkkfHaKhSDVKlPMMdmKqw+9+9sNszVnUlFDJeg/pMaxS8k+ZKt7KmWQ33QfeuDfJe61x2xOHUOxoDtrCbhmqs0n68Ywh1uIXoL9rZUGpOyPkEQGHFXvuoY3amsmHn5l0oIUrqB+hqo3/w7YoB5XVtp6y07W9t6YGEt3RrNhUck3zFJ/uWnbAkeaN9AlNdVi09DN+tFTXyw== 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=RmqowAx24OOOJpsd+S0aluwjNaHIyEOrBq4/krDyslU=; b=lcHWLIcN7iLuDKg9TRU2YdtboHNwv9GI7VsNHyk/5H3JKQQ0bBQ0Vfvyv43pct6oBzJDT8cdhQvwdgn9ZUkPckI4VtHQ0S9SZY2t2DajAYYh6pgztuLO2tlmfIYeSeaNHP/rcXRS37OnD5kduTv7HRIggOM8tN+pbAs6+25kcJi/iw3A5g1/5yOZoa/w3V7vrqKDeuwOwEXD4O1/lh66iuR0kXN+7kqhsIOXv2hGRMdZtU0NumXwx5TuPKGCpoz08CnDrX7v/SGz786N+Rz4yoXol+PBgWC0Y6HcELQO+vnDcD/Z9OJMtt5elPa01czG9yE1lxSVir7euQ6my73CWA== 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 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=RmqowAx24OOOJpsd+S0aluwjNaHIyEOrBq4/krDyslU=; b=SWBERPDTKhdYc2VxczkT/Hx5JLZmPLs8ikpyOdrNHptJxA4Nf0yUv+pqd3xwdD/WP4JXPU992qTAZG4wmENPIqSlPvqYGmM5PQ6RsK99iAbYJSAxRENXSazSta5If9ttxEU8onb4Q09YnzZcw0V9vUyaUy05E8A16nbGdyF5y/8= 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: Ayan Kumar Halder To: CC: , , , , , , , , Ayan Kumar Halder Subject: [XEN v1 1/4] xen/arm: arm32: Move pt_enforce_wxn() so that it can be bundled with other MMU functionality Date: Mon, 11 Sep 2023 14:59:39 +0100 Message-ID: <20230911135942.791206-2-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230911135942.791206-1-ayan.kumar.halder@amd.com> References: <20230911135942.791206-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003444:EE_|PH8PR12MB6842:EE_ X-MS-Office365-Filtering-Correlation-Id: ddf0bd6f-988c-4cd3-2564-08dbb2cf76f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VIbAHOJkt6eWHotY3vePWYxqmDkyPs+5vOfEtmssDw/U2GHiwM+r7EBenZoe8AIwV01HXjbGedbEJIpBfZwQOtAiRGKO7zhSagCOifnMnzUmp9A+6jCaO5ioWg7ipfCVF3vaLPJlyrA0DuJUPDRdhM6sxBy+PHVD+Y1dn/mX67IcvW3NESjV7BJP0PolmLtiRlsGwuQimrxgqM4OKAjjtfJLiL7YBGIxlHVB4X1q8ULCGXQ8/ZsPbXbm6iAMFSZbElJdtZdU4uv/fc2AJPlZkUwAckXAmMsX6bx5n82bOHnuw6nGCgPZQgex8HzJtj20LQoGIqFQNPVDmlR/N3xdPD43bl/jj6xAG306Tezg47iOXqiZVYe5NVsDZ9PuHyo8a4KjcSORJW5jRx909dPvZKMlHT+sYwoxGp/kqeIvrDdG9wfe4PI8CEwqRWugea8hjiqPI+cjHDL1pqCQ2DNhuQFED4aHrMtHGZkUAcwQQn4yAdLhUV7zwyJj2GTyaStXnlnqNQ/o1vwAMb/YUHZ9b0xot8lnh0ytImgYbFFqRkl6PnJsaFbKPnCASScS0cfuZAKPkbZtD/gPaCkmUhfMDdskhjHnccwacSyaH2g8rZ750znNGuw1mSKY6lbdC8lesBD6inrRtksK93lpry+n0rtvOwBQLFcrxNr/AK6LQDHTEkkFoXo6k5CFsIa8BUOfcCy6ctvIiWRQl8uUD02spWe+Aul8N45r0IG+WW+zF/b58StWUkUJSZtnNiBcMBDnS0JKYwgRfqVn+fXEZCEumQ== 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)(4636009)(136003)(376002)(396003)(39860400002)(346002)(186009)(451199024)(82310400011)(1800799009)(46966006)(40470700004)(36840700001)(70586007)(70206006)(40460700003)(336012)(83380400001)(1076003)(4744005)(86362001)(2906002)(26005)(426003)(2616005)(103116003)(40480700001)(6666004)(36860700001)(356005)(82740400003)(81166007)(47076005)(36756003)(478600001)(5660300002)(8676002)(8936002)(316002)(6916009)(54906003)(4326008)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2023 14:00:32.5765 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddf0bd6f-988c-4cd3-2564-08dbb2cf76f1 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: DS2PEPF00003444.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6842 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1694440920456100001 Content-Type: text/plain; charset="utf-8" pt_enforce_wxn() is moved up (as the previous instruction ie mov_w has no effect on this). This way it is grouped with other MMU related functions so that they can be moved together in the subsequent patch. Signed-off-by: Ayan Kumar Halder --- This is based on my comment on "[PATCH v6 08/13] xen/arm: Fold mmu_init_secondary_cpu() to head.S". This patch can be ignored if the comment is addressed. xen/arch/arm/arm32/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index c7b2efb8f0..057c44a5a2 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -268,12 +268,12 @@ secondary_switched: dsb isb flush_xen_tlb_local r0 + pt_enforce_wxn r0 =20 #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS #endif - pt_enforce_wxn r0 PRINT("- Ready -\r\n") /* Jump to C world */ mov_w r2, start_secondary --=20 2.25.1 From nobody Tue May 14 08:36: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=1694440873; cv=pass; d=zohomail.com; s=zohoarc; b=nRKvRcc1oywLh7wclRf0YBw0nNL6t6LwVKMjW1k1oamQ30iWTxz7gdB4aTCTYFThg0DW2+1XU3FjtFEqVNOtWZW4SKw5B0z2C4s5udKlhrxA9GNIskwCd5WYihPnG1BsYUt7ZgkMk3ZvjCwKi3IXyTU/NZAF6eacvFvt3pCsjCs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694440873; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kRY9UbEDG6nTXq04KFID+lWxWkzScTYfxvU19N9FVto=; b=laOpUXJnMc2jMGi1ROtLbMlbEb5iChjNqG0UHCQOc8nzTBi3dzVoQnjBMCocPnvyEfLQHb/iIJ/uDV2H2YEP0KW1FyvYL2CBXhgXIa9nwTPuX0ZjChSfiFNCACu/21TOtv7YAnAKjoYfFHJD8nAjL2r1gN4LApe6qJYYWybzmhI= 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 1694440873124849.3509225406569; Mon, 11 Sep 2023 07:01:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.599437.934874 (Exim 4.92) (envelope-from ) id 1qfhTD-00065C-DG; Mon, 11 Sep 2023 14:00:55 +0000 Received: by outflank-mailman (output) from mailman id 599437.934874; Mon, 11 Sep 2023 14:00:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfhTD-000655-Ad; Mon, 11 Sep 2023 14:00:55 +0000 Received: by outflank-mailman (input) for mailman id 599437; Mon, 11 Sep 2023 14:00:53 +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 1qfhTB-0005N8-PM for xen-devel@lists.xenproject.org; Mon, 11 Sep 2023 14:00:53 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9e810d98-50ab-11ee-8784-cb3800f73035; Mon, 11 Sep 2023 16:00:53 +0200 (CEST) Received: from CH2PR04CA0021.namprd04.prod.outlook.com (2603:10b6:610:52::31) by DS0PR12MB7745.namprd12.prod.outlook.com (2603:10b6:8:13c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31; Mon, 11 Sep 2023 14:00:49 +0000 Received: from DS2PEPF00003444.namprd04.prod.outlook.com (2603:10b6:610:52:cafe::af) by CH2PR04CA0021.outlook.office365.com (2603:10b6:610:52::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35 via Frontend Transport; Mon, 11 Sep 2023 14:00:49 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003444.mail.protection.outlook.com (10.167.17.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Mon, 11 Sep 2023 14:00:49 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.27; Mon, 11 Sep 2023 09:00:48 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 11 Sep 2023 07:00:48 -0700 Received: from xcbayankuma40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 11 Sep 2023 09:00:47 -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: 9e810d98-50ab-11ee-8784-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FMfuXEPV4FiAganS7x5zuheUqg6EA2clj2LBu76e/ej5WQR9Juz58pF56fcp4E+D2fUjWJLpzj7yV2+XsWr6z9lbl5Zw5pw1d7Xqi+BycUtL6Tu+xbLd7VkhayvqVbq7cvIgUXTZXDuCGrVH2rUgsPZ95BgRLLUgEHPk5+9z3040VBZnuuxiRBlJi83qZHrKXFqVBIhlPC/S00mJRTJR9nIUIDLb6+JKZuZ7XdHTVShiGZyvNt5xxjV/rzSw67IqlFVgTXrZORJDuwViWw3b+D4qfCiVzFCtbPOlELPdwcKCcm3uT0rcHcQ7DGztOq3Jfjx2teR3o5I5hhj6h9tCxw== 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=kRY9UbEDG6nTXq04KFID+lWxWkzScTYfxvU19N9FVto=; b=HRoSBNQvoGlXTGY75a+RSVc1PLRUGIOg28cNtWsvdce4dKE73VGgtyyiKVS7j65yLvrMnPSKfHhw5FEp5kO5Eh96rlNjArCXuTISMCItp0F/Bfk+iDTRc+o07q9dMV/9zJO80n3jNcVbuSGw7NwlxdT9yNfSwvxl0tUWZF5QK3N3edyIxbVgYG7RTLs0udhuVeyaLK71RhiPb4+KpIp1O+f+8+jBQMXgOKKdkg6r2a6V7rugdypKj8Oiacz7Amko0AIzNwFfTIFzo4ZuXloP6J38x/5SQywAxMLGHIwl3gPgR374RMgs5SP+Rv2gndgczRZSTomhlGVKNMHS7kP1TA== 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 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=kRY9UbEDG6nTXq04KFID+lWxWkzScTYfxvU19N9FVto=; b=UWlSq4iwy+JC67HXwbBoznQuAf4YB75MooFFdX7DgJ1zhb4woxQ/5fSyubcXi483opEFbGxiZH5Gbd7gQzrR787RMaMw1qT1kbBCmnuQDyPReQHzg2CgqRX87ICfhM14e8Ew0ZcnQp1xhlX3YP5i1aa2WQu7czv083xl8OW036M= 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: Ayan Kumar Halder To: CC: , , , , , , , , Ayan Kumar Halder Subject: [XEN v1 2/4] xen/arm32: head.S: Introduce enable_{boot,secondary}_cpu_mm() Date: Mon, 11 Sep 2023 14:59:40 +0100 Message-ID: <20230911135942.791206-3-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230911135942.791206-1-ayan.kumar.halder@amd.com> References: <20230911135942.791206-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003444:EE_|DS0PR12MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f51f141-1b18-4824-fcef-08dbb2cf810b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VJiYg1RMJ5R92LU8zGcShPIcgq280RaOoltvaUXww0Ak2Xu0BAENkw0vBovfBcR4qUdEKyy5h34qDKYMKqCc1BdsuNk2olHB+eDO91oG545Oz9EPAdMEkV9CCEfOTOmMOxp1A1e0U7452flLMYQYmMCn7EoJMUpZQk+LoeIN08XA49dy3dQY5bYiqLCagH4irr06zHXrntufPSHaLUuCbIFQMtVcYWsfiGbuRRti39SBmbvFOB/rMF7ye+FyzeghkdAXZDkQlYjVQypyvI9NjnVdmRN4WHcanf0N4bWGZIzjdXNzb6ESpt9b9GYpq3pirSqIZE8sYwShluqzume6qKxhBJ67d/CO54jciP9OYr5FBdXysMX1rvg9IjPODF9MlrzKx97MlQBeQOnnk7qnKUai1Bte1brC5MxYZ/XnpxOkpP4sJw2bVNhelCcn9U+V9XuiSAI4KiwgBvMksAVH6hq0dL93OqLN+jeKMEn4FSg0GaT4tVzW0e/CLyZePYHMlf/z7uCFzxRzMF8AT8c7c30RhjAA4ZwsqyCpRi0zUvdUS+JB7ToDELodpu8oin/FwM0oz+WCOZhIAPmoQW7t4nKN+0A4JO+rM60+qzacpNxAvJjyeG26/r3/FERisWOByg1MNq2PiBacO9H6SOdbLq7gPk4y594vX4ExZlZFKCjjDSbu34iPi042zhZDqa66H/DGsyNJfou1WN++e7DO7SnOEiluWyJ4UmCoTC0+ScdHY2pA0jeXXaDRHL6Ou2Tge6Ds0l7aot7PGyB0XrabZ0Sr7Z8i1zcsBVBeZlx/YJ8= 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)(4636009)(39860400002)(136003)(376002)(396003)(346002)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(5660300002)(316002)(6916009)(54906003)(70206006)(36756003)(70586007)(8936002)(4326008)(8676002)(41300700001)(40460700003)(36860700001)(2906002)(336012)(1076003)(47076005)(426003)(26005)(40480700001)(82740400003)(6666004)(356005)(81166007)(478600001)(103116003)(2616005)(86362001)(966005)(83380400001)(21314003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2023 14:00:49.5296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f51f141-1b18-4824-fcef-08dbb2cf810b 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: DS2PEPF00003444.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7745 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1694440938858100001 Content-Type: text/plain; charset="utf-8" This is based on:- "[PATCH v6 01/13] xen/arm64: head.S: Introduce enable_{boot,secondary}_cpu_= mm()" https://www.mail-archive.com/xen-devel@lists.xenproject.org/msg151918.html This is being done for Arm32 as MPU support will be added for Arm32 as well. Signed-off-by: Ayan Kumar Halder --- xen/arch/arm/arm32/head.S | 90 +++++++++++++++++++++++++++++---------- 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 057c44a5a2..c0c425eac6 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -201,13 +201,10 @@ past_zImage: =20 bl check_cpu_mode bl cpu_init - bl create_page_tables + ldr lr, =3Dprimary_switched + b enable_boot_cpu_mm =20 - /* Address in the runtime mapping to jump to after the MMU is enab= led */ - mov_w lr, primary_switched - b enable_mmu primary_switched: - bl setup_fixmap #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS @@ -249,27 +246,11 @@ GLOBAL(init_secondary) #endif bl check_cpu_mode bl cpu_init - bl create_page_tables =20 - /* Address in the runtime mapping to jump to after the MMU is enab= led */ mov_w lr, secondary_switched - b enable_mmu -secondary_switched: - /* - * Non-boot CPUs need to move on to the proper pagetables, which w= ere - * setup in prepare_secondary_mm. - * - * XXX: This is not compliant with the Arm Arm. - */ - mov_w r4, init_ttbr /* VA of HTTBR value stashed by CPU 0= */ - ldrd r4, r5, [r4] /* Actual value */ - dsb - mcrr CP64(r4, r5, HTTBR) - dsb - isb - flush_xen_tlb_local r0 - pt_enforce_wxn r0 + b enable_secondary_cpu_mm =20 +secondary_switched: #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS @@ -692,6 +673,69 @@ ready_to_switch: mov pc, lr ENDPROC(switch_to_runtime_mapping) =20 +/* + * Enable mm (turn on the data cache and the MMU) for secondary CPUs. + * The function will return to the virtual address provided in LR (e.g. the + * runtime mapping). + * + * Inputs: + * lr : Virtual address to return to. + * + * Clobbers r0 - r6 + */ +enable_secondary_cpu_mm: + mov r6, lr + bl create_page_tables + + mov_w lr, secondary_cpu_mmu_on + b enable_mmu +secondary_cpu_mmu_on: + /* + * Non-boot CPUs need to move on to the proper pagetables, which w= ere + * setup in prepare_secondary_mm. + * + * XXX: This is not compliant with the Arm Arm. + */ + mov_w r4, init_ttbr /* VA of HTTBR value stashed by CPU 0= */ + ldrd r4, r5, [r4] /* Actual value */ + dsb + mcrr CP64(r4, r5, HTTBR) + dsb + isb + flush_xen_tlb_local r0 + pt_enforce_wxn r0 + mov lr, r6 + + /* Return to the virtual address requested by the caller. */ + mov pc, lr +ENDPROC(enable_secondary_cpu_mm) + +/* + * Enable mm (turn on the data cache and the MMU) for the boot CPU. + * The function will return to the virtual address provided in LR (e.g. the + * runtime mapping). + * + * Inputs: + * lr : Virtual address to return to. + * + * Clobbers r0 - r6 + */ +enable_boot_cpu_mm: + mov r6, lr + bl create_page_tables + + /* Address in the runtime mapping to jump to after the MMU is enab= led */ + mov_w lr, boot_cpu_mmu_on + b enable_mmu +boot_cpu_mmu_on: + bl setup_fixmap + + mov lr, r6 + + /* Return to the virtual address requested by the caller. */ + mov pc, lr +ENDPROC(enable_boot_cpu_mm) + /* * Remove the 1:1 map from the page-tables. It is not easy to keep track * where the 1:1 map was mapped, so we will look for the top-level entry --=20 2.25.1 From nobody Tue May 14 08:36: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=1694440883; cv=pass; d=zohomail.com; s=zohoarc; b=bM1xsxaw6JzwE7kHQmVzTNus9rkKpsTb29wwaJKx5EvI/pOyqPBusr1fdrrHt31UWdEyoGJSWxgor+wGFGT63IVSCMzp9pqqjhDa6mMN76hrAl4wmFPGJXsEtde4moMiyaWS2kOF96qgjTz474TMo+rfmrJuq4bWFLjq4a97lUE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694440883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XAH1WiIeVJj3IAVh1Dsv0pG9StcDrOe4Q2KhJNanpNo=; b=SFFMhK/rcOEy2dF7t7bhwem/HRpYp6fLnoEHQBXnB9aboAEb95HONdbCBG1PJClDMI8bw8B88Xar0zglJBBnvb1ldvjxwMq9BLGSK4xuchDXBFizYWjEbSZpWv3soNlJORzJ/eELmH/ulviraxzQaLCE/hXms3C9kH3K2FEIe6U= 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 169444088342674.03297737242349; Mon, 11 Sep 2023 07:01:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.599440.934885 (Exim 4.92) (envelope-from ) id 1qfhTJ-0006Sj-NN; Mon, 11 Sep 2023 14:01:01 +0000 Received: by outflank-mailman (output) from mailman id 599440.934885; Mon, 11 Sep 2023 14:01: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 1qfhTJ-0006Sb-KD; Mon, 11 Sep 2023 14:01:01 +0000 Received: by outflank-mailman (input) for mailman id 599440; Mon, 11 Sep 2023 14:01:01 +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 1qfhTI-0005N8-RO for xen-devel@lists.xenproject.org; Mon, 11 Sep 2023 14:01:01 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20604.outbound.protection.outlook.com [2a01:111:f400:7eaa::604]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a1de3a97-50ab-11ee-8784-cb3800f73035; Mon, 11 Sep 2023 16:00:59 +0200 (CEST) Received: from SN7P220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::14) by CH2PR12MB4088.namprd12.prod.outlook.com (2603:10b6:610:a5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Mon, 11 Sep 2023 14:00:53 +0000 Received: from SN1PEPF0002529E.namprd05.prod.outlook.com (2603:10b6:806:123:cafe::5a) by SN7P220CA0009.outlook.office365.com (2603:10b6:806:123::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35 via Frontend Transport; Mon, 11 Sep 2023 14:00:53 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF0002529E.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.17 via Frontend Transport; Mon, 11 Sep 2023 14:00:52 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.27; Mon, 11 Sep 2023 09:00:51 -0500 Received: from xcbayankuma40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 11 Sep 2023 09:00:50 -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: a1de3a97-50ab-11ee-8784-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GZ1S9V19bzvj0fPw92FyD2CDJvTMtVMVM4hOwqbZhybte25yN0vGOt92rBBt8LwJMZ1ZnjiIAScy13wqa/zqm5EzQro3dwYSUiM7GTiBvnb6Q7RosDtpnZP6h4MbKdDRA+etGH9Z70VJ3TnJrhr5KzdL5s0WCLmG/J/xG6x1XtkN+qeXwNMG0jlct7Y8lnBNs2nE0+o+cT0br9KTXxz6vYtQHfKyFVt/3bctuF9wYpRWIf/bJHQw6nyMF2YzOYMSqZ9UZ9ApKlyd9d3nYNnG9JfaIXtFwplc7oz2/K5pD9XqlgkceC1A/dy92zlnQkvu+hLzHo2ToOBbTytRuZZ0lg== 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=XAH1WiIeVJj3IAVh1Dsv0pG9StcDrOe4Q2KhJNanpNo=; b=MTN2i9luCJ+ilMPM8zl7iAFwlJYpRJ9n8YRKpmZoz0vs3sDZR+KgSMvlXx3fnv0JlNpbqHCPKomNZ6hCojhTioFYyWAqCQ+FSC4UBqenzEW9Ky12TsXyQjhaw/nupJjf6oG8Tl9RB9RoOOa8/PVvA+I2dWMqNUcGY+5/SbZU8w8ILptF4mcGOyuX1PYGqh193lr3oJhJJ1ETvWm1B7O/ZXdXQSi+iwfzelcLZ97yhzEutkXvZiurGbobsWUBb5xXnXxs8y1riBBEZYgoxzVm+ap7ohU93kSwunLIMgZDqmJWinp6rjUXxsIg+PIQIA0gM2u6MQtLSY4MZ8F1iPGcYw== 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 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=XAH1WiIeVJj3IAVh1Dsv0pG9StcDrOe4Q2KhJNanpNo=; b=I/m/fTiSDBWzxRjtf40IhPL6nKKvWyywqfxKqBeYbomBoxwVtNmsyqtOVtYiPj2V795eu/MzG+9/SpMBoQY87SoUkx8g4wQA40z3FW7UqeJSy96Muw6DXMKvjxEsSIxyhGccoXrmvCBIqdYhyqDrncThv2JPfOZ57lWxg2V4KQU= 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: Ayan Kumar Halder To: CC: , , , , , , , , Ayan Kumar Halder Subject: [XEN v1 3/4] xen/arm32: Split and move MMU-specific head.S to mmu/head.S Date: Mon, 11 Sep 2023 14:59:41 +0100 Message-ID: <20230911135942.791206-4-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230911135942.791206-1-ayan.kumar.halder@amd.com> References: <20230911135942.791206-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002529E:EE_|CH2PR12MB4088:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c89a23e-ef69-47fd-af73-08dbb2cf82c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Crbt/7hd/h5N5lvHwAsaJb+evE1TelrcqNFsbfifa3Pl6fTBPyBH352OnGaSq35DE7bajK66IrtANIpJn3X2UD2kuE8da0uhoX+Y92P0wTVJdPeNUFL0Z8MRSQPxPI16EfEXRSZSQjoQ7mxYcY5iGrfGX0uZsDu07ZMP3TrNKH6vFBmLtjxdY98q6+1lFCQXDopOijjtA8PXn2rP/fKvzZK3NUOdRUiWCiilqAHDx3eD855AjC26DCyJY/HRk5d5IKjvHX5cFw0tgdnugIlSpzS0CBe4RBVLHrAg6urhBSiZ0YpB7ABRZuCnvvpk6ZaibckG0M3TiNArHEeVxJE/qW6x1wt9vp+VBz7uNInbP0gFGeKps9slIeu9GR3pvn52Uwsm+yWbSBEfpoft7sLDyfN7EVWAidB5VoGhjzofyt5Dsa6dDWCzuqui9OapRQXuDu6qCFK/fPa8nhhwi1RIKbQDrqJ2D3R/8Me0/Gu8gKxFhR0sWFtmngg390Qol/Yd5mqgXbm+GgJZmzUCpDxN1nriVpmDU+3irZp4CF0x7IIWu6mtAkZNf0HGt5Y9TIiC1gVHLdsZZF1b9HPGyq8jO0gDHmdo/QI4pINUmSOE58P2PcetZ3eDxhsmVwNeC/CpZ1WSs0BmHE176PG3Jc1KmdCHt/nN/DHxaMyWh3i6iSJk6tN8iHgQaYZFnGSEZyHDpnTt67cerbsk7nV+WGlV+cKO7tCKlz2ZyiShuPSyBJtLEop7iWJR62y6uoQ7EU7rvS/nh1hrClvveHT5pTEQJQ== 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)(4636009)(136003)(39860400002)(346002)(376002)(396003)(186009)(451199024)(82310400011)(1800799009)(40470700004)(36840700001)(46966006)(5660300002)(70206006)(41300700001)(6916009)(4326008)(8676002)(8936002)(316002)(54906003)(70586007)(40460700003)(47076005)(81166007)(966005)(478600001)(36756003)(40480700001)(6666004)(103116003)(26005)(30864003)(1076003)(2906002)(336012)(426003)(83380400001)(2616005)(86362001)(82740400003)(356005)(36860700001)(21314003)(36900700001)(579004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2023 14:00:52.3981 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c89a23e-ef69-47fd-af73-08dbb2cf82c1 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: SN1PEPF0002529E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4088 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1694440952327100001 Content-Type: text/plain; charset="utf-8" This is based on "[PATCH v6 03/13] xen/arm64: Split and move MMU-specific head.S to mmu/head= .S" https://www.mail-archive.com/xen-devel@lists.xenproject.org/msg151920.html Signed-off-by: Ayan Kumar Halder --- xen/arch/arm/arm32/head.S | 603 +----------------------- xen/arch/arm/arm32/mmu/Makefile | 1 + xen/arch/arm/arm32/mmu/head.S | 556 ++++++++++++++++++++++ xen/arch/arm/include/asm/arm32/macros.h | 62 +++ 4 files changed, 620 insertions(+), 602 deletions(-) create mode 100644 xen/arch/arm/arm32/mmu/head.S diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index c0c425eac6..77095152b9 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -22,86 +22,10 @@ =20 #define ZIMAGE_MAGIC_NUMBER 0x016f2818 =20 -#define PT_PT 0xf7f /* nG=3D1 AF=3D1 SH=3D11 AP=3D01 NS=3D1 ATTR=3D111= T=3D1 P=3D1 */ -#define PT_MEM 0xf7d /* nG=3D1 AF=3D1 SH=3D11 AP=3D01 NS=3D1 ATTR=3D111= T=3D0 P=3D1 */ -#define PT_MEM_L3 0xf7f /* nG=3D1 AF=3D1 SH=3D11 AP=3D01 NS=3D1 ATTR=3D111= T=3D1 P=3D1 */ -#define PT_DEV 0xe71 /* nG=3D1 AF=3D1 SH=3D10 AP=3D01 NS=3D1 ATTR=3D100= T=3D0 P=3D1 */ -#define PT_DEV_L3 0xe73 /* nG=3D1 AF=3D1 SH=3D10 AP=3D01 NS=3D1 ATTR=3D100= T=3D1 P=3D1 */ - -#define PT_UPPER(x) (PT_##x & 0xf00) -#define PT_LOWER(x) (PT_##x & 0x0ff) - -/* Convenience defines to get slot used by Xen mapping. */ -#define XEN_FIRST_SLOT first_table_offset(XEN_VIRT_START) -#define XEN_SECOND_SLOT second_table_offset(XEN_VIRT_START) - -/* Offset between the early boot xen mapping and the runtime xen mapping */ -#define XEN_TEMPORARY_OFFSET (TEMPORARY_XEN_VIRT_START - XEN_VIRT_STA= RT) - #if defined(CONFIG_EARLY_PRINTK) && defined(CONFIG_EARLY_PRINTK_INC) #include CONFIG_EARLY_PRINTK_INC #endif =20 -/* - * Move an immediate constant into a 32-bit register using movw/movt - * instructions. - */ -.macro mov_w reg, word - movw \reg, #:lower16:\word - movt \reg, #:upper16:\word -.endm - -/* - * Pseudo-op for PC relative adr , where is - * within the range +/- 4GB of the PC. - * - * @dst: destination register - * @sym: name of the symbol - */ -.macro adr_l, dst, sym - mov_w \dst, \sym - .Lpc\@ - .set .Lpc\@, .+ 8 /* PC bias */ - add \dst, \dst, pc -.endm - -.macro load_paddr rb, sym - mov_w \rb, \sym - add \rb, \rb, r10 -.endm - -/* - * Flush local TLBs - * - * @tmp: Scratch register - * - * See asm/arm32/flushtlb.h for the explanation of the sequence. - */ -.macro flush_xen_tlb_local tmp - dsb nshst - mcr CP32(\tmp, TLBIALLH) - dsb nsh - isb -.endm - -/* - * Enforce Xen page-tables do not contain mapping that are both - * Writable and eXecutables. - * - * This should be called on each secondary CPU. - */ -.macro pt_enforce_wxn tmp - mrc CP32(\tmp, HSCTLR) - orr \tmp, \tmp, #SCTLR_Axx_ELx_WXN - dsb - mcr CP32(\tmp, HSCTLR) - /* - * The TLBs may cache SCTLR_EL2.WXN. So ensure it is synchronized - * before flushing the TLBs. - */ - isb - flush_xen_tlb_local \tmp -.endm - /* * Common register usage in this file: * r0 - @@ -121,38 +45,6 @@ * r14 - LR * r15 - PC */ -#ifdef CONFIG_EARLY_PRINTK -/* - * Macro to print a string to the UART, if there is one. - * - * Clobbers r0 - r3 - */ -#define PRINT(_s) \ - mov r3, lr ;\ - adr_l r0, 98f ;\ - bl puts ;\ - mov lr, r3 ;\ - RODATA_STR(98, _s) - -/* - * Macro to print the value of register \rb - * - * Clobbers r0 - r4 - */ -.macro print_reg rb - mov r0, \rb - mov r4, lr - bl putn - mov lr, r4 -.endm - -#else /* CONFIG_EARLY_PRINTK */ -#define PRINT(s) - -.macro print_reg rb -.endm - -#endif /* !CONFIG_EARLY_PRINTK */ =20 .section .text.header, "ax", %progbits .arm @@ -354,467 +246,6 @@ cpu_init_done: mov pc, r5 /* Return address is in r5 */ ENDPROC(cpu_init) =20 -/* - * Macro to find the slot number at a given page-table level - * - * slot: slot computed - * virt: virtual address - * lvl: page-table level - * - * Note that ubxf is unpredictable when the end bit is above 32-bit. So we - * can't use it for first level offset. - */ -.macro get_table_slot, slot, virt, lvl - .if \lvl =3D=3D 1 - lsr \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl) - .else - ubfx \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl), #XEN_PT_LPAE_SHIFT - .endif -.endm - -/* - * Macro to create a page table entry in \ptbl to \tbl (physical - * address) - * - * ptbl: table symbol where the entry will be created - * tbl: physical address of the table to point to - * virt: virtual address - * lvl: page-table level - * - * Preserves \virt - * Clobbers \tbl, r1 - r3 - * - * Note that \tbl and \virt should be in a register other than r1 - r3 - */ -.macro create_table_entry_from_paddr, ptbl, tbl, virt, lvl - get_table_slot r1, \virt, \lvl /* r1 :=3D slot in \tbl */ - lsl r1, r1, #3 /* r1 :=3D slot offset in \tbl */ - - movw r2, #PT_PT /* r2:r3 :=3D right for linear PT */ - orr r2, r2, \tbl /* + \tbl paddr */ - mov r3, #0 - - adr_l \tbl, \ptbl /* \tbl :=3D (v,p)addr of \ptbl */ - - strd r2, r3, [\tbl, r1] -.endm - - -/* - * Macro to create a page table entry in \ptbl to \tbl (symbol) - * - * ptbl: table symbol where the entry will be created - * tbl: table symbol to point to - * virt: virtual address - * lvl: page-table level - * - * Preserves \virt - * Clobbers r1 - r4 - * - * Also use r10 for the phys offset. - * - * Note that \virt should be in a register other than r1 - r4 - */ -.macro create_table_entry, ptbl, tbl, virt, lvl - load_paddr r4, \tbl - create_table_entry_from_paddr \ptbl, r4, \virt, \lvl - .endm - -/* - * Macro to create a mapping entry in \tbl to \paddr. Only mapping in 3rd - * level table (i.e page granularity) is supported. - * - * ptbl: table symbol where the entry will be created - * virt: virtual address - * phys: physical address - * type: mapping type. If not specified it will be normal memory (PT_ME= M_L3) - * - * Preserves \virt, \phys - * Clobbers r1 - r4 - * - * Note that \virt and \paddr should be in other registers than r1 - r4 - * and be distinct. - */ -.macro create_mapping_entry, ptbl, virt, phys, type=3DPT_MEM_L3 - mov_w r2, XEN_PT_LPAE_ENTRY_MASK - lsr r1, \virt, #THIRD_SHIFT - and r1, r1, r2 /* r1 :=3D slot in \tlb */ - lsl r1, r1, #3 /* r1 :=3D slot offset in \tlb */ - - lsr r4, \phys, #THIRD_SHIFT - lsl r4, r4, #THIRD_SHIFT /* r4 :=3D PAGE_ALIGNED(phys) */ - - movw r2, #\type /* r2:r3 :=3D right for section PT */ - orr r2, r2, r4 /* + PAGE_ALIGNED(phys) */ - mov r3, #0 - - adr_l r4, \ptbl - - strd r2, r3, [r4, r1] -.endm - -/* - * Rebuild the boot pagetable's first-level entries. The structure - * is described in mm.c. - * - * After the CPU enables paging it will add the fixmap mapping - * to these page tables, however this may clash with the 1:1 - * mapping. So each CPU must rebuild the page tables here with - * the 1:1 in place. - * - * Inputs: - * r9 : paddr(start) - * r10: phys offset - * - * Output: - * r12: Was a temporary mapping created? - * - * Clobbers r0 - r5 - */ -create_page_tables: - /* Prepare the page-tables for mapping Xen */ - mov_w r0, XEN_VIRT_START - - /* - * We need to use a stash register because - * create_table_entry_paddr() will clobber the register storing - * the physical address of the table to point to. - */ - load_paddr r5, boot_third - mov_w r4, XEN_VIRT_START -.rept XEN_NR_ENTRIES(2) - mov r0, r5 /* r0 :=3D paddr(l3 table) */ - create_table_entry_from_paddr boot_second, r0, r4, 2 - add r4, r4, #XEN_PT_LEVEL_SIZE(2) /* r4 :=3D Next vaddr */ - add r5, r5, #PAGE_SIZE /* r5 :=3D Next table */ -.endr - - /* - * Find the size of Xen in pages and multiply by the size of a - * PTE. This will then be compared in the mapping loop below. - * - * Note the multiplication is just to avoid using an extra - * register/instruction per iteration. - */ - mov_w r0, _start /* r0 :=3D vaddr(_start) */ - mov_w r1, _end /* r1 :=3D vaddr(_end) */ - sub r0, r1, r0 /* r0 :=3D effective size of Xen */ - lsr r0, r0, #PAGE_SHIFT /* r0 :=3D Number of pages for Xen */ - lsl r0, r0, #3 /* r0 :=3D Number of pages * PTE size = */ - - /* Setup boot_third: */ - adr_l r4, boot_third - - lsr r2, r9, #THIRD_SHIFT /* Base address for 4K mapping */ - lsl r2, r2, #THIRD_SHIFT - orr r2, r2, #PT_UPPER(MEM_L3) /* r2:r3 :=3D map */ - orr r2, r2, #PT_LOWER(MEM_L3) - mov r3, #0x0 - - /* ... map of vaddr(start) in boot_third */ - mov r1, #0 -1: strd r2, r3, [r4, r1] /* Map vaddr(start) */ - add r2, r2, #PAGE_SIZE /* Next page */ - add r1, r1, #8 /* Next slot */ - cmp r1, r0 /* Loop until we map all of Xen */ - blo 1b - - /* - * Setup the 1:1 mapping so we can turn the MMU on. Note that - * only the first page of Xen will be part of the 1:1 mapping. - */ - create_table_entry boot_pgtable, boot_second_id, r9, 1 - create_table_entry boot_second_id, boot_third_id, r9, 2 - create_mapping_entry boot_third_id, r9, r9 - - /* - * Find the first slot used. If the slot is not the same - * as TEMPORARY_AREA_FIRST_SLOT, then we will want to switch - * to the temporary mapping before jumping to the runtime - * virtual mapping. - */ - get_table_slot r1, r9, 1 /* r1 :=3D first slot */ - cmp r1, #TEMPORARY_AREA_FIRST_SLOT - bne use_temporary_mapping - - mov_w r0, XEN_VIRT_START - create_table_entry boot_pgtable, boot_second, r0, 1 - mov r12, #0 /* r12 :=3D temporary mapping not cre= ated */ - mov pc, lr - -use_temporary_mapping: - /* - * The identity mapping is not using the first slot - * TEMPORARY_AREA_FIRST_SLOT. Create a temporary mapping. - * See switch_to_runtime_mapping for more details. - */ - PRINT("- Create temporary mapping -\r\n") - - /* Map boot_second (cover Xen mappings) to the temporary 1st slot = */ - mov_w r0, TEMPORARY_XEN_VIRT_START - create_table_entry boot_pgtable, boot_second, r0, 1 - - mov r12, #1 /* r12 :=3D temporary mapping created= */ - mov pc, lr -ENDPROC(create_page_tables) - -/* - * Turn on the Data Cache and the MMU. The function will return - * to the virtual address provided in LR (e.g. the runtime mapping). - * - * Inputs: - * r9 : paddr(start) - * r12 : Was the temporary mapping created? - * lr : Virtual address to return to - * - * Clobbers r0 - r5 - */ -enable_mmu: - PRINT("- Turning on paging -\r\n") - - /* - * The state of the TLBs is unknown before turning on the MMU. - * Flush them to avoid stale one. - */ - flush_xen_tlb_local r0 - - /* Write Xen's PT's paddr into the HTTBR */ - load_paddr r0, boot_pgtable - mov r1, #0 /* r0:r1 is paddr (boot_pagetable) */ - mcrr CP64(r0, r1, HTTBR) - isb - - mrc CP32(r0, HSCTLR) - /* Enable MMU and D-cache */ - orr r0, r0, #(SCTLR_Axx_ELx_M|SCTLR_Axx_ELx_C) - dsb /* Flush PTE writes and finish reads = */ - mcr CP32(r0, HSCTLR) /* now paging is enabled */ - isb /* Now, flush the icache */ - - /* - * The MMU is turned on and we are in the 1:1 mapping. Switch - * to the runtime mapping. - */ - mov r5, lr /* Save LR before overwritting it */ - mov_w lr, 1f /* Virtual address in the runtime mapp= ing */ - b switch_to_runtime_mapping -1: - mov lr, r5 /* Restore LR */ - /* - * At this point, either the 1:1 map or the temporary mapping - * will be present. The former may clash with other parts of the - * Xen virtual memory layout. As both of them are not used - * anymore, remove them completely to avoid having to worry - * about replacing existing mapping afterwards. - * - * On return this will jump to the virtual address requested by - * the caller. - */ - teq r12, #0 - beq remove_identity_mapping - b remove_temporary_mapping -ENDPROC(enable_mmu) - -/* - * Switch to the runtime mapping. The logic depends on whether the - * runtime virtual region is clashing with the physical address - * - * - If it is not clashing, we can directly jump to the address in - * the runtime mapping. - * - If it is clashing, create_page_tables() would have mapped Xen to - * a temporary virtual address. We need to switch to the temporary - * mapping so we can remove the identity mapping and map Xen at the - * correct position. - * - * Inputs - * r9: paddr(start) - * r12: Was a temporary mapping created? - * lr: Address in the runtime mapping to jump to - * - * Clobbers r0 - r4 - */ -switch_to_runtime_mapping: - /* - * Jump to the runtime mapping if the virt and phys are not - * clashing - */ - teq r12, #0 - beq ready_to_switch - - /* We are still in the 1:1 mapping. Jump to the temporary Virtual = address. */ - mov_w r0, 1f - add r0, r0, #XEN_TEMPORARY_OFFSET /* r0 :=3D address in temporar= y mapping */ - mov pc, r0 - -1: - /* Remove boot_second_id */ - mov r2, #0 - mov r3, #0 - adr_l r0, boot_pgtable - get_table_slot r1, r9, 1 /* r1 :=3D first slot */ - lsl r1, r1, #3 /* r1 :=3D first slot offset */ - strd r2, r3, [r0, r1] - - flush_xen_tlb_local r0 - - /* Map boot_second into boot_pgtable */ - mov_w r0, XEN_VIRT_START - create_table_entry boot_pgtable, boot_second, r0, 1 - - /* Ensure any page table updates are visible before continuing */ - dsb nsh - /* - * The function will return on the runtime mapping. So we want - * to prevent instruction fetch before the dsb completes. - */ - isb - -ready_to_switch: - mov pc, lr -ENDPROC(switch_to_runtime_mapping) - -/* - * Enable mm (turn on the data cache and the MMU) for secondary CPUs. - * The function will return to the virtual address provided in LR (e.g. the - * runtime mapping). - * - * Inputs: - * lr : Virtual address to return to. - * - * Clobbers r0 - r6 - */ -enable_secondary_cpu_mm: - mov r6, lr - bl create_page_tables - - mov_w lr, secondary_cpu_mmu_on - b enable_mmu -secondary_cpu_mmu_on: - /* - * Non-boot CPUs need to move on to the proper pagetables, which w= ere - * setup in prepare_secondary_mm. - * - * XXX: This is not compliant with the Arm Arm. - */ - mov_w r4, init_ttbr /* VA of HTTBR value stashed by CPU 0= */ - ldrd r4, r5, [r4] /* Actual value */ - dsb - mcrr CP64(r4, r5, HTTBR) - dsb - isb - flush_xen_tlb_local r0 - pt_enforce_wxn r0 - mov lr, r6 - - /* Return to the virtual address requested by the caller. */ - mov pc, lr -ENDPROC(enable_secondary_cpu_mm) - -/* - * Enable mm (turn on the data cache and the MMU) for the boot CPU. - * The function will return to the virtual address provided in LR (e.g. the - * runtime mapping). - * - * Inputs: - * lr : Virtual address to return to. - * - * Clobbers r0 - r6 - */ -enable_boot_cpu_mm: - mov r6, lr - bl create_page_tables - - /* Address in the runtime mapping to jump to after the MMU is enab= led */ - mov_w lr, boot_cpu_mmu_on - b enable_mmu -boot_cpu_mmu_on: - bl setup_fixmap - - mov lr, r6 - - /* Return to the virtual address requested by the caller. */ - mov pc, lr -ENDPROC(enable_boot_cpu_mm) - -/* - * Remove the 1:1 map from the page-tables. It is not easy to keep track - * where the 1:1 map was mapped, so we will look for the top-level entry - * exclusive to the 1:1 map and remove it. - * - * Inputs: - * r9 : paddr(start) - * - * Clobbers r0 - r3 - */ -remove_identity_mapping: - /* r2:r3 :=3D invalid page-table entry */ - mov r2, #0x0 - mov r3, #0x0 - - /* Find the first slot used and remove it */ - get_table_slot r1, r9, 1 /* r1 :=3D first slot */ - mov_w r0, boot_pgtable /* r0 :=3D root table */ - lsl r1, r1, #3 /* r1 :=3D Slot offset */ - strd r2, r3, [r0, r1] - - flush_xen_tlb_local r0 - mov pc, lr -ENDPROC(remove_identity_mapping) - -/* - * Remove the temporary mapping of Xen starting at TEMPORARY_XEN_VIRT_STAR= T. - * - * Clobbers r0 - r3 - */ -remove_temporary_mapping: - /* r2:r3 :=3D invalid page-table entry */ - mov r2, #0 - mov r3, #0 - - adr_l r0, boot_pgtable - mov_w r1, TEMPORARY_XEN_VIRT_START - get_table_slot r1, r1, 1 /* r1 :=3D first slot */ - lsl r1, r1, #3 /* r1 :=3D first slot offset */ - strd r2, r3, [r0, r1] - - flush_xen_tlb_local r0 - - mov pc, lr -ENDPROC(remove_temporary_mapping) - -/* - * Map the UART in the fixmap (when earlyprintk is used) and hook the - * fixmap table in the page tables. - * - * The fixmap cannot be mapped in create_page_tables because it may - * clash with the 1:1 mapping. - * - * Inputs: - * r10: Physical offset - * r11: Early UART base physical address - * - * Clobbers r0 - r4 - */ -setup_fixmap: -#if defined(CONFIG_EARLY_PRINTK) - /* Add UART to the fixmap table */ - mov_w r0, EARLY_UART_VIRTUAL_ADDRESS - create_mapping_entry xen_fixmap, r0, r11, type=3DPT_DEV_L3 -#endif - /* Map fixmap into boot_second */ - mov_w r0, FIXMAP_ADDR(0) - create_table_entry boot_second, xen_fixmap, r0, 2 - /* Ensure any page table updates made above have occurred. */ - dsb nshst - /* - * The fixmap area will be used soon after. So ensure no hardware - * translation happens before the dsb completes. - */ - isb - - mov pc, lr -ENDPROC(setup_fixmap) - /* * Setup the initial stack and jump to the C world * @@ -842,38 +273,6 @@ fail: PRINT("- Boot failed -\r\n") b 1b ENDPROC(fail) =20 -/* - * Switch TTBR - * r1:r0 ttbr - * - * TODO: This code does not comply with break-before-make. - */ -ENTRY(switch_ttbr) - dsb /* Ensure the flushes happen before - * continuing */ - isb /* Ensure synchronization with prev= ious - * changes to text */ - mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ - mcr CP32(r0, ICIALLU) /* Flush I-cache */ - mcr CP32(r0, BPIALL) /* Flush branch predictor */ - dsb /* Ensure completion of TLB+BP flus= h */ - isb - - mcrr CP64(r0, r1, HTTBR) - - dsb /* ensure memory accesses do not cr= oss - * over the TTBR0 write */ - isb /* Ensure synchronization with prev= ious - * changes to text */ - mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ - mcr CP32(r0, ICIALLU) /* Flush I-cache */ - mcr CP32(r0, BPIALL) /* Flush branch predictor */ - dsb /* Ensure completion of TLB+BP flus= h */ - isb - - mov pc, lr -ENDPROC(switch_ttbr) - #ifdef CONFIG_EARLY_PRINTK /* * Initialize the UART. Should only be called on the boot CPU. @@ -898,7 +297,7 @@ ENDPROC(init_uart) * r11: Early UART base address * Clobbers r0-r1 */ -puts: +ENTRY(puts) early_uart_ready r11, r1 ldrb r1, [r0], #1 /* Load next char */ teq r1, #0 /* Exit on nul */ diff --git a/xen/arch/arm/arm32/mmu/Makefile b/xen/arch/arm/arm32/mmu/Makef= ile index b18cec4836..336805c636 100644 --- a/xen/arch/arm/arm32/mmu/Makefile +++ b/xen/arch/arm/arm32/mmu/Makefile @@ -1 +1,2 @@ obj-y +=3D mm.o +obj-y +=3D head.o diff --git a/xen/arch/arm/arm32/mmu/head.S b/xen/arch/arm/arm32/mmu/head.S new file mode 100644 index 0000000000..3d2fa2932d --- /dev/null +++ b/xen/arch/arm/arm32/mmu/head.S @@ -0,0 +1,556 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/arm32/mmu/head.S + * + * Arm32 MMU specific start-of-day code. + */ + +#include +#include + +#define PT_PT 0xf7f /* nG=3D1 AF=3D1 SH=3D11 AP=3D01 NS=3D1 ATTR=3D111= T=3D1 P=3D1 */ +#define PT_MEM 0xf7d /* nG=3D1 AF=3D1 SH=3D11 AP=3D01 NS=3D1 ATTR=3D111= T=3D0 P=3D1 */ +#define PT_MEM_L3 0xf7f /* nG=3D1 AF=3D1 SH=3D11 AP=3D01 NS=3D1 ATTR=3D111= T=3D1 P=3D1 */ +#define PT_DEV 0xe71 /* nG=3D1 AF=3D1 SH=3D10 AP=3D01 NS=3D1 ATTR=3D100= T=3D0 P=3D1 */ +#define PT_DEV_L3 0xe73 /* nG=3D1 AF=3D1 SH=3D10 AP=3D01 NS=3D1 ATTR=3D100= T=3D1 P=3D1 */ + +#define PT_UPPER(x) (PT_##x & 0xf00) +#define PT_LOWER(x) (PT_##x & 0x0ff) + +/* Convenience defines to get slot used by Xen mapping. */ +#define XEN_FIRST_SLOT first_table_offset(XEN_VIRT_START) +#define XEN_SECOND_SLOT second_table_offset(XEN_VIRT_START) + +/* + * Flush local TLBs + * + * @tmp: Scratch register + * + * See asm/arm32/flushtlb.h for the explanation of the sequence. + */ +.macro flush_xen_tlb_local tmp + dsb nshst + mcr CP32(\tmp, TLBIALLH) + dsb nsh + isb +.endm + +/* + * Enforce Xen page-tables do not contain mapping that are both + * Writable and eXecutables. + * + * This should be called on each secondary CPU. + */ +.macro pt_enforce_wxn tmp + mrc CP32(\tmp, HSCTLR) + orr \tmp, \tmp, #SCTLR_Axx_ELx_WXN + dsb + mcr CP32(\tmp, HSCTLR) + /* + * The TLBs may cache SCTLR_EL2.WXN. So ensure it is synchronized + * before flushing the TLBs. + */ + isb + flush_xen_tlb_local \tmp +.endm + +/* + * Macro to find the slot number at a given page-table level + * + * slot: slot computed + * virt: virtual address + * lvl: page-table level + * + * Note that ubxf is unpredictable when the end bit is above 32-bit. So we + * can't use it for first level offset. + */ +.macro get_table_slot, slot, virt, lvl + .if \lvl =3D=3D 1 + lsr \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl) + .else + ubfx \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl), #XEN_PT_LPAE_SHIFT + .endif +.endm + +/* + * Macro to create a page table entry in \ptbl to \tbl (physical + * address) + * + * ptbl: table symbol where the entry will be created + * tbl: physical address of the table to point to + * virt: virtual address + * lvl: page-table level + * + * Preserves \virt + * Clobbers \tbl, r1 - r3 + * + * Note that \tbl and \virt should be in a register other than r1 - r3 + */ +.macro create_table_entry_from_paddr, ptbl, tbl, virt, lvl + get_table_slot r1, \virt, \lvl /* r1 :=3D slot in \tbl */ + lsl r1, r1, #3 /* r1 :=3D slot offset in \tbl */ + + movw r2, #PT_PT /* r2:r3 :=3D right for linear PT */ + orr r2, r2, \tbl /* + \tbl paddr */ + mov r3, #0 + + adr_l \tbl, \ptbl /* \tbl :=3D (v,p)addr of \ptbl */ + + strd r2, r3, [\tbl, r1] +.endm + + +/* + * Macro to create a page table entry in \ptbl to \tbl (symbol) + * + * ptbl: table symbol where the entry will be created + * tbl: table symbol to point to + * virt: virtual address + * lvl: page-table level + * + * Preserves \virt + * Clobbers r1 - r4 + * + * Also use r10 for the phys offset. + * + * Note that \virt should be in a register other than r1 - r4 + */ +.macro create_table_entry, ptbl, tbl, virt, lvl + load_paddr r4, \tbl + create_table_entry_from_paddr \ptbl, r4, \virt, \lvl + .endm + +/* + * Macro to create a mapping entry in \tbl to \paddr. Only mapping in 3rd + * level table (i.e page granularity) is supported. + * + * ptbl: table symbol where the entry will be created + * virt: virtual address + * phys: physical address + * type: mapping type. If not specified it will be normal memory (PT_ME= M_L3) + * + * Preserves \virt, \phys + * Clobbers r1 - r4 + * + * Note that \virt and \paddr should be in other registers than r1 - r4 + * and be distinct. + */ +.macro create_mapping_entry, ptbl, virt, phys, type=3DPT_MEM_L3 + mov_w r2, XEN_PT_LPAE_ENTRY_MASK + lsr r1, \virt, #THIRD_SHIFT + and r1, r1, r2 /* r1 :=3D slot in \tlb */ + lsl r1, r1, #3 /* r1 :=3D slot offset in \tlb */ + + lsr r4, \phys, #THIRD_SHIFT + lsl r4, r4, #THIRD_SHIFT /* r4 :=3D PAGE_ALIGNED(phys) */ + + movw r2, #\type /* r2:r3 :=3D right for section PT */ + orr r2, r2, r4 /* + PAGE_ALIGNED(phys) */ + mov r3, #0 + + adr_l r4, \ptbl + + strd r2, r3, [r4, r1] +.endm + +.section .text.idmap, "ax", %progbits + +/* + * Rebuild the boot pagetable's first-level entries. The structure + * is described in mm.c. + * + * After the CPU enables paging it will add the fixmap mapping + * to these page tables, however this may clash with the 1:1 + * mapping. So each CPU must rebuild the page tables here with + * the 1:1 in place. + * + * Inputs: + * r9 : paddr(start) + * r10: phys offset + * + * Output: + * r12: Was a temporary mapping created? + * + * Clobbers r0 - r5 + */ +create_page_tables: + /* Prepare the page-tables for mapping Xen */ + mov_w r0, XEN_VIRT_START + + /* + * We need to use a stash register because + * create_table_entry_paddr() will clobber the register storing + * the physical address of the table to point to. + */ + load_paddr r5, boot_third + mov_w r4, XEN_VIRT_START +.rept XEN_NR_ENTRIES(2) + mov r0, r5 /* r0 :=3D paddr(l3 table) */ + create_table_entry_from_paddr boot_second, r0, r4, 2 + add r4, r4, #XEN_PT_LEVEL_SIZE(2) /* r4 :=3D Next vaddr */ + add r5, r5, #PAGE_SIZE /* r5 :=3D Next table */ +.endr + + /* + * Find the size of Xen in pages and multiply by the size of a + * PTE. This will then be compared in the mapping loop below. + * + * Note the multiplication is just to avoid using an extra + * register/instruction per iteration. + */ + mov_w r0, _start /* r0 :=3D vaddr(_start) */ + mov_w r1, _end /* r1 :=3D vaddr(_end) */ + sub r0, r1, r0 /* r0 :=3D effective size of Xen */ + lsr r0, r0, #PAGE_SHIFT /* r0 :=3D Number of pages for Xen */ + lsl r0, r0, #3 /* r0 :=3D Number of pages * PTE size = */ + + /* Setup boot_third: */ + adr_l r4, boot_third + + lsr r2, r9, #THIRD_SHIFT /* Base address for 4K mapping */ + lsl r2, r2, #THIRD_SHIFT + orr r2, r2, #PT_UPPER(MEM_L3) /* r2:r3 :=3D map */ + orr r2, r2, #PT_LOWER(MEM_L3) + mov r3, #0x0 + + /* ... map of vaddr(start) in boot_third */ + mov r1, #0 +1: strd r2, r3, [r4, r1] /* Map vaddr(start) */ + add r2, r2, #PAGE_SIZE /* Next page */ + add r1, r1, #8 /* Next slot */ + cmp r1, r0 /* Loop until we map all of Xen */ + blo 1b + + /* + * Setup the 1:1 mapping so we can turn the MMU on. Note that + * only the first page of Xen will be part of the 1:1 mapping. + */ + create_table_entry boot_pgtable, boot_second_id, r9, 1 + create_table_entry boot_second_id, boot_third_id, r9, 2 + create_mapping_entry boot_third_id, r9, r9 + + /* + * Find the first slot used. If the slot is not the same + * as TEMPORARY_AREA_FIRST_SLOT, then we will want to switch + * to the temporary mapping before jumping to the runtime + * virtual mapping. + */ + get_table_slot r1, r9, 1 /* r1 :=3D first slot */ + cmp r1, #TEMPORARY_AREA_FIRST_SLOT + bne use_temporary_mapping + + mov_w r0, XEN_VIRT_START + create_table_entry boot_pgtable, boot_second, r0, 1 + mov r12, #0 /* r12 :=3D temporary mapping not cre= ated */ + mov pc, lr + +use_temporary_mapping: + /* + * The identity mapping is not using the first slot + * TEMPORARY_AREA_FIRST_SLOT. Create a temporary mapping. + * See switch_to_runtime_mapping for more details. + */ + PRINT("- Create temporary mapping -\r\n") + + /* Map boot_second (cover Xen mappings) to the temporary 1st slot = */ + mov_w r0, TEMPORARY_XEN_VIRT_START + create_table_entry boot_pgtable, boot_second, r0, 1 + + mov r12, #1 /* r12 :=3D temporary mapping created= */ + mov pc, lr +ENDPROC(create_page_tables) + +/* + * Turn on the Data Cache and the MMU. The function will return + * to the virtual address provided in LR (e.g. the runtime mapping). + * + * Inputs: + * r9 : paddr(start) + * r12 : Was the temporary mapping created? + * lr : Virtual address to return to + * + * Clobbers r0 - r5 + */ +enable_mmu: + PRINT("- Turning on paging -\r\n") + + /* + * The state of the TLBs is unknown before turning on the MMU. + * Flush them to avoid stale one. + */ + flush_xen_tlb_local r0 + + /* Write Xen's PT's paddr into the HTTBR */ + load_paddr r0, boot_pgtable + mov r1, #0 /* r0:r1 is paddr (boot_pagetable) */ + mcrr CP64(r0, r1, HTTBR) + isb + + mrc CP32(r0, HSCTLR) + /* Enable MMU and D-cache */ + orr r0, r0, #(SCTLR_Axx_ELx_M|SCTLR_Axx_ELx_C) + dsb /* Flush PTE writes and finish reads = */ + mcr CP32(r0, HSCTLR) /* now paging is enabled */ + isb /* Now, flush the icache */ + + /* + * The MMU is turned on and we are in the 1:1 mapping. Switch + * to the runtime mapping. + */ + mov r5, lr /* Save LR before overwritting it */ + mov_w lr, 1f /* Virtual address in the runtime mapp= ing */ + b switch_to_runtime_mapping +1: + mov lr, r5 /* Restore LR */ + /* + * At this point, either the 1:1 map or the temporary mapping + * will be present. The former may clash with other parts of the + * Xen virtual memory layout. As both of them are not used + * anymore, remove them completely to avoid having to worry + * about replacing existing mapping afterwards. + * + * On return this will jump to the virtual address requested by + * the caller. + */ + teq r12, #0 + beq remove_identity_mapping + b remove_temporary_mapping +ENDPROC(enable_mmu) + +/* + * Switch to the runtime mapping. The logic depends on whether the + * runtime virtual region is clashing with the physical address + * + * - If it is not clashing, we can directly jump to the address in + * the runtime mapping. + * - If it is clashing, create_page_tables() would have mapped Xen to + * a temporary virtual address. We need to switch to the temporary + * mapping so we can remove the identity mapping and map Xen at the + * correct position. + * + * Inputs + * r9: paddr(start) + * r12: Was a temporary mapping created? + * lr: Address in the runtime mapping to jump to + * + * Clobbers r0 - r4 + */ +switch_to_runtime_mapping: + /* + * Jump to the runtime mapping if the virt and phys are not + * clashing + */ + teq r12, #0 + beq ready_to_switch + + /* We are still in the 1:1 mapping. Jump to the temporary Virtual = address. */ + mov_w r0, 1f + add r0, r0, #XEN_TEMPORARY_OFFSET /* r0 :=3D address in temporar= y mapping */ + mov pc, r0 + +1: + /* Remove boot_second_id */ + mov r2, #0 + mov r3, #0 + adr_l r0, boot_pgtable + get_table_slot r1, r9, 1 /* r1 :=3D first slot */ + lsl r1, r1, #3 /* r1 :=3D first slot offset */ + strd r2, r3, [r0, r1] + + flush_xen_tlb_local r0 + + /* Map boot_second into boot_pgtable */ + mov_w r0, XEN_VIRT_START + create_table_entry boot_pgtable, boot_second, r0, 1 + + /* Ensure any page table updates are visible before continuing */ + dsb nsh + /* + * The function will return on the runtime mapping. So we want + * to prevent instruction fetch before the dsb completes. + */ + isb + +ready_to_switch: + mov pc, lr +ENDPROC(switch_to_runtime_mapping) + +/* + * Enable mm (turn on the data cache and the MMU) for secondary CPUs. + * The function will return to the virtual address provided in LR (e.g. the + * runtime mapping). + * + * Inputs: + * lr : Virtual address to return to. + * + * Clobbers r0 - r6 + */ +ENTRY(enable_secondary_cpu_mm) + mov r6, lr + bl create_page_tables + + mov_w lr, secondary_cpu_mmu_on + b enable_mmu +secondary_cpu_mmu_on: + /* + * Non-boot CPUs need to move on to the proper pagetables, which w= ere + * setup in prepare_secondary_mm. + * + * XXX: This is not compliant with the Arm Arm. + */ + mov_w r4, init_ttbr /* VA of HTTBR value stashed by CPU 0= */ + ldrd r4, r5, [r4] /* Actual value */ + dsb + mcrr CP64(r4, r5, HTTBR) + dsb + isb + flush_xen_tlb_local r0 + pt_enforce_wxn r0 + mov lr, r6 + + /* Return to the virtual address requested by the caller. */ + mov pc, lr +ENDPROC(enable_secondary_cpu_mm) + +/* + * Enable mm (turn on the data cache and the MMU) for the boot CPU. + * The function will return to the virtual address provided in LR (e.g. the + * runtime mapping). + * + * Inputs: + * lr : Virtual address to return to. + * + * Clobbers r0 - r6 + */ +ENTRY(enable_boot_cpu_mm) + mov r6, lr + bl create_page_tables + + /* Address in the runtime mapping to jump to after the MMU is enab= led */ + mov_w lr, boot_cpu_mmu_on + b enable_mmu +boot_cpu_mmu_on: + bl setup_fixmap + + mov lr, r6 + + /* Return to the virtual address requested by the caller. */ + mov pc, lr +ENDPROC(enable_boot_cpu_mm) + +/* + * Remove the 1:1 map from the page-tables. It is not easy to keep track + * where the 1:1 map was mapped, so we will look for the top-level entry + * exclusive to the 1:1 map and remove it. + * + * Inputs: + * r9 : paddr(start) + * + * Clobbers r0 - r3 + */ +remove_identity_mapping: + /* r2:r3 :=3D invalid page-table entry */ + mov r2, #0x0 + mov r3, #0x0 + + /* Find the first slot used and remove it */ + get_table_slot r1, r9, 1 /* r1 :=3D first slot */ + mov_w r0, boot_pgtable /* r0 :=3D root table */ + lsl r1, r1, #3 /* r1 :=3D Slot offset */ + strd r2, r3, [r0, r1] + + flush_xen_tlb_local r0 + mov pc, lr +ENDPROC(remove_identity_mapping) + +/* + * Remove the temporary mapping of Xen starting at TEMPORARY_XEN_VIRT_STAR= T. + * + * Clobbers r0 - r3 + */ +remove_temporary_mapping: + /* r2:r3 :=3D invalid page-table entry */ + mov r2, #0 + mov r3, #0 + + adr_l r0, boot_pgtable + mov_w r1, TEMPORARY_XEN_VIRT_START + get_table_slot r1, r1, 1 /* r1 :=3D first slot */ + lsl r1, r1, #3 /* r1 :=3D first slot offset */ + strd r2, r3, [r0, r1] + + flush_xen_tlb_local r0 + + mov pc, lr +ENDPROC(remove_temporary_mapping) + +/* + * Map the UART in the fixmap (when earlyprintk is used) and hook the + * fixmap table in the page tables. + * + * The fixmap cannot be mapped in create_page_tables because it may + * clash with the 1:1 mapping. + * + * Inputs: + * r10: Physical offset + * r11: Early UART base physical address + * + * Clobbers r0 - r4 + */ +setup_fixmap: +#if defined(CONFIG_EARLY_PRINTK) + /* Add UART to the fixmap table */ + mov_w r0, EARLY_UART_VIRTUAL_ADDRESS + create_mapping_entry xen_fixmap, r0, r11, type=3DPT_DEV_L3 +#endif + /* Map fixmap into boot_second */ + mov_w r0, FIXMAP_ADDR(0) + create_table_entry boot_second, xen_fixmap, r0, 2 + /* Ensure any page table updates made above have occurred. */ + dsb nshst + /* + * The fixmap area will be used soon after. So ensure no hardware + * translation happens before the dsb completes. + */ + isb + + mov pc, lr +ENDPROC(setup_fixmap) + +/* Fail-stop */ +fail: PRINT("- Boot failed -\r\n") +1: wfe + b 1b +ENDPROC(fail) + +/* + * Switch TTBR + * r1:r0 ttbr + * + * TODO: This code does not comply with break-before-make. + */ +ENTRY(switch_ttbr) + dsb /* Ensure the flushes happen before + * continuing */ + isb /* Ensure synchronization with prev= ious + * changes to text */ + mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ + mcr CP32(r0, ICIALLU) /* Flush I-cache */ + mcr CP32(r0, BPIALL) /* Flush branch predictor */ + dsb /* Ensure completion of TLB+BP flus= h */ + isb + + mcrr CP64(r0, r1, HTTBR) + + dsb /* ensure memory accesses do not cr= oss + * over the TTBR0 write */ + isb /* Ensure synchronization with prev= ious + * changes to text */ + mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ + mcr CP32(r0, ICIALLU) /* Flush I-cache */ + mcr CP32(r0, BPIALL) /* Flush branch predictor */ + dsb /* Ensure completion of TLB+BP flus= h */ + isb + + mov pc, lr +ENDPROC(switch_ttbr) diff --git a/xen/arch/arm/include/asm/arm32/macros.h b/xen/arch/arm/include= /asm/arm32/macros.h index a4e20aa520..64fbe4876a 100644 --- a/xen/arch/arm/include/asm/arm32/macros.h +++ b/xen/arch/arm/include/asm/arm32/macros.h @@ -1,8 +1,70 @@ #ifndef __ASM_ARM_ARM32_MACROS_H #define __ASM_ARM_ARM32_MACROS_H =20 +/* Offset between the early boot xen mapping and the runtime xen mapping */ +#define XEN_TEMPORARY_OFFSET (TEMPORARY_XEN_VIRT_START - XEN_VIRT_STA= RT) + .macro ret mov pc, lr .endm =20 +/* + * Move an immediate constant into a 32-bit register using movw/movt + * instructions. + */ +.macro mov_w reg, word + movw \reg, #:lower16:\word + movt \reg, #:upper16:\word +.endm + +/* + * Pseudo-op for PC relative adr , where is + * within the range +/- 4GB of the PC. + * + * @dst: destination register + * @sym: name of the symbol + */ +.macro adr_l, dst, sym + mov_w \dst, \sym - .Lpc\@ + .set .Lpc\@, .+ 8 /* PC bias */ + add \dst, \dst, pc +.endm + +.macro load_paddr rb, sym + mov_w \rb, \sym + add \rb, \rb, r10 +.endm + +#ifdef CONFIG_EARLY_PRINTK +/* + * Macro to print a string to the UART, if there is one. + * + * Clobbers r0 - r3 + */ +#define PRINT(_s) \ + mov r3, lr ;\ + adr_l r0, 98f ;\ + bl puts ;\ + mov lr, r3 ;\ + RODATA_STR(98, _s) + +/* + * Macro to print the value of register \rb + * + * Clobbers r0 - r4 + */ +.macro print_reg rb + mov r0, \rb + mov r4, lr + bl putn + mov lr, r4 +.endm + +#else /* CONFIG_EARLY_PRINTK */ +#define PRINT(s) + +.macro print_reg rb +.endm + +#endif /* !CONFIG_EARLY_PRINTK */ #endif /* __ASM_ARM_ARM32_MACROS_H */ --=20 2.25.1 From nobody Tue May 14 08:36: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=1694440886; cv=pass; d=zohomail.com; s=zohoarc; b=HBdEGNWmlmt6Zhz7GZpCEYX6lHOAe0vDk06fALPUpV5Z0SfTzMM7/tVslCMB+QjF/jK9TGFOPLuM8+Z5tNArpEcO9d3ZFbmq2a7FWlPHsuuF5cWQC56o2/XNdj/Lb/ZHLtpzlWG2OmasaUvjgMtFCLVNqOw0Ol+YX/hDC5wzqOk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694440886; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CZ03rabC0ifyCB6txpZL3Bm38Ko4qgK8bj669nLmS5M=; b=DHkgmxOo3ibifRUl8YNM7ebTPn5mJogQZrUZE6P7eoT54VoNN50WTtJDo3Ugf5RbAJyNStoJfUB5O32PPf/PQDCZfWzmKAg/Bu+5NeWVEB1eK8CTOU2Y3RIyLbNiS4WjPp0UFKa7mTExtypqEZ0JrvnH0gqHCNmPXFawDW95qCg= 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 1694440886095137.88045859747706; Mon, 11 Sep 2023 07:01:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.599443.934895 (Exim 4.92) (envelope-from ) id 1qfhTR-0006pT-5Y; Mon, 11 Sep 2023 14:01:09 +0000 Received: by outflank-mailman (output) from mailman id 599443.934895; Mon, 11 Sep 2023 14:01:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfhTR-0006pL-2G; Mon, 11 Sep 2023 14:01:09 +0000 Received: by outflank-mailman (input) for mailman id 599443; Mon, 11 Sep 2023 14:01:07 +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 1qfhTP-0005N8-B6 for xen-devel@lists.xenproject.org; Mon, 11 Sep 2023 14:01:07 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061c.outbound.protection.outlook.com [2a01:111:f400:fe5b::61c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a666a1b7-50ab-11ee-8784-cb3800f73035; Mon, 11 Sep 2023 16:01:06 +0200 (CEST) Received: from CH2PR04CA0008.namprd04.prod.outlook.com (2603:10b6:610:52::18) by CH2PR12MB4328.namprd12.prod.outlook.com (2603:10b6:610:a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Mon, 11 Sep 2023 14:01:00 +0000 Received: from DS2PEPF00003444.namprd04.prod.outlook.com (2603:10b6:610:52:cafe::ea) by CH2PR04CA0008.outlook.office365.com (2603:10b6:610:52::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35 via Frontend Transport; Mon, 11 Sep 2023 14:01:00 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003444.mail.protection.outlook.com (10.167.17.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Mon, 11 Sep 2023 14:01:00 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.27; Mon, 11 Sep 2023 09:00:54 -0500 Received: from xcbayankuma40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 11 Sep 2023 09:00:53 -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: a666a1b7-50ab-11ee-8784-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dvb1ASgV803bOS/IKi1FVDCGSEXUMJiIzW+GOOck7TWQG1ntkbtYRPHIeya/kLuTz2ccACmHfOjOfdc2NSXnCHdY4aVN9uPCT3ytywBn96kiFHVp3ulA+/Nc6L3884Owg/MJ/S9Gml/DqhnrRxHf28Bq4zaLHVPXzPCl/cf9ti0V1/bHJ4VdSnK1vyC6KuXTXcRjgGITE8/uv190vUv6aO8Bsmekfhp93IZKdBmPfn1MQbbu0ByXmyrxeN7xtS32Ugx3HdlEFoxf/96DBC0gHn0EHuDyKE8M4fFs/bp1nYQ8AvDwCidhzzDAJHeIt3MnO8fzqpKZXGT7lPbL//eGgA== 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=CZ03rabC0ifyCB6txpZL3Bm38Ko4qgK8bj669nLmS5M=; b=PjYPtyJWNc3Fj4h7u4GB6qVq9fP5nNbEGcjsFCV/idX+fbT58vQfElvxx6K+5aU83fBDODh2yBdWk1qiYpghzW9C3ugu6NjyzXcHl7YQpYf7axeahuPpERhP66W3pGGXl5xenp/CDenzvbQLVmiG/oE0YIOCyzSDDRvaY9r2e6fdmWeJGZtSVwiavlo0EDRxMuA5FPZW+85Id4sw5f2hDwKZNGw4HddUCsh/hVmon7SZbzVl3tyv9UTPnGk8/9eTFlEPDqZUkTC6EhblWlpAneD+8RNqpS3Q8GiE/fidMyFmBfiJ7/I5G/+KLgBV0pXljkD1rzOcDa2M2NftwGac6g== 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 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=CZ03rabC0ifyCB6txpZL3Bm38Ko4qgK8bj669nLmS5M=; b=X8Mjjek0VrIGfA2Y9iYnpE5b/aN3a2KTI6tu3vUBc9zBSExM5rpHiZP+p1BkAKQKKZ2014rV61nZbFOdKurTKwJPaFJimTUXsEMBABgItMKpcIbBPuV5B1YNzHZeDQZ0AoAhoSpdZHLQmWjQsDxGvfOhc9pT4riXyQgAWCcnQ68= 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: Ayan Kumar Halder To: CC: , , , , , , , , Ayan Kumar Halder Subject: [XEN v1 4/4] xen/arm: traps.c: Enclose VMSA specific registers within CONFIG_MMU Date: Mon, 11 Sep 2023 14:59:42 +0100 Message-ID: <20230911135942.791206-5-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230911135942.791206-1-ayan.kumar.halder@amd.com> References: <20230911135942.791206-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003444:EE_|CH2PR12MB4328:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a7c3af5-8f2e-4ce6-4edd-08dbb2cf8774 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5jMevpm3KxWfY2402R2YnZOkislKOztc59g7u2ezdcagfiE8l4fezFotJT/nssRSwW4X5sfPHCAARJEQX6Eb7mE7B1EbCRAwCEPhHD7sAoWbDatwoi8mi6vIAXtpwsCepzG+1Sj6ENwxYbYAYRRcnYgy/vZZQaDfVMLgD+qJ3NiQCOlOr9uTTqDRO3LbDABIEIaKUu9uVm4BHbzXe3rOWMuVlDjBXDLrAdY93IqBZQmlwvm5O7BY3gJz9Ibweb0mMT75RlGJlbCv31IUhcgfUH/yKo358EAwJDtW3XO8VmqWyKbpBI1/Oo2Pkc0GmcgQZ9w/HLKleh0gk4axzpb53Heucgidv9VydB6HbPBwgHLu4emnpQDjAQkeNIxC9lYMlTy1L3zxuG8ZPafA6LAG79h/t5rIYz5kx76WHqThr6WNJng5TuRN+5IJKwZU1x+GwE0AhS+IzhvX+jd9TNZh2C7HKkJzYnddNOTDR700f+1Uh2oS07U1rCbVwe5TbZMi+NIx1sMmbsmBPRQvvD0KlIqhxQcp1TssHE+1KqFbXKuR2fc9+VgJgDL8INM1a2AQN48yttr5obTJYqTTdVVbnIbLqrcJLCux/zr9n1DmMBax41NgvnrxE2Opsaw48W1W9aAgQlnQBGzhRX66qlp1CpeXXojLFTRSjk/2fLohG6u8zYZWb0NHxaX9+URNc7eDdV2eSnYjn2AVtCH4lAgrB5AkmUtkYjqm9o/CbY7f1addM507pvgKMI8Rww4jdf0L0O5NEAbWKJO8FWCDCMH0QA== 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)(4636009)(346002)(396003)(39860400002)(136003)(376002)(1800799009)(82310400011)(186009)(451199024)(46966006)(36840700001)(40470700004)(70586007)(26005)(86362001)(1076003)(426003)(336012)(2906002)(83380400001)(103116003)(6666004)(40480700001)(2616005)(36860700001)(356005)(82740400003)(81166007)(47076005)(40460700003)(478600001)(36756003)(5660300002)(4326008)(8936002)(8676002)(316002)(54906003)(6916009)(70206006)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2023 14:01:00.2796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a7c3af5-8f2e-4ce6-4edd-08dbb2cf8774 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: DS2PEPF00003444.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4328 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1694440964500100001 Content-Type: text/plain; charset="utf-8" The VMSA specific registers (ie TCR, TTBR0, TTBR1, VTTBR, etc) are valid wh= en MMU is used, thus we can enclose them with CONFIG_MMU. Signed-off-by: Ayan Kumar Halder --- xen/arch/arm/traps.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 46c9a4031b..83522fcc5a 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -698,8 +698,10 @@ static void __do_trap_serror(struct cpu_user_regs *reg= s, bool guest) struct reg_ctxt { /* Guest-side state */ register_t sctlr_el1; +#ifdef CONFIG_MMU register_t tcr_el1; uint64_t ttbr0_el1, ttbr1_el1; +#endif #ifdef CONFIG_ARM_32 uint32_t dfsr, ifsr; uint32_t dfar, ifar; @@ -801,9 +803,11 @@ static void show_registers_32(const struct cpu_user_re= gs *regs, if ( guest_mode_on ) { printk(" SCTLR: %"PRIregister"\n", ctxt->sctlr_el1); +#ifdef CONFIG_MMU printk(" TCR: %"PRIregister"\n", ctxt->tcr_el1); printk(" TTBR0: %016"PRIx64"\n", ctxt->ttbr0_el1); printk(" TTBR1: %016"PRIx64"\n", ctxt->ttbr1_el1); +#endif printk(" IFAR: %08"PRIx32", IFSR: %08"PRIx32"\n" " DFAR: %08"PRIx32", DFSR: %08"PRIx32"\n", #ifdef CONFIG_ARM_64 @@ -873,9 +877,11 @@ static void show_registers_64(const struct cpu_user_re= gs *regs, printk(" FAR_EL1: %016"PRIx64"\n", ctxt->far); printk("\n"); printk(" SCTLR_EL1: %"PRIregister"\n", ctxt->sctlr_el1); +#ifdef CONFIG_MMU printk(" TCR_EL1: %"PRIregister"\n", ctxt->tcr_el1); printk(" TTBR0_EL1: %016"PRIx64"\n", ctxt->ttbr0_el1); printk(" TTBR1_EL1: %016"PRIx64"\n", ctxt->ttbr1_el1); +#endif printk("\n"); } } @@ -907,13 +913,15 @@ static void _show_registers(const struct cpu_user_reg= s *regs, show_registers_32(regs, ctxt, guest_mode_on, v); #endif } +#ifdef CONFIG_MMU printk(" VTCR_EL2: %"PRIregister"\n", READ_SYSREG(VTCR_EL2)); printk(" VTTBR_EL2: %016"PRIx64"\n", ctxt->vttbr_el2); + printk(" TTBR0_EL2: %016"PRIx64"\n", READ_SYSREG64(TTBR0_EL2)); printk("\n"); +#endif =20 printk(" SCTLR_EL2: %"PRIregister"\n", READ_SYSREG(SCTLR_EL2)); printk(" HCR_EL2: %"PRIregister"\n", READ_SYSREG(HCR_EL2)); - printk(" TTBR0_EL2: %016"PRIx64"\n", READ_SYSREG64(TTBR0_EL2)); printk("\n"); printk(" ESR_EL2: %"PRIregister"\n", regs->hsr); printk(" HPFAR_EL2: %"PRIregister"\n", READ_SYSREG(HPFAR_EL2)); @@ -931,9 +939,13 @@ void show_registers(const struct cpu_user_regs *regs) { struct reg_ctxt ctxt; ctxt.sctlr_el1 =3D READ_SYSREG(SCTLR_EL1); +#ifdef CONFIG_MMU ctxt.tcr_el1 =3D READ_SYSREG(TCR_EL1); ctxt.ttbr0_el1 =3D READ_SYSREG64(TTBR0_EL1); ctxt.ttbr1_el1 =3D READ_SYSREG64(TTBR1_EL1); + ctxt.vttbr_el2 =3D READ_SYSREG64(VTTBR_EL2); +#endif + #ifdef CONFIG_ARM_32 ctxt.dfar =3D READ_CP32(DFAR); ctxt.ifar =3D READ_CP32(IFAR); @@ -945,7 +957,6 @@ void show_registers(const struct cpu_user_regs *regs) if ( guest_mode(regs) && is_32bit_domain(current->domain) ) ctxt.ifsr32_el2 =3D READ_SYSREG(IFSR32_EL2); #endif - ctxt.vttbr_el2 =3D READ_SYSREG64(VTTBR_EL2); =20 _show_registers(regs, &ctxt, guest_mode(regs), current); } @@ -954,9 +965,11 @@ void vcpu_show_registers(const struct vcpu *v) { struct reg_ctxt ctxt; ctxt.sctlr_el1 =3D v->arch.sctlr; +#ifdef CONFIG_MMU ctxt.tcr_el1 =3D v->arch.ttbcr; ctxt.ttbr0_el1 =3D v->arch.ttbr0; ctxt.ttbr1_el1 =3D v->arch.ttbr1; +#endif #ifdef CONFIG_ARM_32 ctxt.dfar =3D v->arch.dfar; ctxt.ifar =3D v->arch.ifar; --=20 2.25.1