From: Tom Duffy <tomduffy@dslextreme.com>
To: sparclinux@vger.kernel.org
Subject: mmap(/dev/mem) causing sigbus
Date: Thu, 13 Jan 2005 23:12:14 +0000 [thread overview]
Message-ID: <1105657934.2527.96.camel@duffman> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1383 bytes --]
It seems that there is an issue with either mmap or mmap'ing /dev/mem on
sparc64. A tool (mstflint) for flashing firmware for Mellanox
Infiniband HCA's is crashing on sparc64. It mmap's /dev/mem and when it
accesses it, a bus error is generated.
Should this work?
Attached is a small test program to demonstrate. Change BAR0 to
something in your PCI address space (grab an address from /proc/iomem).
# cat /proc/iomem
<snip>
1ff00100000-1ff001fffff : 0000:81:00.0
1ff00180680-1ff0018070f : ib_mthca
1ff001f00d8-1ff001f00df : ib_mthca
1ff00800000-1ff00ffffff : 0000:81:00.0
1ff00800000-1ff00ffffff : ib_mthca
1ff08000000-1ff0fffffff : 0000:81:00.0
# gdb ./mmap-test
(gdb) run
Starting program: /root/mmap-test
warning: linux_test_for_tracefork: unexpected result from waitpid (3298, status 0xb7f)
Program received signal SIGBUS, Bus error.
0x00010630 in main () at mmap-test.c:29
29 value= *( (unsigned*)(ptr + 0x000f0014) );
(gdb) print ptr
$1 = (void *) 0x7018c000
(gdb) print ptr + 0x000f0014
$2 = (void *) 0x7027c014
(gdb) x 0x7027c014
0x7027c014: Cannot access memory at address 0x7027c014
# cat /proc/3317/maps
<snip>
7018c000-7028c000 rw-s 1ff00100000 00:0d 316 /dev/mem
# uname -a
Linux tat 2.6.10 #14 SMP Mon Jan 3 12:30:51 PST 2005 sparc64 GNU/Linux
-tduffy
[-- Attachment #1.2: mmap-test.c --]
[-- Type: text/x-csrc, Size: 659 bytes --]
#define BAR0 0x1ff00100000ull
#define _XOPEN_SOURCE 500
#define _FILE_OFFSET_BITS 64
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
int fd;
void *ptr;
unsigned value;
unsigned long long offset = BAR0;
fd = open("/dev/mem",O_RDWR | O_SYNC);
if (fd<0) {
perror("open");
return 1;
}
ptr = mmap(NULL, 0x100000, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, offset);
if ( (! ptr) || (ptr == MAP_FAILED) ) {
perror("map");
return 1;
}
value= *( (unsigned*)(ptr + 0x000f0014) );
printf("value at 0x000f0014 is %#8.8x\n", value);
return 0;
err:
return 1;
}
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2005-01-13 23:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-13 23:12 Tom Duffy [this message]
2005-01-13 23:29 ` mmap(/dev/mem) causing sigbus David S. Miller
2005-01-14 22:30 ` [openib-general] " Tom Duffy
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=1105657934.2527.96.camel@duffman \
--to=tomduffy@dslextreme.com \
--cc=sparclinux@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.