Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-15 Thread Heiko Carstens
On Tue, Sep 15, 2015 at 09:41:49AM +0200, Willy Tarreau wrote:
> On Tue, Sep 15, 2015 at 08:09:27AM +0200, Heiko Carstens wrote:
> > On Tue, Sep 15, 2015 at 03:10:45AM +0100, Ben Hutchings wrote:
> > > On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> > > > 2.6.32-longterm review patch.  If anyone has any objections, please let 
> > > > me know.
> > > > 
> > > > --
> > > > 
> > > > From: Heiko Carstens 
> > > > 
> > > > commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> > > > 
> > > > Sebastian reported a crash caused by a jump label mismatch after resume.
> > > > This happens because we do not save the kernel text section during 
> > > > suspend
> > > > and therefore also do not restore it during resume, but use the kernel 
> > > > image
> > > > that restores the old system.
> > > [...]
> > > 
> > > I don't think this is needed because jump labels aren't implemented in
> > > 2.6.32.  But maybe there was some other mechanism that changes the
> > > kernel text on s390?
> > 
> > Broken jump labels were the symptons when the problem was reported. However
> > we lose everything that modifies kernel text without this patch.
> > If it's not jump labels then there is still kprobes around where we have
> > the same problem.
> > Probably the patch description should have been better.
> 
> OK so in the end you suggest you keep it in both 2.6.32 and 3.2 ?

Yes, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-15 Thread Willy Tarreau
On Tue, Sep 15, 2015 at 08:09:27AM +0200, Heiko Carstens wrote:
> On Tue, Sep 15, 2015 at 03:10:45AM +0100, Ben Hutchings wrote:
> > On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> > > 2.6.32-longterm review patch.  If anyone has any objections, please let 
> > > me know.
> > > 
> > > --
> > > 
> > > From: Heiko Carstens 
> > > 
> > > commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> > > 
> > > Sebastian reported a crash caused by a jump label mismatch after resume.
> > > This happens because we do not save the kernel text section during suspend
> > > and therefore also do not restore it during resume, but use the kernel 
> > > image
> > > that restores the old system.
> > [...]
> > 
> > I don't think this is needed because jump labels aren't implemented in
> > 2.6.32.  But maybe there was some other mechanism that changes the
> > kernel text on s390?
> 
> Broken jump labels were the symptons when the problem was reported. However
> we lose everything that modifies kernel text without this patch.
> If it's not jump labels then there is still kprobes around where we have
> the same problem.
> Probably the patch description should have been better.

OK so in the end you suggest you keep it in both 2.6.32 and 3.2 ?

Thanks,
Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-15 Thread Heiko Carstens
On Tue, Sep 15, 2015 at 03:10:45AM +0100, Ben Hutchings wrote:
> On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> > 2.6.32-longterm review patch.  If anyone has any objections, please let me 
> > know.
> > 
> > --
> > 
> > From: Heiko Carstens 
> > 
> > commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> > 
> > Sebastian reported a crash caused by a jump label mismatch after resume.
> > This happens because we do not save the kernel text section during suspend
> > and therefore also do not restore it during resume, but use the kernel image
> > that restores the old system.
> [...]
> 
> I don't think this is needed because jump labels aren't implemented in
> 2.6.32.  But maybe there was some other mechanism that changes the
> kernel text on s390?

Broken jump labels were the symptons when the problem was reported. However
we lose everything that modifies kernel text without this patch.
If it's not jump labels then there is still kprobes around where we have
the same problem.
Probably the patch description should have been better.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-15 Thread Heiko Carstens
On Tue, Sep 15, 2015 at 03:10:45AM +0100, Ben Hutchings wrote:
> On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> > 2.6.32-longterm review patch.  If anyone has any objections, please let me 
> > know.
> > 
> > --
> > 
> > From: Heiko Carstens 
> > 
> > commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> > 
> > Sebastian reported a crash caused by a jump label mismatch after resume.
> > This happens because we do not save the kernel text section during suspend
> > and therefore also do not restore it during resume, but use the kernel image
> > that restores the old system.
> [...]
> 
> I don't think this is needed because jump labels aren't implemented in
> 2.6.32.  But maybe there was some other mechanism that changes the
> kernel text on s390?

