Linux MIPS Architecture development
 help / color / mirror / Atom feed
* MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume()
@ 2014-03-22  9:21 Huacai Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2014-03-22  9:21 UTC (permalink / raw)


commit c14af233fbe279d0e561ecf84f1208b1bae087ef upstream.

The original MIPS hibernate code flushes cache and TLB entries in
swsusp_arch_resume(). But they are removed in Commit 44eeab67416711
(MIPS: Hibernation: Remove SMP TLB and cacheflushing code.). A cross-
CPU flush is surely unnecessary because all but the local CPU have
already been disabled. But a local flush (at least the TLB flush) is
needed. When we do hibernation on Loongson-3 with an E1000E NIC, it is
very easy to produce a kernel panic (kernel page fault, or unaligned
access). The root cause is E1000E driver use vzalloc_node() to allocate
pages, the stale TLB entries of the booting kernel will be misused by
the resumed target kernel.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Cc: John Crispin <john@phrozen.org>
Cc: Steven J. Hill <Steven.Hill@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: linux-mips@linux-mips.org
Cc: Fuxin Zhang <zhangfx@lemote.com>
Cc: Zhangjin Wu <wuzhangjin@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/6643/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/mips/power/hibernate.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/power/hibernate.S b/arch/mips/power/hibernate.S
index 61e2558..63bc9e5 100644
--- a/arch/mips/power/hibernate.S
+++ b/arch/mips/power/hibernate.S
@@ -43,6 +43,7 @@ LEAF(swsusp_arch_resume)
 	bne t1, t3, 1b
 	PTR_L t0, PBE_NEXT(t0)
 	bnez t0, 0b
+	jal local_flush_tlb_all /* Avoid TLB mismatch after kernel resume */
 	PTR_LA t0, saved_regs
 	PTR_L ra, PT_R31(t0)
 	PTR_L sp, PT_R29(t0)
--
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume()
@ 2014-03-22  9:21 Huacai Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2014-03-22  9:21 UTC (permalink / raw)


commit c14af233fbe279d0e561ecf84f1208b1bae087ef upstream.

The original MIPS hibernate code flushes cache and TLB entries in
swsusp_arch_resume(). But they are removed in Commit 44eeab67416711
(MIPS: Hibernation: Remove SMP TLB and cacheflushing code.). A cross-
CPU flush is surely unnecessary because all but the local CPU have
already been disabled. But a local flush (at least the TLB flush) is
needed. When we do hibernation on Loongson-3 with an E1000E NIC, it is
very easy to produce a kernel panic (kernel page fault, or unaligned
access). The root cause is E1000E driver use vzalloc_node() to allocate
pages, the stale TLB entries of the booting kernel will be misused by
the resumed target kernel.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Cc: John Crispin <john@phrozen.org>
Cc: Steven J. Hill <Steven.Hill@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: linux-mips@linux-mips.org
Cc: Fuxin Zhang <zhangfx@lemote.com>
Cc: Zhangjin Wu <wuzhangjin@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/6643/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/mips/power/hibernate.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/power/hibernate.S b/arch/mips/power/hibernate.S
index 7e0277a..32a7c82 100644
--- a/arch/mips/power/hibernate.S
+++ b/arch/mips/power/hibernate.S
@@ -43,6 +43,7 @@ LEAF(swsusp_arch_resume)
 	bne t1, t3, 1b
 	PTR_L t0, PBE_NEXT(t0)
 	bnez t0, 0b
+	jal local_flush_tlb_all /* Avoid TLB mismatch after kernel resume */
 	PTR_LA t0, saved_regs
 	PTR_L ra, PT_R31(t0)
 	PTR_L sp, PT_R29(t0)
--
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume()
@ 2014-03-22  9:21 Huacai Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2014-03-22  9:21 UTC (permalink / raw)


commit c14af233fbe279d0e561ecf84f1208b1bae087ef upstream.

The original MIPS hibernate code flushes cache and TLB entries in
swsusp_arch_resume(). But they are removed in Commit 44eeab67416711
(MIPS: Hibernation: Remove SMP TLB and cacheflushing code.). A cross-
CPU flush is surely unnecessary because all but the local CPU have
already been disabled. But a local flush (at least the TLB flush) is
needed. When we do hibernation on Loongson-3 with an E1000E NIC, it is
very easy to produce a kernel panic (kernel page fault, or unaligned
access). The root cause is E1000E driver use vzalloc_node() to allocate
pages, the stale TLB entries of the booting kernel will be misused by
the resumed target kernel.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Cc: John Crispin <john@phrozen.org>
Cc: Steven J. Hill <Steven.Hill@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: linux-mips@linux-mips.org
Cc: Fuxin Zhang <zhangfx@lemote.com>
Cc: Zhangjin Wu <wuzhangjin@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/6643/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/mips/power/hibernate.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/power/hibernate.S b/arch/mips/power/hibernate.S
index 7e0277a..32a7c82 100644
--- a/arch/mips/power/hibernate.S
+++ b/arch/mips/power/hibernate.S
@@ -43,6 +43,7 @@ LEAF(swsusp_arch_resume)
 	bne t1, t3, 1b
 	PTR_L t0, PBE_NEXT(t0)
 	bnez t0, 0b
