public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xgchenshy at 126 dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-106635-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2022-08-16  6:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  6:51 xgchenshy at 126 dot com [this message]
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

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-106635-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).