From nobody Sat Nov 2 10:33:13 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 1494454213786806.835931909508; Wed, 10 May 2017 15:10:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 12B5621A16E3D; Wed, 10 May 2017 15:09:54 -0700 (PDT) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on061f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4a::61f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DB8C021A16E33 for ; Wed, 10 May 2017 15:09:51 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11; Wed, 10 May 2017 22:09:50 +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=8jXJFNUtc8Sbd3Ccvk2AnbY5hOHb8g9LZneYWcqHf+c=; b=Je/rs1dSpRce3P/hHwcwaAXWftw6t9jM1xlsSnHch4bAqsYpuIj1q+Fku0Wzty5w7+kZiwzMv68FBE5qtDYDgsmrOKz0AwbdY0ntZOOhJhw0LOlWGtCaeb01mRH8sXejFy/lQnEfBIFRlwxXqHGojSLH0x5C9zpBUocb9DZCjO4= 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: Wed, 10 May 2017 18:09:19 -0400 Message-ID: <1494454162-9940-11-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494454162-9940-1-git-send-email-brijesh.singh@amd.com> References: <1494454162-9940-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR21CA0051.namprd21.prod.outlook.com (10.172.93.141) To CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6e556cb-6636-4291-2868-08d497f14794 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:CY1PR12MB0149; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 3:UUPtX7ZX6Y+i8cIGAiGnjQj9GQF2M+4zGKvIA4qwEKgdk7/bSbljl+LaMyiDiNj9Q59YsoMbneVtvOQUQ/t1ivqPacW/tpiL0B9Ie0/zaZvZRW/7YdqU3cbFeJIZ/aXel54Qb+gPsotY6tLajWqmQBrMKcrYUnVNFMC9ZEpiMZ2Av8acnmGi3ihdNldpiL3W+753RSmr8RQYVCDnvXStwSra2G1HPSu9Wc0QYBpvu/nYhqfzcQFiUa84CDI094woQ18V1WI8BM0Mw5ElXwlP5aJ7NZTSOAysBLEVbDGYjQjkdw8G/C6E3Enfba29eHtrmOyQqXMb6nxr74vikdn1hOijfc4ELbEU2vE6FvljfyQ=; 25:f7n9xObKSw5xwVSY+ocw6E2wJ4M/71vyGr0Hb78zVt8vNktO2PD9+HpFXX4q3QQidSnf4ewIeh5pykBE0SZSrYAcuB4aSbp896psikO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CpOQSTf/hZyhBhTVHgmAj2VqHBrIk66Ral2e4G2FKu5MFr0gGnIJgULZqSeV/8Vt26g9yMzGPdEfRPvGUYycexip3As8tyRY7sshpR77eifOG 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:CY1PR12MB0149; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0149; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 4:+w3zTzON+Tdh11+zU9cNNGcZIZ5t3N1ZRkvEOlh4oNlqdcxWiGcWgWkpKSWsSwswlvhsiDY1KRQ2T5HSl53a60fcwuIgZvY8H3tM0nzAvQdlT20we3hLPYBIZYI7QCXrz8Cn1TUkjcVx/0vJ3nZ+igc6vk8SPotspRCBy230LgNbpAHkB3t+TpTr6pW+VwyREymjJMK3p13tP3seXNAxUDePCIbBGpI54rcsllLPJWMiHZKgI9AlA4EyHen9R0b6nwS3XwhMKcFB9uAmniqbvRUtPC0FL7EmPkat8mLoocDK2SPLItelnQmM0T+qC6cfvqrw3ZLtpOWr2x1JuVzO19UIm+dGKHYrznxGX3qaw7lCoPUvoE8ulhzMABEEnjtrDh0Btn4Xr+tifkJGW1+e8LpbzLY2koZNrRmYEsSS5C13B0IQ4npa4M7ESrE33pIFgpuUeUUR9xeer0H5fETllYuZHpzB8MykGmjV0ry84m07clFq5KKTD61uUty5CgKGIP1iMokLYP9jsykylGj6WNomxVuU7+s7jgBZjJk92PXjv87lcp78s6B7LH6og1OnSDb0yOnBps1vLp/P4ZT7X1P3njLDoVyUaWlZvm3fcBm3S9PKYj2PMjJ2eiBkuiA9/CMfNwht/hGaGWZw2019kVHE77CyyRgJ88ve+30fvPeRb1R9wABhlM43ZuPmbGP1I9uOJmqQxiM1z0fM8+qK6SwUd5XOhcO1lGt5TE2m79Bhfyj5Yjx0W/wtUb0cIHldsSQ0j0bjntHKiS9IrShDHKmux9IC0N068cqBWMbI7bvKsuhsyItBKUbO5AVp2NZu2KBVvDh1XtMzhoMLCQUC9PtZfcjPuhZNrOLrfVvH+5sR/DAqzZarOyr2OpaemY1G X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6029001)(6009001)(39840400002)(39400400002)(39410400002)(39850400002)(50986999)(2950100002)(6666003)(6916009)(6486002)(76176999)(50466002)(33646002)(478600001)(86362001)(189998001)(48376002)(110136004)(8676002)(4326008)(2906002)(54906002)(38730400002)(53936002)(3846002)(6116002)(50226002)(25786009)(81166006)(5003940100001)(5660300001)(53416004)(36756003)(42186005)(66066001)(7736002)(305945005)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0149; H:brijesh-build-machine.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0149; 23:IljyKaVF8gNXoRoqe63MjbG6fomy0gKamZkJKPC1t?= =?us-ascii?Q?wroof6vJIJ3ChPxES2SqdGu9VxCuGXhF7itPP89vEBC2V3HU2kZ0RaWdyVB3?= =?us-ascii?Q?XukJKBxqa5kJgBDrlJiviosakJ/toZSVt0r1VWJ8jqJhGL9OJEyuj+h6Hoj+?= =?us-ascii?Q?HPYxxm7dRAeKuL9D42QscNw4TSDpsgAGvIcIXYCr0sOumoUVCDA0DYWvhsfE?= =?us-ascii?Q?cidEXQGVrN/cUTCXIfPNY8NXdQjGY2DFuctIYn9i2JBedZwQ64gEBidHMrgV?= =?us-ascii?Q?5HawAZhOP8aVJeOYVKN1Ae9VEAVZxUk8KVSU2WDzp77bShd9+C+2hPkkMlrZ?= =?us-ascii?Q?sfu29YkS0m13GDa1YkRkF63Zf9Ut6MGgFZ2ALaCRicGRYNwwxrmp+YKtr6H3?= =?us-ascii?Q?GEtcYnpEjsOuOputTnTzuQcUA6X0lbDxXjpv/B+nhF+7rQVDWDaUQkowmBRO?= =?us-ascii?Q?lSScH1dcuZ7k3zfDhZLqi99bTstdpgdyo51niwV84kPfUq2jBNf/rdxUN8W1?= =?us-ascii?Q?iD+aiCs6hegLSsofluaY4ThRq4ODL3JKPcCmhE0ONnezmWaiqA5zgunwuKLh?= =?us-ascii?Q?bQ88xkIxfB7Nue15oRcTi+V3FqWWKPYnq3UF4Q7f5WxuH62hv1G0esLI275a?= =?us-ascii?Q?XNXwyxpndYdFwep1qaSmcCYDWX/OjYstCq0Sl4Popsixbw2MupP9l97ts5T/?= =?us-ascii?Q?nbMXnd97KUfdPrlKVH0eTcpl29v26O/7mgFGRLRpPIZG392QBSX0Cy7E0rf/?= =?us-ascii?Q?iebITl/4CGj9pcQfzVFC87tJJ8mcl/mHruWEF4ftu9Csaa1u0WFHpl37dfGP?= =?us-ascii?Q?hqzcirEV6FRiL+kFvT6FnVD9aUrxFEs7oYWrKX2JHuke9PGG1YcUj6JxGQZi?= =?us-ascii?Q?voglRoX43IpeVKXDORkRgkymp6HMu/M6/d8K9zP+K2v1t7uxlZme/OTS7tle?= =?us-ascii?Q?2pa6C4MKO45B9ft8/mvonXB7Sl/vPrUonHuZS9H5L54zhIO4M8OX9+Zdh30o?= =?us-ascii?Q?GXpO4ls2Ea9O9oAF1CCJk0g?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 6:Ovejiy8sn+nLwxEufvcCyBNT7x1jdmgPJbHfEJRc742+0nUlwtM5+q3qXwJwy7i6Cv2j+9pa9qusH+lzSlX/mrrCOYmkNMpg2RWnxRl8I/Pq9gOI+OJWJdlu+MudZA3n0m1fF9VKQOZso29xM3257BnIqYgH42usDJB9uDbrKKlZ/dtSzGpr+oVSavTSdb9FA3OyK4dEh0N+oGgbjFDkla67fTBIHoaK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491aE9Zb5phR5m59GrMl6+TBHtWK7Xiu/IhDwoxhcIMOrwuM8e9EWGGXQbHL0JUdlE2qg159defsi42nhr7UKcSEgx+/3z8OY6sIyGbv8/X5/gBxvN2yGInhMRHESCZ6JzCWU8F4hqo//2IkxzsEVjcRp0fLcRBWGR0U+5W0nAALNkDave/uECmGVKYVxz1RypAsKfNBDu X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2017 22:09:50.3162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0149 Subject: [edk2] [RFC v4 10/13] 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 4f966a85088a..b97b475c7cad 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..1696512bccaf 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 ( + IN UINT32 NumPages, + OUT VOID **Buffer + ) +{ + // + // 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