public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luofengwc at qq dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/31492] ARM ldp instruction trigger bus error when kernel open option CONFIG_IO_STRICT_DEVMEM
Date: Sun, 17 Mar 2024 02:02:38 +0000	[thread overview]
Message-ID: <bug-31492-131-ROE4OweGJo@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31492-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31492

--- Comment #3 from luofeng14 <luofengwc at qq dot com> ---
(In reply to Florian Weimer from comment #2)
> You use the x0 and x1 registers, but you don't tell the compiler about it.
> Anything may happen as a result.

there may be some misunderstandings about the problem, actually, i encountered
this problem

```
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>

typedef char u8;

void * func(void)
{
        off_t base = 9654697984;
        void *p;
        int fd;
        int len = 724;
        // scanf ("%d",&len);

        struct stat statbuf;
        off_t mmoffset;
        void *mmp;

        if ((fd = open("/dev/mem", O_RDONLY)) == -1)
        {
                printf("%d\n",__LINE__);
                return NULL;
        }

        if ((p = malloc(len)) == NULL)
        {
                printf("%d\n",__LINE__);
                return NULL;
        }

        if (fstat(fd, &statbuf) == -1)
        {
                printf("%d\n",__LINE__);
                return NULL;
        }


    mmoffset = base % sysconf(_SC_PAGESIZE);
        mmp = mmap(NULL, mmoffset + len, PROT_READ, MAP_SHARED, fd, base -
mmoffset);
        if (mmp == MAP_FAILED)
                return 0;
        memcpy(p, (char *)mmp + mmoffset, len);

        if (munmap(mmp, mmoffset + len) == -1)
        {
                return NULL;
        }

  return p;
}
int main() {
  if(!func())
    return -1;
  return 0;
}

```
in above code, the ldp command is also used in memcpy. when use memcpy to copy
/dev/mem data, alos has bus error;

using inline assembly is to simplify the problem

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-03-17  2:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15  7:51 [Bug libc/31492] New: " luofengwc at qq dot com
2024-03-15  8:09 ` [Bug libc/31492] " luofengwc at qq dot com
2024-03-15  9:51 ` fweimer at redhat dot com
2024-03-17  2:02 ` luofengwc at qq dot com [this message]
2024-03-19 11:56 ` adhemerval.zanella at linaro dot org
2024-03-20  8:47 ` luofengwc at qq dot com

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=bug-31492-131-ROE4OweGJo@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).