[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: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 6 Jul 2022 12:59:13 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=5WSB1M4P3ugheaXogNqtwf3c7T+etBrYrVKxCBMoqzY=; b=JrGjl5Kb6XccLwdbGMzeUnDpql8YMR+8/kfNJtNxS4I9n9ni2/v2QKjzs3nOCTQEjaoWPTu3E+2BH9kjAgjdUBmCzemBy7D8QLPvVaBRm/z7nyhh8zyrO2IZV5F2pgmYMgAbYWW+j9hOCSepwwP7ACjXoI5qTHsNhDZainwCVf9N3ylpRcDg3yKX3dNIILFC0CiJDRVtiRJY2g8aSmLZrDEk+fxZXDDi4c4bZzznQvd03tecZiWDp7MCr/mKDb0wXPYeG+Yb55sTiJnO98XZbqJOPVJFCFs/eO4lvIeNUZ+YzSyvm4leHM6qufaAJeM5dnpkqV3zxsfqTUZ3+rfPsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E7cDyus65AbztAygQsrO4QWOzoUHlyIGVyvah8tcvufbxxCl5iC9kaxTea0qfATvSaUZXHXGJNeGWulngHzwT66S/nxMoHWm/8D0gvOYNqn283xXqc4DJ+fia5WCNYaX6dX3KLdWdMp41iZCNxwN2ZvZeBWNmh4dW1NlM12g77izJ5wUwItZef8tGUw7EVcVshPV+J2rPUYggEhRdnoJNbB6v1NpTS43SInwFmzh+GwICwkFdYWHv4zk4c5+5kcUQFGYd3HzF7MAP8/p5gQLXl6IaAj7hn1klaGQh48W+nzLpaZAukLBEkXpbCDPnmXx/6UIDosD290fJjvniUK33A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Luca Fancellu <Luca.Fancellu@xxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 06 Jul 2022 10:59:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

Jan



 


Rackspace

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