CakeML looks interesting. I will definitely take a look when I have time.
As a side note, I find the general problem of testing a specification quite an interesting problem. Even with formal proofs there is the problem of proving something as true based on an erroneous assumption; in addition to the problem of human introduced transcription errors.
The comment earlier about dual compilers could also be applied to ISA interpreters. Spike and QEMU come to mind.
One considers the problem of a minimal JIT compiler for an ISA that is able to JIT itself from the ISA specification. This clearly emerges from a language that can describe the logic of the ISA in its most minimal form (we bootstrap from a shared language and notation).
My pragmatism (and following the lead set by riscv-opcodes) led me to remove almost all syntax altogether so we are only left with pure notation. This opens the door to expression in new languages that one can also use to derive the specification. English (or any other spoken language for that matter) seems to be boilerplate for the mind.
The security problem emerges from the semantic gap problem in that one has ambiguities in proving a barrier between privilege levels (*1). This extends beyond the ISA and the language of the system into the operating system kernel itself.
Randomisation (ASLR and the like) are merely shortcuts taken because the core security proof for the OS is missing. This leads my mind towards L4 in a ML with a JIT and a specification produced form the ML.
L4 for RISC-V in a ML might be an M5. There needs to be a tiny micro kernel that can turn declaration into execution (and we omit the complexity of synthesis into gate level logic). ~500 lines is quite an achievement (Z-Scale); only now we have an HDL and the need for symmetry with its notation.
http://ssrg.nicta.com.au/projects/TS/l4.verified/
The final point is really that one needs three implementations to prove one wrong (only to be left still suffering from the Byzantine general problem). Two only ensures dual consistency. Five is required to reduce the probability of one Byzantine general having less than 100% interest in maliciously crafted errors.
Seems we have diverged into full stack verification (ISA, compiler and OS) with 5 implementations of each.
UNIX, C and all of the associated security issues (buffer overflow, use-after free, double-free etc) emerged from an abstraction above PDP-11/20.
Is making a register distinguish between an address and a scalar a needless complexity? It seems one can only logically add a multiplied or divided displacement to an address to form another valid address (within some bounds). You can't shift an address but you can shift a scalar that you add to an address as a displacement. It never makes sense to add two addresses yet CPUs will do this happily. Would a secure processor ever make these kinds of distinctions at the register level? and fault if they saw an illegal operation (NaA - Not an Address symmetry with NaN). It seems there may be an 'address bit' which is orthogonal to a 'sign bit' for a scalar (this reminds me of the SORNs paper posted by Sam *2). The fatal flaw in current CPU designs that leads to vulnerabilities and errors is this lack of faults on operations that are legal for scalars but illegal for addresses (reflecting on history to prevent repeating its mistakes)
[1] "Best to keep it short"
[2]
http://www.johngustafson.net/presentations/Multicore2016-JLG.pdf
~mc
Sent from my iPhone