[gem5-dev] Change in gem5/gem5[master]: tests: Incrase jenkins test timeout to 4 hours.

2019-12-08 Thread Rahul Thakur (Gerrit)
Rahul Thakur has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23463 )



Change subject: tests: Incrase jenkins test timeout to 4 hours.
..

tests: Incrase jenkins test timeout to 4 hours.

Change-Id: I11d36a429254df01a46040325baff5b7d18e22b3
---
M tests/jenkins/presubmit.cfg
1 file changed, 2 insertions(+), 0 deletions(-)



diff --git a/tests/jenkins/presubmit.cfg b/tests/jenkins/presubmit.cfg
index 742a6fc..6c9296e 100644
--- a/tests/jenkins/presubmit.cfg
+++ b/tests/jenkins/presubmit.cfg
@@ -2,3 +2,5 @@

 # Location of the continuous batch script in repository.
 build_file: "jenkins-gem5-prod/tests/jenkins/presubmit.sh"
+
+timeout_mins: 240

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23463
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I11d36a429254df01a46040325baff5b7d18e22b3
Gerrit-Change-Number: 23463
Gerrit-PatchSet: 1
Gerrit-Owner: Rahul Thakur 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: arch-riscv: set MaxMiscDestRegs to 2

2019-12-08 Thread Alec Roelke (Gerrit)
Alec Roelke has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23220 )


Change subject: arch-riscv: set MaxMiscDestRegs to 2
..

arch-riscv: set MaxMiscDestRegs to 2

In an earlier patch, the FCSR was split into its two components, FRM and
FFLAGS, causing explicit writes to FCSR to incur two CSR writes. With
the O3 CPU model, which defers them both to later, this creates a bug
where an assertion that the number of CSR writes must be less than
MaxMiscDestRegs fails because that constant is 1. This patch sets it to
2 so the O3 CPU is compatible with this scheme.

Change-Id: Ic3413738c4eebe9f127980d0d0af5033d18468e7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23220
Reviewed-by: Alec Roelke 
Maintainer: Alec Roelke 
Tested-by: kokoro 
---
M src/arch/riscv/registers.hh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Alec Roelke: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/riscv/registers.hh b/src/arch/riscv/registers.hh
index 582a6c5..352c600 100644
--- a/src/arch/riscv/registers.hh
+++ b/src/arch/riscv/registers.hh
@@ -67,7 +67,7 @@

 using RiscvISAInst::MaxInstSrcRegs;
 using RiscvISAInst::MaxInstDestRegs;
-const int MaxMiscDestRegs = 1;
+const int MaxMiscDestRegs = 2;

 // Not applicable to RISC-V
 using VecElem = ::DummyVecElem;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23220
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ic3413738c4eebe9f127980d0d0af5033d18468e7
Gerrit-Change-Number: 23220
Gerrit-PatchSet: 2
Gerrit-Owner: Alec Roelke 
Gerrit-Reviewer: Alec Roelke 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: arch, sim: Get rid of the now unused getSyscallArg method.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23462 )



Change subject: arch,sim: Get rid of the now unused getSyscallArg method.
..

arch,sim: Get rid of the now unused getSyscallArg method.

Change-Id: I2f78420d8687da7530feb66784fe3e6d2357baf8
---
M src/arch/alpha/process.cc
M src/arch/alpha/process.hh
M src/arch/arm/freebsd/process.hh
M src/arch/arm/linux/process.hh
M src/arch/arm/process.cc
M src/arch/arm/process.hh
M src/arch/mips/process.cc
M src/arch/mips/process.hh
M src/arch/power/linux/process.cc
M src/arch/power/linux/process.hh
M src/arch/power/process.cc
M src/arch/power/process.hh
M src/arch/riscv/process.cc
M src/arch/riscv/process.hh
M src/arch/sparc/process.cc
M src/arch/sparc/process.hh
M src/arch/x86/process.cc
M src/arch/x86/process.hh
M src/sim/process.cc
M src/sim/process.hh
20 files changed, 0 insertions(+), 167 deletions(-)



diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc
index 8571f0e..6f3ee1e 100644
--- a/src/arch/alpha/process.cc
+++ b/src/arch/alpha/process.cc
@@ -215,13 +215,6 @@
 tc->setMiscRegNoEffect(IPR_MCSR, 0);
 }

-RegVal
-AlphaProcess::getSyscallArg(ThreadContext *tc, int )
-{
-assert(i < 6);
-return tc->readIntReg(FirstArgumentReg + i++);
-}
-
 void
 AlphaProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
 {
diff --git a/src/arch/alpha/process.hh b/src/arch/alpha/process.hh
index 8ff72bc..b973d87 100644
--- a/src/arch/alpha/process.hh
+++ b/src/arch/alpha/process.hh
@@ -50,9 +50,6 @@
 void argsInit(int intSize, int pageSize);

   public:
-RegVal getSyscallArg(ThreadContext *tc, int ) override;
-/// Explicitly import the otherwise hidden getSyscallArg
-using Process::getSyscallArg;
 void setSyscallReturn(ThreadContext *tc,
   SyscallReturn return_value) override;

diff --git a/src/arch/arm/freebsd/process.hh  
b/src/arch/arm/freebsd/process.hh

index 8c28232..8ff3ec5 100644
--- a/src/arch/arm/freebsd/process.hh
+++ b/src/arch/arm/freebsd/process.hh
@@ -97,9 +97,6 @@

 void syscall(ThreadContext *tc, Fault *fault) override;

-/// Explicitly import the otherwise hidden getSyscallArg
-using ArmProcess::getSyscallArg;
-
 /// A page to hold "kernel" provided functions. The name might be  
wrong.

 static const Addr commPage;

diff --git a/src/arch/arm/linux/process.hh b/src/arch/arm/linux/process.hh
index 8f13279..8f2a496 100644
--- a/src/arch/arm/linux/process.hh
+++ b/src/arch/arm/linux/process.hh
@@ -99,9 +99,6 @@

 void syscall(ThreadContext *tc, Fault *fault) override;

-/// Explicitly import the otherwise hidden getSyscallArg
-using ArmProcess::getSyscallArg;
-
 /// A page to hold "kernel" provided functions. The name might be  
wrong.

 static const Addr commPage;

diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc
index 6657f54..03275a9 100644
--- a/src/arch/arm/process.cc
+++ b/src/arch/arm/process.cc
@@ -481,45 +481,6 @@
 0, 1, 2, 3, 4, 5, 6
 };

-RegVal
-ArmProcess32::getSyscallArg(ThreadContext *tc, int )
-{
-assert(i < 6);
-return tc->readIntReg(ArgumentReg0 + i++);
-}
-
-RegVal
-ArmProcess64::getSyscallArg(ThreadContext *tc, int )
-{
-assert(i < 8);
-return tc->readIntReg(ArgumentReg0 + i++);
-}
-
-RegVal
-ArmProcess32::getSyscallArg(ThreadContext *tc, int , int width)
-{
-assert(width == 32 || width == 64);
-if (width == 32)
-return getSyscallArg(tc, i);
-
-// 64 bit arguments are passed starting in an even register
-if (i % 2 != 0)
-   i++;
-
-// Registers r0-r6 can be used
-assert(i < 5);
-uint64_t val;
-val = tc->readIntReg(ArgumentReg0 + i++);
-val |= ((uint64_t)tc->readIntReg(ArgumentReg0 + i++) << 32);
-return val;
-}
-
-RegVal
-ArmProcess64::getSyscallArg(ThreadContext *tc, int , int width)
-{
-return getSyscallArg(tc, i);
-}
-
 void
 ArmProcess32::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
 {
diff --git a/src/arch/arm/process.hh b/src/arch/arm/process.hh
index b90a051..1553fe0 100644
--- a/src/arch/arm/process.hh
+++ b/src/arch/arm/process.hh
@@ -88,8 +88,6 @@

   public:

-RegVal getSyscallArg(ThreadContext *tc, int , int width) override;
-RegVal getSyscallArg(ThreadContext *tc, int ) override;
 void setSyscallReturn(ThreadContext *tc,
 SyscallReturn return_value) override;

@@ -137,8 +135,6 @@

   public:

-RegVal getSyscallArg(ThreadContext *tc, int , int width) override;
-RegVal getSyscallArg(ThreadContext *tc, int ) override;
 void setSyscallReturn(ThreadContext *tc,
 SyscallReturn return_value) override;

diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index 8e279cf..6f8ee95 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -193,13 +193,6 @@
 }


-RegVal
-MipsProcess::getSyscallArg(ThreadContext *tc, 

[gem5-dev] Change in gem5/gem5[master]: sim: Add a dumpSimcall mechanism to GuestABI.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23460 )



Change subject: sim: Add a dumpSimcall mechanism to GuestABI.
..

sim: Add a dumpSimcall mechanism to GuestABI.

This dumps a signature for a simcall as if it was going to be invoked,
and can be used for debugging.

Change-Id: I6262b94ad4186bac8dc5a1469e9bb3b8ae9d34e1
---
M src/sim/guest_abi.hh
M src/sim/guest_abi.test.cc
2 files changed, 85 insertions(+), 0 deletions(-)



diff --git a/src/sim/guest_abi.hh b/src/sim/guest_abi.hh
index b2176a6..f0a6a2d 100644
--- a/src/sim/guest_abi.hh
+++ b/src/sim/guest_abi.hh
@@ -32,6 +32,7 @@

 #include 
 #include 
+#include 
 #include 

 class ThreadContext;
@@ -213,6 +214,14 @@
 }
 };

+template 
+std::ostream &
+operator << (std::ostream , const VarArgs )
+{
+os << "...";
+return os;
+}
+
 // The ABI independent hook which tells the GuestABI mechanism what to do  
with
 // a VarArgs argument. It constructs the underlying implementation which  
knows

 // about the ABI, and installs it in the VarArgs wrapper to give to the
@@ -301,6 +310,47 @@
 callFrom(tc, position, partial);
 }

+
+
+/*
+ * These functions are like the ones above, except they print the arguments
+ * a target function would be called with instead of actually calling it.
+ */
+
+// With no arguments to print, add the closing parenthesis and return.
+template 
+static void
+dumpArgsFrom(std::ostream , ThreadContext *tc,
+ typename ABI::Position )
+{
+os << ")";
+}
+
+// Recursively gather arguments for target from tc until we get to the base
+// case above, and append those arguments to the string stream being
+// constructed.
+template 
+static void
+dumpArgsFrom(std::ostream , ThreadContext *tc,
+ typename ABI::Position )
+{
+// Either open the parenthesis or add a comma, depending on where we  
are

+// in the argument list.
+if (position == typename ABI::Position())
+os << "(";
+else
+os << ", ";
+
+// Extract the next argument from the thread context.
+NextArg next = Argument::get(tc, position);
+
+// Add this argument to the list.
+os << next;
+
+// Recursively handle any remaining arguments.
+dumpArgsFrom(os, tc, position);
+}
+
 } // namespace GuestABI


@@ -347,4 +397,32 @@
 tc, std::function(target));
 }

+
+// These functions also wrap a simulator level function. Instead of  
running the
+// function, they return a string which shows what arguments the function  
would

