public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Gleb Natapov <gleb@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Add instruction length to VCPU event state
Date: Sat, 13 Feb 2010 20:20:41 +0100	[thread overview]
Message-ID: <4B76FB89.50107@web.de> (raw)
In-Reply-To: <20100213190615.GC2511@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2783 bytes --]

Gleb Natapov wrote:
> On Sat, Feb 13, 2010 at 07:41:35PM +0100, Jan Kiszka wrote:
>> Gleb Natapov wrote:
>>> On Sat, Feb 13, 2010 at 06:49:44PM +0100, Jan Kiszka wrote:
>>>> Gleb Natapov wrote:
>>>>> On Sat, Feb 13, 2010 at 10:51:40AM +0100, Jan Kiszka wrote:
>>>>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>>>>
>>>>>> VMX requires a properly set instruction length VM entry field when
>>>>>> trying to inject soft exception and interrupts. We have to preserve this
>>>>>> state across VM save/restore to avoid breaking the re-injection of such
>>>>>> events on Intel. So add it to the new VCPU event state.
>>>>>>
>>>>> We shouldn't re-inject soft exceptions/interrupts after migration, but
>>>>> re-execute instruction instead. Instruction length field doesn't exist
>>>>> on SVM and migration shouldn't expose implementation details.
>>>>>
>>>> Hmm, then I guess this totally untested patch should fly:
>>>>
>>> I don't understand what problem are you trying to solve by your patch.
>>> During normal operation event_exit_inst_len will be set to correct
>>> value. After migration rip will point to int instruction an no even will
>>> be pending at all. Here is the patch:
>> The patch will cause an endless loop if BP interception is enabled.
>>
> How? This code path is not executed normally.

Oh, I read it the other way around, but it is supposed to mask soft
exceptions/irqs (clearing *.injected is missing then).

> 
>> What is the purpose of keeping event_exit_inst_len around? Either we
>> need it also across user space exists, then we have to save/restore or
>> reconstruct it, or we don't need it, then simply drop it.
>>
> Why we need to save/restore is if we need it across user space exits?
> We need to save/restore it only if we nedd it across migration.
> 
> When exception happens during soft interrupt/exception delivery soft i/e
> should be retried somehow. There are two ways to do that. First one is just
> reenter guest with the same rip. Instruction will be reexecuted and
> event redelivered. Another is to reinject event via event reinjection
> mechanism and for that we need to tell CPU how to calculate rip of a next
> instruction and this is done by providing event_exit_inst_len. The

But I still fail to see the case where event_exit_inst_len is set to
anything but 1 or 2 and where it is related to anything else than exits
at INT3, INT X, or INTO.

> problem is that SVM supports only the first way. Intel advised us to use
> reinjection mechanism, so that what we use on VMX, but since migration
> can happen from Intel to AMD and vice versa we chose to reexecute
> instruction after migration on those rare occasions that migration
> happens exactly after intercepted soft i/e.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

  reply	other threads:[~2010-02-13 19:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-13  9:51 [PATCH] KVM: x86: Add instruction length to VCPU event state Jan Kiszka
2010-02-13 10:21 ` Avi Kivity
2010-02-13 10:55   ` Jan Kiszka
2010-02-13 15:26 ` Gleb Natapov
2010-02-13 17:49   ` Jan Kiszka
2010-02-13 18:22     ` Gleb Natapov
2010-02-13 18:41       ` Jan Kiszka
2010-02-13 19:06         ` Gleb Natapov
2010-02-13 19:20           ` Jan Kiszka [this message]
2010-02-13 19:25             ` Gleb Natapov
2010-02-14 10:19               ` Jan Kiszka
2010-02-14 13:44             ` Paolo Bonzini
2010-02-14 14:38               ` Gleb Natapov
2010-02-14 15:10               ` Avi Kivity

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=4B76FB89.50107@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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