From patchwork Thu May 11 14:51:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 761137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wNx1m4rHwz9rxm for ; Fri, 12 May 2017 00:53:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="yD8u3uhN"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=CAihCjGmgM83HAvvqrBAod9j18NjyKd Lkszw6tlTdr5ViBo1/c3u1mlFZJ4ZcWDHeI3MOo9WLf0xqiVhb/FNOlnp7V+7azu 8txH95ovEDo3H8A0GCdrFPhYvplhjhfsx9C14SVChOmbPndi7ZueJlT/EHgTLHiP EgALt8s5Z170= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=FCUV701uYqYmfiSmt/M5VKc5HYw=; b=yD8u3 uhNSdItnmFQUeuIVmfzkAOib220tQowJTZvCn+tNdqpne+YB/gwWbghFOy5fEms+ 3Wu789HDuC5Qv6dJhHb3wPiiYx8g/TDS06Hx9ebpaVWhXFNXjhwZivswAvKpV3KC qsCgH1wIvp/Ma0okLdEYTi3bAxr/oFp0xG9FkA= Received: (qmail 91616 invoked by alias); 11 May 2017 14:52:16 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91557 invoked by uid 89); 11 May 2017 14:52:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=mrs X-HELO: homiemail-a40.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH 7/7] aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK Date: Thu, 11 May 2017 20:21:46 +0530 Message-Id: <1494514306-4167-8-git-send-email-siddhesh@sourceware.org> In-Reply-To: <1494514306-4167-1-git-send-email-siddhesh@sourceware.org> References: <1494514306-4167-1-git-send-email-siddhesh@sourceware.org> Now that LD_HWCAP_MASK (or glibc.tune.hwcap_mask) is read early enough to influence cpu feature check in aarch64, use it to influence multiarch selection. Setting LD_HWCAP_MASK such that it clears HWCAP_CPUID will now disable multiarch for the binary. * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features): Use glibc.tune.hwcap_mask. Change-Id: Ia801ed6b8166b79a0cae184ee7417272f2f60593 --- sysdeps/unix/sysv/linux/aarch64/cpu-features.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c index 7025062..0478fcc 100644 --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c @@ -18,18 +18,25 @@ #include #include +#include static inline void init_cpu_features (struct cpu_features *cpu_features) { - if (GLRO(dl_hwcap) & HWCAP_CPUID) +#if HAVE_TUNABLES + uint64_t hwcap_mask = TUNABLE_GET (glibc, tune, hwcap_mask, uint64_t); +#else + uint64_t hwcap_mask = GLRO (dl_hwcap_mask); +#endif + + uint64_t hwcap = GLRO (dl_hwcap) & hwcap_mask; + + if (hwcap & HWCAP_CPUID) { register uint64_t id = 0; asm volatile ("mrs %0, midr_el1" : "=r"(id)); cpu_features->midr_el1 = id; } else - { - cpu_features->midr_el1 = 0; - } + cpu_features->midr_el1 = 0; }