Ciro Santilli has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/17849

Change subject: [RFC] sim-se: add a release parameter to Process.py
......................................................................

[RFC] sim-se: add a release parameter to Process.py

glibc has checks for the kernel version based on uname, and refuses
to start any syscall emulation programs if those checks don't pass with
error:

FATAL: kernel too old

The ideal solution to this problem is to actually implement all missing
system calls for the required kernel version and bumping the release
accordingly.

However, it is very hard to implement all missing syscalls and verify
compliance.

Previously, we have simply bumped the version manually from time to
time when major glibc versions started breaking.

This commit makes it is possible to set the release with a parameter,
which in turn can be set from the command line with:

se.py --param 'system.cpu[:].workload[:].release = "4.18.0"'

Change-Id: I9e3c31073bfe68735f7b0775c8e299aa62b98222
---
M src/arch/alpha/linux/process.cc
M src/arch/alpha/process.hh
M src/arch/arm/linux/process.cc
M src/arch/arm/linux/process.hh
M src/arch/mips/linux/process.cc
M src/arch/mips/linux/process.hh
M src/arch/power/linux/process.cc
M src/arch/power/linux/process.hh
M src/arch/riscv/linux/process.cc
M src/arch/riscv/linux/process.hh
M src/arch/sparc/linux/process.cc
M src/arch/sparc/linux/process.hh
M src/arch/sparc/linux/syscalls.cc
M src/arch/sparc/solaris/process.cc
M src/arch/sparc/solaris/process.hh
M src/arch/x86/linux/process.cc
M src/arch/x86/process.hh
M src/sim/Process.py
M src/sim/process.cc
M src/sim/process.hh
20 files changed, 105 insertions(+), 14 deletions(-)



diff --git a/src/arch/alpha/linux/process.cc b/src/arch/alpha/linux/process.cc
index c1162ba..046791a 100644
--- a/src/arch/alpha/linux/process.cc
+++ b/src/arch/alpha/linux/process.cc
@@ -54,7 +54,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "sim.gem5.org");
-    strcpy(name->release, "3.0.0");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
     strcpy(name->machine, "alpha");

@@ -589,3 +589,9 @@
         return NULL;
     return &syscallDescs[callnum];
 }
+
+std::string
+AlphaLinuxProcess::getDefaultRelease() const
+{
+    return "3.0.0";
+}
diff --git a/src/arch/alpha/process.hh b/src/arch/alpha/process.hh
index 5f22488..52b2684 100644
--- a/src/arch/alpha/process.hh
+++ b/src/arch/alpha/process.hh
@@ -59,6 +59,7 @@
     // override default implementation in Process as the mmap
     // region for Alpha platforms grows upward
     virtual bool mmapGrowsDown() const override { return false; }
+    std::string getDefaultRelease() const override;
 };

 #endif // __ARCH_ALPHA_PROCESS_HH__
diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc
index 99f4b2c..cb2c9c1 100644
--- a/src/arch/arm/linux/process.cc
+++ b/src/arch/arm/linux/process.cc
@@ -71,7 +71,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "m5.eecs.umich.edu");
-    strcpy(name->release, "3.7.0+");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 SMP Sat Dec  1 00:00:00 GMT 2012");
     strcpy(name->machine, "armv7l");

@@ -89,7 +89,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "gem5");
-    strcpy(name->release, "4.10.8+");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 SMP Sat Dec  1 00:00:00 GMT 2012");
     strcpy(name->machine, "armv8l");

@@ -1735,3 +1735,16 @@
     ArmProcess64::initState();
     // The 64 bit equivalent of the comm page would be set up here.
 }
+
+
+std::string
+ArmLinuxProcess32::getDefaultRelease() const
+{
+    return "3.7.0+";
+}
+
+std::string
+ArmLinuxProcess64::getDefaultRelease() const
+{
+    return "4.10.8+";
+}
diff --git a/src/arch/arm/linux/process.hh b/src/arch/arm/linux/process.hh
index d4b7ca7..eca59b5 100644
--- a/src/arch/arm/linux/process.hh
+++ b/src/arch/arm/linux/process.hh
@@ -80,6 +80,7 @@
     static const Addr commPage;

     SyscallDesc* getDesc(int callnum);
+    std::string getDefaultRelease() const override;
 };

 /// A process with emulated Arm/Linux syscalls.
@@ -91,6 +92,7 @@

     void initState();
     SyscallDesc* getDesc(int callnum);
+    std::string getDefaultRelease() const override;
 };

 #endif // __ARM_LINUX_PROCESS_HH__
diff --git a/src/arch/mips/linux/process.cc b/src/arch/mips/linux/process.cc
index b1c09a5..ec77b7e 100644
--- a/src/arch/mips/linux/process.cc
+++ b/src/arch/mips/linux/process.cc
@@ -57,7 +57,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename,"sim.gem5.org");
-    strcpy(name->release, "3.0.0");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
     strcpy(name->machine, "mips");

