From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AA650385840F; Tue, 16 Aug 2022 06:51:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA650385840F From: "xgchenshy at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106635] New: AARCH64 STUR instruction causes bus error Date: Tue, 16 Aug 2022 06:51:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xgchenshy at 126 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.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 target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Aug 2022 06:51:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106635 Bug ID: 106635 Summary: AARCH64 STUR instruction causes bus error Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: xgchenshy at 126 dot com Target Milestone: --- Hi, We are using aarch64-none-linux-gnueabi-gcc (version 11.2.1) to compile= our userspace code with cortex A55 platform in linux environment, we met an bus error which causes the program to exit. with closer look, we found such STUR instruction causes this issue this is the cflags: CFLAGS =3D -fpic -Wall -ansi -std=3Dc99 -Wno-variadic-macros -g -Werror = -fPIC -shared -Wall -O2 -ggdb3 below is the C code: void CWLCollectReadRegData(u32* dst,u16 reg_start, u32 reg_length,u32* total_length, addr_t status_data_base_addr) { u32 data_length=3D0; { //opcode *dst++ =3D (OPCODE_RREG<<27)|(reg_length<<16)|(reg_start*4); data_length++; //data *dst++ =3D (u32)status_data_base_addr; <<----this line of code causes b= us error data_length++; .... } below is the disassemble code: (gdb) disassemble CWLCollectReadRegData Dump of assembler code for function CWLCollectReadRegData: 0x0000000000000080 <+0>: ubfiz w1, w1, #2, #16 0x0000000000000084 <+4>: stur x4, [x0, #4] <<------this is the code that causes bus error 0x0000000000000088 <+8>: orr w2, w1, w2, lsl #16 0x000000000000008c <+12>: mov w1, #0xb0000000 // #-1342177280 0x0000000000000090 <+16>: orr w2, w2, w1 0x0000000000000094 <+20>: str w2, [x0] 0x0000000000000098 <+24>: str wzr, [x0, #12] 0x000000000000009c <+28>: mov w1, #0x4 // #4 0x00000000000000a0 <+32>: str w1, [x3] 0x00000000000000a4 <+36>: ret End of assembler dump. this line of code causes bus error.=20 stur x4, [x0, #4] our program expects to write a 32 bit value to [x0,#4], but this instruncti= on writes a 64 bit value X4, this is already wrong. but STUR instrunction should support unaligned access, I also dont' quite k= now why the bus error happens. Thanks=