changeset 9e2f25dcf8c8 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=9e2f25dcf8c8
description:
syscall: Zero out memory that already exists during the brk system call.
Glibc often assumes that memory it receives from the kernel after a brk
system call will contain only zeros. This is important during a calloc,
because it won't clear the new memory itself. In the simulator, if the
new page exists, it will be cleared using this patch, to mimic the
kernel's
functionality.
diffstat:
1 file changed, 18 insertions(+)
src/sim/syscall_emul.cc | 18 ++++++++++++++++++
diffs (28 lines):
diff -r db7e5f2778cf -r 9e2f25dcf8c8 src/sim/syscall_emul.cc
--- a/src/sim/syscall_emul.cc Sat Oct 24 10:53:58 2009 -0700
+++ b/src/sim/syscall_emul.cc Sat Oct 24 10:53:58 2009 -0700
@@ -144,6 +144,24 @@
if (!p->pTable->translate(gen.addr()))
p->pTable->allocate(roundDown(gen.addr(), VMPageSize),
VMPageSize);
+
+ // if the address is already there, zero it out
+ else {
+ uint8_t zero = 0;
+ TranslatingPort *tp = tc->getMemPort();
+
+ // split non-page aligned accesses
+ Addr next_page = roundUp(gen.addr(), VMPageSize);
+ uint32_t size_needed = next_page - gen.addr();
+ tp->memsetBlob(gen.addr(), zero, size_needed);
+ if (gen.addr() + VMPageSize > next_page &&
+ next_page < new_brk &&
+ p->pTable->translate(next_page))
+ {
+ size_needed = VMPageSize - size_needed;
+ tp->memsetBlob(next_page, zero, size_needed);
+ }
+ }
}
}
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev