Page MenuHomeFreeBSD

D61530.1794715395.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61530.1794715395.diff

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

Mime Type
text/plain
Expires
Sun, Nov 15, 4:03 AM (4 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41737432
Default Alt Text
D61530.1794715395.diff (1 KB)

Event Timeline