# git rev-parse -q --verify ad7b4e8022b9864c075fe71e1328b1d25cad82f6^{commit} ad7b4e8022b9864c075fe71e1328b1d25cad82f6 already have revision, skipping fetch # git checkout -q -f -B kisskb ad7b4e8022b9864c075fe71e1328b1d25cad82f6 # git clean -qxdf # < git log -1 # commit ad7b4e8022b9864c075fe71e1328b1d25cad82f6 # Author: Frederic Barrat # Date: Tue Apr 3 15:54:02 2018 +0200 # # cxl: Fix possible deadlock when processing page faults from cxllib # # cxllib_handle_fault() is called by an external driver when it needs to # have the host resolve page faults for a buffer. The buffer can cover # several pages and VMAs. The function iterates over all the pages used # by the buffer, based on the page size of the VMA. # # To ensure some stability while processing the faults, the thread T1 # grabs the mm->mmap_sem semaphore with read access (R1). However, when # processing a page fault for a single page, one of the underlying # functions, copro_handle_mm_fault(), also grabs the same semaphore with # read access (R2). So the thread T1 takes the semaphore twice. # # If another thread T2 tries to access the semaphore in write mode W1 # (say, because it wants to allocate memory and calls 'brk'), then that # thread T2 will have to wait because there's a reader (R1). If the # thread T1 is processing a new page at that time, it won't get an # automatic grant at R2, because there's now a writer thread # waiting (T2). And we have a deadlock. # # The timeline is: # 1. thread T1 owns the semaphore with read access R1 # 2. thread T2 requests write access W1 and waits # 3. thread T1 requests read access R2 and waits # # The fix is for the thread T1 to release the semaphore R1 once it got # the information it needs from the current VMA. The address space/VMAs # could evolve while T1 iterates over the full buffer, but in the # unlikely case where T1 misses a page, the external driver will raise a # new page fault when retrying the memory access. # # Fixes: 3ced8d730063 ("cxl: Export library to support IBM XSL") # Cc: stable@vger.kernel.org # 4.13+ # Signed-off-by: Frederic Barrat # Signed-off-by: Michael Ellerman # < /opt/cross/kisskb/gcc-5.3.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc --version # < git log --format=%s --max-count=1 ad7b4e8022b9864c075fe71e1328b1d25cad82f6 # < make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next_mpc85xx_smp_defconfig_powerpc-5.3 CROSS_COMPILE=/opt/cross/kisskb/gcc-5.3.0-nolibc/powerpc64-linux/bin/powerpc64-linux- mpc85xx_smp_defconfig # make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next_mpc85xx_smp_defconfig_powerpc-5.3 CROSS_COMPILE=/opt/cross/kisskb/gcc-5.3.0-nolibc/powerpc64-linux/bin/powerpc64-linux- In file included from /kisskb/src/include/linux/kernel.h:10:0, from /kisskb/src/include/linux/list.h:9, from /kisskb/src/include/linux/module.h:9, from /kisskb/src/drivers/net/ethernet/freescale/fs_enet/mac-scc.c:15: /kisskb/src/drivers/net/ethernet/freescale/fs_enet/mac-scc.c: In function 'allocate_bd': /kisskb/src/include/linux/err.h:22:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO) ^ /kisskb/src/include/linux/compiler.h:77:42: note: in definition of macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ /kisskb/src/drivers/net/ethernet/freescale/fs_enet/mac-scc.c:139:6: note: in expansion of macro 'IS_ERR_VALUE' if (IS_ERR_VALUE(fep->ring_mem_addr)) ^ INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbd9594) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xbc8ddc) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:49 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842173 Bytes = 5705.25 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:49 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842157 Bytes = 5705.23 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c00278 Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:49 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5818360 Bytes = 5681.99 kB = 5.55 MB Load Address: 00000000 Entry Point: 00000000 Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:50 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5841906 Bytes = 5704.99 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:50 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842064 Bytes = 5705.14 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c00278 Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:50 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842098 Bytes = 5705.17 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:53 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5844641 Bytes = 5707.66 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:54 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842170 Bytes = 5705.24 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c00278 Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:54 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842090 Bytes = 5705.17 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c00278 Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842143 Bytes = 5705.22 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5844510 Bytes = 5707.53 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5844010 Bytes = 5707.04 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842066 Bytes = 5705.14 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c00278 Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842178 Bytes = 5705.25 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5842350 Bytes = 5705.42 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Image Name: Linux-4.16.0-rc4-gad7b4e8 Created: Wed Apr 4 23:38:55 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5844286 Bytes = 5707.31 kB = 5.57 MB Load Address: 00c00000 Entry Point: 00c0020c Completed OK # rm -rf /kisskb/build/powerpc-next_mpc85xx_smp_defconfig_powerpc-5.3 # Build took: 0:01:46.951437