From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] KVM: x86: Fully re-initialize supported_vm_types on vendor module load
Date: Tue, 23 Apr 2024 09:53:26 -0700 [thread overview]
Message-ID: <20240423165328.2853870-2-seanjc@google.com> (raw)
In-Reply-To: <20240423165328.2853870-1-seanjc@google.com>
Recompute the entire set of supported VM types when a vendor module is
loaded, as preserving supported_vm_types across vendor module unload and
reload can result in VM types being incorrectly treated as supported.
E.g. if a vendor module is loaded with TDP enabled, unloaded, and then
reloaded with TDP disabled, KVM_X86_SW_PROTECTED_VM will be incorrectly
retained. Ditto for SEV_VM and SEV_ES_VM and their respective module
params in kvm-amd.ko.
Fixes: 2a955c4db1dd ("KVM: x86: Add supported_vm_types to kvm_caps")
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/x86.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2d2619d3eee4..a65a1012d878 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -94,7 +94,6 @@
struct kvm_caps kvm_caps __read_mostly = {
.supported_mce_cap = MCG_CTL_P | MCG_SER_P,
- .supported_vm_types = BIT(KVM_X86_DEFAULT_VM),
};
EXPORT_SYMBOL_GPL(kvm_caps);
@@ -9776,6 +9775,8 @@ int kvm_x86_vendor_init(struct kvm_x86_init_ops *ops)
if (r)
goto out_free_percpu;
+ kvm_caps.supported_vm_types = BIT(KVM_X86_DEFAULT_VM);
+
if (boot_cpu_has(X86_FEATURE_XSAVE)) {
host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
kvm_caps.supported_xcr0 = host_xcr0 & KVM_SUPPORTED_XCR0;
--
2.44.0.769.g3c40516874-goog
next prev parent reply other threads:[~2024-04-23 16:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 16:53 [PATCH 0/3] KVM: x86: Fix supported VM_TYPES caps Sean Christopherson
2024-04-23 16:53 ` Sean Christopherson [this message]
2024-04-23 16:53 ` [PATCH 2/3] KVM: x86: Fully re-initialize supported_mce_cap on vendor module load Sean Christopherson
2024-04-23 16:53 ` [PATCH 3/3] KVM: x86: Explicitly zero kvm_caps during " Sean Christopherson
2024-04-24 3:25 ` Huang, Kai
2024-04-24 15:33 ` Sean Christopherson
2024-04-25 10:07 ` Huang, Kai
2024-04-25 13:43 ` [PATCH 0/3] KVM: x86: Fix supported VM_TYPES caps Xiaoyao Li
2024-04-25 14:30 ` Sean Christopherson
2024-04-26 1:17 ` Huang, Kai
2024-04-26 15:47 ` Sean Christopherson
2024-04-29 2:45 ` Huang, Kai
2024-04-29 15:56 ` Sean Christopherson
2024-05-07 17:20 ` Paolo Bonzini
2024-05-07 17:08 ` Paolo Bonzini
2024-05-10 14:50 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240423165328.2853870-2-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).