aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2018-02-14 23:35:47 +0000
committerConrad Meyer <cem@FreeBSD.org>2018-02-14 23:35:47 +0000
commit5bd0149714c1ee467cda3558bf318aca0bb86898 (patch)
treef184a25cdeb9ef05b99230f15b39f1e11fa95998 /sys/i386
parent8be8c75688e6b1941f4a9bbca512e5e4f4b877aa (diff)
downloadsrc-5bd0149714c1ee467cda3558bf318aca0bb86898.tar.gz
src-5bd0149714c1ee467cda3558bf318aca0bb86898.zip
x86 pmap: Make memory mapped via pmap_qenter() non-executable
The idea is, the pmap_qenter() API is now defined to not produce executable mappings. If you need executable mappings, use another API. Add pg_nx flag in pmap_qenter on x86 to make kernel pages non-executable. Other architectures that support execute-specific permissons on page table entries should subsequently be updated to match. Submitted by: Darrick Lew <darrick.freebsd AT gmail.com> Reviewed by: markj Discussed with: alc, jhb, kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14062
Notes
Notes: svn path=/head/; revision=329281
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/pmap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 092c2f9909cc..c0895cabcc2e 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -1677,7 +1677,11 @@ pmap_qenter(vm_offset_t sva, vm_page_t *ma, int count)
pa = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(m->md.pat_mode, 0);
if ((*pte & (PG_FRAME | PG_PTE_CACHE)) != pa) {
oldpte |= *pte;
+#if defined(PAE) || defined(PAE_TABLES)
+ pte_store(pte, pa | pgeflag | pg_nx | PG_RW | PG_V);
+#else
pte_store(pte, pa | pgeflag | PG_RW | PG_V);
+#endif
}
pte++;
}