@@ -478,7 +478,8 @@
     return &syscallDescs[m5_sys_idx];
 }

-
-
-
-
+std::string
+MipsLinuxProcess::getDefaultRelease() const
+{
+    return "3.0.0";
+}
diff --git a/src/arch/mips/linux/process.hh b/src/arch/mips/linux/process.hh
index cbf0d78..db4d591 100644
--- a/src/arch/mips/linux/process.hh
+++ b/src/arch/mips/linux/process.hh
@@ -54,6 +54,7 @@
     /// Array of syscall descriptors, indexed by call number.
     static SyscallDesc syscallDescs[];
     const int Num_Syscall_Descs;
+    std::string getDefaultRelease() const override;
 };

 #endif // __MIPS_LINUX_PROCESS_HH__
diff --git a/src/arch/power/linux/process.cc b/src/arch/power/linux/process.cc
index 664b93b..531f64e 100644
--- a/src/arch/power/linux/process.cc
+++ b/src/arch/power/linux/process.cc
@@ -57,7 +57,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "sim.gem5.org");
-    strcpy(name->release, "3.0.0");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
     strcpy(name->machine, "power");

@@ -454,3 +454,9 @@
     assert(i < 6);
     tc->setIntReg(ArgumentReg0 + i, val);
 }
+
+std::string
+PowerLinuxProcess64::getDefaultRelease() const
+{
+    return "3.0.0";
+}
diff --git a/src/arch/power/linux/process.hh b/src/arch/power/linux/process.hh
index aad4c5f..4330749 100644
--- a/src/arch/power/linux/process.hh
+++ b/src/arch/power/linux/process.hh
@@ -54,6 +54,7 @@
     static SyscallDesc syscallDescs[];

     const int Num_Syscall_Descs;
+    std::string getDefaultRelease() const override;
 };

 #endif // __POWER_LINUX_PROCESS_HH__
diff --git a/src/arch/riscv/linux/process.cc b/src/arch/riscv/linux/process.cc
index 7239920..6e32a65 100644
--- a/src/arch/riscv/linux/process.cc
+++ b/src/arch/riscv/linux/process.cc
@@ -61,7 +61,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename,"sim.gem5.org");
-    strcpy(name->release, "3.0.0");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
     strcpy(name->machine, "riscv64");

@@ -760,6 +760,12 @@
         &syscallDescs.at(callnum) : nullptr;
 }

+std::string
+RiscvLinuxProcess64::getDefaultRelease() const
+{
+    return "3.0.0";
+}
+
 RiscvLinuxProcess32::RiscvLinuxProcess32(ProcessParams * params,
     ObjectFile *objFile) : RiscvProcess32(params, objFile)
 {}
@@ -770,3 +776,9 @@
     return syscallDescs.find(callnum) != syscallDescs.end() ?
         &syscallDescs.at(callnum) : nullptr;
 }
+
+std::string
+RiscvLinuxProcess32::getDefaultRelease() const
+{
+    return "3.0.0";
+}
diff --git a/src/arch/riscv/linux/process.hh b/src/arch/riscv/linux/process.hh
index 1256ac6..d3a1e30 100644
--- a/src/arch/riscv/linux/process.hh
+++ b/src/arch/riscv/linux/process.hh
@@ -57,6 +57,8 @@

     /// Array of syscall descriptors, indexed by call number.
     static std::map<int, SyscallDesc> syscallDescs;
+
+    std::string getDefaultRelease() const override;
 };

 class RiscvLinuxProcess32 : public RiscvProcess32
@@ -75,6 +77,8 @@

     /// Array of syscall descriptors, indexed by call number.
     static std::map<int, SyscallDesc> syscallDescs;
+
+    std::string getDefaultRelease() const override;
 };

 #endif // __RISCV_LINUX_PROCESS_HH__
diff --git a/src/arch/sparc/linux/process.cc b/src/arch/sparc/linux/process.cc
index d12f130..3483511 100644
--- a/src/arch/sparc/linux/process.cc
+++ b/src/arch/sparc/linux/process.cc
@@ -60,6 +60,12 @@
     return &syscall32Descs[callnum];
 }

+std::string
+SparcLinuxProcess::getDefaultRelease() const
+{
+    return "3.0.0";
+}
+
 Sparc32LinuxProcess::Sparc32LinuxProcess(ProcessParams * params,
                                          ObjectFile *objFile)
     : Sparc32Process(params, objFile)
diff --git a/src/arch/sparc/linux/process.hh b/src/arch/sparc/linux/process.hh
index 778af1f..bf2f612 100644
--- a/src/arch/sparc/linux/process.hh
+++ b/src/arch/sparc/linux/process.hh
@@ -55,6 +55,7 @@

     static const int Num_Syscall_Descs;
     static const int Num_Syscall32_Descs;
+    std::string getDefaultRelease() const override;
 };

 /// A process with emulated SPARC/Linux syscalls.
