mem,sim: Get the page size from the page table in SE mode.
The page table already knows the size of a page without having to directly use any ISA specific constants. Change-Id: I68b575e194697065620a2097d972076886766f74 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34172 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
@@ -42,7 +42,7 @@ MemState::MemState(Process *owner, Addr brk_point, Addr stack_base,
|
||||
Addr max_stack_size, Addr next_thread_stack_base,
|
||||
Addr mmap_end)
|
||||
: _ownerProcess(owner),
|
||||
_pageBytes(owner->system->getPageBytes()), _brkPoint(brk_point),
|
||||
_pageBytes(owner->pTable->pageSize()), _brkPoint(brk_point),
|
||||
_stackBase(stack_base), _stackSize(max_stack_size),
|
||||
_maxStackSize(max_stack_size), _stackMin(stack_base - max_stack_size),
|
||||
_nextThreadStackBase(next_thread_stack_base),
|
||||
|
||||
@@ -319,7 +319,7 @@ Process::drain()
|
||||
void
|
||||
Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
|
||||
{
|
||||
int npages = divCeil(size, (int64_t)system->getPageBytes());
|
||||
int npages = divCeil(size, pTable->pageSize());
|
||||
Addr paddr = system->allocPhysPages(npages);
|
||||
pTable->map(vaddr, paddr, size,
|
||||
clobber ? EmulationPageTable::Clobber :
|
||||
@@ -334,15 +334,14 @@ Process::replicatePage(Addr vaddr, Addr new_paddr, ThreadContext *old_tc,
|
||||
new_paddr = system->allocPhysPages(1);
|
||||
|
||||
// Read from old physical page.
|
||||
uint8_t *buf_p = new uint8_t[system->getPageBytes()];
|
||||
old_tc->getVirtProxy().readBlob(vaddr, buf_p, system->getPageBytes());
|
||||
uint8_t buf_p[pTable->pageSize()];
|
||||
old_tc->getVirtProxy().readBlob(vaddr, buf_p, sizeof(buf_p));
|
||||
|
||||
// Create new mapping in process address space by clobbering existing
|
||||
// mapping (if any existed) and then write to the new physical page.
|
||||
bool clobber = true;
|
||||
pTable->map(vaddr, new_paddr, system->getPageBytes(), clobber);
|
||||
new_tc->getVirtProxy().writeBlob(vaddr, buf_p, system->getPageBytes());
|
||||
delete[] buf_p;
|
||||
pTable->map(vaddr, new_paddr, sizeof(buf_p), clobber);
|
||||
new_tc->getVirtProxy().writeBlob(vaddr, buf_p, sizeof(buf_p));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -443,7 +442,7 @@ Process::updateBias()
|
||||
|
||||
// Determine how large the interpreters footprint will be in the process
|
||||
// address space.
|
||||
Addr interp_mapsize = roundUp(interp->mapSize(), system->getPageBytes());
|
||||
Addr interp_mapsize = roundUp(interp->mapSize(), pTable->pageSize());
|
||||
|
||||
// We are allocating the memory area; set the bias to the lowest address
|
||||
// in the allocated memory region.
|
||||
|
||||
@@ -241,7 +241,7 @@ exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status)
|
||||
SyscallReturn
|
||||
getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
return (int)tc->getSystemPtr()->getPageBytes();
|
||||
return (int)tc->getProcessPtr()->pTable->pageSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -336,11 +336,10 @@ munmapFunc(SyscallDesc *desc, ThreadContext *tc, Addr start, size_t length)
|
||||
// access them again.
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
if (start & (tc->getSystemPtr()->getPageBytes() - 1) || !length) {
|
||||
if (p->pTable->pageOffset(start))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
length = roundUp(length, tc->getSystemPtr()->getPageBytes());
|
||||
length = roundUp(length, p->pTable->pageSize());
|
||||
|
||||
p->memState->unmapRegion(start, length);
|
||||
|
||||
|
||||
@@ -1094,7 +1094,7 @@ mremapFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
GuestABI::VarArgs<uint64_t> varargs)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
Addr page_bytes = tc->getSystemPtr()->getPageBytes();
|
||||
Addr page_bytes = p->pTable->pageSize();
|
||||
uint64_t provided_address = 0;
|
||||
bool use_provided_address = flags & OS::TGT_MREMAP_FIXED;
|
||||
|
||||
@@ -1626,7 +1626,7 @@ mmapFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_flags, int tgt_fd, typename OS::off_t offset)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
Addr page_bytes = tc->getSystemPtr()->getPageBytes();
|
||||
Addr page_bytes = p->pTable->pageSize();
|
||||
|
||||
if (start & (page_bytes - 1) ||
|
||||
offset & (page_bytes - 1) ||
|
||||
@@ -1809,8 +1809,9 @@ mmap2Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr start, typename OS::size_t length, int prot,
|
||||
int tgt_flags, int tgt_fd, typename OS::off_t offset)
|
||||
{
|
||||
auto page_size = tc->getProcessPtr()->pTable->pageSize();
|
||||
return mmapFunc<OS>(desc, tc, start, length, prot, tgt_flags,
|
||||
tgt_fd, offset * tc->getSystemPtr()->getPageBytes());
|
||||
tgt_fd, offset * page_size);
|
||||
}
|
||||
|
||||
/// Target getrlimit() handler.
|
||||
|
||||
Reference in New Issue
Block a user