Skip to content

Commit c14d570

Browse files
committed
Add GCS design document
1 parent e0104f9 commit c14d570

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

main/design_documents/gcs.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Design Document for GCS
2+
3+
## Feature test
4+
5+
GCS support has three levels:
6+
7+
(1) Code generation is GCS compatible. (Compile time decision.)
8+
9+
(2) HW supports GCS instructions. (Might be known at compile time,
10+
but this is a runtime feature.)
11+
12+
(3) GCS is enabled at runtime. (Only known at runtime.)
13+
14+
Where (3) implies (1) and (2). In principle a user may decide to
15+
enable GCS even if (1) was false at compile time, but this is
16+
a user error. The runtime system is responsible for enabling GCS
17+
when (1) and (2) holds and GCS protection was requested for the
18+
program.
19+
20+
(1) and (2) need feature test macros since they can be known at
21+
compile time.
22+
23+
(3) can be detected using `__chkfeat(_CHKFEAT_GCS)` which is
24+
available without GCS support.
25+
26+
## Intrinsics
27+
28+
Alternative designs for the support levels at which the intrinsics
29+
are well defined:
30+
31+
(A) require (3),
32+
33+
(B) require (1) and (2) but not (3),
34+
35+
(C) require (2) only.
36+
37+
Simplest is (A), but it does not allow asynchronously disabling GCS,
38+
for that at least (B) is needed since the intrinsics must do something
39+
reasonable if GCS is disabled. Asynchronous disable is e.g. needed to
40+
allow disabling GCS at dlopen time in a multi-threaded process when
41+
the loaded module is not GCS compatible.
42+
43+
(C) is similar to (B) but allows using the intrinsics even if GCS is
44+
guaranteed to be disabled. The intrinsics are expected to be used
45+
behind runtime check for (3) since they don't do anything useful
46+
otherwise and thus (1) and (2) are true when the intrinsics are used
47+
either way. With (B) it is possible to only expose the intrinsics
48+
at compile time if (1) is true which can be feature tested. With (C)
49+
there is no obvious feature test for the presence of the intrinsics.
50+
For this reason option (B) was chosen.

0 commit comments

Comments
 (0)