Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177557475
D61530.1794715375.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D61530.1794715375.diff
View Options
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -104,7 +104,9 @@
/*
* Map the memory segment identified by 'segid' into the guest address space
- * at [gpa,gpa+len) with protection 'prot'.
+ * at [gpa,gpa+len) with protection 'prot'. If an identical mapping already
+ * exists at 'gpa', return 0 without creating another. If a different mapping
+ * starts at 'gpa', fail with EEXIST.
*/
int vm_mmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, int segid,
vm_ooffset_t segoff, size_t len, int prot);
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -291,8 +291,8 @@
vm_mmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, int segid, vm_ooffset_t off,
size_t len, int prot)
{
- struct vm_memmap memmap;
- int error, flags;
+ struct vm_memmap cur, memmap;
+ int error;
memmap.gpa = gpa;
memmap.segid = segid;
@@ -307,11 +307,15 @@
/*
* If this mapping already exists then don't create it again. This
* is the common case for SYSMEM mappings created by bhyveload(8).
+ * Any other mapping starting at the same address is an error.
*/
- error = vm_mmap_getnext(ctx, &gpa, &segid, &off, &len, &prot, &flags);
- if (error == 0 && gpa == memmap.gpa) {
- if (segid != memmap.segid || off != memmap.segoff ||
- prot != memmap.prot || flags != memmap.flags) {
+ cur.gpa = gpa;
+ error = vm_mmap_getnext(ctx, &cur.gpa, &cur.segid, &cur.segoff,
+ &cur.len, &cur.prot, &cur.flags);
+ if (error == 0 && cur.gpa == memmap.gpa) {
+ if (cur.segid != memmap.segid || cur.segoff != memmap.segoff ||
+ cur.len != memmap.len || cur.prot != memmap.prot ||
+ cur.flags != memmap.flags) {
errno = EEXIST;
return (-1);
} else {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 4:02 AM (10 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41737432
Default Alt Text
D61530.1794715375.diff (1 KB)
Attached To
Mode
D61530: libvmmapi: Compare mapping lengths in vm_mmap_memseg()
Attached
Detach File
Event Timeline