gem5-users@gem5.org

The gem5 Users mailing list

View all threads

BasicPioDevice read() / write() not responding

D
diavastos@gmail.com
Sat, Oct 23, 2021 11:36 PM

Hi all,

I implemented a device using the BasicPioDevice class but I can't seem to get the read() & write() calls to work.
I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to the device directly using these two methods:

Method 1:

uint32_t inp_params2 = 14;
uint64_t driver = (uint64_t)0x200000000;
*driver = inp_params2;

Method 2:

asm volatile (
    "mov %0,0x200000000\n"
    :
    : "r" (inp_params2)
    :
);

With the Method 2, the simulation completes with no error but the write() is never called on the device, With Method 1 I get the following error:
panic: panic condition !handled occurred: Page table fault when accessing virtual address 0x200000000

Any help would be greatly appreciated!

Many Thanks,
andreas

Hi all, I implemented a device using the BasicPioDevice class but I can't seem to get the read() & write() calls to work. I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to the device directly using these two methods: Method 1: ----------- uint32_t inp_params2 = 14; uint64_t *driver = (uint64_t*)0x200000000; *driver = inp_params2; Method 2: ----------- asm volatile ( "mov %0,0x200000000\n" : : "r" (inp_params2) : ); With the Method 2, the simulation completes with no error but the write() is never called on the device, With Method 1 I get the following error: panic: panic condition !handled occurred: Page table fault when accessing virtual address 0x200000000 Any help would be greatly appreciated! Many Thanks, andreas
HN
Hoa Nguyen
Sun, Oct 24, 2021 2:01 AM

Hi Andreas,

My guess is that for Method 1, the pointer is of a virtual address so
there's a page fault there.

I'm not sure why the write() function wasn't invoked on Method 2. I got
into the same problem recently where I used mmap() to write to a physical
address, which should be handled by a Pio device. Even though the generated
binary has a store instruction to that address, the write() function wasn't
called. I solved that problem by using printf() to print the value at that
physical address. I think using volatile keyword should have worked as well.

I'm quite rusty on bare metal programming so I might be wrong :)

Regards,
Hoa Nguyen

On Sat, Oct 23, 2021, 4:37 PM diavastos--- via gem5-users <
gem5-users(a)gem5.org> wrote:

Hi all,

I implemented a device using the BasicPioDevice class but I can't seem to
get the read() & write() calls to work.
I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to
the device directly using these two methods:

Method 1:

uint32_t inp_params2 = 14;
uint64_t driver = (uint64_t)0x200000000;
*driver = inp_params2;

Method 2:

 asm volatile (
     "mov %0,0x200000000\n"
     :
     : "r" (inp_params2)
     :
 );

With the Method 2, the simulation completes with no error but the write()
is never called on the device, With Method 1 I get the following error:
panic: panic condition !handled occurred: Page table fault when accessing
virtual address 0x200000000

Any help would be greatly appreciated!

Many Thanks,
andreas


gem5-users mailing list -- gem5-users(a)gem5.org
To unsubscribe send an email to gem5-users-leave(a)gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Hi Andreas, My guess is that for Method 1, the pointer is of a virtual address so there's a page fault there. I'm not sure why the write() function wasn't invoked on Method 2. I got into the same problem recently where I used mmap() to write to a physical address, which should be handled by a Pio device. Even though the generated binary has a store instruction to that address, the write() function wasn't called. I solved that problem by using printf() to print the value at that physical address. I think using volatile keyword should have worked as well. I'm quite rusty on bare metal programming so I might be wrong :) Regards, Hoa Nguyen On Sat, Oct 23, 2021, 4:37 PM diavastos--- via gem5-users < gem5-users(a)gem5.org> wrote: > Hi all, > > I implemented a device using the BasicPioDevice class but I can't seem to > get the read() & write() calls to work. > I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to > the device directly using these two methods: > > Method 1: > ----------- > > uint32_t inp_params2 = 14; > uint64_t *driver = (uint64_t*)0x200000000; > *driver = inp_params2; > > Method 2: > ----------- > > asm volatile ( > "mov %0,0x200000000\n" > : > : "r" (inp_params2) > : > ); > > With the Method 2, the simulation completes with no error but the write() > is never called on the device, With Method 1 I get the following error: > panic: panic condition !handled occurred: Page table fault when accessing > virtual address 0x200000000 > > Any help would be greatly appreciated! > > Many Thanks, > andreas > _______________________________________________ > gem5-users mailing list -- gem5-users(a)gem5.org > To unsubscribe send an email to gem5-users-leave(a)gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >
GB
Gabe Black
Sun, Oct 24, 2021 3:22 AM

I agree with Hoa that you're using virtual addresses, and those are
unrelated to the physical addresses you're trying to access. The second
method is probably moving an immediate constant into the register, and not
loading from a memory address. mmap-ing the physical pages you're
interested in would help. Also you should use the "volatile" keyword to
tell the compiler that this isn't just memory, and it shouldn't assume that
the value won't change out from under it, and hence it needs to read from
it or write to it for real every time you tell it to. If you're using
caches, you'll also want to make sure that range is not cached, or the
accesses will be handled by the cache and not actually make it out to the
rest of the memory system.

Gabe

On Sat, Oct 23, 2021 at 7:02 PM Hoa Nguyen via gem5-users <
gem5-users(a)gem5.org> wrote:

Hi Andreas,

My guess is that for Method 1, the pointer is of a virtual address so
there's a page fault there.

