Skip to contentSkip to conversation

KVM: SEV-ES: Set guest_state_protected after VMSA update

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 15, 2021 – Oct 18, 2021

Subsystems (3)
lore
Share & tools
lore

Paolo Bonzini

author maintainer
#0 lore raw

PATCH 1/1 KVM: SEV-ES: Set guest_state_protected after VMSA update

From: Peter Gonda <[email protected]>

The refactoring in commit bb18a6777465 ("KVM: SEV: Acquire vcpu mutex when updating VMSA") left behind the assignment to svm->vcpu.arch.guest_state_protected; add it back.

[Delta between v2 and v3 of Peter's patch, which had already been
committed; the commit message is my own. - Paolo]

---
 arch/x86/kvm/svm/sev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/sev.c +6 -1
index e672493b5d8d..0d21d59936e5 100644
@@ -618,7 +618,12 @@ static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu,
 	vmsa.handle = to_kvm_svm(kvm)->sev_info.handle;
 	vmsa.address = __sme_pa(svm->vmsa);
 	vmsa.len = PAGE_SIZE;
-	return sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error);
+	ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error);
+	if (ret)
+	  return ret;
+
+	vcpu->arch.guest_state_protected = true;
+	return 0;
 }
 
 static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp)
Signature · 1 line
2.27.0
#1 lore raw
Quoted 19 lines · Paolo Bonzini

From: Peter Gonda <[email protected]>

The refactoring in commit bb18a6777465 ("KVM: SEV: Acquire vcpu mutex when updating VMSA") left behind the assignment to svm->vcpu.arch.guest_state_protected; add it back.

[Delta between v2 and v3 of Peter's patch, which had already been
committed; the commit message is my own. - Paolo]

---
 arch/x86/kvm/svm/sev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/sev.c +0 -0
index e672493b5d8d..0d21d59936e5 100644

arch/x86/kvm/svm/sev.c static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu, · line 623

Quoted 7 lines
arch/x86/kvm/svm/sev.c +3 -1
@@ -618,7 +618,12 @@ static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu,
 	vmsa.handle = to_kvm_svm(kvm)->sev_info.handle;
 	vmsa.address = __sme_pa(svm->vmsa);
 	vmsa.len = PAGE_SIZE;
-	return sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error);
+	ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error);
+	if (ret)
+	  return ret;

Bad indentation.

Quoted 9 lines
arch/x86/kvm/svm/sev.c +3 -0
+
+	vcpu->arch.guest_state_protected = true;
+	return 0;
 }
 
 static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp)
Signature · 1 line
2.27.0