Broken jump labels were the symptons when the problem was reported. However
we lose everything that modifies kernel text without this patch.
If it's not jump labels then there is still kprobes around where we have
the same problem.
Probably the patch description should have been better.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-15 Thread Willy Tarreau
On Tue, Sep 15, 2015 at 08:09:27AM +0200, Heiko Carstens wrote:
> On Tue, Sep 15, 2015 at 03:10:45AM +0100, Ben Hutchings wrote:
> > On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> > > 2.6.32-longterm review patch.  If anyone has any objections, please let 
> > > me know.
> > > 
> > > --
> > > 
> > > From: Heiko Carstens 
> > > 
> > > commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> > > 
> > > Sebastian reported a crash caused by a jump label mismatch after resume.
> > > This happens because we do not save the kernel text section during suspend
> > > and therefore also do not restore it during resume, but use the kernel 
> > > image
> > > that restores the old system.
> > [...]
> > 
> > I don't think this is needed because jump labels aren't implemented in
> > 2.6.32.  But maybe there was some other mechanism that changes the
> > kernel text on s390?
> 
> Broken jump labels were the symptons when the problem was reported. However
> we lose everything that modifies kernel text without this patch.
> If it's not jump labels then there is still kprobes around where we have
> the same problem.
> Probably the patch description should have been better.

OK so in the end you suggest you keep it in both 2.6.32 and 3.2 ?

Thanks,
Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-15 Thread Heiko Carstens
On Tue, Sep 15, 2015 at 09:41:49AM +0200, Willy Tarreau wrote:
> On Tue, Sep 15, 2015 at 08:09:27AM +0200, Heiko Carstens wrote:
> > On Tue, Sep 15, 2015 at 03:10:45AM +0100, Ben Hutchings wrote:
> > > On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> > > > 2.6.32-longterm review patch.  If anyone has any objections, please let 
> > > > me know.
> > > > 
> > > > --
> > > > 
> > > > From: Heiko Carstens 
> > > > 
> > > > commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> > > > 
> > > > Sebastian reported a crash caused by a jump label mismatch after resume.
> > > > This happens because we do not save the kernel text section during 
> > > > suspend
> > > > and therefore also do not restore it during resume, but use the kernel 
> > > > image
> > > > that restores the old system.
> > > [...]
> > > 
> > > I don't think this is needed because jump labels aren't implemented in
> > > 2.6.32.  But maybe there was some other mechanism that changes the
> > > kernel text on s390?
> > 
> > Broken jump labels were the symptons when the problem was reported. However
> > we lose everything that modifies kernel text without this patch.
> > If it's not jump labels then there is still kprobes around where we have
> > the same problem.
> > Probably the patch description should have been better.
> 
> OK so in the end you suggest you keep it in both 2.6.32 and 3.2 ?

Yes, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-14 Thread Ben Hutchings
On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> 2.6.32-longterm review patch.  If anyone has any objections, please let me 
> know.
> 
> --
> 
> From: Heiko Carstens 
> 
> commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> 
> Sebastian reported a crash caused by a jump label mismatch after resume.
> This happens because we do not save the kernel text section during suspend
> and therefore also do not restore it during resume, but use the kernel image
> that restores the old system.
[...]

I don't think this is needed because jump labels aren't implemented in
2.6.32.  But maybe there was some other mechanism that changes the
kernel text on s390?

