Hi, On Sun, Sep 16, 2018 at 02:11:33PM +0200, gregkh@linuxfoundation.org wrote: > > 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 . Please find attached patch 00578cd864d45 ("MIPS: VDSO: Drop gic_get_usm_range() usage") and apply to {4.4,4.9}-stable tree for solving this conflict. Thanks! SZ Lin (林上智) > > thanks, > > greg k-h > > ------------------ original commit in Linus's tree ------------------ > > From 0f02cfbc3d9e413d450d8d0fd660077c23f67eff Mon Sep 17 00:00:00 2001 > From: Paul Burton > Date: Thu, 30 Aug 2018 11:01:21 -0700 > Subject: [PATCH] MIPS: VDSO: Match data page cache colouring when D$ aliases > > When a system suffers from dcache aliasing a user program may observe > stale VDSO data from an aliased cache line. Notably this can break the > expectation that clock_gettime(CLOCK_MONOTONIC, ...) is, as its name > suggests, monotonic. > > In order to ensure that users observe updates to the VDSO data page as > intended, align the user mappings of the VDSO data page such that their > cache colouring matches that of the virtual address range which the > kernel will use to update the data page - typically its unmapped address > within kseg0. > > This ensures that we don't introduce aliasing cache lines for the VDSO > data page, and therefore that userland will observe updates without > requiring cache invalidation. > > Signed-off-by: Paul Burton > Reported-by: Hauke Mehrtens > Reported-by: Rene Nielsen > Reported-by: Alexandre Belloni > Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO") > Patchwork: https://patchwork.linux-mips.org/patch/20344/ > Tested-by: Alexandre Belloni > Tested-by: Hauke Mehrtens > Cc: James Hogan > Cc: linux-mips@linux-mips.org > Cc: stable@vger.kernel.org # v4.4+ > > diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c > index 019035d7225c..8f845f6e5f42 100644 > --- a/arch/mips/kernel/vdso.c > +++ b/arch/mips/kernel/vdso.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -20,6 +21,7 @@ > > #include > #include > +#include > #include > > /* Kernel-provided data used by the VDSO. */ > @@ -128,12 +130,30 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) > vvar_size = gic_size + PAGE_SIZE; > size = vvar_size + image->size; > > + /* > + * Find a region that's large enough for us to perform the > + * colour-matching alignment below. > + */ > + if (cpu_has_dc_aliases) > + size += shm_align_mask + 1; > + > base = get_unmapped_area(NULL, 0, size, 0, 0); > if (IS_ERR_VALUE(base)) { > ret = base; > goto out; > } > > + /* > + * If we suffer from dcache aliasing, ensure that the VDSO data page > + * mapping is coloured the same as the kernel's mapping of that memory. > + * This ensures that when the kernel updates the VDSO data userland > + * will observe it without requiring cache invalidations. > + */ > + if (cpu_has_dc_aliases) { > + base = __ALIGN_MASK(base, shm_align_mask); > + base += ((unsigned long)&vdso_data - gic_size) & shm_align_mask; > + } > + > data_addr = base + gic_size; > vdso_addr = data_addr + PAGE_SIZE; > > -- SZ Lin (林上智) , http://people.debian.org/~szlin Debian Developer, debian.org.tw Administrator 4096R/ 178F 8338 B314 01E3 04FC 44BA A959 B38A 9561 F3F9