OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:34 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: UEFI GetMemoryMap() incorrectly showing low memory as free
PostPosted: Sat May 30, 2020 4:58 am 
Offline

Joined: Tue May 26, 2020 8:44 pm
Posts: 9
Hello all,

I was working on my physical memory manager; more specifically I was working on getting a few memory bitmaps in place. I noticed some very strange performance behavior, and after a ton of debugging, came to realize that my bitmap was actually bring printed as pixels across the top of my screen, and it looks like the performance issues occurred whenever the screen was bring printed too.

The memory area I was in was nowhere near the graphics buffer. Very long story short, my system was allocating the first available large enough space in "free" memory (according to UEFI's getMemoryMap) to store my bitmap. I put the memory map in another post a couple days ago, here it is:

Code:
Type Start Addr   Num Pages
7     0            160
7     1048576      768
2     4194304      2
7     4202496      7172
4     33579008     1
7     33583104     25
4     33685504     2272
7     42991616     9984
2     83886080     1
7     83890176     389055
1     1677459456   10
7     1677500416   491574
4     3690987520   32
7     3691118592   11827
2     3739561984   3
7     3739574272   775
4     3742748672   202
7     3743576064   27
4     3743686656   2836
7     3755302912   18
3     3755376640   366
5     3756875776   48
6     3757072384   36
0     3757219840   4
9     3757236224   8
10    3757268992   4
4     3757285376   134
6     3757834240   32
7     3757965312   16
7     4294967296  1179648


You might already be able to tell what happened, by the title and the table, but the memory bitmap was being stored in very low memory, the first table entry. It appears that the display was changing (and performance issues had) when the bitmap was writing to 0x000A0000, a.k.a. the video display memory. Some other system magic behind the scenes replicated this into my graphics buffer, but that's really besides the point.

I had assumed (silly me) that if UEFI told me that the first 160 pages of memory were "conventional memory" (Type 7, free to use how you want), that I could use it. I thought those low memory addresses just weren't reserved if you were using UEFI. Clearly that's not correct, so what memory addresses should I "black out"? Everything below 1mb? Why doesn't UEFI mark these important sections as reserved anyway? Is it a quirk of using VirtualBox? Are there other important parts of memory I should be marking as reserved?

Thanks ahead of time!


Top
 Profile  
 
 Post subject: Re: UEFI GetMemoryMap() incorrectly showing low memory as fr
PostPosted: Sat May 30, 2020 5:21 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
The memory map is correct, you must be interpreting it wrong somewhere. If you have 160 4kiB pages starting at 0, they cover addresses from 0 to 0x9FFFF and 0xA0000 is not included.


Top
 Profile  
 
 Post subject: Re: UEFI GetMemoryMap() incorrectly showing low memory as fr
PostPosted: Sat May 30, 2020 4:10 pm 
Offline

Joined: Tue May 26, 2020 8:44 pm
Posts: 9
Wow, that's embarrassing lol.. You're right, and my 4am sleep-deprived brain didn't catch that.. I think I should take a break for a day or two lol. There's a problem with the function that translated the free space from the memory map, but I had moved on past that part. Thanks for the help again, I'll try to double-check the obvious things next time before I post :)


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 83 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