[PATCH] D62741: [PowerPC] Set PROT_READ flag for MF_EXEC to prevent segfaults on PPC machines

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 09:53:22 PDT 2019


nemanjai created this revision.
nemanjai added reviewers: hfinkel, echristo, joerg.
Herald added subscribers: jsji, kristina, hiraditya, krytarowski, emaste.
Herald added a project: LLVM.

The big endian PPC buildbots are all failing now due to calls to cache invalidation in unit tests on data that has only the `PROT_EXEC` flag set. This has been an issue all along on FreeBSD but it can affect Linux machines depending on configuration.

This patch mitigates the issue the same way it is mitigated on FreeBSD.

Since this is needed to bring the buildbots back to green, I plan to commit this and allow for post-commit review, but I thought I would also post it here for ease of access/readability. My plan is to commit this later this afternoon to unblock the bots.


Repository:
  rL LLVM

https://reviews.llvm.org/D62741

Files:
  llvm/lib/Support/Unix/Memory.inc


Index: llvm/lib/Support/Unix/Memory.inc
===================================================================
--- llvm/lib/Support/Unix/Memory.inc
+++ llvm/lib/Support/Unix/Memory.inc
@@ -58,14 +58,13 @@
       llvm::sys::Memory::MF_EXEC:
     return PROT_READ | PROT_WRITE | PROT_EXEC;
   case llvm::sys::Memory::MF_EXEC:
-#if defined(__FreeBSD__)
+#if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \
+     defined(_POWER) || defined(_ARCH_PPC))
     // On PowerPC, having an executable page that has no read permission
     // can have unintended consequences.  The function InvalidateInstruction-
     // Cache uses instructions dcbf and icbi, both of which are treated by
     // the processor as loads.  If the page has no read permissions,
     // executing these instructions will result in a segmentation fault.
-    // Somehow, this problem is not present on Linux, but it does happen
-    // on FreeBSD.
     return PROT_READ | PROT_EXEC;
 #else
     return PROT_EXEC;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62741.202454.patch
Type: text/x-patch
Size: 1001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190531/6a7b983b/attachment.bin>


More information about the llvm-commits mailing list