From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] Don't call cpu_synchronize_state() in apic_init_reset() Date: Thu, 24 Sep 2009 10:59:46 +0200 Message-ID: <4ABB3502.4010701@web.de> References: <1253631112-26124-1-git-send-email-gleb@redhat.com> <1253631112-26124-3-git-send-email-gleb@redhat.com> <4AB9E3BC.7060304@redhat.com> <4ABA399F.6030003@web.de> <4ABA3C14.7080803@redhat.com> <4ABA42A1.4010904@web.de> <4ABB2597.7090107@redhat.com> <20090924080312.GB9832@redhat.com> <4ABB2A93.9040905@web.de> <20090924083054.GA14258@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6647EF9C2F4177FF499C0BF9" Cc: Avi Kivity , kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:47146 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbZIXI7u (ORCPT ); Thu, 24 Sep 2009 04:59:50 -0400 In-Reply-To: <20090924083054.GA14258@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6647EF9C2F4177FF499C0BF9 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Gleb Natapov wrote: > On Thu, Sep 24, 2009 at 10:15:15AM +0200, Jan Kiszka wrote: >> Gleb Natapov wrote: >>> On Thu, Sep 24, 2009 at 10:53:59AM +0300, Avi Kivity wrote: >>>> On 09/23/2009 06:45 PM, Jan Kiszka wrote: >>>>>> Functions calling each other in the same subsystem can rely on cal= lers >>>>>> calling cpu_synchronize_state(). Across subsystems, that's anothe= r >>>>>> matter, exported functions should try not to rely on implementatio= n >>>>>> details of their callers. >>>>>> >>>>>> (You might argue that the apic is not separate subsystem wrt an x8= 6 cpu, >>>>>> and I'm not sure I have a counterargument) >>>>>> >>>>> I do accept this argument. It's just that my feeling is that we are= >>>>> lacking proper review of the required call sites of cpu_sychronize_= state >>>>> and rather put it where some regression popped up (and that only in= >>>>> qemu-kvm...). >>>> That's life... >>>> >>>>> The new rule is: Synchronize the states before accessing registers = (or >>>>> in-kernel devices) the first time after a vmexit to user space. >>>> No, the rule is: synchronize state before accessing registers. >>>> Extra synchronization is cheap, while missing synchronization is >>>> very expensive. >>>> >>> So should we stick cpu_synchronize_state() before each register >>> accesses? I think it is reasonable to omit it if all callers do it >>> already. >>> >>>>> But, >>>>> e.g., I do not see where we do this on CPU reset. >>>> That's a bug. >>>> >>> Only if kvm support cpus without apic. Otherwise CPU is reset by=20 >>> apic_reset() and cpu_synchronize_state() is called there. >> No, that's not enough if cpu_reset() first fiddles with some registers= >> that may later on be overwritten on cpu_synchronize_state() with the o= ld >> in-kernel state. At least in theory, haven't checked yet what happens = in > Can't happen. Call chain is apic_reset() -> cpu_reset() and apic_reset(= ) > calls cpu_synchronize_state() before calling cpu_reset(). And system_reset? Jan --------------enig6647EF9C2F4177FF499C0BF9 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 iEYEARECAAYFAkq7NQYACgkQitSsb3rl5xSx9wCg7iDa8b3k4AF3jQ7ufAdp4Wlv R2YAnjUB/GiPCIB9RZyvhK8svXs9eBAv =cV3s -----END PGP SIGNATURE----- --------------enig6647EF9C2F4177FF499C0BF9--