public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: rostedt@goodmis.org (Steven Rostedt)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 8/8] x86/kernel: jump_table: use relative references
Date: Thu, 28 Dec 2017 11:39:15 -0500	[thread overview]
Message-ID: <20171228113915.47838609@gandalf.local.home> (raw)
In-Reply-To: <CAKv+Gu9Gza=RN_v_H-G7m7-qKg9B4Xf4GFvd_H-Gut-V3eabmA@mail.gmail.com>

On Thu, 28 Dec 2017 16:26:07 +0000
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> On 28 December 2017 at 16:19, Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Wed, 27 Dec 2017 08:50:33 +0000
> > Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >  
> >>  static inline jump_label_t jump_entry_code(const struct jump_entry *entry)
> >>  {
> >> -     return entry->code;
> >> +     return (jump_label_t)&entry->code + entry->code;  
> >
> > I'm paranoid about doing arithmetic on abstract types. What happens in
> > the future if jump_label_t becomes a pointer? You will get a different
> > result.
> >  
> 
> In general, I share your concern. In this case, however, jump_label_t
> is typedef'd three lines up and is never used anywhere else.

I would agree if this was in a .c file, but it's in a header file,
which causes me to be more paranoid.

> 
> > Could we switch these calculations to something like:
> >
> >         return (jump_label_t)((long)&entrty->code + entry->code);
> >  
> 
> jump_label_t is local to this .h file, so it can be defined as u32 or
> u64 depending on the word size. I don't mind adding the extra cast,
> but I am not sure if your paranoia is justified in this particular
> case. Perhaps we should just use 'unsigned long' throughout?

Actually, that may be better. Have the return value be jump_label_t,
but the cast be "unsigned long". That way it should always work.

static inline jump_label_t jump_entry_code(...)
{
	return (unsigned long)&entry->code + entry->code;
}


-- Steve

      reply	other threads:[~2017-12-28 16:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-27  8:50 [PATCH v6 0/8] add support for relative references in special sections Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 1/8] arch: enable relative relocations for arm64, power, x86, s390 and x86 Ard Biesheuvel
2017-12-27 19:54   ` Linus Torvalds
2017-12-27 19:59     ` Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 2/8] module: use relative references for __ksymtab entries Ard Biesheuvel
2017-12-27 20:07   ` Linus Torvalds
2017-12-27 20:11     ` Ard Biesheuvel
2017-12-27 20:13       ` Linus Torvalds
2017-12-27 20:24         ` Ard Biesheuvel
2017-12-28 12:05           ` Ingo Molnar
2017-12-28 12:39             ` Ard Biesheuvel
2017-12-29  6:42   ` kbuild test robot
2017-12-27  8:50 ` [PATCH v6 3/8] init: allow initcall tables to be emitted using relative references Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 4/8] PCI: Add support for relative addressing in quirk tables Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 5/8] kernel: tracepoints: add support for relative references Ard Biesheuvel
2017-12-28 15:42   ` Steven Rostedt
2017-12-28 23:24     ` Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 6/8] kernel/jump_label: abstract jump_entry member accessors Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 7/8] arm64/kernel: jump_label: use relative references Ard Biesheuvel
2017-12-27  8:50 ` [PATCH v6 8/8] x86/kernel: jump_table: " Ard Biesheuvel
2017-12-28 16:19   ` Steven Rostedt
2017-12-28 16:26     ` Ard Biesheuvel
2017-12-28 16:39       ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171228113915.47838609@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox