OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Aug 24, 2019 9:37 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: ACPI: read memory fe0000-ffffff problem
PostPosted: Tue May 14, 2019 4:58 am 
Offline

Joined: Sun Apr 14, 2019 12:19 am
Posts: 4
Hello,

I've a strange effect when I try to read memory from fe0000 to ffffff (type 2 memory).
Look to all screenshots:

It's because I got a panic issue (at the line in blue) that I made some test and I see this:
- dump 4 bytes memory 0xfe1656 directely work (in green = RSDT in ASCII).
- dump from value from the struct fail (in red).

When it's strange is that it's exatly the same value.
Below I show you the bank memory available.

An idea?


Attachments:
File comment: Memory bank
MEM_dump2.jpg
MEM_dump2.jpg [ 27.44 KiB | Viewed 492 times ]
File comment: PANIC
MEM_dump1.jpg
MEM_dump1.jpg [ 79.96 KiB | Viewed 492 times ]
File comment: Bug
MEM_dump0.jpg
MEM_dump0.jpg [ 44.35 KiB | Viewed 492 times ]
Top
 Profile  
 
 Post subject: Re: ACPI: read memory fe0000-ffffff problem
PostPosted: Tue May 14, 2019 5:51 am 
Offline
Member
Member

Joined: Fri Jun 28, 2013 1:48 am
Posts: 40
The information you provided is not enough. What's the structure of `sdt`, and what's the code of `MEM_dump`? When running this code, are your OS work in single-thread mode?

_________________
Reinventing the Wheel, code: https://github.com/songziming/wheel


Top
 Profile  
 
 Post subject: Re: ACPI: read memory fe0000-ffffff problem
PostPosted: Tue May 14, 2019 6:05 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 263
Location: Private, UK
You're getting a page fault. That almost certainly means that the address you're trying to access isn't mapped. What do your page tables look like? What does the code that creates them do? I'd suggest that your page fault exception handler should at least have the ability to output the contents of the CR2 register that contains the fault address...

What does "MEM_dump" do? I suspect it's not doing what you think it is; it appears to simply output its parameters (it's pretty unlikely that the address 0xFE1656 actually contains the number "4"), but I suspect it's supposed to output a number of bytes of memory from the address given.

If that function isn't working correctly, then nothing attempts to dereference the pointer "sdt->sig" until the "memcmp" call, hence the crash on that line.


Actually, ignore the above italic text (I wonder if this forum will ever update to a version that supports strikethrough formatting; surely a 12-year-old version of phpBB can't be good for server security...). It appears that "MEM_dump" actually outputs the "dumped" memory on the next line and therefore you have two "identical" calls, but only the second causes a crash. That suggests that either; (1) the code to print addresses as hex has a bug and the addresses are not, in fact, identical or (2) "MEM_dump" has a bug meaning it's not actually doing the same thing both times.

The first dump is printing the correct ASCII values for "RSDT", so it appears that the hard-coded address is correct at least.

_________________
Image


Top
 Profile  
 
 Post subject: Re: ACPI: read memory fe0000-ffffff problem
PostPosted: Tue May 14, 2019 8:49 am 
Offline

Joined: Sun Apr 14, 2019 12:19 am
Posts: 4
You right, the code I study has add a wrong page offset.
So the pointer try to read invalid address memory = crash.

Removing this value and all work perfectly.

And yes, MEM_dump is my tool to dump memory in text, like this (HEX translate a char to hex value):

Code:
void MEM_dump(void * src, unsigned long bytes) { // Affiche une zone mémoire en HEXA
    unsigned char * s = (unsigned char *) src;
    char blanc = 0;
    char col = 0;
    printf("MEM_dump: %x %d\n", s, bytes);
    for(register unsigned long i = 0; i < bytes; i++) {
        printf("%s ", HEX(s[i]));
        if (blanc == 3) {
            blanc = 0;           
            if (col == 5) {
                printf("\n");
                col = 0;
            } else {
                printf(" ");
                col++;
            }
        } else blanc++;       
    }
    printf("\n");
}


Top
 Profile  
 
 Post subject: Re: ACPI: read memory fe0000-ffffff problem
PostPosted: Thu May 16, 2019 2:05 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 263
Location: Private, UK
Is this 32-bit or 64-bit code?

For 64-bit code, the "%x" format specifier will (usually; assuming the common LP64 or LLP64 data models) only print a 32-bit value (and hence, the address passed into the second call to MEM_dump may not be the same as the first). "%p" should be used to print pointer addresses.

I'd still suggest that knowing the address of the page fault (from the CR2 register) would be beneficial in identifying the problem...

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group