From: kernel@jbeekman.nl (Jethro Beekman)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Mapping IO memory read-write
Date: Tue, 12 Jan 2016 15:10:23 -0800 [thread overview]
Message-ID: <569587DF.7020804@jbeekman.nl> (raw)
I'm writing a device driver for a memory-mapped device on x86-64. I'm mapping
the device in the kernel using ioremap_cache(). My file_operations.mmap function
is as follows:
static int dev_mmap(struct file *filep, struct vm_area_struct *vma) {
vma->vm_page_prot.pgprot|=_PAGE_BIT_RW;
return vm_iomap_memory(vma,START,LEN);
}
The user process calls mmap(..,PROT_READ|PROT_WRITE|PROT_EXEC,..). The mapping
in /proc/[pid]/maps shows the write bit. However, when looking at the actual
page table entry does not have the RW bit set. For example:
virtual address = 0000_0001_8000_0000
cr3 = 0000_0000_700a_e000
phys:0000_0000_700a_e000 = 0000_0000_7e05_5067 (P|RW|US|A|D)
phys:0000_0000_7e05_5030 = 0000_0001_66e2_9067 (P|RW|US|A|D)
phys:0000_0001_66e2_9000 = 0000_0001_69db_3067 (P|RW|US|A|D)
phys:0000_0001_69db_3000 = 0000_0000_8020_0225 (P|US|A|SOFTW1)
Am I doing something wrong?
Jethro
next reply other threads:[~2016-01-12 23:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 23:10 Jethro Beekman [this message]
2016-01-13 14:34 ` Mapping IO memory read-write Kenneth Adam Miller
2016-01-13 18:06 ` Jethro Beekman
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=569587DF.7020804@jbeekman.nl \
--to=kernel@jbeekman.nl \
--cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).