[PATCH] Wrong page protection flags on FreeBSD/PPC

Hal Finkel hfinkel at anl.gov
Wed Feb 20 09:55:59 PST 2013


----- Original Message -----
> From: "Krzysztof Parzyszek" <kparzysz at codeaurora.org>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "Roman Divacky" <rdivacky at freebsd.org>, "LLVM Commits" <llvm-commits at cs.uiuc.edu>
> Sent: Wednesday, February 20, 2013 11:27:55 AM
> Subject: Re: [PATCH] Wrong page protection flags on FreeBSD/PPC
> 
> Hi Hal,
> Do you work on Linux?  I'm guessing you don't see any problems
> related
> to this.
> What do you think about this patch?

It is fine by me. I don't know why FreeBSD and Linux differ here, but I suppose this is an empirical matter. Please feel free to commit. Is there a reason that we don't want to remove read permission after the flush?

 -Hal

> 
> -Krzysztof
> 
> 
> On 2/18/2013 12:17 PM, Roman Divacky wrote:
> > 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
> >
> 
> 
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> 



More information about the llvm-commits mailing list