From 066db584c9e3d0b367ea94401373072735335fa2 Mon Sep 17 00:00:00 2001 From: pcpa Date: Mon, 8 Apr 2013 18:00:36 -0300 Subject: [PATCH] Ensure the end argument of __clear_cache is page aligned. * lib/jit_arm.c, lib/jit_ppc.c: Do not rely on __clear_cache aligning to the next page boundary the end argument. It may actually truncate it. --- ChangeLog | 6 ++++++ lib/jit_arm.c | 3 ++- lib/jit_ppc.c | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a174e6433..fe265f9b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-04-08 Paulo Andrade + + * lib/jit_arm.c, lib/jit_ppc.c: Do not rely on __clear_cache + aligning to the next page boundary the end argument. It may + actually truncate it. + 2013-03-29 Paulo Andrade * include/lightning/jit_private.h, lib/jit_arm.c, lib/jit_memory.c, diff --git a/lib/jit_arm.c b/lib/jit_arm.c index c4fe59e27..07223e558 100644 --- a/lib/jit_arm.c +++ b/lib/jit_arm.c @@ -1563,7 +1563,8 @@ _emit_code(jit_state_t *_jit) patch_at(_jitc->patches.ptr[offset].kind & ~arm_patch_node, word, value); } - __clear_cache(_jit->code.ptr, _jit->pc.uc); + word = sysconf(_SC_PAGE_SIZE); + __clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word)); return (_jit->code.ptr); } diff --git a/lib/jit_ppc.c b/lib/jit_ppc.c index a09b24fa3..1f1c6b4ba 100644 --- a/lib/jit_ppc.c +++ b/lib/jit_ppc.c @@ -1346,7 +1346,8 @@ _emit_code(jit_state_t *_jit) patch_at(_jitc->patches.ptr[offset].inst, word); } - __clear_cache(_jit->code.ptr, _jit->pc.uc); + word = sysconf(_SC_PAGE_SIZE); + __clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word)); return (_jit->code.ptr); }