diff --git a/src/arch/sparc/linux/syscalls.cc b/src/arch/sparc/linux/syscalls.cc
index 773982a..3ad289d 100644
--- a/src/arch/sparc/linux/syscalls.cc
+++ b/src/arch/sparc/linux/syscalls.cc
@@ -47,7 +47,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "sim.gem5.org");
-    strcpy(name->release, "3.0.0-sparc64");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
     strcpy(name->machine, "sparc");

diff --git a/src/arch/sparc/solaris/process.cc b/src/arch/sparc/solaris/process.cc
index bcdd088..c854c3e 100644
--- a/src/arch/sparc/solaris/process.cc
+++ b/src/arch/sparc/solaris/process.cc
@@ -53,7 +53,7 @@

     strcpy(name->sysname, "SunOS");
     strcpy(name->nodename, "m5.eecs.umich.edu");
-    strcpy(name->release, "5.9"); //?? do we want this or something newer?
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "Generic_118558-21");
     strcpy(name->machine, "sun4u");

@@ -341,3 +341,9 @@
         return NULL;
     return &syscallDescs[callnum];
 }
+
+std::string
+SparcSolarisProcess::getDefaultRelease() const
+{
+    return "5.9";
+}
diff --git a/src/arch/sparc/solaris/process.hh b/src/arch/sparc/solaris/process.hh
index 660802c..72ffee6 100644
--- a/src/arch/sparc/solaris/process.hh
+++ b/src/arch/sparc/solaris/process.hh
@@ -53,6 +53,8 @@
     static SyscallDesc syscallDescs[];

     const int Num_Syscall_Descs;
+
+    std::string getDefaultRelease() const override;
 };


diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc
index 9e8997a..8aa3c66 100644
--- a/src/arch/x86/linux/process.cc
+++ b/src/arch/x86/linux/process.cc
@@ -64,7 +64,7 @@

     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "sim.gem5.org");
-    strcpy(name->release, "3.2.0");
+    strcpy(name->release, process->getRelease().c_str());
     strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
     strcpy(name->machine, "x86_64");

@@ -895,3 +895,9 @@
 {
     I386Process::clone(old_tc, new_tc, (I386Process*)process, flags);
 }
+
+std::string
+X86Process::getDefaultRelease() const
+{
+    return "3.2.0";
+}
diff --git a/src/arch/x86/process.hh b/src/arch/x86/process.hh
index 9c2ec65..e53a579 100644
--- a/src/arch/x86/process.hh
+++ b/src/arch/x86/process.hh
@@ -106,6 +106,8 @@

             return *this;
         }
+
+        std::string getDefaultRelease() const override;
     };

     class X86_64Process : public X86Process
diff --git a/src/sim/Process.py b/src/sim/Process.py
index 2ffc51a..4231649 100644
--- a/src/sim/Process.py
+++ b/src/sim/Process.py
@@ -61,6 +61,7 @@
     cwd = Param.String('', "current working directory")
simpoint = Param.UInt64(0, 'simulation point at which to start simulation')
     drivers = VectorParam.EmulatedDriver([], 'Available emulated drivers')
+    release = Param.String('', "Linux kernel uname release")

     @classmethod
     def export_methods(cls, code):
diff --git a/src/sim/process.cc b/src/sim/process.cc
index c4dd641..253141b 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -111,7 +111,7 @@
                   SETranslatingPortProxy::Always),
       objFile(obj_file),
       argv(params->cmd), envp(params->env), cwd(params->cwd),
-      executable(params->executable),
+      release(params->release), executable(params->executable),
       _uid(params->uid), _euid(params->euid),
       _gid(params->gid), _egid(params->egid),
       _pid(params->pid), _ppid(params->ppid),
@@ -662,3 +662,19 @@

     return full + file_name;
 }
+
+std::string
+Process::getRelease() const
+{
+    if (release.empty()) {
+        return getDefaultRelease();
+    } else {
+        return release;
+    }
+}
+
+std::string
+Process::getDefaultRelease() const
+{
+    return "unknown";
+}
diff --git a/src/sim/process.hh b/src/sim/process.hh
index c690e82..5474759 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -65,6 +65,7 @@
   public:
     Process(ProcessParams *params, EmulationPageTable *pTable,
             ObjectFile *obj_file);
+    virtual ~Process() {};

     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;
@@ -93,6 +94,8 @@
     const char *progName() const { return executable.c_str(); }
     std::string fullPath(const std::string &filename);
     std::string getcwd() const { return cwd; }
+    std::string getRelease() const;
+    virtual std::string getDefaultRelease() const;

     /**
      * Find an emulated device driver.
@@ -183,6 +186,7 @@
     std::vector<std::string> argv;
     std::vector<std::string> envp;
     std::string cwd;
+    std::string release;
     std::string executable;

     // Id of the owner of the process

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/17849
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: I9e3c31073bfe68735f7b0775c8e299aa62b98222
Gerrit-Change-Number: 17849
Gerrit-PatchSet: 1
Gerrit-Owner: Ciro Santilli <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to