From: "H. Peter Anvin" <hpa@zytor.com>
To: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
"H.J. Lu" <hjl.tools@gmail.com>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: "m" constraints, jumps, and alternatives
Date: Thu, 20 Feb 2014 15:27:24 -0800 [thread overview]
Message-ID: <53068F5C.9000008@zytor.com> (raw)
Hi all,
The alternatives mechanism suffers from problems whenever there are
PC-relative items in the instruction stream. We currently have a hack
in the alternatives mechanism where we detect the opcode of a call or
jmp instruction and adjust the offset, but that only works if the
replacement code consists solely of a call or jmp.
Well, when there are "m" contraints, we could end up with PC-relative
offsets if someone were to point the function in question at a global
variable on 64 bits. This is much harder to decode at runtime; doing so
would require pretty much a full x86 decoder (which we do have one in
the kernel now, but it would be pretty slow I would think.)
I talked with H.J. about this, and one way to do this would be to do
post-linkage fixup of the alternatives section. This does, however,
would seem to not work easily with kernel modules, as the kernel module
is left pre-link. We could, of course, do equivalent fixup in the
kernel at module insertion time, since the module will include the
relocations.
Another option is to say "don't do that then", and weed out the current
uses of "m" and instead force the pointer in question explicitly into a
register.
What do you guys think?
-hpa
next reply other threads:[~2014-02-20 23:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 23:27 H. Peter Anvin [this message]
2014-02-21 0:30 ` "m" constraints, jumps, and alternatives Linus Torvalds
[not found] ` <CAMzpN2ie6ALLmL_A+eaQ54aKaHZkwtTr+AqGL6ThHM1Ay+VfFg@mail.gmail.com>
2014-02-21 3:43 ` H. Peter Anvin
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=53068F5C.9000008@zytor.com \
--to=hpa@zytor.com \
--cc=hjl.tools@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=ross.zwisler@linux.intel.com \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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