westerndigitalcorporation / swerv-ISS

Western Digital’s Open Source RISC-V SweRV Instruction Set Simulator
201 stars 41 forks source link

Support for running on 32-bit systems #9

Closed raulbehl closed 5 years ago

raulbehl commented 5 years ago

Hi,

I tried building it on a 32-bit Ubuntu machines with 1.67 boost libs and gcc 7.4

After fixing the initial errors in Core.cpp related to the usage of __uint128_t datatypes, I was able to compile it successfully on my system.

But when running the simple test as per the readme, I see the following errors:

rahul@rahul:~/work/swerv-ISS$ ./whisper build/test
Unreasonably small memory size (less than 0x 1000) -- using 0x1000
End of ELF segment 0 (100c8) is beyond end of simulated memory (1000)
End of ELF segment 1 (110c8) is beyond end of simulated memory (1000)
No loadable segment in ELF file
rahul@rahul:~/work/swerv-ISS$

On running the attached .hex file in the simulator, I see segmentation fault when enabling --log mode but without that option it seems to work well:

rahul@rahul:~/work/swerv-ISS$ ./whisper --hex inst_hex.hex --startpc 0x00000000 --maxinst 28
Unreasonably small memory size (less than 0x 1000) -- using 0x1000
Stopped -- Reached instruction limit
Retired 1c instructions in 0.00s  692b1 inst/s
rahul@rahul:~/work/swerv-ISS$ 

Using --log option:

rahul@rahul:~/work/swerv-ISS$ ./whisper --hex inst_hex.hex --startpc 0x00000000 --maxinst 28 --log
Unreasonably small memory size (less than 0x 1000) -- using 0x1000
Segmentation fault (core dumped)
rahul@rahul:~/work/swerv-ISS$ 

Any ideas on how to proceed ahead?

raulbehl commented 5 years ago

inst_hex.txt

jrahmeh commented 5 years ago

Hi Rahul,

Somehow, the code that allocates the simulated memory is being passed a memory size that is less than 4k bytes. The target test program does not fit in such a tiny memory. Can you please post the operating system version and the memory size of your machine?

Joe

On Sun, Apr 7, 2019 at 2:41 AM Rahul Behl notifications@github.com wrote:

Hi,

I tried building it on a 32-bit Ubuntu machines with 1.67 boost libs and gcc 7.4

After fixing the initial errors in Core.cpp related to the usage of __uint128_t datatypes, I was able to compile it successfully on my system.

But when running the simple test as per the readme, I see the following errors:

rahul@rahul:~/work/swerv-ISS$ ./whisper build/test Unreasonably small memory size (less than 0x 1000) -- using 0x1000 End of ELF segment 0 (100c8) is beyond end of simulated memory (1000) End of ELF segment 1 (110c8) is beyond end of simulated memory (1000) No loadable segment in ELF file rahul@rahul:~/work/swerv-ISS$

On running the attached .hex file in the simulator, I see segmentation fault when enabling --log mode but without that option it seems to work well:

rahul@rahul:~/work/swerv-ISS$ ./whisper --hex inst_hex.hex --startpc 0x00000000 --maxinst 28 Unreasonably small memory size (less than 0x 1000) -- using 0x1000 Stopped -- Reached instruction limit Retired 1c instructions in 0.00s 692b1 inst/s rahul@rahul:~/work/swerv-ISS$

Using --log option:

rahul@rahul:~/work/swerv-ISS$ ./whisper --hex inst_hex.hex --startpc 0x00000000 --maxinst 28 --log Unreasonably small memory size (less than 0x 1000) -- using 0x1000 Segmentation fault (core dumped) rahul@rahul:~/work/swerv-ISS$

Any ideas on how to proceed ahead?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/westerndigitalcorporation/swerv-ISS/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR4X7XbGAYLt9uWneiHgncBv9zxcjBDks5veaEWgaJpZM4cgnNo .

raulbehl commented 5 years ago

Hi Joe,

Here are the required details:

NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
rahul@rahul:~$ free -m
              total        used        free      shared  buff/cache   available
Mem:           2913         779         417         245        1716        1574
Swap:           975           0         975
rahul@rahul:~$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       293G   19G  259G   7% /
jrahmeh commented 5 years ago

Hi Rahul,

I improved the code to handle machines with less than 4 gigs of memory and a pointer size of 32-bits. I have no access to such a machine to test. Please refresh your code and try again. Please send me your fix for the _uint128_t issue.

Joe

On Sun, Apr 7, 2019 at 10:06 AM Rahul Behl notifications@github.com wrote:

Hi Joe,

Here are the required details:

NAME="Ubuntu" VERSION="16.04.5 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.5 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial

rahul@rahul:~$ free -m total used free shared buff/cache available Mem: 2913 779 417 245 1716 1574 Swap: 975 0 975

rahul@rahul:~$ df -h . Filesystem Size Used Avail Use% Mounted on /dev/sda1 293G 19G 259G 7% /

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/westerndigitalcorporation/swerv-ISS/issues/9#issuecomment-480598198, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR4XwrPUwVJPEvep0oTgy6sGx8KBun1ks5vegl9gaJpZM4cgnNo .

raulbehl commented 5 years ago

Hi Joe,

Thank you so much for looking into it. I tried your fix on my machine but I still got the exact same error. I think there was a small typo in the following change you made:

 // Determine simulated memory size. Default to 4 gigs.
  // If running a 32-bit machine (pointer siz = 32 bits), try 2 gigs.
  size_t memorySize = size_t(1) << 32;  // 4 gigs
  if (memorySize == 0)
    memorySize = size_t(1) << 32;  // 2 gigs

Updating the 2 gigs case to use 31 instead of 32 seems to resolve the memory issue. But I still get the segmentation fault when enabling the --log option. Also, the simulator prints the following error message related to illegal instructions (I am using the simple to_host example C-code as per the GCC):

rahul@rahul:~/work/swerv-ISS/build$ ./whisper test2
Error: Failed stop: 64 consecutive illegal instructions
Retired 66 instructions in 0.00s  532258 inst/s

I'll open a pull request for the _uint128_t issue.

jrahmeh commented 5 years ago

Oops. Fixed the typo and pushed the code.

On Sun, Apr 7, 2019 at 9:08 PM Rahul Behl notifications@github.com wrote:

Hi Joe,

Thank you so much for looking into it. I tried your fix on my machine but I still got the exact same error. I think there was a small typo in the following change you made:

// Determine simulated memory size. Default to 4 gigs. // If running a 32-bit machine (pointer siz = 32 bits), try 2 gigs. size_t memorySize = size_t(1) << 32; // 4 gigs if (memorySize == 0) memorySize = size_t(1) << 32; // 2 gigs

Updating the 2 gigs case to use 31 instead of 32 seems to resolve the memory issue. But I still get the segmentation fault when enabling the --log option. Also, the simulator prints the following error message related to illegal instructions (I am using the simple to_host example C-code as per the GCC):

rahul@rahul:~/work/swerv-ISS/build$ ./whisper test2 Error: Failed stop: 64 consecutive illegal instructions Retired 66 instructions in 0.00s 532258 inst/s

I'll open a pull request for the _uint128_t issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/westerndigitalcorporation/swerv-ISS/issues/9#issuecomment-480658794, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR4X42n_9sX5WJQh8-VcFqp3s9PIr7Mks5veqSRgaJpZM4cgnNo .

jrahmeh commented 5 years ago

I think this is fixed. If not, please re-open.