[RFC PATCH part-1 3/5] pkvm: arm64: Move page allocator to virt/kvm/pkvm

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

 



Create virt/kvm/pkvm to hold arch agnostic files. First set of
files moved to this directory are related to page allocator.
As memory.h is too general which may also be used by pKVM in
the future, and here it's only for buddy page allocator, rename
it to buddy_memory.h.

Signed-off-by: Jason Chen CJ <jason.cj.chen@xxxxxxxxx>
---
 arch/arm64/kvm/Makefile                                   | 1 +
 arch/arm64/kvm/hyp/hyp-constants.c                        | 2 +-
 arch/arm64/kvm/hyp/include/nvhe/mm.h                      | 2 +-
 arch/arm64/kvm/hyp/include/nvhe/pkvm.h                    | 2 +-
 arch/arm64/kvm/hyp/nvhe/Makefile                          | 4 +++-
 arch/arm64/kvm/hyp/nvhe/early_alloc.c                     | 2 +-
 arch/arm64/kvm/hyp/nvhe/mem_protect.c                     | 4 ++--
 arch/arm64/kvm/hyp/nvhe/mm.c                              | 4 ++--
 arch/arm64/kvm/hyp/nvhe/pkvm.c                            | 2 +-
 arch/arm64/kvm/hyp/nvhe/psci-relay.c                      | 2 +-
 arch/arm64/kvm/hyp/nvhe/setup.c                           | 4 ++--
 .../include/nvhe/memory.h => virt/kvm/pkvm/buddy_memory.h | 6 +++---
 {arch/arm64/kvm/hyp/include/nvhe => virt/kvm/pkvm}/gfp.h  | 8 ++++----
 {arch/arm64/kvm/hyp/nvhe => virt/kvm/pkvm}/page_alloc.c   | 2 +-
 14 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile
index 5e33c2d4645a..119b074b001a 100644
--- a/arch/arm64/kvm/Makefile
+++ b/arch/arm64/kvm/Makefile
@@ -31,6 +31,7 @@ define rule_gen_hyp_constants
 endef
 
 CFLAGS_hyp-constants.o = -I $(srctree)/$(src)/hyp/include
+CFLAGS_hyp-constants.o += -I $(srctree)/virt/kvm/pkvm
 $(obj)/hyp-constants.s: $(src)/hyp/hyp-constants.c FORCE
 	$(call if_changed_dep,cc_s_c)
 
diff --git a/arch/arm64/kvm/hyp/hyp-constants.c b/arch/arm64/kvm/hyp/hyp-constants.c
index b257a3b4bfc5..6127969cb182 100644
--- a/arch/arm64/kvm/hyp/hyp-constants.c
+++ b/arch/arm64/kvm/hyp/hyp-constants.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <linux/kbuild.h>
-#include <nvhe/memory.h>
+#include <buddy_memory.h>
 #include <nvhe/pkvm.h>
 
 int main(void)
diff --git a/arch/arm64/kvm/hyp/include/nvhe/mm.h b/arch/arm64/kvm/hyp/include/nvhe/mm.h
index 1d50bb1da315..1a955b16c06b 100644
--- a/arch/arm64/kvm/hyp/include/nvhe/mm.h
+++ b/arch/arm64/kvm/hyp/include/nvhe/mm.h
@@ -7,7 +7,7 @@
 #include <linux/memblock.h>
 #include <linux/types.h>
 
-#include <nvhe/memory.h>
+#include <buddy_memory.h>
 #include <asm/pkvm_spinlock.h>
 
 extern struct kvm_pgtable pkvm_pgtable;
diff --git a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h
index 992d3492297b..4e713e3c4daa 100644
--- a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h
+++ b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h
@@ -9,7 +9,7 @@
 
 #include <asm/kvm_pkvm.h>
 
