All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 0/4] arm64: alternative patching rework
Date: Wed, 03 Jun 2015 14:36:09 +0100	[thread overview]
Message-ID: <556F02C9.9020706@arm.com> (raw)
In-Reply-To: <20150602175902.GF3080@e104818-lin.cambridge.arm.com>

Hi Catalin,

On 02/06/15 18:59, Catalin Marinas wrote:
> On Tue, Jun 02, 2015 at 06:47:15PM +0100, Catalin Marinas wrote:
>> On Mon, Jun 01, 2015 at 10:47:38AM +0100, Marc Zyngier wrote:
>>> The current alternative instruction framework is not kind to branches,
>>> potentially leading to all kind of hacks in the code that uses
>>> alternatives. This series expands it to deal with immediate and
>>> conditional branches.
>>>
>>> This is a rewrite of fef7f2b20103, which got reverted in b9a95e85bbc
>>> as it was breaking unsuspecting branches inside an alternate
>>> sequence. It now also deals with conditional branches (instead of just
>>> asserting a BUG).
>>>
>>> Another nit is addressed by the last patch, where GAS gets confused by
>>> the combinaison of a .inst directive (as used by the msr_s/mrs_s
>>> pseudo-instruction), a label, and a .if directive evaluating said
>>> label. As this is exactly what the alternative framework uses to
>>> detect length mismatch, this patch reverts to using a pair of .org
>>> directives in a creative way. To make this a bit easier,
>>> alternative-asm.h is folded into alternative.h.
>>>
>>> This has been tested on v4.1-rc5.
>>>
>>> Marc Zyngier (4):
>>>   arm64: insn: Add aarch64_{get,set}_branch_offset
>>>   arm64: alternative: Allow immediate branch as alternative instruction
>>>   arm64: alternative: Merge alternative-asm.h into alternative.h
>>>   arm64: alternative: Work around .inst assembler bugs
>>
>> Applied, thanks.
> 
> Applied, but not pushed out yet. Testing on Juno gives:
> 
> alternatives: patching kernel code
> BUG: failure at /work/Linux/linux-2.6-aarch64/arch/arm64/kernel/alternative.c:59/branch_insn_requires_update()!
> Kernel panic - not syncing: BUG!
> CPU: 0 PID: 10 Comm: migration/0 Not tainted 4.1.0-rc4+ #224
> Hardware name: Juno (DT)
> Call trace:
> [<ffffffc00008992c>] dump_backtrace+0x0/0x11c
> [<ffffffc000089a58>] show_stack+0x10/0x1c
> [<ffffffc0005b49b4>] dump_stack+0x88/0xc8
> [<ffffffc0005b38a8>] panic+0xe0/0x220
> [<ffffffc00008e3b0>] __apply_alternatives+0x1ac/0x1cc
> [<ffffffc000123aa8>] multi_cpu_stop+0xf8/0x120
> [<ffffffc000123d60>] cpu_stopper_thread+0xb0/0x148
> [<ffffffc0000d12ec>] smpboot_thread_fn+0x150/0x274
> [<ffffffc0000cdedc>] kthread+0xd8/0xf0
> SMP: failed to stop secondary CPUs
> 
> 
> I haven't investigated yet, I'll have a look tomorrow.

I reproduced this. Two issues:

- the workaround for CONFIG_ARM64_ERRATUM_845719 is written with two 
alternate sequences, and the first one branches in to the second. 
Exactly what this series disallows... I'll post a rewrite of this 
sequence in a minute.

- there is a small bug that the above also triggers, as it branches 
just *after* the last instruction of the sequence. This doesn't 
generate any relocation problem, and can be accepted. Can you fold the 
patchlet below into the second patch of the series?

diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
index df4bf15..221b983 100644
--- a/arch/arm64/kernel/alternative.c
+++ b/arch/arm64/kernel/alternative.c
@@ -49,7 +49,7 @@ static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc)
                return 1;
 
        replptr = (unsigned long)ALT_REPL_PTR(alt);
-       if (pc >= replptr && pc < (replptr + alt->alt_len))
+       if (pc >= replptr && pc <= (replptr + alt->alt_len))
                return 0;
 
        /*

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

      reply	other threads:[~2015-06-03 13:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01  9:47 [PATCH v2 0/4] arm64: alternative patching rework Marc Zyngier
2015-06-01  9:47 ` [PATCH v2 1/4] arm64: insn: Add aarch64_{get,set}_branch_offset Marc Zyngier
2015-06-01  9:47 ` [PATCH v2 2/4] arm64: alternative: Allow immediate branch as alternative instruction Marc Zyngier
2015-06-01  9:47 ` [PATCH v2 3/4] arm64: alternative: Merge alternative-asm.h into alternative.h Marc Zyngier
2015-06-01  9:47 ` [PATCH v2 4/4] arm64: alternative: Work around .inst assembler bugs Marc Zyngier
2015-06-02 17:47 ` [PATCH v2 0/4] arm64: alternative patching rework Catalin Marinas
2015-06-02 17:59   ` Catalin Marinas
2015-06-03 13:36     ` Marc Zyngier [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=556F02C9.9020706@arm.com \
    --to=marc.zyngier@arm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.