From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH 0/5] Split the emulator: decode & execute
Date: Tue, 18 Sep 2007 07:59:57 +0200 [thread overview]
Message-ID: <46EF695D.1020203@qumranet.com> (raw)
In-Reply-To: <46EEDC92.80304-6ktuUTfB/bM@public.gmane.org>
Laurent Vivier wrote:
> Avi Kivity wrote:
>
>> Laurent Vivier (Bull) wrote:
>>
>>>> Not being able to emulate is sometimes legitimate. In the case of
>>>> writing to a write-protected guest page table, we simply
>>>> un-write-protect it and go back to the guest (which should now execute
>>>> the instruction natively).
>>>>
>>>> Perhaps the logic that deals with this (the call to
>>>> kvm_mmu_unprotect_page_virt() in emulate_instruction()) was broken by
>>>> your changes.
>>>>
>>>>
>>> In fact this case is managed in the error cases of
>>> emulate_instruction(). My first patch removes this management for
>>> instruction decoding because I supposed it cannot generate such errors.
>>> So what I proposed in my last email seems to be the good solution :
>>>
>>> emulate_instruction()
>>> ...
>>> r = x86_decode_insn(&vcpu->emulate_ctxt, &emulate_ops);
>>> if (r == 0)
>>> r = x86_emulate_insn(&vcpu->emulate_ctxt, &emulate_ops);
>>> ...
>>> if (r) {
>>> if (kvm_mmu_unprotect_page_virt(vcpu, cr2))
>>> return EMULATE_DONE;
>>> if (!vcpu->mmio_needed) {
>>> kvm_report_emulation_failure(vcpu, "mmio");
>>> return EMULATE_FAIL;
>>> }
>>> return EMULATE_DO_MMIO;
>>> }
>>> ...
>>>
>>>
>> Yes. But pushing the kvm_mmu_unprotect_page() to immediately after the
>> decode stage may be better.
>>
>>
>
> OK, but is this the only error case we can have in the decode stage ?
>
Decode can actually have fetch faults in smp (due to the instruction
lengthening during decode, or due to the page tables changing with npt/ept).
I think these are the only two errors possible for decode: can't decode
and can't fetch.
> Should we remove it from after the emulate stage ?
>
>
Instruction execution shouldn't cause decode failures, so yes, that
error shouldn't be emitted there.
But we can defer these fine tunings until later. Let's merge something
that works first.
(there are a couple of edge cases that can be fixed with the
decode/execute split, like a single read that crosses a page boundary
being split into two. I think Red Hat 7 doesn't work on kvm because it
issues a read that is partially in RAM and partially in mmio space).
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2007-09-18 5:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-29 16:39 [PATCH 0/5] Split the emulator: decode & execute Laurent Vivier
[not found] ` <46D5A151.80000-6ktuUTfB/bM@public.gmane.org>
2007-08-31 20:26 ` Andi Kleen
[not found] ` <200708312226.23678.ak-l3A5Bk7waGM@public.gmane.org>
2007-09-01 14:19 ` Avi Kivity
2007-09-09 12:15 ` Avi Kivity
[not found] ` <46E3E3D4.1050206-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-12 11:31 ` Laurent Vivier
[not found] ` <46E7CDF5.8050403-6ktuUTfB/bM@public.gmane.org>
2007-09-12 11:40 ` Avi Kivity
2007-09-14 16:14 ` Laurent Vivier
[not found] ` <46EAB36E.2060004-6ktuUTfB/bM@public.gmane.org>
2007-09-14 16:57 ` Avi Kivity
[not found] ` <46EABD97.5060503-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-17 16:14 ` Laurent Vivier
[not found] ` <46EEA801.20404-6ktuUTfB/bM@public.gmane.org>
2007-09-17 17:29 ` Avi Kivity
[not found] ` <46EEB971.9000507-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-17 19:08 ` Laurent Vivier (Bull)
[not found] ` <46EED091.2090404-6ktuUTfB/bM@public.gmane.org>
2007-09-17 19:16 ` Avi Kivity
[not found] ` <46EED2A2.8090803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-17 19:59 ` Laurent Vivier
[not found] ` <46EEDC92.80304-6ktuUTfB/bM@public.gmane.org>
2007-09-18 5:59 ` Avi Kivity [this message]
[not found] ` <46EF695D.1020203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-18 7:40 ` Laurent Vivier
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=46EF695D.1020203@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=Laurent.Vivier-6ktuUTfB/bM@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox