Skip to content

Commit

Permalink
amd64 pmap_allocpte_nosleep(): stop testing tautological condition
Browse files Browse the repository at this point in the history
Enabled PTI for given pmap is equivalent to pm_ucr3 being valid is
equivalent to root userspace page table page pm_pmltopu being
allocated.

Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45966
  • Loading branch information
kostikbel committed Jul 14, 2024
1 parent 616dd88 commit 10a6ae0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sys/amd64/amd64/pmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4707,8 +4707,8 @@ pmap_allocpte_nosleep(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp,
*pml5 = VM_PAGE_TO_PHYS(m) | PG_U | PG_RW | PG_V | PG_A | PG_M;

if (pmap->pm_pmltopu != NULL && pml5index < NUPML5E) {
if (pmap->pm_ucr3 != PMAP_NO_CR3)
*pml5 |= pg_nx;
MPASS(pmap->pm_ucr3 != PMAP_NO_CR3);
*pml5 |= pg_nx;

pml5u = &pmap->pm_pmltopu[pml5index];
*pml5u = VM_PAGE_TO_PHYS(m) | PG_U | PG_RW | PG_V |
Expand All @@ -4728,15 +4728,16 @@ pmap_allocpte_nosleep(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp,

if (!pmap_is_la57(pmap) && pmap->pm_pmltopu != NULL &&
pml4index < NUPML4E) {
MPASS(pmap->pm_ucr3 != PMAP_NO_CR3);

/*
* PTI: Make all user-space mappings in the
* kernel-mode page table no-execute so that
* we detect any programming errors that leave
* the kernel-mode page table active on return
* to user space.
*/
if (pmap->pm_ucr3 != PMAP_NO_CR3)
*pml4 |= pg_nx;
*pml4 |= pg_nx;

pml4u = &pmap->pm_pmltopu[pml4index];
*pml4u = VM_PAGE_TO_PHYS(m) | PG_U | PG_RW | PG_V |
Expand Down

0 comments on commit 10a6ae0

Please sign in to comment.