public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106635] New: AARCH64 STUR instruction causes bus error
@ 2022-08-16  6:51 xgchenshy at 126 dot com
  2022-08-16  8:04 ` [Bug target/106635] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: xgchenshy at 126 dot com @ 2022-08-16  6:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106635

            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   = -fpic -Wall -ansi -std=c99 -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=0;
  {
    //opcode
    *dst++ = (OPCODE_RREG<<27)|(reg_length<<16)|(reg_start*4);
    data_length++;

    //data
    *dst++ = (u32)status_data_base_addr; <<----this line of code causes bus
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. 
stur x4, [x0, #4]

our program expects to write a 32 bit value to [x0,#4], but this instrunction
writes a 64 bit value X4, this is already wrong.
but STUR instrunction should support unaligned access, I also dont' quite know
why the bus error happens.

Thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-08-17  6:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16  6:51 [Bug c/106635] New: AARCH64 STUR instruction causes bus error xgchenshy at 126 dot com
2022-08-16  8:04 ` [Bug target/106635] " rguenth at gcc dot gnu.org
2022-08-16  8:34 ` xgchenshy at 126 dot com
2022-08-16  8:35 ` xgchenshy at 126 dot com
2022-08-16  8:36 ` xgchenshy at 126 dot com
2022-08-16 11:15 ` rearnsha at gcc dot gnu.org
2022-08-17  2:26 ` xgchenshy at 126 dot com
2022-08-17  2:32 ` pinskia at gcc dot gnu.org
2022-08-17  2:50 ` pinskia at gcc dot gnu.org
2022-08-17  3:27 ` xgchenshy at 126 dot com
2022-08-17  6:37 ` xgchenshy at 126 dot com

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).