stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules" failed to apply to 4.4-stable tree
@ 2017-04-10 14:35 gregkh
  2017-04-20 14:42 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2017-04-10 14:35 UTC (permalink / raw)
  To: oohall, mpe; +Cc: stable


The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From 8f5f525d5b83f7d76a6baf9c4e94d4bf312ea7f6 Mon Sep 17 00:00:00 2001
From: Oliver O'Halloran <oohall@gmail.com>
Date: Mon, 3 Apr 2017 13:25:12 +1000
Subject: [PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules

When the kernel is compiled to use 64bit ABIv2 the _GLOBAL() macro does
not include a global entry point. A function's global entry point is
used when the function is called from a different TOC context and in the
kernel this typically means a call from a module into the vmlinux (or
vice-versa).

There are a few exported asm functions declared with _GLOBAL() and
calling them from a module will likely crash the kernel since any TOC
relative load will yield garbage.

flush_icache_range() and flush_dcache_range() are both exported to
modules, and use the TOC, so must use _GLOBAL_TOC().

Fixes: 721aeaa9fdf3 ("powerpc: Build little endian ppc64 kernel with ABIv2")
Cc: stable@vger.kernel.org # v3.16+
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index ae179cb1bb3c..c119044cad0d 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -67,7 +67,7 @@ PPC64_CACHES:
  *   flush all bytes from start through stop-1 inclusive
  */
 
-_GLOBAL(flush_icache_range)
+_GLOBAL_TOC(flush_icache_range)
 BEGIN_FTR_SECTION
 	PURGE_PREFETCHED_INS
 	blr
@@ -120,7 +120,7 @@ EXPORT_SYMBOL(flush_icache_range)
  *
  *    flush all bytes from start to stop-1 inclusive
  */
-_GLOBAL(flush_dcache_range)
+_GLOBAL_TOC(flush_dcache_range)
 
 /*
  * Flush the data cache to memory 

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

* Re: FAILED: patch "[PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules" failed to apply to 4.4-stable tree
  2017-04-10 14:35 FAILED: patch "[PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules" failed to apply to 4.4-stable tree gregkh
@ 2017-04-20 14:42 ` Michael Ellerman
  2017-04-25 11:55   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2017-04-20 14:42 UTC (permalink / raw)
  To: gregkh, oohall; +Cc: stable

gregkh@linuxfoundation.org writes:

> The patch below does not apply to the 4.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.

Hi Greg,

Here's a backport to 4.4 at least, and probably earlier. Do you want a
separate backport patch for each stable tree?

cheers


From: Oliver O'Halloran <oohall@gmail.com>
Date: Mon, 3 Apr 2017 13:25:12 +1000
Subject: [PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules

commit 8f5f525d5b83f7d76a6baf9c4e94d4bf312ea7f6 upstream.

When the kernel is compiled to use 64bit ABIv2 the _GLOBAL() macro does
not include a global entry point. A function's global entry point is
used when the function is called from a different TOC context and in the
kernel this typically means a call from a module into the vmlinux (or
vice-versa).

There are a few exported asm functions declared with _GLOBAL() and
calling them from a module will likely crash the kernel since any TOC
relative load will yield garbage.

flush_icache_range() and flush_dcache_range() are both exported to
modules, and use the TOC, so must use _GLOBAL_TOC().

[mpe: We can't use _GLOBAL_TOC() in 4.4 for flush_icache_range() because
it needs to be in the .kprobes.text section, handled by the _KPROBE()
macro. We don't have a _KPROBE_TOC() macro, so just open code the TOC
initialisation.]

Fixes: 721aeaa9fdf3 ("powerpc: Build little endian ppc64 kernel with ABIv2")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/misc_64.S | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index db475d41b57a..06a1697e1fcf 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -67,6 +67,9 @@ PPC64_CACHES:
  */
 
 _KPROBE(flush_icache_range)
+0:	addis	r2,r12,(.TOC. - 0b)@ha
+	addi	r2, r2,(.TOC. - 0b)@l
+	.localentry flush_icache_range, . - flush_icache_range
 BEGIN_FTR_SECTION
 	PURGE_PREFETCHED_INS
 	blr
@@ -117,7 +120,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
  *
  *    flush all bytes from start to stop-1 inclusive
  */
-_GLOBAL(flush_dcache_range)
+_GLOBAL_TOC(flush_dcache_range)
 
 /*
  * Flush the data cache to memory 
-- 
2.7.4

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

* Re: FAILED: patch "[PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules" failed to apply to 4.4-stable tree
  2017-04-20 14:42 ` Michael Ellerman
@ 2017-04-25 11:55   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2017-04-25 11:55 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: oohall, stable

On Fri, Apr 21, 2017 at 12:42:02AM +1000, Michael Ellerman wrote:
> gregkh@linuxfoundation.org writes:
> 
> > The patch below does not apply to the 4.4-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> 
> Hi Greg,
> 
> Here's a backport to 4.4 at least, and probably earlier. Do you want a
> separate backport patch for each stable tree?

This works for me, thanks!

greg k-h

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

end of thread, other threads:[~2017-04-25 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-10 14:35 FAILED: patch "[PATCH] powerpc/64: Fix flush_(d|i)cache_range() called from modules" failed to apply to 4.4-stable tree gregkh
2017-04-20 14:42 ` Michael Ellerman
2017-04-25 11:55   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).