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

[PATCH v3][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: Tue, 11 Oct 2022 11:41:39 +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=gI19HlK+CO49gbR4ePjFhXDQFIgGxU0z5umPLsZbJxo=; b=DeRaVHD0Mg6HuFj2bXXIFQPR4nlTmhEVHGt/aW99m1SkDsRGoIIus0bMHCHRMHu9a5BexpJrYkbeELK2J2SQaKI1F2jJw3x2ZX1Sbml5ekLSPZyT5cElis1Iwgdpar7mL8eVrLplR55+Kkdpg3koTltV1oDlmzH2XJaztunKvQ+JQD46+DPJQjIJ8kdxijKS5MYVOYAMFK9B2AYmN8xFUd9Q3D9qVUu0yhdfYpZwgLYO+CmJN6EVWBCMGtOHMhNhlLfikC6Ve4JhHZdutaCPayECkiKzBKw0LkGnm1dfPWeo9V+kJ+leJfwfEAYw7XwZ8Big7MRwjySctt3N71kMpg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVK36Dr2a/MjxVqTeWYw7y/TXXwemlfoQRITM4K3OYzqJOmqXhQBJO2MglMfJbJ2gwc5Gwg/+jTvuwSh6lnidp1uMowWpL9DN9C1rYPotyYJ9zXOPV87F+BXMxfHTZxd7VRcKDbfOrIbSQzp4C+DbZcfy7LMdmGOf4RHKjKnzmN5upGG7Ognutli/W+OBtg/iq/2gtumrW0nVWM/nxiTo0doww9R0ZTMe8k4uQCh0CPa+15Ket633aTAZMUUINKJBGc0jQQxVIqdZ+NYkcGJSCtwyFQeFjoznd45U2JyNqmHPaYYpZ7MPAyEzAZXZ0GYUoxjnwX1KMAbn2q2OTQqhA==
  • 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: Tue, 11 Oct 2022 09:41:51 +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 in theory the same would
apply to EfiACPIReclaimMemory, we don't actually "reclaim" or clobber
that memory (converted to E820_ACPI on x86) there (and it would be a bug
if the Dom0 kernel tried to reclaim the range, bypassing Xen's memory
management, plus it would be at least bogus if it clobbered that space),
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>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>
---
v3: Alter Arm change to leave EfiACPIReclaimMemory handling alone.
v2: Amend description.

--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -183,7 +183,8 @@ static EFI_STATUS __init efi_process_mem
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
     {
-        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
+        if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) &&
+             (desc_ptr->Attribute & EFI_MEMORY_WB) &&
              (desc_ptr->Type == EfiConventionalMemory ||
               desc_ptr->Type == EfiLoaderCode ||
               desc_ptr->Type == EfiLoaderData ||
--- 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®.