[PATCH] Wrong page protection flags on FreeBSD/PPC

Roman Divacky rdivacky at freebsd.org
Mon Feb 18 10:17:52 PST 2013


This is also a problem on Mac OS, or quite possibly everywhere except Linux.
There was a bug about this, you can search the bugzilla. I suggested pretty
much the same patch.

On Mon, Feb 18, 2013 at 09:02:52AM -0600, Krzysztof Parzyszek wrote:
> The LLVM unit tests (Support) fail on FreeBSD/PPC with a segmentation 
> fault.  The problem is in this part:
>    if (PFlags & MF_EXEC)
>      Memory::InvalidateInstructionCache(Result.Address, Result.Size);
> 
> In order to use the instructions in the Invalidate... function, the 
> memory needs to be readable.
> 
> The proposed fix is to always add PROT_READ to PROT_EXEC on FreeBSD.
> 
> -Krzysztof
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
> hosted by The Linux Foundation

> >From a78e54805687ad090bf8d9ec017e70a383d8320f Mon Sep 17 00:00:00 2001
> From: Krzysztof Parzyszek <kparzysz at codeaurora.org>
> Date: Fri, 15 Feb 2013 09:01:15 -0600
> Subject: [PATCH] On PowerPC, the cache-flush instructions dcbf and icbi are
>  treated as loads. On FreeBSD, add PROT_READ page protection
>  flag before flushing cache.
> 
> ---
>  lib/Support/Unix/Memory.inc |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/Support/Unix/Memory.inc b/lib/Support/Unix/Memory.inc
> index 40d6b3f..a66e3c7 100644
> --- a/lib/Support/Unix/Memory.inc
> +++ b/lib/Support/Unix/Memory.inc
> @@ -51,7 +51,11 @@ int getPosixProtectionFlags(unsigned Flags) {
>  	 llvm::sys::Memory::MF_EXEC:
>      return PROT_READ | PROT_WRITE | PROT_EXEC;
>    case llvm::sys::Memory::MF_EXEC:
> +#if defined(__FreeBSD__)
> +    return PROT_READ | PROT_EXEC;
> +#else
>      return PROT_EXEC;
> +#endif
>    default:
>      llvm_unreachable("Illegal memory protection flag specified!");
>    }
> -- 
> 1.7.6.4
> 

> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list