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-changelog

[Xen-changelog] [xen-unstable] hvmloader: New functions mem_hole_alloc()

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvmloader: New functions mem_hole_alloc() and mem_hole_populate_ram().
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Wed, 03 Aug 2011 21:44:10 +0100
Delivery-date: Wed, 03 Aug 2011 13:47:12 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1311410627 -3600
# Node ID 815ef5cf02613b9d21e2c9837760278516a69965
# Parent  88847c424eec8c5d5df79fc5e961660fe31d83ec
hvmloader: New functions mem_hole_alloc() and mem_hole_populate_ram().

These can be used by BIOS-specific handlers to set up memory regions
as required by their firmware payload.

Use mem_hole_alloc() to allocate properly reserved space for the
shared-info-page mapping. The old location conflicts with space
required for the OVMF BIOS (support for which is work in progress).

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 88847c424eec -r 815ef5cf0261 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Sat Jul 23 08:58:37 2011 +0100
+++ b/tools/firmware/hvmloader/util.c   Sat Jul 23 09:43:47 2011 +0100
@@ -303,29 +303,14 @@
     *p = '\0';
 }
 
-void *mem_alloc(uint32_t size, uint32_t align)
+void mem_hole_populate_ram(xen_pfn_t mfn, uint32_t nr_mfns)
 {
-    static uint32_t reserve = RESERVED_MEMBASE - 1;
     static int over_allocated;
     struct xen_add_to_physmap xatp;
     struct xen_memory_reservation xmr;
-    xen_pfn_t mfn;
-    uint32_t s, e;
 
-    /* Align to at least 16 bytes. */
-    if ( align < 16 )
-        align = 16;
-
-    s = (reserve + align) & ~(align - 1);
-    e = s + size - 1;
-
-    BUG_ON((e < s) || (e >> PAGE_SHIFT) >= hvm_info->reserved_mem_pgstart);
-
-    while ( (reserve >> PAGE_SHIFT) != (e >> PAGE_SHIFT) )
+    for ( ; nr_mfns-- != 0; mfn++ )
     {
-        reserve += PAGE_SIZE;
-        mfn = reserve >> PAGE_SHIFT;
-
         /* Try to allocate a brand new page in the reserved area. */
         if ( !over_allocated )
         {
@@ -356,6 +341,35 @@
         if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 )
             BUG();
     }
+}
+
+static uint32_t reserve = RESERVED_MEMBASE - 1;
+
+xen_pfn_t mem_hole_alloc(uint32_t nr_mfns)
+{
+    hvm_info->reserved_mem_pgstart -= nr_mfns;
+    BUG_ON(hvm_info->reserved_mem_pgstart <= (reserve >> PAGE_SHIFT));
+    return hvm_info->reserved_mem_pgstart;
+}
+
+void *mem_alloc(uint32_t size, uint32_t align)
+{
+    uint32_t s, e;
+
+    /* Align to at least 16 bytes. */
+    if ( align < 16 )
+        align = 16;
+
+    s = (reserve + align) & ~(align - 1);
+    e = s + size - 1;
+
+    BUG_ON((e < s) || (e >> PAGE_SHIFT) >= hvm_info->reserved_mem_pgstart);
+
+    while ( (reserve >> PAGE_SHIFT) != (e >> PAGE_SHIFT) )
+    {
+        reserve += PAGE_SIZE;
+        mem_hole_populate_ram(reserve >> PAGE_SHIFT, 1);
+    }
 
     reserve = e;
 
@@ -635,7 +649,7 @@
     xatp.domid = DOMID_SELF;
     xatp.space = XENMAPSPACE_shared_info;
     xatp.idx   = 0;
-    xatp.gpfn  = 0xfffffu;
+    xatp.gpfn  = mem_hole_alloc(1);
     shared_info = (struct shared_info *)(xatp.gpfn << PAGE_SHIFT);
     if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 )
         BUG();
diff -r 88847c424eec -r 815ef5cf0261 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Sat Jul 23 08:58:37 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Sat Jul 23 09:43:47 2011 +0100
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>
+#include <xen/xen.h>
 #include <xen/hvm/hvm_info_table.h>
 
 #define __STR(...) #__VA_ARGS__
@@ -164,6 +165,12 @@
 int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 int vprintf(const char *fmt, va_list ap);
 
+/* Populate specified memory hole with RAM. */
+void mem_hole_populate_ram(xen_pfn_t mfn, uint32_t nr_mfns);
+
+/* Allocate a memory hole below 4GB. */
+xen_pfn_t mem_hole_alloc(uint32_t nr_mfns);
+
 /* Allocate memory in a reserved region below 4GB. */
 void *mem_alloc(uint32_t size, uint32_t align);
 #define virt_to_phys(v) ((unsigned long)(v))

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] hvmloader: New functions mem_hole_alloc() and mem_hole_populate_ram()., Xen patchbot-unstable <=