public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rory.bolt at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/109933] New: __atomic_test_and_set is broken for BIG ENDIAN riscv targets Date: Mon, 22 May 2023 18:56:26 +0000 [thread overview] Message-ID: <bug-109933-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109933 Bug ID: 109933 Summary: __atomic_test_and_set is broken for BIG ENDIAN riscv targets Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: rory.bolt at gmail dot com Target Milestone: --- Target: riscv64be-unknown-linux-gnu Created attachment 55136 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55136&action=edit Simple test program illustrating the bug PLEASE NOTE: this bug is in reference to BIG ENDIAN riscv targets... Although reported on riscv64be, it most likely exists for 32 bit targets too. Please see the attached test program. The issue appears to be that the value atomically or'ed should be 0x01000000 not 1 for big endian systems, since we want the non-zero value in the lowest memory address and the amoor.w command is writing a 32 bit value to memory. The current (broken) implementation will pass a simple unit test, the problem only manifests itself on a call to __atomic_test_and_set AFTER a previous call to __atomic_test_and_set to the same address and a __atomic_clear to the same address. This problem originally manifested itself in the linux libcap library, which uses __atomic_test_and_set in conjunction with __atomic_clear to implement a mutex to guard the manipulation of capabilities.
next reply other threads:[~2023-05-22 18:56 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-22 18:56 rory.bolt at gmail dot com [this message] 2023-05-22 18:58 ` [Bug target/109933] " pinskia at gcc dot gnu.org 2023-05-22 19:02 ` pinskia at gcc dot gnu.org 2023-05-23 8:06 ` rguenth at gcc dot gnu.org 2023-05-23 22:00 ` patrick at rivosinc dot com 2023-05-23 22:02 ` patrick at rivosinc dot com 2023-05-23 22:49 ` patrick at rivosinc dot com 2023-05-23 23:50 ` rory.bolt at gmail dot com 2023-05-23 23:58 ` palmer at gcc dot gnu.org 2023-05-24 14:08 ` rory.bolt at gmail dot com 2023-05-25 2:39 ` rory.bolt at gmail dot com 2023-05-25 16:46 ` rory.bolt at gmail dot com 2023-05-25 18:30 ` patrick at rivosinc dot com 2023-05-25 19:10 ` rory.bolt at gmail dot com 2023-11-01 23:55 ` patrick at rivosinc 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-109933-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: linkBe 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).