lkml.org 
[lkml]   [2020]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Fix undefined operation VMXOFF during reboot and crash
Gah, I typed too slow :-)

On Wed, Jun 10, 2020 at 11:34:21PM +0200, Thomas Gleixner wrote:
> We have exception fixups to avoid exactly that kind of horrible
> workarounds all over the place.
>
> static inline int cpu_vmxoff_safe(void)
> {
> int err;
>
> asm volatile("2: vmxoff; xor %[err],%[err]\n"
> "1:\n\t"
> ".section .fixup,\"ax\"\n\t"
> "3: mov %[fault],%[err] ; jmp 1b\n\t"
> ".previous\n\t"
> _ASM_EXTABLE(2b, 3b)
> : [err] "=a" (err)
> : [fault] "i" (-EFAULT)
> : "memory");
> return err;
> }
>
> static inline void __cpu_emergency_vmxoff(void)
> {
> if (!cpu_vmx_enabled())
> return;
> if (!cpu_vmxoff_safe())
> cr4_clear_bits(X86_CR4_VMXE);

This bit is wrong, CR4.VMXE should be cleared even if VMXOFF faults, e.g.
if this is called in NMI context and the NMI arrived in KVM code between
VMXOFF and clearing CR4.VMXE.

All other VMXOFF faults are mode related, i.e. any fault is guaranteed to
be due to the !post-VMXON check unless we're magically in RM, VM86, compat
mode, or at CPL>0.

> }
>
> Problem solved.
>
> Thanks,
>
> tglx

\
 
 \ /
  Last update: 2020-06-10 23:42    [W:0.079 / U:0.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site