All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: "Stephan Bärwolf" <stephan.baerwolf@tu-ilmenau.de>
Cc: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: KVM guest-kernel panics double fault
Date: Thu, 29 Dec 2011 12:04:07 +0200	[thread overview]
Message-ID: <4EFC3B17.1040601@redhat.com> (raw)
In-Reply-To: <4EFBC973.1040905@tu-ilmenau.de>

On 12/29/2011 03:59 AM, Stephan Bärwolf wrote:
> Hello guys,
>
> I am sorry to disturb you this short before New Year, but I think this
> shouldn't wait until next year.
>
> After experiencing crashes in virtual maschines and considering kernel /
> qemu / kvm / cpu -bugs, I discovered the following (see patch) issue.
> Because unpriviledged users can crash VMs, I think it is a serious one
> and needs short-term attention.
>
> The patch I wrote is against 3.2-rc7 but I always tested with linux 3.1.6.
> Hopfully it solve the problems to your satisfaction.


Thanks for the report and patch.


> Subject: [PATCH] KVM: fix missing "illegal instruction"-trap in guests
> within non-64bit protected modes
>
> On hosts without this patch, 32bit guests will crash for
> example by simply executing following nasm-demo-application:
>
>         [bits 32]
>         global _start
>         SECTION .text
>         _start: syscall
>
> (I am not sure if this can be exploited in more worse ways,
> like breaking out of VMs in more complex szenarios?
> But I tested it with win32 and linux - both always crashed)
>
>         Disassembly of section .text:
>
>         00000000 <_start>:
>            0:   0f 05                   syscall
>
> The reason seems a missing "invalid opcode"-trap (int6) for the
> syscall opcode "0f05", which is not available on 32bit cpus.
> Intel's "Intel 64 and IA-32 Architecture Software Developers
> Manual" (http://www.intel.com/content/dam/doc/manual/
> 64-ia-32-architectures-software-developer-manual-325462.pdf)
> documents on page 1804 (4-586) "syscall" is only available
> in 64bit longmode. So "syscall" must trap in real- and
> virtual 8086 -mode, as also in all non-64bit protected-modes.

However, 'syscall' is available in compatibility mode on 32-bit cpus.

> 0001-KVM-fix-missing-illegal-instruction-trap-in-guests-w.patch
>  	/* syscall is not available in real mode */
> +	/* 
> +	   "0f05" is also not available in
> +	   all non-64-bit protected modes (16&
> +	   32bit) or virtual 8086 mode		 
> +	   Only 64bit longmode supports this opcode
> +	*/
>  	if (ctxt->mode == X86EMUL_MODE_REAL ||
> +	    ctxt->mode == X86EMUL_MODE_PROT16 ||
> +	    ctxt->mode == X86EMUL_MODE_PROT32 ||
>  	    ctxt->mode == X86EMUL_MODE_VM86)
>  		return emulate_ud(ctxt);
>  
>

The PROT32 check should be qualifed by a checking the the guest cpuid
vendor is not AMD.  Otherwise a guest that was migrated from an AMD host
to an Intel host (this is what this emulation was written for in the
first place) will #UD unexpectedly.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2011-12-29 10:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-29  1:59 KVM guest-kernel panics double fault Stephan Bärwolf
2011-12-29 10:04 ` Avi Kivity [this message]
2012-01-08  2:31   ` Stephan Bärwolf
2012-01-08 10:21     ` Avi Kivity
2012-01-10 10:11       ` Stephan Bärwolf
2012-01-10 10:31         ` Avi Kivity
2012-01-10 12:17           ` Stephan Bärwolf
2012-01-10 12:34             ` Avi Kivity
2012-01-10 12:48               ` Stephan Bärwolf
2012-01-10 14:26                 ` [PATCH 0/2] " Stephan Bärwolf
2012-01-10 14:26                 ` [PATCH 1/2] KVM: extend "struct x86_emulate_ops" with "get_cpuid" Stephan Bärwolf
2012-01-10 14:26                 ` [PATCH 2/2] KVM: fix missing "illegal instruction"-trap in protected modes Stephan Bärwolf
2012-01-11 19:09                   ` Marcelo Tosatti
2012-01-11 20:01                     ` Stephan Bärwolf
2012-01-11 21:21                       ` Marcelo Tosatti
2012-01-11 22:19                         ` Stephan Bärwolf
2012-01-12 10:47                           ` Marcelo Tosatti
2012-01-12 15:43                             ` [PATCH 0/2] KVM guest-kernel panics double fault Stephan Bärwolf
2012-01-12 15:56                               ` Jan Kiszka
2012-01-13 10:13                                 ` Marcelo Tosatti
2012-01-15 19:44                                   ` Stephan Bärwolf
2012-01-16  9:58                                     ` Marcelo Tosatti
2012-01-16 11:24                                       ` Stephan Bärwolf
2012-01-12 15:43                             ` [PATCH 1/2] KVM: extend "struct x86_emulate_ops" with "get_cpuid" Stephan Bärwolf
2012-01-12 15:43                             ` [PATCH 2/2] KVM: fix missing "illegal instruction"-trap in protected modes Stephan Bärwolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EFC3B17.1040601@redhat.com \
    --to=avi@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stephan.baerwolf@tu-ilmenau.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.