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 DA3F6210C2D7D for ; Thu, 5 Jul 2018 07:05:21 -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=2CiPzVBWAx8J+BowfC1bMb8EsEoRuCCnWVzgwJAOrSc=; b=sc/iPDJ3dS20d5vpdWMyh2PZPzBlxNRQMhJniWVdizg91fqdhZKcGD4HxYhhfoZOhEAqP9ZoXcGDNfswwQEO6xIQSi5xPInDeKqE/vJa0iC4sUoopud1ClrcfOfaD/1KP87kJc7znGpYQn9rTp8fPSnfZtW0WKgB5U9ur3o3bZ0= 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:16 +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:03 -0500 Message-Id: <1530799505-28256-1-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 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: fc7bd87c-cef2-43e4-9ac3-08d5e28055ec 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:xmp1aaTewGtvADizBkq4OEflqq//EUw2gYzHAczR5yBt8+WHBsGhmkej9mFTuf00b4sHgkzGBhUkKAMBa9yB8F6brs2YFXH8GJxY35XNOcwAMc8sOtOrJaAPHlZ+sw2k69EG0nijSWX3L10Gep6tW7QTFP1K2EYROvfHQV9s3Bcz4tOHgIluoltB1j7K62zqvyneM0nRKROVeAVRrkYtINflkD+OQaf92EssfoggiZuIAUabxc/bukJ2UVbzdU7F; 25:Rk93vNGTr/fjM2u+M0KTc3Ogmq6Cpmz0FFSLcyl/bteJBc48gkHZjj0CluSThaCux2qRWeIoN3KmTQCUJVRYnntk1R2PJY+KsJtxxP8D3aX6XNe2bU375lLNXtS2ka5gKDIcYELH6KGWAJsyPmAykRiI8+uhEHrYWfje99ODdEmJp9DcwKMEI9ina171+9raM9BENxojWrs+adcka8aWQRQ0Hu3f0ZImOpnkSEHHBRN9yFocJIi00QKyRjmhXUP6G6ZkSl10rk5NL8l/GiAK1wCXs6xDKC65QmqRGbkix64R4kI8/nvewvwRKWVZhZxcVOGzggzT4j2kC5htquRQIQ==; 31:nsUglam/TCLqNS0CvnseE3DNAgshUmiuDM5V1RV9oAGWvWPc1r2e5JRNfa2yrJPbqiRqe1ha01pqUvSQhm+6glQDtzFQdd4o0RRAwCs+DMhPwo7DeRC9CLleKcgib6jsSq2CB6C+VNnBy1JyNW2bs3pKCw8KKuB9hye8TYuyC4ECxAxzoTFNwxEuJItNBRXdof2YCqjsnMQH47iGyKI4nNEEKej3AyUmj2fDLsm1mDQ= X-MS-TrafficTypeDiagnostic: SN6PR12MB2685: X-Microsoft-Exchange-Diagnostics: 1; SN6PR12MB2685; 20:DhbuOHpGg2E+kI6ltBtfobvecGP+1DOb4mY6Ymm75DwdeGERqMnWDqS7vnaCcuIxc6WUFpDbKCCI90ofmkt8zDZxpk1F+HmuItQamzf4Fvn8LNVdYcKyMPqRq050hpQi6zLdcupoJSID41faHQUvYP3XsqGK3GQ7J5mNZkmTghI3HHQDzP71zOGFtmMyZNMUGkGUskLnT7aFm06lgj9FcBZaf6s+iKVHA4IpZAeUFtphfNeBuaaCteOAy9MSvBMDQPZvsBhQqkVMML13k820FEVZNNX8JpfZqyJYNugD0fIVjJZSvVfs+e3af2bdPQA5M1ZKo2JcPYk66rwaWlMh2VYmm+5F5nkZerYTX1tPMyy/LWMcttQ6J2/jIK6yHuINrK3axyHiMXRahDnMqxHK5JjDBBkfcul5j+o39Jkr+DtbBWOD6PKGgEMvF5iOuxyDwQwV4iPP6vDV93gsVJ2uR32t84tmuKM9dTHDG5wmSyuD+moXsRS0OBRQ51D5nquK; 4:ZjLoAy10YOMz6cv8NHEP1HoQvwR7kL+2QnXR9un+2yz3/smpgrixUlF6Md/pUYKNaTVM+JfWoj3YSPDRH/x/+6OT/FUHpcjb/ij8l51xYM205sdUXboT3+GntfOMos0Moc6MNiNGwIgBnS8yaf39dNctiBqVg3imiBJ/HdxH87pktxT6z5eR7nCPnaU8G8u9yQdHHSw9gf9C3qkroLSYfv9FfgW97JNCa2sjiTnPOvMwTvduI5G+tq8wzT4pl4hKJ3dOuu4L29KWFT0mI2+M3aP6sLMqCt3XcutzAn0NK/Ba7Madw4TuHuhFTR4EUjrDl6Bsj2ul0dpr0g6aSVRdEg== 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)(8676002)(86362001)(6486002)(2906002)(81156014)(44832011)(50466002)(3846002)(386003)(81166006)(2616005)(476003)(956004)(8936002)(48376002)(486006)(97736004)(305945005)(6116002)(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:sLgOAAIIiNK4lrDA4F/NqBHrbVQxkBA7mGFjtihRc?= =?us-ascii?Q?O78yF9nV1z/DVKRCoJNLcl8qhxNd1UzJpPXmfg4Bw4ZhCECBWaBEYeG1SHWj?= =?us-ascii?Q?CD8CldJ7ULC3aXMeGzsqAO0d9R2qC0MgVEuyfbmCM0o0zdivqqXUN/hkpWhm?= =?us-ascii?Q?FJov6xXzCo7yaV97moM9xtGjTkV6E8/dyb19KFjQRQ1OjBaYa64YEfmP14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YOIhWuGWH+VbfTIea8B0DpDA9xmAU59eMeeEjM/ycfTfdFf6iFhzirXzOYa8SylvZPZ2zpbHuEo1abT2u1q+oTiL0MzWfBH6wGju89s9tWGMjgAcigmu15iu1pwSjlDOI3vjZqFjr6NqqMHdctJ1Gy6vMfes3Lk/II=; 24:W+/bBuPkaNr9BDwKtSMVBB7EW1yUCzfmpuBZAYplkzHyToC0mulwG1tecYWN4Obd1VTGDLiBuiRLuoiwSLMWFj9tCA2l462jAkfzaKgDGLk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN6PR12MB2685; 7:Rf65SOehHOzEcqYDugTUfZDZnAba+9Rbm0ePvUX5tbdCk6/WPvWd2z0MzHeBSSdX4LoVYP5nu/FPMuMxZB4STTF+HkWrpVugBRxgXF5gMGMaJdYZExEt0i2WwlilJh+gGYGzAwoz+7CNGK9NxgoqeBA64beZsTY2lZce5Eqbg7rjOuwR1V42WDsE7P10VWHRqQHqNLKXI6BN3SquK6e24xC1F6SEoUOsP13DhJq7va9d0Gqc7l88cvgfN7NwNt7U; 20:4LW4AM1ZbN+6SQ0RNKZX3GDHTQv7Cfjyx7Li1EzvWivgNoJGGPYZqQV5p5ArRcCJ623509v4DLM9ClUyrIsxypzZBVaSM5GujNJyXMuqyLZMhzoHECKp9Gk2oFtmGMQcuUiVBYaCT/wRK/jRymVD05pDP/kwEpAW7Vlv8VAv7tEhuC7UPj7lZsQ4XOKJjwpb/rtfvVPr7psGQIc2a1i3L4VBrWDu5lwP5JPAvGJv8ACSsse6gKHYwPasqt30RnhB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2018 14:05:16.3961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc7bd87c-cef2-43e4-9ac3-08d5e28055ec 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 1/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: mark Flash memory range as MMIO 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 The flash memory range is an IO address and should be presented as Memory Mapped IO in EFI Runtime mapping. This information can be used by OS when mapping the flash memory range. It is especially helpful in SEV guest case, in which IO addresses should be mapped as unencrypted. If memory region is not marked as MMIO then OS maps the range as encrypted. Cc: Justen Jordan L Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- .../FwBlockService.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index 558b395dff4a..28499991a43c 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c @@ -831,12 +831,13 @@ ValidateFvHeader ( STATIC EFI_STATUS -MarkMemoryRangeForRuntimeAccess ( +MarkIoMemoryRangeForRuntimeAccess ( EFI_PHYSICAL_ADDRESS BaseAddress, UINTN Length ) { EFI_STATUS Status; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; // // Mark flash region as runtime memory @@ -847,18 +848,31 @@ MarkMemoryRangeForRuntimeAccess ( ); Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, + EfiGcdMemoryTypeMemoryMappedIo, BaseAddress, Length, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME ); ASSERT_EFI_ERROR (Status); - Status = gBS->AllocatePages ( + Status = gDS->AllocateMemorySpace ( AllocateAddress, - EfiRuntimeServicesData, - EFI_SIZE_TO_PAGES (Length), - &BaseAddress + 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); @@ -1091,7 +1105,7 @@ FvbInitialize ( // InstallProtocolInterfaces (FvbDevice); - MarkMemoryRangeForRuntimeAccess (BaseAddress, Length); + MarkIoMemoryRangeForRuntimeAccess (BaseAddress, Length); // // Set several PCD values to point to flash -- 2.7.4