+	jal local_flush_tlb_all /* Avoid TLB mismatch after kernel resume */
 	PTR_LA t0, saved_regs
 	PTR_L ra, PT_R31(t0)
 	PTR_L sp, PT_R29(t0)
--
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume()
       [not found] <tencent_03F1BF0862C094496B5D0360@qq.com>
@ 2014-06-01  6:55 ` Alexandre Oliva
  2014-06-02  1:20   ` Huacai Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Oliva @ 2014-06-01  6:55 UTC (permalink / raw)
  To: 陈华才; +Cc: wuzhangjin, linux-mips, stable

Hi,

Thanks for your response,

On Jun  1, 2014, "陈华才" <chenhc@lemote.com> wrote:

> The original code flush both TLB and cache, and I think the original author (Wu Zhangjin) has tested his code. In my patch I only restore the TLB flush, but not the cache flush. Since Loongson-3A maintain cache coherency by hardware, with or without cache flush will both OK. But for Loongson-2F, I guess cache flush is also needed, but I have no Yeelong-2F to test now.

I'm afraid reintroducing the cache flush is not enough to bring the
kernel back to a working state, hibernation wise.  The last oops message
I saw, after the ones that flew by, had __arch_local_irq_restore at the
top of the backtrace, called by some function with resume in its name.

Any other suggestions?


Here's the patch I tried on top of yours, as an alternative to reverting
it, unfortunately without success:

--- arch/mips/power/hibernate.S
+++ arch/mips/power/hibernate.S
@@ -43,6 +43,9 @@
 	bne t1, t3, 1b
 	PTR_L t0, PBE_NEXT(t0)
 	bnez t0, 0b
+	/* flush caches to make sure context is in memory */
+	PTR_L t0, __flush_cache_all
+	jalr t0
 	jal local_flush_tlb_all /* Avoid TLB mismatch after kernel resume */
 	PTR_LA t0, saved_regs
 	PTR_L ra, PT_R31(t0)


-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume()
  2014-06-01  6:55 ` MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume() Alexandre Oliva
@ 2014-06-02  1:20   ` Huacai Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2014-06-02  1:20 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: wuzhangjin, linux-mips, stable

Hi,

Could you please let's have a look at your error log?

Huacai

On Sun, Jun 1, 2014 at 2:55 PM, Alexandre Oliva <oliva@gnu.org> wrote:
> Hi,
>
> Thanks for your response,
>
> On Jun  1, 2014, "陈华才" <chenhc@lemote.com> wrote:
>
>> The original code flush both TLB and cache, and I think the original author (Wu Zhangjin) has tested his code. In my patch I only restore the TLB flush, but not the cache flush. Since Loongson-3A maintain cache coherency by hardware, with or without cache flush will both OK. But for Loongson-2F, I guess cache flush is also needed, but I have no Yeelong-2F to test now.
>
> I'm afraid reintroducing the cache flush is not enough to bring the
> kernel back to a working state, hibernation wise.  The last oops message
> I saw, after the ones that flew by, had __arch_local_irq_restore at the
> top of the backtrace, called by some function with resume in its name.
>
> Any other suggestions?
>
>
> Here's the patch I tried on top of yours, as an alternative to reverting
> it, unfortunately without success:
>
> --- arch/mips/power/hibernate.S
> +++ arch/mips/power/hibernate.S
> @@ -43,6 +43,9 @@
>         bne t1, t3, 1b
>         PTR_L t0, PBE_NEXT(t0)
>         bnez t0, 0b
> +       /* flush caches to make sure context is in memory */
> +       PTR_L t0, __flush_cache_all
> +       jalr t0
>         jal local_flush_tlb_all /* Avoid TLB mismatch after kernel resume */
>         PTR_LA t0, saved_regs
>         PTR_L ra, PT_R31(t0)
>
>
> --
> Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/   FSF Latin America board member
> Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-02  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <tencent_03F1BF0862C094496B5D0360@qq.com>
2014-06-01  6:55 ` MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume() Alexandre Oliva
2014-06-02  1:20   ` Huacai Chen
2014-03-22  9:21 Huacai Chen
  -- strict thread matches above, loose matches on Subject: below --
2014-03-22  9:21 Huacai Chen
2014-03-22  9:21 Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox