[RFC PATCH part-3 05/22] pkvm: x86: Generate pkvm_constants.h for pKVM initialization

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

 



The pKVM runtime data structure is private in VMX root mode, it shall
not be exposed to host Linux. Meanwhile during pKVM initialization, host
need to allocate memory for pKVM based on such runtime data structure.

Generate pkvm_constants.h to provide constants such as structure size to
the pKVM init without dragging in the definitions themselves.

Signed-off-by: Shaoqin Huang <shaoqin.huang@xxxxxxxxx>
Signed-off-by: Jason Chen CJ <jason.cj.chen@xxxxxxxxx>
---
 arch/x86/kvm/.gitignore                |  1 +
 arch/x86/kvm/vmx/pkvm/Makefile         | 17 +++++++++++++++++
 arch/x86/kvm/vmx/pkvm/pkvm_constants.c | 15 +++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/arch/x86/kvm/.gitignore b/arch/x86/kvm/.gitignore
index 615d6ff35c00..04913dc233b1 100644
--- a/arch/x86/kvm/.gitignore
+++ b/arch/x86/kvm/.gitignore
@@ -1,2 +1,3 @@
 /kvm-asm-offsets.s
 /kvm-asm-offsets.h
+pkvm_constants.h
diff --git a/arch/x86/kvm/vmx/pkvm/Makefile b/arch/x86/kvm/vmx/pkvm/Makefile
index ed0629baf449..fa90a7375f6f 100644
--- a/arch/x86/kvm/vmx/pkvm/Makefile
+++ b/arch/x86/kvm/vmx/pkvm/Makefile
@@ -7,3 +7,20 @@ pkvm-obj		:= pkvm_host.o
 
 obj-$(CONFIG_PKVM_INTEL)	+= $(pkvm-obj)
 obj-$(CONFIG_PKVM_INTEL)	+= hyp/
+
+always-y := pkvm_constants.h pkvm-constants.s
+
+define rule_gen_hyp_constants
+        $(call filechk,offsets,__PKVM_CONSTANTS_H__)
+endef
+
+CFLAGS_pkvm-constants.o = -I $(src)/include
+CFLAGS_pkvm-constants.o += -I $(srctree)/virt/kvm/pkvm
+$(obj)/pkvm-constants.s: $(src)/pkvm_constants.c FORCE
+	        $(call if_changed_dep,cc_s_c)
+
+$(obj)/pkvm_constants.h: $(obj)/pkvm-constants.s FORCE
+	        $(call if_changed_rule,gen_hyp_constants)
+
+obj-intel-pkvm := $(addprefix $(obj)/, $(pkvm-obj))
+$(obj-intel-pkvm): $(obj)/pkvm_constants.h
diff --git a/arch/x86/kvm/vmx/pkvm/pkvm_constants.c b/arch/x86/kvm/vmx/pkvm/pkvm_constants.c
new file mode 100644
index 000000000000..729147e6b85f
--- /dev/null
+++ b/arch/x86/kvm/vmx/pkvm/pkvm_constants.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Intel Corporation
+ */
+
+#include <linux/kbuild.h>
+#include <linux/bug.h>
+#include <vdso/limits.h>
+#include <buddy_memory.h>
+
+int main(void)
+{
+	DEFINE(PKVM_VMEMMAP_ENTRY_SIZE, sizeof(struct hyp_page));
+	return 0;
+}
-- 
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