| 637 | } |
| 638 | |
| 639 | static bool |
| 640 | trap_is_smap(struct trapframe *frame) |
| 641 | { |
| 642 | |
| 643 | /* |
| 644 | * A page fault on a userspace address is classified as |
| 645 | * SMAP-induced if: |
| 646 | * - SMAP is supported; |
| 647 | * - kernel mode accessed present data page; |
| 648 | * - rflags.AC was cleared. |
| 649 | * Kernel must never access user space with rflags.AC cleared |
| 650 | * if SMAP is enabled. |
| 651 | */ |
| 652 | return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 && |
| 653 | (frame->tf_err & (PGEX_P | PGEX_U | PGEX_I | PGEX_RSV)) == |
| 654 | PGEX_P && (frame->tf_rflags & PSL_AC) == 0); |
| 655 | } |
| 656 | |
| 657 | static bool |
| 658 | trap_is_pti(struct trapframe *frame) |