[RFC PATCH part-6 01/13] pkvm: x86: Pre-define the maximum number of supported VMs

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

 



From: Chuanxiao Dong <chuanxiao.dong@xxxxxxxxx>

Define the maximum number of the VMs pKVM can support. pKVM needs
reserve related memory based on the VM number it support (e.g., shadow
EPT page table pages). The reserved memory size for pKVM is calculated
then exposed to pkvm_init through pkvm_constants definition
PKVM_MAX_VM_NUM.

Signed-off-by: Chuanxiao Dong <chuanxiao.dong@xxxxxxxxx>
---
 arch/x86/kvm/vmx/pkvm/hyp/pkvm.c       | 2 +-
 arch/x86/kvm/vmx/pkvm/hyp/pkvm_hyp.h   | 3 +++
 arch/x86/kvm/vmx/pkvm/pkvm_constants.c | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/pkvm/hyp/pkvm.c b/arch/x86/kvm/vmx/pkvm/hyp/pkvm.c
index 9efedba2b3c9..25904252d2dd 100644
--- a/arch/x86/kvm/vmx/pkvm/hyp/pkvm.c
+++ b/arch/x86/kvm/vmx/pkvm/hyp/pkvm.c
@@ -10,7 +10,7 @@
 
 struct pkvm_hyp *pkvm_hyp;
 
-#define MAX_SHADOW_VMS	255
+#define MAX_SHADOW_VMS	(PKVM_MAX_NORMAL_VM_NUM + PKVM_MAX_PROTECTED_VM_NUM)
 #define HANDLE_OFFSET 1
 
 #define to_shadow_vm_handle(vcpu_handle)	((s64)(vcpu_handle) >> SHADOW_VM_HANDLE_SHIFT)
diff --git a/arch/x86/kvm/vmx/pkvm/hyp/pkvm_hyp.h b/arch/x86/kvm/vmx/pkvm/hyp/pkvm_hyp.h
index 82a59b5d7fd5..b7c3f8c478b4 100644
--- a/arch/x86/kvm/vmx/pkvm/hyp/pkvm_hyp.h
+++ b/arch/x86/kvm/vmx/pkvm/hyp/pkvm_hyp.h
@@ -7,6 +7,9 @@
 
 #include <asm/pkvm_spinlock.h>
 
+#define PKVM_MAX_NORMAL_VM_NUM		8
+#define PKVM_MAX_PROTECTED_VM_NUM	2
+
 /*
  * A container for the vcpu state that hyp needs to maintain for protected VMs.
  */
diff --git a/arch/x86/kvm/vmx/pkvm/pkvm_constants.c b/arch/x86/kvm/vmx/pkvm/pkvm_constants.c
index c6dc35b52664..6222a8fff6af 100644
--- a/arch/x86/kvm/vmx/pkvm/pkvm_constants.c
+++ b/arch/x86/kvm/vmx/pkvm/pkvm_constants.c
@@ -15,5 +15,6 @@ int main(void)
 	DEFINE(PKVM_VMEMMAP_ENTRY_SIZE, sizeof(struct hyp_page));
 	DEFINE(PKVM_SHADOW_VM_SIZE, sizeof(struct pkvm_shadow_vm) + pkvm_shadow_vcpu_array_size());
 	DEFINE(PKVM_SHADOW_VCPU_STATE_SIZE, sizeof(struct shadow_vcpu_state));
+	DEFINE(PKVM_MAX_VM_NUM, PKVM_MAX_NORMAL_VM_NUM + PKVM_MAX_PROTECTED_VM_NUM);
 	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