-#include <nvhe/gfp.h>
+#include <gfp.h>
 #include <asm/pkvm_spinlock.h>
 
 /*
diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile
index 530347cdebe3..6cda2cb9b500 100644
--- a/arch/arm64/kvm/hyp/nvhe/Makefile
+++ b/arch/arm64/kvm/hyp/nvhe/Makefile
@@ -13,6 +13,7 @@ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS -D__DISABLE_TRACE_MMI
 ccflags-y += -fno-stack-protector	\
 	     -DDISABLE_BRANCH_PROFILING	\
 	     $(DISABLE_STACKLEAK_PLUGIN)
+ccflags-y += -I $(srctree)/virt/kvm/pkvm
 
 hostprogs := gen-hyprel
 HOST_EXTRACFLAGS += -I$(objtree)/include
@@ -21,10 +22,11 @@ lib-objs := clear_page.o copy_page.o memcpy.o memset.o
 lib-objs := $(addprefix ../../../lib/, $(lib-objs))
 
 hyp-obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o \
-	 hyp-main.o hyp-smp.o psci-relay.o early_alloc.o page_alloc.o \
+	 hyp-main.o hyp-smp.o psci-relay.o early_alloc.o \
 	 cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o
 hyp-obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \
 	 ../fpsimd.o ../hyp-entry.o ../exception.o ../pgtable.o
+hyp-obj-y += ../../../../../virt/kvm/pkvm/page_alloc.o
 hyp-obj-$(CONFIG_DEBUG_LIST) += list_debug.o
 hyp-obj-y += $(lib-objs)
 
diff --git a/arch/arm64/kvm/hyp/nvhe/early_alloc.c b/arch/arm64/kvm/hyp/nvhe/early_alloc.c
index 00de04153cc6..be1e72cdcbce 100644
--- a/arch/arm64/kvm/hyp/nvhe/early_alloc.c
+++ b/arch/arm64/kvm/hyp/nvhe/early_alloc.c
@@ -7,7 +7,7 @@
 #include <asm/kvm_pgtable.h>
 
 #include <nvhe/early_alloc.h>
-#include <nvhe/memory.h>
+#include <buddy_memory.h>
 
 struct kvm_pgtable_mm_ops hyp_early_alloc_mm_ops;
 s64 __ro_after_init hyp_physvirt_offset;
diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
index 552653fa18be..183ae39d2571 100644
--- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
+++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
@@ -14,8 +14,8 @@
 
 #include <hyp/fault.h>
 
-#include <nvhe/gfp.h>
-#include <nvhe/memory.h>
+#include <gfp.h>
+#include <buddy_memory.h>
 #include <nvhe/mem_protect.h>
 #include <nvhe/mm.h>
 
diff --git a/arch/arm64/kvm/hyp/nvhe/mm.c b/arch/arm64/kvm/hyp/nvhe/mm.c
index 9f740e441bce..ca556bb72a90 100644
--- a/arch/arm64/kvm/hyp/nvhe/mm.c
+++ b/arch/arm64/kvm/hyp/nvhe/mm.c
@@ -12,8 +12,8 @@
 #include <asm/spectre.h>
 
 #include <nvhe/early_alloc.h>
-#include <nvhe/gfp.h>
-#include <nvhe/memory.h>
+#include <gfp.h>
+#include <buddy_memory.h>
 #include <nvhe/mem_protect.h>
 #include <nvhe/mm.h>
 #include <asm/pkvm_spinlock.h>
diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
index a06ece14a6d8..75a019345ab5 100644
--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
@@ -8,7 +8,7 @@
 #include <linux/mm.h>
 #include <nvhe/fixed_config.h>
 #include <nvhe/mem_protect.h>
-#include <nvhe/memory.h>
+#include <buddy_memory.h>
 #include <nvhe/pkvm.h>
 #include <nvhe/trap_handler.h>
 
diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c
index 08508783ec3d..1c757bd02d4d 100644
--- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c
+++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c
@@ -11,7 +11,7 @@
 #include <linux/kvm_host.h>
 #include <uapi/linux/psci.h>
 
-#include <nvhe/memory.h>
+#include <buddy_memory.h>
 #include <nvhe/trap_handler.h>
 
 void kvm_hyp_cpu_entry(unsigned long r0);
diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c
index 110f04627785..395affd81421 100644
--- a/arch/arm64/kvm/hyp/nvhe/setup.c
+++ b/arch/arm64/kvm/hyp/nvhe/setup.c
@@ -12,8 +12,8 @@
 
 #include <nvhe/early_alloc.h>
 #include <nvhe/fixed_config.h>
-#include <nvhe/gfp.h>
-#include <nvhe/memory.h>
+#include <gfp.h>
+#include <buddy_memory.h>
 #include <nvhe/mem_protect.h>
 #include <nvhe/mm.h>
 #include <nvhe/pkvm.h>
diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/virt/kvm/pkvm/buddy_memory.h
similarity index 94%
rename from arch/arm64/kvm/hyp/include/nvhe/memory.h
rename to virt/kvm/pkvm/buddy_memory.h
index e7d05f41ddf2..b961cb7ac28f 100644
--- a/arch/arm64/kvm/hyp/include/nvhe/memory.h
+++ b/virt/kvm/pkvm/buddy_memory.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __KVM_HYP_MEMORY_H
-#define __KVM_HYP_MEMORY_H
+#ifndef __PKVM_BUDDY_MEMORY_H
+#define __PKVM_BUDDY_MEMORY_H
 
 #include <asm/kvm_pkvm.h>
 #include <asm/page.h>
@@ -70,4 +70,4 @@ static inline void hyp_set_page_refcounted(struct hyp_page *p)
 	BUG_ON(p->refcount);
 	p->refcount = 1;
 }
-#endif /* __KVM_HYP_MEMORY_H */
+#endif /* __PKVM_BUDDY_MEMORY_H */
diff --git a/arch/arm64/kvm/hyp/include/nvhe/gfp.h b/virt/kvm/pkvm/gfp.h
similarity index 89%
rename from arch/arm64/kvm/hyp/include/nvhe/gfp.h
rename to virt/kvm/pkvm/gfp.h
index 58e9f15b6a64..1c3ff697efea 100644
--- a/arch/arm64/kvm/hyp/include/nvhe/gfp.h
+++ b/virt/kvm/pkvm/gfp.h
@@ -1,10 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __KVM_HYP_GFP_H
-#define __KVM_HYP_GFP_H
+#ifndef __PKVM_GFP_H
+#define __PKVM_GFP_H
 
 #include <linux/list.h>
 
-#include <nvhe/memory.h>
+#include <buddy_memory.h>
 #include <asm/pkvm_spinlock.h>
 
 #define HYP_NO_ORDER	USHRT_MAX
@@ -31,4 +31,4 @@ void hyp_put_page(struct hyp_pool *pool, void *addr);
 /* Used pages cannot be freed */
 int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,
 		  unsigned int reserved_pages);
-#endif /* __KVM_HYP_GFP_H */
+#endif /* __PKVM_GFP_H */
diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/virt/kvm/pkvm/page_alloc.c
similarity index 99%
rename from arch/arm64/kvm/hyp/nvhe/page_alloc.c
rename to virt/kvm/pkvm/page_alloc.c
index ef164102ab6a..a090ccba7717 100644
--- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c
+++ b/virt/kvm/pkvm/page_alloc.c
@@ -4,7 +4,7 @@
  * Author: Quentin Perret <qperret@xxxxxxxxxx>
  */
 
-#include <nvhe/gfp.h>
+#include <gfp.h>
 
 u64 __hyp_vmemmap;
 
-- 
2.25.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux