diff mbox series

[kvm-unit-tests,v9,15/31] powerpc: Enable page alloc operations

Message ID 20240504122841.1177683-16-npiggin@gmail.com (mailing list archive)
State New
Headers show
Series powerpc improvements | expand

Commit Message

Nicholas Piggin May 4, 2024, 12:28 p.m. UTC
These will be used for stack allocation for secondary CPUs.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 lib/powerpc/setup.c     | 8 ++++++++
 powerpc/Makefile.common | 1 +
 2 files changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index 58be93f08..73ca2f931 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -15,6 +15,7 @@ 
 #include <devicetree.h>
 #include <alloc.h>
 #include <alloc_phys.h>
+#include <alloc_page.h>
 #include <argv.h>
 #include <asm/setup.h>
 #include <asm/page.h>
@@ -133,6 +134,7 @@  static void mem_init(phys_addr_t freemem_start)
 		.start = (phys_addr_t)-1,
 	};
 	int nr_regs, i;
+	phys_addr_t base, top;
 
 	nr_regs = dt_get_memory_params(regs, NR_MEM_REGIONS);
 	assert(nr_regs > 0);
@@ -170,6 +172,12 @@  static void mem_init(phys_addr_t freemem_start)
 	phys_alloc_init(freemem_start, primary.end - freemem_start);
 	phys_alloc_set_minimum_alignment(__icache_bytes > __dcache_bytes
 					 ? __icache_bytes : __dcache_bytes);
+
+	phys_alloc_get_unused(&base, &top);
+	base = PAGE_ALIGN(base);
+	top &= PAGE_MASK;
+	page_alloc_init_area(0, base >> PAGE_SHIFT, top >> PAGE_SHIFT);
+	page_alloc_ops_enable();
 }
 
 #define EXCEPTION_STACK_SIZE	SZ_64K
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index 68165fc25..6374418d2 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -38,6 +38,7 @@  cflatobjs += lib/util.o
 cflatobjs += lib/getchar.o
 cflatobjs += lib/alloc_phys.o
 cflatobjs += lib/alloc.o
+cflatobjs += lib/alloc_page.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/migrate.o
 cflatobjs += lib/powerpc/io.o