@@ -3271,11 +3271,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
32713271 switch (insn -> type ) {
32723272
32733273 case INSN_RETURN :
3274- if (opts .sls && !insn -> retpoline_safe &&
3275- next_insn && next_insn -> type != INSN_TRAP ) {
3276- WARN_FUNC ("missing int3 after ret" ,
3277- insn -> sec , insn -> offset );
3278- }
32793274 return validate_return (func , insn , & state );
32803275
32813276 case INSN_CALL :
@@ -3319,13 +3314,6 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
33193314 break ;
33203315
33213316 case INSN_JUMP_DYNAMIC :
3322- if (opts .sls && !insn -> retpoline_safe &&
3323- next_insn && next_insn -> type != INSN_TRAP ) {
3324- WARN_FUNC ("missing int3 after indirect jump" ,
3325- insn -> sec , insn -> offset );
3326- }
3327-
3328- /* fallthrough */
33293317 case INSN_JUMP_DYNAMIC_CONDITIONAL :
33303318 if (is_sibling_call (insn )) {
33313319 ret = validate_sibling_call (file , insn , & state );
@@ -3845,6 +3833,41 @@ static int validate_ibt(struct objtool_file *file)
38453833 return warnings ;
38463834}
38473835
3836+ static int validate_sls (struct objtool_file * file )
3837+ {
3838+ struct instruction * insn , * next_insn ;
3839+ int warnings = 0 ;
3840+
3841+ for_each_insn (file , insn ) {
3842+ next_insn = next_insn_same_sec (file , insn );
3843+
3844+ if (insn -> retpoline_safe )
3845+ continue ;
3846+
3847+ switch (insn -> type ) {
3848+ case INSN_RETURN :
3849+ if (!next_insn || next_insn -> type != INSN_TRAP ) {
3850+ WARN_FUNC ("missing int3 after ret" ,
3851+ insn -> sec , insn -> offset );
3852+ warnings ++ ;
3853+ }
3854+
3855+ break ;
3856+ case INSN_JUMP_DYNAMIC :
3857+ if (!next_insn || next_insn -> type != INSN_TRAP ) {
3858+ WARN_FUNC ("missing int3 after indirect jump" ,
3859+ insn -> sec , insn -> offset );
3860+ warnings ++ ;
3861+ }
3862+ break ;
3863+ default :
3864+ break ;
3865+ }
3866+ }
3867+
3868+ return warnings ;
3869+ }
3870+
38483871static int validate_reachable_instructions (struct objtool_file * file )
38493872{
38503873 struct instruction * insn ;
@@ -3913,7 +3936,7 @@ int check(struct objtool_file *file)
39133936 warnings += ret ;
39143937 }
39153938
3916- if (opts .stackval || opts .orc || opts .uaccess || opts . sls ) {
3939+ if (opts .stackval || opts .orc || opts .uaccess ) {
39173940 ret = validate_functions (file );
39183941 if (ret < 0 )
39193942 goto out ;
@@ -3939,6 +3962,13 @@ int check(struct objtool_file *file)
39393962 warnings += ret ;
39403963 }
39413964
3965+ if (opts .sls ) {
3966+ ret = validate_sls (file );
3967+ if (ret < 0 )
3968+ goto out ;
3969+ warnings += ret ;
3970+ }
3971+
39423972 ret = create_static_call_sections (file );
39433973 if (ret < 0 )
39443974 goto out ;
0 commit comments