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

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


  • To: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 18 May 2022 11:40:34 +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=kR4aguezniYjyWzhm8D0nCH6aT54bM3D5HpG3FdurXY=; b=oSHgl8BINd/a1gay5J6w2WwGmRVtJMXZI0OZQM/xCozSGooxQGQ0IskIYs0uGUJfUfjYpFsYP8UmMpFFvtbqdV9McK111NJhBvensdxXFbbmMV+YQ0hnXGmlrXDqYiYWrblezl3uVlbLMvP52lohY6yiD/ayOf0WboGHE7n59jI7SAPDqyu/SDRe897K5qFYC7cdJaGUQpoGiMFAs3t82vWcYXtwGKRigQNrCDM2/nW+99lWA60YuZBKpVUodAHDVapU185FtYxBzFK1dONlahoEZjxWBXDYdH2EfLZRNkqcxpRtAOh4p2mo5tQO99YW4qKzI9UUZD4dTXmGF4DIiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgvUvGTkCw8+kiCpiOR1J4SVauYWlXF7uGjls26VTAtVOl7DO9PiL4XWQmxoCekkxmStI4LezMIMUWSSApYiAKUUrwiRtS9CgIatkAA69gO6hji80+wxtl65GcbcueYO0iIqxXfVTePoydLSocLNhDJ0zuVqbaSYBK1IFm6C2GIY0Ay+/+nDkkvTWRFLru3zH8gHnOkoSFGz/9gT3+wx3QsKupBocvsFgbM+mGbHFXO4niRkSOzvn7N6iYzPM7wZ8oVv96iXz9d0f/WsUQcY1quH2SsSMH2QcroM6SwAXb4iwa+OODzXv26XpnCRpoJG8JCSJ51dR8An0h14h4jIDg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 18 May 2022 09:40:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17.05.2022 19:07, Demi Marie Obenour wrote:
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -39,6 +39,25 @@
>    { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 
> 0x23} }
>  #define APPLE_PROPERTIES_PROTOCOL_GUID \
>    { 0x91bd12fe, 0xf6c3, 0x44fb, { 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 
> 0xe0} }
> +#define ESRT_GUID    \
> +  { 0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 
> 0x80} }

I'm sorry, but it looks like my earlier comments still weren't clear
enough: The spec calls this EFI_SYSTEM_RESOURCE_TABLE_GUID, ...

> +typedef struct _ESRT_ENTRY {

... has no tag here, ...

> +    EFI_GUID FwClass;
> +    UINT32 FwType;
> +    UINT32 FwVersion;
> +    UINT32 FwLowestSupportedVersion;
> +    UINT32 FwCapsuleFlags;
> +    UINT32 FwLastAttemptVersion;
> +    UINT32 FwLastAttemptStatus;
> +} ESRT_ENTRY;

... calls this EFI_SYSTEM_RESOURCE_ENTRY, ...

> +typedef struct _ESRT {

... again has no tag here, and ...

> +    UINT32 Count;
> +    UINT32 Max;
> +    UINT64 Version;
> +    ESRT_ENTRY Entries[];
> +} ESRT;

... calls this EFI_SYSTEM_RESOURCE_TABLE. Also some of the field
names still aren't matching the spec.

> @@ -1067,6 +1120,46 @@ static void __init efi_exit_boot(EFI_HANDLE 
> ImageHandle, EFI_SYSTEM_TABLE *Syste
>      if ( !efi_memmap )
>          blexit(L"Unable to allocate memory for EFI memory map");
>  
> +    efi_memmap_size = info_size;
> +    status = SystemTable->BootServices->GetMemoryMap(&efi_memmap_size,
> +                                                     efi_memmap, &map_key,
> +                                                     &efi_mdesc_size,
> +                                                     &mdesc_ver);
> +    if ( EFI_ERROR(status) )
> +        PrintErrMesg(L"Cannot obtain memory map", status);
> +
> +    /* Try to obtain the ESRT.  Errors are not fatal. */
> +    for ( i = 0; i < efi_memmap_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);
> +
> +        if ( !esrt_size )
> +            continue;
> +        if ( ((EFI_MEMORY_DESCRIPTOR *)(efi_memmap + i))->Type ==
> +             EfiRuntimeServicesData )
> +            break; /* ESRT already safe from reuse */
> +        status = efi_bs->AllocatePool(EfiRuntimeServicesData, esrt_size,
> +                                      &new_esrt);
> +        if ( status == EFI_SUCCESS && new_esrt )
> +        {
> +            memcpy(new_esrt, (void *)esrt, esrt_size);
> +            status = efi_bs->InstallConfigurationTable(&esrt_guid, new_esrt);
> +            if ( status != EFI_SUCCESS )
> +            {
> +                PrintStr(L"Cannot install new ESRT\r\n");

Perhaps better PrintErr() here and ...

> +                efi_bs->FreePool(new_esrt);
> +            }
> +        }
> +        else
> +            PrintStr(L"Cannot allocate memory for ESRT\r\n");

... here?

Jan




 


Rackspace

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