From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0066.outbound.protection.outlook.com [104.47.32.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 90C0821A07AA1 for ; Thu, 22 Jun 2017 13:37:05 -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=W4IC+zhcTV4mMrz64jftbjfXSFvs/ZXzOqFIaLiO5do=; b=e2DWAwqVBasEzJ1pVpQqFCoPt5+M9Gz/s7oCelrCvTXFx2NWFRehxZzYN3gq6f1hIZD3Xr0dGipIHdt2sK7OMAGVlx4o7QlSFiEw8pRkvjczZPK8RQpJt2eQFIRlXAs/E7Z3aR6JsRfj2YA+djqGtgiKoKByGv31XbG95XKqWRk= 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 BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1199.15; Thu, 22 Jun 2017 20:38:28 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Brijesh Singh , Jordan Justen , Laszlo Ersek , Leo Duran , Jiewen Yao Date: Thu, 22 Jun 2017 16:37:37 -0400 Message-Id: <1498163868-30191-7-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498163868-30191-1-git-send-email-brijesh.singh@amd.com> References: <1498163868-30191-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CO1PR15CA0051.namprd15.prod.outlook.com (10.175.176.19) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96ee9ea9-85ab-4607-bb4a-08d4b9aea3c2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 3:e7162netzhF9FV5j88gdE7GNl2fQIh89wiQITCGEIpG1/McnWca1rf12UYQDFc++RvcHR9Io/oiIMLBQ7UbUMBdcT2hy5qNYwZNtqIYLcrTRi+XyXY/oPnDBWQIvAnlrOph93CYy01jAtmIoPpXvHHYY8EY+3BaVr8KKlkV2allPhX2JE7pX+ApGAkwt8QAAVegVYY/i3luRh1xTRztGzFkzwzMHHsUHHMYLcFDiLqbM6lHO/s4YfmTaPKjXGqwOQVLbXHe+dqncCcOwrERYOqpcalCE1qnVuSL7w5+0eSvtksCAS2gZ+zeoPr8AF3Ue+V090bfxAo6Jx2pAvapsdS/yvYMBIHc+8kXhb1ido5E=; 25:S+RXyg+TPOLJhp2C6brp5Y/vWgg1vLPlGHvWhV7zDtxtan5hNfHpIo8T1wHbE/skLAelIxask1moKP8oFHY2bQgJ+8KzSAU8N1C8/iINg8ms3Ot2/JrUrSC7/pe1kChDu8oGf4/HnO8J5OYWjuZLPqOeRXiGddx0yEpbQkpUmjteuUh3FpKeVK/Rf+B+QDCvbnPXjMeFmaqgHTxZuPRuMmRgK6h3jYb3ZkoPirHj9Qemlfcnf//fTs9KOR9uprmf3o0UBpLAp7valkaUeOOienQpbpaUhANNPaJTRQH/kSj1rOSVh+5hYrXu6vA7p/0UYYDV9VulLhEcX44Z6LrwqvlJeFIBeHe4kJD6OLZiNvmvZ7OP4+XOnInVL+5A7mg148887T9p5dfD3JIvmqb4ZHHk85X9hNXFRBzG0bDxusegO50zCaURqa9pHG3uGf71dIpHyGpeXTnBsZgFed1+ygyK1goXWYApfbNIhED1U6Q= X-MS-TrafficTypeDiagnostic: BY2PR12MB0145: X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 31:qK1M7bOAHY2JAZTLpOgfpRewZXgPeS13RzQ3w2xBnoyqWqc4+3WMZZkc+WPCPY4M16bm2MwbBNviYjhAO945xgQ6ZpUpNJzslXqS/tvKN/0+BxRHSMwJLU8A1aJZ2eEVc/WeT4cTHlr3LB4KEDO+N0IUaA++VwMzUKOgQrnzRQa+eSnkuxiZXSiCMNdSuKvRMVG4scnmwd3sNpgaMql4qwNvL+VAHej6co3/vbrSKgk=; 20:p37tDQdMY7Go39NLlBF+ZrnuhEIMKrXK6FMnzPMQPKR1Cxne0zlnsQxn7AfxLL70BJM26VBx18CbOfQ008nA3zGezfaKhlUtIeaTKTn9S8mj5If7mtLvYPJ6kis1q9VKFISFC92bFSWuT3XFL1peuQ9vd0RGCVv8RcbITofdHHe0Y0EFZvdZSCBJl9LSgle6u2EMb7NLNrPu3Q38yu0bSAmLs8X91voQYBmxqagQsysBjzb9In1NVDhc6rofB3eLK1Ym71bNQPjfkgF5DiLGSY1ZFPkGXpYlMYeJhnz5DARTkHYSDIPDKAFXU/GfShS+BBFwREXw3Ieg8w5wfkTcDWMjpkG7aheKOZG9mneFkhWc5+76e6YDtagvm+PcU7+8+CbfiIyuxjF/WOd8MNch8rCD9kxQb6bpWgAQ5M8OJrcnw/EwRwA/uIQGLIhGryRBXMu5RWqon6xxKinDHZo4eQZgMzIS7p1piqnz0ZlkN6GozNVvv5BHlmEOBQik2vgx X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123558100)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR12MB0145; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0145; 4:gmnu1KgXob8IM5mZ2AMmAxiLETfoeIG/aSSjHHmlXA?= =?us-ascii?Q?qUWByJ7OeVF7j0GpHFUzTWMDJlKfAopD26YzcMNE44brag11rkPweKfcV7oB?= =?us-ascii?Q?enx0CrMSeE0+DVh7+c1ivR5EmS8c1ZPAMtuSJW7/PWASZmWAe9sG9onTQDRQ?= =?us-ascii?Q?ICsjhhmLBUAkH1UoNL/EKbILga/LjlKY58gsnNIJSKTAMnsJh8CQBMFPW5Rd?= =?us-ascii?Q?4e3rxo6+CZsva/PEO4yg4CbBomefsBqN4O6KiBomELmjyEPB9sh4kIFFnFsJ?= =?us-ascii?Q?OEBN5gZd3UnMHCD1NFxdtKMLPp9iYdbDGemjagvzsMVZW2NpBy2E3q4FaUpC?= =?us-ascii?Q?enSYQFIMy7CPutKK1+Oq8igo13+RfaFss7x3W5QRpKg9BI7VduZTkQRF/54e?= =?us-ascii?Q?Gwvq/S+AAl7+QJDl4O+hyrJ9X0X0DKdy7Y3dt3vtx2XPto35mUpVM7evY325?= =?us-ascii?Q?kfy9LqKLz0W7b1aDxxxBFiuDPUtMRPjBn5FsWDM6/nlZ0yAUgsZeppw0TKAs?= =?us-ascii?Q?9av961IXijJNhZStfpOjttgfJZ3xiltPMQ7KL69f2DeGFmZ9/MViN5xymT93?= =?us-ascii?Q?l+UJSsxWp8UmeXA97mhOCUaVYmhgB6QKFOmlBJiNWFV5xqxW15rR6V6R0D+K?= =?us-ascii?Q?A6RgugT5TRYSHG6AFx0iFC+Z5ta/cym6ktV9D6SL9Pnr6sHTs5mKhUB0jKn4?= =?us-ascii?Q?227+XX9A2jMuW1JHveM4Z5DHRojHRK02yUrBjchAP+YLp9pXbDcCZtE260B4?= =?us-ascii?Q?o2axacRD4Nz5rBPP7fjicXoOgdq2xCNagQyeEzsTur/jRw4jaLHYdWpd3MNb?= =?us-ascii?Q?sC3J0xEtRF1r61v/DFTGRVgE0vwNUH43bgcvQhlhGKwUFF7GeReEPC3a6dNp?= =?us-ascii?Q?sl3uaFlS8N51XMQGrWOtaay1geblfQuqjSgUBWXi08bWed857bROYrIz7hFA?= =?us-ascii?Q?PGZ4SxR4KbC187cAcrDIWCDUgkYgvdZVOR9CjMKdR3hlq7eYRnUHnn3p+fEo?= =?us-ascii?Q?uZpIM/1oKKZLuO24L4JP+5VN4pRhN0JSjKjvQatUAmTPKFRT+YVrId+Eiij+?= =?us-ascii?Q?22T96+EdfGAzMmEqLW2xpU0U/Jfo2ePxH5++ej1ELXE1YZ1BFCXwYLL7/9yP?= =?us-ascii?Q?ULX7L9opTyQwwSh2b2FhQJhHnFFWm+Q8t05H+KsobQbbgf5LYAg7Bc5GRv7s?= =?us-ascii?Q?mt5JbR8S5AJQ/Mrnm15FYPoGERlJXyma3wZxSabOZaVn+LOt5igQAJ1xMVi3?= =?us-ascii?Q?4ewQUHSSMVsFqOfg0=3D?= X-Forefront-PRVS: 03468CBA43 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39840400002)(39850400002)(39860400002)(39410400002)(39400400002)(25786009)(189998001)(50226002)(76176999)(50986999)(2351001)(2361001)(7736002)(33646002)(2950100002)(6916009)(6666003)(6486002)(4326008)(53936002)(2906002)(110136004)(15188155005)(5003940100001)(16799955002)(8676002)(81166006)(38730400002)(478600001)(53376002)(966005)(36756003)(6306002)(305945005)(54906002)(47776003)(3846002)(66066001)(50466002)(48376002)(6116002)(86362001)(53416004)(5660300001)(42186005)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0145; H:brijesh-build-machine.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0145; 23:d4aKztm7KJUa9IrYQKX0yeqFIsRNdseZsmWB/stxy?= =?us-ascii?Q?fBglnkhCbnaiDzYtHHEXN2rD7wVE74bT/GmH5yHdRkIvbRTT4JN4mZBRI1qF?= =?us-ascii?Q?MR8zD2+jq7dc8WiKW+G/DVWsT/eJRjLFdGqHxjyL7UFmj87K+QBkTMxDVzdD?= =?us-ascii?Q?iLgmJorQyFB0ubj7v7NiGK6a9re5o/R/F1Lpjk9R3EgfpJGiFgJXYdOfbdPO?= =?us-ascii?Q?i8hnw7bRs10TmJfKW8LwdY7Xm1xdzbXzlT2H1V1Ro0ry1k5a4mRA+UZHsZBp?= =?us-ascii?Q?S3WLTrf/ajQzTOa5TuKLE6ZfS4pDFC1tbHmg8g+Nsflpwad7TQZE2E1O190Y?= =?us-ascii?Q?EGOldoRRIZfEllBrNLqcRWN/ifr7yV/0SMl/DwjuxezSACuITnGTiV1Jzbak?= =?us-ascii?Q?cfi9NixeVv84mPFIxa6W/RiXakOmF0rf9bnsS8m8DGW2lIO/hTZdAldrG+cF?= =?us-ascii?Q?mYVToeCgAfKMSNJilyNqYsJTUW+Vfd3IFNsGNguScco8ku4cvVB/8B5YwKmL?= =?us-ascii?Q?K8Y4hpKX0VNBdVVgK5nmwQz5toUpmCMM/iXVB7gr9dYseYjTTaOyQUo21NdP?= =?us-ascii?Q?whwAdFC9JS/WsAT0jHRvKSjO4q+xkKAsQgEm9iQfV00F97uZAPR0JW00VB8h?= =?us-ascii?Q?0NIzKKMaVHxVm94NdCuHeoGLb4iC9gxl4aCMZ9YW1nRrqmdazPcFXRUS+7Tt?= =?us-ascii?Q?sXJs1e/2q1tUEq2DIC8ub2cAUv8/8sH9Sd8F3/2RbmIc8MGc3PhtOpimQDto?= =?us-ascii?Q?d8P4RZ2hTvA9AtLBwduYEJF2pRQO3WPcNTlUBoeJVKbg4PpOW8e6JPY7PQRw?= =?us-ascii?Q?NMAHS8D4mU7jxfko598MZfvKy1QBsrcFzfdHQmCCNkcHn/c90xNjGA8jdUb0?= =?us-ascii?Q?++Af2T8Jjwu7qt52jHpu65IglmElVzVkE7F9EthK8GxEFXGV03iGwSMaXApj?= =?us-ascii?Q?yzYmOWkFWHaHxTKS1VBzCzGORdZmukYvKt72pFxR7FuCZ136RYn3P/YZsU42?= =?us-ascii?Q?1v2pPGnpA/hqLrNSVGRvcygAoSEnozekHUu+HYBDY+IkW4t5Bt07oIQWnl3Q?= =?us-ascii?Q?evHtZodMmfDDGT5WbC6GqxfXyxfX2RDPNOL3JK3CoQC8HY4jAOPhRgPAJhgd?= =?us-ascii?Q?D2OWEZWCA/IlcLEkmqcZYBPdKoOeOKx1j0c/sfM+8O7KjDTieBOE55CQuCBC?= =?us-ascii?Q?QTDumNIh6vqihAhYoVlgW+UV9+0hBIoJQyvAZ5+7CppyDXkAKqGMelWiA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0145; 6:HPC54khuNz/mKzDSyOobJgjfJnzLy+8eNNyIMY/P7Z?= =?us-ascii?Q?w1MtX4BuX0bY8TZghmmwVjV8FHSR+rtutz9sdTXJqFJteAedQgRvj0+N0n/0?= =?us-ascii?Q?ARExzQWGQIPsGHj8U02wu97CMgf0Q9PaoqGPCQ72glMsHDUVlT1dOwkaQbR5?= =?us-ascii?Q?x291GM1RQeEg847zJaL3dIGO4dD8HilPw6zJD71K3firVfs30ch3ZrOmrpxY?= =?us-ascii?Q?2uK+466owPmAqn4o0EY566AuyMaXvSTrBFmzfJYhZKaqa6Q5OkWlaudAXebY?= =?us-ascii?Q?FZdXlAdQvWLxL8ll+AzFEEPj1IEt5TKEvgeOuRa23Ov1xqqchVoFkik6BGqI?= =?us-ascii?Q?X4teYoVgzR8OmWywK1g2BXk+d2N4hH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0ZCwjf3vaiX+YlnopAU0c/7cPSSn2Ed7/RQgZx8PvgtkiEX1Fxd9ZFz5XlppFOTrnOsekGZ9got5hwsPHd0C+utN57rcjjpKCl+4amxRkmgA3g6nNU29CoKE01KnBuRAPFAhjY8H/J/uO8djeWN0nGAeOOGr/s5VoxOB/Wv8oiJa78J74chj0mks2q8PHX92HMhgN87mNygn8aF6Y94tc= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 20:Rh5GHIPrJHKx92NRzXhluR7LMQK21Z44QWFWlhf1gMAyu9HiRarTDI9EW+nal28X6n3X5ELCaDGRsPuZNgLvMhBpfnKJiR2SJHJgD+FR0wSmjXZkq4DezqDzPPR0IH1jNPux6/yvOG6mqtyerYXec2ik+DS0rcNb1D4K7z71MBeiTl6FqVb1Rs3gyaaVw1Afn5qZKXl5XZmqlgKh0OqTbMU1atd5pXptILwxg4xa/fXObamTjgqgMWRns1jnW+nr X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2017 20:38:28.2259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Subject: [PATCH v7 06/17] OvmfPkg: Add AmdSevDxe driver 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: Thu, 22 Jun 2017 20:37:06 -0000 Content-Type: text/plain When SEV is enabled, the MMIO memory range must be mapped as unencrypted (i.e C-bit cleared). We need to clear the C-bit for MMIO GCD entries in order to cover the ranges that were added during the PEI phase (through memory resource descriptor HOBs). Additionally, the NonExistent ranges are processed in order to cover, in advance, MMIO ranges added later in the DXE phase by various device drivers, via the appropriate DXE memory space services. The approach is not transparent for later addition of system memory ranges to the GCD memory space map. (Such ranges should be encrypted.) OVMF does not do such a thing at the moment, so this approach should be OK. The driver is being added to the APRIORI DXE file so that, we clear the C-bit from MMIO regions before any driver accesses it. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Leo Duran Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Suggested-by: Jiewen Yao Signed-off-by: Brijesh Singh Reviewed-by: Jiewen Yao Reviewed-by: Laszlo Ersek --- OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.fdf | 2 + OvmfPkg/OvmfPkgX64.fdf | 2 + OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 43 +++++++++++ OvmfPkg/AmdSevDxe/AmdSevDxe.c | 75 ++++++++++++++++++++ 6 files changed, 124 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index dfc2534fc998..8dd6179893a9 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -824,6 +824,7 @@ [Components.X64] !endif OvmfPkg/PlatformDxe/Platform.inf + OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) == TRUE OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 60e42794483b..6324941ca2ab 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -822,6 +822,7 @@ [Components] !endif OvmfPkg/PlatformDxe/Platform.inf + OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) == TRUE OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index 5233314139bc..12871860d001 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -190,6 +190,7 @@ [FV.DXEFV] APRIORI DXE { INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) == FALSE INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf !endif @@ -351,6 +352,7 @@ [FV.DXEFV] INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf +INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) == TRUE INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 36150101e784..ae6e66a1c08d 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -190,6 +190,7 @@ [FV.DXEFV] APRIORI DXE { INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) == FALSE INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf !endif @@ -351,6 +352,7 @@ [FV.DXEFV] INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf INF OvmfPkg/PlatformDxe/Platform.inf +INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf !if $(SMM_REQUIRE) == TRUE INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf new file mode 100644 index 000000000000..41635a57a454 --- /dev/null +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -0,0 +1,43 @@ +#/** @file +# +# Driver clears the encryption attribute from MMIO regions when SEV is enabled +# +# Copyright (c) 2017, AMD Inc. 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 distribution. The full text of the license may +# be found at http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 1.25 + BASE_NAME = AmdSevDxe + FILE_GUID = 2ec9da37-ee35-4de9-86c5-6d9a81dc38a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = AmdSevDxeEntryPoint + +[Sources] + AmdSevDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + DxeServicesTableLib + DebugLib + MemEncryptSevLib + +[Depex] + TRUE diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c new file mode 100644 index 000000000000..e472096320ea --- /dev/null +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -0,0 +1,75 @@ +/** @file + + AMD Sev Dxe driver. This driver is dispatched early in DXE, due to being list + in APRIORI. It clears C-bit from MMIO and NonExistent Memory space when SEV is + enabled. + + Copyright (c) 2017, AMD Inc. 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 distribution. The full text of the license may + be found at http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +AmdSevDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap; + UINTN NumEntries; + UINTN Index; + + // + // Do nothing when SEV is not enabled + // + if (!MemEncryptSevIsEnabled ()) { + return EFI_UNSUPPORTED; + } + + // + // Iterate through the GCD map and clear the C-bit from MMIO and NonExistent + // memory space. The NonExistent memory space will be used for mapping the MMIO + // space added later (eg PciRootBridge). By clearing both known MMIO and + // NonExistent memory space can gurantee that current and furture MMIO adds + // will have C-bit cleared. + // + Status = gDS->GetMemorySpaceMap (&NumEntries, &AllDescMap); + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < NumEntries; Index++) { + CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc; + + Desc = &AllDescMap[Index]; + if (Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo || + Desc->GcdMemoryType == EfiGcdMemoryTypeNonExistent) { + Status = MemEncryptSevClearPageEncMask (0, + Desc->BaseAddress, + EFI_SIZE_TO_PAGES(Desc->Length), + FALSE); + ASSERT_EFI_ERROR (Status); + } + } + + FreePool (AllDescMap); + } + + return EFI_SUCCESS; +} -- 2.7.4