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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 12 Jan 2022 09:45:06 +0100
  • 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=Vscs0Ld50Z2FxslJ+PxeiZQ5qyRFcfaBGNlyXBD69qo=; b=Npdv9MtrolITCmNZzD1wCjOhFbGCWDWNu8B1snsmm1244vQ8zm3jGZYF6t1RHQtoAFNojTiVoARIrjYR/pgtOL9VTQq+EHjcTWZw+2qms4oY+9LlWk2v7orMCimlyQ1WAHdUXDzP3GfPQgXCJDXFSy5cNtbzwFz/6mBz36YAaLoVRDUVBaJyk2iiq9LIattm9x3EpoYWdAMLtNwH3mFSF2PZSbrpkBitCtn0CL89oLr798eAOLkA9ZSfZw4Kd8IPZHWZ4/te5SoMfEfgUI/Zi2ltjSBvMqbzZD5uDqQp3l6iKClehxhzNSIONQzFp0bATbwgIVcMzeujvUI6jmFxHQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DqWMbzs136iWSNP2QY22DLRipopY9+LJtNncXJpFeNQt4gPfbrZgrNYEokTd+WSYgyPNKbkzowRCzjoFoYlNJI7JGtvS+vi6fTRNjd8jKQ0GbrIxmjVcU8X31n0ZnnSgRvvU7QI+OZhYTp83G5D5doZOdlF1o+8gSqgJMhs8GGlWvy0n2pXphVhUbMbaSpn0FY0WJ+ZNoukcvI1LjGk3PgtArNKdAy7IoeJBnPYWdwvD3IkB8GGtnS1mSKc9tLLbwAEs+tsRSTisUsdTDVAOEHjsK1LqL/b8r9iM7W2ocBg1pKjDmqMgbx6iQNag1RL8KZJt4eumdW2r/9nfKUrSDw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Sergey Temerkhanov <s.temerkhanov@xxxxxxxxx>
  • Delivery-date: Wed, 12 Jan 2022 08:45:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>
---
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®.