~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/arch/s390/annotate/instructions.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/compiler.h>
  3 
  4 static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
  5                             struct map_symbol *ms)
  6 {
  7         char *endptr, *tok, *name;
  8         struct map *map = ms->map;
  9         struct addr_map_symbol target = {
 10                 .ms = { .map = map, },
 11         };
 12 
 13         tok = strchr(ops->raw, ',');
 14         if (!tok)
 15                 return -1;
 16 
 17         ops->target.addr = strtoull(tok + 1, &endptr, 16);
 18 
 19         name = strchr(endptr, '<');
 20         if (name == NULL)
 21                 return -1;
 22 
 23         name++;
 24 
 25         if (arch->objdump.skip_functions_char &&
 26             strchr(name, arch->objdump.skip_functions_char))
 27                 return -1;
 28 
 29         tok = strchr(name, '>');
 30         if (tok == NULL)
 31                 return -1;
 32 
 33         *tok = '\0';
 34         ops->target.name = strdup(name);
 35         *tok = '>';
 36 
 37         if (ops->target.name == NULL)
 38                 return -1;
 39         target.addr = map__objdump_2mem(map, ops->target.addr);
 40 
 41         if (maps__find_ams(ms->maps, &target) == 0 &&
 42             map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
 43                 ops->target.sym = target.ms.sym;
 44 
 45         return 0;
 46 }
 47 
 48 static struct ins_ops s390_call_ops = {
 49         .parse     = s390_call__parse,
 50         .scnprintf = call__scnprintf,
 51 };
 52 
 53 static int s390_mov__parse(struct arch *arch __maybe_unused,
 54                            struct ins_operands *ops,
 55                            struct map_symbol *ms __maybe_unused)
 56 {
 57         char *s = strchr(ops->raw, ','), *target, *endptr;
 58 
 59         if (s == NULL)
 60                 return -1;
 61 
 62         *s = '\0';
 63         ops->source.raw = strdup(ops->raw);
 64         *s = ',';
 65 
 66         if (ops->source.raw == NULL)
 67                 return -1;
 68 
 69         target = ++s;
 70         ops->target.raw = strdup(target);
 71         if (ops->target.raw == NULL)
 72                 goto out_free_source;
 73 
 74         ops->target.addr = strtoull(target, &endptr, 16);
 75         if (endptr == target)
 76                 goto out_free_target;
 77 
 78         s = strchr(endptr, '<');
 79         if (s == NULL)
 80                 goto out_free_target;
 81         endptr = strchr(s + 1, '>');
 82         if (endptr == NULL)
 83                 goto out_free_target;
 84 
 85         *endptr = '\0';
 86         ops->target.name = strdup(s + 1);
 87         *endptr = '>';
 88         if (ops->target.name == NULL)
 89                 goto out_free_target;
 90 
 91         return 0;
 92 
 93 out_free_target:
 94         zfree(&ops->target.raw);
 95 out_free_source:
 96         zfree(&ops->source.raw);
 97         return -1;
 98 }
 99 
100 
101 static struct ins_ops s390_mov_ops = {
102         .parse     = s390_mov__parse,
103         .scnprintf = mov__scnprintf,
104 };
105 
106 static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name)
107 {
108         struct ins_ops *ops = NULL;
109 
110         /* catch all kind of jumps */
111         if (strchr(name, 'j') ||
112             !strncmp(name, "bct", 3) ||
113             !strncmp(name, "br", 2))
114                 ops = &jump_ops;
115         /* override call/returns */
116         if (!strcmp(name, "bras") ||
117             !strcmp(name, "brasl") ||
118             !strcmp(name, "basr"))
119                 ops = &s390_call_ops;
120         if (!strcmp(name, "br"))
121                 ops = &ret_ops;
122         /* override load/store relative to PC */
123         if (!strcmp(name, "lrl") ||
124             !strcmp(name, "lgrl") ||
125             !strcmp(name, "lgfrl") ||
126             !strcmp(name, "llgfrl") ||
127             !strcmp(name, "strl") ||
128             !strcmp(name, "stgrl"))
129                 ops = &s390_mov_ops;
130 
131         if (ops)
132                 arch__associate_ins_ops(arch, name, ops);
133         return ops;
134 }
135 
136 static int s390__cpuid_parse(struct arch *arch, char *cpuid)
137 {
138         unsigned int family;
139         char model[16], model_c[16], cpumf_v[16], cpumf_a[16];
140         int ret;
141 
142         /*
143          * cpuid string format:
144          * "IBM,family,model-capacity,model[,cpum_cf-version,cpum_cf-authorization]"
145          */
146         ret = sscanf(cpuid, "%*[^,],%u,%[^,],%[^,],%[^,],%s", &family, model_c,
147                      model, cpumf_v, cpumf_a);
148         if (ret >= 2) {
149                 arch->family = family;
150                 arch->model = 0;
151                 return 0;
152         }
153 
154         return -1;
155 }
156 
157 static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
158 {
159         int err = 0;
160 
161         if (!arch->initialized) {
162                 arch->initialized = true;
163                 arch->associate_instruction_ops = s390__associate_ins_ops;
164                 if (cpuid) {
165                         if (s390__cpuid_parse(arch, cpuid))
166                                 err = SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING;
167                 }
168         }
169 
170         return err;
171 }
172 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php