[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 35/49] i386/sev: Add KVM_EXIT_VMGEXIT handling for Page State
From: |
Michael Roth |
Subject: |
[PATCH v3 35/49] i386/sev: Add KVM_EXIT_VMGEXIT handling for Page State Changes (MSR-based) |
Date: |
Wed, 20 Mar 2024 03:39:31 -0500 |
SEV-SNP guests might issue MSR-based Page State Changes for situations
like early boot where it might not be easily able to make use of a GHCB
page to issue the request. Just as with GHCB-based Page State Changes,
these are forwarded to userspace as KVM_EXIT_VMGEXITs. Add handling for
these.
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
target/i386/sev.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 0c6a253138..b54422b28e 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -1560,6 +1560,18 @@ out_unmap:
return 0;
}
+static int kvm_handle_vmgexit_psc_msr_protocol(__u64 gpa, __u8 op, __u32
*psc_ret)
+{
+ int ret;
+
+ ret = kvm_convert_memory(gpa, TARGET_PAGE_SIZE,
+ op == KVM_USER_VMGEXIT_PSC_MSR_OP_PRIVATE);
+
+ *psc_ret = ret;
+
+ return ret;
+}
+
int kvm_handle_vmgexit(struct kvm_run *run)
{
int ret;
@@ -1567,6 +1579,10 @@ int kvm_handle_vmgexit(struct kvm_run *run)
if (run->vmgexit.type == KVM_USER_VMGEXIT_PSC) {
ret = kvm_handle_vmgexit_psc(run->vmgexit.psc.shared_gpa,
&run->vmgexit.psc.ret);
+ } else if (run->vmgexit.type == KVM_USER_VMGEXIT_PSC_MSR) {
+ ret = kvm_handle_vmgexit_psc_msr_protocol(run->vmgexit.psc_msr.gpa,
+ run->vmgexit.psc_msr.op,
+ &run->vmgexit.psc_msr.ret);
} else {
warn_report("KVM: unknown vmgexit type: %d", run->vmgexit.type);
ret = -1;
--
2.25.1
- [PATCH v3 02/49] scripts/update-linux-headers: Add setup_data.h to import list, (continued)
- [PATCH v3 02/49] scripts/update-linux-headers: Add setup_data.h to import list, Michael Roth, 2024/03/20
- [PATCH v3 31/49] i386/sev: Update query-sev QAPI format to handle SEV-SNP, Michael Roth, 2024/03/20
- [PATCH v3 32/49] i386/sev: Don't return launch measurements for SEV-SNP guests, Michael Roth, 2024/03/20
- [PATCH v3 33/49] kvm: Make kvm_convert_memory() non-static, Michael Roth, 2024/03/20
- [PATCH v3 34/49] i386/sev: Add KVM_EXIT_VMGEXIT handling for Page State Changes, Michael Roth, 2024/03/20
- [PATCH v3 35/49] i386/sev: Add KVM_EXIT_VMGEXIT handling for Page State Changes (MSR-based),
Michael Roth <=
- [PATCH v3 36/49] i386/sev: Add KVM_EXIT_VMGEXIT handling for Extended Guest Requests, Michael Roth, 2024/03/20
- [PATCH v3 37/49] i386/sev: Add the SNP launch start context, Michael Roth, 2024/03/20
- [PATCH v3 38/49] i386/sev: Add handling to encrypt/finalize guest launch data, Michael Roth, 2024/03/20
- [PATCH v3 39/49] i386/sev: Set CPU state to protected once SNP guest payload is finalized, Michael Roth, 2024/03/20
- [PATCH v3 40/49] hw/i386/sev: Add function to get SEV metadata from OVMF header, Michael Roth, 2024/03/20