linux-mips-fnet
[Top] [All Lists]

Re: mmap() frame buffer causes bus error on MIPS ...

To: Jun Sun <jsun@mvista.com>
Subject: Re: mmap() frame buffer causes bus error on MIPS ...
From: Ralf Baechle <ralf@oss.sgi.com>
Date: Thu, 7 Sep 2000 11:20:13 +0200
Cc: linux-fbdev@vuser.vu.union.edu, linux-mips@oss.sgi.com, linux-mips@fnet.fr
In-reply-to: <39B6B75D.2501654E@mvista.com>; from jsun@mvista.com on Wed, Sep 06, 2000 at 02:30:05PM -0700
References: <39B5BD14.A8D2F467@mvista.com> <39B5DABB.7FB85B09@mvista.com> <39B6B75D.2501654E@mvista.com>
On Wed, Sep 06, 2000 at 02:30:05PM -0700, Jun Sun wrote:

> In MIPS, mk_pte_phys() is defined as follows :
> 
> extern inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
> {
>       return __pte(((physpage & PAGE_MASK) - PAGE_OFFSET) |
> pgprot_val(pgprot));
> }
> 
> The problematic part is " - PAGE_OFFSET" (where PAGE_OFFSET is
> 0x80000000).  If "physpage" is a physical address, it should not be
> substracted by PAGE_OFFSET.  This is a bug.
> 
> On the other hand, I wonder why this bug is there without being caught
> before (it is so fundamental).  If this is not a bug in MIPS kernel,
> then the fix is in the fb_mmap(), where under __mips__ case, we should
> add PAGE_OFFSET to the start of buffer address.

The definition should be:

extern inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
{
        return __pte(physpage) | pgprot_val(pgprot);
}

Masking with PAGE_MASK also seemed to be useless.

It's really surprising why it never has been caught.  Probably people
feed it with the addresses that are tweaked such that sich just work.

I'll cook up a patch for this bug.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>