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 CD23E211F888D for ; Fri, 6 Jul 2018 08:00:56 -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=2purUg/awxSrQME8PERSaYUaDhefqq01YOaLDZLeo00=; b=w3M2+1UAah0p0EtbrkhbcX/ug6Y32ENwdvEhByLHF177tgFccNJlFp+9Qaxc2STtM4AxqwKqkG12ZmxR+i0tWOlUA9WHSBxVI4OSW7SoNYrllb8INwZSW7ng5xqYu5ntE3R+SuA6WUci/6Zqj1k8yjIEIJPJNtCJfYweNOJL6ZI= 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:52 +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:40 -0500 Message-Id: <1530889242-21667-2-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: 00a71eab-96ed-4024-40a4-08d5e3514516 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:oGKjJWxC7JTiB7rQQe+Vpy5Iv/Kjs/+U8dch7mekuhZN/LNnIW3Ignss3lzs8JhmzIDn/0sa8d02B+ZVWToGETwogzc9n9lhBYvtybS3+jHXI86dqsPLRvpitISad5cQbejNyzaPCpOhXlS/MhIeqT9M0nYe2sOpNhxcqp640zCpxguLDg3zpoPOPaaTOr7zfN3huuJDrMONVGGvokSkaIoJNacyjdvnoRn29MXDtUaNYJI2+n2DU6laUVN/5JL5; 25:52U0tS6l8xLGKBTZuJuBjlFudkB2jfLbZsE2IF0opsFVZ/X6M2ZNgSkuhQHDjyTu5ANI7LnY29DUxR4RRfebbugE26vLNhVAEri2PelaFyGGevP7GCdsg1+wUq6C5pg9lQHyLaQtdeIMJT8h8TQmBAMi6Q77SHqq/1G3+80HVJx4ZfahK8aNHIddlj2dKF+LHgSGj4uQfRBXz1X/UQpKNeC0voIuvRACZP/FKiXe3xzZMG/SJtvAnALzFnmoak0zUNOF8isYaSQ+8JncPQ/ngHfQXmkTFaZ93+KoGmRSn5NQ7v4j6UMsU77o8Of8rHSm2B/7suG/zRG98AKXq7VGeA==; 31:3Kz4Dm0vugYzsfAUROUN9XeohtsiY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NR7ZRgVNPC3UgsXoER7dN/3cpCWBmIGTCVdHOVkxvroGn8txJoLT9mnFn2hJStJ63uMUFuZqYaTSqT5qzTJ9655btpIDLJeriJX 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:6jeCIVeTLwfaVJgtT091Ctv3efuTyXkKA8yPNjfD8?= =?us-ascii?Q?m+P5hghpv2WV0NSlL61pYzHJoGb3FO1gYqrLJhilrw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X2clHLhYZEtQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2018 15:00:52.8151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00a71eab-96ed-4024-40a4-08d5e3514516 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 1/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: mark Flash memory range as MMIO 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 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: 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 | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index 558b395dff4a..b3f428bb4284 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 ( - AllocateAddress, - EfiRuntimeServicesData, - EFI_SIZE_TO_PAGES (Length), - &BaseAddress + 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); @@ -1091,7 +1105,7 @@ FvbInitialize ( // InstallProtocolInterfaces (FvbDevice); - MarkMemoryRangeForRuntimeAccess (BaseAddress, Length); + MarkIoMemoryRangeForRuntimeAccess (BaseAddress, Length); // // Set several PCD values to point to flash -- 2.7.4