-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Architecture-dependent Page Table Entry (PTE) flags for x86_64
and aarch64
#699
Architecture-dependent Page Table Entry (PTE) flags for x86_64
and aarch64
#699
Conversation
…ation, conversion routines between arch-specific flags and software ones.
100a3ed
to
ba4190c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, other than the two other comments I left on specific lines.
Not so important: PteFlags
has the flags that best match x86_64 & aarch64; if we want to support risc-v in the future, would we change it based on flags common to aarch64, x86_64 & risc-v? I guess we'll see in the future
ok this should be completely ready now. @NathanRoyer please re-review and also see how I did the cool cfg stuff with docs |
edit: we solved this during our meeting
Very nice, didn't know about this trick |
Also, should we add a dummy |
Something I forgot: Regarding the output address size: I was using 48-bit OA mode in my experimental code; I assumed we could only address up to 48 bits (4 levels * 9 bits + 12 bits). However, actually one of the following configurations can be selected (using As we can see, the 52-bit output address mode is a bit more complex as some bits of the OA are shifted to the middle of lower attributes. This allows the dirty bit to always occupy the 51st bit. In 48-bit OA mode, bits 48 & 49 are reserved and bit 50 is the Guarded Page bit - implementation is optional. In 52-bit OA mode, the shareability attributes are stored in the TCR_EL1 register, specifcially in field SH0 for TTBR0 page table walks and in field SH1 for TTBR1 page table walks. This limits us to two shareability profiles and also complexifies page table management a bit since that requires us to maintain two page tables at all time. Apparently long mode x86_64 also supports 52-bit OA mode; I don't know how this is configured however, but maybe you know. |
whoa, definitely not. That would be invalid and could lead to us completely misinterpreting what PTE values mean. For a concrete example of why, in the initial bootstrap assembly code (boot.asm) we actually do use huge pages to efficiently and easily map large regions of the very lowest and very highest addresses before jumping to Rust code. If we attempted to call In any case, why do something like that which could confuse the caller? It also acts as a sanity check if we ever do come across a mapping that uses huge pages, or in the future when we add proper support for them. |
That's fine, it seems that those bits just allow hardware to set the access flag (as is the default behavior on x86) instead of the OS always doing it (?). Looks like the Access Flag Fault always occurs regardless of HA/HD value, so let's just always set the |
48-bit is fine with me, we can use that for now and if it presents problems we can move to 52-bit.
I was wondering about the DIRTY bit, that makes sense. Glad we resolved that.
We'd only ever use
We don't use it, but it's much simpler on x86 -- the 52-bit physical address can pretty much always be used. |
@NathanRoyer I have addressed all of our comments, please double-check everything again. Important Note: in the |
About
I think it's not necessarily the previous one; from the DDI0487:
But anyway, the nuance is small and we don't use it so I'll leave it as is.
I responded to this on Discord: the most significant bits of an address are typically used for tagged addresses (ASID) or ignored, when that mechanism is disabled. I will approve this, you can merge it in. |
Right, thanks for pointing that out. I'll fix it. |
…4` (#699) * The `pte_flags` crate will replace `entryflags` and supports both `aarch64` & `x86_64` * There are "lower-level" (architecture-specific) PTE flag types that can be converted to and from a "higher-level" (architecture-independent) `PteFlags` type. * Currently unused in Theseus, but will be used in an upcoming PR. Co-authored-by: Nathan Royer <[email protected]> 29ffb09
* The `pte_flags` crate offers the following improvements: * Builder-style functions to set or clear each flag. * A unified interface for checking or setting PTE flags across all architectures. * The ability to be as generic or as specific to an architecture as you like. * Lossless conversions from the generic `PteFlags` to the arch-specific `PteFlags<Arch>`, and lossy conversions from the arch-specific `PteFlags<Arch>` to the generic `PteFlags`. * See #699 and #712 for more details. * All memory mapping functions now accept the PTE flags parameter as an instance of `Into<PteFlagsArch>`, which allows both arch-generic `PteFlags` and arch-specific `PteFlagsX86_64` or `PteFlagsAarch64` to be used.
* The `pte_flags` crate offers the following improvements: * Builder-style functions to set or clear each flag. * A unified interface for checking or setting PTE flags across all architectures. * The ability to be as generic or as specific to an architecture as you like. * Lossless conversions from the generic `PteFlags` to the arch-specific `PteFlags<Arch>`, and lossy conversions from the arch-specific `PteFlags<Arch>` to the generic `PteFlags`. * See #699 and #712 for more details. * All memory mapping functions now accept the PTE flags parameter as an instance of `Into<PteFlagsArch>`, which allows both arch-generic `PteFlags` and arch-specific `PteFlagsX86_64` or `PteFlagsAarch64` to be used. e7847d5
For purposes of comparison with #696
Remaining TODO: addDone#[test]
cases for the four conversion routines.