[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8] Preserve the EFI System Resource Table for dom0


  • To: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 6 Jul 2022 11:01:50 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=+AHvB7ins89WpfSqIps/7lJFHP4PZk57CUcJRupgc2I=; b=m4bho4/cW7Hy85Ipu38ZFh/mHek/4qsaRSpmx+YoLmiy00Wuy6f8jNRdPpUM/gy9pohhQ23YpBMNlCo1q7dQJDj/JtdDYDy6uOUR4E6vggXOJ5DmVbyHVxSk5sHPuD3L3kugJV1EWjpl7NlJ8pfFMSYtykZRN/Oiu85Qbi6VcvtIZdwo7wkVNBToF3R8wWDlZlGPSbx4Uavic0ehVd9Alsq39gg54Sptx4JEjrs+l1qfyBTGqj201gJTKSvFHkFgD7j+dxwdCVrYnHSXudaS+yO3HXQRdehLCcw4i5u9/ia1huG2pUnPoN2RLa1eTirhrhg/EtwIOiUYIG4+mYzYDw==
  • 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=+AHvB7ins89WpfSqIps/7lJFHP4PZk57CUcJRupgc2I=; b=N7fmR1evGdbNstwaHW4j9ryUK0pi7FTiwBIzV9HiI32sJwpJ+F8lBfJLOorzXqraFBXu4/f2pi78pbvc8wRbSwwNVIIDLtPLCwDNpWeh649C7/Er+hvb/qs4twgQLGwYCMxkTT65bCiL32reezhF1yESvnTh2sPEwogHCErBXsxST9zNx0Xugs5IeNkpmO8icBJzTQXKCtfMPJoDu4S5mBq8djzt5rK0r2enwSgDmfGsii3zCsiSVNGBNSAahh6b6z9vkx1fWn5mPds9Y3NgsSkfM2oM0OuaFbYXKBLKry5dxd/31g/l8B4XnkMEB5c5GgVt8k97fC0GYy0u4vxToA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=hEgmOs+me5WpT3CZBTYkf6oVrHKkYspJ/k6ZVfmNKOEkIvosRmnjPER3XoUAQPO15dxTcnA6CFeGKhTmIFJrv+BCjvYC5v76UYiWSpJvUJWiQF1XGJeSRGvzeC299B20jEDc1gy5IBgZSVkXC7EUTzCOEZvk8dHEcNVQJpreMm2WWDuQT/Rg2dtbDszh9+qG42dLBK8tMQBa6LEZaqvsMg0rG6mAnjk+2nm5O/R10wIGo76rt4dsPM3IOvItEqemdxWLxvIlyoMdKIyTwmyIL58hAZd4QrzoiebamdijsxPzlaR+qLoZOeYP+cpHm9JDvbkeEFsoLxiqbUj4CXSWzA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hywtD6nEgcylpZqD6oGREErU+sz7UcAVtZW0Eu2DpAsF1N+GsS180WT8RjGrYlAwLziaYbiypmHpuNU9e41/5TNhdHUmv7CmX/V6bqWu8PE9axKE0IhzV340yIcVyZp7vMgE+ScBYRCPhSB11tfUO2ogQm/PGmj6gUYryXd8kb3gmy4qlRMdyFw90WnM6GT1ig24w7C9DAMuvtxJTJjvzOYBcRFH+rlPngsHObkOE6ILvDo87lLY+OEvhwZWWg3E6F0Cz3UxwoOC+1VA8CuPvGTsjG6hLdTI5OCOxMTNlkgS6Kdhk6+uyzqj0gW/BMRbNSMrfbxuK2Z0RGdWCFYskA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Wed, 06 Jul 2022 11:02:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYh/bQ1tgd5TeBbEyn28hq3tAw6K1xN30AgAADZgCAAAMXAIAAAKaAgAAATICAAAC6gA==
  • Thread-topic: [PATCH v8] Preserve the EFI System Resource Table for dom0


