Skip to content
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

Should the mptl3.ppn be aligned with the mpt table size (16MB)? #111

Closed
rock-ifly opened this issue Nov 7, 2024 · 6 comments · Fixed by #112
Closed

Should the mptl3.ppn be aligned with the mpt table size (16MB)? #111

rock-ifly opened this issue Nov 7, 2024 · 6 comments · Fixed by #112

Comments

@rock-ifly
Copy link

Should the mptL3 ppn be aligned with the mpt table size?

for MPTL3, the mptl3.ppn is the base addr for mptL2, which is size of 16MB,

should the mptl3.ppn be

A : aligned with the mpt table size(16MB)?

B: or any addr without any alignment restriction?

@rsahita
Copy link
Collaborator

rsahita commented Nov 9, 2024

yes (A). the address of the table should be naturally aligned to the size of the table. Will post a PR.

@rock-ifly
Copy link
Author

rock-ifly commented Nov 12, 2024

OK.

Then we can see that, when PAW(physical address width) > 46

  1. mptl3 is aligned to size of mptl3, which is determined by PAW. such as when PAW=48, mptl3 need to aligned with 4 Bytes.
  2. mptl2 is aligned to size of mptl2, which is 16MB.
  3. mptl1 is aligned to size of mptl1, which is 4KB.

@rsahita
Copy link
Collaborator

rsahita commented Nov 13, 2024

Actually this is specified in Section 3.1

The mmpt.PPN refers to an MPTL3 table or an MPTL2 table based on physical address width (PAW). For 56
= PAW > 46, MPTL3 table must be of size 2^(PAW-43) bytes and naturally aligned to that sized byte
boundary. For 46 >= PAW > 32 the MPTL2 table must be of size 2^(PAW-22) bytes for Smmpt46 and Smmpt34,
and must be naturally aligned to that sized byte boundary. In these modes, the lowest two bits of
the physical page number (mmpt.PPN) in mmpt always read as zeros.

so for your example PAW of 48, mmpt.PPN will refer to a MPTL3 of size 2^5 bytes and aligned to that size,
MPTL2 will refer to a table of size 16MB and aligned to that size, and MPTL3 will be a 4K table and aligned to that size.

@rsahita rsahita closed this as completed Nov 13, 2024
@rock-ifly
Copy link
Author

OK, thank you.

@SiFiveHolland
Copy link
Collaborator

SiFiveHolland commented Nov 15, 2024

so for your example PAW of 48, mmpt.PPN will refer to a MPTL3 of size 2^5 bytes and aligned to that size

This is not correct. mmpt.PPN is a physical page number, not a physical address, so the alignment is at least 4 KiB, regardless of the size of the table.

In fact, the last sentence from that paragraph implies the minimum alignment is 16 KiB (4 pages), even though I think it was meant to imply that the minimum alignment is 4 bytes (as it would imply if empt.PPN was an address).

@rsahita
Copy link
Collaborator

rsahita commented Nov 18, 2024

thanks for catching my error @SiFiveHolland - I misspoke - I meant that the actual entries may occupy less than the min 4KiB page for the L3 entries. thanks for the PR #112

@rsahita rsahita closed this as completed Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants