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

Re: [PATCH v4] EFI: always map EfiRuntimeServices{Code,Data}


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Sergey Temerkhanov <s.temerkhanov@xxxxxxxxx>
  • From: Luca Fancellu <luca.fancellu@xxxxxxx>
  • Date: Wed, 12 Jan 2022 13:02:43 +0000
  • 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=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=yiD12yVF33hhP7D1rCSvvT0DjxYWVb7mbS/tTEXBKhI=; b=aBqryKQoTZT1hAbYqlXv/YnvQUM9nst3MoXmFbxyzCh8ecZLHXiSIbMsHt5fVWQXGCPCUNPOfeD85F0dzFCNruQtnEnoJ/5JeWRT3YCY6bfs44UgapF6l/28gDYrDkAXJA4y/EWTD8y/ma+TULtUoHubiqxMn3T0RcPmKsT8GifCa+gHooAxvDLSaZLFTWnM9VVA9AGZ063xVK+mowL3HY7lmasnsrCSzogfVLxZcmm9ZvCiwK9u/yL23+NAMPjrfIA+EE9mNaF2RwwZAdElLdb5rXAuKmdqKeAcYdc96l9wUycJ9tOEst98kXev9ciLHsU/tv9lukBDfnyjJl3/gQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m+dVneeoXZC0nQkHW5SDJ3pXJS1At+VwQqda4JV/5M7NNTeKr0RO0vXI88owkwIDxVAl1Y0oPtYq1Pw/BY3GyMvMewgbX0fN1VzQIBeAaZ1uaFm5im9U39kQu9ieSL3ZdozZUfch4EbCl7zNQDkegND8/scDBV708vclgaGnETb1YyyTuXvIqK5tR61wTVAHBGesIPU4G1Af+NK/V+kFtBq/iYFAuIfrysfeU4GVk+638rQZlPgY/gdLsouqDq5oztHviFx1myEFqHA5aHMwTS8jyCyQJZNA7lZNQ3fDH8bt+bf6BrpsVFc6Hy559HpUJkim2l4YCGKiBj/E2kP1jA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 12 Jan 2022 13:03:32 +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;


> On 12 Jan 2022, at 08:45, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> From: Sergey Temerkhanov <s.temerkhanov@xxxxxxxxx>
> 
> This helps overcome problems observed with some UEFI implementations
> which don't set the Attributes field in memery descriptors properly.
> 
> Signed-off-by: Sergey Temerkhanov <s.temerkhanov@xxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Hi,

I’ve tested this patch on an arm machine with UEFI boot and it works fine.

Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
Tested-by: Luca Fancellu <luca.fancellu@xxxxxxx>

Cheers,
Luca

> ---
> v4: Drop EFI_MEMORY_CACHEABILITY_MASK. Fold with pre-existing if() (into
>    switch()). Style.
> ---
> I guess "map_bs" would also want honoring in efi_exit_boot(), but that's
> yet another patch then I suppose.
> 
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1094,7 +1094,13 @@ static void __init efi_exit_boot(EFI_HAN
>     {
>         EFI_MEMORY_DESCRIPTOR *desc = efi_memmap + i;
> 
> -        if ( desc->Attribute & EFI_MEMORY_RUNTIME )
> +        /*
> +         * Runtime services regions are always mapped here.
> +         * Attributes may be adjusted in efi_init_memory().
> +         */
> +        if ( (desc->Attribute & EFI_MEMORY_RUNTIME) ||
> +             desc->Type == EfiRuntimeServicesCode ||
> +             desc->Type == EfiRuntimeServicesData )
>             desc->VirtualStart = desc->PhysicalStart;
>         else
>             desc->VirtualStart = INVALID_VIRTUAL_ADDRESS;
> @@ -1545,13 +1551,36 @@ void __init efi_init_memory(void)
>                     ROUNDUP(desc->PhysicalStart + len, PAGE_SIZE));
>         }
> 
> -        if ( !efi_enabled(EFI_RS) ||
> -             (!(desc->Attribute & EFI_MEMORY_RUNTIME) &&
> -              (!map_bs ||
> -               (desc->Type != EfiBootServicesCode &&
> -                desc->Type != EfiBootServicesData))) )
> +        if ( !efi_enabled(EFI_RS) )
>             continue;
> 
> +        if ( !(desc->Attribute & EFI_MEMORY_RUNTIME) )
> +        {
> +            switch ( desc->Type )
> +            {
> +            default:
> +                continue;
> +
> +            /*
> +             * Adjust runtime services regions. Keep in sync with
> +             * efi_exit_boot().
> +             */
> +            case EfiRuntimeServicesCode:
> +            case EfiRuntimeServicesData:
> +                printk(XENLOG_WARNING
> +                       "Setting RUNTIME attribute for %013" PRIx64 "-%013" 
> PRIx64 "\n",
> +                       desc->PhysicalStart, desc->PhysicalStart + len - 1);
> +                desc->Attribute |= EFI_MEMORY_RUNTIME;
> +                break;
> +
> +            case EfiBootServicesCode:
> +            case EfiBootServicesData:
> +                if ( !map_bs )
> +                    continue;
> +                break;
> +            }
> +        }
> +
>         desc->VirtualStart = INVALID_VIRTUAL_ADDRESS;
> 
>         smfn = PFN_DOWN(desc->PhysicalStart);
> 
> 




 


Rackspace

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