> On 6 Jul 2022, at 11:59, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 06.07.2022 12:58, Demi Marie Obenour wrote:
>> On Wed, Jul 06, 2022 at 12:55:50PM +0200, Jan Beulich wrote:
>>> On 06.07.2022 12:44, Andrew Cooper wrote:
>>>> On 06/07/2022 11:32, Luca Fancellu wrote:
>>>>>> On 24 Jun 2022, at 19:17, Demi Marie Obenour 
>>>>>> <demi@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>>>> 
>>>>>> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>>>>>> index a25e1d29f1..f6f34aa816 100644
>>>>>> --- a/xen/common/efi/boot.c
>>>>>> +++ b/xen/common/efi/boot.c
>>>>>> @@ -567,6 +587,41 @@ static int __init efi_check_dt_boot(const 
>>>>>> EFI_LOADED_IMAGE *loaded_image)
>>>>>> }
>>>>>> #endif
>>>>>> 
>>>>>> +static UINTN __initdata esrt = EFI_INVALID_TABLE_ADDR;
>>>>>> +
>>>>>> +static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)
>>>>>> +{
>>>>>> + size_t available_len, len;
>>>>>> + const UINTN physical_start = desc->PhysicalStart;
>>>>> Hi,
>>>>> 
>>>>> From my tests on an arm64 machine so far I can tell that desc is NULL 
>>>>> here,
>>>>> for this reason we have the problem.
>>>>> 
>>>>> I’ll have a further look on the cause of this, but if you are faster than 
>>>>> me you are
>>>>> welcome to give your opinion on that.
>>>> 
>>>> Given this observation, there's clearly ...
>>>> 
>>>>> @@ -1051,6 +1110,70 @@ static void __init 
>>>>> efi_set_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop
>>>>> #define INVALID_VIRTUAL_ADDRESS (0xBAAADUL << \
>>>>> (EFI_PAGE_SHIFT + BITS_PER_LONG - 32))
>>>>> 
>>>>> +static void __init efi_relocate_esrt(EFI_SYSTEM_TABLE *SystemTable)
>>>>> +{
>>>>> + EFI_STATUS status;
>>>>> + UINTN info_size = 0, map_key, mdesc_size;
>>>>> + void *memory_map = NULL;
>>>>> + UINT32 ver;
>>>>> + unsigned int i;
>>>>> +
>>>>> + for ( ; ; ) {
>>>>> + status = efi_bs->GetMemoryMap(&info_size, memory_map, &map_key,
>>>>> + &mdesc_size, &ver);
>>>>> + if ( status == EFI_SUCCESS && memory_map != NULL )
>>>>> + break;
>>>>> + if ( status == EFI_BUFFER_TOO_SMALL || memory_map == NULL )
>>>>> + {
>>>>> + info_size += 8 * efi_mdesc_size;
>>>>> + if ( memory_map != NULL )
>>>>> + efi_bs->FreePool(memory_map);
>>>>> + memory_map = NULL;
>>>>> + status = efi_bs->AllocatePool(EfiLoaderData, info_size, &memory_map);
>>>>> + if ( status == EFI_SUCCESS )
>>>>> + continue;
>>>>> + PrintErr(L"Cannot allocate memory to relocate ESRT\r\n");
>>>>> + }
>>>>> + else
>>>>> + PrintErr(L"Cannot obtain memory map to relocate ESRT\r\n");
>>>>> + return;
>>>>> + }
>>>>> +
>>>>> + /* Try to obtain the ESRT. Errors are not fatal. */
>>>>> + for ( i = 0; i < info_size; i += efi_mdesc_size )
>>>>> + {
>>>>> + /*
>>>>> + * ESRT needs to be moved to memory of type EfiRuntimeServicesData
>>>>> + * so that the memory it is in will not be used for other purposes.
>>>>> + */
>>>>> + void *new_esrt = NULL;
>>>>> + size_t esrt_size = get_esrt_size(efi_memmap + i);
>>>> 
>>>> ... a NULL pointer here.  And the only way that could happen is if
>>>> efi_memmap is NULL.
>>> 
>>> Incomplete refactoring - this needs to be memory_map, not efi_memmap.
>>> Of course efi_mdesc_size also needs to be mdesc_size. Didn't check
>>> for further leftover from the earlier patch version. I'm going to
>>> revert the commit.
>> 
>> Sorry about that. Want me to submit a v9?
> 
> Yes please. And please make sure you have tested this at least on x86.

I will test it on arm64, so please ping me if I miss it, I got submerged by ML 
mails
after my holidays and I didn’t test (on arm) this one like the previous version 
that
you sent before

Cheers,
Luca

> 
> Jan


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.