[RFC PATCH 4/5] x86/kvm: Add x86 field to find the default VMPL that IRQs should target

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

 



When a CPU supports multiple VMPLs, injected interrupts need to be sent
to the correct context. This commit adds an operation that determines
the VMPL number that IRQs should be sent to in the absence of an explicit
target VMPL.

Signed-off-by: Roy Hopkins <roy.hopkins@xxxxxxxx>
---
 arch/x86/include/asm/kvm_host.h | 7 +++++++
 arch/x86/kvm/svm/sev.c          | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 94e7b5a4fafe..3dd3a5ff0cec 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1537,6 +1537,13 @@ struct kvm_arch {
 	 */
 #define SPLIT_DESC_CACHE_MIN_NR_OBJECTS (SPTE_ENT_PER_PAGE + 1)
 	struct kvm_mmu_memory_cache split_desc_cache;
+
+	/*
+	 * When a system supports multiple VMPLs, injected interrupts need to be
+	 * sent to the correct context. The default VMPL that IRQs should be sent
+	 * to is indicated in this variable.
+	 */
+	unsigned int default_irq_vmpl;
 };
 
 struct kvm_vm_stat {
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 3fbb1ce5195d..ed91aa93da6e 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3983,6 +3983,14 @@ static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
 		 * means.
 		 */
 		kvm_release_pfn_clean(pfn);
+
+		/*
+		 * TEMP: If the newly created VMSA is for a lower VMPL then
+		 * set this VMPL to be the default for sending IRQs to.
+		 */
+		if (vcpu->vmpl > vcpu->kvm->arch.default_irq_vmpl) {
+			vcpu->kvm->arch.default_irq_vmpl = vcpu->vmpl;
+		}
 	}
 
 	return 0;
-- 
2.43.0





[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