From nobody Sun Dec 29 00:24:46 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495809922162635.520441804051; Fri, 26 May 2017 07:45:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 999B321C8D0C4; Fri, 26 May 2017 07:44:41 -0700 (PDT) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0608.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe42::608]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E98C821C8D0A2 for ; Fri, 26 May 2017 07:44:37 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 26 May 2017 14:44:36 +0000 X-Original-To: edk2-devel@lists.01.org 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; bh=9dnV1R1kNo4E6yB/pI6qM+bPQLJ+qfuSBdskyfDOwbg=; b=MX6Aycon87VkkGz7uAwdArs6wFY7eY6gUKH075byyikb0Y6R5psVBebBnY5eGBFJVO0mFbLcaiD/xNtJ+IV+u+fV0Eztu4qTFsvG7Mo93GQAQbFXIDuVTc9fEgvzEwjhiIHqYfTd6SVR6o+9f3Vrt7QDUyB4qkcGwTTbkoi2268= Authentication-Results: lists.01.org; dkim=none (message not signed) header.d=none;lists.01.org; dmarc=none action=none header.from=amd.com; From: Brijesh Singh To: Date: Fri, 26 May 2017 10:44:01 -0400 Message-ID: <1495809845-32472-14-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495809845-32472-1-git-send-email-brijesh.singh@amd.com> References: <1495809845-32472-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR16CA0024.namprd16.prod.outlook.com (10.172.173.34) To SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PR12MB0158: X-MS-Office365-Filtering-Correlation-Id: 4841b999-0541-43cc-b1c6-08d4a445bb2c X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:d2iNASiEfnvEkvoixK7KekKSeeNlntMMNiLNRSXLXyQErgRAWfjNllFPOC5Tvd1du28ihOGrNGnl9mKgyGQ0fO5giwzLPi3SF1paL1phb3ZoDHI/+jG1e5vG4FIengTfoUiBoWLzezlRs1WEYLumDdkifJatjGna91SzDjjKxp+iozl2E9IW9UMWptxF8SSY5pe+Z0ypJQml4oD+AtO+5FiG9ZAm4dnP+hOFChCXWB0eFlCsiLYJ7QSGiFjPma4vGqjKgp+onGhMVwKWsBq6Y/AWqt9g1B8zhav6z5FtrfgGzDEF0lvHafI5xLKmoWTY2ARP4r1F4ViDcOipbip40XfV6t0aFDQzi6mNlKb4Aps=; 25:149Y0Imrv5qPFXFMyr6wYRl8uBOFUlq7IemuNIYBgu+EyO4hIR+LbIqjm5Oi6/GoitfQzhwn7ng2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jKmGaPBK8z9XFrIEHughaGH33bEDEGv/Gb3zflzDtGrzeRyz+O7X3ZN7Xe8U/5/cyQBd5OTaXSDj0ed2KYTJheeT6mRRRPTTe5zbzF5o7VKFpAerFX63xMPTr0B5K1k0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 4:DzGN+xH5xFExsZOaJ77+7TIZBX6ILyDO1nwlmWALZ/j56NfPqR039KWtJE6CmUAeWNfPOoAnrkrgfMBiAAirZ+M/QwmPJkneARAgYfiEaZ6YBL47VjCfR2MeAIfg8d0ea0erDjnblo+spVk7koPzYj1+dtXr6/3AxzIX5I74oQmlW3IEB2hE05qwHjQep/ZZRURJbXTf9c4c9iWT+I0dJ/9D2pNE9l9giRzCvMXdc2a8n5eNJm5oLCbOybql7bQ6snAxSzHs6QvNPMhieAKDcsTr3tQ7Wi15NKpn8AVjW420CBGj1EPQrl8TnioCriWduGOHsHn24jS8c/iZ7xPK2FpSl8t50VZUFol6BMGHb1IEpIjuWp8fBN+7frWVVL/1gGfR2jtgjrJGdYPTSoOEsg277B6yx6BwfAHa26510WWKM19g7HCy9KQgNOdMolIQF9lttiPE/o9n7XRFfoDWkyRPT9+ClC7BFIzK4GUvPO2Mh87KX1U2WglQZ0FNOoio1RnOPHA2+Bhb/RXfvfRWGPikIwp6pdBIhpjg6l3ZHaAnpi+2ycpPW3O0f0AvmHKApZzqg4NkcrWstTaw5eMLYST1ifsWgcjg3HYfyDGStV7iILb90NM6gos0UbAtist7x4ycQBX+kdwuSeMO63XkeMa7NDRrtaV7m59mxRKrBnNT2JDsdgG4dfPHjr26Ok1SHBuEyEy0hXG+AgFu1aLKGgZbjWz6BowdpVXGuiimCh5Jz75mITbLBzX25/zEOV0wYvu+wxsK4Su6EFzWbmfySTGyj/NAomAM2p2nxsI+XRBUddm2JEuoVnwqBZt/o60nCwr4c+wVg5wF3DY5R7+ybgCrGP0/tpdQt1Ca1Z2olL8amDu2kUlOQ3PyOgkqWzDK X-Forefront-PRVS: 031996B7EF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(6029001)(39450400003)(39410400002)(39840400002)(39860400002)(39400400002)(39850400002)(2950100002)(6916009)(6666003)(38730400002)(110136004)(50226002)(76176999)(36756003)(81166006)(8676002)(53936002)(86362001)(478600001)(48376002)(54906002)(25786009)(5660300001)(50986999)(189998001)(5003940100001)(33646002)(305945005)(6486002)(2906002)(53416004)(47776003)(2351001)(42186005)(3846002)(6116002)(66066001)(4326008)(50466002)(7736002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; H:brijesh-build-machine.amd.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0158; 23:0ih6rDOmLN8Rb5aAJf7x5Ds2TZFBxmBK8vhaAJLw5?= =?us-ascii?Q?7Qjkv875q27TYErjXH/D1htj2ZTfWRp8+d/S4LFEL9OFfJlPSoGUWhu8Q4Jw?= =?us-ascii?Q?AeRMt6BsKW60I9jAkaF6RLjcDTNQousjzrNBKXRxFGMkgSBZ2w1s+69u05Ps?= =?us-ascii?Q?5mWEYZ2ZvdUGKHvsuc0rKpyG/0ly9D7dEc3DN7VcjwkVfvfX5zVGDhfjL4lU?= =?us-ascii?Q?16dSsOapQDSvzjDBHUJNDWdbynKXGrTVUMXAWjNaGT5XTg0VBLoHCFX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6ybs79nIx3ihiHyelsupMT4DLK?= =?us-ascii?Q?2l5b7rEnHttSb8=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 6:0sLdeRCFZAB2u2C4wHb65mzZlcRAk18a5flKGhpqgkI3v4WKZbFsQbTcgJ/R3aclYjSN56ynByQOV8pEevViNqxxgjlqBg/cLoOs83RyiZFL1o3ZgrZB3N9oS0qwTm6t14qjTm7e248SxNmC7FnpnH3MEUSLpzGcAMjmCk+wpl5iay2SRnYVQfpM1MjOUtTbogVVX7W3jCQT+dfDI5lGeWArJcY65ny4ctsbPcYAf+Zo7nTwfNxRFwwtxL8eNpR8D4c+npjWRmgmVZmsnS7IgObyEUk0EaSRf3RCPtZZNwtb4/Llq7HUqnIgDvvJtM3pw/7vrm9slAUskHvEViOpFCfNELOd+jfpsfkVFTAKXDPVsvQD7UzqaYOxLOtuLCYvqT/T7gBp1AIGosQoo0gcgKFwpm59Vg5I1VEsitOJpefmuBrhU0PUT20lvJrM1q05CnuPDBTru/wQVKMy0pi8hA2t6wB0WuDno1hjdn6N5cvyoRqdk+Cr0aBx96Zr1tXtImRv71z7pXwR9+IMltdqBjVs2GepX5/6c/QpVj4y/3A=; 5:teujGynT7+NmKb4PrXrWHpWLlhmCTcyXTtdDblcgXpuBXeZhiex7Txm5hHs9nVL9epcve6qzH1Iqh3Z9faSdzc/c8wDkuaokENgYNZvbId2X1oC8qOMVVi6e+t17mGY+Yw4wdlxw/pfSSLN2Y3BssQ==; 24:W4wjLpfOJ5KHCyGEEjznsr6hKvJomO9bV7ZrGLov8YhvcakaIwPINxbUQmfIdMtkVDlharJEdbPxBJE1TWaY83J5saTyQjon+HJHGt41kwo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 7:Z6eERau9CdG64gshcgpqbgikePq9GHZ4u1MYW6kjNiX5QLXcqnJgZT9FlRlQny4EewwqSMWfvh9OnsrTTQwjDZd1V4OrwZXJfwj00K/TsyZYCejdMe6TCBj6hRHFMCSgAmhfmshDG9AKb/8zdoaWji75AJbILEBsYLxeVzKVSCpBhz5a88TY52hGGAZzoVdinQgrMbHjYI7gW0FSPk29+FxAQ12Ngtb+GrbhYGXCTLjluTQT9e7MmjnOBGpqfVs3xmNEgf7ISx9SIhdyN+rlexZNyLjElQt+bmEKcn9h9OH18h/B3lDODv69w+aQX8RKerscX9ftsq9JPRoK9rzFxg==; 20:HT/k6BZHp6iMDBnAXG+i1LTk6gVDsgBia9sIgq7laz2MR5g/3DDMPvxcQFxHF4tCBdJ3d10RkZD2jsUsB3C0vhlhCrs1r/O6XvwPpEMvqq7d1D5W2eNYouIZqIreYIiq4hTwi+XG/KhgGVe+x2c0yoR4CaNGlY87CBZi4pDsKccEN4tNEW0Xg4Ir2LWO+7gMOVQZUYesXzUKFORHc87DO4NTWsYyKtLqdHQnFJwT3Jbuf1ziWYR8jaSF/yHTx24b X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2017 14:44:36.1275 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 Subject: [edk2] [PATCH v6 13/17] OvmfPkg/QemuFwCfgLib: Implement SEV internal functions for PEI phase X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas.Lendacky@amd.com, leo.duran@amd.com, Laszlo Ersek , Jordan Justen Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Jordan Justen Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf | 1 + OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 72 +++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf b/OvmfPkg/Lib= rary/QemuFwCfgLib/QemuFwCfgPeiLib.inf index 47e23b97eccf..7e51c3f160ac 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf @@ -47,4 +47,5 @@ [LibraryClasses] DebugLib IoLib MemoryAllocationLib + MemEncryptSevLib =20 diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c b/OvmfPkg/Library/= QemuFwCfgLib/QemuFwCfgPei.c index ac05f4c347f3..40f89c3b53e2 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c @@ -4,6 +4,7 @@ =20 Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, Advanced Micro Devices. All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -14,8 +15,10 @@ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ =20 +#include #include #include +#include =20 #include "QemuFwCfgLibInternal.h" =20 @@ -76,8 +79,18 @@ QemuFwCfgInitialize ( if ((Revision & FW_CFG_F_DMA) =3D=3D 0) { DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n")); } else { - mQemuFwCfgDmaSupported =3D TRUE; - DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); + // + // If SEV is enabled then we do not support DMA operations in PEI phas= e. + // This is mainly because DMA in SEV guest requires using bounce buffer + // (which need to allocate dynamic memory and allocating a PAGE size'd + // buffer can be challenge in PEI phase) + // + if (InternalQemuFwCfgSevIsEnabled ()) { + DEBUG ((DEBUG_INFO, "SEV: QemuFwCfg fallback to IO Port interface.\n= ")); + } else { + mQemuFwCfgDmaSupported =3D TRUE; + DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); + } } return RETURN_SUCCESS; } @@ -114,3 +127,58 @@ InternalQemuFwCfgDmaIsAvailable ( { return mQemuFwCfgDmaSupported; } + +/** + + Returns a boolean indicating whether SEV is enabled + + @retval TRUE SEV is enabled + @retval FALSE SEV is disabled +**/ +BOOLEAN +InternalQemuFwCfgSevIsEnabled ( + VOID + ) +{ + return MemEncryptSevIsEnabled (); +} + +/** + Allocate a bounce buffer for SEV DMA. + + @param[in] NumPage Number of pages. + @param[out] Buffer Allocated DMA Buffer pointer + +**/ +VOID +InternalQemuFwCfgSevDmaAllocateBuffer ( + OUT VOID **Buffer, + IN UINT32 NumPages + ) +{ + // + // We should never reach here + // + ASSERT (FALSE); + CpuDeadLoop (); +} + +/** + Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer + + @param[in] NumPage Number of pages. + @param[in] Buffer DMA Buffer pointer + +**/ +VOID +InternalQemuFwCfgSevDmaFreeBuffer ( + IN VOID *Buffer, + IN UINT32 NumPages + ) +{ + // + // We should never reach here + // + ASSERT (FALSE); + CpuDeadLoop (); +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel