Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19PTad-0007dm-64 for qemu-devel@nongnu.org; Mon, 09 Jun 2003 16:50:03 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19PTaI-0007Nj-L5 for qemu-devel@nongnu.org; Mon, 09 Jun 2003 16:49:43 -0400 Received: from falcon.skarpodata.com ([193.45.208.6] helo=griffin.skarpodata.com) by monty-python.gnu.org with esmtp (Exim 4.20) id 19PTUs-0005qB-Th for qemu-devel@nongnu.org; Mon, 09 Jun 2003 16:44:07 -0400 Received: from falcon.skarpodata.com (root@[164.9.187.2]) h59KfJjB014711 for ; Mon, 9 Jun 2003 22:41:19 +0200 Received: (from mailgw@localhost) by falcon.skarpodata.com (8.9.3/8.9.3) id WAA18675 for ; Mon, 9 Jun 2003 22:44:05 +0200 Date: Mon, 9 Jun 2003 22:43:44 +0200 From: Johan Rydberg Subject: Re: [Qemu-devel] simulated memory instead of host memory Message-Id: <20030609224344.387ddfdc.jrydberg@night.trouble.net> In-Reply-To: <3EE4EB88.5000203@free.fr> References: <20030609203126.7fc1bb17.jrydberg@night.trouble.net> <3EE4DB71.3090706@free.fr> <20030609213710.03f5677b.jrydberg@night.trouble.net> <3EE4EB88.5000203@free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , To: qemu-devel@nongnu.org Fabrice Bellard wrote: : Using a cache as you do is a good idea. You can save some insns, and : more if you use differents bits of the address (do a mask with 0x7f8), : but you would have less cache hits. Since doing it the "slow way" is really slow you should try to maximize the hit rate. The ideal whould be something like 95-99% hit rate for normal pages, and it should only have to escape into the slow path on accesses to memory mapped I/O devices. Well, you could always dream I guess. : 40017160: 0000005b: push %ecx : 40017167: 00000062: mov %eax,%esi : 40017169: 00000064: shr $0xc,%esi : movl %esi, %ecx : 4001716c: 00000067: and $0xff,%esi 256 entries : 4001717e: 00000079: cmp %ecx,0x805cee4(%esi,8) compare : 40017181: 0000007c: jne 0x00000439 miss -> slow way : 40017187: 00000082: add 0x805cee8(%esi,8),%eax : 4001718c: 00000087: mov %ebx,0x0(%eax) do the store : 4001718f: 0000008a: pop %ecx Does this really work? 0x805cee4 is the address to _a pointer_ that holds the address of the mtcache. The reason for having a pointer to the real mtcache is that it is much faster just to change the pointer when switching between user and supervisor mode (and the other way around). Maybe it would be better to have centralized mtcache, and copy the contents of the per-cpu and per-state mtcaches into that one when the state changes. The reason for masking the virtual address as I did, and use it as tag in the cache is that you may also check for unaligned memory accesses. This is not an issue when simulating IA-32, but you must detect it when simulate machines that can not cope with unaligned accesses. : I guess GCC should give nearly optimal code. Most probably. I will wrap something together and see what it generates. : [...] : Well, if you generate code it is already not portable :-) I ment between systsems such as GNU/Linux and BSD. -- Johan Rydberg, Free Software Developer, Sweden http://rtmk.sf.net | http://www.nongnu.org/guss/ Listning to Her Majesty - Rules to follow