diff mbox

[RFC] arm64: mm: Export __sync_icache_dcache() for xen-privcmd

Message ID 20180711231822.GG14131@decadent.org.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Hutchings July 11, 2018, 11:18 p.m. UTC
The xen-privcmd driver, which can be modular, calls set_pte_at()
which in turn may call __sync_icache_dcache().

The call to __sync_icache_dcache() may be optimised out because it is
conditional on !pte_special(), and xen-privcmd calls pte_mkspecial().
But it seems unwise to rely on this optimisation.

Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
This is an RFC since I haven't found an actual build failure.  Using
Debian's gcc 7.3 with either CC_OPTIMIZE_FOR_PERFORMANCE or
CC_OPTIMIZE_FOR_SIZE, the call *is* optimised away.

Ben.

 arch/arm64/mm/flush.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Catalin Marinas July 27, 2018, 12:06 p.m. UTC | #1
On Thu, Jul 12, 2018 at 12:18:22AM +0100, Ben Hutchings wrote:
> The xen-privcmd driver, which can be modular, calls set_pte_at()
> which in turn may call __sync_icache_dcache().
> 
> The call to __sync_icache_dcache() may be optimised out because it is
> conditional on !pte_special(), and xen-privcmd calls pte_mkspecial().
> But it seems unwise to rely on this optimisation.
> 
> Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> This is an RFC since I haven't found an actual build failure.  Using
> Debian's gcc 7.3 with either CC_OPTIMIZE_FOR_PERFORMANCE or
> CC_OPTIMIZE_FOR_SIZE, the call *is* optimised away.

Since apply_to_page_range() is EXPORT_SYMBOL_GPL() and a
pte_fn_t function would likely use set_pte_at(), I'm fine with this
patch for consistency.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Will Deacon July 27, 2018, 1:22 p.m. UTC | #2
On Fri, Jul 27, 2018 at 01:06:33PM +0100, Catalin Marinas wrote:
> On Thu, Jul 12, 2018 at 12:18:22AM +0100, Ben Hutchings wrote:
> > The xen-privcmd driver, which can be modular, calls set_pte_at()
> > which in turn may call __sync_icache_dcache().
> > 
> > The call to __sync_icache_dcache() may be optimised out because it is
> > conditional on !pte_special(), and xen-privcmd calls pte_mkspecial().
> > But it seems unwise to rely on this optimisation.
> > 
> > Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE")
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > ---
> > This is an RFC since I haven't found an actual build failure.  Using
> > Debian's gcc 7.3 with either CC_OPTIMIZE_FOR_PERFORMANCE or
> > CC_OPTIMIZE_FOR_SIZE, the call *is* optimised away.
> 
> Since apply_to_page_range() is EXPORT_SYMBOL_GPL() and a
> pte_fn_t function would likely use set_pte_at(), I'm fine with this
> patch for consistency.
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

Okey doke, I'll pick this up for 4.19.

Will
Geert Uytterhoeven July 30, 2018, 6:46 a.m. UTC | #3
On Fri, Jul 27, 2018 at 3:23 PM Will Deacon <will.deacon@arm.com> wrote:
> On Fri, Jul 27, 2018 at 01:06:33PM +0100, Catalin Marinas wrote:
> > On Thu, Jul 12, 2018 at 12:18:22AM +0100, Ben Hutchings wrote:
> > > The xen-privcmd driver, which can be modular, calls set_pte_at()
> > > which in turn may call __sync_icache_dcache().
> > >
> > > The call to __sync_icache_dcache() may be optimised out because it is
> > > conditional on !pte_special(), and xen-privcmd calls pte_mkspecial().
> > > But it seems unwise to rely on this optimisation.
> > >
> > > Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE")
> > > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > > ---
> > > This is an RFC since I haven't found an actual build failure.  Using
> > > Debian's gcc 7.3 with either CC_OPTIMIZE_FOR_PERFORMANCE or
> > > CC_OPTIMIZE_FOR_SIZE, the call *is* optimised away.
> >
> > Since apply_to_page_range() is EXPORT_SYMBOL_GPL() and a
> > pte_fn_t function would likely use set_pte_at(), I'm fine with this
> > patch for consistency.
> >
> > Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>
> Okey doke, I'll pick this up for 4.19.

Note that this is a build regression in v4.18-rc4 and later:
http://kisskb.ellerman.id.au/kisskb/buildresult/13450058/

Gr{oetje,eeting}s,

                        Geert
Geert Uytterhoeven July 30, 2018, 6:50 a.m. UTC | #4
On Mon, Jul 30, 2018 at 8:46 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Fri, Jul 27, 2018 at 3:23 PM Will Deacon <will.deacon@arm.com> wrote:
> > On Fri, Jul 27, 2018 at 01:06:33PM +0100, Catalin Marinas wrote:
> > > On Thu, Jul 12, 2018 at 12:18:22AM +0100, Ben Hutchings wrote:
> > > > The xen-privcmd driver, which can be modular, calls set_pte_at()
> > > > which in turn may call __sync_icache_dcache().
> > > >
> > > > The call to __sync_icache_dcache() may be optimised out because it is
> > > > conditional on !pte_special(), and xen-privcmd calls pte_mkspecial().
> > > > But it seems unwise to rely on this optimisation.
> > > >
> > > > Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE")
> > > > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > > > ---
> > > > This is an RFC since I haven't found an actual build failure.  Using
> > > > Debian's gcc 7.3 with either CC_OPTIMIZE_FOR_PERFORMANCE or
> > > > CC_OPTIMIZE_FOR_SIZE, the call *is* optimised away.
> > >
> > > Since apply_to_page_range() is EXPORT_SYMBOL_GPL() and a
> > > pte_fn_t function would likely use set_pte_at(), I'm fine with this
> > > patch for consistency.
> > >
> > > Acked-by: Catalin Marinas <catalin.marinas@arm.com>
> >
> > Okey doke, I'll pick this up for 4.19.
>
> Note that this is a build regression in v4.18-rc4 and later:
> http://kisskb.ellerman.id.au/kisskb/buildresult/13450058/

s/is/fixes (presumably)/

Gr{oetje,eeting}s,

                        Geert
diff mbox

Patch

diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c
index 1059884f9a6f..a76f0b983294 100644
--- a/arch/arm64/mm/flush.c
+++ b/arch/arm64/mm/flush.c
@@ -66,6 +66,7 @@  void __sync_icache_dcache(pte_t pte)
 		sync_icache_aliases(page_address(page),
 				    PAGE_SIZE << compound_order(page));
 }
+EXPORT_SYMBOL_GPL(__sync_icache_dcache);
 
 /*
  * This function is called when a page has been modified by the kernel. Mark