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