glibc/backport-x86-Add-Hygon-support.patch

39 lines
1.5 KiB
Diff
Raw Normal View History

From 2b46bc9b5a148f6da198321a8396a6c2c6a1b070 Mon Sep 17 00:00:00 2001
From: Feifei Wang1994 <wangfeifei@hygon.cn>
Date: Tue, 3 Sep 2024 08:30:43 +0000
Subject: [PATCH] backport-x86-Add-Hygon-support
This patch fix Hygon processor CPU Vendor ID detection problem
in glibc sysdep module, current glibc-2.28 doesn't recognize
Hygon CPU Vendor ID("HygonGenuine") and sets kind to arch_kind_other,
which result in incorrect zero value for __cache_sysconf() syscall.
This patch add Hygon CPU Vendor ID check, setup kind to arch_kind_amd
and reuse AMD code path, which lead to correct return value in __cache_sysconf() syscall.
Test case shows no failure with this patch in Hygon arch.
Signed-off-by: Feifei Wang <wangfeifei@hygon.cn>
---
sysdeps/x86/cpu-features.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index ea0b64fd..4b1a0169 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -344,8 +344,9 @@ init_cpu_features (struct cpu_features *cpu_features)
cpu_features->feature[index_arch_Prefer_No_AVX512]
|= bit_arch_Prefer_No_AVX512;
}
- /* This spells out "AuthenticAMD". */
- else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
+ /* This spells out "AuthenticAMD" or "HygonGenuine". */
+ else if ((ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
+ || (ebx == 0x6f677948 && ecx == 0x656e6975 && edx == 0x6e65476e))
{
unsigned int extended_model, stepping;
--
2.27.0