Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154769187
D56518.id175892.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D56518.id175892.diff
View Options
diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h
--- a/sys/sys/malloc.h
+++ b/sys/sys/malloc.h
@@ -61,6 +61,7 @@
#define M_EXEC 0x4000 /* allocate executable space */
#define M_NEXTFIT 0x8000 /* only for vmem, follow cursor */
#define M_NEVERFREED 0x10000 /* chunk will never get freed */
+#define M_UNPROTECTED 0x20000 /* alloc out of unprotected memory */
#define M_VERSION 2024073001
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -409,6 +409,7 @@
#define PG_MARKER 0x08 /* special queue marker page */
#define PG_NODUMP 0x10 /* don't include this page in a dump */
#define PG_NOFREE 0x20 /* page should never be freed. */
+#define PG_UNPROTECTED 0x40 /* page is in unprotected memory */
/*
* Misc constants.
@@ -487,7 +488,7 @@
#define VM_ALLOC_INTERRUPT 1
#define VM_ALLOC_SYSTEM 2
#define VM_ALLOC_CLASS_MASK 3
-#define VM_ALLOC_AVAIL0 0x0004
+#define VM_ALLOC_UNPROTECTED 0x0004
#define VM_ALLOC_WAITOK 0x0008 /* (gnp) Sleep and retry */
#define VM_ALLOC_WAITFAIL 0x0010 /* (acgnp) Sleep and return error */
#define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */
@@ -533,6 +534,8 @@
pflags |= VM_ALLOC_NORECLAIM;
if ((malloc_flags & M_NEVERFREED))
pflags |= VM_ALLOC_NOFREE;
+ if ((malloc_flags & M_UNPROTECTED) != 0)
+ pflags |= VM_ALLOC_UNPROTECTED;
return (pflags);
}
#endif
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2102,7 +2102,7 @@
VM_ALLOC_WIRED | VM_ALLOC_ZERO)
#define VPA_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
VM_ALLOC_NOBUSY | VM_ALLOC_NOFREE | \
- VM_ALLOC_SBUSY)
+ VM_ALLOC_SBUSY | VM_ALLOC_UNPROTECTED)
KASSERT((req & ~VPA_FLAGS) == 0,
("invalid request %#x", req));
KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) !=
@@ -2181,6 +2181,8 @@
flags |= PG_NODUMP;
if ((req & VM_ALLOC_NOFREE) != 0)
flags |= PG_NOFREE;
+ if ((req & VM_ALLOC_UNPROTECTED) != 0)
+ flags |= PG_UNPROTECTED;
m->flags = flags;
m->a.flags = 0;
m->oflags = (object->flags & OBJ_UNMANAGED) != 0 ? VPO_UNMANAGED : 0;
@@ -2345,7 +2347,7 @@
#define VPAC_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
VM_ALLOC_NOBUSY | VM_ALLOC_NORECLAIM | \
- VM_ALLOC_SBUSY)
+ VM_ALLOC_SBUSY | VM_ALLOC_UNPROTECTED)
KASSERT((req & ~VPAC_FLAGS) == 0,
("invalid request %#x", req));
KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) !=
@@ -2383,6 +2385,8 @@
flags = PG_ZERO;
if ((req & VM_ALLOC_NODUMP) != 0)
flags |= PG_NODUMP;
+ if ((req & VM_ALLOC_UNPROTECTED) != 0)
+ flags |= PG_UNPROTECTED;
oflags = (object->flags & OBJ_UNMANAGED) != 0 ? VPO_UNMANAGED : 0;
if ((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) == 0)
busy_lock = VPB_CURTHREAD_EXCLUSIVE;
@@ -2400,6 +2404,8 @@
vm_page_alloc_check(m);
m->a.flags = 0;
m->flags = (m->flags | PG_NODUMP) & flags;
+ if (flags & PG_UNPROTECTED)
+ m->flags |= PG_UNPROTECTED;
m->busy_lock = busy_lock;
if ((req & VM_ALLOC_WIRED) != 0)
m->ref_count = 1;
@@ -2447,12 +2453,14 @@
int flags;
#define VPAN_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
- VM_ALLOC_NOFREE | VM_ALLOC_WAITOK)
+ VM_ALLOC_NOFREE | VM_ALLOC_WAITOK | \
+ VM_ALLOC_UNPROTECTED)
KASSERT((req & ~VPAN_FLAGS) == 0,
("invalid request %#x", req));
flags = ((req & VM_ALLOC_NODUMP) != 0 ? PG_NODUMP : 0) |
- ((req & VM_ALLOC_NOFREE) != 0 ? PG_NOFREE : 0);
+ ((req & VM_ALLOC_NOFREE) != 0 ? PG_NOFREE : 0) |
+ ((req & VM_ALLOC_UNPROTECTED) != 0 ? PG_UNPROTECTED : 0);
vmd = VM_DOMAIN(domain);
again:
if (__predict_false((req & VM_ALLOC_NOFREE) != 0)) {
@@ -4123,6 +4131,8 @@
if (m->ref_count != 0)
panic("vm_page_free_prep: page %p has references", m);
+ m->flags &= ~PG_UNPROTECTED;
+
/*
* Restore the default memory attribute to the page.
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 30, 10:05 AM (6 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32493573
Default Alt Text
D56518.id175892.diff (3 KB)
Attached To
Mode
D56518: vm: Add flags for unprotected allocations
Attached
Detach File
Event Timeline
Log In to Comment