From patchwork Wed Mar 13 09:21:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1055977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-497805-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FXD9g6lZ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44K5v84qS0z9s00 for ; Wed, 13 Mar 2019 20:21:40 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=BtGdKbBxopFBkN0J 01HJQFgKl0wXgkttoLrromcp5bWyOBk6avmdrMIO3jVAdbxRwMhT30tpSsZ6gb55 w+NqySyiCusSQnlJE955RieXs0Kd65ZqLw76oiHLdCtH2eZmm50whXWntVa1pGzx 2Z76/bn43xzGn8P+f5ilHn7wAq4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=L4f8waBOjLaU0Mj2RoWCAe mRm3M=; b=FXD9g6lZJZc3nlMHJ52iRlvMFaht5gCTTGNvGbqPcUrW1weO+XewUw iDV/idWPFeZdism8w3gg2/Sq49WSWPtT9pgfycmomnXbejPZ2srzUMy/XZfyvCc4 Wg8mJsusPvX9lu2wB++H98f2pxqtp/YjiCdMd2vnq7pmirKVcjbLs= Received: (qmail 131048 invoked by alias); 13 Mar 2019 09:21:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 131035 invoked by uid 89); 13 Mar 2019 09:21:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=272, 8 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Mar 2019 09:21:32 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id CB27A815A8 for ; Wed, 13 Mar 2019 10:21:29 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m7Ey_6Gqxi8P for ; Wed, 13 Mar 2019 10:21:29 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 83FD08139E for ; Wed, 13 Mar 2019 10:21:29 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [libsanitizer] SanitizerCommon: 64-bit SPARC/Linux port Date: Wed, 13 Mar 2019 10:21:27 +0100 Message-ID: <67501970.CGAUrkAME7@polaris> MIME-Version: 1.0 This patch contains the bits required to make the common 32-bit allocator work on SPARC64/Linux. It only affects the SPARC ports and has been tested on SPARC/Solaris and SPARC64/Linux. It merges r355978 of the LLVM repository. Installed on the mainline. 2019-03-13 Eric Botcazou PR sanitizer/80953 Merge from LLVM revision 355978 * sanitizer_common/sanitizer_allocator_primary32.h (class SizeClassAllocator32): Assert that kSpaceSize is power of 2 if SANITIZER_SIGN_EXTENDED_ADDRESSES is set. (PointerIsMine): Deal with SANITIZER_SIGN_EXTENDED_ADDRESSES. (ComputeRegionId): Likewise. * sanitizer_common/sanitizer_linux.cc (GetMaxVirtualAddress): Return appropriate value for SPARC 64-bit. * sanitizer_common/sanitizer_platform.h (SANITIZER_MMAP_RANGE_SIZE): Define for SPARC. (SANITIZER_SIGN_EXTENDED_ADDRESSES): Define to 1 for SPARC 64-bit. Index: sanitizer_common/sanitizer_allocator_primary32.h =================================================================== --- sanitizer_common/sanitizer_allocator_primary32.h (revision 269546) +++ sanitizer_common/sanitizer_allocator_primary32.h (working copy) @@ -54,6 +54,9 @@ class SizeClassAllocator32 { typedef typename Params::ByteMap ByteMap; typedef typename Params::MapUnmapCallback MapUnmapCallback; + COMPILER_CHECK(!SANITIZER_SIGN_EXTENDED_ADDRESSES || + (kSpaceSize & (kSpaceSize - 1)) == 0); + static const bool kRandomShuffleChunks = Params::kFlags & SizeClassAllocator32FlagMasks::kRandomShuffleChunks; static const bool kUseSeparateSizeClassForBatch = Params::kFlags & @@ -175,6 +178,8 @@ class SizeClassAllocator32 { bool PointerIsMine(const void *p) { uptr mem = reinterpret_cast(p); + if (SANITIZER_SIGN_EXTENDED_ADDRESSES) + mem &= (kSpaceSize - 1); if (mem < kSpaceBeg || mem >= kSpaceBeg + kSpaceSize) return false; return GetSizeClass(p) != 0; @@ -267,6 +272,8 @@ class SizeClassAllocator32 { COMPILER_CHECK(sizeof(SizeClassInfo) % kCacheLineSize == 0); uptr ComputeRegionId(uptr mem) { + if (SANITIZER_SIGN_EXTENDED_ADDRESSES) + mem &= (kSpaceSize - 1); const uptr res = mem >> kRegionSizeLog; CHECK_LT(res, kNumPossibleRegions); return res; Index: sanitizer_common/sanitizer_linux.cc =================================================================== --- sanitizer_common/sanitizer_linux.cc (revision 269546) +++ sanitizer_common/sanitizer_linux.cc (working copy) @@ -1064,6 +1064,8 @@ uptr GetMaxVirtualAddress() { return (1ULL << 40) - 1; // 0x000000ffffffffffUL; # elif defined(__s390x__) return (1ULL << 53) - 1; // 0x001fffffffffffffUL; +# elif defined(__sparc__) + return ~(uptr)0; # else return (1ULL << 47) - 1; // 0x00007fffffffffffUL; # endif Index: sanitizer_common/sanitizer_platform.h =================================================================== --- sanitizer_common/sanitizer_platform.h (revision 269546) +++ sanitizer_common/sanitizer_platform.h (working copy) @@ -239,10 +239,21 @@ # else # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 48) # endif +#elif defined(__sparc__) +# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 52) #else # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47) #endif +// Whether the addresses are sign-extended from the VMA range to the word. +// The SPARC64 Linux port implements this to split the VMA space into two +// non-contiguous halves with a huge hole in the middle. +#if defined(__sparc__) && SANITIZER_WORDSIZE == 64 +# define SANITIZER_SIGN_EXTENDED_ADDRESSES 1 +#else +# define SANITIZER_SIGN_EXTENDED_ADDRESSES 0 +#endif + // The AArch64 linux port uses the canonical syscall set as mandated by // the upstream linux community for all new ports. Other ports may still // use legacy syscalls.