+// be invoked with if it were called from the given context.
+
+template 
+std::string
+dumpSimcall(std::string name, ThreadContext *tc,
+std::function target=
+std::function())
+{
+auto position = typename ABI::Position();
+std::ostringstream ss;
+
+ss << name;
+GuestABI::dumpArgsFrom(ss, tc, position);
+return ss.str();
+}
+
+template 
+std::string
+dumpSimcall(std::string name, ThreadContext *tc,
+Ret (*target)(ThreadContext *, Args...))
+{
+return dumpSimcall(
+name, tc, std::functionArgs...)>(target));

+}
+
 #endif // __SIM_GUEST_ABI_HH__
diff --git a/src/sim/guest_abi.test.cc b/src/sim/guest_abi.test.cc
index ee536aa..19efb7d 100644
--- a/src/sim/guest_abi.test.cc
+++ b/src/sim/guest_abi.test.cc
@@ -275,3 +275,10 @@
 EXPECT_EQ(tc.floatResult, DoubleRetValue + 2.0);
 }
 }
+
+TEST(GuestABI, dumpSimcall)
+{
+ThreadContext tc;
+std::string dump = dumpSimcall("test", , testIntVoid);
+EXPECT_EQ(dump, "test(0, 11, 2, 13, ...)");
+}

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23460
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I6262b94ad4186bac8dc5a1469e9bb3b8ae9d34e1
Gerrit-Change-Number: 23460
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim: Make SyscallReturn handle extra/"pseudo" return registers.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23440 )



Change subject: sim: Make SyscallReturn handle extra/"pseudo" return  
registers.

..

sim: Make SyscallReturn handle extra/"pseudo" return registers.

Avoid special casing them in the system calls themselves.

Change-Id: I735f8e6fdff164c66e3f1386aed3fc9b107ea45f
---
M src/arch/alpha/process.cc
M src/arch/arm/process.cc
M src/arch/mips/process.cc
M src/arch/sparc/process.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_return.hh
6 files changed, 33 insertions(+), 17 deletions(-)



diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc
index 02a6899..f40b771 100644
--- a/src/arch/alpha/process.cc
+++ b/src/arch/alpha/process.cc
@@ -237,4 +237,6 @@
 tc->setIntReg(SyscallSuccessReg, (RegVal)-1);
 tc->setIntReg(ReturnValueReg, sysret.errnoValue());
 }
+if (sysret.count() > 1)
+tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }
diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc
index 19ee32b..df21183 100644
--- a/src/arch/arm/process.cc
+++ b/src/arch/arm/process.cc
@@ -527,6 +527,8 @@
 }

 tc->setIntReg(ReturnValueReg, sysret.encodedValue());
+if (sysret.count() > 1)
+tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }

 void
@@ -544,4 +546,6 @@
 }

 tc->setIntReg(ReturnValueReg, sysret.encodedValue());
+if (sysret.count() > 1)
+tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }
diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index a62c1de..9f90623 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -212,4 +212,6 @@
 tc->setIntReg(SyscallSuccessReg, (uint32_t)(-1));
 tc->setIntReg(ReturnValueReg, sysret.errnoValue());
 }
+if (sysret.count() > 1)
+tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index 189afac..ce1503c 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -536,4 +536,6 @@
 val = bits(val, 31, 0);
 tc->setIntReg(ReturnValueReg, val);
 }
+if (sysret.count() > 1)
+tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 30bc2d3..b1f098f 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -980,8 +980,7 @@
 // not getting a unique value.

 auto process = tc->getProcessPtr();
-tc->setIntReg(SyscallPseudoReturnReg, process->ppid());
-return process->pid();
+return SyscallReturn(process->pid(), process->ppid());
 }


@@ -991,20 +990,17 @@
 // Make up a UID and EUID... it shouldn't matter, and we want the
 // simulation to be deterministic.

-// EUID goes in r20.
 auto process = tc->getProcessPtr();
-tc->setIntReg(SyscallPseudoReturnReg, process->euid()); // EUID
-return process->uid(); // UID
+return SyscallReturn(process->uid(), process->euid());
 }


 SyscallReturn
 getgidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
 {
-// Get current group ID.  EGID goes in r20.
+// Get current group ID.
 auto process = tc->getProcessPtr();
-tc->setIntReg(SyscallPseudoReturnReg, process->egid()); // EGID
-return process->gid();
+return SyscallReturn(process->gid(), process->egid());
 }


diff --git a/src/sim/syscall_return.hh b/src/sim/syscall_return.hh
index b60434e..49a0d2f 100644
--- a/src/sim/syscall_return.hh
+++ b/src/sim/syscall_return.hh
@@ -63,10 +63,16 @@
 /// conversion, so a bare integer is used where a SyscallReturn
 /// value is expected, e.g., as the return value from a system
 /// call emulation function ('return 0;' or 'return -EFAULT;').
-SyscallReturn(int64_t v) : value(v) {}
+SyscallReturn(int64_t v) : _value(v), _count(1) {}

 /// A SyscallReturn constructed with no value means don't return  
anything.

-SyscallReturn() : suppressedFlag(true) {}
+SyscallReturn() : _count(0) {}
+
+/// A SyscallReturn constructed with two values means put the second  
value
+/// in additional return registers as defined by the ABI, if they  
exist.

+SyscallReturn(int64_t v1, int64_t v2) :
+_value(v1), _value2(v2), _count(2)
+{}

 /// Pseudo-constructor to create an instance with the retry flag set.
 static SyscallReturn
@@ -83,21 +89,24 @@
 bool
 successful() const
 {
-return (value >= 0 || value <= -4096);
+return (_value >= 0 || _value <= -4096);
 }

 /// Does the syscall need to be retried?
 bool needsRetry() const { return retryFlag; }

 /// Should returning this value be suppressed?
-bool suppressed() const { return suppressedFlag; }
+bool suppressed() const { return _count == 0; }
+
+/// How many values did the syscall 

[gem5-dev] Change in gem5/gem5[master]: x86: In X86 linux, system calls simply return their result in a regis...

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23442 )



Change subject: x86: In X86 linux, system calls simply return their result  
in a register.

..

x86: In X86 linux, system calls simply return their result in a register.

We can partially define an x86 linux system call ABI which handles the
return value. Argument gathering would be handled elsewhere.

Change-Id: Id2841dea39aa2ea3fc42e1a0fb70ff4e477b3671
---
M src/arch/x86/linux/linux.hh
1 file changed, 23 insertions(+), 0 deletions(-)



diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh
index 2192e50..fe8bd23 100644
--- a/src/arch/x86/linux/linux.hh
+++ b/src/arch/x86/linux/linux.hh
@@ -42,6 +42,8 @@

 #include "arch/x86/utility.hh"
 #include "kern/linux/linux.hh"
+#include "sim/guest_abi.hh"
+#include "sim/syscall_return.hh"

 class X86Linux : public Linux
 {
@@ -64,6 +66,27 @@
 if (stack)
 ctc->setIntReg(X86ISA::StackPointerReg, stack);
 }
+
+class SyscallABI
+{
+};
+};
+
+namespace GuestABI
+{
+
+template 
+struct Result::value>::type>
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+tc->setIntReg(ABI::ReturnValueReg, ret.encodedValue());
+}
+};
+
 };

 class X86Linux64 : public X86Linux

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23442
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Id2841dea39aa2ea3fc42e1a0fb70ff4e477b3671
Gerrit-Change-Number: 23442
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: arm: Use an ARM specific GuestABI for ARM system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23448 )



Change subject: arm: Use an ARM specific GuestABI for ARM system calls.
..

arm: Use an ARM specific GuestABI for ARM system calls.

Change-Id: I2d0d0a563355f43ed791ba2f2a1894e303cca994
---
M src/arch/arm/freebsd/process.cc
M src/arch/arm/freebsd/process.hh
M src/arch/arm/linux/process.cc
M src/arch/arm/linux/process.hh
M src/arch/arm/process.cc
M src/arch/arm/process.hh
6 files changed, 122 insertions(+), 6 deletions(-)



diff --git a/src/arch/arm/freebsd/process.cc  
b/src/arch/arm/freebsd/process.cc

index 58edefc..e384e6a 100644
--- a/src/arch/arm/freebsd/process.cc
+++ b/src/arch/arm/freebsd/process.cc
@@ -131,7 +131,7 @@
 }
 #endif

-static SyscallDescABI syscallDescs32[] = {
+static SyscallDescABI syscallDescs32[] = {
 /*0 */ { "unused#000" },
 /*1 */ { "unused#001" },
 /*2 */ { "unused#002" },
@@ -682,7 +682,7 @@
 /*  547 */ { "unused#547" },
 };

-static SyscallDescABI syscallDescs64[] = {
+static SyscallDescABI syscallDescs64[] = {
 /*0 */ { "unused#000" },
 /*1 */ { "exit", exitFunc },
 /*2 */ { "unused#002" },
diff --git a/src/arch/arm/freebsd/process.hh  
b/src/arch/arm/freebsd/process.hh

index 5f4a896..8c28232 100644
--- a/src/arch/arm/freebsd/process.hh
+++ b/src/arch/arm/freebsd/process.hh
@@ -52,8 +52,40 @@
 };

 std::vector syscallTables;
+
+struct SyscallABI {};
 };

+namespace GuestABI
+{
+
+template 
+struct Result::value>::type>
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+RegVal val;
+if (ret.successful()) {
+tc->setCCReg(ArmISA::CCREG_C, 0);
+val = ret.returnValue();
+} else {
+tc->setCCReg(ArmISA::CCREG_C, 1);
+val = ret.encodedValue();
+}
+tc->setIntReg(ArmISA::ReturnValueReg, val);
+if (ret.count() > 1)
+tc->setIntReg(ArmISA::SyscallPseudoReturnReg, ret.value2());
+}
+};
+
+} // namespace GuestABI
+
 /// A process with emulated Arm/Freebsd syscalls.
 class ArmFreebsdProcess32 : public ArmProcess32, public  
ArmFreebsdProcessBits

 {
@@ -72,6 +104,10 @@
 static const Addr commPage;

 SyscallDesc* getDesc(int callnum);
+
+struct SyscallABI : public ArmProcess32::SyscallABI,
+public ArmFreebsdProcessBits::SyscallABI
+{};
 };

 /// A process with emulated Arm/Freebsd syscalls.
@@ -84,6 +120,10 @@
 void initState();
 void syscall(ThreadContext *tc, Fault *fault) override;
 SyscallDesc* getDesc(int callnum);
+
+struct SyscallABI : public ArmProcess64::SyscallABI,
+public ArmFreebsdProcessBits::SyscallABI
+{};
 };

 #endif // __ARCH_ARM_FREEBSD_PROCESS_HH__
diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc
index c2ff32c..a45c438 100644
--- a/src/arch/arm/linux/process.cc
+++ b/src/arch/arm/linux/process.cc
@@ -156,7 +156,7 @@
 return 0;
 }