I'm not sure why the write() function wasn't invoked on Method 2. I got
into the same problem recently where I used mmap() to write to a physical
address, which should be handled by a Pio device. Even though the generated
binary has a store instruction to that address, the write() function wasn't
called. I solved that problem by using printf() to print the value at that
physical address. I think using volatile keyword should have worked as well.

I'm quite rusty on bare metal programming so I might be wrong :)

Regards,
Hoa Nguyen

On Sat, Oct 23, 2021, 4:37 PM diavastos--- via gem5-users <
gem5-users(a)gem5.org> wrote:

Hi all,

I implemented a device using the BasicPioDevice class but I can't seem to
get the read() & write() calls to work.
I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to
the device directly using these two methods:

Method 1:

uint32_t inp_params2 = 14;
uint64_t driver = (uint64_t)0x200000000;
*driver = inp_params2;

Method 2:

 asm volatile (
     "mov %0,0x200000000\n"
     :
     : "r" (inp_params2)
     :
 );

With the Method 2, the simulation completes with no error but the write()
is never called on the device, With Method 1 I get the following error:
panic: panic condition !handled occurred: Page table fault when accessing
virtual address 0x200000000

Any help would be greatly appreciated!

Many Thanks,
andreas


gem5-users mailing list -- gem5-users(a)gem5.org
To unsubscribe send an email to gem5-users-leave(a)gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s


gem5-users mailing list -- gem5-users(a)gem5.org
To unsubscribe send an email to gem5-users-leave(a)gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

I agree with Hoa that you're using virtual addresses, and those are unrelated to the physical addresses you're trying to access. The second method is probably moving an immediate constant into the register, and not loading from a memory address. mmap-ing the physical pages you're interested in would help. Also you should use the "volatile" keyword to tell the compiler that this isn't just memory, and it shouldn't assume that the value won't change out from under it, and hence it needs to read from it or write to it for real every time you tell it to. If you're using caches, you'll also want to make sure that range is not cached, or the accesses will be handled by the cache and not actually make it out to the rest of the memory system. Gabe On Sat, Oct 23, 2021 at 7:02 PM Hoa Nguyen via gem5-users < gem5-users(a)gem5.org> wrote: > Hi Andreas, > > My guess is that for Method 1, the pointer is of a virtual address so > there's a page fault there. > > I'm not sure why the write() function wasn't invoked on Method 2. I got > into the same problem recently where I used mmap() to write to a physical > address, which should be handled by a Pio device. Even though the generated > binary has a store instruction to that address, the write() function wasn't > called. I solved that problem by using printf() to print the value at that > physical address. I think using volatile keyword should have worked as well. > > I'm quite rusty on bare metal programming so I might be wrong :) > > Regards, > Hoa Nguyen > > On Sat, Oct 23, 2021, 4:37 PM diavastos--- via gem5-users < > gem5-users(a)gem5.org> wrote: > >> Hi all, >> >> I implemented a device using the BasicPioDevice class but I can't seem to >> get the read() & write() calls to work. >> I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to >> the device directly using these two methods: >> >> Method 1: >> ----------- >> >> uint32_t inp_params2 = 14; >> uint64_t *driver = (uint64_t*)0x200000000; >> *driver = inp_params2; >> >> Method 2: >> ----------- >> >> asm volatile ( >> "mov %0,0x200000000\n" >> : >> : "r" (inp_params2) >> : >> ); >> >> With the Method 2, the simulation completes with no error but the write() >> is never called on the device, With Method 1 I get the following error: >> panic: panic condition !handled occurred: Page table fault when accessing >> virtual address 0x200000000 >> >> Any help would be greatly appreciated! >> >> Many Thanks, >> andreas >> _______________________________________________ >> gem5-users mailing list -- gem5-users(a)gem5.org >> To unsubscribe send an email to gem5-users-leave(a)gem5.org >> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >> > _______________________________________________ > gem5-users mailing list -- gem5-users(a)gem5.org > To unsubscribe send an email to gem5-users-leave(a)gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
D
diavastos@gmail.com
Sun, Oct 24, 2021 11:16 AM

Hi,

Thank you for the replies!

I mapped the physical address of the device to a virtual address and marked it as uncacheable and did the trick for X86. So now using memcpy() I read/write from and to the device using it's mapped virtual address.

However, for ARM it only works for read. Even if I write to the device memory address, it will still call the read() function on the device.

Is ARM handling the writes differently?

Many Thanks,
andreas

Hi, Thank you for the replies! I mapped the physical address of the device to a virtual address and marked it as uncacheable and did the trick for X86. So now using memcpy() I read/write from and to the device using it's mapped virtual address. However, for ARM it only works for read. Even if I write to the device memory address, it will still call the read() function on the device. Is ARM handling the writes differently? Many Thanks, andreas
DC
Derek Christ
Wed, Oct 25, 2023 8:44 PM

Hello everyone,

I'm hitting the exact same problem on ARM as Andreas.

I have a physical address mapped into the virtual address space and
marked it as uncacheable.
When I now write to the virtual address from my SE-program (multiple
times), exactly one read access is made to the corresponding physical
address.

It seems like the uncacheable flag is ignored and the Cache just handles
the miss and sends a read request.

Best
Derek

Hello everyone, I'm hitting the exact same problem on ARM as Andreas. I have a physical address mapped into the virtual address space and marked it as uncacheable. When I now write to the virtual address from my SE-program (multiple times), exactly one read access is made to the corresponding physical address. It seems like the uncacheable flag is ignored and the Cache just handles the miss and sends a read request. Best Derek