Processed: Re: [klibc] Bug#943425: Debian #943425: klibc: [s390x] setjmp/longjmp do not save/restore all registers in use

2021-05-05 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> tags 943425 + patch
Bug #943425 [libklibc-dev] klibc: [s390x] setjmp/longjmp do not save/restore 
all registers in use
Added tag(s) patch.
> tags 988027 + patch
Bug #988027 [libklibc-dev] klibc: sigsetjmp ignores second argument, siglongjmp 
always restores signals
Added tag(s) patch.
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
943425: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=943425
988027: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988027
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#943425: [klibc] Bug#943425: Debian #943425: klibc: [s390x] setjmp/longjmp do not save/restore all registers in use

2021-05-05 Thread Thorsten Glaser
tags 943425 + patch
tags 988027 + patch
thanks

Dixi quod…

>Patches for klibc upstream git attched; I’m currently trying to test
>them, will report.

This was really tricky given we can’t install patched B-Ds on
porterboxen, but I managed. I can confirm this fixes my issue.

bye,
//mirabilos
-- 
 Beware of ritual lest you forget the meaning behind it.
 yeah but it means if you really care about something, don't
ritualise it, or you will lose it. don't fetishise it, don't
obsess. or you'll forget why you love it in the first place.diff -Nru klibc-2.0.8/debian/changelog klibc-2.0.8/debian/changelog
--- klibc-2.0.8/debian/changelog2021-04-30 03:05:23.0 +0200
+++ klibc-2.0.8/debian/changelog2021-05-05 21:38:31.0 +0200
@@ -1,3 +1,11 @@
+klibc (2.0.8-6.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix sig{set,long}jmp always saves the signal mask (Closes: #988027)
+  * [s390x] Fix {set,long}jmp registers to save (Closes: #943425)
+
+ -- Thorsten Glaser   Wed, 05 May 2021 21:38:31 +0200
+
 klibc (2.0.8-6) unstable; urgency=medium
 
   * Upload to unstable
diff -Nru 
klibc-2.0.8/debian/patches/0001-klibc-sig-set-long-jmp-do-not-ignore-sigsetjmp-s-sec.patch
 
klibc-2.0.8/debian/patches/0001-klibc-sig-set-long-jmp-do-not-ignore-sigsetjmp-s-sec.patch
--- 
klibc-2.0.8/debian/patches/0001-klibc-sig-set-long-jmp-do-not-ignore-sigsetjmp-s-sec.patch
  1970-01-01 01:00:00.0 +0100
+++ 
klibc-2.0.8/debian/patches/0001-klibc-sig-set-long-jmp-do-not-ignore-sigsetjmp-s-sec.patch
  2021-05-05 21:38:31.0 +0200
@@ -0,0 +1,71 @@
+From ba9cce08553cb49fe077485b13ae99548bb2da5c Mon Sep 17 00:00:00 2001
+From: mirabilos 
+Date: Wed, 5 May 2021 21:02:37 +0200
+Subject: [PATCH 1/2] [klibc] sig{set,long}jmp: do not ignore sigsetjmp's
+ second argument
+
+Save and restore the signal mask only if that argument is nonzero,
+as required by the standards.  (Closes: Debian #988027)
+
+Signed-off-by: mirabilos 
+---
+ usr/include/setjmp.h   | 7 ++-
+ usr/klibc/CAVEATS  | 3 +--
+ usr/klibc/siglongjmp.c | 3 ++-
+ 3 files changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/usr/include/setjmp.h b/usr/include/setjmp.h
+index abebccde..5916cd8a 100644
+--- a/usr/include/setjmp.h
 b/usr/include/setjmp.h
+@@ -27,6 +27,7 @@ __extern __noreturn longjmp(jmp_buf, int);
+ struct __sigjmp_buf {
+   jmp_buf __jmpbuf;
+   sigset_t __sigs;
++  unsigned char __sigs_saved;
+ };
+ 
+ typedef struct __sigjmp_buf sigjmp_buf[1];
+@@ -34,7 +35,11 @@ typedef struct __sigjmp_buf sigjmp_buf[1];
+ #define sigsetjmp(__env, __save) \
+ ({ \
+   struct __sigjmp_buf *__e = (__env); \
+-  sigprocmask(0, NULL, &__e->__sigs); \
++  if (__save) { \
++sigprocmask(0, NULL, &__e->__sigs); \
++__e->__sigs_saved = 1; \
++  } else \
++__e->__sigs_saved = 0; \
+   setjmp(__e->__jmpbuf); \
+ })
+ 
+diff --git a/usr/klibc/CAVEATS b/usr/klibc/CAVEATS
+index 5e991cb7..39949c28 100644
+--- a/usr/klibc/CAVEATS
 b/usr/klibc/CAVEATS
+@@ -13,8 +13,7 @@ Compiling with -O0 is more likely to work on gcc 3.
+ setjmp()/longjmp():
+ ---
+ setjmp() and longjmp() *do not* save signal state.  sigsetjmp() and
+-siglongjmp() *do* save the signal mask -- regardless of the value of
+-the extra argument.
++siglongjmp() *do* save the signal mask if the extra argument is nonzero.
+ 
+ The standards actually state that if you pass longjmp() a final value
+ of zero the library should change that to a 1!  Presumably the reason
+diff --git a/usr/klibc/siglongjmp.c b/usr/klibc/siglongjmp.c
+index 31042cbd..45f4e400 100644
+--- a/usr/klibc/siglongjmp.c
 b/usr/klibc/siglongjmp.c
+@@ -10,6 +10,7 @@
+ 
+ __noreturn siglongjmp(sigjmp_buf buf, int retval)
+ {
+-  sigprocmask(SIG_SETMASK, >__sigs, NULL);
++  if (buf->__sigs_saved)
++  sigprocmask(SIG_SETMASK, >__sigs, NULL);
+   longjmp(buf->__jmpbuf, retval);
+ }
+-- 
+2.31.1
+
diff -Nru 
klibc-2.0.8/debian/patches/0002-klibc-set-long-jmp-s390x-save-restore-the-correct-re.patch
 
klibc-2.0.8/debian/patches/0002-klibc-set-long-jmp-s390x-save-restore-the-correct-re.patch
--- 
klibc-2.0.8/debian/patches/0002-klibc-set-long-jmp-s390x-save-restore-the-correct-re.patch
  1970-01-01 01:00:00.0 +0100
+++ 
klibc-2.0.8/debian/patches/0002-klibc-set-long-jmp-s390x-save-restore-the-correct-re.patch
  2021-05-05 21:38:31.0 +0200
@@ -0,0 +1,76 @@
+From fc5a53932ee56d61a9fd8db75784e9f39ca474a3 Mon Sep 17 00:00:00 2001
+From: mirabilos 
+Date: Wed, 5 May 2021 21:26:33 +0200
+Subject: [PATCH 2/2] [klibc] {set,long}jmp [s390x]: save/restore the correct
+ registers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The s390x ABI actually has FPU registers f8‥f15, not f1/f3/f5/f7,
+to be saved. (Closes: Debian #943425)
+
+Signed-off-by: mirabilos 
+---
+ usr/include/arch/s390/klibc/archsetjmp.h |  2 +-
+ usr/klibc/arch/s390/setjmp.S | 24 

Bug#985681: linux-cpupower: Fix Pkg Power tracking on Zen

2021-05-05 Thread Salvatore Bonaccorso
Hi

This has now been fixed upstream with 
https://git.kernel.org/linus/301b1d3a9104f4f3a8ab4171cf88d0f55d632b41

I'm going probably to cherry-pick the commit, but in case you can/want
to double check (again I know, but there was some followup) the issue
for you that would be great.

Regards,
Salvatore



Bug#943425: [klibc] Debian #943425: klibc: [s390x] setjmp/longjmp do not save/restore all registers in use

2021-05-05 Thread Ben Hutchings
On Wed, 2021-05-05 at 20:24 +0200, Ben Hutchings wrote:
> On Wed, 2021-05-05 at 17:32 +, Thorsten Glaser wrote:
> [...]
> > > > > @klibc list: as indicated earlier, I can provide a patch if needed
> > > > > (though it should be obvious).
> > 
> > hpa, maks, bwh: any of you taking these two or should I send patches
> > and possibly NMU klibc in Debian?
> 
> Please send patches.  If you have a test base that could catch bugs

test *case*

> like this (without writing lists of registers in the test itself), that
> would be really useful.

-- 
Ben Hutchings
It is easier to change the specification to fit the program
than vice versa.


signature.asc
Description: This is a digitally signed message part


Processed: found 988027 in 2.0.8-1

2021-05-05 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> found 988027 2.0.8-1
Bug #988027 [libklibc-dev] klibc: sigsetjmp ignores second argument, siglongjmp 
always restores signals
Marked as found in versions klibc/2.0.8-1.
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
988027: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988027
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Processed: affects 988027

2021-05-05 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> affects 988027 - 2.0.8-1
Bug #988027 [libklibc-dev] klibc: sigsetjmp ignores second argument, siglongjmp 
always restores signals
Removed indication that 988027 affects 2.0.8-1
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
988027: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988027
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#943425: [klibc] Debian #943425: klibc: [s390x] setjmp/longjmp do not save/restore all registers in use

2021-05-05 Thread Ben Hutchings
On Wed, 2021-05-05 at 17:32 +, Thorsten Glaser wrote:
[...]
> > > > @klibc list: as indicated earlier, I can provide a patch if needed
> > > > (though it should be obvious).
> 
> hpa, maks, bwh: any of you taking these two or should I send patches
> and possibly NMU klibc in Debian?

Please send patches.  If you have a test base that could catch bugs
like this (without writing lists of registers in the test itself), that
would be really useful.

Ben.

-- 
Ben Hutchings
It is easier to change the specification to fit the program
than vice versa.


signature.asc
Description: This is a digitally signed message part


Processed: affects 988027

2021-05-05 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> affects 988027 2.0.8-1
Bug #988027 [libklibc-dev] klibc: sigsetjmp ignores second argument, siglongjmp 
always restores signals
Added indication that 988027 affects 2.0.8-1
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
988027: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988027
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#943425: Debian #943425: klibc: [s390x] setjmp/longjmp do not save/restore all registers in use

2021-05-05 Thread Thorsten Glaser
Hi Andreas,

>>> Jessica Clarke brought out docs saying f8‥f15 must be saved, the
>>> other FPU registers not:
>
>I can confirm this. It is f8-f15 for the z/Architecture (64 bit).

thanks!

>It is f1, f3, f5, f7 for the ESA
>architecture (32 bit) which is still supported by Glibc and GCC.

Is this what we know as s390 in Debian? (klibc saves f4 and f6 there
currently. If so, this also needs to change.)

>>> … GCC chooses to allocate an FPU register for a pointer value.
>
>GCC will put integer values into vector registers for
>auto-vectorization or for spilling. We also use call-clobbered FPRs as
>save slots for GPRs in leaf-functions if can get rid of allocating a
>stack frame that way.

Ah, interesting. Thanks!

>The vector registers are call-clobbered - exactly for the reason of
>setjmp / longjmp. Only f8-f15 need to be saved.

Right.

>You can find the latest version of our ABI here:
>https://github.com/IBM/s390x-abi/releases/download/v1.5/lzsabi_s390x.pdf
>
>However, it is still lacking the vector ABI extension. I wrote a
>document for that which we use internally and we are working on
>integrating it into the publicly available version.

OK, thanks for the information!

>>> @klibc list: as indicated earlier, I can provide a patch if needed
>>> (though it should be obvious).

hpa, maks, bwh: any of you taking these two or should I send patches
and possibly NMU klibc in Debian?

Thanks,
//mirabilos
-- 
 you introduced a merge commit│ % g rebase -i HEAD^^
 sorry, no idea and rebasing just fscked │ Segmentation
 should have cloned into a clean repo  │  fault (core dumped)
 if I rebase that now, it's really ugh │ wuahh



Bug#943425: Debian #943425: [s390x] setjmp/longjmp do not save/restore all registers in use

2021-05-05 Thread Andreas Krebbel
On 5/5/21 4:45 AM, Thorsten Glaser wrote:
> Dixi quod…
> 
>> Jessica Clarke brought out docs saying f8‥f15 must be saved, the
>> other FPU registers not:

I can confirm this. It is f8-f15 for the z/Architecture (64 bit). It is f1, f3, 
f5, f7 for the ESA
architecture (32 bit) which is still supported by Glibc and GCC.

> 
> This needs to be fixed in klibc.
> 
>>> • klibc does not really support the FPU anyway
>>
>> … GCC chooses to allocate an FPU register for a pointer value.

GCC will put integer values into vector registers for auto-vectorization or for 
spilling. We also
use call-clobbered FPRs as save slots for GPRs in leaf-functions if can get rid 
of allocating a
stack frame that way.

> 
> This is a curiosity.
> 
>>> • the half of v10 that equals f10 just HAPPENS to be saved by
>>>  glibc, but what if the upper half, that is outside of the FPU,
>>>  is used?
>>
>> The question here is, does GCC only use the halves of the half
>> of the vector registers that match the FPU registers?
> 
> 04:41⎜«jrtc27:#debian-x32» hephaistor: re s390x vector registers, reading the 
> gcc and llvm sources they're
>  ⎜all call-clobbered by default, only the float parts are call-saved
> 04:41⎜«jrtc27:#debian-x32» so that's why setjmp/longjmp don't need to 
> save/restore them
> 04:42⎜«jrtc27:#debian-x32» there *is* a vector calling convention, but it's 
> not the default for the ABI,
>  ⎜it's opt-in, and setjmp/longjmp won't be annotated as such
> 
> So we indeed need to only save the registers glibc does.

The vector registers are call-clobbered - exactly for the reason of setjmp / 
longjmp. Only f8-f15
need to be saved.

You can find the latest version of our ABI here:
https://github.com/IBM/s390x-abi/releases/download/v1.5/lzsabi_s390x.pdf

However, it is still lacking the vector ABI extension. I wrote a document for 
that which we use
internally and we are working on integrating it into the publicly available 
version.

Andreas

> 
>> @klibc list: as indicated earlier, I can provide a patch if needed
>> (though it should be obvious).
> 
> bye,
> //mirabilos
>