From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.69]) by mx.groups.io with SMTP id smtpd.web11.15844.1676299130638116802 for ; Mon, 13 Feb 2023 06:38:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=qVdsYwv/; 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.93.69, mailfrom: pankaj.gupta@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cpHDbrVKAPmwhJHQxjJ46Hu5HP2cMwu+xMWUkQYBittz4vxEKx+1J4j/H3BMglNAuSiePJuhZ4a6gGbxE+f6lUisvn5wSa89I9DUt4/HAEGCNdsL1Wh+6V/indXVA70snIjqD0K8995kAIEzhVOSbds1RzSTmcwPn0+PbRrK+uA8FRWYKIlXIwRtiPjOvlj/vlzTv51xF/8YtmRjH6zPDrxdQueycLIEVwVPEDjtBbf/C3c7tFJXvTEFLdR89Y6OIAyaYSqSuftYdV0opZelmUaGbCdOKnju6NMZ6dBYYkw1DLctvASodHSZjghxetgtRtEvubRdv0eoFNo8odmq+w== 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=MzAf2545uzRU8kMPN6KZklO/+Yr3isbfkjPjNMt+l1U=; b=S8EBb302HZ44Edlo5fW8RhFrU3ITcE7YB7UGIf2b8qqGcWwlRUJiLR88W01JasjpVSxYU1uTRl9IDYsLeGzRqc4vgZSLOLjLPtuOpPbmCSi6zzHHM7q+6gSQK/jvtJ3eDNJSxrBIcMkcGsvAFfqIGc0bPOvPtQktwrH87EP7d2EKUaF70b4d5rmVQyf09ItyV96Rsp8kbdlr2IJ75RITGp91bKXmGpoLGZos95HWWv3b6n/JhcPa2a1JWnby/gyvSSQQq4TiYzdlqaZKNtpsU42tEPX6AJbvPYcZCORLqnk/jNZVIM1chBEomHCI4QLgVSx1B5sD8W26vnOh5EkZzA== 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=MzAf2545uzRU8kMPN6KZklO/+Yr3isbfkjPjNMt+l1U=; b=qVdsYwv/9C9wuaw/N5VoWPyWy+S6Z7sU6aE5Cb5DulGpFowyMmrZeUr+Lom6knWirEuGufOdAyKTIQ9TC9V09ZNU97RldyuMFYY58VAKfKCRMXdS8enklNa7hnDjFXSUac+IvbV7cqah3qKuVKZowC09H3uvsbiy38CRLd6ueqw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB2810.namprd12.prod.outlook.com (2603:10b6:5:41::21) by BL1PR12MB5826.namprd12.prod.outlook.com (2603:10b6:208:395::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.24; Mon, 13 Feb 2023 14:38:48 +0000 Received: from DM6PR12MB2810.namprd12.prod.outlook.com ([fe80::b84e:f638:fa40:27ef]) by DM6PR12MB2810.namprd12.prod.outlook.com ([fe80::b84e:f638:fa40:27ef%6]) with mapi id 15.20.6086.024; Mon, 13 Feb 2023 14:38:48 +0000 Message-ID: <9ea61013-e2c1-30a4-3be7-feed537c035a@amd.com> Date: Mon, 13 Feb 2023 15:38:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [edk2-devel] [PATCH v10 1/4] OvmfPkg: Add memory acceptance event in AmdSevDxe To: Dionna Amalie Glaze Cc: devel@edk2.groups.io, Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel , "Min M. Xu" , Andrew Fish , "Michael D. Kinney" References: <20230126005647.3019225-1-dionnaglaze@google.com> <20230126005647.3019225-2-dionnaglaze@google.com> <0d8f2b0b-1d62-3db6-34c9-e9ce39838bce@amd.com> From: "Gupta, Pankaj" In-Reply-To: X-ClientProxiedBy: FR3P281CA0046.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::12) To DM6PR12MB2810.namprd12.prod.outlook.com (2603:10b6:5:41::21) Return-Path: Pankaj.Gupta@amd.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB2810:EE_|BL1PR12MB5826:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d969614-972e-4320-9c2f-08db0dd00466 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yWTVdvxjUpURgFkRy4zFtyYt1eW00b0uqVCMtKhWjkr2Ya02l8O0oJnUmJcjYIK1Gjkubp2CFV+2RFPItE9UjP7fzRUxubg1Vlkyog1ARVw6+AZXAGW/o1+bcNYtwrIazHVVzGFwOUmt+nAWGZG938uCO+83N53ERSuP0ZlyAj3Si5zcpbxHDql0+YZXPiyhyLAfm6ZVSCUsBkjrhZueQZm8JBg+Nn4N4fXvXoeZj0FKLNpnFxNnNOd6Otw/+cxugWYMooLgxX1yhQtwJnVaf7RTiCUwLM2bFOWmS+eG/4/KGEM2oetpODAu+fQWIYmrzgTBBMzWpfAWkb/WNB/uy7amqnnK7Sianrwc6KERXPRj39/A3EQtNarwqe1A02OJtwTeFO2jSSz4ttQzz46rI0/0lr2qFRLTWmlUYiA1DEz//wMAB4SRD5plhBwa32y88X++jN0kq6pOCwTKauT0+GxpBH9Dd2FSe0W5UgU1c9geIjFO57cTLsdFm+SPkweVvGklaetmI1Nm1MR9SE2DjLyg1WJk/qWBk51YVbD9xqXrGERfwU0DRhT9Er9s+6NQOlm+nrqvqkH4XeH45Lt7Qcn5y3SZajD1JCJ3oSOJhRLrvF5wJwFWzp5mAXahFvRVYv8GugRjCzOSoHbMw0QwDQAvD3+yjsddOVjgdehvxLWK2KR5fBnZsQZ2zUgAjw61WtaUDL8m9+k3e0IVfNvjRIralT3PQNQHIWXGP+2YpQQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB2810.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(376002)(346002)(39860400002)(366004)(451199018)(31686004)(6512007)(83380400001)(186003)(26005)(5660300002)(36756003)(2906002)(31696002)(6506007)(86362001)(41300700001)(478600001)(6666004)(6486002)(2616005)(66556008)(54906003)(8936002)(66476007)(316002)(6916009)(38100700002)(8676002)(66946007)(4326008)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SytzQmt4THBIK0dXTS9vUnBOOXEzYlRkUURWVU9PUVN0Y0xBc2V0OEVTQUtR?= =?utf-8?B?NlY0OFlXS2NaYWtybVJhR1JwUXgvNTVUY3RUbTRSR3JhSlRPdDdNV2xnd0ZX?= =?utf-8?B?c0ZQbWM5LzR2SUNDZjdWWWxlazlHa240NVp4cWZveDFvUngxTXMxL3pSTVpY?= =?utf-8?B?emFzZ0VCZEdLUCtaWGlUWG9nakt1S0hRWWR6dnB3cklTNmhNekp3SEtNS2dp?= =?utf-8?B?OGlVdnRzejNISm0wR21jd3ljYVVVQk9XN1lBZnRhcHBzMnZ5b2ozOGtFRUZH?= =?utf-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SGs3NnUzTDlzK3hXbUc3NXpuSHZoYVFa?= =?utf-8?Q?6q+l0Q/dDAEmK2QxkQ9M+YYXE?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d969614-972e-4320-9c2f-08db0dd00466 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2810.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 14:38:48.3280 (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: mnww0UzSFXiJGETFk5KNEiYG3XP6lQY5S6AjBlJ5z3V0U/l5Ti+Y9x//wgHsCs3Tv2PqnlZkc5CSBNlf0gkg8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5826 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit >>>>> With this patch I observe an issue where my Linux (6.2.0-rc7) guest >>>>> recur to Bootloader menu again. I am testing this with SEV SNP (w/o >>>>> UPM). Also, guest don't have lazy memory acceptance support. >>>>> >>>> >>>> Thanks for the report. I'll try to reproduce it on our UEFI and if I'm >>>> unable, then we'll discuss next steps. >>>> >>> >>> I don't see this in our test Ubuntu 22.04 image from Canonical. Do you >> >> Ubuntu 22.04 guest by default run 5.15 kernel? But SEV SNP got >> merged in 5.19. I don't know currently how we are handling accepting >> the memory on "ExitBootServices" with or w/o guest supporting SNP. >> > > It does, but I used the Qemu kernel injection pathway in Ovmf to run a > build of 6.2.0-rc7. Our testing setup doesn't give the user a boot > menu to select a kernel, so I wasn't aware that this return to > bootmenu could happen. > > >> This looks to me like it is entering the 'accept' path twice, and so >> ExitBootServices() is failing twice, resulting in a failed boot. > > The double log is expected behavior because I didn't add a check for > whether accepting all memory would be a no-op. > > The "Accepting all memory" message occurs twice if the guest does not > have support for unaccepted memory following this control flow: > > 1. EBS > 2. [...] Log "Accepting all memory" > 3. Loop through all memory spaces > 3a. If the memory space is unaccepted, accept it. > 3b. Remove the unaccepted memory space. > 3c. Add a conventional memory space back with the same range and capabilities. > 4. EBS returns an error since the map key is different. > 5. OS calls GetMemoryMap to get the updated key. > 6. OS calls EBS with the updated key. > 7. [...] Log "Accepting all memory" > 8. Loop through all memory spaces > 8a. There are no unaccepted memory spaces left, so nothing happens. Seems like hitting this all the time. Can't see EFI_GCD_MEMORY_TYPE_UNACCEPTED memory at all in the memory map. And always hitting: if (Desc->GcdMemoryType != EFI_GCD_MEMORY_TYPE_UNACCEPTED) { So, no memory is getting accepted. Questions below: - If no memory is getting accepted at all, should guest boot fail with below errors? - Why unaccepted memory not being set in my setup but works fine for you? Does it require any other change? Thanks, Pankaj > 9. Return successfully (one would hope) > >> Accepting all memory^M >> Accepting all memory^M >> EFI stub: ERROR: exit_boot() failed!^M >> EFI stub: ERROR: efi_main() failed!^M > > This now does suggest that EBS is failing twice, since after the > supposed no-op of the second log, the EFI stub's exit_boot claims > failure. I can't reproduce this part. Would you try adding a log > within the acceptance loop inside the if that checks for unaccepted > memory? I'd be curious if the loop is indeed changing the map again, > despite my claims at idempotency. >