From: tixy@linaro.org (Jon Medhurst (Tixy))
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 2/7] arm64: introduce interfaces to hotpatch kernel and module code
Date: Thu, 17 Oct 2013 16:24:01 +0100 [thread overview]
Message-ID: <1382023441.19506.66.camel@linaro1.home> (raw)
In-Reply-To: <20131017113826.GJ18765@mudshark.cambridge.arm.com>
On Thu, 2013-10-17 at 12:38 +0100, Will Deacon wrote:
> [adding Tixy for stop_machine() question below]
>
> On Thu, Oct 17, 2013 at 07:19:35AM +0100, Jiang Liu wrote:
[...]
> > +int __kprobes aarch64_insn_patch_text_sync(void *addrs[], u32 insns[], int cnt)
> > +{
> > + struct aarch64_insn_patch patch = {
> > + .text_addrs = addrs,
> > + .new_insns = insns,
> > + .insn_cnt = cnt,
> > + };
> > +
> > + if (cnt <= 0)
> > + return -EINVAL;
> > +
> > + /*
> > + * Execute __aarch64_insn_patch_text() on every online CPU,
> > + * which ensure serialization among all online CPUs.
> > + */
> > + return stop_machine(aarch64_insn_patch_text_cb, &patch, NULL);
> > +}
>
> Whoa, whoa, whoa! The comment here is wrong -- we only run the patching on
> *one* CPU, which is the right thing to do. However, the arch/arm/ call to
> stop_machine in kprobes does actually run the patching code on *all* the
> online cores (including the cache flushing!). I think this is to work around
> cores without hardware cache maintenance broadcasting, but that could easily
> be called out specially (like we do in patch.c) and the flushing could be
> separated from the patching too.
[...]
For code modifications done in 32bit ARM kprobes (and ftrace) I'm not
sure we ever actually resolved the possible cache flushing issues. If
there was specific reasons for flushing on all cores I can't remember
them, sorry. I have a suspicion that doing so was a case of sticking
with what the code was already doing, and flushing on all cores seemed
safest to guard against problems we hadn't thought about.
Some of the issues discussed were that we couldn't have one core
potentially executing instructions being modified by another CPU,
because that's architecturally unpredictable except for a few
instructions [1], and we also have the case where a 32-bit Thumb
instruction can straddle two different cache-lines. But these may not be
reasons to flush on all cores if stop machine is synchronising all CPU's
in a kind of holding pen and the cache operations done on one core are
broadcast to others. (Are there correct barriers involved in
stop-machine so that when the other cores resume they are guaranteed to
only see the new version of the modified code, or do we only get that
guarantee because we happen to execute the cache flushing on all cores?)
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2012-December/136441.html
Another of the issues I hit was big.LITTLE related whereby the cache
line size is different on different cores [2].
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-February/149794.html
I don't think anything I've said above actually gives a solid reason why
we _must_ execute cache flushing on all cores for kprobes and can't just
use the relatively new patch_text function (which checks for the one
case we do need to flush on all cores using cache_ops_need_broadcast).
Sorry, I don't think I've added much light on things here have I?
--
Tixy
next prev parent reply other threads:[~2013-10-17 15:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 6:19 [PATCH v4 0/7] Optimize jump label implementation for ARM64 Jiang Liu
2013-10-17 6:19 ` [PATCH v4 1/7] arm64: introduce basic aarch64 instruction decoding helpers Jiang Liu
2013-10-17 10:47 ` Will Deacon
2013-10-17 15:14 ` Jiang Liu
2013-10-17 6:19 ` [PATCH v4 2/7] arm64: introduce interfaces to hotpatch kernel and module code Jiang Liu
2013-10-17 11:38 ` Will Deacon
2013-10-17 15:24 ` Jon Medhurst (Tixy) [this message]
2013-10-17 15:59 ` Jiang Liu
2013-10-18 8:56 ` Will Deacon
2013-10-18 13:44 ` Jon Medhurst (Tixy)
2013-10-18 15:08 ` Jiang Liu
2013-10-17 15:38 ` Jiang Liu
2013-10-17 6:19 ` [PATCH v4 3/7] arm64: move encode_insn_immediate() from module.c to insn.c Jiang Liu
2013-10-17 12:11 ` Will Deacon
2013-10-17 6:19 ` [PATCH v4 4/7] arm64: introduce aarch64_insn_gen_{nop|branch_imm}() helper functions Jiang Liu
2013-10-17 6:19 ` [PATCH v4 5/7] arm64, jump label: detect %c support for ARM64 Jiang Liu
2013-10-17 6:19 ` [PATCH v4 6/7] arm64, jump label: optimize jump label implementation Jiang Liu
2013-10-17 6:19 ` [PATCH v4 7/7] jump_label: use defined macros instead of hard-coding for better readability Jiang Liu
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=1382023441.19506.66.camel@linaro1.home \
--to=tixy@linaro.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;
as well as URLs for NNTP newsgroup(s).