WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH][GFW] Fix SMBIOS allocation

To: Tristan Gingold <tgingold@xxxxxxx>
Subject: [Xen-ia64-devel] [PATCH][GFW] Fix SMBIOS allocation
From: Alex Williamson <alex.williamson@xxxxxx>
Date: Thu, 01 Nov 2007 18:33:56 -0600
Cc: xen-ia64-devel <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 01 Nov 2007 17:34:50 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: HP OSLO R&D
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
   When we allocate space for the SMBIOS table in the GFW, we check to
see if it landed under 4GB, but we're not actually telling the allocator
that's where we want it.  This always failed for me.  The patch below
calls AllocatePages directly with the AllocateMaxAddress option to hint
to the allocator where we want the buffer.  Thanks,

        Alex

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
--

diff -r c238cddcd25b edk2-sparse/EdkXenPkg/Dxe/Bds/SMBios.c
--- a/edk2-sparse/EdkXenPkg/Dxe/Bds/SMBios.c    Wed Oct 24 02:50:08 2007 +0200
+++ b/edk2-sparse/EdkXenPkg/Dxe/Bds/SMBios.c    Thu Nov 01 18:26:09 2007 -0600
@@ -1,3 +1,4 @@
+#include <Common/UefiBaseTypes.h>
 #include <Ppi/XenHobs.h>
 #include <hypercall.h>
 
@@ -747,7 +748,9 @@ UINT32 create_smbios_table(VOID **smbios
     CHAR8 tmp[16]; /* holds result of itoa() */
     UINT16 tmp_len; /* length of next string to add */
 
-    VOID *smbios_table = NULL;
+    EFI_PHYSICAL_ADDRESS phys_addr = 0xffffffff; /* allocate below 4G */
+    EFI_STATUS status;
+    VOID *smbios_table;
 
     hypercall_xen_version(XEN_UUID, (VOID *)uuid);
     hypercall_xen_version(XEN_VERSION, (VOID *)&xen_version);
@@ -794,14 +797,18 @@ UINT32 create_smbios_table(VOID **smbios
 
     // The memory used as smbios table for runtime, so no free() invoked
     // otherwise error_out
-    smbios_table = (VOID *)AllocateRuntimePool(SMBIOS_MAXIMUM_SIZE);
-
-    if ( !smbios_table || (UINT64)smbios_table > ADDR_4G )
+    status = gBS->AllocatePages(AllocateMaxAddress,
+                                EfiReservedMemoryType,
+                                EFI_SIZE_TO_PAGES(SMBIOS_MAXIMUM_SIZE),
+                                &phys_addr);
+    if ( EFI_ERROR(status) )
     {
-        DEBUG((EFI_D_ERROR, "Cannot allocate memory below 4G for smbios 
table.\n"));
+        DEBUG((EFI_D_ERROR, "Cannot allocate memory for smbios table.\n"));
         goto error_out;
     }
     
+    smbios_table = (VOID *)(UINTN)phys_addr;
+
     len = write_smbios_tables(smbios_table,
                               get_vcpu_nr(), get_memsize(),
                               uuid, xen_version_str,
@@ -820,8 +827,7 @@ error_out:
         FreePool(smbios_table);
 
     *smbios = NULL;
-    DEBUG((EFI_D_ERROR, "Could not write SMBIOS tables, error in hvmloader.c:"
-           "hvm_write_smbios_tables()\n"));
+    DEBUG((EFI_D_ERROR, "Could not write SMBIOS tables\n"));
     return 0;
 }
 



_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

<Prev in Thread] Current Thread [Next in Thread>