sim-se, arch: Fix syscall parametre sizes for 32-bit OSs (#1482)
A bug was uncovered in that for various syscalls that used 64bit parametres, the ABI for 32bit operating systems was passing the wrong values to the syscalls, due to discrepancies between the target and guest OS. This commit fixes that by replacing 64-bit types, or types that are platform specific in size, with the exact correspondent for the guest OS, thus producing the correct signature for the respective syscalls. On top of this, the --param argument is added to the starter_se script, in order to support attachment of remote debuggers.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2016-2017, 2022-2023 Arm Limited
|
||||
# Copyright (c) 2016-2017, 2022-2024 Arm Limited
|
||||
# All rights reserved.
|
||||
#
|
||||
# The license below extends only to copyright in the software and shall
|
||||
@@ -203,6 +203,19 @@ def main():
|
||||
default="stdoutput",
|
||||
help="Destination for the Tarmac trace output. [Default: stdoutput]",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-P",
|
||||
"--param",
|
||||
action="append",
|
||||
default=[],
|
||||
help="Set a SimObject parameter relative to the root node. "
|
||||
"An extended Python multi range slicing syntax can be used "
|
||||
"for arrays. For example: "
|
||||
"'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' "
|
||||
"sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 "
|
||||
"Direct parameters of the root object are not accessible, "
|
||||
"only parameters of its children.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -215,6 +228,7 @@ def main():
|
||||
# Populate the root node with a system. A system corresponds to a
|
||||
# single node with shared memory.
|
||||
root.system = create(args)
|
||||
root.apply_config(args.param)
|
||||
|
||||
# Instantiate the C++ object hierarchy. After this point,
|
||||
# SimObjects can't be instantiated anymore.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013, 2015, 2020 ARM Limited
|
||||
* Copyright (c) 2010-2013, 2015, 2020, 2024 ARM Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
@@ -163,7 +163,7 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 14, "mknod", mknodFunc },
|
||||
{ base + 15, "chmod", chmodFunc<ArmLinux32> },
|
||||
{ base + 16, "lchown", chownFunc },
|
||||
{ base + 19, "lseek", lseekFunc },
|
||||
{ base + 19, "lseek", lseekFunc<ArmLinux32> },
|
||||
{ base + 20, "getpid", getpidFunc },
|
||||
{ base + 21, "mount" },
|
||||
{ base + 22, "umount" },
|
||||
@@ -185,7 +185,7 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 42, "pipe", pipePseudoFunc },
|
||||
{ base + 43, "times", timesFunc<ArmLinux32> },
|
||||
{ base + 45, "brk", brkFunc },
|
||||
{ base + 46, "setgid" },
|
||||
{ base + 46, "setgid", ignoreFunc },
|
||||
{ base + 47, "getgid", getgidFunc },
|
||||
{ base + 49, "geteuid", geteuidFunc },
|
||||
{ base + 50, "getegid", getegidFunc },
|
||||
@@ -272,7 +272,7 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 142, "newselect" },
|
||||
{ base + 143, "flock" },
|
||||
{ base + 144, "msync" },
|
||||
{ base + 145, "readv" },
|
||||
{ base + 145, "readv", readvFunc<ArmLinux32> },
|
||||
{ base + 146, "writev", writevFunc<ArmLinux32> },
|
||||
{ base + 147, "getsid" },
|
||||
{ base + 148, "fdatasync" },
|
||||
@@ -293,7 +293,7 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 163, "mremap", mremapFunc<ArmLinux32> }, // ARM-specific
|
||||
{ base + 164, "setresuid" },
|
||||
{ base + 165, "getresuid" },
|
||||
{ base + 168, "poll" },
|
||||
{ base + 168, "poll", pollFunc<ArmLinux32> },
|
||||
{ base + 169, "nfsservctl" },
|
||||
{ base + 170, "setresgid" },
|
||||
{ base + 171, "getresgid" },
|
||||
@@ -305,10 +305,10 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 177, "rt_sigtimedwait" },
|
||||
{ base + 178, "rt_sigqueueinfo", ignoreFunc },
|
||||
{ base + 179, "rt_sigsuspend" },
|
||||
{ base + 180, "pread64" },
|
||||
{ base + 181, "pwrite64" },
|
||||
{ base + 180, "pread64", pread64Func<ArmLinux32> },
|
||||
{ base + 181, "pwrite64", pwrite64Func<ArmLinux32> },
|
||||
{ base + 182, "chown" },
|
||||
{ base + 183, "getcwd", getcwdFunc },
|
||||
{ base + 183, "getcwd", getcwdFunc<ArmLinux32> },
|
||||
{ base + 184, "capget" },
|
||||
{ base + 185, "capset" },
|
||||
{ base + 186, "sigaltstack" },
|
||||
@@ -316,7 +316,7 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 190, "vfork" },
|
||||
{ base + 191, "getrlimit", getrlimitFunc<ArmLinux32> },
|
||||
{ base + 192, "mmap2", mmapFunc<ArmLinux32> },
|
||||
{ base + 193, "truncate64" },
|
||||
{ base + 193, "truncate64", truncate64Func },
|
||||
{ base + 194, "ftruncate64", ftruncate64Func },
|
||||
{ base + 195, "stat64", stat64Func<ArmLinux32> },
|
||||
{ base + 196, "lstat64", lstat64Func<ArmLinux32> },
|
||||
@@ -336,8 +336,8 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 210, "setresgid" },
|
||||
{ base + 211, "getresgid" },
|
||||
{ base + 212, "chown" },
|
||||
{ base + 213, "setuid" },
|
||||
{ base + 214, "setgid" },
|
||||
{ base + 213, "setuid", ignoreFunc },
|
||||
{ base + 214, "setgid", ignoreFunc },
|
||||
{ base + 215, "setfsuid" },
|
||||
{ base + 216, "setfsgid" },
|
||||
#if defined(SYS_getdents64)
|
||||
@@ -488,7 +488,9 @@ class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
|
||||
{ base + 363, "sys_rt_tgsigqueueinfo" },
|
||||
{ base + 364, "sys_perf_event_open" },
|
||||
{ base + 365, "sys_recvmmsg" },
|
||||
{ base + 384, "getrandom", getrandomFunc<ArmLinux32> }
|
||||
{ base + 384, "getrandom", getrandomFunc<ArmLinux32> },
|
||||
{ base + 397, "sys_statx", ignoreFunc },
|
||||
{ base + 398, "sys_rseq", ignoreFunc }
|
||||
})
|
||||
{}
|
||||
};
|
||||
@@ -516,7 +518,7 @@ class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
|
||||
{ base + 14, "removexattr" },
|
||||
{ base + 15, "lremovexattr" },
|
||||
{ base + 16, "fremovexattr" },
|
||||
{ base + 17, "getcwd", getcwdFunc },
|
||||
{ base + 17, "getcwd", getcwdFunc<ArmLinux64> },
|
||||
{ base + 18, "lookup_dcookie" },
|
||||
{ base + 19, "eventfd2" },
|
||||
{ base + 20, "epoll_create1" },
|
||||
@@ -544,7 +546,7 @@ class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
|
||||
{ base + 42, "nfsservctl" },
|
||||
{ base + 43, "statfs64" },
|
||||
{ base + 44, "fstatfs64" },
|
||||
{ base + 45, "truncate64" },
|
||||
{ base + 45, "truncate64", truncate64Func },
|
||||
{ base + 46, "ftruncate64", ftruncate64Func },
|
||||
{ base + 47, "fallocate", fallocateFunc<ArmLinux64> },
|
||||
{ base + 48, "faccessat", faccessatFunc<ArmLinux64> },
|
||||
@@ -565,13 +567,13 @@ class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
|
||||
#else
|
||||
{ base + 61, "getdents64" },
|
||||
#endif
|
||||
{ base + 62, "llseek", lseekFunc },
|
||||
{ base + 62, "lseek", lseekFunc<ArmLinux64> },
|
||||
{ base + 63, "read", readFunc<ArmLinux64> },
|
||||
{ base + 64, "write", writeFunc<ArmLinux64> },
|
||||
{ base + 65, "readv" },
|
||||
{ base + 65, "readv", readvFunc<ArmLinux64> },
|
||||
{ base + 66, "writev", writevFunc<ArmLinux64> },
|
||||
{ base + 67, "pread64" },
|
||||
{ base + 68, "pwrite64" },
|
||||
{ base + 67, "pread64", pread64Func<ArmLinux64> },
|
||||
{ base + 68, "pwrite64", pwrite64Func<ArmLinux64> },
|
||||
{ base + 69, "preadv" },
|
||||
{ base + 70, "pwritev" },
|
||||
{ base + 71, "sendfile64" },
|
||||
@@ -815,7 +817,7 @@ class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
|
||||
{ base + 1054, "newfstatat" },
|
||||
{ base + 1055, "fstatfs" },
|
||||
{ base + 1056, "statfs" },
|
||||
{ base + 1057, "lseek", lseekFunc },
|
||||
{ base + 1057, "lseek", lseekFunc<ArmLinux64> },
|
||||
{ base + 1058, "mmap", mmapFunc<ArmLinux64> },
|
||||
{ base + 1059, "alarm" },
|
||||
{ base + 1060, "getpgrp" },
|
||||
@@ -830,7 +832,7 @@ class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
|
||||
#endif
|
||||
{ base + 1066, "futimesat", futimesatFunc<ArmLinux64> },
|
||||
{ base + 1067, "select" },
|
||||
{ base + 1068, "poll" },
|
||||
{ base + 1068, "poll", pollFunc<ArmLinux64> },
|
||||
{ base + 1069, "epoll_wait" },
|
||||
{ base + 1070, "ustat" },
|
||||
{ base + 1071, "vfork" },
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -192,6 +203,8 @@ class MipsLinux : public Linux, public OpenFlagTable<MipsLinux>
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
};
|
||||
|
||||
typedef uint32_t size_t;
|
||||
typedef int32_t off_t;
|
||||
};
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright 2005 The Regents of The University of Michigan
|
||||
* Copyright 2007 MIPS Technologies, Inc.
|
||||
* Copyright 2020 Google Inc.
|
||||
@@ -177,7 +188,7 @@ SyscallDescTable<MipsISA::SEWorkload::SyscallABI> EmuLinux::syscallDescs = {
|
||||
{ 4016, "lchown", chownFunc },
|
||||
{ 4017, "break", brkFunc },
|
||||
{ 4018, "unused#18" },
|
||||
{ 4019, "lseek", lseekFunc },
|
||||
{ 4019, "lseek", lseekFunc<MipsLinux> },
|
||||
{ 4020, "getpid", getpidFunc },
|
||||
{ 4021, "mount" },
|
||||
{ 4022, "umount" },
|
||||
@@ -361,7 +372,7 @@ SyscallDescTable<MipsISA::SEWorkload::SyscallABI> EmuLinux::syscallDescs = {
|
||||
{ 4200, "pread64" },
|
||||
{ 4201, "pwrite64" },
|
||||
{ 4202, "chown" },
|
||||
{ 4203, "getcwd", getcwdFunc },
|
||||
{ 4203, "getcwd", getcwdFunc<MipsLinux> },
|
||||
{ 4204, "capget" },
|
||||
{ 4205, "capset" },
|
||||
{ 4206, "sigalstack" },
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright 2003-2005 The Regents of The University of Michigan
|
||||
* Copyright 2007-2008 The Florida State University
|
||||
* Copyright 2009 The University of Edinburgh
|
||||
@@ -126,7 +137,7 @@ SyscallDescTable<PowerISA::SEWorkload::SyscallABI> EmuLinux::syscallDescs = {
|
||||
{ 16, "lchown", chownFunc },
|
||||
{ 17, "break", brkFunc }, //???
|
||||
{ 18, "unused#18" }, //???
|
||||
{ 19, "lseek", lseekFunc },
|
||||
{ 19, "lseek", lseekFunc<PowerLinux> },
|
||||
{ 20, "getpid", getpidFunc },
|
||||
{ 21, "mount" },
|
||||
{ 22, "umount" },
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright 2005 The Regents of The University of Michigan
|
||||
* Copyright 2007 MIPS Technologies, Inc.
|
||||
* Copyright 2016 The University of Virginia
|
||||
@@ -141,7 +152,7 @@ SyscallDescTable<SEWorkload::SyscallABI64> EmuLinux::syscallDescs64 = {
|
||||
{ 14, "removexattr" },
|
||||
{ 15, "lremovexattr" },
|
||||
{ 16, "fremovexattr" },
|
||||
{ 17, "getcwd", getcwdFunc },
|
||||
{ 17, "getcwd", getcwdFunc<RiscvLinux64> },
|
||||
{ 18, "lookup_dcookie" },
|
||||
{ 19, "eventfd2" },
|
||||
{ 20, "epoll_create1" },
|
||||
@@ -190,7 +201,7 @@ SyscallDescTable<SEWorkload::SyscallABI64> EmuLinux::syscallDescs64 = {
|
||||
#else
|
||||
{ 61, "getdents64" },
|
||||
#endif
|
||||
{ 62, "lseek", lseekFunc },
|
||||
{ 62, "lseek", lseekFunc<RiscvLinux64> },
|
||||
{ 63, "read", readFunc<RiscvLinux64> },
|
||||
{ 64, "write", writeFunc<RiscvLinux64> },
|
||||
{ 66, "writev", writevFunc<RiscvLinux64> },
|
||||
@@ -432,7 +443,7 @@ SyscallDescTable<SEWorkload::SyscallABI64> EmuLinux::syscallDescs64 = {
|
||||
{ 1054, "newfstatat", newfstatatFunc<RiscvLinux64> },
|
||||
{ 1055, "fstatfs", fstatfsFunc<RiscvLinux64> },
|
||||
{ 1056, "statfs", statfsFunc<RiscvLinux64> },
|
||||
{ 1057, "lseek", lseekFunc },
|
||||
{ 1057, "lseek", lseekFunc<RiscvLinux64> },
|
||||
{ 1058, "mmap", mmapFunc<RiscvLinux64> },
|
||||
{ 1059, "alarm" },
|
||||
{ 1060, "getpgrp", getpgrpFunc },
|
||||
@@ -480,7 +491,7 @@ SyscallDescTable<SEWorkload::SyscallABI32> EmuLinux::syscallDescs32 = {
|
||||
{ 14, "removexattr" },
|
||||
{ 15, "lremovexattr" },
|
||||
{ 16, "fremovexattr" },
|
||||
{ 17, "getcwd", getcwdFunc },
|
||||
{ 17, "getcwd", getcwdFunc<RiscvLinux32> },
|
||||
{ 18, "lookup_dcookie" },
|
||||
{ 19, "eventfd2" },
|
||||
{ 20, "epoll_create1" },
|
||||
@@ -529,7 +540,7 @@ SyscallDescTable<SEWorkload::SyscallABI32> EmuLinux::syscallDescs32 = {
|
||||
#else
|
||||
{ 61, "getdents64" },
|
||||
#endif
|
||||
{ 62, "lseek", lseekFunc },
|
||||
{ 62, "lseek", lseekFunc<RiscvLinux32> },
|
||||
{ 63, "read", readFunc<RiscvLinux32> },
|
||||
{ 64, "write", writeFunc<RiscvLinux32> },
|
||||
{ 66, "writev", writevFunc<RiscvLinux32> },
|
||||
@@ -771,7 +782,7 @@ SyscallDescTable<SEWorkload::SyscallABI32> EmuLinux::syscallDescs32 = {
|
||||
{ 1054, "newfstatat", newfstatatFunc<RiscvLinux32> },
|
||||
{ 1055, "fstatfs", fstatfsFunc<RiscvLinux32> },
|
||||
{ 1056, "statfs", statfsFunc<RiscvLinux32> },
|
||||
{ 1057, "lseek", lseekFunc },
|
||||
{ 1057, "lseek", lseekFunc<RiscvLinux32> },
|
||||
{ 1058, "mmap", mmapFunc<RiscvLinux32> },
|
||||
{ 1059, "alarm" },
|
||||
{ 1060, "getpgrp", getpgrpFunc },
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -242,6 +253,9 @@ class SparcLinux : public Linux, public OpenFlagTable<SparcLinux>
|
||||
ptc->setReg(SparcISA::SyscallPseudoReturnReg, (RegVal)0);
|
||||
ctc->setReg(SparcISA::SyscallPseudoReturnReg, 1);
|
||||
}
|
||||
|
||||
typedef uint64_t size_t;
|
||||
typedef int64_t off_t;
|
||||
};
|
||||
|
||||
class Sparc32Linux : public SparcLinux
|
||||
@@ -288,6 +302,9 @@ class Sparc32Linux : public SparcLinux
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
};
|
||||
|
||||
typedef uint32_t size_t;
|
||||
typedef int32_t off_t;
|
||||
|
||||
/// Resource constants for getrlimit() (overide some generics).
|
||||
static const unsigned TGT_RLIMIT_NPROC = 7;
|
||||
static const unsigned TGT_RLIMIT_NOFILE = 6;
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -104,7 +115,7 @@ SyscallDescTable<SEWorkload::SyscallABI32> EmuLinux::syscall32Descs = {
|
||||
{ 16, "lchown" }, // 32 bit
|
||||
{ 17, "brk", brkFunc },
|
||||
{ 18, "perfctr" }, // 32 bit
|
||||
{ 19, "lseek", lseekFunc }, // 32 bit
|
||||
{ 19, "lseek", lseekFunc<Sparc32Linux> }, // 32 bit
|
||||
{ 20, "getpid", getpidFunc },
|
||||
{ 21, "capget" },
|
||||
{ 22, "capset" },
|
||||
@@ -204,7 +215,7 @@ SyscallDescTable<SEWorkload::SyscallABI32> EmuLinux::syscall32Descs = {
|
||||
{ 116, "gettimeofday", gettimeofdayFunc<Sparc32Linux> }, // 32 bit
|
||||
{ 117, "getrusage" }, // 32 bit
|
||||
{ 118, "getsockopt" },
|
||||
{ 119, "getcwd", getcwdFunc },
|
||||
{ 119, "getcwd", getcwdFunc<Sparc32Linux> },
|
||||
{ 120, "readv" },
|
||||
{ 121, "writev" },
|
||||
{ 122, "settimeofday" }, // 32 bit
|
||||
@@ -407,7 +418,7 @@ SyscallDescTable<SEWorkload::SyscallABI64> EmuLinux::syscallDescs = {
|
||||
{ 16, "lchown" },
|
||||
{ 17, "brk", brkFunc },
|
||||
{ 18, "perfctr" },
|
||||
{ 19, "lseek", lseekFunc },
|
||||
{ 19, "lseek", lseekFunc<SparcLinux> },
|
||||
{ 20, "getpid", getpidFunc },
|
||||
{ 21, "capget" },
|
||||
{ 22, "capset" },
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
* Copyright (c) 2007 The Hewlett-Packard Development Company
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -240,7 +241,7 @@ class X86Linux64 : public X86Linux, public OpenFlagTable<X86Linux64>
|
||||
//@{
|
||||
/// Basic X86_64 Linux types
|
||||
typedef uint64_t size_t;
|
||||
typedef uint64_t off_t;
|
||||
typedef int64_t off_t;
|
||||
typedef int64_t time_t;
|
||||
typedef int64_t clock_t;
|
||||
//@}
|
||||
@@ -387,7 +388,7 @@ class X86Linux32 : public X86Linux, public OpenFlagTable<X86Linux32>
|
||||
//@{
|
||||
/// Basic X86 Linux types
|
||||
typedef uint32_t size_t;
|
||||
typedef uint32_t off_t;
|
||||
typedef int32_t off_t;
|
||||
typedef int32_t time_t;
|
||||
typedef int32_t clock_t;
|
||||
//@}
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -58,7 +69,7 @@ SyscallDescTable<EmuLinux::SyscallABI32> EmuLinux::syscallDescs32 = {
|
||||
{ 16, "lchown" },
|
||||
{ 17, "break" },
|
||||
{ 18, "oldstat" },
|
||||
{ 19, "lseek" },
|
||||
{ 19, "lseek", lseekFunc<X86Linux32> },
|
||||
{ 20, "getpid", getpidFunc },
|
||||
{ 21, "mount" },
|
||||
{ 22, "umount" },
|
||||
@@ -226,7 +237,7 @@ SyscallDescTable<EmuLinux::SyscallABI32> EmuLinux::syscallDescs32 = {
|
||||
{ 180, "pread64", pread64Func<X86Linux64> },
|
||||
{ 181, "pwrite64", pwrite64Func<X86Linux64> },
|
||||
{ 182, "chown" },
|
||||
{ 183, "getcwd", getcwdFunc },
|
||||
{ 183, "getcwd", getcwdFunc<X86Linux32> },
|
||||
{ 184, "capget" },
|
||||
{ 185, "capset" },
|
||||
{ 186, "sigaltstack" },
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -47,7 +58,7 @@ SyscallDescTable<EmuLinux::SyscallABI64> EmuLinux::syscallDescs64 = {
|
||||
{ 5, "fstat", fstat64Func<X86Linux64> },
|
||||
{ 6, "lstat", lstat64Func<X86Linux64> },
|
||||
{ 7, "poll", pollFunc<X86Linux64> },
|
||||
{ 8, "lseek", lseekFunc },
|
||||
{ 8, "lseek", lseekFunc<X86Linux64> },
|
||||
{ 9, "mmap", mmapFunc<X86Linux64> },
|
||||
{ 10, "mprotect", ignoreFunc },
|
||||
{ 11, "munmap", munmapFunc<X86Linux64> },
|
||||
@@ -122,7 +133,7 @@ SyscallDescTable<EmuLinux::SyscallABI64> EmuLinux::syscallDescs64 = {
|
||||
#else
|
||||
{ 78, "getdents" },
|
||||
#endif
|
||||
{ 79, "getcwd", getcwdFunc },
|
||||
{ 79, "getcwd", getcwdFunc<X86Linux64> },
|
||||
{ 80, "chdir", chdirFunc },
|
||||
{ 81, "fchdir" },
|
||||
{ 82, "rename", renameFunc },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Arm Limited
|
||||
* Copyright (c) 2021, 2024 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -66,7 +66,7 @@ class Linux : public OperatingSystem
|
||||
//@{
|
||||
/// Basic Linux types.
|
||||
typedef uint64_t size_t;
|
||||
typedef uint64_t off_t;
|
||||
typedef int64_t off_t;
|
||||
typedef int64_t time_t;
|
||||
typedef int64_t clock_t;
|
||||
typedef uint32_t uid_t;
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
*
|
||||
* The license below extends only to copyright in the software and
|
||||
* shall not be construed as granting a license to any other
|
||||
* intellectual property including but not limited to intellectual
|
||||
* property relating to a hardware implementation of the
|
||||
* functionality of the software licensed hereunder. You may use the
|
||||
* software subject to the license terms below provided that you
|
||||
* ensure that this notice is replicated unmodified and in its
|
||||
* entirety in all distributions of the software, modified or
|
||||
* unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -277,7 +289,7 @@ brkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk)
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, uint64_t tidPtr)
|
||||
setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> tidPtr)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
|
||||
@@ -292,26 +304,10 @@ closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
|
||||
return p->fds->closeFDEntry(tgt_fd);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
lseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offs, int whence)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
|
||||
if (!ffdp)
|
||||
return -EBADF;
|
||||
int sim_fd = ffdp->getSimFD();
|
||||
|
||||
off_t result = lseek(sim_fd, offs, whence);
|
||||
|
||||
return (result == (off_t)-1) ? -errno : result;
|
||||
}
|
||||
|
||||
|
||||
SyscallReturn
|
||||
_llseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offset_high, uint32_t offset_low,
|
||||
int tgt_fd, uint32_t offset_high, uint32_t offset_low,
|
||||
VPtr<> result_ptr, int whence)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -321,7 +317,7 @@ _llseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
return -EBADF;
|
||||
int sim_fd = ffdp->getSimFD();
|
||||
|
||||
uint64_t offset = (offset_high << 32) | offset_low;
|
||||
uint64_t offset = ((uint64_t) offset_high << 32) | offset_low;
|
||||
|
||||
uint64_t result = lseek(sim_fd, offset, whence);
|
||||
result = htog(result, tc->getSystemPtr()->getGuestByteOrder());
|
||||
@@ -348,36 +344,6 @@ gethostnameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getcwdFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> buf_ptr, unsigned long size)
|
||||
{
|
||||
int result = 0;
|
||||
auto p = tc->getProcessPtr();
|
||||
BufferArg buf(buf_ptr, size);
|
||||
|
||||
// Is current working directory defined?
|
||||
std::string cwd = p->tgtCwd;
|
||||
if (!cwd.empty()) {
|
||||
if (cwd.length() >= size) {
|
||||
// Buffer too small
|
||||
return -ERANGE;
|
||||
}
|
||||
strncpy((char *)buf.bufferPtr(), cwd.c_str(), size);
|
||||
result = cwd.length();
|
||||
} else {
|
||||
if (getcwd((char *)buf.bufferPtr(), size)) {
|
||||
result = strlen((char *)buf.bufferPtr());
|
||||
} else {
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
|
||||
buf.copyOut(SETranslatingPortProxy(tc));
|
||||
|
||||
return (result == -1) ? -errno : result;
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
unlinkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2013, 2015, 2019-2021, 2023 Arm Limited
|
||||
* Copyright (c) 2012-2013, 2015, 2019-2021, 2023-2024 Arm Limited
|
||||
* Copyright (c) 2015 Advanced Micro Devices, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
@@ -149,7 +149,7 @@ SyscallReturn exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status);
|
||||
|
||||
/// Target set_tid_address() handler.
|
||||
SyscallReturn setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
uint64_t tidPtr);
|
||||
VPtr<> tidPtr);
|
||||
|
||||
/// Target getpagesize() handler.
|
||||
SyscallReturn getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
@@ -160,13 +160,9 @@ SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk);
|
||||
/// Target close() handler.
|
||||
SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd);
|
||||
|
||||
/// Target lseek() handler.
|
||||
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offs, int whence);
|
||||
|
||||
/// Target _llseek() handler.
|
||||
SyscallReturn _llseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offset_high,
|
||||
int tgt_fd, uint32_t offset_high,
|
||||
uint32_t offset_low, VPtr<> result_ptr, int whence);
|
||||
|
||||
/// Target shutdown() handler.
|
||||
@@ -177,10 +173,6 @@ SyscallReturn shutdownFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
SyscallReturn gethostnameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> buf_ptr, int name_len);
|
||||
|
||||
/// Target getcwd() handler.
|
||||
SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> buf_ptr, unsigned long size);
|
||||
|
||||
/// Target unlink() handler.
|
||||
SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> pathname);
|
||||
@@ -976,6 +968,56 @@ openFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
desc, tc, OS::TGT_AT_FDCWD, pathname, tgt_flags, mode);
|
||||
}
|
||||
|
||||
/// Target getcwd() handler
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
getcwdFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> buf_ptr, typename OS::size_t size)
|
||||
{
|
||||
int result = 0;
|
||||
auto p = tc->getProcessPtr();
|
||||
BufferArg buf(buf_ptr, size);
|
||||
|
||||
// Is current working directory defined?
|
||||
std::string cwd = p->tgtCwd;
|
||||
if (!cwd.empty()) {
|
||||
if (cwd.length() >= size) {
|
||||
// Buffer too small
|
||||
return -ERANGE;
|
||||
}
|
||||
strncpy((char *)buf.bufferPtr(), cwd.c_str(), size);
|
||||
result = cwd.length();
|
||||
} else {
|
||||
if (getcwd((char *)buf.bufferPtr(), size)) {
|
||||
result = strlen((char *)buf.bufferPtr());
|
||||
} else {
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
|
||||
buf.copyOut(SETranslatingPortProxy(tc));
|
||||
|
||||
return (result == -1) ? -errno : result;
|
||||
}
|
||||
|
||||
/// Target lseek() handler
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
lseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, typename OS::off_t offs, int whence)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
|
||||
if (!ffdp)
|
||||
return -EBADF;
|
||||
int sim_fd = ffdp->getSimFD();
|
||||
|
||||
off_t result = lseek(sim_fd, offs, whence);
|
||||
|
||||
return (result == (off_t)-1) ? -errno : result;
|
||||
}
|
||||
|
||||
/// Target unlinkat() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
@@ -1327,7 +1369,8 @@ fchmodFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t mode)
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
mremapFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> start, uint64_t old_length, uint64_t new_length, uint64_t flags,
|
||||
VPtr<> start, typename OS::size_t old_length,
|
||||
typename OS::size_t new_length, int flags,
|
||||
guest_abi::VarArgs<uint64_t> varargs)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1877,7 +1920,7 @@ fstatfsFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
readvFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t tiov_base,
|
||||
int tgt_fd, VPtr<> tiov_base,
|
||||
typename OS::size_t count)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1915,7 +1958,7 @@ readvFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
writevFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t tiov_base,
|
||||
int tgt_fd, VPtr<> tiov_base,
|
||||
typename OS::size_t count)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2092,7 +2135,8 @@ mmapFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pread64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, VPtr<> bufPtr, int nbytes, int offset)
|
||||
int tgt_fd, VPtr<> bufPtr, typename OS::size_t nbytes,
|
||||
typename OS::off_t offset)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -2113,7 +2157,8 @@ pread64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pwrite64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, VPtr<> bufPtr, int nbytes, int offset)
|
||||
int tgt_fd, VPtr<> bufPtr, typename OS::size_t nbytes,
|
||||
typename OS::off_t offset)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -2746,7 +2791,7 @@ selectFunc(SyscallDesc *desc, ThreadContext *tc, int nfds,
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
readFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, VPtr<> buf_ptr, int nbytes)
|
||||
int tgt_fd, VPtr<> buf_ptr, typename OS::size_t nbytes)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -2774,7 +2819,7 @@ readFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
writeFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, VPtr<> buf_ptr, int nbytes)
|
||||
int tgt_fd, VPtr<> buf_ptr, typename OS::size_t nbytes)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user