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.

objtool: Improve naming of group alternatives

Improve the naming of group alternatives by showing the feature name and
flags used by the alternative.

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://patch.msgid.link/20251121095340.464045-28-alexandre.chartre@oracle.com

authored by

Alexandre Chartre and committed by
Peter Zijlstra
56967b9a 8308fd00

+52 -6
+52 -6
tools/objtool/disas.c
··· 9 9 #include <objtool/arch.h> 10 10 #include <objtool/check.h> 11 11 #include <objtool/disas.h> 12 + #include <objtool/special.h> 12 13 #include <objtool/warn.h> 13 14 14 15 #include <bfd.h> ··· 60 59 #define DALT_INSN(dalt) (DALT_DEFAULT(dalt) ? (dalt)->orig_insn : (dalt)->alt->insn) 61 60 #define DALT_GROUP(dalt) (DALT_INSN(dalt)->alt_group) 62 61 #define DALT_ALTID(dalt) ((dalt)->orig_insn->offset) 62 + 63 + #define ALT_FLAGS_SHIFT 16 64 + #define ALT_FLAG_NOT (1 << 0) 65 + #define ALT_FLAG_DIRECT_CALL (1 << 1) 66 + #define ALT_FEATURE_MASK ((1 << ALT_FLAGS_SHIFT) - 1) 67 + 68 + static int alt_feature(unsigned int ft_flags) 69 + { 70 + return (ft_flags & ALT_FEATURE_MASK); 71 + } 72 + 73 + static int alt_flags(unsigned int ft_flags) 74 + { 75 + return (ft_flags >> ALT_FLAGS_SHIFT); 76 + } 63 77 64 78 /* 65 79 * Wrapper around asprintf() to allocate and format a string. ··· 651 635 */ 652 636 char *disas_alt_name(struct alternative *alt) 653 637 { 638 + char pfx[4] = { 0 }; 654 639 char *str = NULL; 640 + const char *name; 641 + int feature; 642 + int flags; 643 + int num; 655 644 656 645 switch (alt->type) { 657 646 ··· 670 649 671 650 case ALT_TYPE_INSTRUCTIONS: 672 651 /* 673 - * This is a non-default group alternative. Create a unique 674 - * name using the offset of the first original and alternative 675 - * instructions. 652 + * This is a non-default group alternative. Create a name 653 + * based on the feature and flags associated with this 654 + * alternative. Use either the feature name (it is available) 655 + * or the feature number. And add a prefix to show the flags 656 + * used. 657 + * 658 + * Prefix flags characters: 659 + * 660 + * '!' alternative used when feature not enabled 661 + * '+' direct call alternative 662 + * '?' unknown flag 676 663 */ 677 - asprintf(&str, "ALTERNATIVE %lx.%lx", 678 - alt->insn->alt_group->orig_group->first_insn->offset, 679 - alt->insn->alt_group->first_insn->offset); 664 + 665 + feature = alt->insn->alt_group->feature; 666 + num = alt_feature(feature); 667 + flags = alt_flags(feature); 668 + str = pfx; 669 + 670 + if (flags & ~(ALT_FLAG_NOT | ALT_FLAG_DIRECT_CALL)) 671 + *str++ = '?'; 672 + if (flags & ALT_FLAG_DIRECT_CALL) 673 + *str++ = '+'; 674 + if (flags & ALT_FLAG_NOT) 675 + *str++ = '!'; 676 + 677 + name = arch_cpu_feature_name(num); 678 + if (!name) 679 + str = strfmt("%sFEATURE 0x%X", pfx, num); 680 + else 681 + str = strfmt("%s%s", pfx, name); 682 + 680 683 break; 681 684 } 682 685 ··· 937 892 WARN("%s has more alternatives than supported", alt_name); 938 893 break; 939 894 } 895 + 940 896 dalt = &dalts[i]; 941 897 err = disas_alt_init(dalt, orig_insn, alt); 942 898 if (err) {