KVM: nVMX/nSVM: Don't intercept #UD when running L2
authorLiran Alon <[email protected]>
Mon, 6 Nov 2017 14:15:10 +0000 (16:15 +0200)
committerPaolo Bonzini <[email protected]>
Fri, 17 Nov 2017 12:20:09 +0000 (13:20 +0100)
commitac9b305caa0df6f5b75d294e4b86c1027648991e
tree595aed5c7cb8395662b54f79e6ad3befae3a10fd
parent51c4b8bba674cfd2260d173602c4dac08e4c3a99
KVM: nVMX/nSVM: Don't intercept #UD when running L2

When running L2, #UD should be intercepted by L1 or just forwarded
directly to L2. It should not reach L0 x86 emulator.
Therefore, set intercept for #UD only based on L1 exception-bitmap.

Also add WARN_ON_ONCE() on L0 #UD intercept handlers to make sure
it is never reached while running L2.

This improves commit ae1f57670703 ("KVM: nVMX: Do not emulate #UD while
in guest mode") by removing an unnecessary exit from L2 to L0 on #UD
when L1 doesn't intercept it.

In addition, SVM L0 #UD intercept handler doesn't handle correctly the
case it is raised from L2. In this case, it should forward the #UD to
guest instead of x86 emulator. As done in VMX #UD intercept handler.
This commit fixes this issue as-well.

Signed-off-by: Liran Alon <[email protected]>
Reviewed-by: Nikita Leshenko <[email protected]>
Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Reviewed-by: Wanpeng Li <[email protected]>
Signed-off-by: Radim Krčmář <[email protected]>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c