qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] softmmu thoughts


From: Magnus Damm
Subject: [Qemu-devel] softmmu thoughts
Date: Tue, 19 Oct 2004 22:27:57 +0200

Hello all,

Wouldn't it be possible to speed up the softmmu code by using some
mmap() tricks?

u_int32_t mem_read(u_int32_t address)
{
  u_int8_t entry;
  u_int32_t a;

  entry = CPUState->softmmu_lookup[address >> 12];
  a = CPUState->softmmu_entries[entry].base + (address & 0xfff);
  return *(u_int32_t *)a;
}

The idea is to optimize so the most common memory accesses becomes
faster than today but the more uncommon (crossing page boundary) will
generate a signal and thus become slower. If I remember correctly the
code above will be around 7 x86 instructions long.

The code above will use 1 MiB of memory for the softmmu_lookup, one byte
for each entry. A value of 0 means "not mapped" and softmmu_entries[0]
will always point to a page that generates a signal. The other 255
entries are used to map one virtual address to a base address of a
two-page combination somewhere in memory. This two page combination is
actually two VMA:s where the first page maps to the correct simulated
physical address. The second page is mapped as inaccessible and is used
to generate a signal when a memory access crosses the page boundary.

And of course, there are many more things that must be done including a
complicated signal handler, and I guess that this kind of implementation
is not really useful for mapping in memory mapped I/O. But maybe it is
efficient for userspace?

Any thoughts?

/ magnus





reply via email to

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