From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=helo; client-ip=104.47.38.62; helo=nam02-bl2-obe.outbound.protection.outlook.com; envelope-from=brijesh.singh@amd.com; receiver=edk2-devel@lists.01.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0062.outbound.protection.outlook.com [104.47.38.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 33A6B20337371 for ; Thu, 5 Jul 2018 07:05:22 -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=1viUorx9n6ZqNcwkx1Mvj9HdZic3fEv+1rK8vo2D2lY=; b=EkXXOtALCpv8nU7sLoO4D2slFTsI7ScP1wyvJNfSzMq9vBe3oTYqq/uOR3FVCZ5YnGibE4KPCpb8bF1Etyuk+nAOYuoT4fV5bGicjnCOwVzeGiyWj7OCotDYYLhrtEjojM1O3E8ctlYIRZSRkTTfj7SOk/7jqjLd27tivpEtXpU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SN6PR12MB2685.namprd12.prod.outlook.com (2603:10b6:805:6f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.20; Thu, 5 Jul 2018 14:05:17 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Tom Lendacky , Brijesh Singh , Justen Jordan L , Laszlo Ersek Date: Thu, 5 Jul 2018 09:05:04 -0500 Message-Id: <1530799505-28256-2-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530799505-28256-1-git-send-email-brijesh.singh@amd.com> References: <1530799505-28256-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR07CA0074.namprd07.prod.outlook.com (2603:10b6:4:ad::39) To SN6PR12MB2685.namprd12.prod.outlook.com (2603:10b6:805:6f::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c999ee2-e022-46ce-1c43-08d5e2805661 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:SN6PR12MB2685; X-Microsoft-Exchange-Diagnostics: 1; SN6PR12MB2685; 3:GXr+tE2nIvYY1s1lHgXsrL5MzQwAQtQ/vVzLhOKy8Z9CEb7EA5kHT4xzI3/h7yX5466aR2Gh5T8gk/61a61XWl5Hfae/v9ON5ILRkEiHbSwPrGI6wHEhwzErCQ4LFont6TqJ5d0e5w/cPYd1BK3IAtAf8yRbxtRlMGGg3QcC5Ex7EB+1wESOskGRk9kF4rbYo6lPBYcRwqMhZi/ZXkxBYv0BYUufsJ3w429l/eoy4hoO85TOcZ2GxtxEBKULaPtj; 25:WG9czYicHqVPMup/OngEDt4zWBah+WJ8KCyl53B7xQhh5tfD0iC50Z+6T/dwcM0NWMU84/3PhzNYdcjRHIUeIxwygK5rDlGfY7MdSH/jicNczDUtrGilouY754MVHXlbpzbfl9evllkh0iQfxjBs1ru3+stalsc6gK+MWpO4mowhM90njdBgfQSTaI1cbOiUGLKB6GynOpBLR/KNptBaxzaQhEFhI5IEsJ5PzqzyWBJuezns2+okOqQD/OTsFowLG/G4M5C/wYNYy3CzsENuBs4u6TKicYgW3RM7kuhfDNk2xvGVc6SZoX7wHIifZXJIra8ckFaagT0jctdnKqGuag==; 31:LXK2tqlRCFqW93QDslshn4e5T/2MVfM+hgWS0l5dc+CsensF78GKiyt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IHtrwwxYNtgaOK7eXGFkx8x2+l0JbqhsVg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:SN6PR12MB2685; BCL:0; PCL:0; RULEID:; SRVR:SN6PR12MB2685; X-Forefront-PRVS: 0724FCD4CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(346002)(136003)(396003)(39860400002)(189003)(199004)(105586002)(4326008)(2351001)(106356001)(54906003)(50226002)(25786009)(53936002)(51416003)(7696005)(36756003)(52116002)(16526019)(186003)(47776003)(2361001)(66066001)(5660300001)(6916009)(68736007)(316002)(16586007)(6666003)(478600001)(53416004)(446003)(8676002)(86362001)(6486002)(2906002)(81156014)(44832011)(50466002)(3846002)(386003)(81166006)(2616005)(476003)(11346002)(956004)(8936002)(48376002)(486006)(97736004)(305945005)(6116002)(76176011)(26005)(7736002)(213903007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR12MB2685; H:sbrijesh-desktop.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN6PR12MB2685; 23:zha0psG0Btjo3XXEr5BIeOALJckiidrutN8Msf9T4?= =?us-ascii?Q?C7C6tg6QsVsGuHNTc7zMeWNb2CcbCrzUd1pLaYkpIAWWkHcRqoVnVUXmRMct?= =?us-ascii?Q?h+O9iuGeVAkDUGgvHPhV0b09XjK7xVCa5kVSaO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q2x7b/NxaqdbQv/7E7/EY/TNixqsSgmjiaSZx74dZe+QEzuhz0nNI+pW26x6p9AAzH0OF3YqANaE0IeZCLwv9tBo5VYQeERZtVWLFtxrLCB1coX2hcV2OFzR+EN6uNYcwVOjX45hUHcsScrXH49cLXGc8Ug==; 5:1155hbmCW8UNnVWpxv/Ilr3NbGpOqDOyikTMO3P9ZGkSU0GiqNhu8mn29i71kxfI3qR+Ct3+f7aZzYZ3i/PmJCeBr58lw7OmaMa2RcHzE/gg6rSziL3glh597d2hM1UIs+UdoWz23LqVhljsaBuxB63nb4BXsCMVsrNyDEl5BkE=; 24:oGULefggycCbPH0qCe6YPpHqnMZjYWr7O0lYZtXVxaRjRqoTnVVWSK177vrGZ73vXhEm+9uQbepfwU2MvKgQgaIMb/5DXCILfq3KbXIjhT0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN6PR12MB2685; 7:OTm0/ubkhqNP55StaY6GMQqfwushMqxBIWCuqSLEzYFlqdr1/96Q7QOXVARDuxN2L8ev+spvfbsERw+lobc5S9x46VLoKvo1SN3nziJh0DMpJwHutFdXqaUgp2fSK0wiyUX7iASfr6VRNdvflZbAgpY90U7EDwxugpefC3+SwWUccGyLyTmjcP/kGVr5hWyVecsxWJvddBeEGAGNQzDskSUKDVHsoMElnIoLvvGAzDu2SjUZRtteahTmWKcASHTJ; 20:0LpF9b5uv6GihqBloGNxI1RbS+5KIWS9Mjfwus9pJ98knI6CTTHJTwNTvpcISa+EtWobq2UiXdjHtyizUszMUY9R+q84YmdFj+3zSgKqwTS6d3cxr1Dqc9DwnnpxC6WzcNLRLwO54X8DDuexdxr72lMr/ru4trB6+i4tGZZtRb27QlMDCTq6B8eW/rhLuxyYwctfSGek5+PkREaFchsS7jEd+JVr1LNNbQgqdiTrNX7jgfbtKobIMPpDdqGXW2Nv X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2018 14:05:17.1606 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c999ee2-e022-46ce-1c43-08d5e2805661 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2685 Subject: [PATCH v2 2/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not expose MMIO in SMM build X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2018 14:05:22 -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: 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 | 51 ++++++++++++++++++++++ .../FwBlockServiceSmm.c | 13 ++++++ 4 files changed, 71 insertions(+), 50 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index 28499991a43c..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 ( - AllocateAddress, - 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..646427bf4e2c 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "FwBlockService.h" #include "QemuFlash.h" @@ -155,3 +157,52 @@ InstallVirtualAddressChangeHandler ( ); ASSERT_EFI_ERROR (Status); } + +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 ( + AllocateAddress, + 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..cdb073348158 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c @@ -67,3 +67,16 @@ InstallVirtualAddressChangeHandler ( // Nothing. // } + +EFI_STATUS +MarkIoMemoryRangeForRuntimeAccess ( + EFI_PHYSICAL_ADDRESS BaseAddress, + UINTN Length + ) +{ + // + // Nothing + // + + return EFI_SUCCESS; +} -- 2.7.4