From patchwork Thu May 18 20:07:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 764167 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 3wTMhZ4vdhz9s4s for ; Fri, 19 May 2017 06:09:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="JHpjzvyO"; 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:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=V+JuFWgMHaWcIYJp9XEkmbup6PNP1lu DYEkiQrVemrE17qSnWHIYsq+z1khW8k3o9oEuaXd2Dw9UFmIKujQ7fcuvXJbcSKb 8u0AqRy8McabJW7gtOdvNelciYNPIFOlSHGo2XD3XolAeXN6MnrNOz9nJeeEmJjV arTq95ccGYEo= 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:cc:subject:date:message-id:in-reply-to :references; s=default; bh=i7009Co8Pr+VFDfWD9YXCYeAUsQ=; b=JHpjz vyO5HVwc+TdlffygMdPZDX+zVkRK/5qLFfJ5QVx1a8lrEMExAe3vNs1P8XhU+ap/ oQ1WWujziMC7YxSTWHuEM9z+EioV2BiTgTo2c3q+JOdJ/Hiw8PuUAJ+a5xlM9lXU BVByr3Uyl7WO2qALaZLWA+EJl2Gma8NWWKp100= Received: (qmail 117046 invoked by alias); 18 May 2017 20:07:45 -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 116978 invoked by uid 89); 18 May 2017 20:07:44 -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-a68.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org Subject: [PATCH 5/5] aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK Date: Fri, 19 May 2017 01:37:18 +0530 Message-Id: <1495138038-32212-6-git-send-email-siddhesh@sourceware.org> In-Reply-To: <1495138038-32212-1-git-send-email-siddhesh@sourceware.org> References: <1495138038-32212-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. --- 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; }