From: <gregkh@suse.de>
To: agh@cisco.com, gregkh@suse.de, hjk@linutronix.de,
linux-kernel@vger.kernel.org
Subject: patch uio-fix-mapping-of-logical-and-virtual-memory.patch added to gregkh-2.6 tree
Date: Wed, 01 Oct 2008 14:15:19 -0700 [thread overview]
Message-ID: <12228957191236@kroah.org> (raw)
In-Reply-To: <20080923230959.GB4066@local>
This is a note to let you know that I've just added the patch titled
Subject: UIO: Fix mapping of logical and virtual memory
to my gregkh-2.6 tree. Its filename is
uio-fix-mapping-of-logical-and-virtual-memory.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
>From hjk@linutronix.de Wed Oct 1 14:01:23 2008
From: Andrew Harvey <agh@cisco.com>
Date: Wed, 24 Sep 2008 01:10:02 +0200
Subject: UIO: Fix mapping of logical and virtual memory
To: LKML <linux-kernel@vger.kernel.org>
Cc: Greg KH <gregkh@suse.de>, "Andrew G. Harvey" <agh@cisco.com>
Message-ID: <20080923230959.GB4066@local>
Content-Disposition: inline
From: "Andrew G. Harvey" <agh@cisco.com>
mmap() doesn't work as expected for UIO_MEM_LOGICAL or UIO_MEM_VIRTUAL
mappings. The offset into the memory needs to be added, otherwise
uio_vma_fault always returns the first page only. Note that for UIO
userspace calls mmap() with offset = N * getpagesize() to access
mapping N. This must be compensated when calculating the offset. A
comment was added to explain this since it is not obvious.
Signed-off-by: Andrew G. Harvey <agh@cisco.com>
Signed-off-by: Hans J. Koch <hjk@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/uio/uio.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -490,15 +490,23 @@ static int uio_vma_fault(struct vm_area_
{
struct uio_device *idev = vma->vm_private_data;
struct page *page;
+ unsigned long offset;
int mi = uio_find_mem_index(vma);
if (mi < 0)
return VM_FAULT_SIGBUS;
+ /*
+ * We need to subtract mi because userspace uses offset = N*PAGE_SIZE
+ * to use mem[N].
+ */
+ offset = (vmf->pgoff - mi) << PAGE_SHIFT;
+
if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL)
- page = virt_to_page(idev->info->mem[mi].addr);
+ page = virt_to_page(idev->info->mem[mi].addr + offset);
else
- page = vmalloc_to_page((void*)idev->info->mem[mi].addr);
+ page = vmalloc_to_page((void *)idev->info->mem[mi].addr
+ + offset);
get_page(page);
vmf->page = page;
return 0;
Patches currently in gregkh-2.6 which might be from agh@cisco.com are
driver-core/uio-fix-mapping-of-logical-and-virtual-memory.patch
prev parent reply other threads:[~2008-10-01 21:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 23:10 [PATCH] UIO: Fix mapping of logical and virtual memory Hans J. Koch
2008-10-01 21:15 ` gregkh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12228957191236@kroah.org \
--to=gregkh@suse.de \
--cc=agh@cisco.com \
--cc=hjk@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome