From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.groups.io (mail03.groups.io [45.79.227.220]) by spool.mail.gandi.net (Postfix) with ESMTPS id 336AE74004A for ; Fri, 12 Apr 2024 14:34:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TVMBTYbTj90c4YHbgz2nzQfoh1SrOYeBV3SNWDvpQBA=; c=relaxed/simple; d=groups.io; h=Received-SPF:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:NoDisclaimer:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1712932438; v=1; b=ly0IN5tP6KOdLR59XoS0EEj97EYK8Pnqaf18kvB2So8zVUwludR8ftGHVP538txfkotoWY9G rACdpaXfxUALZf96o2OArHSg2dEBN78fre9d7k+Td3X44v52F+PNccIItaIucHCiSDoy8JGEE1Q VgaBkco9MvzT6NI8cT9LNKRNZc+grIbgwPl82CjC2WVETqYhij1KFFmbWAaHqkJIeZpbw849AKm pIJFAx831a7M8tvuUzgs/oExZSnIe1FBK8flG1y0jEip0SR932ZsvIGZp2oh76HGBZEzH27HyWk X/PXz2s492P2EI3SSOcf4akB0GhR2NWkDVlgeB5wQu75g== X-Received: by 127.0.0.2 with SMTP id fZidYY7687511xPiys9tQEvj; Fri, 12 Apr 2024 07:33:58 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.43]) by mx.groups.io with SMTP id smtpd.web11.47959.1712932432654691842 for ; Fri, 12 Apr 2024 07:33:53 -0700 X-Received: from DB8PR06CA0039.eurprd06.prod.outlook.com (2603:10a6:10:120::13) by AS8PR08MB9816.eurprd08.prod.outlook.com (2603:10a6:20b:613::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.49; Fri, 12 Apr 2024 14:33:45 +0000 X-Received: from DB5PEPF00014B8F.eurprd02.prod.outlook.com (2603:10a6:10:120:cafe::38) by DB8PR06CA0039.outlook.office365.com (2603:10a6:10:120::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46 via Frontend Transport; Fri, 12 Apr 2024 14:33:45 +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 X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5PEPF00014B8F.mail.protection.outlook.com (10.167.8.203) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:45 +0000 X-Received: ("Tessian outbound e14047529286:v313"); Fri, 12 Apr 2024 14:33:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 96bedb77629d996b X-CR-MTA-TID: 64aa7808 X-Received: from fc7250547ec0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3154B08F-7072-4055-9567-4882AABBC5FF.1; Fri, 12 Apr 2024 14:33:38 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fc7250547ec0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 14:33:38 +0000 X-Received: from DB8P191CA0022.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::32) by DB9PR08MB9779.eurprd08.prod.outlook.com (2603:10a6:10:460::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.54; Fri, 12 Apr 2024 14:33:36 +0000 X-Received: from DU6PEPF00009529.eurprd02.prod.outlook.com (2603:10a6:10:130:cafe::a4) by DB8P191CA0022.outlook.office365.com (2603:10a6:10:130::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Fri, 12 Apr 2024 14:33:36 +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 X-Received: from nebula.arm.com (40.67.248.234) by DU6PEPF00009529.mail.protection.outlook.com (10.167.8.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:36 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 14:33:34 +0000 X-Received: from E114225.Arm.com (10.1.196.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 14:33:33 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 18/45] ArmVirtPkg: Configure the MMIO regions for Arm CCA Date: Fri, 12 Apr 2024 15:32:55 +0100 Message-ID: <20240412143322.5244-19-sami.mujawar@arm.com> In-Reply-To: <20240412143322.5244-1-sami.mujawar@arm.com> References: <20240412143322.5244-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU6PEPF00009529:EE_|DB9PR08MB9779:EE_|DB5PEPF00014B8F:EE_|AS8PR08MB9816:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b33fc2a-5f13-41dd-da64-08dc5afd8f0f 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: hbI3Zkhe76INRG9+mtaGmg57WYuyEn8M0Q6qYlev6rR145Q1kihNhG5c6VUFBC8zDJJnD44U+ZjdIctH3WCTREHKXiuKufEhLRz0Zd10LzBZYWWKyNBAU6/IU6H0bpxovPAwKisW3m74dJbvWtpJ78gogxcTMw4fE2YH4MRKp56j9AMDqu2CN+Tzs6Ox38/IRWbzNyixYtDRxEsCcaFOeHGWgILWH7rrHM0HQBn5D2HjRzIysG4XEHPEtTUBJFhyhkgylJtEjTO/G9dNrBTUAtg+ZCqGaI1bjinfYZcbBoqTQ59qx6U3v5O+1JD7J6+Ci8G4cZ+G5+2ZBXo3zt2fPr+m9sg6XcsbH/s6pkPkm97mSFqFAqTxmw+icgyDRVs95cmp98DAixMh3i9JWk6o7sCxwlRE4g6iLncOQ4/GsvD2MbSUjIe6EM2hVWFvMlLMQsyicRMO3/ER9RbO10WtUEfP3PQrsCE+VNCjUcGX+9llKHhG2vp5D7EEbmB9rt7mNhDpVehhriXTyHPkERFghZsYCfkqvaCcwqhUUFRIyBQbwW13LluFqy/96+nsUIGvP6BDhSVSXjNuM/KLyN4a0VevB27cOJMA/phIhR0YOMZIVBkLvJPMTDhaPPJGR7sWxvQgaC21doeb6gCcNl6o8qS3EojTFaRjTlWJgOno0a0M2MZtLeIulLvnQdiNxbJxUrhqzUerdV3laoZJdvPf0a9FZSdtazKemkRiDG3tz7KkCnyNS0DnhernCW8LXXNu 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:(13230031)(82310400014)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9779 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B8F.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f240d3c2-0564-4ac5-5cec-08dc5afd8a06 X-Microsoft-Antispam-Message-Info: yqO+CigE4//a8Lr/dE74myIT/hnKz6vsemskdyUY55zUv1IgQCtQXoy4S9Ygmo8OIX27O3YJ0FY9JzR6F+ddoCCsRdvIB/DQ5yghx8zKAUGFIBH8By6tSjCYx2h0+xr0SVKGSIauq6OC/aSyqSp/cqMyNo+9mitsFrwn3RHY8yd2pZZi949sAGWaF1IlgF/UPl47FhOiybI0pG+zOsTlYDQOdNpb0GAgYCwrlPT6ZH10+pS4UqbaU0bg1HI8URxYyYlwKFTcEAIWGlAc5j5+Qmq0PpnJfKH9TICwQ7rdKyO7qUTq2C2RSFy89Y/DG/2iYHyqm9DP2a8vqt+UjERiYPP+I00W/10QoMhHKgkVNnmlOdu9+0PH2OZEpNSWTj1xJTOhisSh21hXPDUGc7C+EOz8l7UFnN0BZ7rPPX4LtlOInPzDPY/dZBhe8rCNt+/xxUFFbUIAGOFARidwMZqiDIxNSfvYvDP6pfRuDfXP3Fwinf34td+guBhZszcj3knLpWHhN1wwCrxqjn6RKIF4fDWuGJuaplSrJtHGrG+L//CVQQSd+l8RydIEWNT/qJum1sVAV1oH2J7G9Rc3z6VRWgf3W1ajcaaNabXZaiE0DzSX6Jud+4m36+tNWub1CrNNcKYSsTLe6cbnAuKRKfuU6Mh+Wsx/eP6mivFRrFmge+RKA0FMiYCzrIQaML1CsvVBQfyVq0G98XlcA28RsaUzpHgEPL+CZ1PP2qmfqfrl1tsV6wGX+UDBvoXyhQql0Tvr X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 14:33:45.3174 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b33fc2a-5f13-41dd-da64-08dc5afd8f0f 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: DB5PEPF00014B8F.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9816 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 12 Apr 2024 07:33:53 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 4EViS8qyXsVtIjO2g5rYBYF4x7686176AA= Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=ly0IN5tP; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io 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. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann 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)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117683): https://edk2.groups.io/g/devel/message/117683 Mute This Topic: https://groups.io/mt/105483421/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-