Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'objtool-urgent-2025-04-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull misc objtool fixes from Ingo Molnar:

- Remove the recently introduced ANNOTATE_IGNORE_ALTERNATIVE noise from
clac()/stac() code to make .s files more readable

- Fix INSN_SYSCALL / INSN_SYSRET semantics

- Fix various false-positive warnings

* tag 'objtool-urgent-2025-04-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
objtool: Fix false-positive "ignoring unreachables" warning
objtool: Remove ANNOTATE_IGNORE_ALTERNATIVE from CLAC/STAC
objtool, xen: Fix INSN_SYSCALL / INSN_SYSRET semantics
objtool: Stop UNRET validation on UD2
objtool: Split INSN_CONTEXT_SWITCH into INSN_SYSCALL and INSN_SYSRET
objtool: Fix INSN_CONTEXT_SWITCH handling in validate_unret()

+72 -26
+6 -6
arch/x86/include/asm/smap.h
··· 16 16 #ifdef __ASSEMBLER__ 17 17 18 18 #define ASM_CLAC \ 19 - ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "clac", X86_FEATURE_SMAP 19 + ALTERNATIVE "", "clac", X86_FEATURE_SMAP 20 20 21 21 #define ASM_STAC \ 22 - ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "stac", X86_FEATURE_SMAP 22 + ALTERNATIVE "", "stac", X86_FEATURE_SMAP 23 23 24 24 #else /* __ASSEMBLER__ */ 25 25 26 26 static __always_inline void clac(void) 27 27 { 28 28 /* Note: a barrier is implicit in alternative() */ 29 - alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP); 29 + alternative("", "clac", X86_FEATURE_SMAP); 30 30 } 31 31 32 32 static __always_inline void stac(void) 33 33 { 34 34 /* Note: a barrier is implicit in alternative() */ 35 - alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP); 35 + alternative("", "stac", X86_FEATURE_SMAP); 36 36 } 37 37 38 38 static __always_inline unsigned long smap_save(void) ··· 59 59 60 60 /* These macros can be used in asm() statements */ 61 61 #define ASM_CLAC \ 62 - ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP) 62 + ALTERNATIVE("", "clac", X86_FEATURE_SMAP) 63 63 #define ASM_STAC \ 64 - ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP) 64 + ALTERNATIVE("", "stac", X86_FEATURE_SMAP) 65 65 66 66 #define ASM_CLAC_UNSAFE \ 67 67 ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP)
+1 -3
arch/x86/xen/xen-asm.S
··· 226 226 push %rax 227 227 mov $__HYPERVISOR_iret, %eax 228 228 syscall /* Do the IRET. */ 229 - #ifdef CONFIG_MITIGATION_SLS 230 - int3 231 - #endif 229 + ud2 /* The SYSCALL should never return. */ 232 230 .endm 233 231 234 232 SYM_CODE_START(xen_iret)
+11 -7
tools/objtool/arch/x86/decode.c
··· 522 522 case INAT_PFX_REPNE: 523 523 if (modrm == 0xca) 524 524 /* eretu/erets */ 525 - insn->type = INSN_CONTEXT_SWITCH; 525 + insn->type = INSN_SYSRET; 526 526 break; 527 527 default: 528 528 if (modrm == 0xca) ··· 535 535 536 536 insn->type = INSN_JUMP_CONDITIONAL; 537 537 538 - } else if (op2 == 0x05 || op2 == 0x07 || op2 == 0x34 || 539 - op2 == 0x35) { 538 + } else if (op2 == 0x05 || op2 == 0x34) { 540 539 541 - /* sysenter, sysret */ 542 - insn->type = INSN_CONTEXT_SWITCH; 540 + /* syscall, sysenter */ 541 + insn->type = INSN_SYSCALL; 542 + 543 + } else if (op2 == 0x07 || op2 == 0x35) { 544 + 545 + /* sysret, sysexit */ 546 + insn->type = INSN_SYSRET; 543 547 544 548 } else if (op2 == 0x0b || op2 == 0xb9) { 545 549 ··· 680 676 681 677 case 0xca: /* retf */ 682 678 case 0xcb: /* retf */ 683 - insn->type = INSN_CONTEXT_SWITCH; 679 + insn->type = INSN_SYSRET; 684 680 break; 685 681 686 682 case 0xe0: /* loopne */ ··· 725 721 } else if (modrm_reg == 5) { 726 722 727 723 /* jmpf */ 728 - insn->type = INSN_CONTEXT_SWITCH; 724 + insn->type = INSN_SYSRET; 729 725 730 726 } else if (modrm_reg == 6) { 731 727
+1 -1
tools/objtool/arch/x86/special.c
··· 126 126 * indicates a rare GCC quirk/bug which can leave dead 127 127 * code behind. 128 128 */ 129 - if (reloc_type(text_reloc) == R_X86_64_PC32) { 129 + if (!file->ignore_unreachables && reloc_type(text_reloc) == R_X86_64_PC32) { 130 130 WARN_INSN(insn, "ignoring unreachables due to jump table quirk"); 131 131 file->ignore_unreachables = true; 132 132 }
+51 -8
tools/objtool/check.c
··· 3505 3505 return next_insn_same_sec(file, alt_group->orig_group->last_insn); 3506 3506 } 3507 3507 3508 + static bool skip_alt_group(struct instruction *insn) 3509 + { 3510 + struct instruction *alt_insn = insn->alts ? insn->alts->insn : NULL; 3511 + 3512 + /* ANNOTATE_IGNORE_ALTERNATIVE */ 3513 + if (insn->alt_group && insn->alt_group->ignore) 3514 + return true; 3515 + 3516 + /* 3517 + * For NOP patched with CLAC/STAC, only follow the latter to avoid 3518 + * impossible code paths combining patched CLAC with unpatched STAC 3519 + * or vice versa. 3520 + * 3521 + * ANNOTATE_IGNORE_ALTERNATIVE could have been used here, but Linus 3522 + * requested not to do that to avoid hurting .s file readability 3523 + * around CLAC/STAC alternative sites. 3524 + */ 3525 + 3526 + if (!alt_insn) 3527 + return false; 3528 + 3529 + /* Don't override ASM_{CLAC,STAC}_UNSAFE */ 3530 + if (alt_insn->alt_group && alt_insn->alt_group->ignore) 3531 + return false; 3532 + 3533 + return alt_insn->type == INSN_CLAC || alt_insn->type == INSN_STAC; 3534 + } 3535 + 3508 3536 /* 3509 3537 * Follow the branch starting at the given instruction, and recursively follow 3510 3538 * any other branches (jumps). Meanwhile, track the frame pointer state at ··· 3653 3625 } 3654 3626 } 3655 3627 3656 - if (insn->alt_group && insn->alt_group->ignore) 3628 + if (skip_alt_group(insn)) 3657 3629 return 0; 3658 3630 3659 3631 if (handle_insn_ops(insn, next_insn, &state)) ··· 3712 3684 3713 3685 break; 3714 3686 3715 - case INSN_CONTEXT_SWITCH: 3716 - if (func) { 3717 - if (!next_insn || !next_insn->hint) { 3718 - WARN_INSN(insn, "unsupported instruction in callable function"); 3719 - return 1; 3720 - } 3721 - break; 3687 + case INSN_SYSCALL: 3688 + if (func && (!next_insn || !next_insn->hint)) { 3689 + WARN_INSN(insn, "unsupported instruction in callable function"); 3690 + return 1; 3722 3691 } 3692 + 3693 + break; 3694 + 3695 + case INSN_SYSRET: 3696 + if (func && (!next_insn || !next_insn->hint)) { 3697 + WARN_INSN(insn, "unsupported instruction in callable function"); 3698 + return 1; 3699 + } 3700 + 3723 3701 return 0; 3724 3702 3725 3703 case INSN_STAC: ··· 3920 3886 WARN_INSN(insn, "RET before UNTRAIN"); 3921 3887 return 1; 3922 3888 3889 + case INSN_SYSCALL: 3890 + break; 3891 + 3892 + case INSN_SYSRET: 3893 + return 0; 3894 + 3923 3895 case INSN_NOP: 3924 3896 if (insn->retpoline_safe) 3925 3897 return 0; ··· 3934 3894 default: 3935 3895 break; 3936 3896 } 3897 + 3898 + if (insn->dead_end) 3899 + return 0; 3937 3900 3938 3901 if (!next) { 3939 3902 WARN_INSN(insn, "teh end!");
+2 -1
tools/objtool/include/objtool/arch.h
··· 19 19 INSN_CALL, 20 20 INSN_CALL_DYNAMIC, 21 21 INSN_RETURN, 22 - INSN_CONTEXT_SWITCH, 22 + INSN_SYSCALL, 23 + INSN_SYSRET, 23 24 INSN_BUG, 24 25 INSN_NOP, 25 26 INSN_STAC,