[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d8eb94631cdd98196e81119f19b9a0cae9dddc3a.1726506534.git.roy.hopkins@suse.com>
Date: Mon, 16 Sep 2024 19:17:56 +0100
From: Roy Hopkins <roy.hopkins@...e.com>
To: kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
x86@...nel.org,
linux-coco@...ts.linux.dev
Cc: Roy Hopkins <roy.hopkins@...e.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Michael Roth <michael.roth@....com>,
Ashish Kalra <ashish.kalra@....com>,
Joerg Roedel <jroedel@...e.de>,
Tom Lendacky <thomas.lendacky@....com>
Subject: [RFC PATCH 4/5] x86/kvm: Add x86 field to find the default VMPL that IRQs should target
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@...e.com>
---
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
Powered by blists - more mailing lists