Ben.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-14 Thread Ben Hutchings
On Sun, 2015-09-13 at 00:56 +0200, Willy Tarreau wrote:
> 2.6.32-longterm review patch.  If anyone has any objections, please let me 
> know.
> 
> --
> 
> From: Heiko Carstens 
> 
> commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.
> 
> Sebastian reported a crash caused by a jump label mismatch after resume.
> This happens because we do not save the kernel text section during suspend
> and therefore also do not restore it during resume, but use the kernel image
> that restores the old system.
[...]

I don't think this is needed because jump labels aren't implemented in
2.6.32.  But maybe there was some other mechanism that changes the
kernel text on s390?

Ben.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-12 Thread Willy Tarreau
2.6.32-longterm review patch.  If anyone has any objections, please let me know.

--

From: Heiko Carstens 

commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.

Sebastian reported a crash caused by a jump label mismatch after resume.
This happens because we do not save the kernel text section during suspend
and therefore also do not restore it during resume, but use the kernel image
that restores the old system.

This means that after a suspend/resume cycle we lost all modifications done
to the kernel text section.
The reason for this is the pfn_is_nosave() function, which incorrectly
returns that read-only pages don't need to be saved. This is incorrect since
we mark the kernel text section read-only.
We still need to make sure to not save and restore pages contained within
NSS and DCSS segment.
To fix this add an extra case for the kernel text section and only save
those pages if they are not contained within an NSS segment.

Fixes the following crash (and the above bugs as well):

Jump label code mismatch at netif_receive_skb_internal+0x28/0xd0
Found:c0 04 00 00 00 00
Expected: c0 f4 00 00 00 11
New:  c0 04 00 00 00 00
Kernel panic - not syncing: Corrupted kernel text
CPU: 0 PID: 9 Comm: migration/0 Not tainted 3.19.0-01975-gb1b096e70f23 #4
Call Trace:
  [<00113972>] show_stack+0x72/0xf0
  [<0081f15e>] dump_stack+0x6e/0x90
  [<0081c4e8>] panic+0x108/0x2b0
  [<0081be64>] jump_label_bug.isra.2+0x104/0x108
  [<00112176>] __jump_label_transform+0x9e/0xd0
  [<001121e6>] __sm_arch_jump_label_transform+0x3e/0x50
  [<001d1136>] multi_cpu_stop+0x12e/0x170
  [<001d1472>] cpu_stopper_thread+0xb2/0x168
  [<0015d2ac>] smpboot_thread_fn+0x134/0x1b0
  [<00158baa>] kthread+0x10a/0x110
  [<00824a86>] kernel_thread_starter+0x6/0xc

Reported-and-tested-by: Sebastian Ott 
Signed-off-by: Heiko Carstens 
Signed-off-by: Martin Schwidefsky 
[bwh: Backported to 3.2: add necessary #include directives]
Signed-off-by: Ben Hutchings 
(cherry picked from commit 98b4a75c0792d281beb904911e2271d45c71511a)
Signed-off-by: Willy Tarreau 
---
 arch/s390/kernel/suspend.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/s390/kernel/suspend.c b/arch/s390/kernel/suspend.c
index cf9e5c6..f03c8df 100644
--- a/arch/s390/kernel/suspend.c
+++ b/arch/s390/kernel/suspend.c
@@ -7,6 +7,8 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 
 /*
@@ -18,6 +20,8 @@ int pfn_is_nosave(unsigned long pfn)
 {
unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end));
+   unsigned long eshared_pfn = PFN_DOWN(__pa(&_eshared)) - 1;
+   unsigned long stext_pfn = PFN_DOWN(__pa(&_stext));
 
/* Always save lowcore pages (LC protection might be enabled). */
if (pfn <= LC_PAGES)
@@ -25,6 +29,8 @@ int pfn_is_nosave(unsigned long pfn)
if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn)
return 1;
/* Skip memory holes and read-only pages (NSS, DCSS, ...). */
+   if (pfn >= stext_pfn && pfn <= eshared_pfn)
+   return ipl_info.type == IPL_TYPE_NSS ? 1 : 0;
if (tprot(PFN_PHYS(pfn)))
return 1;
return 0;
-- 
1.7.12.2.21.g234cd45.dirty



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2.6.32 18/62] s390/hibernate: fix save and restore of kernel text section