-static SyscallDescABI syscallDescs32[] = {
+static SyscallDescABI syscallDescs32[] = {
 /*  0 */ { "syscall" },
 /*  1 */ { "exit", exitFunc },
 /*  2 */ { "fork" },
@@ -533,7 +533,7 @@
 /* 365 */ { "sys_recvmmsg" },
 };

-static SyscallDescABI syscallDescs64[] = {
+static SyscallDescABI syscallDescs64[] = {
 /*0 */ { "io_setup" },
 /*1 */ { "io_destroy" },
 /*2 */ { "io_submit" },
@@ -1624,7 +1624,7 @@
 /* 1079 */ { "fork" }
 };

-static SyscallDescABI privSyscallDescs32[] = {
+static SyscallDescABI privSyscallDescs32[]  
= {

 /*  1 */ { "breakpoint" },
 /*  2 */ { "cacheflush" },
 /*  3 */ { "usr26" },
@@ -1633,7 +1633,7 @@
 };

 // Indices 1, 3 and 4 are unallocated.
-static SyscallDescABI privSyscallDescs64[] = {
+static SyscallDescABI privSyscallDescs64[]  
= {

 /*  1 */ { "unallocated" },
 /*  2 */ { "cacheflush" },
 /*  3 */ { "unallocated" },
diff --git a/src/arch/arm/linux/process.hh b/src/arch/arm/linux/process.hh
index 8e2709f..8f13279 100644
--- a/src/arch/arm/linux/process.hh
+++ b/src/arch/arm/linux/process.hh
@@ -62,8 +62,32 @@
 };

 std::vector syscallTables;
+
+struct SyscallABI {};
 };

+namespace GuestABI
+{
+
+template 
+struct Result::value>::type>
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+tc->setIntReg(ArmISA::ReturnValueReg, ret.encodedValue());
+if (ret.count() > 1)
+tc->setIntReg(ArmISA::SyscallPseudoReturnReg, ret.value2());
+}
+};
+
+} // namespace GuestABI
+
 /// A process with emulated Arm/Linux syscalls.
 class ArmLinuxProcess32 : public ArmProcess32, public ArmLinuxProcessBits
 {
@@ -82,6 +106,10 @@
 static const Addr 

[gem5-dev] Change in gem5/gem5[master]: sim: Get rid of the no longer needed DefaultSyscallABI.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23458 )



Change subject: sim: Get rid of the no longer needed DefaultSyscallABI.
..

sim: Get rid of the no longer needed DefaultSyscallABI.

All ISAs now have their own ABI definitions.

Change-Id: I20484b024227658bed7093c232ebf7d64f29bdb6
---
M src/sim/syscall_desc.hh
1 file changed, 0 insertions(+), 46 deletions(-)



diff --git a/src/sim/syscall_desc.hh b/src/sim/syscall_desc.hh
index c34dc90..4d71add 100644
--- a/src/sim/syscall_desc.hh
+++ b/src/sim/syscall_desc.hh
@@ -154,50 +154,4 @@
 using SyscallDesc::SyscallDesc;
 };

-struct DefaultSyscallABI
-{
-using Position = int;
-};
-
-namespace GuestABI
-{
-
-template <>
-struct Result
-{
-static void
-store(ThreadContext *tc, const SyscallReturn )
-{
-auto *process = tc->getProcessPtr();
-process->setSyscallReturn(tc, ret);
-}
-};
-
-template 
-struct Argument::value>::type>
-{
-static Arg
-get(ThreadContext *tc, DefaultSyscallABI::Position )
-{
-auto *process = tc->getProcessPtr();
-return process->getSyscallArg(tc, position);
-}
-};
-
-template 
-struct Argument::value>::type>
-{
-static Arg
-get(ThreadContext *tc, DefaultSyscallABI::Position )
-{
-auto *process = tc->getProcessPtr();
-RegVal reg = process->getSyscallArg(tc, position);
-return (Arg)(uintptr_t)(reg);
-}
-};
-
-} // namespace GuestABI
-
 #endif // __SIM_SYSCALL_DESC_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23458
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I20484b024227658bed7093c232ebf7d64f29bdb6
Gerrit-Change-Number: 23458
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sparc: Get rid of some commented out constants.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23444 )



Change subject: sparc: Get rid of some commented out constants.
..

sparc: Get rid of some commented out constants.

Change-Id: Ie2a223f5f969402a03b924ef767eddbcc14bf312
---
M src/arch/sparc/sparc_traits.hh
1 file changed, 0 insertions(+), 5 deletions(-)



diff --git a/src/arch/sparc/sparc_traits.hh b/src/arch/sparc/sparc_traits.hh
index 5f37292..84c94b9 100644
--- a/src/arch/sparc/sparc_traits.hh
+++ b/src/arch/sparc/sparc_traits.hh
@@ -41,15 +41,10 @@

 // Number of register windows, can legally be 3 to 32
 const int NWindows = 8;
-// const int NumMicroIntRegs = 1;
 const int NumMicroIntRegs = 9;

-// const int NumRegularIntRegs = MaxGL * 8 + NWindows * 16;
-// const int NumMicroIntRegs = 1;
-// const int NumIntRegs = NumRegularIntRegs + NumMicroIntRegs;
 const int NumFloatRegs = 64;
 const int NumFloatArchRegs = NumFloatRegs;
-// const int NumMiscRegs = 40;
 }

 #endif // __ARCH_SPARC_SPARC_TRAITS_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23444
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie2a223f5f969402a03b924ef767eddbcc14bf312
Gerrit-Change-Number: 23444
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim: Clean up some constants used in some syscalls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23455 )



Change subject: sim: Clean up some constants used in some syscalls.
..

sim: Clean up some constants used in some syscalls.

Having readable constants for these large numbers is good, but they
used incorrect style, were at global scope, and were only used in one
place.

This change centralizes them where they're used, fixes their style, and
rewrites the actual constants in a way that makes it clear what they're
values are.

Change-Id: Ib89c46fce133d4180296d384a61d51d1fe1f8d20
---
M src/sim/syscall_emul.hh
1 file changed, 9 insertions(+), 10 deletions(-)



diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 5537817..27b4a43 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -523,15 +523,10 @@
 SyscallReturn getxgidFunc(SyscallDesc *desc, int num, ThreadContext *tc);


-/// A readable name for 1,000,000, for converting microseconds to seconds.
-const int one_million = 100;
-/// A readable name for 1,000,000,000, for converting nanoseconds to  
seconds.

-const int one_billion = 10;
-
 /// Approximate seconds since the epoch (1/1/1970).  About a billion,
 /// by my reckoning.  We want to keep this a constant (not use the
 /// real-world time) to keep simulations repeatable.
-const unsigned seconds_since_epoch = 10;
+const unsigned seconds_since_epoch = 1000 * 1000 * 1000;

 /// Helper function to convert current elapsed time to seconds and
 /// microseconds.
@@ -539,9 +534,11 @@
 void
 getElapsedTimeMicro(T1 , T2 )
 {
+static const int OneMillion = 1000 * 1000;
+
 uint64_t elapsed_usecs = curTick() / SimClock::Int::us;
-sec = elapsed_usecs / one_million;
-usec = elapsed_usecs % one_million;
+sec = elapsed_usecs / OneMillion;
+usec = elapsed_usecs % OneMillion;
 }

 /// Helper function to convert current elapsed time to seconds and
@@ -550,9 +547,11 @@
 void
 getElapsedTimeNano(T1 , T2 )
 {
+static const int OneBillion = 1000 * 1000 * 1000;
+
 uint64_t elapsed_nsecs = curTick() / SimClock::Int::ns;
-sec = elapsed_nsecs / one_billion;
-nsec = elapsed_nsecs % one_billion;
+sec = elapsed_nsecs / OneBillion;
+nsec = elapsed_nsecs % OneBillion;
 }

 //

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23455
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ib89c46fce133d4180296d384a61d51d1fe1f8d20
Gerrit-Change-Number: 23455
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sparc: Introduce constants for pseudo integer registers.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23445 )



Change subject: sparc: Introduce constants for pseudo integer registers.
..

sparc: Introduce constants for pseudo integer registers.

These are "integer" registers which are renamed, but which aren't
normally considered integer registers by the ISA. They had been indexed
by adding an opaque constant to the number of official integer
registers which obscured what they were, and was also fragile and
invited mistakes.

Change-Id: Idab8cf4d889682b98c7c81a00d9a92d8e3bb3a05
---
M src/arch/sparc/faults.cc
M src/arch/sparc/isa/operands.isa
M src/arch/sparc/linux/linux.hh
M src/arch/sparc/nativetrace.cc
M src/arch/sparc/process.cc
M src/arch/sparc/registers.hh
M src/arch/sparc/remote_gdb.cc
M src/arch/sparc/sparc_traits.hh
8 files changed, 88 insertions(+), 73 deletions(-)



diff --git a/src/arch/sparc/faults.cc b/src/arch/sparc/faults.cc
index 3859b30..0057f12 100644
--- a/src/arch/sparc/faults.cc
+++ b/src/arch/sparc/faults.cc
@@ -306,10 +306,10 @@
 RegVal TSTATE = tc->readMiscRegNoEffect(MISCREG_TSTATE);
 PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
 HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
-RegVal CCR = tc->readIntReg(NumIntArchRegs + 2);
+RegVal CCR = tc->readIntReg(INTREG_CCR);
 RegVal ASI = tc->readMiscRegNoEffect(MISCREG_ASI);
 RegVal CWP = tc->readMiscRegNoEffect(MISCREG_CWP);
-RegVal CANSAVE = tc->readMiscRegNoEffect(NumIntArchRegs + 3);
+RegVal CANSAVE = tc->readMiscRegNoEffect(INTREG_CANSAVE);
 RegVal GL = tc->readMiscRegNoEffect(MISCREG_GL);
 PCState pc = tc->pcState();

@@ -385,10 +385,10 @@
 RegVal TSTATE = tc->readMiscRegNoEffect(MISCREG_TSTATE);
 PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
 HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
-RegVal CCR = tc->readIntReg(NumIntArchRegs + 2);
+RegVal CCR = tc->readIntReg(INTREG_CCR);
 RegVal ASI = tc->readMiscRegNoEffect(MISCREG_ASI);
 RegVal CWP = tc->readMiscRegNoEffect(MISCREG_CWP);
-RegVal CANSAVE = tc->readIntReg(NumIntArchRegs + 3);
+RegVal CANSAVE = tc->readIntReg(INTREG_CANSAVE);
 RegVal GL = tc->readMiscRegNoEffect(MISCREG_GL);
 PCState pc = tc->pcState();

diff --git a/src/arch/sparc/isa/operands.isa  
b/src/arch/sparc/isa/operands.isa

index 26c0d87..6681dbe 100644
--- a/src/arch/sparc/isa/operands.isa
+++ b/src/arch/sparc/isa/operands.isa
@@ -89,7 +89,7 @@
 'Rs1':  ('IntReg', 'udw', 'RS1', 'IsInteger', 6),
 'Rs2':  ('IntReg', 'udw', 'RS2', 'IsInteger', 7),
 # A microcode register. Right now, this is the only one.
-'uReg0':('IntReg', 'udw', 'NumIntArchRegs', 'IsInteger',  
8),

+'uReg0':('IntReg', 'udw', 'INTREG_UREG0', 'IsInteger', 8),
 # Because double and quad precision register numbers are decoded
 # differently, they get different operands. The single precision  
versions

 # have an s post pended to their name.
@@ -139,24 +139,21 @@
 'R1':   ('IntReg', 'udw', '1', None, 7),
 'R15':  ('IntReg', 'udw', '15', 'IsInteger', 8),
 'R16':  ('IntReg', 'udw', '16', None, 9),
-'O0':   ('IntReg', 'udw', '8', 'IsInteger', 10),
-'O1':   ('IntReg', 'udw', '9', 'IsInteger', 11),
-'O2':   ('IntReg', 'udw', '10', 'IsInteger', 12),
-'O3':   ('IntReg', 'udw', '11', 'IsInteger', 13),
-'O4':   ('IntReg', 'udw', '12', 'IsInteger', 14),
-'O5':   ('IntReg', 'udw', '13', 'IsInteger', 15),
+'O0':   ('IntReg', 'udw', 'INTREG_O0', 'IsInteger', 10),
+'O1':   ('IntReg', 'udw', 'INTREG_O1', 'IsInteger', 11),
+'O2':   ('IntReg', 'udw', 'INTREG_O2', 'IsInteger', 12),
+'O3':   ('IntReg', 'udw', 'INTREG_O3', 'IsInteger', 13),
+'O4':   ('IntReg', 'udw', 'INTREG_O4', 'IsInteger', 14),
+'O5':   ('IntReg', 'udw', 'INTREG_O5', 'IsInteger', 15),

 # Control registers
-#   'Y':('ControlReg', 'udw', 'MISCREG_Y', None, 40),
-#   'Ccr':  ('ControlReg', 'udw', 'MISCREG_CCR', None, 41),
-'Y':('IntReg', 'udw', 'NumIntArchRegs + 1', None, 40),
-'Ccr':  ('IntReg', 'udw', 'NumIntArchRegs + 2', None, 41),
+'Y':('IntReg', 'udw', 'INTREG_Y', None, 40),
+'Ccr':  ('IntReg', 'udw', 'INTREG_CCR', None, 41),
 'Asi':  ('ControlReg', 'udw', 'MISCREG_ASI', None, 42),
 'Fprs': ('ControlReg', 'udw', 'MISCREG_FPRS', None, 43),
 'Pcr':  ('ControlReg', 'udw', 'MISCREG_PCR', None, 44),
 'Pic':  ('ControlReg', 'udw', 'MISCREG_PIC', None, 45),
-#   'Gsr':  ('ControlReg', 'udw', 'MISCREG_GSR', 

[gem5-dev] Change in gem5/gem5[master]: mips: Use a mips specific GuestABI for mips system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23451 )



Change subject: mips: Use a mips specific GuestABI for mips system calls.
..

mips: Use a mips specific GuestABI for mips system calls.

Change-Id: Ice9fb867b47e56bc00b171399a82b2892b16c9e4
---
M src/arch/mips/linux/process.cc
M src/arch/mips/linux/process.hh
M src/arch/mips/process.cc
M src/arch/mips/process.hh
4 files changed, 40 insertions(+), 2 deletions(-)



diff --git a/src/arch/mips/linux/process.cc b/src/arch/mips/linux/process.cc
index 1f3ee99..15cdce1 100644
--- a/src/arch/mips/linux/process.cc
+++ b/src/arch/mips/linux/process.cc
@@ -154,7 +154,7 @@
 return 0;
 }

-SyscallDescABI MipsLinuxProcess::syscallDescs[] = {
+SyscallDescABI MipsLinuxProcess::syscallDescs[] =  
{

 /*  0 */ { "syscall" },
 /*  1 */ { "exit", exitFunc },
 /*  2 */ { "fork" },
diff --git a/src/arch/mips/linux/process.hh b/src/arch/mips/linux/process.hh
index b2ab91e..361390c 100644
--- a/src/arch/mips/linux/process.hh
+++ b/src/arch/mips/linux/process.hh
@@ -55,7 +55,7 @@
 void syscall(ThreadContext *tc, Fault *fault) override;

 /// Array of syscall descriptors, indexed by call number.
-static SyscallDescABI syscallDescs[];
+static SyscallDescABI syscallDescs[];
 const int Num_Syscall_Descs;
 };

diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index 9f90623..8e279cf 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -215,3 +215,7 @@
 if (sysret.count() > 1)
 tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }
+
+const std::vector MipsProcess::SyscallABI::ArgumentRegs = {
+4, 5, 6, 7, 8, 9
+};
diff --git a/src/arch/mips/process.hh b/src/arch/mips/process.hh
index fb31bef..20fbacf 100644
--- a/src/arch/mips/process.hh
+++ b/src/arch/mips/process.hh
@@ -37,6 +37,7 @@

 #include "mem/page_table.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"

 class ObjectFile;

@@ -55,6 +56,39 @@
 /// Explicitly import the otherwise hidden getSyscallArg
 using Process::getSyscallArg;
 void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
+
+struct SyscallABI : public GenericSyscallABI64
+{
+static const std::vector ArgumentRegs;
+};
 };

+namespace GuestABI
+{
+
+template <>
+struct Result
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+if (ret.successful()) {
+// no error
+tc->setIntReg(MipsISA::SyscallSuccessReg, 0);
+tc->setIntReg(MipsISA::ReturnValueReg, ret.returnValue());
+} else {
+// got an error, return details
+tc->setIntReg(MipsISA::SyscallSuccessReg, (uint32_t)(-1));
+tc->setIntReg(MipsISA::ReturnValueReg, ret.errnoValue());
+}
+if (ret.count() > 1)
+tc->setIntReg(MipsISA::SyscallPseudoReturnReg, ret.value2());
+}
+};
+
+} // namespace GuestABI
+
 #endif // __MIPS_PROCESS_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23451
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ice9fb867b47e56bc00b171399a82b2892b16c9e4
Gerrit-Change-Number: 23451
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim: Rework the SyscallDesc to use the dumpSimcall mechanism.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23461 )



Change subject: sim: Rework the SyscallDesc to use the dumpSimcall  
mechanism.

..

sim: Rework the SyscallDesc to use the dumpSimcall mechanism.

This greatly simplifies the doSyscall method, removes a use of
getSyscallArg, and will only print arguments the target syscall is
going to use.

Change-Id: Id8c9c995a2506468fd99fd865f2eb31c40db8b55
---
M src/sim/syscall_desc.cc
M src/sim/syscall_desc.hh
2 files changed, 40 insertions(+), 58 deletions(-)



diff --git a/src/sim/syscall_desc.cc b/src/sim/syscall_desc.cc
index 3d767f0..7a18f03 100644
--- a/src/sim/syscall_desc.cc
+++ b/src/sim/syscall_desc.cc
@@ -33,54 +33,22 @@

 #include "sim/syscall_desc.hh"

-#include 
-
-#include "base/trace.hh"
 #include "base/types.hh"
-#include "config/the_isa.hh"
-#include "cpu/base.hh"
-#include "cpu/thread_context.hh"
-#include "sim/faults.hh"
-#include "sim/process.hh"
 #include "sim/syscall_debug_macros.hh"

+class ThreadContext;
+
 void
 SyscallDesc::doSyscall(int callnum, ThreadContext *tc, Fault *fault)
 {
-RegVal arg[6] M5_VAR_USED;
-auto process = tc->getProcessPtr();
+DPRINTF_SYSCALL(Base, "Calling %s...\n", dumper(name(), tc));

-/**
- * Step through the first six parameters for the system call and
- * retrieve their values. Note that index is incremented as a
- * side-effect of the getSyscallArg method.
- */
-int index = 0;
-for (int i = 0; i < 6; i++)
-arg[i] = process->getSyscallArg(tc, index);
-
-/**
- * Linux supports up to six system call arguments through registers
- * so we want to print all six. Check to the relevant man page to
- * verify how many are actually used by a given system call.
- */
-DPRINTF_SYSCALL(Base, "%s called w/arguments %d, %d, %d, %d, %d, %d\n",
-_name, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
-
-/** Invoke the system call */
 SyscallReturn retval = executor(this, callnum, tc);

-/**
- * If the system call needs to be restarted, most likely due to
- * blocking behavior, warn that the system call will retry;
- * alternatively, print the return value.
- */
-if (retval.needsRetry()) {
-*fault = std::make_shared();
-DPRINTF_SYSCALL(Base, "%s needs retry\n", _name);
-} else
-DPRINTF_SYSCALL(Base, "%s returns %d\n", _name,  
retval.encodedValue());

-
-if (!retval.suppressed() && !retval.needsRetry())
-process->setSyscallReturn(tc, retval);
+if (retval.needsRetry())
+DPRINTF_SYSCALL(Base, "Needs retry.\n", name());
+else if (retval.suppressed())
+DPRINTF_SYSCALL(Base, "No return value.\n", name());
+else
+DPRINTF_SYSCALL(Base, "Returned %d.\n", retval.encodedValue());
 }
diff --git a/src/sim/syscall_desc.hh b/src/sim/syscall_desc.hh
index 4d71add..0ac357d 100644
--- a/src/sim/syscall_desc.hh
+++ b/src/sim/syscall_desc.hh
@@ -68,13 +68,6 @@
  */
 class SyscallDesc {
   public:
-using SyscallExecutor =
-std::function*)>;

-
-SyscallDesc(const char *name, SyscallExecutor  
sys_exec=unimplementedFunc)

-: _name(name), executor(sys_exec)
-{}
-
 /**
  * Interface for invoking the system call funcion pointer. Note that
  * this acts as a gateway for all system calls and serves a good point
@@ -87,12 +80,22 @@

 std::string name() { return _name; }

+  protected:
+using Executor =
+std::function*)>;
+using Dumper = std::function*)>;

+
+SyscallDesc(const char *name, Executor exec, Dumper dump) :
+_name(name), executor(exec), dumper(dump)
+{}
+
   private:
 /** System call name (e.g., open, mmap, clone, socket, etc.) */
 std::string _name;

 /** Mechanism for ISAs to connect to the emul function definitions */
-SyscallExecutor executor;
+Executor executor;
+Dumper dumper;
 };

 /*
@@ -106,20 +109,20 @@
   private:
 // Aliases to make the code below a little more concise.
 template 
-using SyscallABIExecutor =
+using ABIExecutor =
 std::function;

 template 
-using SyscallABIExecutorPtr =
+using ABIExecutorPtr =
 SyscallReturn (*)(SyscallDesc *, int, ThreadContext *, Args...);


 // Wrap an executor with guest arguments with a normal executor that  
gets

 // those additional arguments from the guest context.
 template 
-static inline SyscallExecutor
-buildExecutor(SyscallABIExecutor target)
+static inline Executor
+buildExecutor(ABIExecutor target)
 {
 return [target](SyscallDesc *desc, int num,
 ThreadContext *tc) -> SyscallReturn {
@@ -138,20 +141,31 @@
 };
 }

+template 
+static inline Dumper
+buildDumper()
+{
+return [](std::string name, ThreadContext *tc) -> 

[gem5-dev] Change in gem5/gem5[master]: x86: Define a local ABI for system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23443 )



Change subject: x86: Define a local ABI for system calls.
..

x86: Define a local ABI for system calls.

These ABIs (one 32 bit and one 64 bit) take advantage of the
GenericSyscallABI and X86Linux::SyscallABI partial ABIs set up earlier.

This removes x86's dependence on the getSyscallArg and setSyscallReturn
Process methods.

Change-Id: Ia07834cea1afa827d77e590af5397e2a1e0e2099
---
M src/arch/x86/linux/linux.hh
M src/arch/x86/linux/process.cc
M src/arch/x86/linux/process.hh
3 files changed, 50 insertions(+), 6 deletions(-)



diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh
index fe8bd23..3fd1778 100644
--- a/src/arch/x86/linux/linux.hh
+++ b/src/arch/x86/linux/linux.hh
@@ -67,9 +67,7 @@
 ctc->setIntReg(X86ISA::StackPointerReg, stack);
 }

-class SyscallABI
-{
-};
+class SyscallABI {};
 };

 namespace GuestABI
@@ -83,7 +81,10 @@
 static void
 store(ThreadContext *tc, const SyscallReturn )
 {
-tc->setIntReg(ABI::ReturnValueReg, ret.encodedValue());
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+tc->setIntReg(X86ISA::INTREG_RAX, ret.encodedValue());
 }
 };

diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc
index 47e9f27..31b8989 100644
--- a/src/arch/x86/linux/process.cc
+++ b/src/arch/x86/linux/process.cc
@@ -252,7 +252,11 @@
 return 0;
 }

-static SyscallDescABI syscallDescs64[] = {
+const std::vector  
X86_64LinuxProcess::SyscallABI::ArgumentRegs = {

+INTREG_RDI, INTREG_RSI, INTREG_RDX, INTREG_R10W, INTREG_R8W, INTREG_R9W
+};
+
+static SyscallDescABI syscallDescs64[] = {
 /*   0 */ { "read", readFunc },
 /*   1 */ { "write", writeFunc },
 /*   2 */ { "open", openFunc },
@@ -592,7 +596,11 @@
 X86_64Process::clone(old_tc, new_tc, (X86_64Process*)process, flags);
 }

-static SyscallDescABI syscallDescs32[] = {
+const std::vector I386LinuxProcess::SyscallABI::ArgumentRegs  
= {

+INTREG_EBX, INTREG_ECX, INTREG_EDX, INTREG_ESI, INTREG_EDI, INTREG_EBP
+};
+
+static SyscallDescABI syscallDescs32[] = {
 /*   0 */ { "restart_syscall" },
 /*   1 */ { "exit", exitFunc },
 /*   2 */ { "fork" },
diff --git a/src/arch/x86/linux/process.hh b/src/arch/x86/linux/process.hh
index 5f3135d..d7df138 100644
--- a/src/arch/x86/linux/process.hh
+++ b/src/arch/x86/linux/process.hh
@@ -43,6 +43,7 @@
 #include "arch/x86/linux/linux.hh"
 #include "arch/x86/process.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"

 struct ProcessParams;
 struct ThreadContext;
@@ -57,6 +58,11 @@
 void syscall(ThreadContext *tc, Fault *fault) override;
 void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process  
*process,

RegVal flags);
+
+struct SyscallABI : public GenericSyscallABI64, public  
X86Linux::SyscallABI

+{
+static const std::vector ArgumentRegs;
+};
 };

 class I386LinuxProcess : public I386Process
@@ -67,7 +73,36 @@
 void syscall(ThreadContext *tc, Fault *fault) override;
 void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process  
*process,

RegVal flags);
+
+struct SyscallABI : public GenericSyscallABI32, public  
X86Linux::SyscallABI

+{
+static const std::vector ArgumentRegs;
+};
 };

 } // namespace X86ISA
+
+namespace GuestABI
+{
+
+template 
+struct Argument::value>::type>
+{
+using ABI = X86ISA::I386LinuxProcess::SyscallABI;
+
+static Arg
+get(ThreadContext *tc, typename ABI::Position )
+{
+panic_if(position + 1 >= ABI::ArgumentRegs.size(),
+"Ran out of syscall argument registers.");
+auto low = ABI::ArgumentRegs[position++];
+auto high = ABI::ArgumentRegs[position++];
+return (Arg)ABI::mergeRegs(tc, low, high);
+}
+};
+
+} // namespace GuestABI
+
 #endif // __X86_LINUX_PROCESS_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23443
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ia07834cea1afa827d77e590af5397e2a1e0e2099
Gerrit-Change-Number: 23443
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: power: Use a power specific GuestABI for power system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23452 )



Change subject: power: Use a power specific GuestABI for power system calls.
..

power: Use a power specific GuestABI for power system calls.

Change-Id: I39cf64c025c284b63980f3c2e48fbd8b6c355d2b
---
M src/arch/power/linux/process.cc
M src/arch/power/linux/process.hh
M src/arch/power/process.cc
M src/arch/power/process.hh
4 files changed, 37 insertions(+), 2 deletions(-)



diff --git a/src/arch/power/linux/process.cc  
b/src/arch/power/linux/process.cc

index a7232d8..13d7c85 100644
--- a/src/arch/power/linux/process.cc
+++ b/src/arch/power/linux/process.cc
@@ -95,7 +95,7 @@
 return 0;
 }

-SyscallDescABI PowerLinuxProcess::syscallDescs[] = {
+SyscallDescABI PowerLinuxProcess::syscallDescs[]  
= {

 /*  0 */ { "syscall" },
 /*  1 */ { "exit", exitFunc },
 /*  2 */ { "fork" },
diff --git a/src/arch/power/linux/process.hh  
b/src/arch/power/linux/process.hh

index 60b38a1..1c9230d 100644
--- a/src/arch/power/linux/process.hh
+++ b/src/arch/power/linux/process.hh
@@ -54,7 +54,7 @@
 using Process::getSyscallArg;

 /// Array of syscall descriptors, indexed by call number.
-static SyscallDescABI syscallDescs[];
+static SyscallDescABI syscallDescs[];

 const int Num_Syscall_Descs;
 };
diff --git a/src/arch/power/process.cc b/src/arch/power/process.cc
index fdef2fa..c095879 100644
--- a/src/arch/power/process.cc
+++ b/src/arch/power/process.cc
@@ -291,3 +291,7 @@
 tc->setIntReg(INTREG_CR, cr);
 tc->setIntReg(ReturnValueReg, sysret.encodedValue());
 }
+
+const std::vector PowerProcess::SyscallABI::ArgumentRegs = {
+3, 4, 5, 6, 7
+};
diff --git a/src/arch/power/process.hh b/src/arch/power/process.hh
index f746f11..db43461 100644
--- a/src/arch/power/process.hh
+++ b/src/arch/power/process.hh
@@ -38,6 +38,7 @@

 #include "mem/page_table.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"

 class ObjectFile;

@@ -54,7 +55,37 @@
 /// Explicitly import the otherwise hidden getSyscallArg
 using Process::getSyscallArg;
 void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
+
+struct SyscallABI : public GenericSyscallABI64
+{
+static const std::vector ArgumentRegs;
+};
 };

+namespace GuestABI
+{
+
+template <>
+struct Result
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+PowerISA::Cr cr = tc->readIntReg(PowerISA::INTREG_CR);
+if (ret.successful()) {
+cr.cr0.so = 0;
+} else {
+cr.cr0.so = 1;
+}
+tc->setIntReg(PowerISA::INTREG_CR, cr);
+tc->setIntReg(PowerISA::ReturnValueReg, ret.encodedValue());
+}
+};
+
+} // namespace GuestABI
+
 #endif // __POWER_PROCESS_HH__


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23452
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I39cf64c025c284b63980f3c2e48fbd8b6c355d2b
Gerrit-Change-Number: 23452
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sparc: Use a SPARC specific GuestABI for system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23447 )



Change subject: sparc: Use a SPARC specific GuestABI for system calls.
..

sparc: Use a SPARC specific GuestABI for system calls.

Change-Id: I41996cada5ccde7b265e5315829ac6690da8902f
---
M src/arch/sparc/linux/process.hh
M src/arch/sparc/linux/syscalls.cc
M src/arch/sparc/process.cc
M src/arch/sparc/process.hh
M src/arch/sparc/solaris/process.cc
M src/arch/sparc/solaris/process.hh
6 files changed, 91 insertions(+), 8 deletions(-)



diff --git a/src/arch/sparc/linux/process.hh  
b/src/arch/sparc/linux/process.hh

index b7a4117..f16cc19 100644
--- a/src/arch/sparc/linux/process.hh
+++ b/src/arch/sparc/linux/process.hh
@@ -45,11 +45,11 @@
 {
   public:
  /// Array of syscall descriptors, indexed by call number.
-static SyscallDescABI syscallDescs[];
+static SyscallDescABI syscallDescs[];

  /// Array of 32 bit compatibility syscall descriptors,
  /// indexed by call number.
-static SyscallDescABI syscall32Descs[];
+static SyscallDescABI syscall32Descs[];

 SyscallDesc* getDesc(int callnum);
 SyscallDesc* getDesc32(int callnum);
diff --git a/src/arch/sparc/linux/syscalls.cc  
b/src/arch/sparc/linux/syscalls.cc

index 6f8e646..1b8f400 100644
--- a/src/arch/sparc/linux/syscalls.cc
+++ b/src/arch/sparc/linux/syscalls.cc
@@ -83,7 +83,8 @@
 return 0;
 }

-SyscallDescABI SparcLinuxProcess::syscall32Descs[] = {
+SyscallDescABI
+SparcLinuxProcess::syscall32Descs[] = {
 /*   0 */ { "restart_syscall" },
 /*   1 */ { "exit", exitFunc }, // 32 bit
 /*   2 */ { "fork" },
@@ -389,7 +390,8 @@
 const int SparcLinuxProcess::Num_Syscall32_Descs =
 sizeof(SparcLinuxProcess::syscall32Descs) / sizeof(SyscallDesc);

-SyscallDescABI SparcLinuxProcess::syscallDescs[] = {
+SyscallDescABI
+SparcLinuxProcess::syscallDescs[] = {
 /*  0 */ { "restart_syscall" },
 /*  1 */ { "exit", exitFunc },
 /*  2 */ { "fork" },
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index d064de2..50167c7 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -51,8 +51,9 @@
 using namespace std;
 using namespace SparcISA;

-static const int FirstArgumentReg = 8;
-
+const std::vector SparcProcess::SyscallABI::ArgumentRegs = {
+INTREG_O0, INTREG_O1, INTREG_O2, INTREG_O3, INTREG_O4, INTREG_O5
+};

 SparcProcess::SparcProcess(ProcessParams *params, ObjectFile *objFile,
Addr _StackBias)
@@ -493,6 +494,8 @@
 tc->setMiscReg(MISCREG_CWP, origCWP);
 }

+static const int FirstArgumentReg = 8;
+
 RegVal
 Sparc32Process::getSyscallArg(ThreadContext *tc, int )
 {
diff --git a/src/arch/sparc/process.hh b/src/arch/sparc/process.hh
index 2e5379b..d3d6866 100644
--- a/src/arch/sparc/process.hh
+++ b/src/arch/sparc/process.hh
@@ -37,10 +37,12 @@
 #include 

 #include "arch/sparc/isa_traits.hh"
+#include "arch/sparc/miscregs.hh"
 #include "base/loader/object_file.hh"
 #include "mem/page_table.hh"
 #include "sim/byteswap.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"

 class SparcProcess : public Process
 {
@@ -69,8 +71,52 @@

 virtual void flushWindows(ThreadContext *tc) = 0;
 void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
+
+struct SyscallABI
+{
+static const std::vector ArgumentRegs;
+};
 };

+namespace GuestABI
+{
+
+template 
+struct Result::value>::type>
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+// check for error condition.  SPARC syscall convention is to
+// indicate success/failure in reg the carry bit of the ccr
+// and put the return value itself in the standard return value  
reg.

+SparcISA::PSTATE pstate =
+tc->readMiscRegNoEffect(SparcISA::MISCREG_PSTATE);
+SparcISA::CCR ccr = tc->readIntReg(SparcISA::INTREG_CCR);
+RegVal val;
+if (ret.successful()) {
+ccr.xcc.c = ccr.icc.c = 0;
+val = ret.returnValue();
+} else {
+ccr.xcc.c = ccr.icc.c = 1;
+val = ret.errnoValue();
+}
+tc->setIntReg(SparcISA::INTREG_CCR, ccr);
+if (pstate.am)
+val = bits(val, 31, 0);
+tc->setIntReg(SparcISA::ReturnValueReg, val);
+if (ret.count() == 2)
+tc->setIntReg(SparcISA::SyscallPseudoReturnReg, ret.value2());
+}
+};
+
+} // namespace GuestABI
+
 class Sparc32Process : public SparcProcess
 {
   protected:
@@ -111,8 +157,35 @@
 RegVal getSyscallArg(ThreadContext *tc, int );
 /// Explicitly import the otherwise hidden getSyscallArg
 using Process::getSyscallArg;
+
+struct SyscallABI : public GenericSyscallABI32,
+public SparcProcess::SyscallABI
+{};
 };


[gem5-dev] Change in gem5/gem5[master]: sim: Convert the various flavors of pipe to GuestABI.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23457 )



Change subject: sim: Convert the various flavors of pipe to GuestABI.
..

sim: Convert the various flavors of pipe to GuestABI.

Change-Id: I44aaff417ea6a3ce311208b084fe4013bb93a48e
---
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
2 files changed, 24 insertions(+), 48 deletions(-)



diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 53928ff..4c9ebbb 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -813,19 +813,22 @@
 }

 SyscallReturn
-pipeImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool  
pseudo_pipe,

- bool is_pipe2)
+pipePseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
 {
-Addr tgt_addr = 0;
-int flags = 0;
+return pipe2Func(desc, callnum, tc, 0, 0);
+}
+
+SyscallReturn
+pipeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr tgt_addr)
+{
+return pipe2Func(desc, callnum, tc, tgt_addr, 0);
+}
+
+SyscallReturn
+pipe2Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
+  Addr tgt_addr, int flags)
+{
 auto p = tc->getProcessPtr();
-if (!pseudo_pipe) {
-int index = 0;
-tgt_addr = p->getSyscallArg(tc, index);
-if (is_pipe2) {
-flags = p->getSyscallArg(tc, index);
-}
-}

 int sim_fds[2], tgt_fds[2];

@@ -850,13 +853,12 @@
 rpfd->setPipeReadSource(tgt_fds[1]);

 /**
- * Alpha Linux convention for pipe() is that fd[0] is returned as
- * the return value of the function, and fd[1] is returned in r20.
+ * On some architectures, it's possible to use more than one register  
for

+ * a return value. In those cases, pipe returns its values rather than
+ * write them into a buffer.
  */
-if (pseudo_pipe) {
-tc->setIntReg(SyscallPseudoReturnReg, tgt_fds[1]);
-return tgt_fds[0];
-}
+if (tgt_addr == 0)
+return SyscallReturn(tgt_fds[0], tgt_fds[1]);

 /**
  * Copy the target file descriptors into buffer space and then copy
@@ -868,8 +870,7 @@
 buf_ptr[1] = tgt_fds[1];
 tgt_handle.copyOut(tc->getVirtProxy());

-// pipe2 has additional behavior if flags != 0
-if (is_pipe2 && flags) {
+if (flags) {
 // pipe2 only uses O_NONBLOCK, O_CLOEXEC, and (O_NONBLOCK |  
O_CLOEXEC)

 // if flags set to anything else, return EINVAL
 if ((flags != O_CLOEXEC) && (flags != O_NONBLOCK) &&
@@ -910,26 +911,6 @@
 }

 SyscallReturn
-pipePseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
-{
-return pipeImpl(desc, callnum, tc, true);
-}
-
-SyscallReturn
-pipeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
-{
-return pipeImpl(desc, callnum, tc, false);
-}
-
-SyscallReturn
-pipe2Func(SyscallDesc *desc, int callnum, ThreadContext *tc)
-{
-// call pipeImpl since the only difference between pipe and pipe2 is
-// the flags values and what they do (at the end of pipeImpl)
-return pipeImpl(desc, callnum, tc, false, true);
-}
-
-SyscallReturn
 getpgrpFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
 {
 auto process = tc->getProcessPtr();
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index ad5be4e..a7ff015 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -279,17 +279,15 @@
   int tgt_fd, int cmd);

 /// Target pipe() handler.
-SyscallReturn pipeFunc(SyscallDesc *desc, int num, ThreadContext *tc);
-
-/// Internal pipe() handler.
-SyscallReturn pipeImpl(SyscallDesc *desc, int num, ThreadContext *tc,
-   bool pseudo_pipe, bool is_pipe2=false);
+SyscallReturn pipeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
+   Addr tgt_addr);

 /// Target pipe handler with alternative signature.
 SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);


 /// Target pipe() handler.
-SyscallReturn pipe2Func(SyscallDesc *desc, int num, ThreadContext *tc);
+SyscallReturn pipe2Func(SyscallDesc *desc, int num, ThreadContext *tc,
+Addr tgt_addr, int flags);

 /// Target getpid() handler.
 SyscallReturn getpidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
@@ -509,9 +507,6 @@
 return -ENOSYS;
 }

-/// Pseudo Funcs  - These functions use a different return convension,
-/// returning a second value in a register other than the normal return  
register
-SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);


 /// Target getpidPseudo() handler.
 SyscallReturn getxpidFunc(SyscallDesc *desc, int num, ThreadContext *tc);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23457
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: 

[gem5-dev] Change in gem5/gem5[master]: riscv: Use a riscv specific GuestABI for riscv system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23453 )



Change subject: riscv: Use a riscv specific GuestABI for riscv system calls.
..

riscv: Use a riscv specific GuestABI for riscv system calls.

Change-Id: Ia6ac34dfb38b71eff7b573b3c9ce477fef0ef5f7
---
M src/arch/riscv/linux/process.cc
M src/arch/riscv/linux/process.hh
M src/arch/riscv/process.cc
M src/arch/riscv/process.hh
4 files changed, 39 insertions(+), 4 deletions(-)



diff --git a/src/arch/riscv/linux/process.cc  
b/src/arch/riscv/linux/process.cc

index 8321301..730974b 100644
--- a/src/arch/riscv/linux/process.cc
+++ b/src/arch/riscv/linux/process.cc
@@ -120,7 +120,7 @@
 return 0;
 }

-std::map>
+std::map>
 RiscvLinuxProcess64::syscallDescs = {
 {0,{ "io_setup" }},
 {1,{ "io_destroy" }},
@@ -452,7 +452,7 @@
 {2011, { "getmainvars" }}
 };

-std::map>
+std::map>
 RiscvLinuxProcess32::syscallDescs = {
 {0,{ "io_setup" }},
 {1,{ "io_destroy" }},
diff --git a/src/arch/riscv/linux/process.hh  
b/src/arch/riscv/linux/process.hh

index 7a2ad28..c6ae14e 100644
--- a/src/arch/riscv/linux/process.hh
+++ b/src/arch/riscv/linux/process.hh
@@ -59,7 +59,7 @@
 void syscall(ThreadContext *tc, Fault *fault) override;

 /// Array of syscall descriptors, indexed by call number.
-static std::map> syscallDescs;
+static std::map> syscallDescs;
 };

 class RiscvLinuxProcess32 : public RiscvProcess32
@@ -79,7 +79,7 @@
 void syscall(ThreadContext *tc, Fault *fault) override;

 /// Array of syscall descriptors, indexed by call number.
-static std::map> syscallDescs;
+static std::map> syscallDescs;
 };

 #endif // __RISCV_LINUX_PROCESS_HH__
diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc
index ce49836..adc3982 100644
--- a/src/arch/riscv/process.cc
+++ b/src/arch/riscv/process.cc
@@ -270,3 +270,7 @@
 tc->setIntReg(SyscallPseudoReturnReg, sysret.encodedValue());
 }
 }
+
+const std::vector RiscvProcess::SyscallABI::ArgumentRegs = {
+10, 11, 12, 13, 14, 15, 16
+};
diff --git a/src/arch/riscv/process.hh b/src/arch/riscv/process.hh
index 71a0c7b..1782b52 100644
--- a/src/arch/riscv/process.hh
+++ b/src/arch/riscv/process.hh
@@ -39,6 +39,7 @@

 #include "mem/page_table.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"

 class ObjectFile;
 class System;
@@ -58,6 +59,36 @@
   SyscallReturn return_value) override;

 virtual bool mmapGrowsDown() const override { return false; }
+
+//FIXME RISCV needs to handle 64 bit arguments in its 32 bit ISA.
+struct SyscallABI : public GenericSyscallABI64
+{
+static const std::vector ArgumentRegs;
+};
+};
+
+namespace GuestABI
+{
+
+template <>
+struct Result
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+if (ret.successful()) {
+// no error
+tc->setIntReg(RiscvISA::ReturnValueReg, ret.returnValue());
+} else {
+// got an error, return details
+tc->setIntReg(RiscvISA::ReturnValueReg, ret.encodedValue());
+}
+}
+};
+
 };

 class RiscvProcess64 : public RiscvProcess

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23453
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ia6ac34dfb38b71eff7b573b3c9ce477fef0ef5f7
Gerrit-Change-Number: 23453
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim, gpu: Make ioctl unconditionally take an address parameter.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23456 )



Change subject: sim,gpu: Make ioctl unconditionally take an address  
parameter.

..

sim,gpu: Make ioctl unconditionally take an address parameter.

The definition of ioctl is not actually variadic, it just doesn't
specify what the type of the pointer is that it takes as its third
argument. The man page says that that's because it predates void *
being valid C.

By passing this address around (even if it's unused), we avoid having
to extract system call arguments further down the call stack.

Change-Id: I62541237baafaec30bbe3df06b3284dd286a4051
---
M src/gpu-compute/cl_driver.cc
M src/gpu-compute/cl_driver.hh
M src/sim/emul_driver.hh
M src/sim/syscall_emul.hh
4 files changed, 7 insertions(+), 10 deletions(-)



diff --git a/src/gpu-compute/cl_driver.cc b/src/gpu-compute/cl_driver.cc
index c63856a..d8a4618 100644
--- a/src/gpu-compute/cl_driver.cc
+++ b/src/gpu-compute/cl_driver.cc
@@ -103,11 +103,10 @@
 }

 int
-ClDriver::ioctl(ThreadContext *tc, unsigned req)
+ClDriver::ioctl(ThreadContext *tc, unsigned req, Addr buf_addr)
 {
 int index = 2;
 auto process = tc->getProcessPtr();
-Addr buf_addr = process->getSyscallArg(tc, index);

 switch (req) {
   case HSA_GET_SIZES:
diff --git a/src/gpu-compute/cl_driver.hh b/src/gpu-compute/cl_driver.hh
index 5dbb27d..bc7b749 100644
--- a/src/gpu-compute/cl_driver.hh
+++ b/src/gpu-compute/cl_driver.hh
@@ -54,7 +54,7 @@
 ClDriver(ClDriverParams *p);
 void handshake(GpuDispatcher *_dispatcher);
 int open(ThreadContext *tc, int mode, int flags);
-int ioctl(ThreadContext *tc, unsigned req);
+int ioctl(ThreadContext *tc, unsigned req, Addr buf);
 const char* codeOffToKernelName(uint64_t code_ptr);

   private:
diff --git a/src/sim/emul_driver.hh b/src/sim/emul_driver.hh
index fe13d90..9921d15 100644
--- a/src/sim/emul_driver.hh
+++ b/src/sim/emul_driver.hh
@@ -83,7 +83,7 @@
  * @return The return code for the ioctl, or the negation of the errno
  * (see the SyscallReturn class).
  */
-virtual int ioctl(ThreadContext *tc, unsigned req) = 0;
+virtual int ioctl(ThreadContext *tc, unsigned req, Addr buf) = 0;

 /**
  * Virtual method, invoked when the user program calls mmap() on
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 27b4a43..ad5be4e 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -717,7 +717,7 @@
 template 
 SyscallReturn
 ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
-int tgt_fd, unsigned req, GuestABI::VarArgs varargs)
+int tgt_fd, unsigned req, Addr addr)
 {
 auto p = tc->getProcessPtr();

@@ -730,7 +730,7 @@
 if (dfdp) {
 EmulatedDriver *emul_driver = dfdp->getDriver();
 if (emul_driver)
-return emul_driver->ioctl(tc, req);
+return emul_driver->ioctl(tc, req, addr);
 }

 auto sfdp =  
std::dynamic_pointer_cast((*p->fds)[tgt_fd]);

@@ -739,8 +739,7 @@

 switch (req) {
   case SIOCGIFCONF: {
-Addr conf_addr = varargs.get();
-BufferArg conf_arg(conf_addr, sizeof(ifconf));
+BufferArg conf_arg(addr, sizeof(ifconf));
 conf_arg.copyIn(tc->getVirtProxy());

 ifconf *conf = (ifconf*)conf_arg.bufferPtr();
@@ -769,8 +768,7 @@
   case SIOCGIFHWADDR:
 #endif
   case SIOCGIFMTU: {
-Addr req_addr = varargs.get();
-BufferArg req_arg(req_addr, sizeof(ifreq));
+BufferArg req_arg(addr, sizeof(ifreq));
 req_arg.copyIn(tc->getVirtProxy());

 status = ioctl(sfdp->getSimFD(), req, req_arg.bufferPtr());

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23456
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I62541237baafaec30bbe3df06b3284dd286a4051
Gerrit-Change-Number: 23456
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim: Include some required headers in the syscall debug macros header.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23459 )



Change subject: sim: Include some required headers in the syscall debug  
macros header.

..

sim: Include some required headers in the syscall debug macros header.

Everything that includes syscall_debug_macros.hh and uses the macro in
it will need these headers, so they should be included through
syscall_debug_macros.hh. The consumer shouldn't have to know what the
macros use internally and to include extra headers to support them.

Change-Id: I9bfa932368daec0772d552357ecad8790b4cfead
---
M src/sim/syscall_debug_macros.hh
1 file changed, 2 insertions(+), 0 deletions(-)



diff --git a/src/sim/syscall_debug_macros.hh  
b/src/sim/syscall_debug_macros.hh

index 35a0a05..84ab552 100644
--- a/src/sim/syscall_debug_macros.hh
+++ b/src/sim/syscall_debug_macros.hh
@@ -46,6 +46,8 @@
 #ifndef __SIM_SYSCALL_DEBUG_MACROS_HH__
 #define __SIM_SYSCALL_DEBUG_MACROS_HH__

+#include "cpu/base.hh"
+#include "cpu/thread_context.hh"
 #include "debug/SyscallBase.hh"
 #include "debug/SyscallVerbose.hh"


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23459
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I9bfa932368daec0772d552357ecad8790b4cfead
Gerrit-Change-Number: 23459
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim: Convert ftruncate64 to GuestABI.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23454 )



Change subject: sim: Convert ftruncate64 to GuestABI.
..

sim: Convert ftruncate64 to GuestABI.

This function was specifying a particular width to getSyscallArg. The
new ISA specific ABIs now handle that automatically.

Change-Id: I141655d3bcb78f56c2a9278d140dfbc0d69e1ff4
---
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
2 files changed, 4 insertions(+), 6 deletions(-)



diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index a75fa6e..53928ff 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -616,12 +616,10 @@
 }

 SyscallReturn
-ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc)
+ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
+int tgt_fd, int64_t length)
 {
-int index = 0;
 auto p = tc->getProcessPtr();
-int tgt_fd = p->getSyscallArg(tc, index);
-int64_t length = p->getSyscallArg(tc, index, 64);

 auto ffdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]);
 if (!ffdp)
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index db31ca5..5537817 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -238,8 +238,8 @@
  Addr pathname, int64_t length);

 /// Target ftruncate64() handler.
-SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, ThreadContext  
*tc);

-
+SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, ThreadContext  
*tc,

+  int tgt_fd, int64_t length);

 /// Target umask() handler.
 SyscallReturn umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23454
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I141655d3bcb78f56c2a9278d140dfbc0d69e1ff4
Gerrit-Change-Number: 23454
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim: Add GenericSyscallABI structs which can be used by the ISAs.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23441 )



Change subject: sim: Add GenericSyscallABI structs which can be used by the  
ISAs.

..

sim: Add GenericSyscallABI structs which can be used by the ISAs.

It's very common for system call arguments to be passed in a sequence
of registers, one argument per register. To avoid having that
implementation repeated over and over across the various ISAs and OSes,
these partial ABI implementations provide that mechanism they can just
pull in. They would need to define the sequence of registers to use,
and these would take care of the rest.

Unlike the temporary DefaultSyscallABI which defers to the Process
classes, these read registers from the ThreadContext directly.

Change-Id: Ic72eb8d784ecf4711b5eec76d958a87c70850fce
---
A src/sim/syscall_abi.hh
1 file changed, 136 insertions(+), 0 deletions(-)



diff --git a/src/sim/syscall_abi.hh b/src/sim/syscall_abi.hh
new file mode 100644
index 000..ef1072b
--- /dev/null
+++ b/src/sim/syscall_abi.hh
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2019 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#ifndef __SIM_SYSCALL_ABI_HH__
+#define __SIM_SYSCALL_ABI_HH__
+
+#include "base/types.hh"
+#include "cpu/thread_context.hh"
+#include "sim/guest_abi.hh"
+#include "sim/syscall_return.hh"
+
+class SyscallDesc;
+
+namespace GuestABI
+{
+
+// Does this normally 64 bit data type shrink down to 32 bits for 32 bit  
ABIs?

+template 
+struct IsConforming
+{
+static const bool value = false;
+};
+
+template <>
+struct IsConforming
+{
+static const bool value = true;
+};
+
+} // namespace GuestABI
+
+struct GenericSyscallABI
+{
+using Position = int;
+};
+
+struct GenericSyscallABI64 : public GenericSyscallABI
+{};
+
+struct GenericSyscallABI32 : public GenericSyscallABI
+{
+// Is this argument too big for a single register?
+template 
+struct IsWide;
+
+template 
+struct IsWide::value &&
+(sizeof(T) < sizeof(uint64_t) ||
+ GuestABI::IsConforming::value)>::type>
+{
+static const bool value = false;
+};
+
+template 
+struct IsWide::value &&
+sizeof(T) == sizeof(uint64_t) &&
+!GuestABI::IsConforming::value>::type>
+{
+static const bool value = true;
+};
+
+// Read two registers and merge them into one value.
+static uint64_t
+mergeRegs(ThreadContext *tc, RegIndex low_idx, RegIndex high_idx)
+{
+RegVal low = tc->readIntReg(low_idx);
+RegVal high = tc->readIntReg(high_idx);
+return insertBits(low, 63, 32, high);
+}
+};
+
+namespace GuestABI
+{
+
+// For 64 bit systems, return syscall args directly.
+template 
+struct Argument::value &&
+std::is_integral::value>::type>
+{
+static Arg
+get(ThreadContext *tc, typename ABI::Position )
+{
+panic_if(position >= ABI::ArgumentRegs.size(),
+"Ran out of syscall argument registers.");
+return tc->readIntReg(ABI::ArgumentRegs[position++]);
+}
+};
+
+// For 32 bit systems, return small enough syscall args directly. Large
+// arguments aren't handled generically.
+template 
+struct Argument::value>::type>
+{
+static Arg
+get(ThreadContext *tc, typename ABI::Position )
+{
+panic_if(position >= ABI::ArgumentRegs.size(),
+"Ran out of syscall argument registers.");
+ 

[gem5-dev] Change in gem5/gem5[master]: alpha, sim: Rename the get*PseudoFunc handlers to their proper names.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23449 )



Change subject: alpha,sim: Rename the get*PseudoFunc handlers to their  
proper names.

..

alpha,sim: Rename the get*PseudoFunc handlers to their proper names.

These system calls are actually called something different in Alpha,
and so we can just give them their proper names to distinguish them
from the normal version. This also mostly removes the "Pseudo" suffix
which was used to distinguish handlers that wrote into additional
pseudo return registers.

Change-Id: I801ef71972b0c3d2aa04d682a3a94acfb27ac7ed
---
M src/arch/alpha/linux/process.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
3 files changed, 14 insertions(+), 12 deletions(-)



diff --git a/src/arch/alpha/linux/process.cc  
b/src/arch/alpha/linux/process.cc

index 9bef2f7..a1c026e 100644
--- a/src/arch/alpha/linux/process.cc
+++ b/src/arch/alpha/linux/process.cc
@@ -165,11 +165,11 @@
 /* 17 */ { "brk", brkFunc },
 /* 18 */ { "osf_getfsstat" },
 /* 19 */ { "lseek", lseekFunc },
-/* 20 */ { "getxpid", getpidPseudoFunc },
+/* 20 */ { "getxpid", getxpidFunc },
 /* 21 */ { "osf_mount" },
 /* 22 */ { "umount" },
 /* 23 */ { "setuid", ignoreFunc },
-/* 24 */ { "getxuid", getuidPseudoFunc },
+/* 24 */ { "getxuid", getxuidFunc },
 /* 25 */ { "exec_with_loader" },
 /* 26 */ { "osf_ptrace" },
 /* 27 */ { "osf_nrecvmsg" },
@@ -192,7 +192,7 @@
 /* 44 */ { "osf_profil" },
 /* 45 */ { "open", openFunc },
 /* 46 */ { "osf_old_sigaction" },
-/* 47 */ { "getxgid", getgidPseudoFunc },
+/* 47 */ { "getxgid", getxgidFunc },
 /* 48 */ { "osf_sigprocmask", ignoreFunc },
 /* 49 */ { "osf_getlogin" },
 /* 50 */ { "osf_setlogin" },
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index b1f098f..a75fa6e 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -973,7 +973,7 @@
 }

 SyscallReturn
-getpidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
+getxpidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
 {
 // Make up a PID.  There's no interprocess communication in
 // fake_syscall mode, so there's no way for a process to know it's
@@ -985,7 +985,7 @@


 SyscallReturn
-getuidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
+getxuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
 {
 // Make up a UID and EUID... it shouldn't matter, and we want the
 // simulation to be deterministic.
@@ -996,7 +996,7 @@


 SyscallReturn
-getgidPseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
+getxgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
 {
 // Get current group ID.
 auto process = tc->getProcessPtr();
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index b48e334..db31ca5 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -285,6 +285,9 @@
 SyscallReturn pipeImpl(SyscallDesc *desc, int num, ThreadContext *tc,
bool pseudo_pipe, bool is_pipe2=false);

+/// Target pipe handler with alternative signature.
+SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);

+
 /// Target pipe() handler.
 SyscallReturn pipe2Func(SyscallDesc *desc, int num, ThreadContext *tc);

@@ -506,19 +509,18 @@
 return -ENOSYS;
 }

-
 /// Pseudo Funcs  - These functions use a different return convension,
 /// returning a second value in a register other than the normal return  
register
 SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);


 /// Target getpidPseudo() handler.
-SyscallReturn getpidPseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);

+SyscallReturn getxpidFunc(SyscallDesc *desc, int num, ThreadContext *tc);

