From f6b1d9f8cadfc66d136c8baf466970943ed15093 Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Wed, 1 Apr 2020 16:56:55 -0700 Subject: [PATCH] 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 Reviewed-by: Matthew Poremba Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/arch/x86/linux/linux.hh | 16 ++++++++++++++++ src/sim/syscall_emul.hh | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh index e373dafbb..470512321 100644 --- a/src/arch/x86/linux/linux.hh +++ b/src/arch/x86/linux/linux.hh @@ -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; diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 11561a6f7..e5444b1d8 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1642,8 +1642,8 @@ writevFunc(SyscallDesc *desc, ThreadContext *tc, template 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 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(desc, tc, start, length, prot, tgt_flags, tgt_fd, offset * tc->getSystemPtr()->getPageBytes()); -- 2.30.2