All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Richard Henderson" <rth@twiddle.net>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/7] target-i386: Dump illegal opcodes with -d unimp
Date: Fri, 4 Mar 2016 13:15:44 +0100	[thread overview]
Message-ID: <56D97C70.4060208@redhat.com> (raw)
In-Reply-To: <56D88B42.7060208@twiddle.net>



On 03/03/2016 20:06, Richard Henderson wrote:
> On 03/03/2016 02:08 AM, Paolo Bonzini wrote:
>>> Do you want LOG_UNIMP or LOG_GUEST_ERROR?
>>
>> I would actually use LOG_IN_ASM.  As you noticed, guests sometimes use
>> illegal opcodes; another example is Xen's hypercall interface.
>>
>> On 03/03/2016 07:57, Hervé Poussineau wrote:
>>> This patch is not quiet on some operating systems:
>>> OS/2:
>>> ILLOPC: 000172e1: 0f a6
>>>
>>> Windows XP:
>>> ILLOPC: 00020d1a: c4 c4
>>>
>>> And very verbose in Windows 3.11, Windows 9x:
>>> ILLOPC: 000ffb17: 63
>>> ILLOPC: 000ffb17: 63
>>>
>>> Is it normal?
>>
>> Yes, it is.  As usual, Raymond Chen explains what's going on:
>>
>> https://blogs.msdn.microsoft.com/oldnewthing/20041215-00/?p=37003
> 
> Wow.  That's... interesting.

It's actually even more interesting (the explanation is in the book) if
you notice that 0xffb17 is in the middle of the BIOS.  Indeed Windows 95
first locates a single 0x63 in the BIOS (so that it's ROM and no one can
write a different byte).  Then the 32-bit code can use a system service
that allocates a callback from 16-bit MS-DOS.  That service gets a
32-bit address for the 32-bit code and returns a real-mode address to be
used in 16-bit code.

The kick is that all the real-mode addresses point to that single 0x63
that was found in ROM.  For example in the case above the real-mode
addresses could be FFB1:07, FFB0:17, FFAF:27, etc.  The illegal opcode
exception handler looks at the segment to figure out which 32-bit
address to jump to.

There are also cases where the ARPL is patched into existing code (like
a breakpoint) to trap that code to 32-bit.  But this one using the ROM
is much cooler.

Paolo

  parent reply	other threads:[~2016-03-04 12:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03  5:30 [Qemu-devel] [PATCH 0/7] target-i386 fixes Richard Henderson
2016-03-03  5:30 ` [Qemu-devel] [PATCH 1/7] target-i386: avoid repeated calls to the bnd_jmp helper Richard Henderson
2016-03-03  5:30 ` [Qemu-devel] [PATCH 2/7] target-i386: fix smsw and lmsw from/to register Richard Henderson
2016-03-03  5:30 ` [Qemu-devel] [PATCH 3/7] target-i386: Fix SMSW for 64-bit mode Richard Henderson
2016-03-03  5:30 ` [Qemu-devel] [PATCH 4/7] target-i386: Dump illegal opcodes with -d unimp Richard Henderson
2016-03-03  6:57   ` Hervé Poussineau
2016-03-03 10:08     ` Paolo Bonzini
2016-03-03 19:06       ` Richard Henderson
2016-03-04 10:41         ` Paolo Bonzini
2016-03-04 18:12           ` Richard Henderson
2016-03-04 12:15         ` Paolo Bonzini [this message]
2016-03-03  5:30 ` [Qemu-devel] [PATCH 5/7] target-i386: fix addr16 prefix Richard Henderson
2016-03-03  5:30 ` [Qemu-devel] [PATCH 6/7] target-i386: Use gen_nop_modrm for prefetch instructions Richard Henderson
2016-03-03  5:30 ` [Qemu-devel] [PATCH 7/7] target-i386: Fix inhibit irq mask handling Richard Henderson
2016-03-03  8:46   ` Paolo Bonzini
2016-03-03  6:49 ` [Qemu-devel] [PATCH 0/7] target-i386 fixes Hervé Poussineau

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=56D97C70.4060208@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.