Re: kernel BUG at arch/x86/kvm/x86.c:361! on AMD CPU

Sean Christopherson
2019-06-12T20:54:34Z

On Wed, Jun 12, 2019 at 09:51:52PM +0200, Borislav Petkov wrote:
> On Wed, Jun 12, 2019 at 02:45:34PM -0400, George Kennedy wrote:
> > The crash can still be reproduced with VM running Upstream 5.2.0-rc4
>
> That's clear.
>
> > and host running Ubuntu on AMD CPU.
>
> That's the important question: why can't I trigger it with 5.2.0-rc4+ as
> the host and you can with the ubuntu kernel 4.15 or so. I.e., what changed
> upstream or does the ubuntu kernel have out-of-tree stuff?
>
> Maybe kvm folks would have a better idea. That kvm_spurious_fault thing
> is for:
>
> /*
> * Hardware virtualization extension instructions may fault if a
> * reboot turns off virtualization while processes are running.
> * Trap the fault and ignore the instruction if that happens.
> */
> asmlinkage void kvm_spurious_fault(void);
>
> but you're not rebooting...

The reboot thing is a red-herring. The ____kvm_handle_fault_on_reboot()
macro suppresses faults that occur on VMX and SVM instructions while the
kernel is rebooting (CPUs need to leave VMX/SVM mode to recognize INIT),
i.e. kvm_spurious_fault() is reached when a VMX or SVM instruction faults
and we're *not* rebooting.

TL;DR: an SVM instruction is faulting unexpectedly.