We have a memsetBlob function. Can you use that instead of allocating a page, zeroing it and then doing a write?
Do you actually see unaligned pages? Shouldn't we just align the increment value to the next page boundary. It seems to me that you need to use the chunk generator or some looping construct to loop over all of the pages that may have been allocated and check each individual page to make sure that they are all zeroed (because the brk can be incremented by many pages.) Nate On Thu, Oct 8, 2009 at 7:37 AM, Timothy M. Jones <[email protected]> wrote: > # HG changeset patch > # User Timothy M. Jones <[email protected]> > # Date 1255004954 -3600 > # Node ID 0569f32a43a12eaa170b8d9a804e78ad9bef6de4 > # Parent 0c3f1856877bc570e3c853ff6a79fab71bcd6f95 > 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. > > diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc > --- a/src/sim/syscall_emul.cc > +++ b/src/sim/syscall_emul.cc > @@ -144,6 +144,25 @@ > 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[VMPageSize]; > + memset(zero, 0, VMPageSize); > + 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->writeBlob(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->writeBlob(next_page, zero, size_needed); > + } > + } > } > } > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > _______________________________________________ > m5-dev mailing list > [email protected] > http://m5sim.org/mailman/listinfo/m5-dev > > _______________________________________________ m5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/m5-dev
