From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.57]) by mx.groups.io with SMTP id smtpd.web10.179.1685740814436766333 for ; Fri, 02 Jun 2023 14:20:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=x+/cA4fc; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.220.57, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LwYy7K65DTJiUFbIyCjW5w/dfpt8DtSSxDF4oX4WXxt5ubgYC/d3H4HuUOtqpCyrAhqjdL2yDL2U4yvDwetKe8YOrseoPihDfxJdX14lEJdPXxRjKIsV5R0Q1yr4xxjZ8jkXYfynlNolmNi1ecXlsdgu0ryYCM1GBMs1eLVwrmK1i90ceZsEJ0w0RVfRgyn1kNd6QW8hF+6Q/g5XwKgeC3DUhxuN9sDTApJXR+r9ZfL1S4v8Nf/LDRHjxSCcQsdav7ny498t0Jts3AiAtHKWP5y4sRkgd6k8LBCdwiI9gVP7Ns9IV+9MgLf79QyVMNoI2Rd/XNI3cA5CQvcCI77RQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tX5xWH6vAle9nsZ1hYVZGofJcxJvyYy2ooD/5CX2hYw=; b=Nqfd6dyGisWfmz/u5ULf3kGtRWnwAi7w50PeKJIKN832R2FFt09n8NDuytFOz2rZXN9PiA5RBpub81KQHR3bhBt/tcIuzUjnww5NGhrjdrqhvE1c77CxO92SPgMK2rkUGEGNG3+Ug+uuF/o1aydnpROZNBZrzg03SUwoDFC+1xOa5Sd7mFPgWRl7lIA9YBS3EkPnifMX1WUP4Gc29ZwRNGQzxFOxKDBz8I8dcByJJ/SVmHFxYEmToAc4iiXvemoH0kkI+tzScSP909h2fLKmptkAEb17ff+YlPlSbaMl4dsIp+6TzytBQZKENQDam8/Povq6GrOhgETdFT88z+HfYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tX5xWH6vAle9nsZ1hYVZGofJcxJvyYy2ooD/5CX2hYw=; b=x+/cA4fcITbKETG0k9IDGW4/kwdrx6Q4Rih15oo+OLf3xDmd+DoEoSXUWu0CDPRJ4rZvjpIfxfKLXHFo0yPbCvJDuo/LwNMyRs6f4aNgHbg3R1gxgxo8hUCiTecOXw+lBbbnwiK3mqwPlsVQjp6ma87gcXyLW8muSDCXi7r0pok= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by SA1PR12MB8598.namprd12.prod.outlook.com (2603:10b6:806:253::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.27; Fri, 2 Jun 2023 21:20:10 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::61f6:a95e:c41e:bb25]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::61f6:a95e:c41e:bb25%3]) with mapi id 15.20.6455.026; Fri, 2 Jun 2023 21:20:10 +0000 Message-ID: <9d9d8bb2-ac6f-0339-738e-44c6d50f286b@amd.com> Date: Fri, 2 Jun 2023 16:20:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs To: Mikolaj Lisik , devel@edk2.groups.io, Gerd Hoffmann Cc: pedro.falcato@gmail.com, erdemaktas@google.com, jejb@linux.ibm.com, jiewen.yao@intel.com, min.m.xu@intel.com, michael.roth@amd.com References: From: "Lendacky, Thomas" In-Reply-To: X-ClientProxiedBy: DM6PR02CA0077.namprd02.prod.outlook.com (2603:10b6:5:1f4::18) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) Return-Path: Thomas.Lendacky@amd.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5229:EE_|SA1PR12MB8598:EE_ X-MS-Office365-Filtering-Correlation-Id: eb916e72-059d-4efc-dbe9-08db63af24f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RdMeOF+X344pfnruycKX4F8XfEL7cO3YrnITm4Y6CQ15yAD8qwyNQ8BenNlPyJDdfKtc792aCvShuAFZPNyMcyHQw9djaUkhK56/i0dWx+Mi9JhP7ooLiY6fDTuEwbFnuDDw+SCNpF9lGoYpU+FOnxXHVfzfQhHBnZA46f6vGCgr08kXN81ZgDLnq1c1yqdfEVoNGirjVajq93QG/rEwaqqguOu1VrdI+f/ydBi0c6oMWLuKWbt6W8i70IjwBDOMSZhMvhgIQHntsah8g+QvxPlRBRNICDTgnTceg6f1gXQD9UaeW6/iK0QY/AYOjJB2ts5o71Qu+RyaORu6/WSrH4YVIi0udQpXmSQlpoYkYxDO/wRo/wn6RflZ8YVUlx/gr4iWosr9y+HdSseajGp4QUbxjfelO2Wi97oJJBAmCOpGkrSMlTzJJc/+cadfKLKxl0sYInWRpdbOUIcZBXj6HI0VUFnCTG5k9wTF+B3k6TelwvHwM0wQKz1FHPeAjqX0ZhMK4CCrY2lmxv1bqT4BzK6YYe7vjF42DWh6yqs1KrNk8vZ+QzgCKdBV1RXUGLBxeEJThBkIEnYF9u5iYlgt0y5E2dQqj4DiLMvbi1WfQerkFnyG/ocuXIKj73IqkTgsfDB50jlSo5sxWBDfaX2UFw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(376002)(39860400002)(346002)(366004)(451199021)(31686004)(316002)(2906002)(186003)(5660300002)(19627235002)(8936002)(8676002)(66946007)(4326008)(66476007)(66556008)(83380400001)(41300700001)(38100700002)(110136005)(2616005)(31696002)(86362001)(478600001)(6666004)(6486002)(36756003)(53546011)(6512007)(6506007)(26005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RkU1KzlwWVN2UWNmREV2RDc3b0c2SzF6KzJZcXZNQmhxWTF1UGdxOUovbzAv?= =?utf-8?B?NTdjWWJxNU93NEI1Ylh0Zm9iaHhnb2NYbDJNS21lMVdOY3l0cjRNVjBYU3pQ?= =?utf-8?B?YkZDRHFtZnJtL2ptQlpaRjlJMGYrOFhZVTh1L1JjTTZ1ZWxUZ1NNWVNRWEVN?= =?utf-8?B?dzBCL2ZXZGNMZGQyVC81SjJ2OFBobStoOTI5Y0pUeEtpWEJqdkdSV3drSnIr?= =?utf-8?B?b2dNMDY5dW91SmV4YlcxQkxzUjhVQnVUUDFQeGc0SHNXYnhLWitvNFQ2ZW5p?= =?utf-8?B?UnluT010QTBEMHlnYjhPa2NmVmtHNmc1dDJDZWIvd2ptMW82bVo5NEoyRXZl?= =?utf-8?B?RWhVeWJlVUdvcTNKSTl6VXZuS0JneXhVN2VuR2hiUFdhRXhkRDFlc3cvMk1U?= =?utf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Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 21:20:09.9201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i62hD3d8ZSm9lw5IIfIoxDNJKK+/kTcVNZoMm3/6iR/HgdB2ggNfOuMNsnwrcHEZRptMkJuHp/GAUkVc+90L2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8598 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/26/23 14:26, Mikolaj Lisik wrote: > Edk2 was failing, rather than creating more PML4 entries, when they > weren't present in the initial memory acceptance flow. Because of that > VMs with more than 512G memory were crashing. This code fixes that. > > This change affects only SEV-SNP VMs. > > The code was tested by successfully booting a 512G SEV-SNP VM. > > Signed-off-by: Mikolaj Lisik I don't see where this was merged. Both Gerd and I acked it back in January, was there a problem with it? Thanks, Tom > --- > .../X64/PeiDxeVirtualMemory.c | 26 ++++++++++++------- > 1 file changed, 17 insertions(+), 9 deletions(-) > > diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c > index b9c0a5b25a..75c2c36bb4 100644 > --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c > +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c > @@ -548,6 +548,7 @@ InternalMemEncryptSevCreateIdentityMap1G ( > PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry; > PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry; > UINT64 PgTableMask; > + UINT64 *NewPageTable; > UINT64 AddressEncMask; > BOOLEAN IsWpEnabled; > RETURN_STATUS Status; > @@ -602,15 +603,22 @@ InternalMemEncryptSevCreateIdentityMap1G ( > PageMapLevel4Entry = (VOID *)(Cr3BaseAddress & ~PgTableMask); > PageMapLevel4Entry += PML4_OFFSET (PhysicalAddress); > if (!PageMapLevel4Entry->Bits.Present) { > - DEBUG (( > - DEBUG_ERROR, > - "%a:%a: bad PML4 for Physical=0x%Lx\n", > - gEfiCallerBaseName, > - __FUNCTION__, > - PhysicalAddress > - )); > - Status = RETURN_NO_MAPPING; > - goto Done; > + NewPageTable = AllocatePageTableMemory (1); > + if (NewPageTable == NULL) { > + DEBUG (( > + DEBUG_ERROR, > + "%a:%a: failed to allocate a new PML4 entry\n", > + gEfiCallerBaseName, > + __FUNCTION__ > + )); > + Status = RETURN_NO_MAPPING; > + goto Done; > + } > + SetMem (NewPageTable, EFI_PAGE_SIZE, 0); > + PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)NewPageTable | AddressEncMask; > + PageMapLevel4Entry->Bits.MustBeZero = 0; > + PageMapLevel4Entry->Bits.ReadWrite = 1; > + PageMapLevel4Entry->Bits.Present = 1; > } > > PageDirectory1GEntry = (VOID *)(