Skip to content

Commit 92e7d5c

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: allow L1 to not intercept triple fault
This is SVM correctness fix - although a sane L1 would intercept SHUTDOWN event, it doesn't have to, so we have to honour this. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20221103141351.50662-8-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 0bd2d3f commit 92e7d5c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,12 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
10911091

10921092
static void nested_svm_triple_fault(struct kvm_vcpu *vcpu)
10931093
{
1094+
struct vcpu_svm *svm = to_svm(vcpu);
1095+
1096+
if (!vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_SHUTDOWN))
1097+
return;
1098+
1099+
kvm_clear_request(KVM_REQ_TRIPLE_FAULT, vcpu);
10941100
nested_svm_simple_vmexit(to_svm(vcpu), SVM_EXIT_SHUTDOWN);
10951101
}
10961102

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4854,6 +4854,7 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
48544854

48554855
static void nested_vmx_triple_fault(struct kvm_vcpu *vcpu)
48564856
{
4857+
kvm_clear_request(KVM_REQ_TRIPLE_FAULT, vcpu);
48574858
nested_vmx_vmexit(vcpu, EXIT_REASON_TRIPLE_FAULT, 0, 0);
48584859
}
48594860

arch/x86/kvm/x86.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9811,7 +9811,7 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu)
98119811

98129812
int kvm_check_nested_events(struct kvm_vcpu *vcpu)
98139813
{
9814-
if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
9814+
if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
98159815
kvm_x86_ops.nested_ops->triple_fault(vcpu);
98169816
return 1;
98179817
}
@@ -10566,15 +10566,16 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1056610566
r = 0;
1056710567
goto out;
1056810568
}
10569-
if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
10570-
if (is_guest_mode(vcpu)) {
10569+
if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
10570+
if (is_guest_mode(vcpu))
1057110571
kvm_x86_ops.nested_ops->triple_fault(vcpu);
10572-
} else {
10572+
10573+
if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) {
1057310574
vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;
1057410575
vcpu->mmio_needed = 0;
1057510576
r = 0;
10576-
goto out;
1057710577
}
10578+
goto out;
1057810579
}
1057910580
if (kvm_check_request(KVM_REQ_APF_HALT, vcpu)) {
1058010581
/* Page is swapped out. Do synthetic halt */

0 commit comments

Comments
 (0)