X86-64 paging global bit

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
bmj
Posts: 5
Joined: Sun Jun 05, 2022 4:16 pm

X86-64 paging global bit

Post by bmj »

How is the global bit used on 64 bit paging? Can it be used on the top level like when using 32 bit paging?

I am kind of confused by the images on the wiki for 6 for 64 4 bit paging. I'd don't know why there are two images, and what is meant with page-sized and non-page-sized.

Thanks
thewrongchristian
Member
Member
Posts: 426
Joined: Tue Apr 03, 2018 2:44 am

Re: X86-64 paging global bit

Post by thewrongchristian »

bmj wrote:How is the global bit used on 64 bit paging? Can it be used on the top level like when using 32 bit paging?
The Global bit just prevents that page from being flushed from the TLB when the CR3 is updated. It's used for mappings that are shared between all address spaces, such as the kernel page mapping.

64-bit paging on x86 is just like PAE paging in 32-bit, except the "top" level is no longer 4 entries long, but the full 512 entries long (it also is no longer the top level either, but instead has possibly a 4th and 5th level above it.)

Global is a PTE bit, so if a higher level page table is mapping a large page (such as a 2MB page in PAE mode), then yes, it can have the Global bit set, and will be used across address spaces.
bmj wrote: I am kind of confused by the images on the wiki for 6 for 64 4 bit paging. I'd don't know why there are two images, and what is meant with page-sized and non-page-sized.

Thanks
The PS field at the directory level indicates whether the physical address is:
- 0 - A pointer to the next level down page table.
- 1 - A pointer to an actual page, sized accordingly by the page table level.

For example, when PS=1 at the page directory level, the physical address is the address of a page of size 4MB (non-PAE) or 2MB (PAE). It's just discriminating between entries for big pages and entries for page tables.
bmj
Posts: 5
Joined: Sun Jun 05, 2022 4:16 pm

Re: X86-64 paging global bit

Post by bmj »

thewrongchristian wrote:
bmj wrote:How is the global bit used on 64 bit paging? Can it be used on the top level like when using 32 bit paging?
The Global bit just prevents that page from being flushed from the TLB when the CR3 is updated. It's used for mappings that are shared between all address spaces, such as the kernel page mapping.

64-bit paging on x86 is just like PAE paging in 32-bit, except the "top" level is no longer 4 entries long, but the full 512 entries long (it also is no longer the top level either, but instead has possibly a 4th and 5th level above it.)

Global is a PTE bit, so if a higher level page table is mapping a large page (such as a 2MB page in PAE mode), then yes, it can have the Global bit set, and will be used across address spaces.
bmj wrote: I am kind of confused by the images on the wiki for 6 for 64 4 bit paging. I'd don't know why there are two images, and what is meant with page-sized and non-page-sized.

Thanks
The PS field at the directory level indicates whether the physical address is:
- 0 - A pointer to the next level down page table.
- 1 - A pointer to an actual page, sized accordingly by the page table level.

For example, when PS=1 at the page directory level, the physical address is the address of a page of size 4MB (non-PAE) or 2MB (PAE). It's just discriminating between entries for big pages and entries for page tables.
Post Reply