PAL-Enforced CPU Usage Constraints #82
JaredWright
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The goal of this discussion is to brainstorm if/how PAL could be used to encapsulate logical constraints surrounding the usage of CPU instruction and registers, and enforce them at runtime or compile time.
Background Context
CPU instructions and registers often have logical constraints (or documented suggestions) that relate to their usage in a given execution environment. For example, the Intel x86_64 architecture contains the SGX processor extension which comprises system registers (MSRs, CPUID leaves) and instructions (e.g. ENCLS). Intel's documentation for SGX (Volume 3, Chapter 37.7) describes considerations for how to properly enable SGX:
The above presents two logical preconditions that must be satisfied before an SGX instruction can be executed:
It might be interesting if PAL could enforce this constraint in some program (e.g. Rust code within a BIOS) like the following:
What could this be used for?
Challenges
For something like this to happen, there are a few challenges to overcome:
1) Expressing CPU constraints and semantics
PAL would need something to express constraints in both a human-friendly and machine-friendly format. It would need to be complete enough to describe both logical and temporal relationships between components within a CPU. Perhaps a language like Gherkin would be feasible? For example, you could write a constraint like this:
2) Add pre and post instruction callback points to PAL generated code
Code generators for PAL's language-specific APIs would need to be extended with a mechanism to register callback points before and after an instruction gets executed. For example, PAL would need to generate all of the functions in the following pseudo-Rust-code's
main()routine:3) A way to bridge (1) and (2) together
For example, could PAL (or something else?) look at constraints expressed in (1), and then generate a program (2) that sets up PAL to enforce those constraints?
Beta Was this translation helpful? Give feedback.
All reactions