New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entering Long Mode: Mention physical address bits in the table describing a page table entry #314

phil-opp opened this Issue Apr 17, 2017 · 3 comments


3 participants
Copy link

phil-opp commented Apr 17, 2017

In the paging section we describe the page table entry format this way:

An entry in the P4, P3, P2, and P1 tables consists of the page aligned 52-bit physical address of the frame or the next page table and the following bits that can be OR-ed in:

It is followed by a table with the various field descriptions. This table doesn't mention bits 12 to 51, because the preceding sentence already said that these bits contain a physical address. This approach seems to cause some confusion, e.g. on why we can just OR the address with some bits without overwriting important parts of it.

In the blog comments, Frank Afriat recommended that it “would be clearer to add in the Paging section the meaning of bits 12-31 containing the physical address of the next P or the physical address”. I agree with that (but it should be “bits 12 - 51”).

So I think we should do the following:

  • Describe bits 12-51 in the table.
  • Explain that the address is always page aligned, so that we don't need to store bits 0-11.
  • Explain that the address is 2MiB/1GiB aligned for huge pages.
  • Maybe remove the “the following bits that can be OR-ed in” formulation in the preceding sentence and use something simpler (e.g. “a page table entry has the following format”) instead.

This comment has been minimized.

Copy link

le-jzr commented Apr 17, 2017

I agree that the formulation is clunky. The entry is a bit field, with particular bits and bit ranges being reserved for different pieces of information. The fact that we can build the entry using shifts and bitwise or is an implementation detail, and doesn't serve well as an explanation.


This comment has been minimized.

Copy link

blackdogbro commented Dec 12, 2018

Hi, Phil-opp

I have a problem when trying to compile and run your source code.
The situation is..
I tried to read(or write) the memory range 1M-955M on the computer, and the result was successful.
But when I tried to read(or write) the memory range 956M-1023M on the computer, the result was always crash...

I would like to ask if the page table or something needs to be modified?


This comment has been minimized.

Copy link

phil-opp commented Dec 12, 2018

@blackdogbro Hi, this is an old, outdated issue about a formulation in the "Entering Long Mode" post. Could you create a new issue for your problem?

About your issue: The crash could have various causes. Do you have your code online somewhere so that I can take a look?

@phil-opp phil-opp closed this Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment