forked from rpms/qemu-kvm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.3 KiB
86 lines
3.3 KiB
3 months ago
|
From be37914ae54c8aebc218cf41b37bc0ea1563daae Mon Sep 17 00:00:00 2001
|
||
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
Date: Fri, 31 May 2024 12:51:44 +0200
|
||
|
Subject: [PATCH 074/100] i386/sev: Invoke launch_updata_data() for SEV class
|
||
|
|
||
|
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
RH-MergeRequest: 245: SEV-SNP support
|
||
|
RH-Jira: RHEL-39544
|
||
|
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
||
|
RH-Acked-by: Bandan Das <bdas@redhat.com>
|
||
|
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
||
|
RH-Commit: [74/91] f1b588a9ffecd6944a78186d88a6be3849698710 (bonzini/rhel-qemu-kvm)
|
||
|
|
||
|
Add launch_update_data() in SevCommonStateClass and
|
||
|
invoke as sev_launch_update_data() for SEV object.
|
||
|
|
||
|
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
|
||
|
Message-ID: <20240530111643.1091816-26-pankaj.gupta@amd.com>
|
||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
(cherry picked from commit 9861405a8f845133b7984322c2df0c43a45553c3)
|
||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
---
|
||
|
target/i386/sev.c | 11 ++++++++---
|
||
|
1 file changed, 8 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/target/i386/sev.c b/target/i386/sev.c
|
||
|
index 7b5c4b4874..8834cf9441 100644
|
||
|
--- a/target/i386/sev.c
|
||
|
+++ b/target/i386/sev.c
|
||
|
@@ -74,6 +74,7 @@ struct SevCommonStateClass {
|
||
|
/* public */
|
||
|
int (*launch_start)(SevCommonState *sev_common);
|
||
|
void (*launch_finish)(SevCommonState *sev_common);
|
||
|
+ int (*launch_update_data)(SevCommonState *sev_common, hwaddr gpa, uint8_t *ptr, uint64_t len);
|
||
|
int (*kvm_init)(ConfidentialGuestSupport *cgs, Error **errp);
|
||
|
};
|
||
|
|
||
|
@@ -929,7 +930,7 @@ out:
|
||
|
}
|
||
|
|
||
|
static int
|
||
|
-sev_launch_update_data(SevGuestState *sev_guest, uint8_t *addr, uint64_t len)
|
||
|
+sev_launch_update_data(SevCommonState *sev_common, hwaddr gpa, uint8_t *addr, uint64_t len)
|
||
|
{
|
||
|
int ret, fw_error;
|
||
|
struct kvm_sev_launch_update_data update;
|
||
|
@@ -941,7 +942,7 @@ sev_launch_update_data(SevGuestState *sev_guest, uint8_t *addr, uint64_t len)
|
||
|
update.uaddr = (uintptr_t)addr;
|
||
|
update.len = len;
|
||
|
trace_kvm_sev_launch_update_data(addr, len);
|
||
|
- ret = sev_ioctl(SEV_COMMON(sev_guest)->sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA,
|
||
|
+ ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA,
|
||
|
&update, &fw_error);
|
||
|
if (ret) {
|
||
|
error_report("%s: LAUNCH_UPDATE ret=%d fw_error=%d '%s'",
|
||
|
@@ -1487,6 +1488,7 @@ int
|
||
|
sev_encrypt_flash(hwaddr gpa, uint8_t *ptr, uint64_t len, Error **errp)
|
||
|
{
|
||
|
SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs);
|
||
|
+ SevCommonStateClass *klass = SEV_COMMON_GET_CLASS(sev_common);
|
||
|
|
||
|
if (!sev_common) {
|
||
|
return 0;
|
||
|
@@ -1494,7 +1496,9 @@ sev_encrypt_flash(hwaddr gpa, uint8_t *ptr, uint64_t len, Error **errp)
|
||
|
|
||
|
/* if SEV is in update state then encrypt the data else do nothing */
|
||
|
if (sev_check_state(sev_common, SEV_STATE_LAUNCH_UPDATE)) {
|
||
|
- int ret = sev_launch_update_data(SEV_GUEST(sev_common), ptr, len);
|
||
|
+ int ret;
|
||
|
+
|
||
|
+ ret = klass->launch_update_data(sev_common, gpa, ptr, len);
|
||
|
if (ret < 0) {
|
||
|
error_setg(errp, "SEV: Failed to encrypt pflash rom");
|
||
|
return ret;
|
||
|
@@ -1968,6 +1972,7 @@ sev_guest_class_init(ObjectClass *oc, void *data)
|
||
|
|
||
|
klass->launch_start = sev_launch_start;
|
||
|
klass->launch_finish = sev_launch_finish;
|
||
|
+ klass->launch_update_data = sev_launch_update_data;
|
||
|
klass->kvm_init = sev_kvm_init;
|
||
|
x86_klass->kvm_type = sev_kvm_type;
|
||
|
|
||
|
--
|
||
|
2.39.3
|
||
|
|