Make the PTI violation check to follow style of the SMAP check.

No functional changes.

Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Approved by:	re (rgrimes)
Differential revision:	https://reviews.freebsd.org/D17181
This commit is contained in:
Konstantin Belousov 2018-09-17 14:59:05 +00:00
parent c6851ad04c
commit 76ed0c542f

View File

@ -705,6 +705,17 @@ trap_is_smap(struct trapframe *frame)
PGEX_P && (frame->tf_rflags & PSL_AC) == 0);
}
static bool
trap_is_pti(struct trapframe *frame)
{
return (PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 &&
pg_nx != 0 && (frame->tf_err & (PGEX_P | PGEX_W |
PGEX_U | PGEX_I)) == (PGEX_P | PGEX_U | PGEX_I) &&
(curpcb->pcb_saved_ucr3 & ~CR3_PCID_MASK) ==
(PCPU_GET(curpmap)->pm_cr3 & ~CR3_PCID_MASK));
}
static int
trap_pfault(struct trapframe *frame, int usermode)
{
@ -806,11 +817,7 @@ trap_pfault(struct trapframe *frame, int usermode)
* If nx protection of the usermode portion of kernel page
* tables caused trap, panic.
*/
if (usermode && PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 &&
pg_nx != 0 && (frame->tf_err & (PGEX_P | PGEX_W |
PGEX_U | PGEX_I)) == (PGEX_P | PGEX_U | PGEX_I) &&
(curpcb->pcb_saved_ucr3 & ~CR3_PCID_MASK)==
(PCPU_GET(curpmap)->pm_cr3 & ~CR3_PCID_MASK))
if (usermode && trap_is_pti(frame))
panic("PTI: pid %d comm %s tf_err %#lx", p->p_pid,
p->p_comm, frame->tf_err);