Coder Social home page Coder Social logo

Comments (24)

Virtual-Machine avatar Virtual-Machine commented on July 25, 2024 9

What worked for me was to pull the source for Qemu 4.2.1 and compile. I put this 4.2.1 version qemu-system-riscv64 in my path before the system version so it would be preferred.

What I am unsure of is if a later version of Qemu would work, but this atleast let me boot from make qemu. Maybe someone with a faster rig could try newer versions to see if one of them will also suffice.

Another strange thing which I am unsure if this is a generic risc-v/qemu issue or not but I cannot seem to get it to launch a graphics window like the x86_64 version does regardless of the version. Maybe someone more knowledgable can comment.

from xv6-riscv.

VitalyAnkh avatar VitalyAnkh commented on July 25, 2024 6

I'm running Arch Linux with an amd64 laptop but meet the same problem.

from xv6-riscv.

Taowyoo avatar Taowyoo commented on July 25, 2024 5

@Taowyoo Thanks! This makes us run the tutorial smoothly, but I wonder how could we port xv6 to the latest qemu? I think it’s worthing doing.

@VitalyAnkh
Yes, that's the best way.
I tried to debug xv6 to found the problem:
I found the code stuck at

asm volatile("mret");

I am new to RISC-V and xv6 also qemu. But I will continue learning and working on this problem

from xv6-riscv.

Taowyoo avatar Taowyoo commented on July 25, 2024 3

This problem should be fixed by #62
I have checked it works correctly with Qemu 6.0.0 on my Arch.
@Virtual-Machine @VitalyAnkh

from xv6-riscv.

Alice-space avatar Alice-space commented on July 25, 2024 1

I ran into the same problem.
The solution of this blog works

from xv6-riscv.

Virtual-Machine avatar Virtual-Machine commented on July 25, 2024 1

@u2386 to debug OS boot you can use the provided "make qemu-gdb" which should start up xv6 in qemu waiting for a gdb session to connect. If you then run gdb in another shell you can have it connect to the OS waiting in qemu. From there you should be able to set breakpoints, jump, read, inspect the OS as it boots up etc.

Reviewing the Makefile should be helpful to see how it does this via command line flags.

image

Also of relevance see the .gdbinit file:

image

from xv6-riscv.

gaelwjl avatar gaelwjl commented on July 25, 2024

I have met the same problem with qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied

from xv6-riscv.

Taowyoo avatar Taowyoo commented on July 25, 2024

I'm running Arch Linux with an amd64 laptop but meet the same problem.

@VitalyAnkh
I meet the same problem in Archlinux.
According to Virtual-Machine 's solution.
Because Archlinux update in rolling, qemu 4.2 depending on many old version libraries so it cannot run correctly.
After serval tries, I found qemu 5.2 is OK to me.

My OS info

Operating System: Manjaro Linux 21.0.5
Kernel: Linux 5.9.16-1-MANJARO

Here is how to downgrade qemu and qemu-arch-extra

  1. Install downgrade through yay
# install yay
pacman -S yay
# use yay to install downgrade from AUR repo
yay -S downgrade
  1. Use downgrade to downgrade qemu and qemu-arch-extra to 5.2
sudo su
export DOWNGRADE_FROM_ALA=1
downgrade qemu-arch-extra qemu

When asking you which version to downgrade, choose:
qemu 5.2.0 4 x86_64
qemu-arch-extra 5.2.0 4 x86_64

from xv6-riscv.

VitalyAnkh avatar VitalyAnkh commented on July 25, 2024

@Taowyoo Thanks! This makes us run the tutorial smoothly, but I wonder how could we port xv6 to the latest qemu? I think it’s worthing doing.

from xv6-riscv.

Virtual-Machine avatar Virtual-Machine commented on July 25, 2024

@Taowyoo

Nice catch. I tried debugging as well and I am also getting caught on mret but inside the timervec routine instead... when using QEMU 6.0.0 on Arch. I can send an interrupt signal and it will reloop back and get caught on the mret again.

from xv6-riscv.

Taowyoo avatar Taowyoo commented on July 25, 2024

@Virtual-Machine
Yes, same to me.
I have updated this problem on QEMU's Gitlab repo:
https://gitlab.com/qemu-project/qemu/-/issues/192

I am not sure that's the correct place.
Maybe I should create a new issue.

from xv6-riscv.

kalpesh2001 avatar kalpesh2001 commented on July 25, 2024

I am trying to compile on Mac running Big Sur 11.2.3 and getting
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied

Any idea how to get around this. Any help is appreciated.

from xv6-riscv.

ZonePG avatar ZonePG commented on July 25, 2024

I am trying to compile on Mac running Big Sur 11.2.3 and getting
qemu-system-riscv64: qemu_mprotect__osdep: mprotect failed: Permission denied

Any idea how to get around this. Any help is appreciated.

This article may help you, but applies to qemu5.1.0 and xv6 os run well.

from xv6-riscv.

siwei-li avatar siwei-li commented on July 25, 2024

Two patches added to qemu-5.10.0 and it works!
See here: ReZeroS/mit6.828-note#3

from xv6-riscv.

jcob-sikorski avatar jcob-sikorski commented on July 25, 2024

Solution:

