diff mbox series

[kvm-unit-tests,PULL,10/10] s390x: Initialize the physical allocator on mem init

Message ID 1548067555-15766-11-git-send-email-thuth@redhat.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,PULL,01/10] s390x: cleanup and add SCLP defines | expand

Commit Message

Thomas Huth Jan. 21, 2019, 10:45 a.m. UTC
From: Janosch Frank <frankja@linux.ibm.com>

The physical and virtual allocators can coexist, so we can initialize
the former and allocate pages without breaking VM alloc.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 lib/s390x/sclp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index 7f556e5..b60f7a4 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -16,6 +16,7 @@ 
 #include <asm/interrupt.h>
 #include "sclp.h"
 #include <alloc_phys.h>
+#include <alloc_page.h>
 
 extern unsigned long stacktop;
 
@@ -28,8 +29,16 @@  char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));
 static void mem_init(phys_addr_t mem_end)
 {
 	phys_addr_t freemem_start = (phys_addr_t)&stacktop;
+	phys_addr_t base, top;
 
 	phys_alloc_init(freemem_start, mem_end - freemem_start);
+	phys_alloc_get_unused(&base, &top);
+	base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
+	top = top & -PAGE_SIZE;
+
+	/* Make the pages available to the physical allocator */
+	free_pages((void *)(unsigned long)base, top - base);
+	page_alloc_ops_enable();
 }
 
 static void sclp_read_scp_info(ReadInfo *ri, int length)