Skip to content

Commit

Permalink
Set PROT_EXEC on the whole pixelflinger code cache.
Browse files Browse the repository at this point in the history
The pointer difference between word pointers is a number
of words, and it needs to be multiplied by the size of a word
to get a proper byte size.

Without this, we tend to see crashes when the code crosses
a page boundary.

Bug: 3026204
Bug: 3097482
Change-Id: I37776d26d5afcdb1da71680de02fbb95e6548371
  • Loading branch information
Jean-Baptiste Queru committed Oct 14, 2010
1 parent 9cd8057 commit 8e0e372
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libpixelflinger/codeflinger/CodeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void Assembly::ensureMbaseExecutable()
long pagemask = ~(pagesize - 1); // assumes pagesize is a power of 2

uint32_t* pageStart = (uint32_t*) (((uintptr_t) mBase) & pagemask);
size_t adjustedLength = mBase - pageStart + mSize;
size_t adjustedLength = (mBase - pageStart) * sizeof(uint32_t) + mSize;

if (mBase && mprotect(pageStart, adjustedLength, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
mspace_free(getMspace(), mBase);
Expand Down

0 comments on commit 8e0e372

Please sign in to comment.