From patchwork Wed Jun 24 15:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Earnshaw X-Patchwork-Id: 39787 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3092398786F; Wed, 24 Jun 2020 15:54:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id CD8183851C3B for ; Wed, 24 Jun 2020 15:53:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CD8183851C3B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rearnsha@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C4FA31B; Wed, 24 Jun 2020 08:53:57 -0700 (PDT) Received: from eagle.buzzard.freeserve.co.uk (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ED8333F73C; Wed, 24 Jun 2020 08:53:56 -0700 (PDT) From: Richard Earnshaw To: libc-alpha@sourceware.org Subject: [PATCH v2 1/6] config: Allow memory tagging to be enabled when configuring glibc Date: Wed, 24 Jun 2020 16:53:44 +0100 Message-Id: <20200624155349.12134-2-rearnsha@arm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200624155349.12134-1-rearnsha@arm.com> References: <20200624155349.12134-1-rearnsha@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Earnshaw Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch adds the configuration machinery to allow memory tagging to be enabled from the command line via the configure option --enable-memory-tagging. The current default is off, though in time we may change that once the API is more stable. --- INSTALL | 14 ++++++++++++++ config.h.in | 3 +++ config.make.in | 2 ++ configure | 17 +++++++++++++++++ configure.ac | 10 ++++++++++ manual/install.texi | 13 +++++++++++++ 6 files changed, 59 insertions(+) diff --git a/INSTALL b/INSTALL index 62e78725f5..37c98ca015 100644 --- a/INSTALL +++ b/INSTALL @@ -142,6 +142,20 @@ if 'CFLAGS' is specified it must enable optimization. For example: non-CET processors. '--enable-cet' has been tested for i686, x86_64 and x32 on CET processors. +'--enable-memory-tagging' + Enable memory tagging support on architectures that support it. + When the GNU C Library is built with this option then the resulting + library will be able to control the use of tagged memory when + hardware support is present by use of the tunable + 'glibc.memtag.enable'. This includes the generation of tagged + memory when using the 'malloc' APIs. + + At present only AArch64 platforms with MTE provide this + functionality, although the library will still operate (without + memory tagging) on older versions of the architecture. + + The default is to disable support for memory tagging. + '--disable-profile' Don't build libraries with profiling information. You may want to use this option if you don't plan to do profiling. diff --git a/config.h.in b/config.h.in index 831eca2fe1..134f4257cd 100644 --- a/config.h.in +++ b/config.h.in @@ -148,6 +148,9 @@ /* Define if __stack_chk_guard canary should be randomized at program startup. */ #undef ENABLE_STACKGUARD_RANDOMIZE +/* Define if memory tagging support should be enabled. */ +#undef _LIBC_MTAG + /* Package description. */ #undef PKGVERSION diff --git a/config.make.in b/config.make.in index 2fed3da773..b3be8e0381 100644 --- a/config.make.in +++ b/config.make.in @@ -84,6 +84,8 @@ mach-interface-list = @mach_interface_list@ experimental-malloc = @experimental_malloc@ +memory-tagging = @memory_tagging@ + nss-crypt = @libc_cv_nss_crypt@ static-nss-crypt = @libc_cv_static_nss_crypt@ diff --git a/configure b/configure index b8ef8c7a51..528112aabf 100755 --- a/configure +++ b/configure @@ -678,6 +678,7 @@ link_obsolete_rpc libc_cv_static_nss_crypt libc_cv_nss_crypt build_crypt +memory_tagging experimental_malloc enable_werror all_warnings @@ -783,6 +784,7 @@ enable_all_warnings enable_werror enable_multi_arch enable_experimental_malloc +enable_memory_tagging enable_crypt enable_nss_crypt enable_obsolete_rpc @@ -1454,6 +1456,8 @@ Optional Features: architectures --disable-experimental-malloc disable experimental malloc features + --enable-memory-tagging enable memory tagging if supported by the + architecture [default=no] --disable-crypt do not build nor install the passphrase hashing library, libcrypt --enable-nss-crypt enable libcrypt to use nss @@ -3527,6 +3531,19 @@ fi +# Check whether --enable-memory-tagging was given. +if test "${enable_memory_tagging+set}" = set; then : + enableval=$enable_memory_tagging; memory_tagging=$enableval +else + memory_tagging=no +fi + +if test "$memory_tagging" = yes; then + $as_echo "#define _LIBC_MTAG 1" >>confdefs.h + +fi + + # Check whether --enable-crypt was given. if test "${enable_crypt+set}" = set; then : enableval=$enable_crypt; build_crypt=$enableval diff --git a/configure.ac b/configure.ac index ff00591fd4..ebcc931a8e 100644 --- a/configure.ac +++ b/configure.ac @@ -311,6 +311,16 @@ AC_ARG_ENABLE([experimental-malloc], [experimental_malloc=yes]) AC_SUBST(experimental_malloc) +AC_ARG_ENABLE([memory-tagging], + AC_HELP_STRING([--enable-memory-tagging], + [enable memory tagging if supported by the architecture @<:@default=no@:>@]), + [memory_tagging=$enableval], + [memory_tagging=no]) +if test "$memory_tagging" = yes; then + AC_DEFINE(_LIBC_MTAG) +fi +AC_SUBST(memory_tagging) + AC_ARG_ENABLE([crypt], AC_HELP_STRING([--disable-crypt], [do not build nor install the passphrase hashing library, libcrypt]), diff --git a/manual/install.texi b/manual/install.texi index c1e49a94fe..6cd87326e3 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -171,6 +171,19 @@ NOTE: @option{--enable-cet} has been tested for i686, x86_64 and x32 on non-CET processors. @option{--enable-cet} has been tested for i686, x86_64 and x32 on CET processors. +@item --enable-memory-tagging +Enable memory tagging support on architectures that support it. When +@theglibc{} is built with this option then the resulting library will +be able to control the use of tagged memory when hardware support is +present by use of the tunable @samp{glibc.memtag.enable}. This includes +the generation of tagged memory when using the @code{malloc} APIs. + +At present only AArch64 platforms with MTE provide this functionality, +although the library will still operate (without memory tagging) on +older versions of the architecture. + +The default is to disable support for memory tagging. + @item --disable-profile Don't build libraries with profiling information. You may want to use this option if you don't plan to do profiling.