A variant of init-x86-state that ensures 64-bit mode.
(init-x86-state-64 status start-addr gprs ctrs msrs seg-visibles seg-hidden-bases seg-hidden-limits seg-hidden-attrs flags mem x86) → (mv flg x86)
After calling init-x86-state,
this function updates
The resulting state does not necessarily satisfy expected invariants for 64-bit mode, but that is also the case with init-x86-state.
In alternative, one can use just init-x86-state with appropriate model-specific and hidden segment register alists. But we find this function convenient for now.
Function:
(defun init-x86-state-64 (status start-addr gprs ctrs msrs seg-visibles seg-hidden-bases seg-hidden-limits seg-hidden-attrs flags mem x86) (declare (xargs :stobjs (x86))) (declare (xargs :guard (and (canonical-address-p start-addr) (rgfi-alistp gprs) (ctri-alistp ctrs) (msri-alistp msrs) (seg-visiblei-alistp seg-visibles) (seg-hidden-basei-alistp seg-hidden-bases) (seg-hidden-limiti-alistp seg-hidden-limits) (seg-hidden-attri-alistp seg-hidden-attrs) (n64p flags) (n64p-byte-alistp mem)))) (let ((__function__ 'init-x86-state-64)) (declare (ignorable __function__)) (b* (((mv flg x86) (init-x86-state status start-addr gprs ctrs msrs seg-visibles seg-hidden-bases seg-hidden-limits seg-hidden-attrs flags mem x86)) ((when flg) (mv t x86)) (ia32_efer (n12 (msri 0 x86))) (ia32_efer (!ia32_eferbits->lma 1 ia32_efer)) (x86 (!msri 0 (n64 ia32_efer) x86)) ((the (unsigned-byte 16) cs-attr) (seg-hidden-attri 1 x86)) (cs-attr (!code-segment-descriptor-attributesbits->l 1 cs-attr)) (x86 (!seg-hidden-attri 1 cs-attr x86))) (mv nil x86))))
Theorem:
(defthm x86p-of-init-x86-state-64.x86 (implies (and (x86p x86) (canonical-address-p$inline start-addr) (rgfi-alistp gprs) (ctri-alistp ctrs) (msri-alistp msrs) (seg-visiblei-alistp seg-visibles) (seg-hidden-basei-alistp seg-hidden-bases) (seg-hidden-limiti-alistp seg-hidden-limits) (seg-hidden-attri-alistp seg-hidden-attrs) (n64p$inline flags) (n64p-byte-alistp mem)) (b* (((mv ?flg ?x86) (init-x86-state-64 status start-addr gprs ctrs msrs seg-visibles seg-hidden-bases seg-hidden-limits seg-hidden-attrs flags mem x86))) (x86p x86))) :rule-classes :rewrite)
Theorem:
(defthm 64-bit-modep-of-init-x86-state-64 (b* (((mv flg x86-new) (init-x86-state-64 status start-addr gprs ctrs msrs seg-visibles seg-hidden-bases seg-hidden-limits seg-hidden-attrs flags mem x86))) (implies (not flg) (64-bit-modep x86-new))))