Skip to content

Commit c53ea31

Browse files
committed
RFC-21: Unify behaviour of the Page Map invocation
Signed-off-by: Krishnan Winter <krishnan.winter@unsw.edu.au>
1 parent 746b98b commit c53ea31

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

src/proposed/0210-over-mapping.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!--
2+
SPDX-License-Identifier: CC-BY-SA-4.0
3+
Copyright 2025, UNSW
4+
-->
5+
6+
# Unify behaviour of the Page Map invocation
7+
8+
- Author: Krishnan Winter
9+
- Proposed: 2025-10-21
10+
11+
## Summary
12+
13+
Enforce the same over-map behaviour of the page map invocation across all architectures.
14+
15+
## Motivation
16+
17+
- Currently the handling of over-mapping between architectures differs. On RISCV,
18+
it is not permitted, whereas on aarch32, aarch64 and x86 it is.
19+
- This difference isn't due to any specific hardware requirement. It is a policy
20+
choice in the kernel that should be consistent.
21+
- This RFC proposes to enforce the same behaviour across all architectures,
22+
that is, prevent over-mapping on all architectures.
23+
24+
## Guide-level explanation
25+
26+
Over-mapping refers to when a user overwrites an existing mapping with a
27+
new one. That means, if the user has already mapped frame A to address x,
28+
they would be able to map frame B to address x (supposing that the rest of the
29+
error checking doesn't fail).
30+
31+
Currently, on aarch32, aarch64 and x86 we allow the user to over-map a page.
32+
33+
However, on RISC-V, this is not the behaviour. If you wanted to do the above,
34+
you would get a `seL4_DeleteFirst` error.
35+
36+
37+
## Reference-level explanation
38+
39+
This change is a breaking change to the `seL4_XXX_Page_Map` invocation on the
40+
following architectures:
41+
- aarch32
42+
- aarch64
43+
- x86
44+
45+
Note that there is a difference between "re-mapping" and "over-mapping".
46+
47+
Re-mapping is when the user attempts to map a frame that they have previously
48+
mapped into their address space at the same address, potentially for a permissions
49+
change.
50+
51+
Over-mapping is the case where the kernel has been provided an unmapped frame,
52+
and the user is attempting to map to an address that already has a differnt frame
53+
backing it.
54+
55+
Additions have been made to the `decodeXxxxFrameInvocation` functions for the
56+
above architectures to introduce a check to prevent overmapping, and if detected
57+
then we return a `seL4_DeleteFirst` error.
58+
59+
60+
## Drawbacks
61+
62+
This is a breaking change for existing users that may rely on overmapping.
63+
Additionally, this restricts the flexibility of the API.
64+
65+
Another major drawback that has been brought up is the verification effort that
66+
will be required for this change as it breaks existing proofs.
67+
68+
## Rationale and alternatives
69+
70+
There are two other alternatives to the proposed changes:
71+
72+
- Make RISCV follow the other architectures, allowing over-mapping.
73+
- Make no code changes, and update the manual to explictily mention over-mapping.
74+
This would mean that there are no verification changes that need to be done.
75+
76+
The behaviour of `map` should be well documented, and to avoid confusion for
77+
users, the behvaiour should be the same across architectures if there's no
78+
hardware reason for the difference. This is a change that should be done
79+
sooner rather than later, as although this change may affect some users now, it may
80+
potentially affect many more users if we defer til later.
81+
82+
## Prior art
83+
84+
Linux allows users to choose if over-mapping is allowed through the use of the
85+
`MAP_FIXED` and `MAP_FIXED_NOREPLACE` flags in `mmap`. Whichever approach we
86+
decide is not necessarily incorrect, but should be uniform across architectures.
87+
88+
89+
## Unresolved questions
90+
91+
- Is the verification of these changes something that can be funded?

0 commit comments

Comments
 (0)