(Steps 2-5 have to be made on Ubuntu)

  1. install Ubuntu LTS for arm64 (I made it by installing on UTM virtual machine https://mac.getutm.app/gallery/ubuntu-20-04)
  2. after successful installation, type to Ubuntu Shell sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
  3. git clone this repository
  4. go to directory where this repository was installed
  5. type make qemu

from xv6-riscv.

u2386 avatar u2386 commented on July 25, 2024

I tried to debug xv6 to found the problem:

Hi @Taowyoo @Virtual-Machine, I got the same problem but did know how to debug on qemu, especially at the time of os booting. :/

Could I ask how did you debug this scenario?

from xv6-riscv.

fengxiaohu avatar fengxiaohu commented on July 25, 2024

@u2386 to debug OS boot you can use the provided "make qemu-gdb" which should start up xv6 in qemu waiting for a gdb session to connect. If you then run gdb in another shell you can have it connect to the OS waiting in qemu. From there you should be able to set breakpoints, jump, read, inspect the OS as it boots up etc.

Reviewing the Makefile should be helpful to see how it does this via command line flags.

image

Also of relevance see the .gdbinit file:

image

perfect answer.I used to know run make qemu-gdb to debug,But I never realized to check the Makefile.Now I get it.

from xv6-riscv.

zhouzilong2020 avatar zhouzilong2020 commented on July 25, 2024

Try to boot with

riscv64-unknown-elf-gcc (g2ee5e430018-dirty) 12.2.0
QEMU emulator version 7.2.0

and met the same problem.

from xv6-riscv.

Mazz84002 avatar Mazz84002 commented on July 25, 2024

I was able to run xv6-x86 on my m1 mac running ubuntu arm64. Perform the following steps:

  1. clone the xv6 from git
  2. Now you need to install a cross compiler: sudo apt install gcc-i686-linux-gnu
  3. Go to the directory and instead of make , type make TOLLPREFIX=i686-linux-gnu-
  4. Now, instead of make qemu-nox, type make TOLLPREFIX=i686-linux-gnu- qemu-nox
  5. Voilà!!

from xv6-riscv.

alex-puchkov avatar alex-puchkov commented on July 25, 2024

I was able to run xv6-x86 on my m1 mac running ubuntu arm64. Perform the following steps:

1. clone the xv6 from git

2. Now you need to install a cross compiler: `sudo apt install gcc-i686-linux-gnu`

3. Go to the directory and instead of `make` , type `make TOLLPREFIX=i686-linux-gnu-`

4. Now, instead of `make qemu-nox`, type `make TOLLPREFIX=i686-linux-gnu- qemu-nox`

5. Voilà!!

Hey,

I'm also using M1 and a virtual Ubuntu ARM64 using UTM. How do I find the directory you mentioned at the third line?

from xv6-riscv.

Mazz84002 avatar Mazz84002 commented on July 25, 2024

By directory I mean the location where you have downloaded the files of xv6. When you type git clone https://github.com/mit-pdos/xv6-public.git, you will have a directory named xv6 inside the directory you are already working in. Then you can use cd xv6 in the terminal to go to the xv6 directory. You can also find this by doing a system search and cd to that directly through the terminal.

from xv6-riscv.

alex-puchkov avatar alex-puchkov commented on July 25, 2024

By directory I mean the location where you have downloaded the files of xv6. When you type git clone https://github.com/mit-pdos/xv6-public.git, you will have a directory named xv6 inside the directory you are already working in. Then you can use cd xv6 in the terminal to go to the xv6 directory. You can also find this by doing a system search and cd to that directly through the terminal.

Thanks. I'm getting the following error after running make TOLLPREFIX. Any ideas on how to solve it?

`make TOLLPREFIX=i686-linux-gnu-


*** Error: Couldn't find an i386--elf version of GCC/binutils.
*** Is the directory with i386-jos-elf-gcc in your PATH?
*** If your i386-
-elf toolchain is installed with a command
*** prefix other than 'i386-jos-elf-', set your TOOLPREFIX
*** environment variable to that prefix and run 'make' again.
*** To turn off this error, run 'gmake TOOLPREFIX= ...'.


gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pie -no-pie -fno-pic -O -nostdinc -I. -c bootmain.c
gcc: error: unrecognized command-line option ‘-m32’
make: *** [Makefile:104: bootblock] Error 1
`

from xv6-riscv.

Mazz84002 avatar Mazz84002 commented on July 25, 2024

To run xv6, you need qemu. Do you have it installed> sudo apt install qemu x86_64-elf-gcc
Can you try typing sudo apt install build-essential in your terminal?
Not sure if this will work

from xv6-riscv.

keichenblat avatar keichenblat commented on July 25, 2024

I was able to run xv6-x86 on my m1 mac running ubuntu arm64. Perform the following steps:

  1. clone the xv6 from git
  2. Now you need to install a cross compiler: sudo apt install gcc-i686-linux-gnu
  3. Go to the directory and instead of make , type make TOLLPREFIX=i686-linux-gnu-
  4. Now, instead of make qemu-nox, type make TOLLPREFIX=i686-linux-gnu- qemu-nox
  5. Voilà!!

Thanks, but there's a crucial typo in your answer, it is TOOLPREFIX not TOLLPREFIX. Here's a corrected answer:

  1. clone the xv6 from git
  2. Now you need to install a cross compiler: sudo apt install gcc-i686-linux-gnu
  3. Go to the directory and instead of make , type make TOOLPREFIX=i686-linux-gnu-
  4. Now, instead of make qemu-nox, type make TOOLPREFIX=i686-linux-gnu- qemu-nox

from xv6-riscv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.