public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
@ 2018-07-26 18:08 H.J. Lu
  2018-07-26 18:48 ` H.J. Lu
  2018-07-26 20:05 ` Carlos O'Donell
  0 siblings, 2 replies; 7+ messages in thread
From: H.J. Lu @ 2018-07-26 18:08 UTC (permalink / raw)
  To: libc-alpha

	[BZ #23459]
	* sysdeps/x86/cpu-features.c (get_extended_indeces): New
	function.
	(init_cpu_features): Call get_extended_indeces for both Intel
	and AMD CPUs.
---
 sysdeps/x86/cpu-features.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 8108256c42..f8beb96e51 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -42,6 +42,20 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *)
 # include <cet-tunables.h>
 #endif
 
+static void
+get_extended_indeces (struct cpu_features *cpu_features)
+{
+  unsigned int eax, ebx, ecx, edx;
+  __cpuid (0x80000000, eax, ebx, ecx, edx);
+  if (eax >= 0x80000001)
+    __cpuid (0x80000001,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
+
+}
+
 static void
 get_common_indeces (struct cpu_features *cpu_features,
 		    unsigned int *family, unsigned int *model,
@@ -224,6 +238,8 @@ init_cpu_features (struct cpu_features *cpu_features)
       get_common_indeces (cpu_features, &family, &model, &extended_model,
 			  &stepping);
 
+      get_extended_indeces (cpu_features);
+
       if (family == 0x06)
 	{
 	  model += extended_model;
@@ -338,16 +354,9 @@ init_cpu_features (struct cpu_features *cpu_features)
       get_common_indeces (cpu_features, &family, &model, &extended_model,
 			  &stepping);
 
-      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
+      get_extended_indeces (cpu_features);
 
-      unsigned int eax;
-      __cpuid (0x80000000, eax, ebx, ecx, edx);
-      if (eax >= 0x80000001)
-	__cpuid (0x80000001,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
+      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
 
       if (HAS_ARCH_FEATURE (AVX_Usable))
 	{
-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
  2018-07-26 18:08 [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459] H.J. Lu
@ 2018-07-26 18:48 ` H.J. Lu
  2018-07-26 20:05 ` Carlos O'Donell
  1 sibling, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2018-07-26 18:48 UTC (permalink / raw)
  To: GNU C Library

On Thu, Jul 26, 2018 at 11:07 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>         [BZ #23459]
>         * sysdeps/x86/cpu-features.c (get_extended_indeces): New
>         function.
>         (init_cpu_features): Call get_extended_indeces for both Intel
>         and AMD CPUs.
> ---
>  sysdeps/x86/cpu-features.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> index 8108256c42..f8beb96e51 100644
> --- a/sysdeps/x86/cpu-features.c
> +++ b/sysdeps/x86/cpu-features.c
> @@ -42,6 +42,20 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *)
>  # include <cet-tunables.h>
>  #endif
>
> +static void
> +get_extended_indeces (struct cpu_features *cpu_features)
> +{
> +  unsigned int eax, ebx, ecx, edx;
> +  __cpuid (0x80000000, eax, ebx, ecx, edx);
> +  if (eax >= 0x80000001)
> +    __cpuid (0x80000001,
> +            cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
> +            cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
> +            cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
> +            cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
> +
> +}
> +
>  static void
>  get_common_indeces (struct cpu_features *cpu_features,
>                     unsigned int *family, unsigned int *model,
> @@ -224,6 +238,8 @@ init_cpu_features (struct cpu_features *cpu_features)
>        get_common_indeces (cpu_features, &family, &model, &extended_model,
>                           &stepping);
>
> +      get_extended_indeces (cpu_features);
> +
>        if (family == 0x06)
>         {
>           model += extended_model;
> @@ -338,16 +354,9 @@ init_cpu_features (struct cpu_features *cpu_features)
>        get_common_indeces (cpu_features, &family, &model, &extended_model,
>                           &stepping);
>
> -      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
> +      get_extended_indeces (cpu_features);
>
> -      unsigned int eax;
> -      __cpuid (0x80000000, eax, ebx, ecx, edx);
> -      if (eax >= 0x80000001)
> -       __cpuid (0x80000001,
> -                cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
> -                cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
> -                cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
> -                cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
> +      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
>
>        if (HAS_ARCH_FEATURE (AVX_Usable))
>         {
> --
> 2.17.1
>

enum
  {
    COMMON_CPUID_INDEX_1 = 0,
    COMMON_CPUID_INDEX_7,
    COMMON_CPUID_INDEX_80000001,        /* for AMD */

 ^^^^^^^^^^^^  This should also be removed.
    /* Keep the following line at the end.  */
    COMMON_CPUID_INDEX_MAX
  };


-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
  2018-07-26 18:08 [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459] H.J. Lu
  2018-07-26 18:48 ` H.J. Lu
@ 2018-07-26 20:05 ` Carlos O'Donell
  2018-07-26 20:32   ` H.J. Lu
  1 sibling, 1 reply; 7+ messages in thread
From: Carlos O'Donell @ 2018-07-26 20:05 UTC (permalink / raw)
  To: H.J. Lu, libc-alpha

On 07/26/2018 02:07 PM, H.J. Lu wrote:
> 	[BZ #23459]
> 	* sysdeps/x86/cpu-features.c (get_extended_indeces): New
> 	function.
> 	(init_cpu_features): Call get_extended_indeces for both Intel
> 	and AMD CPUs.
> ---

OK for 2.28 after you fix the indexes v.s indices issue.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

>  sysdeps/x86/cpu-features.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> index 8108256c42..f8beb96e51 100644
> --- a/sysdeps/x86/cpu-features.c
> +++ b/sysdeps/x86/cpu-features.c
> @@ -42,6 +42,20 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *)
>  # include <cet-tunables.h>
>  #endif
>  
> +static void
> +get_extended_indeces (struct cpu_features *cpu_features)

get_extended_indices

or

get_extended_indexes

Your choice.

> +{
> +  unsigned int eax, ebx, ecx, edx;
> +  __cpuid (0x80000000, eax, ebx, ecx, edx);
> +  if (eax >= 0x80000001)
> +    __cpuid (0x80000001,
> +	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
> +	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
> +	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
> +	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);

OK.

> +
> +}
> +
>  static void
>  get_common_indeces (struct cpu_features *cpu_features,
>  		    unsigned int *family, unsigned int *model,
> @@ -224,6 +238,8 @@ init_cpu_features (struct cpu_features *cpu_features)
>        get_common_indeces (cpu_features, &family, &model, &extended_model,
>  			  &stepping);
>  
> +      get_extended_indeces (cpu_features);

OK (after rename).

> +
>        if (family == 0x06)
>  	{
>  	  model += extended_model;
> @@ -338,16 +354,9 @@ init_cpu_features (struct cpu_features *cpu_features)
>        get_common_indeces (cpu_features, &family, &model, &extended_model,
>  			  &stepping);
>  
> -      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
> +      get_extended_indeces (cpu_features);

OK (after rename).

>  
> -      unsigned int eax;
> -      __cpuid (0x80000000, eax, ebx, ecx, edx);
> -      if (eax >= 0x80000001)
> -	__cpuid (0x80000001,
> -		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
> -		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
> -		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
> -		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
> +      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;

OK.

>  
>        if (HAS_ARCH_FEATURE (AVX_Usable))
>  	{
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
  2018-07-26 20:05 ` Carlos O'Donell
@ 2018-07-26 20:32   ` H.J. Lu
  2018-07-26 20:37     ` Carlos O'Donell
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2018-07-26 20:32 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]

On Thu, Jul 26, 2018 at 1:05 PM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 07/26/2018 02:07 PM, H.J. Lu wrote:
>>       [BZ #23459]
>>       * sysdeps/x86/cpu-features.c (get_extended_indeces): New
>>       function.
>>       (init_cpu_features): Call get_extended_indeces for both Intel
>>       and AMD CPUs.
>> ---
>
> OK for 2.28 after you fix the indexes v.s indices issue.
>
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>

This is the patch I am checking in.

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-x86-Populate-COMMON_CPUID_INDEX_80000001-for-Intel-C.patch --]
[-- Type: text/x-patch, Size: 3010 bytes --]

From be525a69a6630abc83144c0a96474f2e26da7443 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 26 Jul 2018 10:49:19 -0700
Subject: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ
 #23459]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23459]
	* sysdeps/x86/cpu-features.c (get_extended_indices): New
	function.
	(init_cpu_features): Call get_extended_indices for both Intel
	and AMD CPUs.
	* sysdeps/x86/cpu-features.h (COMMON_CPUID_INDEX_80000001):
	Remove "for AMD" comment.
---
 sysdeps/x86/cpu-features.c | 27 ++++++++++++++++++---------
 sysdeps/x86/cpu-features.h |  2 +-
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 8108256c42..ea0b64fdb9 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -42,6 +42,20 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *)
 # include <cet-tunables.h>
 #endif
 
+static void
+get_extended_indices (struct cpu_features *cpu_features)
+{
+  unsigned int eax, ebx, ecx, edx;
+  __cpuid (0x80000000, eax, ebx, ecx, edx);
+  if (eax >= 0x80000001)
+    __cpuid (0x80000001,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
+	     cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
+
+}
+
 static void
 get_common_indeces (struct cpu_features *cpu_features,
 		    unsigned int *family, unsigned int *model,
@@ -224,6 +238,8 @@ init_cpu_features (struct cpu_features *cpu_features)
       get_common_indeces (cpu_features, &family, &model, &extended_model,
 			  &stepping);
 
+      get_extended_indices (cpu_features);
+
       if (family == 0x06)
 	{
 	  model += extended_model;
@@ -338,16 +354,9 @@ init_cpu_features (struct cpu_features *cpu_features)
       get_common_indeces (cpu_features, &family, &model, &extended_model,
 			  &stepping);
 
-      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
+      get_extended_indices (cpu_features);
 
-      unsigned int eax;
-      __cpuid (0x80000000, eax, ebx, ecx, edx);
-      if (eax >= 0x80000001)
-	__cpuid (0x80000001,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
-		 cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
+      ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx;
 
       if (HAS_ARCH_FEATURE (AVX_Usable))
 	{
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index 3807a9d611..347a4b118d 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -108,7 +108,7 @@ enum
   {
     COMMON_CPUID_INDEX_1 = 0,
     COMMON_CPUID_INDEX_7,
-    COMMON_CPUID_INDEX_80000001,	/* for AMD */
+    COMMON_CPUID_INDEX_80000001,
     /* Keep the following line at the end.  */
     COMMON_CPUID_INDEX_MAX
   };
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
  2018-07-26 20:32   ` H.J. Lu
@ 2018-07-26 20:37     ` Carlos O'Donell
  2018-07-27 13:43       ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Carlos O'Donell @ 2018-07-26 20:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

On 07/26/2018 04:32 PM, H.J. Lu wrote:
> On Thu, Jul 26, 2018 at 1:05 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>> On 07/26/2018 02:07 PM, H.J. Lu wrote:
>>>       [BZ #23459]
>>>       * sysdeps/x86/cpu-features.c (get_extended_indeces): New
>>>       function.
>>>       (init_cpu_features): Call get_extended_indeces for both Intel
>>>       and AMD CPUs.
>>> ---
>>
>> OK for 2.28 after you fix the indexes v.s indices issue.
>>
>> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>>
> 
> This is the patch I am checking in.

There are *many* incorrect spellings of indices too which you might
fix later ;-)

c.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
  2018-07-26 20:37     ` Carlos O'Donell
@ 2018-07-27 13:43       ` H.J. Lu
  2018-07-27 19:14         ` Carlos O'Donell
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2018-07-27 13:43 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: GNU C Library, Libc-stable Mailing List

On Thu, Jul 26, 2018 at 1:37 PM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 07/26/2018 04:32 PM, H.J. Lu wrote:
>> On Thu, Jul 26, 2018 at 1:05 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>>> On 07/26/2018 02:07 PM, H.J. Lu wrote:
>>>>       [BZ #23459]
>>>>       * sysdeps/x86/cpu-features.c (get_extended_indeces): New
>>>>       function.
>>>>       (init_cpu_features): Call get_extended_indeces for both Intel
>>>>       and AMD CPUs.
>>>> ---
>>>
>>> OK for 2.28 after you fix the indexes v.s indices issue.
>>>
>>> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>>>
>>
>> This is the patch I am checking in.
>
> There are *many* incorrect spellings of indices too which you might
> fix later ;-)
>

I'd like to backport these 2 patches to all affected branches.

-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
  2018-07-27 13:43       ` H.J. Lu
@ 2018-07-27 19:14         ` Carlos O'Donell
  0 siblings, 0 replies; 7+ messages in thread
From: Carlos O'Donell @ 2018-07-27 19:14 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Libc-stable Mailing List

On 07/27/2018 09:43 AM, H.J. Lu wrote:
> On Thu, Jul 26, 2018 at 1:37 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>> On 07/26/2018 04:32 PM, H.J. Lu wrote:
>>> On Thu, Jul 26, 2018 at 1:05 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>>>> On 07/26/2018 02:07 PM, H.J. Lu wrote:
>>>>>       [BZ #23459]
>>>>>       * sysdeps/x86/cpu-features.c (get_extended_indeces): New
>>>>>       function.
>>>>>       (init_cpu_features): Call get_extended_indeces for both Intel
>>>>>       and AMD CPUs.
>>>>> ---
>>>>
>>>> OK for 2.28 after you fix the indexes v.s indices issue.
>>>>
>>>> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>>>>
>>>
>>> This is the patch I am checking in.
>>
>> There are *many* incorrect spellings of indices too which you might
>> fix later ;-)
>>
> 
> I'd like to backport these 2 patches to all affected branches.

You can do that right away. Commits to stable can be backported to any
open stable branch so long as they don't have ABI/API implications.
Even if they changed the selected IFUNC it would still be OK.

You are free to cherry-pick as required. Please post your cherry-picks
to libc-stable and note that you're committing them to branch X, Y, and Z,
this way distros know what you're doing.

Cheers,
Carlos.
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-07-27 19:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 18:08 [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459] H.J. Lu
2018-07-26 18:48 ` H.J. Lu
2018-07-26 20:05 ` Carlos O'Donell
2018-07-26 20:32   ` H.J. Lu
2018-07-26 20:37     ` Carlos O'Donell
2018-07-27 13:43       ` H.J. Lu
2018-07-27 19:14         ` Carlos O'Donell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).