From: peterz@infradead.org
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2] x86/alternatives: Let __text_poke() acquire the pte lock with enabled interrupts
Date: Thu, 13 Aug 2020 13:13:51 +0200 [thread overview]
Message-ID: <20200813111351.GV2674@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200813105026.bvugytmsso6muljw@linutronix.de>
On Thu, Aug 13, 2020 at 12:50:26PM +0200, Sebastian Andrzej Siewior wrote:
> The pte lock is never acquired in-IRQ context so it does not require the
> interrupts to be disabled.
>
> RT complains here because the spinlock_t must not be acquired with
> disabled interrupts.
>
> use_temporary_mm() expects interrupts to be off because it invokes
> switch_mm_irqs_off() and uses per-CPU (current active mm) data.
>
> Move the PTE lock handling outside the interrupt disabled region.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Agreed, this should be fine.
Acked-by; Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> v1…v2: Reword the patch description.
>
> arch/x86/kernel/alternative.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -875,8 +875,6 @@ static void *__text_poke(void *addr, con
> */
> BUG_ON(!pages[0] || (cross_page_boundary && !pages[1]));
>
> - local_irq_save(flags);
> -
> /*
> * Map the page without the global bit, as TLB flushing is done with
> * flush_tlb_mm_range(), which is intended for non-global PTEs.
> @@ -893,6 +891,8 @@ static void *__text_poke(void *addr, con
> */
> VM_BUG_ON(!ptep);
>
> + local_irq_save(flags);
> +
> pte = mk_pte(pages[0], pgprot);
> set_pte_at(poking_mm, poking_addr, ptep, pte);
>
> @@ -942,8 +942,8 @@ static void *__text_poke(void *addr, con
> */
> BUG_ON(memcmp(addr, opcode, len));
>
> - pte_unmap_unlock(ptep, ptl);
> local_irq_restore(flags);
> + pte_unmap_unlock(ptep, ptl);
> return addr;
> }
>
next prev parent reply other threads:[~2020-08-13 11:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 16:42 [PATCH] x86/alternatives: Let __text_poke() acquire the pte lock with enabled interrupts Sebastian Andrzej Siewior
2020-08-12 14:39 ` Thomas Gleixner
2020-08-13 10:47 ` Sebastian Andrzej Siewior
2020-08-13 10:50 ` [PATCH v2] " Sebastian Andrzej Siewior
2020-08-13 11:13 ` peterz [this message]
2020-08-13 12:15 ` [tip: x86/urgent] x86/alternatives: Acquire pte lock with interrupts enabled tip-bot2 for Sebastian Andrzej Siewior
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=20200813111351.GV2674@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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).