{"id":810745,"url":"http://patchwork.ozlabs.org/api/patches/810745/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/20170906180229.GA32425@gmail.com/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170906180229.GA32425@gmail.com>","list_archive_url":null,"date":"2017-09-06T18:02:29","name":"x86: Add x86_64 to x86-64 HWCAP [BZ #22093]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c0454d3dd6c3d9cd4188dc7f22f5c3e81533dcaf","submitter":{"id":4412,"url":"http://patchwork.ozlabs.org/api/people/4412/?format=json","name":"H.J. Lu","email":"hongjiu.lu@intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20170906180229.GA32425@gmail.com/mbox/","series":[{"id":1861,"url":"http://patchwork.ozlabs.org/api/series/1861/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=1861","date":"2017-09-06T18:02:29","name":"x86: Add x86_64 to x86-64 HWCAP [BZ #22093]","version":1,"mbox":"http://patchwork.ozlabs.org/series/1861/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810745/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810745/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-return-84273-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84273-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"S0oooey0\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnWff5zb1z9sBW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 04:03:38 +1000 (AEST)","(qmail 125216 invoked by alias); 6 Sep 2017 18:03:32 -0000","(qmail 125198 invoked by uid 89); 6 Sep 2017 18:03:30 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:date:from:to:subject:message-id:reply-to\n\t:mime-version:content-type; q=dns; s=default; b=KaUrGkHNL7VgNYCj\n\tuzIYJhOC6qAGZON9ORaUwfn9cCuXmKwrZBl6d7Dp9mXP/bYzv5BYp1lDk66gHKZF\n\t4zlXJXJqJObMKGr+DFg4YfxWXyXoDXId4F+/jDMksPLvBxH1K19e+gsBkOcVPJCL\n\tphoN2UP/OjsGOzqu87VC/xYGza4=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:date:from:to:subject:message-id:reply-to\n\t:mime-version:content-type; s=default; bh=SyGlLsxzycnSqoNt6dC8VV\n\t3wIYY=; b=S0oooey0h2rB1ZN0QAEZNOvnu4H7Q28TCalT7EQksk33DSCZRBa648\n\tGBVJ6XzzODCEPKBHffKo2YsH1iW6IQmMm2wNtIO2rJlDn7zeHK+v221vAjyRs8AW\n\tPRabN71trgWEZMNJKbxDxBGOFRr8UZY9R6EM1JKwMepoCKuT54ekI=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-24.5 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM,\n\tRP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=","X-HELO":"mga14.intel.com","X-ExtLoop1":"1","Date":"Wed, 6 Sep 2017 11:02:29 -0700","From":"\"H.J. Lu\" <hongjiu.lu@intel.com>","To":"GNU C Library <libc-alpha@sourceware.org>","Subject":"[PATCH] x86: Add x86_64 to x86-64 HWCAP [BZ #22093]","Message-ID":"<20170906180229.GA32425@gmail.com>","Reply-To":"\"H.J. Lu\" <hjl.tools@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","User-Agent":"Mutt/1.8.3 (2017-05-23)"},"content":"Before glibc 2.26, ld.so set dl_platform to \"x86_64\" and searched the\n\"x86_64\" subdirectory when loading a shared library.  ld.so in glibc\n2.26 was changed to set dl_platform to \"haswell\" or \"xeon_phi\", based\non supported ISAs.  This led to shared library loading failure for\nshared libraries placed under the \"x86_64\" subdirectory.\n\nThis patch adds \"x86_64\" to x86-64 dl_hwcap so that ld.so will always\nsearch the \"x86_64\" subdirectory when loading a shared library.\n\nNB: We can't set x86-64 dl_platform to \"x86-64\" since ld.so will skip\nthe \"haswell\" and \"xeon_phi\" subdirectories on \"haswell\" and \"xeon_phi\"\nmachines.\n\nTested on i686 and x86-64.  OK for master?\n\n\nH.J.\n--\n\t[BZ #22093]\n\t* sysdeps/x86/cpu-features.c (init_cpu_features): Initialize\n\tGLRO(dl_hwcap) to HWCAP_X86_64 for x86-64.\n\t* sysdeps/x86/dl-hwcap.h (HWCAP_COUNT): Updated.\n\t(HWCAP_IMPORTANT): Likewise.\n\t(HWCAP_X86_64): New enum.\n\t(HWCAP_X86_AVX512_1): Updated.\n\t* sysdeps/x86/dl-procinfo.c (_dl_x86_hwcap_flags): Add \"x86_64\".\n\t* sysdeps/x86_64/Makefile (tests): Add tst-x86_64-1.\n\t(modules-names): Add x86_64/tst-x86_64mod-1.\n\t(LDFLAGS-tst-x86_64mod-1.so): New.\n\t($(objpfx)tst-x86_64-1): Likewise.\n\t($(objpfx)x86_64/tst-x86_64mod-1.os): Likewise.\n\t(tst-x86_64-1-clean): Likewise.\n\t* sysdeps/x86_64/tst-x86_64-1.c: New file.\n\t* sysdeps/x86_64/tst-x86_64mod-1.c: Likewise.\n---\n sysdeps/x86/cpu-features.c       |  3 ++-\n sysdeps/x86/dl-hwcap.h           | 12 +++++++-----\n sysdeps/x86/dl-procinfo.c        |  4 ++--\n sysdeps/x86_64/Makefile          | 17 +++++++++++++++++\n sysdeps/x86_64/tst-x86_64-1.c    | 26 ++++++++++++++++++++++++++\n sysdeps/x86_64/tst-x86_64mod-1.c | 22 ++++++++++++++++++++++\n 6 files changed, 76 insertions(+), 8 deletions(-)\n create mode 100644 sysdeps/x86_64/tst-x86_64-1.c\n create mode 100644 sysdeps/x86_64/tst-x86_64mod-1.c","diff":"diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c\nindex 6f900840d4..c267f17b76 100644\n--- a/sysdeps/x86/cpu-features.c\n+++ b/sysdeps/x86/cpu-features.c\n@@ -336,7 +336,6 @@ no_cpuid:\n \n   /* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86.  */\n   GLRO(dl_platform) = NULL;\n-  GLRO(dl_hwcap) = 0;\n #if !HAVE_TUNABLES && defined SHARED\n   /* The glibc.tune.hwcap_mask tunable is initialized already, so no need to do\n      this.  */\n@@ -344,6 +343,7 @@ no_cpuid:\n #endif\n \n #ifdef __x86_64__\n+  GLRO(dl_hwcap) = HWCAP_X86_64;\n   if (cpu_features->kind == arch_kind_intel)\n     {\n       if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable)\n@@ -374,6 +374,7 @@ no_cpuid:\n \tGLRO(dl_platform) = \"haswell\";\n     }\n #else\n+  GLRO(dl_hwcap) = 0;\n   if (CPU_FEATURES_CPU_P (cpu_features, SSE2))\n     GLRO(dl_hwcap) |= HWCAP_X86_SSE2;\n \ndiff --git a/sysdeps/x86/dl-hwcap.h b/sysdeps/x86/dl-hwcap.h\nindex c95668415a..38627e9eef 100644\n--- a/sysdeps/x86/dl-hwcap.h\n+++ b/sysdeps/x86/dl-hwcap.h\n@@ -24,15 +24,16 @@\n # define HWCAP_PLATFORMS_START\t0\n # define HWCAP_PLATFORMS_COUNT\t4\n # define HWCAP_START\t\t0\n-# define HWCAP_COUNT\t\t2\n-# define HWCAP_IMPORTANT\t(HWCAP_X86_SSE2 | HWCAP_X86_AVX512_1)\n+# define HWCAP_COUNT\t\t3\n+# define HWCAP_IMPORTANT \\\n+  (HWCAP_X86_SSE2 | HWCAP_X86_64 | HWCAP_X86_AVX512_1)\n #elif defined __x86_64__\n /* For 64 bit, only cover x86-64 platforms and capabilities.  */\n # define HWCAP_PLATFORMS_START\t2\n # define HWCAP_PLATFORMS_COUNT\t4\n # define HWCAP_START\t\t1\n-# define HWCAP_COUNT\t\t2\n-# define HWCAP_IMPORTANT\t(HWCAP_X86_AVX512_1)\n+# define HWCAP_COUNT\t\t3\n+# define HWCAP_IMPORTANT\t(HWCAP_X86_64 | HWCAP_X86_AVX512_1)\n #else\n /* For 32 bit, only cover i586, i686 and SSE2.  */\n # define HWCAP_PLATFORMS_START\t0\n@@ -45,7 +46,8 @@\n enum\n {\n   HWCAP_X86_SSE2\t\t= 1 << 0,\n-  HWCAP_X86_AVX512_1\t\t= 1 << 1\n+  HWCAP_X86_64\t\t\t= 1 << 1,\n+  HWCAP_X86_AVX512_1\t\t= 1 << 2\n };\n \n static inline const char *\ndiff --git a/sysdeps/x86/dl-procinfo.c b/sysdeps/x86/dl-procinfo.c\nindex 43ab8fe25b..0192feb850 100644\n--- a/sysdeps/x86/dl-procinfo.c\n+++ b/sysdeps/x86/dl-procinfo.c\n@@ -58,11 +58,11 @@ PROCINFO_CLASS struct cpu_features _dl_x86_cpu_features\n #if !defined PROCINFO_DECL && defined SHARED\n   ._dl_x86_hwcap_flags\n #else\n-PROCINFO_CLASS const char _dl_x86_hwcap_flags[2][9]\n+PROCINFO_CLASS const char _dl_x86_hwcap_flags[3][9]\n #endif\n #ifndef PROCINFO_DECL\n = {\n-    \"sse2\", \"avx512_1\"\n+    \"sse2\", \"x86_64\", \"avx512_1\"\n   }\n #endif\n #if !defined SHARED || defined PROCINFO_DECL\ndiff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile\nindex 7f3ffe34ba..1514805f4a 100644\n--- a/sysdeps/x86_64/Makefile\n+++ b/sysdeps/x86_64/Makefile\n@@ -52,6 +52,12 @@ $(objpfx)tst-quad2pie: $(objpfx)tst-quadmod2pie.o\n CFLAGS-tst-quad1pie.c = $(PIE-ccflag)\n CFLAGS-tst-quad2pie.c = $(PIE-ccflag)\n \n+tests += tst-x86_64-1\n+modules-names += x86_64/tst-x86_64mod-1\n+LDFLAGS-tst-x86_64mod-1.so = -Wl,-soname,tst-x86_64mod-1.so\n+\n+$(objpfx)tst-x86_64-1: $(objpfx)x86_64/tst-x86_64mod-1.so\n+\n tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \\\n \t tst-audit10 tst-sse tst-avx tst-avx512\n test-extras += tst-audit4-aux tst-audit10-aux \\\n@@ -124,3 +130,14 @@ endif\n ifeq ($(subdir),csu)\n gen-as-const-headers += tlsdesc.sym rtld-offsets.sym\n endif\n+\n+$(objpfx)x86_64/tst-x86_64mod-1.os: $(objpfx)tst-x86_64mod-1.os\n+\t$(make-target-directory)\n+\trm -f $@\n+\tln $< $@\n+\n+do-tests-clean common-mostlyclean: tst-x86_64-1-clean\n+\n+.PHONY: tst-x86_64-1-clean\n+tst-x86_64-1-clean:\n+\t-rm -rf $(objpfx)x86_64\ndiff --git a/sysdeps/x86_64/tst-x86_64-1.c b/sysdeps/x86_64/tst-x86_64-1.c\nnew file mode 100644\nindex 0000000000..ba1a55cdaf\n--- /dev/null\n+++ b/sysdeps/x86_64/tst-x86_64-1.c\n@@ -0,0 +1,26 @@\n+/* Test searching the \"x86_64\" directory for shared libraries.\n+   Copyright (C) 2017 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <http://www.gnu.org/licenses/>.  */\n+\n+extern void foo (void);\n+\n+int\n+main (void)\n+{\n+  foo ();\n+  return 0;\n+}\ndiff --git a/sysdeps/x86_64/tst-x86_64mod-1.c b/sysdeps/x86_64/tst-x86_64mod-1.c\nnew file mode 100644\nindex 0000000000..83dfafb5a8\n--- /dev/null\n+++ b/sysdeps/x86_64/tst-x86_64mod-1.c\n@@ -0,0 +1,22 @@\n+/* Test searching the \"x86_64\" directory for shared libraries.\n+   Copyright (C) 2017 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <http://www.gnu.org/licenses/>.  */\n+\n+void\n+foo (void)\n+{\n+}\n","prefixes":[]}