[v2,1/3] x86: Add new architecture type for Hygon processors

Message ID 1724050675-17136-2-git-send-email-wangfeifei@hygon.cn
State Committed
Commit 6b08116b2deab23c0f4c9688ff4aa6ca4483889c
Delegated to: H.J. Lu
Headers
Series x86: Add support for Hygon processors |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Feifei Wang Aug. 19, 2024, 6:57 a.m. UTC
  Add a new architecture type arch_kind_hygon to spilt Hygon branch
from AMD. This is to facilitate the Hygon processors to make settings
that are suitable for its own characteristics.

Signed-off-by: Feifei Wang <wangfeifei@hygon.cn>
Reviewed-by: Jing Li <lijing@hygon.cn>
---
 sysdeps/x86/cpu-features.c         | 19 ++++++++++++++++---
 sysdeps/x86/include/cpu-features.h |  1 +
 2 files changed, 17 insertions(+), 3 deletions(-)
  

Comments

H.J. Lu Aug. 24, 2024, 8:31 p.m. UTC | #1
On Sun, Aug 18, 2024 at 11:58 PM Feifei Wang <wangfeifei@hygon.cn> wrote:
>
> Add a new architecture type arch_kind_hygon to spilt Hygon branch
> from AMD. This is to facilitate the Hygon processors to make settings
> that are suitable for its own characteristics.
>
> Signed-off-by: Feifei Wang <wangfeifei@hygon.cn>
> Reviewed-by: Jing Li <lijing@hygon.cn>
> ---
>  sysdeps/x86/cpu-features.c         | 19 ++++++++++++++++---
>  sysdeps/x86/include/cpu-features.h |  1 +
>  2 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> index 0fb50f9432..e6139e2837 100644
> --- a/sysdeps/x86/cpu-features.c
> +++ b/sysdeps/x86/cpu-features.c
> @@ -986,9 +986,8 @@ https://www.intel.com/content/www/us/en/support/articles/000059422/processors.ht
>         cpu_features->preferred[index_arch_Avoid_Short_Distance_REP_MOVSB]
>           |= bit_arch_Avoid_Short_Distance_REP_MOVSB;
>      }
> -  /* This spells out "AuthenticAMD" or "HygonGenuine".  */
> -  else if ((ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
> -          || (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e))
> +  /* This spells out "AuthenticAMD".  */
> +  else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
>      {
>        unsigned int extended_model;
>
> @@ -1104,6 +1103,20 @@ https://www.intel.com/content/www/us/en/support/articles/000059422/processors.ht
>             }
>         }
>      }
> +  /* This spells out "HygonGenuine".  */
> +  else if (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e)
> +    {
> +      unsigned int extended_model;
> +
> +      kind = arch_kind_hygon;
> +
> +      get_common_indices (cpu_features, &family, &model, &extended_model,
> +                         &stepping);
> +
> +      get_extended_indices (cpu_features);
> +
> +      update_active (cpu_features);
> +    }
>    else
>      {
>        kind = arch_kind_other;
> diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h
> index aaae44f0e1..b8e790c8fd 100644
> --- a/sysdeps/x86/include/cpu-features.h
> +++ b/sysdeps/x86/include/cpu-features.h
> @@ -881,6 +881,7 @@ enum cpu_features_kind
>    arch_kind_intel,
>    arch_kind_amd,
>    arch_kind_zhaoxin,
> +  arch_kind_hygon,
>    arch_kind_other
>  };
>
> --
> 2.43.0
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.
  

Patch

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 0fb50f9432..e6139e2837 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -986,9 +986,8 @@  https://www.intel.com/content/www/us/en/support/articles/000059422/processors.ht
 	cpu_features->preferred[index_arch_Avoid_Short_Distance_REP_MOVSB]
 	  |= bit_arch_Avoid_Short_Distance_REP_MOVSB;
     }
-  /* This spells out "AuthenticAMD" or "HygonGenuine".  */
-  else if ((ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
-	   || (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e))
+  /* This spells out "AuthenticAMD".  */
+  else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
     {
       unsigned int extended_model;
 
@@ -1104,6 +1103,20 @@  https://www.intel.com/content/www/us/en/support/articles/000059422/processors.ht
 	    }
 	}
     }
+  /* This spells out "HygonGenuine".  */
+  else if (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e)
+    {
+      unsigned int extended_model;
+
+      kind = arch_kind_hygon;
+
+      get_common_indices (cpu_features, &family, &model, &extended_model,
+			  &stepping);
+
+      get_extended_indices (cpu_features);
+
+      update_active (cpu_features);
+    }
   else
     {
       kind = arch_kind_other;
diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h
index aaae44f0e1..b8e790c8fd 100644
--- a/sysdeps/x86/include/cpu-features.h
+++ b/sysdeps/x86/include/cpu-features.h
@@ -881,6 +881,7 @@  enum cpu_features_kind
   arch_kind_intel,
   arch_kind_amd,
   arch_kind_zhaoxin,
+  arch_kind_hygon,
   arch_kind_other
 };