2015-09-12 Thread Willy Tarreau
2.6.32-longterm review patch.  If anyone has any objections, please let me know.

--

From: Heiko Carstens 

commit d74419495633493c9cd3f2bbeb7f3529d0edded6 upstream.

Sebastian reported a crash caused by a jump label mismatch after resume.
This happens because we do not save the kernel text section during suspend
and therefore also do not restore it during resume, but use the kernel image
that restores the old system.

This means that after a suspend/resume cycle we lost all modifications done
to the kernel text section.
The reason for this is the pfn_is_nosave() function, which incorrectly
returns that read-only pages don't need to be saved. This is incorrect since
we mark the kernel text section read-only.
We still need to make sure to not save and restore pages contained within
NSS and DCSS segment.
To fix this add an extra case for the kernel text section and only save
those pages if they are not contained within an NSS segment.

Fixes the following crash (and the above bugs as well):

Jump label code mismatch at netif_receive_skb_internal+0x28/0xd0
Found:c0 04 00 00 00 00
Expected: c0 f4 00 00 00 11
New:  c0 04 00 00 00 00
Kernel panic - not syncing: Corrupted kernel text
CPU: 0 PID: 9 Comm: migration/0 Not tainted 3.19.0-01975-gb1b096e70f23 #4
Call Trace:
  [<00113972>] show_stack+0x72/0xf0
  [<0081f15e>] dump_stack+0x6e/0x90
  [<0081c4e8>] panic+0x108/0x2b0
  [<0081be64>] jump_label_bug.isra.2+0x104/0x108
  [<00112176>] __jump_label_transform+0x9e/0xd0
  [<001121e6>] __sm_arch_jump_label_transform+0x3e/0x50
  [<001d1136>] multi_cpu_stop+0x12e/0x170
  [<001d1472>] cpu_stopper_thread+0xb2/0x168
  [<0015d2ac>] smpboot_thread_fn+0x134/0x1b0
  [<00158baa>] kthread+0x10a/0x110
  [<00824a86>] kernel_thread_starter+0x6/0xc

Reported-and-tested-by: Sebastian Ott 
Signed-off-by: Heiko Carstens 
Signed-off-by: Martin Schwidefsky 
[bwh: Backported to 3.2: add necessary #include directives]
Signed-off-by: Ben Hutchings 
(cherry picked from commit 98b4a75c0792d281beb904911e2271d45c71511a)
Signed-off-by: Willy Tarreau 
---
 arch/s390/kernel/suspend.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/s390/kernel/suspend.c b/arch/s390/kernel/suspend.c
index cf9e5c6..f03c8df 100644
--- a/arch/s390/kernel/suspend.c
+++ b/arch/s390/kernel/suspend.c
@@ -7,6 +7,8 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 
 /*
@@ -18,6 +20,8 @@ int pfn_is_nosave(unsigned long pfn)
 {
unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end));
+   unsigned long eshared_pfn = PFN_DOWN(__pa(&_eshared)) - 1;
+   unsigned long stext_pfn = PFN_DOWN(__pa(&_stext));
 
/* Always save lowcore pages (LC protection might be enabled). */
if (pfn <= LC_PAGES)
@@ -25,6 +29,8 @@ int pfn_is_nosave(unsigned long pfn)
if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn)
return 1;
/* Skip memory holes and read-only pages (NSS, DCSS, ...). */
+   if (pfn >= stext_pfn && pfn <= eshared_pfn)
+   return ipl_info.type == IPL_TYPE_NSS ? 1 : 0;
if (tprot(PFN_PHYS(pfn)))
return 1;
return 0;
-- 
1.7.12.2.21.g234cd45.dirty



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/