@@ -2389,17 +2389,15 @@ fn test_callx() {
2389
2389
test_interpreter_and_jit_asm ! (
2390
2390
"
2391
2391
mov64 r0, 0x0
2392
- mov64 r8, 0x1
2393
- lsh64 r8, 0x20
2394
- or64 r8, 0x30
2392
+ or64 r8, 0x20
2395
2393
callx r8
2396
2394
exit
2397
2395
function_foo:
2398
2396
mov64 r0, 0x2A
2399
2397
exit" ,
2400
2398
[ ] ,
2401
2399
( ) ,
2402
- TestContextObject :: new( 8 ) ,
2400
+ TestContextObject :: new( 6 ) ,
2403
2401
ProgramResult :: Ok ( 42 ) ,
2404
2402
) ;
2405
2403
}
@@ -2409,27 +2407,30 @@ fn test_err_callx_unregistered() {
2409
2407
test_interpreter_and_jit_asm ! (
2410
2408
"
2411
2409
mov64 r0, 0x0
2412
- mov64 r8, 0x1
2413
- lsh64 r8, 0x20
2414
- or64 r8, 0x30
2410
+ or64 r8, 0x20
2415
2411
callx r8
2416
2412
exit
2417
2413
mov64 r0, 0x2A
2418
2414
exit" ,
2419
2415
[ ] ,
2420
2416
( ) ,
2421
- TestContextObject :: new( 6 ) ,
2417
+ TestContextObject :: new( 4 ) ,
2422
2418
ProgramResult :: Err ( EbpfError :: UnsupportedInstruction ) ,
2423
2419
) ;
2424
2420
}
2425
2421
2426
2422
#[ test]
2427
2423
fn test_err_callx_oob_low ( ) {
2424
+ let config = Config {
2425
+ enabled_sbpf_versions : SBPFVersion :: V1 ..=SBPFVersion :: V1 ,
2426
+ ..Config :: default ( )
2427
+ } ;
2428
2428
test_interpreter_and_jit_asm ! (
2429
2429
"
2430
2430
mov64 r0, 0x3
2431
2431
callx r0
2432
2432
exit" ,
2433
+ config,
2433
2434
[ ] ,
2434
2435
( ) ,
2435
2436
TestContextObject :: new( 2 ) ,
@@ -2518,14 +2519,12 @@ fn test_err_reg_stack_depth() {
2518
2519
} ;
2519
2520
test_interpreter_and_jit_asm ! (
2520
2521
"
2521
- mov64 r0, 0x1
2522
- lsh64 r0, 0x20
2523
2522
callx r0
2524
2523
exit" ,
2525
2524
config,
2526
2525
[ ] ,
2527
2526
( ) ,
2528
- TestContextObject :: new( max_call_depth as u64 * 3 ) ,
2527
+ TestContextObject :: new( max_call_depth as u64 ) ,
2529
2528
ProgramResult :: Err ( EbpfError :: CallDepthExceeded ) ,
2530
2529
) ;
2531
2530
}
@@ -2765,9 +2764,7 @@ fn test_tight_infinite_recursion() {
2765
2764
fn test_tight_infinite_recursion_callx ( ) {
2766
2765
test_interpreter_and_jit_asm ! (
2767
2766
"
2768
- mov64 r8, 0x1
2769
- lsh64 r8, 0x20
2770
- or64 r8, 0x28
2767
+ or64 r8, 0x18
2771
2768
call function_foo
2772
2769
exit
2773
2770
function_foo:
@@ -2776,7 +2773,7 @@ fn test_tight_infinite_recursion_callx() {
2776
2773
exit" ,
2777
2774
[ ] ,
2778
2775
( ) ,
2779
- TestContextObject :: new( 8 ) ,
2776
+ TestContextObject :: new( 6 ) ,
2780
2777
ProgramResult :: Err ( EbpfError :: ExceededMaxInstructions ) ,
2781
2778
) ;
2782
2779
}
@@ -2815,27 +2812,6 @@ fn test_err_instruction_count_syscall_capped() {
2815
2812
) ;
2816
2813
}
2817
2814
2818
- #[ test]
2819
- fn test_non_terminate_early ( ) {
2820
- test_interpreter_and_jit_asm ! (
2821
- "
2822
- mov64 r6, 0x0
2823
- mov64 r1, 0x0
2824
- mov64 r2, 0x0
2825
- mov64 r3, 0x0
2826
- mov64 r4, 0x0
2827
- mov64 r5, r6
2828
- callx r6
2829
- add64 r6, 0x1
2830
- ja -0x8
2831
- exit" ,
2832
- [ ] ,
2833
- ( ) ,
2834
- TestContextObject :: new( 7 ) ,
2835
- ProgramResult :: Err ( EbpfError :: CallOutsideTextSegment ) ,
2836
- ) ;
2837
- }
2838
-
2839
2815
#[ test]
2840
2816
fn test_err_non_terminate_capped ( ) {
2841
2817
test_interpreter_and_jit_asm ! (
@@ -2882,31 +2858,27 @@ fn test_err_non_terminate_capped() {
2882
2858
fn test_err_capped_before_exception ( ) {
2883
2859
test_interpreter_and_jit_asm ! (
2884
2860
"
2885
- mov64 r1, 0x0
2886
- mov64 r2, 0x0
2887
- add64 r0, 0x0
2888
- add64 r0, 0x0
2861
+ mov64 r0, 0x0
2862
+ add64 r2, 0x0
2889
2863
udiv64 r1, r2
2890
2864
add64 r0, 0x0
2891
2865
exit" ,
2892
2866
[ ] ,
2893
2867
( ) ,
2894
- TestContextObject :: new( 4 ) ,
2868
+ TestContextObject :: new( 2 ) ,
2895
2869
ProgramResult :: Err ( EbpfError :: ExceededMaxInstructions ) ,
2896
2870
) ;
2897
2871
2898
2872
test_interpreter_and_jit_asm ! (
2899
2873
"
2900
- mov64 r1, 0x0
2901
- mov64 r2, 0x0
2902
- add64 r0, 0x0
2903
- add64 r0, 0x0
2874
+ mov64 r0, 0x0
2875
+ hor64 r2, 0x1
2904
2876
callx r2
2905
2877
add64 r0, 0x0
2906
2878
exit" ,
2907
2879
[ ] ,
2908
2880
( ) ,
2909
- TestContextObject :: new( 4 ) ,
2881
+ TestContextObject :: new( 2 ) ,
2910
2882
ProgramResult :: Err ( EbpfError :: ExceededMaxInstructions ) ,
2911
2883
) ;
2912
2884
}
@@ -2915,33 +2887,29 @@ fn test_err_capped_before_exception() {
2915
2887
fn test_err_exit_capped ( ) {
2916
2888
test_interpreter_and_jit_asm ! (
2917
2889
"
2918
- mov64 r1, 0x1
2919
- lsh64 r1, 0x20
2920
- or64 r1, 0x28
2921
- callx r1
2890
+ or64 r0, 0x18
2891
+ callx r0
2922
2892
exit
2923
2893
function_foo:
2924
2894
exit
2925
2895
" ,
2926
2896
[ ] ,
2927
2897
( ) ,
2928
- TestContextObject :: new( 5 ) ,
2898
+ TestContextObject :: new( 3 ) ,
2929
2899
ProgramResult :: Err ( EbpfError :: ExceededMaxInstructions ) ,
2930
2900
) ;
2931
2901
test_interpreter_and_jit_asm ! (
2932
2902
"
2933
- mov64 r1, 0x1
2934
- lsh64 r1, 0x20
2935
- or64 r1, 0x28
2936
- callx r1
2903
+ or64 r0, 0x18
2904
+ callx r0
2937
2905
exit
2938
2906
function_foo:
2939
2907
mov r0, r0
2940
2908
exit
2941
2909
" ,
2942
2910
[ ] ,
2943
2911
( ) ,
2944
- TestContextObject :: new( 6 ) ,
2912
+ TestContextObject :: new( 4 ) ,
2945
2913
ProgramResult :: Err ( EbpfError :: ExceededMaxInstructions ) ,
2946
2914
) ;
2947
2915
test_interpreter_and_jit_asm ! (
@@ -2970,13 +2938,12 @@ fn test_far_jumps() {
2970
2938
.fill 1024, 0x0F
2971
2939
exit
2972
2940
function_c:
2973
- mov32 r1, 0x00000010
2974
- hor64 r1, 0x00000001
2941
+ mov32 r1, 0x10
2975
2942
callx r1
2976
2943
exit" ,
2977
2944
[ ] ,
2978
2945
( ) ,
2979
- TestContextObject :: new( 7 ) ,
2946
+ TestContextObject :: new( 6 ) ,
2980
2947
ProgramResult :: Ok ( 0 ) ,
2981
2948
) ;
2982
2949
}
0 commit comments