From 0181291385671286db5eefc5eea9913c647f14d8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 30 Jun 2009 04:39:09 -0700 Subject: Determine and store processor family and model on x86-64. --- ChangeLog | 10 ++++++++ sysdeps/x86_64/multiarch/ifunc-defines.sym | 2 ++ sysdeps/x86_64/multiarch/init-arch.c | 37 +++++++++++++++++++++++------- sysdeps/x86_64/multiarch/init-arch.h | 2 ++ 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff4e26ad67..7a25874b73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-06-26 H.J. Lu + + * sysdeps/x86_64/multiarch/ifunc-defines.sym (FAMILIY_OFFSET): Define. + (MODEL_OFFSET): Define. + * sysdeps/x86_64/multiarch/init-arch.h (cpu_features): Add + family and model. + * sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): Break + out common code into new function get_common_indeces. Determine + extended family and model for Intel processors. + 2009-06-26 Ulrich Drepper * resolv/resolv.h: Define RES_SNGLKUPREOP. diff --git a/sysdeps/x86_64/multiarch/ifunc-defines.sym b/sysdeps/x86_64/multiarch/ifunc-defines.sym index 48d1287246..e2021cdf87 100644 --- a/sysdeps/x86_64/multiarch/ifunc-defines.sym +++ b/sysdeps/x86_64/multiarch/ifunc-defines.sym @@ -11,5 +11,7 @@ CPUID_EAX_OFFSET offsetof (struct cpuid_registers, eax) CPUID_EBX_OFFSET offsetof (struct cpuid_registers, ebx) CPUID_ECX_OFFSET offsetof (struct cpuid_registers, ecx) CPUID_EDX_OFFSET offsetof (struct cpuid_registers, edx) +FAMILY_OFFSET offsetof (struct cpu_features, family) +MODEL_OFFSET offsetof (struct cpu_features, model) COMMON_CPUID_INDEX_1 diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c index ec0eb29faf..d559331d70 100644 --- a/sysdeps/x86_64/multiarch/init-arch.c +++ b/sysdeps/x86_64/multiarch/init-arch.c @@ -24,6 +24,22 @@ struct cpu_features __cpu_features attribute_hidden; +static void +get_common_indeces (void) +{ + asm volatile ("cpuid" + : "=a" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax), + "=b" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx), + "=c" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx), + "=d" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx) + : "0" (1)); + + unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax; + __cpu_features.family = (eax >> 8) & 0x0f; + __cpu_features.model = (eax >> 4) & 0x0f; +} + + void __init_cpu_features (void) { @@ -41,20 +57,25 @@ __init_cpu_features (void) { __cpu_features.kind = arch_kind_intel; - get_common_cpuid: - asm volatile ("cpuid" - : "=a" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax), - "=b" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx), - "=c" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx), - "=d" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx) - : "0" (1)); + get_common_indeces (); + + unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax; + unsigned int extended_family = (eax >> 20) & 0xff; + unsigned int extended_model = (eax >> 12) & 0xf0; + if (family == 0x0f) + { + __cpu_features.family += extended_family; + __cpu_features.model += extended_model; + } + else if (family == 0x06) + __cpu_features.model += extended_model; } /* This spells out "AuthenticAMD". */ else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) { __cpu_features.kind = arch_kind_amd; - goto get_common_cpuid; + get_common_indeces (); } else __cpu_features.kind = arch_kind_other; diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h index 5c4892de38..48a2127418 100644 --- a/sysdeps/x86_64/multiarch/init-arch.h +++ b/sysdeps/x86_64/multiarch/init-arch.h @@ -42,6 +42,8 @@ extern struct cpu_features unsigned int ecx; unsigned int edx; } cpuid[COMMON_CPUID_INDEX_MAX]; + unsigned int family; + unsigned int model; } __cpu_features attribute_hidden; -- cgit v1.2.3-70-g09d2 From b38a2e2e642c0a0884a2d77e38eecf3cbe7720fd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 30 Jun 2009 04:41:38 -0700 Subject: Fix little checkin problem in last patch. --- sysdeps/x86_64/multiarch/init-arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c index d559331d70..29e687344d 100644 --- a/sysdeps/x86_64/multiarch/init-arch.c +++ b/sysdeps/x86_64/multiarch/init-arch.c @@ -62,12 +62,12 @@ __init_cpu_features (void) unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax; unsigned int extended_family = (eax >> 20) & 0xff; unsigned int extended_model = (eax >> 12) & 0xf0; - if (family == 0x0f) + if (__cpu_features.family == 0x0f) { __cpu_features.family += extended_family; __cpu_features.model += extended_model; } - else if (family == 0x06) + else if (__cpu_features.family == 0x06) __cpu_features.model += extended_model; } /* This spells out "AuthenticAMD". */ -- cgit v1.2.3-70-g09d2 From e6bd12ddf72412918fe9002a3e27ecc07775bd64 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 30 Jun 2009 05:33:52 -0700 Subject: Regenerated. --- sysdeps/x86_64/elf/configure | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/sysdeps/x86_64/elf/configure b/sysdeps/x86_64/elf/configure index 7a2e3004a5..774654997d 100755 --- a/sysdeps/x86_64/elf/configure +++ b/sysdeps/x86_64/elf/configure @@ -1,12 +1,44 @@ +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + # This file is generated from configure.in by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/x86_64/elf. if test "$usetls" != no; then # Check for support of thread-local storage handling in assembler and linker. -{ echo "$as_me:$LINENO: checking for x86-64 TLS support" >&5 -echo $ECHO_N "checking for x86-64 TLS support... $ECHO_C" >&6; } +{ $as_echo "$as_me:$LINENO: checking for x86-64 TLS support" >&5 +$as_echo_n "checking for x86-64 TLS support... " >&6; } if test "${libc_cv_x86_64_tls+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + $as_echo_n "(cached) " >&6 else cat > conftest.s <<\EOF .section ".tdata", "awT", @progbits @@ -25,7 +57,7 @@ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then libc_cv_x86_64_tls=yes else @@ -33,8 +65,8 @@ else fi rm -f conftest* fi -{ echo "$as_me:$LINENO: result: $libc_cv_x86_64_tls" >&5 -echo "${ECHO_T}$libc_cv_x86_64_tls" >&6; } +{ $as_echo "$as_me:$LINENO: result: $libc_cv_x86_64_tls" >&5 +$as_echo "$libc_cv_x86_64_tls" >&6; } if test $libc_cv_x86_64_tls = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_TLS_SUPPORT 1 -- cgit v1.2.3-70-g09d2 From 29ba9812bb86bf6da9702f4fbff5cdbb25846401 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 1 Jul 2009 02:42:59 -0700 Subject: Fix getnetbyaddr implementation. There were two problems in the getnetbyaddr implementation. The type argument is pretty much useless since (almost) no input file contains this information and the NSS backends make up the value they fill in for the n_addrtype field. Therefore we now declare that passing AF_UNSPEC is always recognized. Secondly, the files backend didn't compare the network numbers with the correct endianess. Also change getent to take advantage of the type parameter change. --- ChangeLog | 7 +++++++ nss/getent.c | 2 +- nss/nss_files/files-network.c | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a25874b73..714d114d5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-07-01 Ulrich Drepper + + * nss/nss_files/files-network.c (netbyaddr): If type is AF_UNSPEC, + recognize all types. Fix endianess in comparison of network number. + * nss/getent.c (networks_keys): Pass AF_UNSPEC instead of AF_UNIX + to getnetbyaddr. + 2009-06-26 H.J. Lu * sysdeps/x86_64/multiarch/ifunc-defines.sym (FAMILIY_OFFSET): Define. diff --git a/nss/getent.c b/nss/getent.c index 3a9430fd66..3a482e140f 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -534,7 +534,7 @@ networks_keys (int number, char *key[]) for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) - net = getnetbyaddr (inet_addr (key[i]), AF_UNIX); + net = getnetbyaddr (inet_addr (key[i]), AF_UNSPEC); else net = getnetbyname (key[i]); diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c index 9f4a3e0324..064de5a143 100644 --- a/nss/nss_files/files-network.c +++ b/nss/nss_files/files-network.c @@ -1,5 +1,5 @@ /* Networks file parser in nss_files module. - Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996-1998, 2000, 2001, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -81,7 +81,8 @@ DB_LOOKUP (netbyname, ,, DB_LOOKUP (netbyaddr, ,, { - if (result->n_addrtype == type && result->n_net == net) + if ((type == AF_UNSPEC || result->n_addrtype == type) + && result->n_net == htonl (net)) /* Bingo! */ break; }, uint32_t net, int type) -- cgit v1.2.3-70-g09d2 From 5cd1f906c34256abdccc92052fbbde51fd70a565 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 1 Jul 2009 03:33:26 -0700 Subject: Fix getent networks lookup and resulting incorrect NSS change. I changed the files NSS backend for networks because I thought the getent use of getnetbyaddr is correct. But it isn't. Undo parts of the last change and fix getent. --- ChangeLog | 5 +++-- nss/getent.c | 2 +- nss/nss_files/files-network.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 714d114d5e..6dfd700637 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,10 @@ 2009-07-01 Ulrich Drepper * nss/nss_files/files-network.c (netbyaddr): If type is AF_UNSPEC, - recognize all types. Fix endianess in comparison of network number. + recognize all types. * nss/getent.c (networks_keys): Pass AF_UNSPEC instead of AF_UNIX - to getnetbyaddr. + to getnetbyaddr. Fix network parameter to getnetbyaddr. It must + be in host byte order. 2009-06-26 H.J. Lu diff --git a/nss/getent.c b/nss/getent.c index 3a482e140f..d70a8da0f4 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -534,7 +534,7 @@ networks_keys (int number, char *key[]) for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) - net = getnetbyaddr (inet_addr (key[i]), AF_UNSPEC); + net = getnetbyaddr (ntohl (inet_addr (key[i])), AF_UNSPEC); else net = getnetbyname (key[i]); diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c index 064de5a143..92aea75d9e 100644 --- a/nss/nss_files/files-network.c +++ b/nss/nss_files/files-network.c @@ -82,7 +82,7 @@ DB_LOOKUP (netbyname, ,, DB_LOOKUP (netbyaddr, ,, { if ((type == AF_UNSPEC || result->n_addrtype == type) - && result->n_net == htonl (net)) + && result->n_net == net) /* Bingo! */ break; }, uint32_t net, int type) -- cgit v1.2.3-70-g09d2 From 2fd0cd8b5257e7ae0c0df0651ee62a6ef7c37cc2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 1 Jul 2009 03:41:30 -0700 Subject: Fix NIS and NIS+ getnetbyaddr backends. The addresses were interpreted as class-based network addresses. --- ChangeLog | 5 +++++ nis/nss_nis/nis-network.c | 2 +- nis/nss_nisplus/nisplus-network.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dfd700637..0c6c36f472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-07-01 Ulrich Drepper + * nis/nss_nis/nis-network.c (_nss_nis_getnetbyaddr_r): Don't use + inet_makeaddr. This worked only with class-based networks. + * nis/nss_nisplus/nisplus-network.c (_nss_nisplus_getnetbyaddr_r): + Likewise. + * nss/nss_files/files-network.c (netbyaddr): If type is AF_UNSPEC, recognize all types. * nss/getent.c (networks_keys): Pass AF_UNSPEC instead of AF_UNIX diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c index 9b02302e0b..22a898bb21 100644 --- a/nis/nss_nis/nis-network.c +++ b/nis/nss_nis/nis-network.c @@ -241,7 +241,7 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net, if (__builtin_expect (yp_get_default_domain (&domain), 0)) return NSS_STATUS_UNAVAIL; - struct in_addr in = inet_makeaddr (addr, 0); + struct in_addr in = { .s_addr = htonl (addr) }; char *buf = inet_ntoa (in); size_t blen = strlen (buf); diff --git a/nis/nss_nisplus/nisplus-network.c b/nis/nss_nisplus/nisplus-network.c index 1cf652f071..902826b62a 100644 --- a/nis/nss_nisplus/nisplus-network.c +++ b/nis/nss_nisplus/nisplus-network.c @@ -433,7 +433,7 @@ _nss_nisplus_getnetbyaddr_r (uint32_t addr, const int type, char buf2[18]; int olderr = errno; - struct in_addr in = inet_makeaddr (addr, 0); + struct in_addr in = { .s_addr = htonl (addr) }; strcpy (buf2, inet_ntoa (in)); size_t b2len = strlen (buf2); -- cgit v1.2.3-70-g09d2