[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220402010903.727604-1-seanjc@google.com>
Date: Sat, 2 Apr 2022 01:08:55 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
"Maciej S . Szmigiero" <maciej.szmigiero@...cle.com>
Subject: [PATCH 0/8] KVM: SVM: Fix soft int/ex re-injection
This is a continuation/alternative of Maciej's series[*] to fix soft
interrupt/exception reinjection. The core difference is that this version
fixes the underlying issue of not doing proper reinjection, which
manifests most readily as the nested virtualization bugs Maciej's series
addressed.
The underlying issue is that SVM simply retries INT* instructions instead
of reinjecting the soft interupt/exception if an exception VM-Exit occurred
during vectoring. Lack of reinjection breaks nested virtualization if
the injected event came from L1 and the VM-Exit is not forwarded to L1,
as there is no instruction to retry. More fundamentally, retrying the
instruction is wrong as it can produce side effects that shouldn't occur,
e.g. code #DBs.
VMX has been fixed since commit 66fd3f7f901f ("KVM: Do not re-execute
INTn instruction."), but SVM was left behind. Probably because fixing
SVM is a mess due to NRIPS not being supported on all architectures, and
due to it being poorly implemented (with respect to soft events) when it
is supported.
[*] https://lore.kernel.org/all/cover.1646944472.git.maciej.szmigiero@oracle.com
Maciej S. Szmigiero (3):
KVM: nSVM: Sync next_rip field from vmcb12 to vmcb02
KVM: SVM: Downgrade BUG_ON() to WARN_ON() in svm_inject_irq()
KVM: selftests: nSVM: Add svm_nested_soft_inject_test
Sean Christopherson (5):
KVM: SVM: Unwind "speculative" RIP advancement if INTn injection
"fails"
KVM: SVM: Stuff next_rip on emualted INT3 injection if NRIPS is
supported
KVM: SVM: Re-inject INT3/INTO instead of retrying the instruction
KVM: SVM: Re-inject INTn instead of retrying the insn on "failure"
KVM: x86: Trace re-injected exceptions
arch/x86/kvm/svm/nested.c | 22 ++-
arch/x86/kvm/svm/svm.c | 135 ++++++++++++----
arch/x86/kvm/svm/svm.h | 5 +-
arch/x86/kvm/x86.c | 8 +-
tools/testing/selftests/kvm/.gitignore | 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../selftests/kvm/include/x86_64/svm_util.h | 2 +
.../kvm/x86_64/svm_nested_soft_inject_test.c | 147 ++++++++++++++++++
8 files changed, 279 insertions(+), 42 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
base-commit: 81d50efcff6cf4310aaf6a19806416ffeccf1cdb
--
2.35.1.1094.g7c7d902a7c-goog
Powered by blists - more mailing lists