Compile in buddy page allocator for pKVM on Intel platform, to support its own page allocation. Signed-off-by: Jason Chen CJ <jason.cj.chen@xxxxxxxxx> --- arch/x86/include/asm/kvm_pkvm.h | 5 +++++ arch/x86/include/asm/pkvm_spinlock.h | 9 +++++++++ arch/x86/kvm/vmx/pkvm/hyp/Makefile | 5 +++++ virt/kvm/pkvm/gfp.h | 1 + 4 files changed, 20 insertions(+) diff --git a/arch/x86/include/asm/kvm_pkvm.h b/arch/x86/include/asm/kvm_pkvm.h index 224143567aaa..480051f28ebc 100644 --- a/arch/x86/include/asm/kvm_pkvm.h +++ b/arch/x86/include/asm/kvm_pkvm.h @@ -13,6 +13,11 @@ unsigned long pkvm_virt_to_phys(void *virt); #define __pkvm_pa(virt) pkvm_virt_to_phys((void *)(virt)) #define __pkvm_va(phys) pkvm_phys_to_virt((unsigned long)(phys)) + +/*TODO: unify the API name: __pkvm vs. __hyp? */ +#define __hyp_pa __pkvm_pa +#define __hyp_va __pkvm_va + #endif #endif diff --git a/arch/x86/include/asm/pkvm_spinlock.h b/arch/x86/include/asm/pkvm_spinlock.h index 1af9c1243576..e105402c695f 100644 --- a/arch/x86/include/asm/pkvm_spinlock.h +++ b/arch/x86/include/asm/pkvm_spinlock.h @@ -61,4 +61,13 @@ static inline void pkvm_spin_unlock(pkvm_spinlock_t *lock) } +/* + * Redefine for virt/kvm/pkvm/page_alloc.c usage + * TODO: unify the API name: pkvm_ vs. hyp_ ? + */ +#define hyp_spinlock_t pkvm_spinlock_t +#define hyp_spin_lock_init pkvm_spin_lock_init +#define hyp_spin_lock pkvm_spin_lock +#define hyp_spin_unlock pkvm_spin_unlock + #endif diff --git a/arch/x86/kvm/vmx/pkvm/hyp/Makefile b/arch/x86/kvm/vmx/pkvm/hyp/Makefile index f659debf4d76..578d6955a1d1 100644 --- a/arch/x86/kvm/vmx/pkvm/hyp/Makefile +++ b/arch/x86/kvm/vmx/pkvm/hyp/Makefile @@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 +KVM_PKVM = virt/kvm/pkvm + +ccflags-y += -I $(srctree)/$(KVM_PKVM)/ ccflags-y += -I $(srctree)/arch/x86/kvm ccflags-y += -I $(srctree)/arch/x86/kvm/vmx/pkvm/include ccflags-y += -fno-stack-protector @@ -7,12 +10,14 @@ ccflags-y += -D__DISABLE_EXPORTS ccflags-y += -D__PKVM_HYP__ lib-dir := lib +virt-dir := ../../../../../../$(KVM_PKVM) pkvm-hyp-y := vmx_asm.o vmexit.o memory.o pkvm-hyp-y += $(lib-dir)/memset_64.o pkvm-hyp-$(CONFIG_RETPOLINE) += $(lib-dir)/retpoline.o pkvm-hyp-$(CONFIG_DEBUG_LIST) += $(lib-dir)/list_debug.o +pkvm-hyp-y += $(virt-dir)/page_alloc.o pkvm-obj := $(patsubst %.o,%.pkvm.o,$(pkvm-hyp-y)) obj-$(CONFIG_PKVM_INTEL) += pkvm.o diff --git a/virt/kvm/pkvm/gfp.h b/virt/kvm/pkvm/gfp.h index 1c3ff697efea..38015b4ec231 100644 --- a/virt/kvm/pkvm/gfp.h +++ b/virt/kvm/pkvm/gfp.h @@ -2,6 +2,7 @@ #ifndef __PKVM_GFP_H #define __PKVM_GFP_H +#include <linux/mmzone.h> #include <linux/list.h> #include <buddy_memory.h> -- 2.25.1