backport patch from glibc upstream 2.38 branch.

here is the bugfix:
- x86_64: Optimize ffsll function code size
- S390: Fix building with disable mutli arch (BZ 31196)
- sparc: Fix broken memset for sparc32 (BZ 31068)
- sparc: Remove unwind information from signal return
- sparc: Fix sparc64 memmove length comparison (BZ 31266)
- sparc: Remove unwind information from signal return stubs (BZ 31244)
This commit is contained in:
liqingqing_1229 2024-02-05 14:46:39 +08:00
parent e958cab628
commit ddb1b4b4a4
7 changed files with 322 additions and 1 deletions

View File

@ -0,0 +1,66 @@
From 18876c9ff52c3d9aefe2c663b1a287589bebedc0 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Tue, 30 Jan 2024 09:34:32 +0100
Subject: [PATCH 2/6] S390: Fix building with --disable-mutli-arch [BZ #31196]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Starting with commits
- 7ea510127e2067efa07865158ac92c330c379950
string: Add libc_hidden_proto for strchrnul
- 22999b2f0fb62eed1af4095d062bd1272d6afeb1
string: Add libc_hidden_proto for memrchr
building glibc on s390x with --disable-multi-arch fails if only
the C-variant of strchrnul / memrchr is used. This is the case
if gcc uses -march < z13.
The build fails with:
../sysdeps/s390/strchrnul-c.c:28:49: error: __strchrnul_c undeclared here (not in a function); did you mean __strchrnul?
28 | __hidden_ver1 (__strchrnul_c, __GI___strchrnul, __strchrnul_c);
With --disable-multi-arch, __strchrnul_c is not available as string/strchrnul.c
is just included without defining STRCHRNUL and thus we also don't have to create
the internal hidden symbol.
Tested-by: Andreas K. Hüttel <dilfridge@gentoo.org>
(cherry picked from commit cc1b91eabd806057aa7e3058a84bf129ed36e157)
---
sysdeps/s390/memrchr-c.c | 4 +++-
sysdeps/s390/strchrnul-c.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sysdeps/s390/memrchr-c.c b/sysdeps/s390/memrchr-c.c
index bdf3c7bbe0..fadd63087a 100644
--- a/sysdeps/s390/memrchr-c.c
+++ b/sysdeps/s390/memrchr-c.c
@@ -25,7 +25,9 @@
# include <string/memrchr.c>
-# if defined SHARED && IS_IN (libc)
+# if HAVE_MEMRCHR_IFUNC
+# if defined SHARED && IS_IN (libc)
__hidden_ver1 (__memrchr_c, __GI___memrchr, __memrchr_c);
+# endif
# endif
#endif
diff --git a/sysdeps/s390/strchrnul-c.c b/sysdeps/s390/strchrnul-c.c
index f6f5bae311..97fbc16edb 100644
--- a/sysdeps/s390/strchrnul-c.c
+++ b/sysdeps/s390/strchrnul-c.c
@@ -24,7 +24,9 @@
# endif
# include <string/strchrnul.c>
-# if defined SHARED && IS_IN (libc)
+# if HAVE_STRCHRNUL_IFUNC
+# if defined SHARED && IS_IN (libc)
__hidden_ver1 (__strchrnul_c, __GI___strchrnul, __strchrnul_c);
+# endif
# endif
#endif
--
2.33.0

View File

@ -67,7 +67,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.38 Version: 2.38
Release: 19 Release: 20
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -133,6 +133,12 @@ Patch44: malloc-Improve-MAP_HUGETLB-with-glibc.malloc.hugetlb.patch
Patch45: 0001-syslog-Fix-heap-buffer-overflow-in-__vsyslog_interna.patch Patch45: 0001-syslog-Fix-heap-buffer-overflow-in-__vsyslog_interna.patch
Patch46: 0002-syslog-Fix-heap-buffer-overflow-in-__vsyslog_interna.patch Patch46: 0002-syslog-Fix-heap-buffer-overflow-in-__vsyslog_interna.patch
Patch47: 0003-syslog-Fix-integer-overflow-in-__vsyslog_internal-CV.patch Patch47: 0003-syslog-Fix-integer-overflow-in-__vsyslog_internal-CV.patch
Patch48: x86_64-Optimize-ffsll-function-code-size.patch
Patch49: S390-Fix-building-with-disable-mutli-arch-BZ-31196.patch
Patch50: sparc-Fix-broken-memset-for-sparc32-BZ-31068.patch
Patch51: sparc64-Remove-unwind-information-from-signal-return.patch
Patch52: sparc-Fix-sparc64-memmove-length-comparison-BZ-31266.patch
Patch53: sparc-Remove-unwind-information-from-signal-return-s.patch
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch
Patch9001: locale-delete-no-hard-link-to-avoid-all_language-pac.patch Patch9001: locale-delete-no-hard-link-to-avoid-all_language-pac.patch
@ -1346,6 +1352,14 @@ fi
%endif %endif
%changelog %changelog
* Mon Feb 5 Qingqing Li <liqingqing3@huawei.com> - 2.38-20
- x86_64: Optimize ffsll function code size
- S390: Fix building with disable mutli arch (BZ 31196)
- sparc: Fix broken memset for sparc32 (BZ 31068)
- sparc: Remove unwind information from signal return
- sparc: Fix sparc64 memmove length comparison (BZ 31266)
- sparc: Remove unwind information from signal return stubs (BZ 31244)
* Thu Feb 1 Hewenliang <hewenliang4@huawei.com> - 2.38-19 * Thu Feb 1 Hewenliang <hewenliang4@huawei.com> - 2.38-19
- backport:fix CVE-2023-6779 CVE-2023-6780 - backport:fix CVE-2023-6779 CVE-2023-6780

View File

@ -0,0 +1,43 @@
From 6f68075869f6034f5fde3823741623d34164dc7d Mon Sep 17 00:00:00 2001
From: Andreas Larsson <andreas@gaisler.com>
Date: Wed, 15 Nov 2023 13:29:43 +0100
Subject: [PATCH 3/6] sparc: Fix broken memset for sparc32 [BZ #31068]
Fixes commit a61933fe27df ("sparc: Remove bzero optimization") that
after moving code jumped to the wrong label 4.
Verfied by successfully running string/test-memset on sparc32.
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 578190b7e43305141512dee777e4a3b3e8159393)
---
sysdeps/sparc/sparc32/memset.S | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sysdeps/sparc/sparc32/memset.S b/sysdeps/sparc/sparc32/memset.S
index ca29ff5685..1dc3a640e8 100644
--- a/sysdeps/sparc/sparc32/memset.S
+++ b/sysdeps/sparc/sparc32/memset.S
@@ -55,7 +55,7 @@ ENTRY(memset)
andcc %o0, 3, %o2
bne 3f
-4: andcc %o0, 4, %g0
+5: andcc %o0, 4, %g0
be 2f
mov %g3, %g2
@@ -139,7 +139,7 @@ ENTRY(memset)
stb %g3, [%o0 + 0x02]
2: sub %o2, 4, %o2
add %o1, %o2, %o1
- b 4b
+ b 5b
sub %o0, %o2, %o0
END(memset)
libc_hidden_builtin_def (memset)
--
2.33.0

View File

@ -0,0 +1,32 @@
From aac57faf5425b472a72132b09f4b3a2aa1f77a63 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu, 18 Jan 2024 10:52:18 -0300
Subject: [PATCH 5/6] sparc: Fix sparc64 memmove length comparison (BZ 31266)
The small counts copy bytes comparsion should be unsigned (as the
memmove size argument). It fixes string/tst-memmove-overflow on
sparcv9, where the input size triggers an invalid code path.
Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
(cherry picked from commit 926a4bdbb5fc8955570208b5571b2d04c6ffbd1d)
---
sysdeps/sparc/sparc64/memmove.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/sparc/sparc64/memmove.S b/sysdeps/sparc/sparc64/memmove.S
index db6f4f0e84..62b19ebc1b 100644
--- a/sysdeps/sparc/sparc64/memmove.S
+++ b/sysdeps/sparc/sparc64/memmove.S
@@ -38,7 +38,7 @@ ENTRY(memmove)
/*
* normal, copy forwards
*/
-2: ble %XCC, .Ldbytecp
+2: bleu %XCC, .Ldbytecp
andcc %o1, 3, %o5 /* is src word aligned */
bz,pn %icc, .Laldst
cmp %o5, 2 /* is src half-word aligned */
--
2.33.0

View File

@ -0,0 +1,74 @@
From 0c5e5bace57578ed3e28eb89ee2d2b31b74c4ecc Mon Sep 17 00:00:00 2001
From: Daniel Cederman <cederman@gaisler.com>
Date: Tue, 16 Jan 2024 09:31:41 +0100
Subject: [PATCH 6/6] sparc: Remove unwind information from signal return stubs
[BZ #31244]
The functions were previously written in C, but were not compiled
with unwind information. The ENTRY/END macros includes .cfi_startproc
and .cfi_endproc which adds unwind information. This caused the
tests cleanup-8 and cleanup-10 in the GCC testsuite to fail.
This patch adds a version of the ENTRY/END macros without the
CFI instructions that can be used instead.
sigaction registers a restorer address that is located two instructions
before the stub function. This patch adds a two instruction padding to
avoid that the unwinder accesses the unwind information from the function
that the linker has placed right before it in memory. This fixes an issue
with pthread_cancel that caused tst-mutex8-static (and other tests) to fail.
Signed-off-by: Daniel Cederman <cederman@gaisler.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 7bd06985c0a143cdcba2762bfe020e53514a53de)
---
sysdeps/sparc/sysdep.h | 9 +++++++++
.../unix/sysv/linux/sparc/sparc32/sigreturn_stub.S | 11 +++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/sysdeps/sparc/sysdep.h b/sysdeps/sparc/sysdep.h
index 687e626182..151baa5e10 100644
--- a/sysdeps/sparc/sysdep.h
+++ b/sysdeps/sparc/sysdep.h
@@ -76,6 +76,15 @@ C_LABEL(name) \
cfi_endproc; \
.size name, . - name
+#define ENTRY_NOCFI(name) \
+ .align 4; \
+ .global C_SYMBOL_NAME(name); \
+ .type name, @function; \
+C_LABEL(name)
+
+#define END_NOCFI(name) \
+ .size name, . - name
+
#undef LOC
#define LOC(name) .L##name
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S b/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S
index cf509c8d5c..1962f9053c 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sigreturn_stub.S
@@ -23,12 +23,15 @@
[1] https://lkml.org/lkml/2016/5/27/465 */
-ENTRY (__rt_sigreturn_stub)
+ nop
+ nop
+
+ENTRY_NOCFI (__rt_sigreturn_stub)
mov __NR_rt_sigreturn, %g1
ta 0x10
-END (__rt_sigreturn_stub)
+END_NOCFI (__rt_sigreturn_stub)
-ENTRY (__sigreturn_stub)
+ENTRY_NOCFI (__sigreturn_stub)
mov __NR_sigreturn, %g1
ta 0x10
-END (__sigreturn_stub)
+END_NOCFI (__sigreturn_stub)
--
2.33.0

View File

@ -0,0 +1,42 @@
From 0e383d2d4e7c08b36ad3edb30c072a3dc4d26ed8 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 17 Jan 2024 10:38:09 -0300
Subject: [PATCH 4/6] sparc64: Remove unwind information from signal return
stubs [BZ#31244]
Similar to sparc32 fix, remove the unwind information on the signal
return stubs. This fixes the regressions:
FAIL: nptl/tst-cancel24-static
FAIL: nptl/tst-cond8-static
FAIL: nptl/tst-mutex8-static
FAIL: nptl/tst-mutexpi8-static
FAIL: nptl/tst-mutexpi9
On sparc64-linux-gnu.
(cherry picked from commit 369efd817780276dbe0ecf8be6e1f354bdbc9857)
---
sysdeps/unix/sysv/linux/sparc/sparc64/sigreturn_stub.S | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigreturn_stub.S b/sysdeps/unix/sysv/linux/sparc/sparc64/sigreturn_stub.S
index 7fac04f657..f089bcaf68 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigreturn_stub.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sigreturn_stub.S
@@ -23,7 +23,10 @@
[1] https://lkml.org/lkml/2016/5/27/465 */
-ENTRY (__rt_sigreturn_stub)
+ nop
+ nop
+
+ENTRY_NOCFI (__rt_sigreturn_stub)
mov __NR_rt_sigreturn, %g1
ta 0x6d
-END (__rt_sigreturn_stub)
+END_NOCFI (__rt_sigreturn_stub)
--
2.33.0

View File

@ -0,0 +1,50 @@
From 30e546d76e756fe4d2d20a8b2286de4fbf30ceb5 Mon Sep 17 00:00:00 2001
From: Sunil K Pandey <skpgkp2@gmail.com>
Date: Wed, 26 Jul 2023 08:34:05 -0700
Subject: [PATCH 1/6] x86_64: Optimize ffsll function code size.
Ffsll function randomly regress by ~20%, depending on how code gets
aligned in memory. Ffsll function code size is 17 bytes. Since default
function alignment is 16 bytes, it can load on 16, 32, 48 or 64 bytes
aligned memory. When ffsll function load at 16, 32 or 64 bytes aligned
memory, entire code fits in single 64 bytes cache line. When ffsll
function load at 48 bytes aligned memory, it splits in two cache line,
hence random regression.
Ffsll function size reduction from 17 bytes to 12 bytes ensures that it
will always fit in single 64 bytes cache line.
This patch fixes ffsll function random performance regression.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 9d94997b5f9445afd4f2bccc5fa60ff7c4361ec1)
---
sysdeps/x86_64/ffsll.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sysdeps/x86_64/ffsll.c b/sysdeps/x86_64/ffsll.c
index a1c13d4906..0c6680735c 100644
--- a/sysdeps/x86_64/ffsll.c
+++ b/sysdeps/x86_64/ffsll.c
@@ -26,13 +26,13 @@ int
ffsll (long long int x)
{
long long int cnt;
- long long int tmp;
- asm ("bsfq %2,%0\n" /* Count low bits in X and store in %1. */
- "cmoveq %1,%0\n" /* If number was zero, use -1 as result. */
- : "=&r" (cnt), "=r" (tmp) : "rm" (x), "1" (-1));
+ asm ("mov $-1,%k0\n" /* Initialize cnt to -1. */
+ "bsf %1,%0\n" /* Count low bits in x and store in cnt. */
+ "inc %k0\n" /* Increment cnt by 1. */
+ : "=&r" (cnt) : "r" (x));
- return cnt + 1;
+ return cnt;
}
#ifndef __ILP32__
--
2.33.0