From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe46::62a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E0C9321969FA3 for ; Mon, 22 May 2017 08:23:45 -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; bh=9dnV1R1kNo4E6yB/pI6qM+bPQLJ+qfuSBdskyfDOwbg=; b=dwZMuk3hHO2da6KWNFdPx17ePy0HeyR67AZe7O/Q4XwqsyYWm8ghMb79mQuDWKe48B/TCB0gMzZqJATV1NQNKSf091Lm5Tlmd/OiRQjPq0mWQwRjC4XR66p7H2NvLHjyeE/93iJdFPXAl01o2j9ToMpBAbVslJSei3Kr/6sL+Ks= Authentication-Results: lists.01.org; dkim=none (message not signed) header.d=none;lists.01.org; dmarc=none action=none header.from=amd.com; Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Mon, 22 May 2017 15:23:44 +0000 From: Brijesh Singh To: , , CC: , , Brijesh Singh Date: Mon, 22 May 2017 11:23:09 -0400 Message-ID: <1495466592-21641-12-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495466592-21641-1-git-send-email-brijesh.singh@amd.com> References: <1495466592-21641-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR17CA0030.namprd17.prod.outlook.com (2603:10b6:404:123::16) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-MS-Office365-Filtering-Correlation-Id: 3bab3162-96f5-472b-efd7-08d4a1268917 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:hy17kzfIwVU2THJq9BEFebx3bCaZ1Tw2pZuWVudMb83ZONUzt5VOlJgfD4CwapaMzJtq8mIa6WIX4r13dzAMMqGnSSoT9mSKDfDnpi3Ay86hBOSCaQD8A//l7xzYRXZYKt8WNcITAqTcWc/BNmxHy2TPzf9E3gP+x73lYYSjHdcOIemnqSauM1z5D+rCcdtfycohj8MRsR5omb9eGfWRNCygw4uJ5zexc2q5giUdDL9ObEzZKZ8xJIwT41aXgnl65OFu4vozKR4cMVkzd1YR2ZzUHzbu1Sht7MfnPhSfaT3b9xPnNfD4W1RkzTx52xdXsE5NRUPAOwFhVavrn2onihjh7/Td31sFfMUwZMcoNOo=; 25:sE7+J2aQZH5TQut9EoMdXbSUgcsXsn0Ru25DQ7zIsHZPFVs+/Iw9+hHovjwrRuhexx4q50knIz17dtBzygQbqpCsULNJ+ugorkF2oz7ot80Dkw8ZJzyfQjJlUgL5LpHcks8jT1AXGsnWc5TjubDe6BCUey/Gbg5oy1PzyqsRLUY3YW9qp2EklWNDfEqA8+UHdnIfCTecAQHQhaQYM2jrOyxm6A9FyH407PNbe+WLhtyABYataZtw4DbdMys91SyT6iSBXkFOWDvY6JDQVDxUkBuH3rYvh/0HpekHLKo56PZEBJDeTqiYtECc5FTqx9QmaPLgC/nsYFzyr42qmAG+PgiRHeKFLuTf0wNA3EYIUFrFCYxw5g4OXMLu+krA3gxLW4Eoqrls6Na1y6i7EjzPTeaO2JsaVWbnrApKg9HGrTwmHYMNbIEnriuku62M1KUbOI46sNpWyUsq5p7zWOSvb9xPBXBJNFBimqtvPw6/GGk= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 31:0BJbC/vQBxXcKbUZmC5P+x8PPANgmtfFxGSI/WD+a/ciw9X3xpp7Kr5fQbo2DAMJG1GU/uguplQfSdB+u5bF8gOAGxWhkrYsnNgJmdWiUFDvOYW/+mDPisYgjM4EZDERqGGelQueYfgPFodT8NZKnyIxu2rhTt6YyGUy/JBQqUlHc2He8ZXnBkcaVipCUxfxdmh4aYDoby5P9Jb1XInlBRApZoejrLwoeymJhOgvL8c=; 20:xP1uE0OKDb0YjXzv+V4gABayaQ2CsO3EMx18m3iJYcLNdVuhWw1PhD9zjgoNiddDNbxO0Kayds1eCGlKX+olsiU1zPxgczuvi2HQUNTPjKtRpT8Hultikw2vcuXUoFEng5JGEXBIBUKTocJZw6KfKnbbKeX/SkUy9gkX2YmurrERFXx686HsJkhUAihr6USHZundRK3mFEPBlqtc7KQnNWbidyutQ9pkIbBZJgeDxhkym6e7iGoouBClKshhCjEsj9W4iJB1n09ZH96unqmmk0s52nbmr9ptQLQOvR4JUp4wVXmWy8bSqBPsWFwRuw6thpYxIPVKm22YjWZC30MAJ5RgzWjMD9p5mxH3j8F8IG/GAnCCiSrd6YsYXCt8teONumkVeqHWMgRXWpcrdSFrXhm/KSlof5/v5EU4w9Br4Syids15+I58pE/jyqL1fWU2jO8x8NBQ37iujWj91GZ2UAGDAtI1bdz4rgD+4Ta5NJM/v4LcOr2eZNsQYGTX/IfW 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)(20161123558100)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 4:QqPulJmPSg5K4dYSirtTAWUWk0Kw3+Huo1CqCG73pLXj51xM1xU2tzFQbS/0U/BZz+T6RRgSnYSoAMXWIPts0r7QldbLp3+sWb4IPq/xhoT4iHBkF84gtEd4oKTwTn3FIgtr3t1O9V+BCFB+aEYSU+uQvu9K0lBwrQK8C0U77hegvcdn5lo5yt6NQSyJkLlOzY7fGqNuo1Sm6UflhC+9W5h2iHHA95ac9baFzC7RriSnl61i4HrlfMdRcigznoVw/Dd9lhEbAQXXww4/XjFIG3cNuP53TMF8L8/BP7BXZQ+osHHDpKSOF1CjSEcuKf81lrbSRf+fKVJ0fMKKAiwU7cYwnfhxSdpKKn498ygW/xN3rZd5GACokxVxwelLfj0yIXPfaJkKIhHh0mocfdPjTaF24/ea6YFQOGkhW5ht2KA7hY3QFQPhSH29mPtMZDv6/8hcC0w83e42idydUzzINtIeYmTWGLDJMcXGGTIfjfNM7iVlouGUp9uIeCRfM4jSposGD2392G7QiVjTulSqtfmy+Oal4YXtWf6MxbkZyzJhGdX53076IRj66ygfKcfsjoVAlDx+RkRHK32gyEN7XvB7D0xz5c/21wU/F44bHMo6VM/XmPBPGQdjpepWfI9JrzwNrMvmZ/YYr+RhMzYgXdCRM/6DjK+RNGwnekxj2NHsKnWMZ8clRlLC44TC3qNOjJUSRaI8BACbml0JWB/cr9hz317sITVG9Sb6JJkBHD2BeXtgabMUz9pHezXGFSTL4BX4faoMGFORKus7MCYdEOrf/tm2PQJCz/938Ny+e/Q8nyYdHZNrNsSGpM6+m5xpWtdMLBoYmuMZ/QHFqlrR2Hlnety5VmjKHgP2ffuqgt6HCWyGkvB7+WJ7Z8U7T+co X-Forefront-PRVS: 03152A99FF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39860400002)(39850400002)(39450400003)(39410400002)(39400400002)(6486002)(5003940100001)(54906002)(6666003)(2950100002)(36756003)(53416004)(42186005)(86362001)(47776003)(2201001)(66066001)(2906002)(5660300001)(305945005)(7736002)(50226002)(38730400002)(3846002)(6116002)(189998001)(8676002)(76176999)(81166006)(53936002)(50986999)(33646002)(4326008)(478600001)(48376002)(50466002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:uW7/lstp0CfFS+ol7Gsp5x19pN2tCHtO96W7M0G4x?= =?us-ascii?Q?Ijj40yyHqa+tm1tLLLyUjnj2IsgWEgUrzLuYT2IWpFsBpKDiO9er3lF6rVjf?= =?us-ascii?Q?eKgb2rWQecZCgSD6cIfNijhYHR7bmArYti4Hm8IsmjpoLwmMKJSVxQjxpf/g?= =?us-ascii?Q?t/xHyQtuykXn4n4On4hdlflUOcYy3OyMv2EQOy52cLeKIrfmXZgXqNpBOatQ?= =?us-ascii?Q?n/6rBFWISn2OxElH6mlnnO1DdPIuLtCsZG7OchTWCn9w2ARspn1JeCXPdqnT?= =?us-ascii?Q?CMj1p6F6oSl/ksC6X5/dSSfMHfNxu6jLLLoM93ynF5kho0i8vAYFfMs9Svnr?= =?us-ascii?Q?Hd6lAp8B9eXPJWVnys8MDceT1IfiDuA+kuIZ2h7myLA+P+fG9qU0OsTG1U7g?= =?us-ascii?Q?EfcTu4rWN+BPKuAG/6rLQ76SxtDVDMztwJbRUd/UpelMBoetEZdkctsx2LiY?= =?us-ascii?Q?2q0oN0FFM9yEj7ubIuo5B0DnAAqwsIIPw6lD1OcJJHEMAQxu6u7Xupo0afCK?= =?us-ascii?Q?kTAtWJUod0AW+ibgC2E5X8qni1o+DwYWQ1a7J2z8GpFBaiJOlCFLDR/opPqI?= =?us-ascii?Q?g78DWI4CePWmGmwFrviUWA2/Y3JvrwvtaZLTYMFSSgjzISY4DZqq1FmLdASW?= =?us-ascii?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d21B5rZx7mlDTCJBE=; 5:UjJny1EFv1WYxbfCOZQ9CaqQURM6GP11ZID82xAfyNvEYgT1g9UES6q6GSMp5i+4BHGzI/33aG81fdD+Y3IGZdMVFv+AQwQJXJdh9ene/lkn09Svs1lRNWQHtTXSm2eM+uTRWdgxYFk5rzdzDrBLFw==; 24:3hkx1z2RZapQ4mIC+aSLCdc/VG1AilWbJM13Y1G1jYyobiVDBSPjJjH0Fy6fe0NgZeSKkmeY/wS4TLYm09XHMVBrvRn6xYufKyXQOWvQkSo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 7:j2sG6hLN/RVpt2SNKHAwhidJ6oe7YC8NtbBrcUbBgP7C3LxfFVJ8izKYLjpL6Nr8pBsfCoTOcX2FXUTgH9ZGK/xzq3EoLKdJvIemDohJvSWBASa9JSWvR9pn+uIEwzzAOh/ea65rsT4n6GmKY71yN78DICcJGaY9fato360ZuAc3SUUH76Et3ZrLlWjggz20bJddj66NPjU+TcH96EvpvRCH2q94Gd2ioHRoC0Jd8N5djv6QO1KNmw7tUUJyWvYU+zI1aRoIb9vCvubLl6NQA3+cwsENrtdq5NOkN7UpnYs50zV2GA0T9EBSCPUGtACcLKe53WhX6hZqoK1rdSZetg==; 20:FFc6J8uG3kQnmHS5Ln5eTuoSmeYtPEr+hy9wgTgtT7RFtdr3WElJfUYlXtr/TK0+XIAvSxfVoYWm2jQWXGdifNPAChYU6JC7EyKEEG+vB9PkBeMeM9CHFhPnExPl1v2QC11L56J7bKIRbUtg2Ot3pqxrwJJOPUgfxd4fijvPHvISainMMJRwl7tZwpDJbQtPJ45AOkBEW8kwjUgRL8qcdSa/mcH6uyJh/53afLZLvDjF5SihPtU86cxAnQjsIVtJ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2017 15:23:44.0709 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [PATCH v5 11/14] 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: , X-List-Received-Date: Mon, 22 May 2017 15:23:46 -0000 Content-Type: text/plain 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/Library/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 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 @@ Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, Advanced Micro Devices. All rights reserved.
This program and the accompanying materials are licensed and made available 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. **/ +#include #include #include +#include #include "QemuFwCfgLibInternal.h" @@ -76,8 +79,18 @@ QemuFwCfgInitialize ( if ((Revision & FW_CFG_F_DMA) == 0) { DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n")); } else { - mQemuFwCfgDmaSupported = TRUE; - DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); + // + // If SEV is enabled then we do not support DMA operations in PEI phase. + // 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 = 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 (); +} -- 2.7.4