public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/106635] AARCH64 STUR instruction causes bus error
Date: Tue, 16 Aug 2022 11:15:54 +0000	[thread overview]
Message-ID: <bug-106635-4-BzWRpfyo5V@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106635-4@http.gcc.gnu.org/bugzilla/>

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

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|WAITING                     |RESOLVED

--- Comment #5 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Your original code contains (after stripping out the volatile):
    u32 temp_32 = (u32)status_data_base_addr;
    *dst++ = temp_32;
    data_length++;

    if(sizeof(addr_t) == 8) {
      *dst++ = (u32)(((u64)status_data_base_addr)>>32);
      data_length++;
    }

Which of course on a 64-bit machine simplifies to 

    u32 temp_32 = (u32)status_data_base_addr;
    *dst++ = temp_32;
    data_length++;

    *dst++ = (u32)(((u64)status_data_base_addr)>>32);
    data_length++;

And which the compiler then further simplifies to 

   *([unaligned]u64*)dst = status_data_base_addr;
   data_length += 2;
   dst += 2;

If the location that dst points to is in normal, cachable, memory, then this
will be fine.  But if you're writing to non-cachable memory, then you might get
a trap.

the correct fix is to mark dst as volatile in this case.

void CWLCollectReadRegData(volatile u32* dst,u16 reg_start, u32 reg_length,u32*
total_length, addr_t status_data_base_addr)

  parent reply	other threads:[~2022-08-16 11:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  6:51 [Bug c/106635] New: " 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 [this message]
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-BzWRpfyo5V@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).