devobj: allow read only device file mappings (OFED 3.3 support)
This commit is contained in:
@ -1208,7 +1208,8 @@ struct pager_map_result {
|
||||
int8_t padding[4];
|
||||
};
|
||||
|
||||
static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off, uintptr_t result_rpa)
|
||||
static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
||||
uintptr_t result_rpa, int prot)
|
||||
{
|
||||
const ihk_device_t dev = ihk_os_to_dev(os);
|
||||
const off_t pgoff = off / PAGE_SIZE;
|
||||
@ -1239,7 +1240,7 @@ static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off, uintptr_t r
|
||||
if (file->f_mode & FMODE_READ) {
|
||||
maxprot |= PROT_READ;
|
||||
}
|
||||
if (file->f_mode & FMODE_WRITE) {
|
||||
if ((file->f_mode & FMODE_WRITE) && (prot ? (prot & PROT_WRITE) : 1)) {
|
||||
maxprot |= PROT_WRITE;
|
||||
}
|
||||
if (!(file->f_path.mnt->mnt_flags & MNT_NOEXEC)) {
|
||||
@ -1414,7 +1415,8 @@ static long pager_call(ihk_os_t os, struct syscall_request *req)
|
||||
break;
|
||||
|
||||
case PAGER_REQ_MAP:
|
||||
ret = pager_req_map(os, req->args[1], req->args[2], req->args[3], req->args[4]);
|
||||
ret = pager_req_map(os, req->args[1], req->args[2], req->args[3], req->args[4],
|
||||
req->args[5]);
|
||||
break;
|
||||
|
||||
case PAGER_REQ_PFN:
|
||||
|
||||
@ -78,7 +78,8 @@ static struct memobj *to_memobj(struct devobj *devobj)
|
||||
/***********************************************************************
|
||||
* devobj
|
||||
*/
|
||||
int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxprotp)
|
||||
int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxprotp,
|
||||
int prot)
|
||||
{
|
||||
ihk_mc_user_context_t ctx;
|
||||
struct pager_map_result result; // XXX: assumes contiguous physical
|
||||
@ -115,6 +116,7 @@ int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxp
|
||||
ihk_mc_syscall_arg2(&ctx) = len;
|
||||
ihk_mc_syscall_arg3(&ctx) = off;
|
||||
ihk_mc_syscall_arg4(&ctx) = virt_to_phys(&result);
|
||||
ihk_mc_syscall_arg5(&ctx) = prot;
|
||||
|
||||
error = syscall_generic_forwarding(__NR_mmap, &ctx);
|
||||
if (error) {
|
||||
|
||||
@ -141,6 +141,7 @@ int fileobj_create(int fd, struct memobj **objp, int *maxprotp);
|
||||
struct shmid_ds;
|
||||
int shmobj_create(struct shmid_ds *ds, struct memobj **objp);
|
||||
int zeroobj_create(struct memobj **objp);
|
||||
int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxprotp);
|
||||
int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxprotp,
|
||||
int prot);
|
||||
|
||||
#endif /* HEADER_MEMOBJ_H */
|
||||
|
||||
@ -1108,7 +1108,7 @@ do_mmap(const intptr_t addr0, const size_t len0, const int prot,
|
||||
vrflags &= ~VR_MEMTYPE_MASK;
|
||||
vrflags |= VR_MEMTYPE_UC;
|
||||
}
|
||||
error = devobj_create(fd, len, off, &memobj, &maxprot);
|
||||
error = devobj_create(fd, len, off, &memobj, &maxprot, prot);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("do_mmap:fileobj_create failed. %d\n", error);
|
||||
|
||||
Reference in New Issue
Block a user