[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 24/49] target/i386: Add handling for KVM_X86_SNP_VM VM type
From: |
Michael Roth |
Subject: |
[PATCH v3 24/49] target/i386: Add handling for KVM_X86_SNP_VM VM type |
Date: |
Wed, 20 Mar 2024 03:39:20 -0500 |
An SNP VM requires VM type KVM_X86_SNP_VM to be passed to
kvm_ioctl(KVM_CREATE_VM). Add it to the list of supported VM types, and
return it appropriately via X86ConfidentialGuestClass->kvm_type().
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
target/i386/kvm/kvm.c | 1 +
target/i386/sev.c | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index e109648f26..59e9048e61 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -164,6 +164,7 @@ static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t
*value);
static const char *vm_type_name[] = {
[KVM_X86_DEFAULT_VM] = "default",
+ [KVM_X86_SNP_VM] = "snp"
};
bool kvm_is_vm_type_supported(int type)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 2eb13ba639..61af312a11 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -853,14 +853,20 @@ sev_vm_state_change(void *opaque, bool running, RunState
state)
static int sev_kvm_type(X86ConfidentialGuest *cg)
{
SevCommonState *sev_common = SEV_COMMON(cg);
- SevGuestState *sev_guest = SEV_GUEST(sev_common);
int kvm_type;
if (sev_common->kvm_type != -1) {
goto out;
}
- kvm_type = (sev_guest->policy & SEV_POLICY_ES) ? KVM_X86_SEV_ES_VM :
KVM_X86_SEV_VM;
+ if (sev_snp_enabled()) {
+ kvm_type = KVM_X86_SNP_VM;
+ } else if (sev_es_enabled()) {
+ kvm_type = KVM_X86_SEV_ES_VM;
+ } else {
+ kvm_type = KVM_X86_SEV_VM;
+ }
+
if (kvm_is_vm_type_supported(kvm_type)) {
sev_common->kvm_type = kvm_type;
} else {
--
2.25.1
- Re: [PATCH v3 21/49] i386/sev: Introduce "sev-common" type to encapsulate common SEV state, (continued)
- [PATCH v3 22/49] i386/sev: Introduce 'sev-snp-guest' object, Michael Roth, 2024/03/20
- [PATCH v3 23/49] i386/sev: Add a sev_snp_enabled() helper, Michael Roth, 2024/03/20
- [PATCH v3 24/49] target/i386: Add handling for KVM_X86_SNP_VM VM type,
Michael Roth <=
- [PATCH v3 25/49] i386/sev: Skip RAMBlock notifiers for SNP, Michael Roth, 2024/03/20
- [PATCH v3 26/49] i386/sev: Skip machine-init-done notifiers for SNP, Michael Roth, 2024/03/20
- [PATCH v3 27/49] i386/sev: Set ms->require_guest_memfd for SNP, Michael Roth, 2024/03/20
- [PATCH v3 28/49] i386/sev: Disable SMM for SNP, Michael Roth, 2024/03/20
- [PATCH v3 29/49] i386/sev: Don't disable block discarding for SNP, Michael Roth, 2024/03/20