aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/uma.h
diff options
context:
space:
mode:
authorJonathan T. Looney <jtl@FreeBSD.org>2018-06-13 17:04:41 +0000
committerJonathan T. Looney <jtl@FreeBSD.org>2018-06-13 17:04:41 +0000
commit0766f278d88b93e81e8b81cac6258cf75cde3e35 (patch)
treef8f2ae136eac014f148148596c13d4ec4bcd75f8 /sys/vm/uma.h
parentb13a70d5a4979997a0dbc0795d27bb7e22ec794b (diff)
downloadsrc-0766f278d88b93e81e8b81cac6258cf75cde3e35.tar.gz
src-0766f278d88b93e81e8b81cac6258cf75cde3e35.zip
Make UMA and malloc(9) return non-executable memory in most cases.
Most kernel memory that is allocated after boot does not need to be executable. There are a few exceptions. For example, kernel modules do need executable memory, but they don't use UMA or malloc(9). The BPF JIT compiler also needs executable memory and did use malloc(9) until r317072. (Note that a side effect of r316767 was that the "small allocation" path in UMA on amd64 already returned non-executable memory. This meant that some calls to malloc(9) or the UMA zone(9) allocator could return executable memory, while others could return non-executable memory. This change makes the behavior consistent.) This change makes malloc(9) return non-executable memory unless the new M_EXEC flag is specified. After this change, the UMA zone(9) allocator will always return non-executable memory, and a KASSERT will catch attempts to use the M_EXEC flag to allocate executable memory using uma_zalloc() or its variants. Allocations that do need executable memory have various choices. They may use the M_EXEC flag to malloc(9), or they may use a different VM interfact to obtain executable pages. Now that malloc(9) again allows executable allocations, this change also reverts most of r317072. PR: 228927 Reviewed by: alc, kib, markj, jhb (previous version) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D15691
Notes
Notes: svn path=/head/; revision=335068
Diffstat (limited to 'sys/vm/uma.h')
-rw-r--r--sys/vm/uma.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 9fe51e515f4a..ed33ae030728 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -617,11 +617,12 @@ void uma_zone_set_freef(uma_zone_t zone, uma_free freef);
* These flags are setable in the allocf and visible in the freef.
*/
#define UMA_SLAB_BOOT 0x01 /* Slab alloced from boot pages */
+#define UMA_SLAB_KRWX 0x02 /* Slab alloced from kernel_rwx_arena */
#define UMA_SLAB_KERNEL 0x04 /* Slab alloced from kernel_map */
#define UMA_SLAB_PRIV 0x08 /* Slab alloced from priv allocator */
#define UMA_SLAB_OFFP 0x10 /* Slab is managed separately */
#define UMA_SLAB_MALLOC 0x20 /* Slab is a large malloc slab */
-/* 0x02, 0x40 and 0x80 are available */
+/* 0x40 and 0x80 are available */
/*
* Used to pre-fill a zone with some number of items