public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/102144] New: hwsan has a hardcoded pagesize requirement for aarch64
@ 2021-08-31  9:03 pinskia at gcc dot gnu.org
  2021-09-19  0:41 ` [Bug sanitizer/102144] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-31  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102144
           Summary: hwsan has a hardcoded pagesize requirement for aarch64
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64-linux-gnu

I am using Linux 5.4.74 and the hwasan testcases have never passed for me on
OcteonTX 2 96xx which is an ARMv8.2-a processor by Marvell.  I am using glibc
2.27.  ****With 64k pages.******

Almost all fail the same way:
==3382612==ERROR: HWAddressSanitizer failed to deallocate 0x4000 (16384) bytes
at address 0xfffff68a2000
HWAddressSanitizer: CHECK failed: sanitizer_posix.cpp:61 "(("unable to unmap"
&& 0)) != (0)" (0x0, 0x0) (tid=3382612)
    #0 0xfffff764ceb8 in CheckUnwind gcc/libsanitizer/hwasan/hwasan.cpp:137
    #1 0xfffff766cac0 in __sanitizer::CheckFailed(char const*, int, char
const*, unsigned long long, unsigned long long)
gcc/libsanitizer/sanitizer_common/sanitizer_termination.cpp:86
    #2 0xfffff7660418 in __sanitizer::UnmapOrDie(void*, unsigned long)
gcc/libsanitizer/sanitizer_common/sanitizer_posix.cpp:61
    #3 0xfffff7660418 in __sanitizer::UnmapOrDie(void*, unsigned long)
gcc/libsanitizer/sanitizer_common/sanitizer_posix.cpp:55
    #4 0xfffff7661188 in __sanitizer::MmapAlignedOrDieOnFatalError(unsigned
long, unsigned long, char const*)
gcc/libsanitizer/sanitizer_common/sanitizer_posix.cpp:99
    #5 0xfffff7653464 in
__hwasan::SavedStackAllocations::SavedStackAllocations(__sanitizer::CompactRingBuffer<unsigned
long>*) gcc/libsanitizer/hwasan/hwasan_report.cpp:113
    #6 0xfffff7653464 in __hwasan::ReportTagMismatch(__sanitizer::StackTrace*,
unsigned long, unsigned long, bool, bool, unsigned long*)
gcc/libsanitizer/hwasan/hwasan_report.cpp:647
    #7 0xfffff764d188 in __hwasan::HandleTagMismatch(__hwasan::AccessInfo,
unsigned long, unsigned long, void*, unsigned long*)
gcc/libsanitizer/hwasan/hwasan.cpp:215
    #8 0xfffff764f8e4 in HwasanOnSIGTRAP
gcc/libsanitizer/hwasan/hwasan_linux.cpp:379
    #9 0xfffff764f8e4 in __hwasan::HwasanOnDeadlySignal(int, void*, void*)
gcc/libsanitizer/hwasan/hwasan_linux.cpp:399
    #10 0xfffff7fc05e0  (linux-vdso.so.1+0x5e0)
    #11 0xfffff764da58 in __hwasan_load4 gcc/libsanitizer/hwasan/hwasan.cpp:442
    #12 0x400b54 in main c-c++-common/hwasan/large-aligned-untagging-0.c:64
    #13 0xfffff71e06dc in __libc_start_main
(/lib/aarch64-linux-gnu/libc.so.6+0x206dc)
    #14 0x400bdc 
(/bajas/pinskia/src/upstream-gcc-aarch64/gcc/objdir/gcc/testsuite/g++1/large-aligned-untagging-7.exe+0x400bdc)

Here is part of kernel config which might make a difference:
CONFIG_ARM64_PAGE_SHIFT=16
CONFIG_ARM64_CONT_SHIFT=5
CONFIG_ARCH_MMAP_RND_BITS_MIN=14
CONFIG_ARCH_MMAP_RND_BITS_MAX=29
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=7
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
...
CONFIG_ARM64_64K_PAGES=y
CONFIG_ARM64_VA_BITS_48=y
CONFIG_ARM64_VA_BITS=48
CONFIG_ARM64_PA_BITS_48=y
CONFIG_ARM64_PA_BITS=48

CONFIG_ARM64_TAGGED_ADDR_ABI=y

CONFIG_ARM64_HW_AFDBM=y
CONFIG_ARM64_PAN=y
CONFIG_ARM64_LSE_ATOMICS=y
CONFIG_ARM64_VHE=y
CONFIG_ARM64_RAS_EXTN=y
CONFIG_ARM64_CNP=y

# git grep 4096 
hwasan/hwasan.cpp:    cf.clear_shadow_mmap_threshold = 4096 *
(SANITIZER_ANDROID ? 2 : 8);
hwasan/hwasan.cpp:static constexpr uptr kMemoryUsageBufferSize = 4096;
hwasan/hwasan_thread_list.h:// * Each ring buffer has a size of (2**N)*4096
where N is in [0, 8), and is
hwasan/hwasan_thread_list.h:    uptr size = 4096 * (1ULL << shift);


The important one here is one in hwasan/hwasan_thread_list.h.
I will see tomorrow if changing it to be based on the current page size will
fix the problem I am seeing.

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

* [Bug sanitizer/102144] hwsan has a hardcoded pagesize requirement for aarch64
  2021-08-31  9:03 [Bug sanitizer/102144] New: hwsan has a hardcoded pagesize requirement for aarch64 pinskia at gcc dot gnu.org
@ 2021-09-19  0:41 ` pinskia at gcc dot gnu.org
  2021-09-19  0:51 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19  0:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This fixes the problem for me:
diff --git a/libsanitizer/hwasan/hwasan_thread_list.h
b/libsanitizer/hwasan/hwasan_thread_list.h
index 15916a802d6..c13c5910b95 100644
--- a/libsanitizer/hwasan/hwasan_thread_list.h
+++ b/libsanitizer/hwasan/hwasan_thread_list.h
@@ -57,7 +57,7 @@ static uptr RingBufferSize() {
   // FIXME: increase the limit to 8 once this bug is fixed:
   // https://bugs.llvm.org/show_bug.cgi?id=39030
   for (int shift = 1; shift < 7; ++shift) {
-    uptr size = 4096 * (1ULL << shift);
+    uptr size = (64*4096) * (1ULL << shift);
     if (size >= desired_bytes)
       return size;
   }


Let me submit a bug upstream.

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

* [Bug sanitizer/102144] hwsan has a hardcoded pagesize requirement for aarch64
  2021-08-31  9:03 [Bug sanitizer/102144] New: hwsan has a hardcoded pagesize requirement for aarch64 pinskia at gcc dot gnu.org
  2021-09-19  0:41 ` [Bug sanitizer/102144] " pinskia at gcc dot gnu.org
@ 2021-09-19  0:51 ` pinskia at gcc dot gnu.org
  2023-11-21  0:57 ` pinskia at gcc dot gnu.org
  2023-11-21  0:57 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19  0:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-09-19
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           See Also|                            |https://github.com/google/s
                   |                            |anitizers/issues/1446

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Submitted upstream:
https://github.com/google/sanitizers/issues/1446

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

* [Bug sanitizer/102144] hwsan has a hardcoded pagesize requirement for aarch64
  2021-08-31  9:03 [Bug sanitizer/102144] New: hwsan has a hardcoded pagesize requirement for aarch64 pinskia at gcc dot gnu.org
  2021-09-19  0:41 ` [Bug sanitizer/102144] " pinskia at gcc dot gnu.org
  2021-09-19  0:51 ` pinskia at gcc dot gnu.org
@ 2023-11-21  0:57 ` pinskia at gcc dot gnu.org
  2023-11-21  0:57 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21  0:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This was fixed with the merge from upstream in April, r14-263-gd53b3d94aaf2 .

Specifically:
@@ -87,19 +85,26 @@ void *MmapAlignedOrDieOnFatalError(uptr size, uptr
alignment,
   CHECK(IsPowerOfTwo(size));
   CHECK(IsPowerOfTwo(alignment));
   uptr map_size = size + alignment;
+  // mmap maps entire pages and rounds up map_size needs to be a an integral
+  // number of pages.
+  // We need to be aware of this size for calculating end and for unmapping
+  // fragments before and after the alignment region.
+  map_size = RoundUpTo(map_size, GetPageSizeCached());


https://github.com/llvm/llvm-project/commit/1293e93ee3da0d53665975499a909a45c5b90423
was the upstream commit. Funny how it was recorded for Mac OS due to 16k page
size rather than my report which was filed before hand.

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

* [Bug sanitizer/102144] hwsan has a hardcoded pagesize requirement for aarch64
  2021-08-31  9:03 [Bug sanitizer/102144] New: hwsan has a hardcoded pagesize requirement for aarch64 pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-11-21  0:57 ` pinskia at gcc dot gnu.org
@ 2023-11-21  0:57 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21  0:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

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

end of thread, other threads:[~2023-11-21  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31  9:03 [Bug sanitizer/102144] New: hwsan has a hardcoded pagesize requirement for aarch64 pinskia at gcc dot gnu.org
2021-09-19  0:41 ` [Bug sanitizer/102144] " pinskia at gcc dot gnu.org
2021-09-19  0:51 ` pinskia at gcc dot gnu.org
2023-11-21  0:57 ` pinskia at gcc dot gnu.org
2023-11-21  0:57 ` pinskia at gcc dot gnu.org

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