qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] simulated memory instead of host memory


From: Johan Rydberg
Subject: Re: [Qemu-devel] simulated memory instead of host memory
Date: Mon, 9 Jun 2003 22:43:44 +0200

Fabrice Bellard <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]