Skip to content

Commit 7294151

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
uio: provide vm access to UIO_MEM_PHYS maps
This makes it possible to let gdb access mappings of the process that is being debugged. uio_mmap_logical was moved and uio_vm_ops renamed to group related code and differentiate to new stuff. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5a73633 commit 7294151

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

‎drivers/uio/uio.c‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -630,19 +630,35 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
630630
return 0;
631631
}
632632

633-
static const struct vm_operations_struct uio_vm_ops = {
633+
static const struct vm_operations_struct uio_logical_vm_ops = {
634634
.open = uio_vma_open,
635635
.close = uio_vma_close,
636636
.fault = uio_vma_fault,
637637
};
638638

639+
static int uio_mmap_logical(struct vm_area_struct *vma)
640+
{
641+
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
642+
vma->vm_ops = &uio_logical_vm_ops;
643+
uio_vma_open(vma);
644+
return 0;
645+
}
646+
647+
static const struct vm_operations_struct uio_physical_vm_ops = {
648+
#ifdef CONFIG_HAVE_IOREMAP_PROT
649+
.access = generic_access_phys,
650+
#endif
651+
};
652+
639653
static int uio_mmap_physical(struct vm_area_struct *vma)
640654
{
641655
struct uio_device *idev = vma->vm_private_data;
642656
int mi = uio_find_mem_index(vma);
643657
if (mi < 0)
644658
return -EINVAL;
645659

660+
vma->vm_ops = &uio_physical_vm_ops;
661+
646662
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
647663

648664
return remap_pfn_range(vma,
@@ -652,14 +668,6 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
652668
vma->vm_page_prot);
653669
}
654670

655-
static int uio_mmap_logical(struct vm_area_struct *vma)
656-
{
657-
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
658-
vma->vm_ops = &uio_vm_ops;
659-
uio_vma_open(vma);
660-
return 0;
661-
}
662-
663671
static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
664672
{
665673
struct uio_listener *listener = filep->private_data;

0 commit comments

Comments
 (0)