Checking if alignment is enabled
(alignment-checking-enabled-p x86) → enabled
Source: Intel Manuals, Volume 3, Section 6.15, Exception and Interrupt Reference:
Description: Indicates that the processor detected an unaligned memory operand when alignment checking was enabled. Alignment checks are only carried out in data (or stack) accesses (not in code fetches or system segment accesses). An example of an alignment-check violation is a word stored at an odd byte address, or a doubleword stored at an address that is not an integer multiple of 4.
Note that the alignment check exception (#AC) is generated only for data types that must be aligned on word, doubleword, and quadword boundaries. A general-protection exception (#GP) is generated 128-bit data types that are not aligned on a 16-byte boundary.
To enable alignment checking, the following conditions must be true:
Alignment-check exceptions (#AC) are generated only when operating at privilege level 3 (user mode). Memory references that default to privilege level 0, such as segment descriptor loads, do not generate alignment-check exceptions, even when caused by a memory reference made from privilege level 3.
Function:
(defun alignment-checking-enabled-p (x86) (declare (xargs :stobjs (x86))) (declare (xargs :guard t)) (let ((__function__ 'alignment-checking-enabled-p)) (declare (ignorable __function__)) (b* ((cr0 (the (unsigned-byte 32) (n32 (ctri 0 x86)))) (am (cr0bits->am cr0)) (ac (flgi :ac x86)) (cpl (cpl x86))) (and (equal am 1) (equal ac 1) (equal cpl 3)))))
Theorem:
(defthm booleanp-of-alignment-checking-enabled-p (b* ((enabled (alignment-checking-enabled-p x86))) (booleanp enabled)) :rule-classes :type-prescription)
Theorem:
(defthm alignment-checking-enabled-p-and-xw (implies (and (not (equal fld :ctr)) (not (equal fld :seg-visible)) (not (equal fld :rflags))) (equal (alignment-checking-enabled-p (xw fld index val x86)) (alignment-checking-enabled-p x86))))
Theorem:
(defthm alignment-checking-enabled-p-and-xw-ctr (implies (case-split (or (not (equal (nfix index) *cr0*)) (and (equal (nfix index) *cr0*) (equal (cr0bits->am (loghead 32 val)) (cr0bits->am (xr :ctr *cr0* x86)))))) (equal (alignment-checking-enabled-p (xw :ctr index val x86)) (alignment-checking-enabled-p x86))))
Theorem:
(defthm alignment-checking-enabled-p-and-xw-rflags (implies (equal (rflagsbits->ac val) (rflagsbits->ac (xr :rflags nil x86))) (equal (alignment-checking-enabled-p (xw :rflags nil val x86)) (alignment-checking-enabled-p x86))))
Theorem:
(defthm alignment-checking-enabled-p-and-xw-seg-visible (implies (case-split (or (not (equal index 1)) (and (equal index 1) (equal (segment-selectorbits->rpl val) (segment-selectorbits->rpl (seg-visiblei 1 x86)))))) (equal (alignment-checking-enabled-p (xw :seg-visible index val x86)) (alignment-checking-enabled-p x86))))
Theorem:
(defthm alignment-checking-enabled-p-and-mv-nth-1-wb (equal (alignment-checking-enabled-p (mv-nth 1 (wb n addr w val x86))) (alignment-checking-enabled-p x86)))
Theorem:
(defthm alignment-checking-enabled-p-and-mv-nth-2-rb (equal (alignment-checking-enabled-p (mv-nth 2 (rb n addr r-x x86))) (alignment-checking-enabled-p x86)))
Theorem:
(defthm alignment-checking-enabled-p-and-mv-nth-2-las-to-pas (equal (alignment-checking-enabled-p (mv-nth 2 (las-to-pas n lin-addr r-w-x x86))) (alignment-checking-enabled-p x86)))