From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNKJu-000229-3V for qemu-devel@nongnu.org; Fri, 20 May 2011 03:40:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNKJr-0001S0-Kf for qemu-devel@nongnu.org; Fri, 20 May 2011 03:40:25 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:49318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNKJr-0001Qr-9w for qemu-devel@nongnu.org; Fri, 20 May 2011 03:40:23 -0400 Message-ID: <4DD61ADD.9050103@web.de> Date: Fri, 20 May 2011 09:40:13 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4DD51CF3.5040306@codemonkey.ws> <4DD51D36.7040504@siemens.com> <20110519173923.GF27310@redhat.com> <4DD55D5B.30008@web.de> <20110519182203.GH27310@redhat.com> <4DD56126.20808@web.de> <20110519184056.GJ27310@redhat.com> <4DD56543.9020404@web.de> <20110519185019.GK27310@redhat.com> <4DD567B5.1060205@web.de> <20110520072358.GL27310@redhat.com> In-Reply-To: <20110520072358.GL27310@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig993F6D19BEB34F64F32DD537" Sender: jan.kiszka@web.de Subject: Re: [Qemu-devel] [RFC] Memory API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: Avi Kivity , qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig993F6D19BEB34F64F32DD537 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-05-20 09:23, Gleb Natapov wrote: > On Thu, May 19, 2011 at 08:55:49PM +0200, Jan Kiszka wrote: >>>>>> Because we should catch accidental overlaps in all those non PCI d= evices >>>>>> with hard-wired addressing. That's a bug in the device/machine mod= el and >>>>>> should be reported as such by QEMU. >>>>> Why should we complicate API to catch unlikely errors? If you want = to >>>>> debug that add capability to dump memory map from the monitor. >>>> >>>> Because we need to switch tons of code that so far saw a fairly >>>> different reaction of the core to overlapping regions. >>>> >>> How so? Today if there is accidental overlap device will not function= properly. >>> With new API it will be the same. >> >> I rather expect subtle differences as overlapping registration changes= >> existing regions, in the future those will recover. >> > Where do you expect the differences will come from? Conversion to the n= ew > API shouldn't change the order of the registration and if the last > registration will override previous one the end result should be the > same as we have today. A) Removing regions will change significantly. So far this is done by setting a region to IO_MEM_UNASSIGNED, keeping truncation. With the new API that will be a true removal which will additionally restore hidden regions. B) Uncontrolled overlapping is a bug that should be caught by the core, and a new API is a perfect chance to do this. >=20 >>>>>>>> new region management will not cause any harm to overlapping reg= ions so >>>>>>>> that they can "recover" when the overlap is gone. >>>>>>>> >>>>>>>>> >>>>>>>>> Another example may be APIC region and PCI. They overlap, but n= either >>>>>>>>> CPU nor PCI knows about it. >>>>>>>> >>>>>>>> And they do not need to. The APIC regions will be managed by the= per-CPU >>>>>>>> region management, reusing the tool box we need for all bridges.= It will >>>>>>>> register the APIC page with a priority higher than the default o= ne, thus >>>>>>>> overriding everything that comes from the host bridge. I think t= hat >>>>>>>> reflects pretty well real machine behaviour. >>>>>>>> >>>>>>> What is "higher"? How does it know that priority is high enough? >>>>>> >>>>>> Because no one else manages priorities at a specific hierarchy lev= el. >>>>>> There is only one. >>>>>> >>>>> PCI and CPU are on different hierarchy levels. PCI is under the PII= X and >>>>> CPU is on a system BUS. >>>> >>>> The priority for the APIC mapping will be applied at CPU level, of >>>> course. So it will override everything, not just PCI. >>>> >>> So you do not need explicit priority because the place in hierarchy >>> implicitly provides you with one. >> >> Yes. > OK :) So you agree that we can do without priorities :) Nope, see below how your own example depends on them. >=20 >> Alternatively, you could add a prio offset to all mappings when >> climbing one level up, provided that offset is smaller than the prio >> range locally available to each level. >> > Then a memory region final priority will depend on a tree height. If tw= o > disjointed tree branches of different height will claim the same memory= > region the higher one will have higher priority. I think this priority > management is a can of worms. It is not as it remains a pure local thing and helps implementing the sketched scenarios. Believe, I tried to fix PAM/SMRAM already. >=20 > Only the lowest level (aka system bus) will use memory API directly. Not necessarily. It depends on how much added value buses like PCI or ISA or whatever can offer for managing I/O regions. For some purposes, it may as well be fine to just call the memory_* service directly and pass the result of some operation to the bus API later on. > PCI > device will call PCI subsystem. PCI subsystem, instead of assigning > arbitrary priorities to all overlappings, Again: PCI will _not_ assign arbitrary priorities but only MEMORY_REGION_DEFAULT_PRIORITY, likely 0. > may just resolve them and pass > flattened view to the chipset. Chipset in turn will look for overlappin= gs > between PCI memory areas and RAM/ISA/other memory areas that are outsid= e > of PCI windows and resolve all those passing the flattened view to syst= em > bus where APIC/PCI conflict will be resolved and finally memory API wil= l > be used to create memory map. In such a model I do not see the need for= > priorities. All overlappings are resolved in the most logical place, > the one that has the best knowledge about how to resolve the conflict. > The will be no code duplication. Overlapping resolution code will be in= > separate library used by all layers. That does not specify how the PCI bridge or the chipset will tell that overlapping resolution lib _how_ overlapping regions shall be translated into a flat representation. And precisely here come priorities into play. It is the way to tell that lib either "region A shall override region B" if A has higher prio or "if region A and B overlap, do whatever you want" if both have the same prio. Jan --------------enig993F6D19BEB34F64F32DD537 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.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk3WGt8ACgkQitSsb3rl5xQm+gCdHnODXyKN9mUcdP6ddZI8lWKu hzQAmQGn2al5VveMZuEmblOkxrALXQLH =3Q9B -----END PGP SIGNATURE----- --------------enig993F6D19BEB34F64F32DD537--