Skip to content

Commit 8d1a36e

Browse files
mdrothbonzini
authored andcommitted
KVM: SEV: Add GHCB handling for termination requests
GHCB version 2 adds support for a GHCB-based termination request that a guest can issue when it reaches an error state and wishes to inform the hypervisor that it should be terminated. Implement support for that similarly to GHCB MSR-based termination requests that are already available to SEV-ES guests via earlier versions of the GHCB protocol. See 'Termination Request' in the 'Invoking VMGEXIT' section of the GHCB specification for more details. Signed-off-by: Michael Roth <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ae01818 commit 8d1a36e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm)
27042704
case SVM_VMGEXIT_AP_JUMP_TABLE:
27052705
case SVM_VMGEXIT_UNSUPPORTED_EVENT:
27062706
case SVM_VMGEXIT_HV_FEATURES:
2707+
case SVM_VMGEXIT_TERM_REQUEST:
27072708
break;
27082709
default:
27092710
reason = GHCB_ERR_INVALID_EVENT;
@@ -3099,6 +3100,14 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
30993100

31003101
ret = 1;
31013102
break;
3103+
case SVM_VMGEXIT_TERM_REQUEST:
3104+
pr_info("SEV-ES guest requested termination: reason %#llx info %#llx\n",
3105+
control->exit_info_1, control->exit_info_2);
3106+
vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
3107+
vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SEV_TERM;
3108+
vcpu->run->system_event.ndata = 1;
3109+
vcpu->run->system_event.data[0] = control->ghcb_gpa;
3110+
break;
31023111
case SVM_VMGEXIT_UNSUPPORTED_EVENT:
31033112
vcpu_unimpl(vcpu,
31043113
"vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",

0 commit comments

Comments
 (0)