@@ -1623,6 +1623,16 @@ static size_t tsrm_tls_offset;
1623
1623
|| }
1624
1624
|.endmacro
1625
1625
1626
+ |.macro ENDBR
1627
+ ||#if defined (__CET__) && (__CET__ & 1) != 0
1628
+ | .if X64
1629
+ | endbr64
1630
+ | .else
1631
+ | endbr32
1632
+ | .endif
1633
+ ||#endif
1634
+ |.endmacro
1635
+
1626
1636
static bool reuse_ip = 0;
1627
1637
static bool delayed_call_chain = 0;
1628
1638
static uint32_t delayed_call_level = 0;
@@ -1690,6 +1700,7 @@ static void zend_jit_stop_reuse_ip(void)
1690
1700
static int zend_jit_interrupt_handler_stub(dasm_State **Dst)
1691
1701
{
1692
1702
|->interrupt_handler:
1703
+ | ENDBR
1693
1704
| SAVE_IP
1694
1705
| //EG(vm_interrupt) = 0;
1695
1706
| MEM_STORE_ZTS byte, executor_globals, vm_interrupt, 0, r0
@@ -1739,6 +1750,7 @@ static int zend_jit_interrupt_handler_stub(dasm_State **Dst)
1739
1750
static int zend_jit_exception_handler_stub(dasm_State **Dst)
1740
1751
{
1741
1752
|->exception_handler:
1753
+ | ENDBR
1742
1754
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
1743
1755
const void *handler = zend_get_opcode_handler_func(EG(exception_op));
1744
1756
@@ -1771,6 +1783,7 @@ static int zend_jit_exception_handler_stub(dasm_State **Dst)
1771
1783
static int zend_jit_exception_handler_undef_stub(dasm_State **Dst)
1772
1784
{
1773
1785
|->exception_handler_undef:
1786
+ | ENDBR
1774
1787
| MEM_LOAD_ZTS r0, aword, executor_globals, opline_before_exception, r0
1775
1788
| test byte OP:r0->result_type, (IS_TMP_VAR|IS_VAR)
1776
1789
| jz >1
@@ -1786,6 +1799,7 @@ static int zend_jit_exception_handler_undef_stub(dasm_State **Dst)
1786
1799
static int zend_jit_exception_handler_free_op1_op2_stub(dasm_State **Dst)
1787
1800
{
1788
1801
|->exception_handler_free_op1_op2:
1802
+ | ENDBR
1789
1803
| UNDEF_OPLINE_RESULT_IF_USED
1790
1804
| test byte OP:RX->op1_type, (IS_TMP_VAR|IS_VAR)
1791
1805
| je >9
@@ -1806,6 +1820,7 @@ static int zend_jit_exception_handler_free_op1_op2_stub(dasm_State **Dst)
1806
1820
static int zend_jit_exception_handler_free_op2_stub(dasm_State **Dst)
1807
1821
{
1808
1822
|->exception_handler_free_op2:
1823
+ | ENDBR
1809
1824
| MEM_LOAD_ZTS RX, aword, executor_globals, opline_before_exception, r0
1810
1825
| UNDEF_OPLINE_RESULT_IF_USED
1811
1826
| test byte OP:RX->op2_type, (IS_TMP_VAR|IS_VAR)
@@ -1821,6 +1836,7 @@ static int zend_jit_exception_handler_free_op2_stub(dasm_State **Dst)
1821
1836
static int zend_jit_leave_function_stub(dasm_State **Dst)
1822
1837
{
1823
1838
|->leave_function_handler:
1839
+ | ENDBR
1824
1840
| mov FCARG1d, dword [FP + offsetof(zend_execute_data, This.u1.type_info)]
1825
1841
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
1826
1842
| test FCARG1d, ZEND_CALL_TOP
@@ -1854,6 +1870,7 @@ static int zend_jit_leave_function_stub(dasm_State **Dst)
1854
1870
static int zend_jit_leave_throw_stub(dasm_State **Dst)
1855
1871
{
1856
1872
|->leave_throw_handler:
1873
+ | ENDBR
1857
1874
| // if (opline->opcode != ZEND_HANDLE_EXCEPTION) {
1858
1875
if (GCC_GLOBAL_REGS) {
1859
1876
| cmp byte OP:IP->opcode, ZEND_HANDLE_EXCEPTION
@@ -1887,6 +1904,7 @@ static int zend_jit_leave_throw_stub(dasm_State **Dst)
1887
1904
static int zend_jit_icall_throw_stub(dasm_State **Dst)
1888
1905
{
1889
1906
|->icall_throw_handler:
1907
+ | ENDBR
1890
1908
| // zend_rethrow_exception(zend_execute_data *execute_data)
1891
1909
| mov IP, aword EX->opline
1892
1910
| // if (EX(opline)->opcode != ZEND_HANDLE_EXCEPTION) {
@@ -1909,6 +1927,7 @@ static int zend_jit_icall_throw_stub(dasm_State **Dst)
1909
1927
static int zend_jit_throw_cannot_pass_by_ref_stub(dasm_State **Dst)
1910
1928
{
1911
1929
|->throw_cannot_pass_by_ref:
1930
+ | ENDBR
1912
1931
| mov r0, EX->opline
1913
1932
| mov ecx, dword OP:r0->result.var
1914
1933
| SET_Z_TYPE_INFO RX+r1, IS_UNDEF
@@ -1936,6 +1955,7 @@ static int zend_jit_throw_cannot_pass_by_ref_stub(dasm_State **Dst)
1936
1955
static int zend_jit_undefined_offset_ex_stub(dasm_State **Dst)
1937
1956
{
1938
1957
|->undefined_offset_ex:
1958
+ | ENDBR
1939
1959
| SAVE_IP
1940
1960
| jmp ->undefined_offset
1941
1961
@@ -1945,6 +1965,7 @@ static int zend_jit_undefined_offset_ex_stub(dasm_State **Dst)
1945
1965
static int zend_jit_undefined_offset_stub(dasm_State **Dst)
1946
1966
{
1947
1967
|->undefined_offset:
1968
+ | ENDBR
1948
1969
|.if X64WIN
1949
1970
| sub r4, 0x28
1950
1971
|.elif X64
@@ -1996,6 +2017,7 @@ static int zend_jit_undefined_offset_stub(dasm_State **Dst)
1996
2017
static int zend_jit_undefined_index_ex_stub(dasm_State **Dst)
1997
2018
{
1998
2019
|->undefined_index_ex:
2020
+ | ENDBR
1999
2021
| SAVE_IP
2000
2022
| jmp ->undefined_index
2001
2023
@@ -2005,6 +2027,7 @@ static int zend_jit_undefined_index_ex_stub(dasm_State **Dst)
2005
2027
static int zend_jit_undefined_index_stub(dasm_State **Dst)
2006
2028
{
2007
2029
|->undefined_index:
2030
+ | ENDBR
2008
2031
|.if X64WIN
2009
2032
| sub r4, 0x28
2010
2033
|.elif X64
@@ -2060,6 +2083,7 @@ static int zend_jit_undefined_index_stub(dasm_State **Dst)
2060
2083
static int zend_jit_cannot_add_element_ex_stub(dasm_State **Dst)
2061
2084
{
2062
2085
|->cannot_add_element_ex:
2086
+ | ENDBR
2063
2087
| SAVE_IP
2064
2088
| jmp ->cannot_add_element
2065
2089
@@ -2069,6 +2093,7 @@ static int zend_jit_cannot_add_element_ex_stub(dasm_State **Dst)
2069
2093
static int zend_jit_cannot_add_element_stub(dasm_State **Dst)
2070
2094
{
2071
2095
|->cannot_add_element:
2096
+ | ENDBR
2072
2097
|.if X64WIN
2073
2098
| sub r4, 0x28
2074
2099
|.elif X64
@@ -2107,6 +2132,7 @@ static int zend_jit_cannot_add_element_stub(dasm_State **Dst)
2107
2132
static int zend_jit_undefined_function_stub(dasm_State **Dst)
2108
2133
{
2109
2134
|->undefined_function:
2135
+ | ENDBR
2110
2136
| mov r0, aword EX->opline
2111
2137
|.if X64
2112
2138
| xor CARG1, CARG1
@@ -2131,6 +2157,7 @@ static int zend_jit_undefined_function_stub(dasm_State **Dst)
2131
2157
static int zend_jit_negative_shift_stub(dasm_State **Dst)
2132
2158
{
2133
2159
|->negative_shift:
2160
+ | ENDBR
2134
2161
| mov RX, EX->opline
2135
2162
|.if X64
2136
2163
|.if WIN
@@ -2160,6 +2187,7 @@ static int zend_jit_negative_shift_stub(dasm_State **Dst)
2160
2187
static int zend_jit_mod_by_zero_stub(dasm_State **Dst)
2161
2188
{
2162
2189
|->mod_by_zero:
2190
+ | ENDBR
2163
2191
| mov RX, EX->opline
2164
2192
|.if X64
2165
2193
|.if WIN
@@ -2189,6 +2217,7 @@ static int zend_jit_mod_by_zero_stub(dasm_State **Dst)
2189
2217
static int zend_jit_invalid_this_stub(dasm_State **Dst)
2190
2218
{
2191
2219
|->invalid_this:
2220
+ | ENDBR
2192
2221
| UNDEF_OPLINE_RESULT
2193
2222
|.if X64
2194
2223
| xor CARG1, CARG1
@@ -2208,6 +2237,7 @@ static int zend_jit_invalid_this_stub(dasm_State **Dst)
2208
2237
static int zend_jit_double_one_stub(dasm_State **Dst)
2209
2238
{
2210
2239
|->one:
2240
+ | ENDBR
2211
2241
|.dword 0, 0x3ff00000
2212
2242
return 1;
2213
2243
}
@@ -2219,6 +2249,7 @@ static int zend_jit_hybrid_runtime_jit_stub(dasm_State **Dst)
2219
2249
}
2220
2250
2221
2251
|->hybrid_runtime_jit:
2252
+ | ENDBR
2222
2253
| EXT_CALL zend_runtime_jit, r0
2223
2254
| JMP_IP
2224
2255
return 1;
@@ -2231,6 +2262,7 @@ static int zend_jit_hybrid_profile_jit_stub(dasm_State **Dst)
2231
2262
}
2232
2263
2233
2264
|->hybrid_profile_jit:
2265
+ | ENDBR
2234
2266
| // ++zend_jit_profile_counter;
2235
2267
| .if X64
2236
2268
| LOAD_ADDR r0, &zend_jit_profile_counter
@@ -2258,6 +2290,7 @@ static int zend_jit_hybrid_hot_code_stub(dasm_State **Dst)
2258
2290
}
2259
2291
2260
2292
|->hybrid_hot_code:
2293
+ | ENDBR
2261
2294
| mov word [r2], ZEND_JIT_COUNTER_INIT
2262
2295
| mov FCARG1a, FP
2263
2296
| GET_IP FCARG2a
@@ -2322,7 +2355,7 @@ static int zend_jit_hybrid_func_hot_counter_stub(dasm_State **Dst)
2322
2355
}
2323
2356
2324
2357
|->hybrid_func_hot_counter:
2325
-
2358
+ | ENDBR
2326
2359
return zend_jit_hybrid_hot_counter_stub(Dst,
2327
2360
((ZEND_JIT_COUNTER_INIT + JIT_G(hot_func) - 1) / JIT_G(hot_func)));
2328
2361
}
@@ -2334,7 +2367,7 @@ static int zend_jit_hybrid_loop_hot_counter_stub(dasm_State **Dst)
2334
2367
}
2335
2368
2336
2369
|->hybrid_loop_hot_counter:
2337
-
2370
+ | ENDBR
2338
2371
return zend_jit_hybrid_hot_counter_stub(Dst,
2339
2372
((ZEND_JIT_COUNTER_INIT + JIT_G(hot_loop) - 1) / JIT_G(hot_loop)));
2340
2373
}
@@ -2346,6 +2379,7 @@ static int zend_jit_hybrid_hot_trace_stub(dasm_State **Dst)
2346
2379
}
2347
2380
2348
2381
|->hybrid_hot_trace:
2382
+ | ENDBR
2349
2383
| mov word [r2], ZEND_JIT_COUNTER_INIT
2350
2384
| mov FCARG1a, FP
2351
2385
| GET_IP FCARG2a
@@ -2379,7 +2413,7 @@ static int zend_jit_hybrid_func_trace_counter_stub(dasm_State **Dst)
2379
2413
}
2380
2414
2381
2415
|->hybrid_func_trace_counter:
2382
-
2416
+ | ENDBR
2383
2417
return zend_jit_hybrid_trace_counter_stub(Dst,
2384
2418
((ZEND_JIT_COUNTER_INIT + JIT_G(hot_func) - 1) / JIT_G(hot_func)));
2385
2419
}
@@ -2391,7 +2425,7 @@ static int zend_jit_hybrid_ret_trace_counter_stub(dasm_State **Dst)
2391
2425
}
2392
2426
2393
2427
|->hybrid_ret_trace_counter:
2394
-
2428
+ | ENDBR
2395
2429
return zend_jit_hybrid_trace_counter_stub(Dst,
2396
2430
((ZEND_JIT_COUNTER_INIT + JIT_G(hot_return) - 1) / JIT_G(hot_return)));
2397
2431
}
@@ -2403,14 +2437,15 @@ static int zend_jit_hybrid_loop_trace_counter_stub(dasm_State **Dst)
2403
2437
}
2404
2438
2405
2439
|->hybrid_loop_trace_counter:
2406
-
2440
+ | ENDBR
2407
2441
return zend_jit_hybrid_trace_counter_stub(Dst,
2408
2442
((ZEND_JIT_COUNTER_INIT + JIT_G(hot_loop) - 1) / JIT_G(hot_loop)));
2409
2443
}
2410
2444
2411
2445
static int zend_jit_trace_halt_stub(dasm_State **Dst)
2412
2446
{
2413
2447
|->trace_halt:
2448
+ | ENDBR
2414
2449
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
2415
2450
| ADD_HYBRID_SPAD
2416
2451
| EXT_JMP zend_jit_halt_op->handler, r0
@@ -2431,7 +2466,7 @@ static int zend_jit_trace_halt_stub(dasm_State **Dst)
2431
2466
static int zend_jit_trace_exit_stub(dasm_State **Dst)
2432
2467
{
2433
2468
|->trace_exit:
2434
- |
2469
+ | ENDBR
2435
2470
| // Save CPU registers
2436
2471
|.if X64
2437
2472
| sub r4, 16*8+16*8-8 /* CPU regs + SSE regs */
@@ -2564,6 +2599,7 @@ static int zend_jit_trace_exit_stub(dasm_State **Dst)
2564
2599
static int zend_jit_trace_escape_stub(dasm_State **Dst)
2565
2600
{
2566
2601
|->trace_escape:
2602
+ | ENDBR
2567
2603
|
2568
2604
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
2569
2605
| ADD_HYBRID_SPAD
@@ -2606,6 +2642,7 @@ static int zend_jit_trace_exit_group_stub(dasm_State **Dst, uint32_t n)
2606
2642
static int zend_jit_context_threaded_call_stub(dasm_State **Dst)
2607
2643
{
2608
2644
|->context_threaded_call:
2645
+ | ENDBR
2609
2646
| pop r0
2610
2647
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
2611
2648
| ADD_HYBRID_SPAD
@@ -2635,6 +2672,7 @@ static int zend_jit_assign_const_stub(dasm_State **Dst)
2635
2672
uint32_t val_info = MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN;
2636
2673
2637
2674
|->assign_const:
2675
+ | ENDBR
2638
2676
|.if X64WIN
2639
2677
| sub r4, 0x28
2640
2678
|.elif X64
@@ -2667,6 +2705,7 @@ static int zend_jit_assign_tmp_stub(dasm_State **Dst)
2667
2705
uint32_t val_info = MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN;
2668
2706
2669
2707
|->assign_tmp:
2708
+ | ENDBR
2670
2709
|.if X64WIN
2671
2710
| sub r4, 0x28
2672
2711
|.elif X64
@@ -2699,6 +2738,7 @@ static int zend_jit_assign_var_stub(dasm_State **Dst)
2699
2738
uint32_t val_info = MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF;
2700
2739
2701
2740
|->assign_var:
2741
+ | ENDBR
2702
2742
|.if X64WIN
2703
2743
| sub r4, 0x28
2704
2744
|.elif X64
@@ -2731,6 +2771,7 @@ static int zend_jit_assign_cv_noref_stub(dasm_State **Dst)
2731
2771
uint32_t val_info = MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN/*|MAY_BE_UNDEF*/;
2732
2772
2733
2773
|->assign_cv_noref:
2774
+ | ENDBR
2734
2775
|.if X64WIN
2735
2776
| sub r4, 0x28
2736
2777
|.elif X64
@@ -2763,6 +2804,7 @@ static int zend_jit_assign_cv_stub(dasm_State **Dst)
2763
2804
uint32_t val_info = MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF/*|MAY_BE_UNDEF*/;
2764
2805
2765
2806
|->assign_cv:
2807
+ | ENDBR
2766
2808
|.if X64WIN
2767
2809
| sub r4, 0x28
2768
2810
|.elif X64
@@ -3044,6 +3086,7 @@ static int zend_jit_align_func(dasm_State **Dst)
3044
3086
track_last_valid_opline = 0;
3045
3087
jit_return_label = -1;
3046
3088
|.align 16
3089
+ | ENDBR
3047
3090
return 1;
3048
3091
}
3049
3092
@@ -3065,6 +3108,7 @@ static int zend_jit_prologue(dasm_State **Dst)
3065
3108
static int zend_jit_label(dasm_State **Dst, unsigned int label)
3066
3109
{
3067
3110
|=>label:
3111
+ | ENDBR
3068
3112
return 1;
3069
3113
}
3070
3114
@@ -3824,10 +3868,11 @@ static int zend_jit_context_threaded_call(dasm_State **Dst, const zend_op *oplin
3824
3868
{
3825
3869
if (!zend_jit_handler(Dst, opline, 1)) return 0;
3826
3870
if (opline->opcode == ZEND_DO_UCALL) {
3871
+ | ENDBR
3827
3872
| call ->context_threaded_call
3828
3873
} else {
3829
3874
const zend_op *next_opline = opline + 1;
3830
-
3875
+ | ENDBR
3831
3876
| CMP_IP next_opline
3832
3877
| je =>next_block
3833
3878
| call ->context_threaded_call
0 commit comments