mcctrl: Switch Linux functions/structures according to the version
For get_user_pages_remote in binfmt_mcexec.c:
In 4.10 with 5b56d49fc31d ("mm: add locked parameter to
get_user_pages_remote()")
In 4.9 with 9beae1ea8930 ("mm: replace get_user_pages_remote()
write/force parameters with gup_flags")
For vmf in syscall.c, these two patches in 4.10:
82b0f8c39a38 ("mm: join struct fault_env and vm_fault")
1a29d85eb0f1 ("mm: use vmf->address instead of
vmf->virtual_address")
Fujitsu: POSTK_DEBUG_ARCH_DEP_41
Change-Id: I89a02d03169a2162ea186da1804bf48910446d11
This commit is contained in:
committed by
Masamichi Takagi
parent
a269d96978
commit
8c33c92720
@ -125,7 +125,6 @@ static int load_elf(struct linux_binprm *bprm
|
||||
for(i = 0, st = 0; mode != 2;){
|
||||
if(st == 0){
|
||||
off = p & ~PAGE_MASK;
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
rc = get_user_pages_remote(current, bprm->mm,
|
||||
bprm->p, 1, FOLL_FORCE, &page, NULL, NULL);
|
||||
@ -141,17 +140,6 @@ static int load_elf(struct linux_binprm *bprm
|
||||
bprm->p, 1, 0, 1,
|
||||
&page, NULL);
|
||||
#endif
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
|
||||
rc = get_user_pages_remote(current, bprm->mm,
|
||||
bprm->p, 1, 0, 1,
|
||||
&page, NULL);
|
||||
#else
|
||||
rc = get_user_pages(current, bprm->mm,
|
||||
bprm->p, 1, 0, 1,
|
||||
&page, NULL);
|
||||
#endif
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
if(rc <= 0) {
|
||||
kfree(pbuf);
|
||||
return -EFAULT;
|
||||
|
||||
@ -803,7 +803,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
struct ikc_scd_packet *packet;
|
||||
int ret = 0;
|
||||
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
dprintk("mcctrl:page fault:flags %#x pgoff %#lx va %#lx page %p\n",
|
||||
vmf->flags, vmf->pgoff, vmf->address, vmf->page);
|
||||
@ -811,10 +810,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
dprintk("mcctrl:page fault:flags %#x pgoff %#lx va %p page %p\n",
|
||||
vmf->flags, vmf->pgoff, vmf->virtual_address, vmf->page);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
dprintk("mcctrl:page fault:flags %#x pgoff %#lx va %p page %p\n",
|
||||
vmf->flags, vmf->pgoff, vmf->virtual_address, vmf->page);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
|
||||
/* Look up per-process structure */
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, task_tgid_vnr(current));
|
||||
@ -847,7 +842,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
}
|
||||
|
||||
for (try = 1; ; ++try) {
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
error = translate_rva_to_rpa(usrdata->os, ppd->rpgtable,
|
||||
vmf->address, &rpa, &pgsize);
|
||||
@ -856,15 +850,9 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
(unsigned long)vmf->virtual_address,
|
||||
&rpa, &pgsize);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
error = translate_rva_to_rpa(usrdata->os, ppd->rpgtable,
|
||||
(unsigned long)vmf->virtual_address,
|
||||
&rpa, &pgsize);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
#define NTRIES 2
|
||||
if (!error || (try >= NTRIES)) {
|
||||
if (error) {
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
printk("%s: error translating 0x%#lx "
|
||||
"(req: TID: %u, syscall: %lu)\n",
|
||||
@ -876,12 +864,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
__FUNCTION__, vmf->virtual_address,
|
||||
packet->req.rtid, packet->req.number);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
printk("%s: error translating 0x%p "
|
||||
"(req: TID: %u, syscall: %lu)\n",
|
||||
__FUNCTION__, vmf->virtual_address,
|
||||
packet->req.rtid, packet->req.number);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
}
|
||||
|
||||
break;
|
||||
@ -892,17 +874,12 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
#define PF_WRITE 0x02
|
||||
reason |= PF_WRITE;
|
||||
}
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
error = remote_page_fault(usrdata, (void *)vmf->address, reason);
|
||||
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
error = remote_page_fault(usrdata, vmf->virtual_address, reason);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
error = remote_page_fault(usrdata, vmf->virtual_address, reason);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
if (error) {
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
printk("%s: error forwarding PF for 0x%#lx "
|
||||
"(req: TID: %d, syscall: %lu)\n",
|
||||
@ -914,12 +891,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
__FUNCTION__, vmf->virtual_address,
|
||||
packet->req.rtid, packet->req.number);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
printk("%s: error forwarding PF for 0x%p "
|
||||
"(req: TID: %d, syscall: %lu)\n",
|
||||
__FUNCTION__, vmf->virtual_address,
|
||||
packet->req.rtid, packet->req.number);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -928,15 +899,11 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
goto put_and_out;
|
||||
}
|
||||
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
rva = vmf->address & ~(pgsize - 1);
|
||||
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
rva = (unsigned long)vmf->virtual_address & ~(pgsize - 1);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
rva = (unsigned long)vmf->virtual_address & ~(pgsize - 1);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
rpa = rpa & ~(pgsize - 1);
|
||||
|
||||
phys = ihk_device_map_memory(dev, rpa, pgsize);
|
||||
@ -956,7 +923,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
|
||||
error = vm_insert_page(vma, rva+(pix*PAGE_SIZE), page);
|
||||
if (error) {
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
printk("%s: error inserting mapping for 0x%#lx "
|
||||
"(req: TID: %d, syscall: %lu) error: %d, "
|
||||
@ -972,14 +938,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
packet->req.rtid, packet->req.number, error,
|
||||
vma->vm_start, vma->vm_end);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
printk("%s: error inserting mapping for 0x%p "
|
||||
"(req: TID: %d, syscall: %lu) error: %d, "
|
||||
"vm_start: 0x%lx, vm_end: 0x%lx\n",
|
||||
__FUNCTION__, vmf->virtual_address,
|
||||
packet->req.rtid, packet->req.number, error,
|
||||
vma->vm_start, vma->vm_end);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1002,7 +960,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
#endif
|
||||
ihk_device_unmap_memory(dev, phys, pgsize);
|
||||
if (error) {
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* HOST-Linux version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
||||
printk("%s: remote PF failed for 0x%#lx, pgoff: %lu "
|
||||
"(req: TID: %d, syscall: %lu)\n",
|
||||
@ -1014,12 +971,6 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
__FUNCTION__, vmf->virtual_address, vmf->pgoff,
|
||||
packet->req.rtid, packet->req.number);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) */
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
printk("%s: remote PF failed for 0x%p, pgoff: %lu "
|
||||
"(req: TID: %d, syscall: %lu)\n",
|
||||
__FUNCTION__, vmf->virtual_address, vmf->pgoff,
|
||||
packet->req.rtid, packet->req.number);
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
ret = VM_FAULT_SIGBUS;
|
||||
goto put_and_out;
|
||||
}
|
||||
@ -2228,15 +2179,7 @@ static int writecore(ihk_os_t os, unsigned long rcoretable, int chunks) {
|
||||
#else /* POSTK_DEBUG_TEMP_FIX_59 */
|
||||
file = filp_open("core", O_CREAT | O_RDWR | O_LARGEFILE, 0600);
|
||||
#endif /* POSTK_DEBUG_TEMP_FIX_59 */
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_41 /* use writehandler version switch add */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
|
||||
if (IS_ERR(file) || !file->f_op) {
|
||||
#else
|
||||
if (IS_ERR(file) || !file->f_op || !file->f_op->write) {
|
||||
#endif
|
||||
#else /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
if (IS_ERR(file) || !file->f_op || !file->f_op->write) {
|
||||
#endif /* POSTK_DEBUG_ARCH_DEP_41 */
|
||||
dprintk("cannot open core file\n");
|
||||
error = PTR_ERR(file);
|
||||
goto fail;
|
||||
|
||||
Reference in New Issue
Block a user