1

I have run gem5 full system simulation for x86 successfully. I mounted the image as follows:

sudo mount -o loop,offset=32256 linux-x86.img tempdisk

and copied a hello world program in there. I then ran the simulation. Linux booted successfully. I used telnet to check into the simulated system. I was able to compile the hello world source code that I had put in the image disk through the simulated system and it run successfully, too.

Then I repeated the same for another C source file I had. That source code needs the following header and I get this error:

  error: x86intrin.h: No such file or directory

I tried to install other versions of gcc. I tried the following to add Google public DNS to run apt-get:

echo "nameserver 8.8.8.8" > /etc/resolv.conf  
apt-get update

However, the apt-get command doesn't work. I found out that the Linux image that was provided in gem5 website for x86 was not an Ubuntu but the following distribution:

Gentoo Base System release 1.12.11.1

Therefore I used emerge command to upgrade and install other versions of gcc but it didn't work also.

    (none) / # emerge gcc-4.8
emerge gcc-4.8
!!! /etc/make.profile is not a symlink and will probably prevent most merges.
!!! It should point into a profile within /usr/portage/profiles/
!!! (You can safely ignore this message when syncing. It's harmless.)
Calculating dependencies -
!!! 'gcc-4.8' is not a valid package atom.
!!! Please check ebuild(5) for full details.
!!! (Did you specify a version but forget to prefix with '='?)

Ultimately, I want to run side channel attacks such as spectre on gem5 full system. Those codes use instructions such as rdtscp and clflush that require x86intrin.h header.
Is there another way to run my code on gem5 full system simulation? I followed the steps explained here for x86 but those were mainly for Arm and Ubuntu. Trying them for x86 took me to the above errors.

donjuedo
  • 2,475
  • 18
  • 28
parisa
  • 784
  • 1
  • 8
  • 27
  • 1
    Hi Parisa, you are compiling the program on your host is that correct? If that is the case, it would be better to completely remove gem5 from the equation, this way many more people will look into it. You should also provide a minimal example that fails to compile, and your gcc command line, although in this case this likely won't matter. Also, why is the question tagged with QEMU? I do not know why your system does not have `x86intrin.h`, all I can say is that in Ubuntu 19.04 GCC 8.3.0 and Ubuntu 16.04 GCC 5.4.0 I do have that header. – Ciro Santilli May 30 '19 at 08:22
  • My understanding is that when I log in to the system that is being simulated on gem5 then gcc command and everything is being excepted in gem5. Am I right? – parisa May 30 '19 at 17:52
  • qemu is tagged because I was basically following the instruction in this link https://www.youtube.com/watch?v=Oh3NK12fnbg – parisa May 30 '19 at 17:55
  • Also I have gem5 and everything else on Ubuntu and the code compiles fine on my Ubuntu 18.04.2. This problem happens when I try to compile that particular code on the system that is being simulated on gem5 which is a Gentoo base system that I'm not familiar with. – parisa May 30 '19 at 18:02
  • OK, now I understand. Why it is possible to compile on target (Gentoo here), it is generally too slow to be feasible from gem5. May be possible in QEMU, but the really correct thing is to use a cross compiler from your host. Compiling with `-static` on host generally works on guest, but is a hack that may backfire. I don't know if gentoo however clearly documents how to cross compile, and presumably it would still fail. – Ciro Santilli May 31 '19 at 09:07
  • This is why I [use Buildroot for my experiments](https://github.com/cirosantilli/linux-kernel-module-cheat/tree/4a4407e7a8761f64b3c1d7b7fbde594bd26811e0#gem5-buildroot-setup), it offers more control and a guaranteed compatible cross compiler. x86intrin.h is just a regular header, can you try to find it inside the Gentoo image (e.g. with mount on host + find), and then add the appropriate `gcc -I` option. On Ubuntu 19.04 it is located under `/usr/lib/gcc/x86_64-linux-gnu/8/include/x86intrin.h`. – Ciro Santilli May 31 '19 at 09:07
  • I tried compiling with static but then I get run time memory segmentation error on Gentoo. – parisa Jun 01 '19 at 23:18

0 Answers0