From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: x86: Add instruction length to VCPU event state Date: Sun, 14 Feb 2010 11:19:13 +0100 Message-ID: <4B77CE21.6000202@web.de> References: <4B76762C.10107@web.de> <20100213152635.GA2511@redhat.com> <4B76E638.5010100@web.de> <20100213182253.GB2511@redhat.com> <4B76F25F.1060009@web.de> <20100213190615.GC2511@redhat.com> <4B76FB89.50107@web.de> <20100213192540.GD2511@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig438CF308FC65967A07F01D91" Cc: Avi Kivity , Marcelo Tosatti , kvm To: Gleb Natapov Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:44741 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758398Ab0BNKT6 (ORCPT ); Sun, 14 Feb 2010 05:19:58 -0500 In-Reply-To: <20100213192540.GD2511@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig438CF308FC65967A07F01D91 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Gleb Natapov wrote: > On Sat, Feb 13, 2010 at 08:20:41PM +0100, Jan Kiszka wrote: >> 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 >>>>>>>> >>>>>>>> VMX requires a properly set instruction length VM entry field wh= en >>>>>>>> trying to inject soft exception and interrupts. We have to prese= rve 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 pat= ch. >>>>> 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 i= s 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 exit= s >> at INT3, INT X, or INTO. >> > You can't know real instruction length without decoding it or relying o= n > VMX exit info. What if prefix were used for INT X? >=20 OK, makes sense now. Then let's go with your suggestion, will post it as a patch. Thanks for explaining, Jan --------------enig438CF308FC65967A07F01D91 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkt3zikACgkQitSsb3rl5xQ/twCgsRJ9ksPgxs2Z3lQOChK2xYsT LdYAn3wiWnhd843OUAfWhZ9Y2jrLDNZS =bHHF -----END PGP SIGNATURE----- --------------enig438CF308FC65967A07F01D91--