Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.c
Show First 20 Lines • Show All 383 Lines • ▼ Show 20 Lines | vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms) | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
/* | /* | ||||
* Stake out a contiguous region covering the guest physical memory | * Stake out a contiguous region covering the guest physical memory | ||||
* and the adjoining guard regions. | * and the adjoining guard regions. | ||||
*/ | */ | ||||
len = VM_MMAP_GUARD_SIZE + objsize + VM_MMAP_GUARD_SIZE; | len = VM_MMAP_GUARD_SIZE + objsize + VM_MMAP_GUARD_SIZE; | ||||
ptr = mmap(NULL, len, PROT_NONE, MAP_GUARD | MAP_ALIGNED_SUPER, -1, 0); | ptr = mmap(NULL, len, PROT_NONE | PROT_MAX(PROT_RW), | ||||
MAP_GUARD | MAP_ALIGNED_SUPER, -1, 0); | |||||
if (ptr == MAP_FAILED) | if (ptr == MAP_FAILED) | ||||
return (-1); | return (-1); | ||||
baseaddr = ptr + VM_MMAP_GUARD_SIZE; | baseaddr = ptr + VM_MMAP_GUARD_SIZE; | ||||
if (ctx->highmem > 0) { | if (ctx->highmem > 0) { | ||||
gpa = 4*GB; | gpa = 4*GB; | ||||
len = ctx->highmem; | len = ctx->highmem; | ||||
error = setup_memory_segment(ctx, gpa, len, baseaddr); | error = setup_memory_segment(ctx, gpa, len, baseaddr); | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | vm_create_devmem(struct vmctx *ctx, int segid, const char *name, size_t len) | ||||
if (fd < 0) | if (fd < 0) | ||||
goto done; | goto done; | ||||
/* | /* | ||||
* Stake out a contiguous region covering the device memory and the | * Stake out a contiguous region covering the device memory and the | ||||
* adjoining guard regions. | * adjoining guard regions. | ||||
*/ | */ | ||||
len2 = VM_MMAP_GUARD_SIZE + len + VM_MMAP_GUARD_SIZE; | len2 = VM_MMAP_GUARD_SIZE + len + VM_MMAP_GUARD_SIZE; | ||||
base = mmap(NULL, len2, PROT_NONE, MAP_GUARD | MAP_ALIGNED_SUPER, -1, | base = mmap(NULL, len2, PROT_NONE | PROT_MAX(PROT_RW), | ||||
0); | MAP_GUARD | MAP_ALIGNED_SUPER, -1, 0); | ||||
kib: And these mappings are also MAP_GUARDs. | |||||
if (base == MAP_FAILED) | if (base == MAP_FAILED) | ||||
goto done; | goto done; | ||||
flags = MAP_SHARED | MAP_FIXED; | flags = MAP_SHARED | MAP_FIXED; | ||||
if ((ctx->memflags & VM_MEM_F_INCORE) == 0) | if ((ctx->memflags & VM_MEM_F_INCORE) == 0) | ||||
flags |= MAP_NOCORE; | flags |= MAP_NOCORE; | ||||
/* mmap the devmem region in the host address space */ | /* mmap the devmem region in the host address space */ | ||||
▲ Show 20 Lines • Show All 1,078 Lines • Show Last 20 Lines |
And these mappings are also MAP_GUARDs.