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

[PATCH v2][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 6 Oct 2022 10:40:56 +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=KYJzW7pJsTsrG7cUmtwhu0ZLDOihzGR909f8ymBMUyw=; b=HNez0h8GEqh2P4s9sIkQlZmVJ6uCz5eTcd2DcnGvAr95oG22iUMF8vDKR+jzxmPbQRdj/DSyajof7V+l4kAirF4Ok/rJO7j35hRhaMTTk1tjGZiF2xwhEJZzDlNFaqc7IapOz02Kvr7kueh7xNRBXYwbhOaJcLs3nXKjn/GghydNGIxR/MfeDO29H3LJXimOi6RQlD6vB1AUZy0/BznsxrRky0Gsqv5JX/WNlA0UPQvDBiEuVGbJYacNCYV7wE7WU2B1jZKAPjO8x6pLXGiHRofpIAElIQ62PmE6MTFckUi4Uqj0GeyJ0klsK6oLluayatBF9WC0qgSrACKqI7/jeg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hSQrbogoVk3ga0B/d42F/H87iBT10DMhFyudqRh1BHCJW94d3sPrSJyVyHa6dxLbu7nJSM4S5FyBk0bc+9c2TaTq9eg2yPWYjl475PDV6rN0fzfEHDx2h0AhCbUNt0YgoDCenlHLk9op6e0rnlhrrBwRdtRY7i+BW5N8BgxsUZ3xxVBLlmcl6Bxg6a+N+tVKGMz3lVXN18huTAy3N/iqJgYCVT6g+UiA16FHIKadpB39GUVRffQaB/n5AgYelEm6cIx0Yw+OvFLlIyk/2LZPNwoMCksIkRnUjXzhyJZV8DNEGbLlgebQWEEAhQ+nsfLn2touoQ51eV2E2aOEXblbdw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Thu, 06 Oct 2022 08:41:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

efi_init_memory() in both relevant places is treating EFI_MEMORY_RUNTIME
higher priority than the type of the range. To avoid accessing memory at
runtime which was re-used for other purposes, make
efi_arch_process_memory_map() follow suit. While on x86 in theory the
same would apply to EfiACPIReclaimMemory, we don't actually "reclaim"
E820_ACPI memory there (and it would be a bug if the Dom0 kernel tried
to do so, bypassing Xen's memory management), hence that type's handling
can be left alone.

Fixes: bf6501a62e80 ("x86-64: EFI boot code")
Fixes: facac0af87ef ("x86-64: EFI runtime code")
Fixes: 6d70ea10d49f ("Add ARM EFI boot support")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx> # Arm
Tested-By: Luca Fancellu <luca.fancellu@xxxxxxx> # Arm
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx> #arm
---
v2: Amend description.

--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -183,13 +183,15 @@ static EFI_STATUS __init efi_process_mem
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
     {
-        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
-             (desc_ptr->Type == EfiConventionalMemory ||
-              desc_ptr->Type == EfiLoaderCode ||
-              desc_ptr->Type == EfiLoaderData ||
-              (!map_bs &&
-               (desc_ptr->Type == EfiBootServicesCode ||
-                desc_ptr->Type == EfiBootServicesData))) )
+        if ( desc_ptr->Attribute & EFI_MEMORY_RUNTIME )
+            /* nothing */;
+        else if ( (desc_ptr->Attribute & EFI_MEMORY_WB) &&
+                  (desc_ptr->Type == EfiConventionalMemory ||
+                   desc_ptr->Type == EfiLoaderCode ||
+                   desc_ptr->Type == EfiLoaderData ||
+                   (!map_bs &&
+                    (desc_ptr->Type == EfiBootServicesCode ||
+                     desc_ptr->Type == EfiBootServicesData))) )
         {
             if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
             {
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -185,7 +185,9 @@ static void __init efi_arch_process_memo
             /* fall through */
         case EfiLoaderCode:
         case EfiLoaderData:
-            if ( desc->Attribute & EFI_MEMORY_WB )
+            if ( desc->Attribute & EFI_MEMORY_RUNTIME )
+                type = E820_RESERVED;
+            else if ( desc->Attribute & EFI_MEMORY_WB )
                 type = E820_RAM;
             else
         case EfiUnusableMemory:



 


Rackspace

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