gem5-users@gem5.org

The gem5 Users mailing list

View all threads

Question about changing PrivilegeMode

王崇滕
Mon, Aug 14, 2023 5:00 PM

Hi everyone,

I ran the following program which simply reads the value of MiscReg
(mhartid, mstatus, ...),
https://pastebin.com/t5XBBWEz. (remove line 31-32)

The compilation command I used is, riscv64-unknown-elf-gcc -static hello1.c
-o hello1.
I ran it with SE script, gem5.opt se.py -c hello1

And this is the error I got,
panic: Illegal instruction 0xf14027f3 at pc (0x101b8=>0x101bc).(0=>1):
mhartid is not accessible in 0.

I believe the "0" stands for the value of PrivilegeMode PRV_U right?
So my question is how do I change from PRV_U to PRV_M in order to access
MiscReg?
Also, I have found an element of array MiscRegNames in isa.cc, which
is [MISCREG_PRV]          = "PRV", does this element control which
PrivilegeMode that i'm in?
Any help would be appreciated!
Thanks

Regards,
Jerry

Hi everyone, I ran the following program which simply reads the value of MiscReg (mhartid, mstatus, ...), https://pastebin.com/t5XBBWEz. (remove line 31-32) The compilation command I used is, riscv64-unknown-elf-gcc -static hello1.c -o hello1. I ran it with SE script, gem5.opt se.py -c hello1 And this is the error I got, panic: Illegal instruction 0xf14027f3 at pc (0x101b8=>0x101bc).(0=>1): mhartid is not accessible in 0. I believe the "0" stands for the value of PrivilegeMode PRV_U right? So my question is how do I change from PRV_U to PRV_M in order to access MiscReg? Also, I have found an element of array MiscRegNames in isa.cc, which is [MISCREG_PRV] = "PRV", does this element control which PrivilegeMode that i'm in? Any help would be appreciated! Thanks Regards, Jerry
BB
Bobby Bruce
Mon, Aug 14, 2023 7:17 PM

Hey,

SE mode runs things in user space, you cannot run privileged instructions in it.

If you wish to support privilege levels then you'll need to build an FS mode simulation.

Kind regards,
Bobby

--
Dr. Bobby R. Bruce
Room 3050,
Kemper Hall, UC Davis
Davis,
CA, 95616

web: https://www.bobbybruce.net

On Aug 14, 2023, at 10:00 AM, 王崇滕 via gem5-users gem5-users@gem5.org wrote:

Hi everyone,

I ran the following program which simply reads the value of MiscReg (mhartid, mstatus, ...),
https://pastebin.com/t5XBBWEz. (remove line 31-32)

The compilation command I used is, riscv64-unknown-elf-gcc -static hello1.c -o hello1.
I ran it with SE script, gem5.opt se.py -c hello1

And this is the error I got,
panic: Illegal instruction 0xf14027f3 at pc (0x101b8=>0x101bc).(0=>1): mhartid is not accessible in 0.

I believe the "0" stands for the value of PrivilegeMode PRV_U right?
So my question is how do I change from PRV_U to PRV_M in order to access MiscReg?
Also, I have found an element of array MiscRegNames in isa.cc, which is [MISCREG_PRV]          = "PRV", does this element control which PrivilegeMode that i'm in?
Any help would be appreciated!
Thanks

Regards,
Jerry


gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-leave@gem5.org

Hey, SE mode runs things in user space, you cannot run privileged instructions in it. If you wish to support privilege levels then you'll need to build an FS mode simulation. Kind regards, Bobby -- Dr. Bobby R. Bruce Room 3050, Kemper Hall, UC Davis Davis, CA, 95616 web: https://www.bobbybruce.net > On Aug 14, 2023, at 10:00 AM, 王崇滕 via gem5-users <gem5-users@gem5.org> wrote: > > Hi everyone, > > I ran the following program which simply reads the value of MiscReg (mhartid, mstatus, ...), > https://pastebin.com/t5XBBWEz. (remove line 31-32) > > The compilation command I used is, riscv64-unknown-elf-gcc -static hello1.c -o hello1. > I ran it with SE script, gem5.opt se.py -c hello1 > > And this is the error I got, > panic: Illegal instruction 0xf14027f3 at pc (0x101b8=>0x101bc).(0=>1): mhartid is not accessible in 0. > > I believe the "0" stands for the value of PrivilegeMode PRV_U right? > So my question is how do I change from PRV_U to PRV_M in order to access MiscReg? > Also, I have found an element of array MiscRegNames in isa.cc, which is [MISCREG_PRV] = "PRV", does this element control which PrivilegeMode that i'm in? > Any help would be appreciated! > Thanks > > Regards, > Jerry > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-leave@gem5.org