@@ -594,7 +594,7 @@ static void bpf_jit_epilogue(struct bpf_jit *jit, u32 stack_depth)
594
594
* stack space for the large switch statement.
595
595
*/
596
596
static noinline int bpf_jit_insn (struct bpf_jit * jit , struct bpf_prog * fp ,
597
- int i , bool extra_pass )
597
+ int i , bool extra_pass , u32 stack_depth )
598
598
{
599
599
struct bpf_insn * insn = & fp -> insnsi [i ];
600
600
u32 dst_reg = insn -> dst_reg ;
@@ -1207,7 +1207,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
1207
1207
*/
1208
1208
1209
1209
if (jit -> seen & SEEN_STACK )
1210
- off = STK_OFF_TCCNT + STK_OFF + fp -> aux -> stack_depth ;
1210
+ off = STK_OFF_TCCNT + STK_OFF + stack_depth ;
1211
1211
else
1212
1212
off = STK_OFF_TCCNT ;
1213
1213
/* lhi %w0,1 */
@@ -1249,7 +1249,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
1249
1249
/*
1250
1250
* Restore registers before calling function
1251
1251
*/
1252
- save_restore_regs (jit , REGS_RESTORE , fp -> aux -> stack_depth );
1252
+ save_restore_regs (jit , REGS_RESTORE , stack_depth );
1253
1253
1254
1254
/*
1255
1255
* goto *(prog->bpf_func + tail_call_start);
@@ -1519,26 +1519,26 @@ static int bpf_set_addr(struct bpf_jit *jit, int i)
1519
1519
* Compile eBPF program into s390x code
1520
1520
*/
1521
1521
static int bpf_jit_prog (struct bpf_jit * jit , struct bpf_prog * fp ,
1522
- bool extra_pass )
1522
+ bool extra_pass , u32 stack_depth )
1523
1523
{
1524
1524
int i , insn_count , lit32_size , lit64_size ;
1525
1525
1526
1526
jit -> lit32 = jit -> lit32_start ;
1527
1527
jit -> lit64 = jit -> lit64_start ;
1528
1528
jit -> prg = 0 ;
1529
1529
1530
- bpf_jit_prologue (jit , fp -> aux -> stack_depth );
1530
+ bpf_jit_prologue (jit , stack_depth );
1531
1531
if (bpf_set_addr (jit , 0 ) < 0 )
1532
1532
return -1 ;
1533
1533
for (i = 0 ; i < fp -> len ; i += insn_count ) {
1534
- insn_count = bpf_jit_insn (jit , fp , i , extra_pass );
1534
+ insn_count = bpf_jit_insn (jit , fp , i , extra_pass , stack_depth );
1535
1535
if (insn_count < 0 )
1536
1536
return -1 ;
1537
1537
/* Next instruction address */
1538
1538
if (bpf_set_addr (jit , i + insn_count ) < 0 )
1539
1539
return -1 ;
1540
1540
}
1541
- bpf_jit_epilogue (jit , fp -> aux -> stack_depth );
1541
+ bpf_jit_epilogue (jit , stack_depth );
1542
1542
1543
1543
lit32_size = jit -> lit32 - jit -> lit32_start ;
1544
1544
lit64_size = jit -> lit64 - jit -> lit64_start ;
@@ -1569,6 +1569,7 @@ struct s390_jit_data {
1569
1569
*/
1570
1570
struct bpf_prog * bpf_int_jit_compile (struct bpf_prog * fp )
1571
1571
{
1572
+ u32 stack_depth = round_up (fp -> aux -> stack_depth , 8 );
1572
1573
struct bpf_prog * tmp , * orig_fp = fp ;
1573
1574
struct bpf_binary_header * header ;
1574
1575
struct s390_jit_data * jit_data ;
@@ -1621,7 +1622,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
1621
1622
* - 3: Calculate program size and addrs arrray
1622
1623
*/
1623
1624
for (pass = 1 ; pass <= 3 ; pass ++ ) {
1624
- if (bpf_jit_prog (& jit , fp , extra_pass )) {
1625
+ if (bpf_jit_prog (& jit , fp , extra_pass , stack_depth )) {
1625
1626
fp = orig_fp ;
1626
1627
goto free_addrs ;
1627
1628
}
@@ -1635,7 +1636,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
1635
1636
goto free_addrs ;
1636
1637
}
1637
1638
skip_init_ctx :
1638
- if (bpf_jit_prog (& jit , fp , extra_pass )) {
1639
+ if (bpf_jit_prog (& jit , fp , extra_pass , stack_depth )) {
1639
1640
bpf_jit_binary_free (header );
1640
1641
fp = orig_fp ;
1641
1642
goto free_addrs ;
0 commit comments