All of lore.kernel.org
 help / color / mirror / Atom feed
From: "shanthi kiran pendyala" <skiranp@cisco.com>
To: <linux-kernel@vger.kernel.org>
Subject: Mmap problem (VM_DENYWRITE)
Date: Mon, 24 May 2004 11:49:10 -0700	[thread overview]
Message-ID: <000a01c441bf$ccb83600$322147ab@amer.cisco.com> (raw)
In-Reply-To: <20040519062044.15651.qmail@web90107.mail.scd.yahoo.com>

Hi,

<<I am not subscribed to this list b'cos of the volume of emails. Please
include my email in the reply.>>

I am writing a device driver for a fpga device. 
I implemented a dummy char device to gain user space access to the device
registers thru mmap. 
The kernel is 2.4.18. 
The CPU is sibyte (mips64 cpu) with 40 bits of physical addressing and 44
bits of virtual addressing.

After mmaping in userspace any writes to the mmap region is not working. 
I think it is b'cos of the protection field in the vma is set to
VM_DENYWRITE. 
The complete prot flag is (VM_READ | VM_WRITE | VM_EXEC | VM_GROWSUP |
VM_DENYWRITE)

Why is this happening? I need to have both read and write access to region.
How do I fix this ?

Thanks for you help

Shanthi kiran


Output after running test program
=================================
 building page tables for va 0x2aac5000 phy 0x10940000 
 vsize 0x20000 psize 0x20000 prot 0xa07


===================================================================
My mmap implementation is as follow

#define FPGA_CSR_ADDR_START 0x10940000
#define FPGA_CSR_ADDR_END   0x1095ffff
#define MMAP_SIZE (FPGA_CSR_ADDR_END + 1 - FPGA_CSR_ADDR_START)

int
fpga_mmap(struct file *filp, struct vm_area_struct *vma) {

    unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
    unsigned long vsize = vma->vm_end - vma->vm_start;
    unsigned long phys = FPGA_CSR_ADDR_START + offset;
    unsigned long psize = MMAP_SIZE - offset;

    if(vsize > psize)
        return -EINVAL;

    printk("<1> building page tables for va 0x%lx phy 0x%lx \n",
            vma->vm_start, phys);

    printk("<1> vsize 0x%lx psize 0x%lx prot 0x%lx\n",
           vsize, psize, vma->vm_page_prot.pgprot);

    /* build new page tables */
    if (remap_page_range(vma->vm_start, phys, vsize, vma->vm_page_prot))
            return -EAGAIN;

    return 0;
}
================================================================
I try to access to the device memory region with this user space test
program
    ....
	fpga_fd = open(FPGA_DEV_FILE_NAME, O_RDWR);

    if(cde_fd < 0) {
        printf("can't open %s err %d\n", FPGA_DEV_FILE_NAME, fpga_fd);
        goto finish;
    }

    offset = 0;
    fpga_csr_start = mmap(0, MMAP_SIZE,
                PROT_READ|PROT_WRITE, MAP_SHARED,
                fpga_fd, offset);

    if (fpga_csr_start < 0 ) {
        printf(" error in mmap errno %d", errno);
        goto finish;
    }

...
============================================================================


  reply	other threads:[~2004-05-24 18:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-18  6:31 how ip header added in ip_bulid_xmit function? linux lover
2004-05-18 14:23 ` Manu Garg
2004-05-19  6:20   ` linux lover
2004-05-24 18:49     ` shanthi kiran pendyala [this message]
2004-05-24 18:58       ` Mmap problem (VM_DENYWRITE) Tommy Reynolds
2004-05-24 20:22       ` Richard B. Johnson
2004-05-24 20:29       ` Chris Wright

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='000a01c441bf$ccb83600$322147ab@amer.cisco.com' \
    --to=skiranp@cisco.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.