From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.47]) by mx.groups.io with SMTP id smtpd.web10.83974.1682438705713915086 for ; Tue, 25 Apr 2023 09:05:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Agb5PTsU; spf=pass (domain: arm.com, ip: 40.107.6.47, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r3BCtOA42w0PMS4IwSH5LR5x5xwQVxUSbhXfyPiE0w0=; b=Agb5PTsUDMo3khzWqBA3HgFUF1U+yaguwSTll+ikihXVUXbom3YL1E31qxaP178CbPNe7tSjrfKyzEEp6SktesRF1/+7M+onLgSG0R3C5uHodambVCfnzQ2ijDGIS1K2C4ogyZ9+qSxxZy0xbRJg+iZib1ddKNOyX7JX81xgA9k= Received: from DUZPR01CA0077.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::15) by PAXPR08MB6510.eurprd08.prod.outlook.com (2603:10a6:102:158::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:05:00 +0000 Received: from DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::85) by DUZPR01CA0077.outlook.office365.com (2603:10a6:10:46a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:05:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT021.mail.protection.outlook.com (100.127.142.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:05:00 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Tue, 25 Apr 2023 16:05:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b79711b0cb348684 X-CR-MTA-TID: 64aa7808 Received: from 9d3f32eee6a9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 847B3A3D-8329-4129-8596-835046A9D8BB.1; Tue, 25 Apr 2023 16:04:53 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9d3f32eee6a9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oSeISpWhjIiwm/k+dl96Q6WMXyfukeqIs6SsuGkbfv+ngyT8KKtngQnqxgc43fOoxZlWBmewOsgDqu27QwAMTepeVpST2dRJX9tPQ9LfcbCpOqTjv63RKx5EZrstjuEAKtMzkwjeRV343aTi6dC5bTQPuMVAJeD9IbAfArwcLcT8+8CZmyaS9jaqzBcZx8ywGhRrxiaoh1U+GQSl3dkqPjeVzH/oDXeICV/j6KT33MF5QGlarhcUyomU01Trwoh43+QgLEqOFcJoSRhfhuwo6IelwmJ1QL4zxCL9AUiZCiW7bGSQGRbXCAn4TLViPbPdV/qgiGTO//oEQ0Y/bXb5sA== 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=r3BCtOA42w0PMS4IwSH5LR5x5xwQVxUSbhXfyPiE0w0=; b=U/aYjwiyj5zQljrzaiXjqrJo/WBQ0kzEg8T378aBWhiZkK7A3/GmS/j0FA/1K26snKn8xdHY0mHr3MoodvXqqRshlYCxeuyWgknFjozBaCsmE7SxxGuLyWT4SqLybQ7s5IGMOQFxA7yah+xKMu6AfL8bKYyEodtOJuRDIZpNlMo+654DbUz4eoxxoDuKK4Q6H8o75T1tjC+dpxCLZPYU3dMS3V6FSNQnN0H2dQB/e1eeeJ4KZuXG6gzKWR+1bHxiog4prRgKZmOs627GwdnJYLg4k9AQIsyJeqY1Dg31jRxsu5Kx2RKrpXY99CbqaVCiKrbgJwT+TpnWQ8MBHq+xJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r3BCtOA42w0PMS4IwSH5LR5x5xwQVxUSbhXfyPiE0w0=; b=Agb5PTsUDMo3khzWqBA3HgFUF1U+yaguwSTll+ikihXVUXbom3YL1E31qxaP178CbPNe7tSjrfKyzEEp6SktesRF1/+7M+onLgSG0R3C5uHodambVCfnzQ2ijDGIS1K2C4ogyZ9+qSxxZy0xbRJg+iZib1ddKNOyX7JX81xgA9k= Received: from DU2PR04CA0016.eurprd04.prod.outlook.com (2603:10a6:10:3b::21) by AS4PR08MB8243.eurprd08.prod.outlook.com (2603:10a6:20b:51f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:51 +0000 Received: from DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::b7) by DU2PR04CA0016.outlook.office365.com (2603:10a6:10:3b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT036.mail.protection.outlook.com (100.127.142.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:51 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:04:49 +0000 Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:49 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [RFC PATCH v1 20/30] ArmVirtPkg: Configure the MMIO regions for Arm CCA Date: Tue, 25 Apr 2023 17:04:18 +0100 Message-ID: <20230425160428.27980-21-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT036:EE_|AS4PR08MB8243:EE_|DBAEUR03FT021:EE_|PAXPR08MB6510:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b322df2-012e-4541-b30d-08db45a6d2a8 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: aN9ezWbol+l19rTPUAPywtvogH0JTATmUmHDOqJvD/4yWPJjmO57Z1miuGhiV02gRclvW3zIGnTzZZ4OiEGtse8YV2irTs86lvm2INJs8PCmqIbZVULpX0SXOg4G0mq+5f/TVpy2Wktnj4f63ueUsmFBM1674EEBobO8VBzXe3Iwc0MirPDsGJpNst8k24HvuFBNoykhpcbhuDTcQZ5+19oa2AXG+C/SkShyVGAnIlm+57auWmok2godoXeeu8wjreHTO09iqVVKe4jkRjEYwxc6nI4Pz1gbTzGluJjI54osO5QMTdRyWsHzyT4MIluEcUt7jyK77Rw2po9nqtngu6EfpxdwToVSl9Dawooc8ZvVMiPhJQ2daxjaf8tsrfH7gOR8Hb2fWXE776Ccm3aG7EDrqer54aaARhtxJkEupo5hnbE/e3NOezAAOtxi3XcYhSUct6ZFodiWPbC2X9icVntiK1UwVZyWPGp3O/yoSlauFVdGW9udg7Fos4z7qN95f+SqZZA2f6T2UAYAIJpK9qv4GxdWz61vTB/M+h1T4fU1y9hWgzS2NK+e9opnKDQtapbhtulxA10W/fAQq7C9b5VEXAWm5vqIX1+CJ8l8+r7ggBJLEsB+SAVkxfCo2oEvpQLcqGuDhkHn3mjxn0tHXfJMyxdPTusVIiRufORDQKWW+IFM/KK8X1QI0L+IwPUyCTKtoMgp8TIlXK+QTaAfLNAduCKeQsdRDGxVW7CRJhk= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(46966006)(36756003)(8676002)(8936002)(54906003)(34070700002)(478600001)(70586007)(6916009)(4326008)(70206006)(40480700001)(356005)(81166007)(44832011)(316002)(41300700001)(82740400003)(2906002)(5660300002)(2616005)(86362001)(36860700001)(186003)(336012)(426003)(26005)(1076003)(7696005)(6666004)(83380400001)(47076005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8243 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8d8e8da3-e0d5-4fb6-58b8-08db45a6cd63 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bO6U2VECo+Is/ylnxrM7taHZf8NkXtRY7tVmEyIHL4rLOkhbbAswBj3lZH+Sb2xuFwapZmqzROdH+u0WDCHp4TVdKS78GfxwZ2zObtlwec1DpZaZYP6vkknLL7RDcdp5ZAnvzym0IKD0xcZ8ppRU9ZGQMFqx7prZZgNpNXYUOaZ2YWx8S25g3OZPIlaYN7g6LKx4zAM9QDsa4n0MI+At82bRKQxmJ8jDHE0zCLrWLOJ8uc0gk8LFQNTeH0vLODhCDDmNAa51G5fDtfG1x3r/LmGs96jXKFlrT3fSmx2P/QBF8V4gMqkACEDVwkJZW5fn304BZIaEd8QHOG0pjkI/QOI9ivMWYZVv5vK0lJ5dRWuc+w6m7nySHvCUauGix83y5nn+eUA1v1aqO2t7kqeQaYrjfZzhSmlqWqOE9WQac76FXT8HifnujGdpVQDejybRBJ2dvN7PQLZ5DnfkAkl1kQ+cX2Oa3SUk273jh6dINXbqX/vmQY55e/QREnN+8EJ58rzxFU7TCO9FVL5RQaofSsrSFeekstpFjhYvrMYKhnTpP6sQdvCZhnK0gPuWTOEmgd60vE3xWpZcACbiwIZa7cKN6bgFIC9xutwlq1GY7tlFlp6yOPvsRMjv0msLq3d7SJtT2iGuyH+5dDxAPamYG8a9/HoMd67GZqngAXppQIcwkuGXU6BpNPtUvi4LP9lFFEeZsAc7+Y+oJ+IAtcyetNcoK0C5Pd/rS/JJEJWrw/o= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(82740400003)(34070700002)(44832011)(7696005)(70586007)(6916009)(70206006)(2906002)(6666004)(1076003)(8936002)(40480700001)(336012)(426003)(186003)(83380400001)(8676002)(2616005)(41300700001)(36860700001)(26005)(5660300002)(316002)(40460700003)(47076005)(86362001)(54906003)(36756003)(4326008)(81166007)(82310400005)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:05:00.3747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b322df2-012e-4541-b30d-08db45a6d2a8 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6510 Content-Type: text/plain The IPA space of a Realm is divided into two halves: - Protected IPA space and - Unprotected IPA space. Software in a Realm should treat the most significant bit of an IPA as a protection attribute. The Unprotected IPA space is used for sharing memory and for performing MMIO accesses with the Host. An Unprotected IPA is an address in the upper half of a Realm's IPA space. The most significant bit of an Unprotected IPA is 1. The page tables for the MMIO regions must be updated to set the most significant bit of the IPA space. Therefore, implement ArmCcaConfigureMmio () which configures the MMIO regions as Unprotected IPA by setting the protection attribute in the page tables for the MMIO regions. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c | 39 +++++++++++++++++++- ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf | 3 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c index 79412897f2251712fafa4a9633b44235f2d7bb9b..a4fee904a43ccb8844ceaea992698a99df2a8b3c 100644 --- a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c @@ -1,14 +1,16 @@ /** @file Kvmtool virtual memory map library. - Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. + Copyright (c) 2018 - 2023, Arm Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include +#include #include +#include #include #include #include @@ -96,3 +98,38 @@ ArmVirtGetMemoryMap ( *VirtualMemoryMap = VirtualMemoryTable; } + +/** + Configure the MMIO regions as shared with the VMM. + + Set the protection attribute for the MMIO regions as Unprotected IPA. + + @param[in] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The execution context is not in a Realm. +**/ +EFI_STATUS +EFIAPI +ArmCcaConfigureMmio ( + IN UINT64 IpaWidth + ) +{ + EFI_STATUS Status; + + if (!IsRealm ()) { + return RETURN_UNSUPPORTED; + } + + // Set the protection attribute for the Peripheral memory. + // Peripheral space before DRAM + Status = ArmCcaSetMemoryProtectAttribute ( + 0, + PcdGet64 (PcdSystemMemoryBase), + IpaWidth, + TRUE + ); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf index a354e734ab1b7308a3e52b4e2b4885ef29592681..8e157a44dc9d11b9258d3f6182d5b169ec97ae9c 100644 --- a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf @@ -1,7 +1,7 @@ ## @file # Kvmtool virtual memory map library. # -# Copyright (c) 2018, ARM Limited. All rights reserved. +# Copyright (c) 2018 - 2023, Arm Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -26,6 +26,7 @@ [Packages] MdePkg/MdePkg.dec [LibraryClasses] + ArmCcaLib ArmLib BaseLib BaseMemoryLib -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'