[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200711095639.GA597537@hirez.programming.kicks-ass.net>
Date: Sat, 11 Jul 2020 11:56:39 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, mhiramat@...nel.org,
bristot@...hat.com, jbaron@...mai.com,
torvalds@...ux-foundation.org, tglx@...utronix.de,
mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
ard.biesheuvel@...aro.org, jpoimboe@...hat.com,
pbonzini@...hat.com, mathieu.desnoyers@...icios.com,
linux@...musvillemoes.dk
Subject: Re: [PATCH v6 10/17] x86/static_call: Add inline static call
implementation for x86-64
On Fri, Jul 10, 2020 at 06:31:55PM -0400, Steven Rostedt wrote:
> On Fri, 10 Jul 2020 15:38:41 +0200
> Peter Zijlstra <peterz@...radead.org> wrote:
> > + /* find key symbol */
> > + key_name = strdup(insn->call_dest->name);
>
> Should check for failed allocation of strdup().
Rigt, I'll go add the perror and exit.
> > + if (strncmp(key_name, STATIC_CALL_TRAMP_PREFIX_STR,
> > + strlen(STATIC_CALL_TRAMP_PREFIX_STR))) {
> > + WARN("static_call: trampoline name malformed: %s", key_name);
> > + return -1;
> > + }
> > + tmp = key_name + STATIC_CALL_TRAMP_PREFIX_LEN - STATIC_CALL_KEY_PREFIX_LEN;
> > + memcpy(tmp, STATIC_CALL_KEY_PREFIX_STR, STATIC_CALL_KEY_PREFIX_LEN);
> > +
> > + key_sym = find_symbol_by_name(file->elf, tmp);
> > + if (!key_sym) {
> > + WARN("static_call: can't find static_call_key symbol: %s", tmp);
> > + return -1;
> > + }
> > + free(key_name);
> > +
> > + /* populate reloc for 'key' */
> > + reloc = malloc(sizeof(*reloc));
> > + if (!reloc) {
> > + perror("malloc");
> > + return -1;
> > + }
> > + memset(reloc, 0, sizeof(*reloc));
> > + reloc->sym = key_sym;
> > + reloc->addend = 0;
> > + reloc->type = R_X86_64_PC32;
>
> How easy would this be for other architectures to implement this? That
> is how much of this function is x86 specific?
I'm not sure; I think it's fairly generic except for the reloc types. So
ARM64 for example might need to use SHT_REL and R_AARCH64_PREL32
instead. But I suppose we'll see that if/when someone tries to make it
work.
Powered by blists - more mailing lists