sim: Use off_t for mmap offset arguments

The GuestABI used to call the system-calls infers the size of values
read from the registers based on the function signature of the system
call. For mmap this was causing offset to be truncated to a 32-bit
value. In the GPUComputeDriver mmap, the offset must be a 64-bit
value. This fixes a bug where the doorbell memory was not setup and
causing GPU applications to fail.

Change-Id: I75d9b32c0470d1907c68826ef81cf6cd46f60ea7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27367
Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Matthew Poremba <matthew.poremba@amd.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
Matthew Poremba
2020-04-01 16:56:55 -07:00
parent 0be2496dd5
commit f6b1d9f8ca
2 changed files with 20 additions and 4 deletions

View File

@@ -190,6 +190,14 @@ class X86Linux64 : public X86Linux
static const int NUM_OPEN_FLAGS;
//@{
/// Basic X86_64 Linux types
typedef uint64_t size_t;
typedef uint64_t off_t;
typedef int64_t time_t;
typedef int64_t clock_t;
//@}
static const unsigned TGT_MAP_SHARED = 0x00001;
static const unsigned TGT_MAP_PRIVATE = 0x00002;
static const unsigned TGT_MAP_32BIT = 0x00040;
@@ -318,6 +326,14 @@ class X86Linux32 : public X86Linux
static SyscallFlagTransTable mmapFlagTable[];
//@{
/// Basic X86 Linux types
typedef uint32_t size_t;
typedef uint32_t off_t;
typedef int32_t time_t;
typedef int32_t clock_t;
//@}
static const unsigned TGT_MAP_SHARED = 0x00001;
static const unsigned TGT_MAP_PRIVATE = 0x00002;
static const unsigned TGT_MAP_32BIT = 0x00040;

View File

@@ -1642,8 +1642,8 @@ writevFunc(SyscallDesc *desc, ThreadContext *tc,
template <class OS>
SyscallReturn
mmapFunc(SyscallDesc *desc, ThreadContext *tc,
Addr start, uint64_t length, int prot, int tgt_flags,
int tgt_fd, int offset)
Addr start, typename OS::size_t length, int prot,
int tgt_flags, int tgt_fd, typename OS::off_t offset)
{
auto p = tc->getProcessPtr();
Addr page_bytes = tc->getSystemPtr()->getPageBytes();
@@ -1826,8 +1826,8 @@ pwrite64Func(SyscallDesc *desc, ThreadContext *tc,
template <class OS>
SyscallReturn
mmap2Func(SyscallDesc *desc, ThreadContext *tc,
Addr start, uint64_t length, int prot, int tgt_flags,
int tgt_fd, int offset)
Addr start, typename OS::size_t length, int prot,
int tgt_flags, int tgt_fd, typename OS::off_t offset)
{
return mmapFunc<OS>(desc, tc, start, length, prot, tgt_flags,
tgt_fd, offset * tc->getSystemPtr()->getPageBytes());