From a0f02af83bd19dffda03bcc15328ee94ed2d4ad3 Mon Sep 17 00:00:00 2001 From: PeterYang12 Date: Fri, 28 Apr 2023 06:18:11 +0000 Subject: [PATCH] JIT: Align JIT stubs Fixed phpGH-11120 Signed-off-by: PeterYang12 --- ext/opcache/jit/zend_jit.c | 1 + ext/opcache/jit/zend_jit_arm64.dasc | 6 ++++++ ext/opcache/jit/zend_jit_trace.c | 1 + ext/opcache/jit/zend_jit_x86.dasc | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 231c976d0bab7..e5a748d8355a8 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -4696,6 +4696,7 @@ static int zend_jit_make_stubs(void) for (i = 0; i < sizeof(zend_jit_stubs)/sizeof(zend_jit_stubs[0]); i++) { dasm_setup(&dasm_state, dasm_actions); + zend_jit_align_stub(&dasm_state); if (!zend_jit_stubs[i].stub(&dasm_state)) { return 0; } diff --git a/ext/opcache/jit/zend_jit_arm64.dasc b/ext/opcache/jit/zend_jit_arm64.dasc index 99c7a53a44b4d..810e514ce9031 100644 --- a/ext/opcache/jit/zend_jit_arm64.dasc +++ b/ext/opcache/jit/zend_jit_arm64.dasc @@ -2854,6 +2854,12 @@ static int zend_jit_align_func(dasm_State **Dst) return 1; } +static int zend_jit_align_stub(dasm_State **Dst) +{ + |.align 16 + return 1; +} + static int zend_jit_prologue(dasm_State **Dst) { if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) { diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index f46e7a73cd5e7..ed8cdbc95b590 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -94,6 +94,7 @@ static const void *zend_jit_trace_allocate_exit_group(uint32_t n) dasm_init(&dasm_state, DASM_MAXSECTION); dasm_setupglobal(&dasm_state, dasm_labels, zend_lb_MAX); dasm_setup(&dasm_state, dasm_actions); + zend_jit_align_stub(&dasm_state); zend_jit_trace_exit_group_stub(&dasm_state, n); sprintf(name, "jit$$trace_exit_%d", n); diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 6846456973fdd..262aac14f7541 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -3070,6 +3070,12 @@ static int zend_jit_align_func(dasm_State **Dst) return 1; } +static int zend_jit_align_stub(dasm_State **Dst) +{ + |.align 16 + return 1; +} + static int zend_jit_prologue(dasm_State **Dst) { | ENDBR