From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=helo; client-ip=104.47.32.48; helo=nam01-sn1-obe.outbound.protection.outlook.com; envelope-from=brijesh.singh@amd.com; receiver=edk2-devel@lists.01.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0048.outbound.protection.outlook.com [104.47.32.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3D60220336AA3 for ; Fri, 6 Jul 2018 08:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FaaHDuaO4ki0IQjC835q6D+HGw8UFh2lznRCVGq1R4U=; b=4WAD1z/86jEj3hHp/1NEn91OzzoUI+5GRHz+C0TibtjFBau9uuEEqlF+6GSj1UrQGJBMCl+kbmBtQ94ph0P062HgHF8e+uL/ztjSd4bf1JUg7odg0VZr1clWnHpwfxFXui4i1zTvF3YsPrrDPdOMLyDkpVz99P0FUJSBwplqOao= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by BN7PR12MB2675.namprd12.prod.outlook.com (2603:10b6:408:29::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.19; Fri, 6 Jul 2018 15:00:53 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Lendacky Thomas , Brijesh Singh , Ard Biesheuvel , Anthony Perard , Julien Grall , Justen Jordan L , Laszlo Ersek Date: Fri, 6 Jul 2018 10:00:41 -0500 Message-Id: <1530889242-21667-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530889242-21667-1-git-send-email-brijesh.singh@amd.com> References: <1530889242-21667-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN4PR0201CA0017.namprd02.prod.outlook.com (2603:10b6:803:2b::27) To BN7PR12MB2675.namprd12.prod.outlook.com (2603:10b6:408:29::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a91856d-b6e5-4133-9766-08d5e35145ab X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:BN7PR12MB2675; X-Microsoft-Exchange-Diagnostics: 1; BN7PR12MB2675; 3:HCNHaOOjaPuR6JWDgMLR3VRwUgLuUGQoYPmV1pdH6eEudi7ScFp+EKacytUBWlRpurDtgO4RmjfZIVjKfPKzt3tiywyh6FRKuZDJjcW+LO5Xz4RV0UHuMhDU57Xps3RukMwyR9Q5o73D8u17A0ZcCRA44WhO3ZsGC8RuaupWjffooEh3t8G1guSNE25jSf7pq9B/m/nZsduJDfleq+bVh8tW6OocXX7ELG6vO45WS+hsPYzOLiaXhN+HbYl8SYdF; 25:UJQPeB4yHI6CwWS9g1PSw9hBFi5IKUj1JDPX2pUIBQAKFM6JFBD4UjpgENMsJDOgk+mkGgNQXUGk0x4qL50t4TAYWlxuKSOEn+0xNKUOqinHxxXzrnrlwbF8/3nfDWh0AXdb/p/zI3d1HcfoXT8cU4AYx7zPeJJYcPkdc5RyqdfrpbiPN9xffzWt1jjhLHEMacZ+J4xSQIEvLPtJg/NQfh6TEKNB38rWLjLXp//eg3fgu0lytz3aEbhJmgTByR2vfMg9Q45Tg9KpEYUqVew/klKNFdY2TyVJtGwonEQXJOqGfZxx4d1XstyrGkg9Cz3l9Wnegh78p9ASHm8HOFTbJg==; 31:TnuJaX1+GOfU5XyFllV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pZtnk8MfzhrEq+QT40JC9qnqGsP/Ro4xjrAeWP/Oq12Am+86n9uo70JVH+m8O/2c3VRMRF2i6AJsiuMwYAxl6nbPKt2BnzuqtwAS2aERC+o X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(70601490899591)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:BN7PR12MB2675; BCL:0; PCL:0; RULEID:; SRVR:BN7PR12MB2675; X-Forefront-PRVS: 0725D9E8D0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(376002)(136003)(366004)(39860400002)(199004)(189003)(478600001)(52116002)(2351001)(25786009)(2906002)(6916009)(3846002)(305945005)(51416003)(50226002)(68736007)(7696005)(54906003)(81166006)(8676002)(6486002)(7736002)(6666003)(6116002)(81156014)(50466002)(48376002)(26005)(86362001)(8936002)(53936002)(5660300001)(386003)(47776003)(16526019)(76176011)(16586007)(316002)(4326008)(36756003)(105586002)(44832011)(97736004)(486006)(53416004)(956004)(186003)(66066001)(2361001)(106356001)(476003)(11346002)(2616005)(446003)(213903007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR12MB2675; H:sbrijesh-desktop.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN7PR12MB2675; 23:VxB0lo8F52eUXtLrNKChZes6iXUOTkdeMqPLO7+PC?= =?us-ascii?Q?sOx7wwEg0VufwYdkUDMAfjalc5YhYT6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wmNT66Nm2aMkigHcyKkWVPHHGhiax40HSiC5 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2018 15:00:53.7928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a91856d-b6e5-4133-9766-08d5e35145ab X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2675 Subject: [PATCH v4 2/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not expose MMIO in SMM build X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jul 2018 15:00:57 -0000 Content-Type: text/plain In the SMM build, only an SMM driver is using the address range hence we do not need to expose the flash MMIO range in EFI runtime mapping. Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Cc: Justen Jordan L Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- .../FwBlockService.c | 50 ---------------------- .../FwBlockService.h | 7 +++ .../FwBlockServiceDxe.c | 50 ++++++++++++++++++++++ .../FwBlockServiceSmm.c | 13 ++++++ 4 files changed, 70 insertions(+), 50 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index b3f428bb4284..eec8b1b1ae9d 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c @@ -831,56 +831,6 @@ ValidateFvHeader ( STATIC EFI_STATUS -MarkIoMemoryRangeForRuntimeAccess ( - EFI_PHYSICAL_ADDRESS BaseAddress, - UINTN Length - ) -{ - EFI_STATUS Status; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; - - // - // Mark flash region as runtime memory - // - Status = gDS->RemoveMemorySpace ( - BaseAddress, - Length - ); - - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, - BaseAddress, - Length, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - Status = gDS->AllocateMemorySpace ( - EfiGcdAllocateAddress, - EfiGcdMemoryTypeMemoryMappedIo, - 0, - Length, - &BaseAddress, - gImageHandle, - NULL - ); - ASSERT_EFI_ERROR (Status); - - Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); - ASSERT_EFI_ERROR (Status); - - Status = gDS->SetMemorySpaceAttributes ( - BaseAddress, - Length, - GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -STATIC -EFI_STATUS InitializeVariableFvHeader ( VOID ) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h index 1f9287b08769..178f578d49f0 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h @@ -189,4 +189,11 @@ VOID InstallVirtualAddressChangeHandler ( VOID ); + +EFI_STATUS +MarkIoMemoryRangeForRuntimeAccess ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINTN Length + ); + #endif diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c index 63b308658e36..37deece363e6 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -155,3 +156,52 @@ InstallVirtualAddressChangeHandler ( ); ASSERT_EFI_ERROR (Status); } + +EFI_STATUS +MarkIoMemoryRangeForRuntimeAccess ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINTN Length + ) +{ + EFI_STATUS Status; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; + + // + // Mark flash region as runtime memory + // + Status = gDS->RemoveMemorySpace ( + BaseAddress, + Length + ); + + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + BaseAddress, + Length, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + + Status = gDS->AllocateMemorySpace ( + EfiGcdAllocateAddress, + EfiGcdMemoryTypeMemoryMappedIo, + 0, + Length, + &BaseAddress, + gImageHandle, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); + ASSERT_EFI_ERROR (Status); + + Status = gDS->SetMemorySpaceAttributes ( + BaseAddress, + Length, + GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c index e0617f2503a2..af08fa69d489 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c @@ -67,3 +67,16 @@ InstallVirtualAddressChangeHandler ( // Nothing. // } + +EFI_STATUS +MarkIoMemoryRangeForRuntimeAccess ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINTN Length + ) +{ + // + // Nothing + // + + return EFI_SUCCESS; +} -- 2.7.4