From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A40AA3857811; Fri, 15 Mar 2024 07:51:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A40AA3857811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710489064; bh=IEDbmozfoIhvWqnM4Rdq6uG8PMH6s1o5mB9UZJ2R6XA=; h=From:To:Subject:Date:From; b=qYxn/dwPHzPOW1kUrArarMaROj0ktzKfd8P5cRkPbdyHjK9HLp8VLHg6Oi0anbApW rr5C4IjpfLlR6FP7MSmmPw6qdZFg5nVRbLSfFvnfpZ3I02UgezBr7JUTEOUWf5g8SK JlJQZOXSlmFZH5exN6CN+NycrZkS2rVd0uT8Nokw= From: "luofengwc at qq dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/31492] New: ARM ldp instruction trigger bus error when kernel open option CONFIG_IO_STRICT_DEVMEM Date: Fri, 15 Mar 2024 07:51:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.34 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luofengwc at qq dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31492 Bug ID: 31492 Summary: ARM ldp instruction trigger bus error when kernel open option CONFIG_IO_STRICT_DEVMEM Product: glibc Version: 2.34 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: luofengwc at qq dot com CC: drepper.fsp at gmail dot com Target Milestone: --- Hi, everyone, I encountered a runtime problem with bus errror caused by the= ldp instruction(ARM instruction). On an aarch architecture Linux machine, when I turned on the option kernel option CONFIG_IO_STRICT_DEVMEM, mapped the memory of /dev/mem using mmap, a= nd used the ldp instruction to read the data, a bus error occurred, but ldr and ldrp ran normally. Why do i think this problem is related to glibc because the ldp command is = also used in memcpy. when use memcpy to copy /dev/mem data, alos has bus error; check kernel CONFIG_IO_STRICT_DEVMEM optoins ``` zcat /proc/config.gz | grep CONFIG_IO_STRICT_DEVMEM CONFIG_IO_STRICT_DEVMEM=3Dy ``` code example: demo.c ``` #include #include #include #include #include #include #include #include #include typedef char u8; int main() { off_t base =3D 9654697984; void *p; int fd; int len =3D 724; struct stat statbuf; off_t mmoffset; void *mmp; if ((fd =3D open("/dev/mem", O_RDONLY)) =3D=3D -1) { printf("%d\n",__LINE__); return NULL; } if ((p =3D malloc(len)) =3D=3D NULL) { printf("%d\n",__LINE__); return NULL; } if (fstat(fd, &statbuf) =3D=3D -1) { printf("%d\n",__LINE__); return NULL; } mmoffset =3D base % sysconf(_SC_PAGESIZE); printf("0"); mmp =3D mmap(NULL, mmoffset + len, PROT_READ, MAP_SHARED, fd, base - mmoffset); if (mmp =3D=3D MAP_FAILED) return 0; long output; __asm__( "ldrb w0, [x0]" : "=3Dr" (output) : "r" (mmp+mmoffset) ); __asm__( "ldr x0, [x0]" : "=3Dr" (output) : "r" (mmp+mmoffset) ); // ldp trigger bus error __asm__( "ldp x0, x1, [x0]" : "=3Dr" (output)=20=20=20=20=20=20=20=20=20 : "r" (mmp+mmoffset) ); if (munmap(mmp, mmoffset + len) =3D=3D -1) { return NULL; } printf("\noutput =3D %ld\n",output); return 0; } ``` compile command with none optimization ``` gcc -O0 demo.c -g ``` --=20 You are receiving this mail because: You are on the CC list for the bug.=