remap_file_pages: check file mapping
Change-Id: Ibf145a20181938a9825214253337a423fcd53064 Refs: #1521
This commit is contained in:
committed by
Masamichi Takagi
parent
e6e66e0392
commit
b0bd1feefb
@@ -113,7 +113,7 @@ int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxp
|
||||
__FUNCTION__, fd, len, off, result.handle, result.maxprot);
|
||||
|
||||
obj->memobj.ops = &devobj_ops;
|
||||
obj->memobj.flags = MF_HAS_PAGER | MF_DEV_FILE;
|
||||
obj->memobj.flags = MF_HAS_PAGER | MF_REMAP_FILE_PAGES | MF_DEV_FILE;
|
||||
obj->memobj.size = len;
|
||||
ihk_atomic_set(&obj->memobj.refcnt, 1);
|
||||
obj->handle = result.handle;
|
||||
|
||||
@@ -236,6 +236,7 @@ int fileobj_create(int fd, struct memobj **objp, int *maxprotp, int flags,
|
||||
memset(newobj, 0, sizeof(*newobj));
|
||||
newobj->memobj.ops = &fileobj_ops;
|
||||
newobj->memobj.flags = MF_HAS_PAGER | MF_REG_FILE |
|
||||
MF_REMAP_FILE_PAGES |
|
||||
((flags & MAP_PRIVATE) ? MF_PRIVATE : 0);
|
||||
newobj->handle = result.handle;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ enum {
|
||||
MF_SHM = 0x40000,
|
||||
MF_HUGETLBFS = 0x100000,
|
||||
MF_PRIVATE = 0x200000, /* To prevent flush in clear_range_* */
|
||||
MF_REMAP_FILE_PAGES = 0x400000, /* remap_file_pages possible */
|
||||
};
|
||||
|
||||
#define MEMOBJ_READY 0
|
||||
@@ -181,4 +182,11 @@ static inline int is_freeable(struct memobj *memobj)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int is_callable_remap_file_pages(struct memobj *memobj)
|
||||
{
|
||||
if (!memobj || !(memobj->flags & MF_REMAP_FILE_PAGES))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* HEADER_MEMOBJ_H */
|
||||
|
||||
@@ -9213,7 +9213,7 @@ SYSCALL_DECLARE(remap_file_pages)
|
||||
if (!range || (start < range->start) || (range->end < end)
|
||||
|| (range->flag & VR_PRIVATE)
|
||||
|| (range->flag & (VR_REMOTE|VR_IO_NOCACHE|VR_RESERVED))
|
||||
|| !range->memobj) {
|
||||
|| !is_callable_remap_file_pages(range->memobj)) {
|
||||
ekprintf("sys_remap_file_pages(%#lx,%#lx,%#x,%#lx,%#x):"
|
||||
"invalid VMR:[%#lx-%#lx) %#lx %p\n",
|
||||
start0, size, prot, pgoff, flags,
|
||||
|
||||
Reference in New Issue
Block a user