-/// Target getuidPseudo() handler.
-SyscallReturn getuidPseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);

+/// Target getxuid() handler.
+SyscallReturn getxuidFunc(SyscallDesc *desc, int num, ThreadContext *tc);

-/// Target getgidPseudo() handler.
-SyscallReturn getgidPseudoFunc(SyscallDesc *desc, int num, ThreadContext  
*tc);

+/// Target getxgid() handler.
+SyscallReturn getxgidFunc(SyscallDesc *desc, int num, ThreadContext *tc);


 /// A readable name for 1,000,000, for converting microseconds to seconds.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23449
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I801ef71972b0c3d2aa04d682a3a94acfb27ac7ed
Gerrit-Change-Number: 23449
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sparc: Introduce a BitUnion for the CCR register.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23446 )



Change subject: sparc: Introduce a BitUnion for the CCR register.
..

sparc: Introduce a BitUnion for the CCR register.

This avoids opaque masks when accessing fields of this register.

Change-Id: If20d82c7c6401e6b1b35bb6d2c69542a56e2fb45
---
M src/arch/sparc/faults.cc
M src/arch/sparc/miscregs.hh
M src/arch/sparc/process.cc
3 files changed, 30 insertions(+), 17 deletions(-)



diff --git a/src/arch/sparc/faults.cc b/src/arch/sparc/faults.cc
index 0057f12..ca63a04 100644
--- a/src/arch/sparc/faults.cc
+++ b/src/arch/sparc/faults.cc
@@ -306,7 +306,7 @@
 RegVal TSTATE = tc->readMiscRegNoEffect(MISCREG_TSTATE);
 PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
 HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
-RegVal CCR = tc->readIntReg(INTREG_CCR);
+CCR ccr = tc->readIntReg(INTREG_CCR);
 RegVal ASI = tc->readMiscRegNoEffect(MISCREG_ASI);
 RegVal CWP = tc->readMiscRegNoEffect(MISCREG_CWP);
 RegVal CANSAVE = tc->readMiscRegNoEffect(INTREG_CANSAVE);
@@ -320,7 +320,7 @@
 // set TSTATE.gl to gl
 replaceBits(TSTATE, 42, 40, GL);
 // set TSTATE.ccr to ccr
-replaceBits(TSTATE, 39, 32, CCR);
+replaceBits(TSTATE, 39, 32, ccr);
 // set TSTATE.asi to asi
 replaceBits(TSTATE, 31, 24, ASI);
 // set TSTATE.pstate to pstate
@@ -385,7 +385,7 @@
 RegVal TSTATE = tc->readMiscRegNoEffect(MISCREG_TSTATE);
 PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
 HPSTATE hpstate = tc->readMiscRegNoEffect(MISCREG_HPSTATE);
-RegVal CCR = tc->readIntReg(INTREG_CCR);
+CCR ccr = tc->readIntReg(INTREG_CCR);
 RegVal ASI = tc->readMiscRegNoEffect(MISCREG_ASI);
 RegVal CWP = tc->readMiscRegNoEffect(MISCREG_CWP);
 RegVal CANSAVE = tc->readIntReg(INTREG_CANSAVE);
@@ -403,7 +403,7 @@
 // set TSTATE.gl to gl
 replaceBits(TSTATE, 42, 40, GL);
 // set TSTATE.ccr to ccr
-replaceBits(TSTATE, 39, 32, CCR);
+replaceBits(TSTATE, 39, 32, ccr);
 // set TSTATE.asi to asi
 replaceBits(TSTATE, 31, 24, ASI);
 // set TSTATE.pstate to pstate
diff --git a/src/arch/sparc/miscregs.hh b/src/arch/sparc/miscregs.hh
index 6c5118f..2f98876 100644
--- a/src/arch/sparc/miscregs.hh
+++ b/src/arch/sparc/miscregs.hh
@@ -136,6 +136,21 @@
 Bitfield<11> pid1;
 EndBitUnion(PSTATE)

+BitUnion8(CCR)
+SubBitUnion(xcc, 7, 4)
+Bitfield<7> n;
+Bitfield<6> z;
+Bitfield<5> v;
+Bitfield<4> c;
+EndSubBitUnion(xcc)
+SubBitUnion(icc, 3, 0)
+Bitfield<3> n;
+Bitfield<2> z;
+Bitfield<1> v;
+Bitfield<0> c;
+EndSubBitUnion(icc)
+EndBitUnion(CCR)
+
 struct STS
 {
 const static int st_idle = 0x00;
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index dd9215f..d064de2 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -512,23 +512,21 @@
 {
 // check for error condition.  SPARC syscall convention is to
 // indicate success/failure in reg the carry bit of the ccr
-// and put the return value itself in the standard return value reg ().
+// and put the return value itself in the standard return value reg.
 PSTATE pstate = tc->readMiscRegNoEffect(MISCREG_PSTATE);
+CCR ccr = tc->readIntReg(INTREG_CCR);
+RegVal val;
 if (sysret.successful()) {
-// no error, clear XCC.C
-tc->setIntReg(INTREG_CCR, tc->readIntReg(INTREG_CCR) & 0xEE);
-RegVal val = sysret.returnValue();
-if (pstate.am)
-val = bits(val, 31, 0);
-tc->setIntReg(ReturnValueReg, val);
+ccr.xcc.c = ccr.icc.c = 0;
+val = sysret.returnValue();
 } else {
-// got an error, set XCC.C
-tc->setIntReg(INTREG_CCR, tc->readIntReg(INTREG_CCR) | 0x11);
-RegVal val = sysret.errnoValue();
-if (pstate.am)
-val = bits(val, 31, 0);
-tc->setIntReg(ReturnValueReg, val);
+ccr.xcc.c = ccr.icc.c = 1;
+val = sysret.errnoValue();
 }
+tc->setIntReg(INTREG_CCR, ccr);
+if (pstate.am)
+val = bits(val, 31, 0);
+tc->setIntReg(ReturnValueReg, val);
 if (sysret.count() > 1)
 tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23446
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: If20d82c7c6401e6b1b35bb6d2c69542a56e2fb45
Gerrit-Change-Number: 23446
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: alpha: Use an alpha specific GuestABI for alpha system calls.

2019-12-08 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/23450 )



Change subject: alpha: Use an alpha specific GuestABI for alpha system  
calls.

..

alpha: Use an alpha specific GuestABI for alpha system calls.

Change-Id: If13e8ff9d20ddafac494cdfb729d9a678d787fcf
---
M src/arch/alpha/linux/process.cc
M src/arch/alpha/linux/process.hh
M src/arch/alpha/process.cc
M src/arch/alpha/process.hh
4 files changed, 43 insertions(+), 2 deletions(-)



diff --git a/src/arch/alpha/linux/process.cc  
b/src/arch/alpha/linux/process.cc

index a1c026e..caa918c 100644
--- a/src/arch/alpha/linux/process.cc
+++ b/src/arch/alpha/linux/process.cc
@@ -144,7 +144,7 @@
 }


-SyscallDescABI AlphaLinuxProcess::syscallDescs[] = {
+SyscallDescABI AlphaLinuxProcess::syscallDescs[]  
= {

 /*  0 */ { "osf_syscall" },
 /*  1 */ { "exit", exitFunc },
 /*  2 */ { "fork" },
diff --git a/src/arch/alpha/linux/process.hh  
b/src/arch/alpha/linux/process.hh

index 14214f1..af2ebf1 100644
--- a/src/arch/alpha/linux/process.hh
+++ b/src/arch/alpha/linux/process.hh
@@ -49,7 +49,7 @@
 virtual SyscallDesc* getDesc(int callnum);

  /// Array of syscall descriptors, indexed by call number.
-static SyscallDescABI syscallDescs[];
+static SyscallDescABI syscallDescs[];

 const int Num_Syscall_Descs;
 };
diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc
index f40b771..8571f0e 100644
--- a/src/arch/alpha/process.cc
+++ b/src/arch/alpha/process.cc
@@ -240,3 +240,7 @@
 if (sysret.count() > 1)
 tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
 }
+
+const std::vector AlphaProcess::SyscallABI::ArgumentRegs = {
+16, 17, 18, 19, 20, 21
+};
diff --git a/src/arch/alpha/process.hh b/src/arch/alpha/process.hh
index c4d4f6b..8ff72bc 100644
--- a/src/arch/alpha/process.hh
+++ b/src/arch/alpha/process.hh
@@ -34,6 +34,7 @@

 #include "mem/page_table.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"

 class AlphaProcess : public Process
 {
@@ -58,6 +59,42 @@
 // override default implementation in Process as the mmap
 // region for Alpha platforms grows upward
 virtual bool mmapGrowsDown() const override { return false; }
+
+struct SyscallABI : public GenericSyscallABI64
+{
+static const std::vector ArgumentRegs;
+};
 };

+namespace GuestABI
+{
+
+template <>
+struct Result
+{
+static void
+store(ThreadContext *tc, const SyscallReturn )
+{
+if (ret.suppressed() || ret.needsRetry())
+return;
+
+// check for error condition.  Alpha syscall convention is to
+// indicate success/failure in reg a3 (r19) and put the
+// return value itself in the standard return value reg (v0).
+if (ret.successful()) {
+// no error
+tc->setIntReg(AlphaISA::SyscallSuccessReg, 0);
+tc->setIntReg(AlphaISA::ReturnValueReg, ret.returnValue());
+} else {
+// got an error, return details
+tc->setIntReg(AlphaISA::SyscallSuccessReg, (RegVal)-1);
+tc->setIntReg(AlphaISA::ReturnValueReg, ret.errnoValue());
+}
+if (ret.count() > 1)
+tc->setIntReg(AlphaISA::SyscallPseudoReturnReg, ret.value2());
+}
+};
+
+} // namespace GuestABI
+
 #endif // __ARCH_ALPHA_PROCESS_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23450
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: If13e8ff9d20ddafac494cdfb729d9a678d787fcf
Gerrit-Change-Number: 23450
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] clone syscall return value(s)

2019-12-08 Thread Gabe Black
Hi folks. I'm still cleaning up the system call stuff, and have mostly
extracted system call argument setting and return value installing from all
the system calls and the process objects themselves. The only place I
really have left is the clone system call which sets some registers in an
"#if THE_ISA ==" block, and which explicitly sets what the return looks
like in the new context.

The man page for clone() seems to refer to the libc wrapper which has more
complicated semantics, but I gather that the underlying system call is
supposed to return "success" (however it does that) to the child, and the
child's PID to the parent. I haven't been able to find anything which
actually says what that's supposed to look like for different ISAs. For
instance, is it written down someplace that in SPARC extra registers are
supposed to be set to 0 and 1?

If that documentation does exist someplace, I'd really like to take a look
at it so I can figure out a (clean) way to extract these last little bits
and fully push argument and return value handling in GuestABI mechanism I
added.

Any pointers would be appreciated. Since Brandon checked in the code with
that behavior, I'm assuming he found something somewhere that said to do
things that way?

Gabe
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev