From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752719AbbICIul (ORCPT ); Thu, 3 Sep 2015 04:50:41 -0400 Received: from mail.skyhub.de ([78.46.96.112]:49672 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbbICIuj (ORCPT ); Thu, 3 Sep 2015 04:50:39 -0400 Date: Thu, 3 Sep 2015 10:50:46 +0200 From: Borislav Petkov To: Thomas Gleixner Cc: "Richard W.M. Jones" , Chuck Ebbert , linux-kernel@vger.kernel.org, x86@kernel.org, Ingo Molnar , "H. Peter Anvin" Subject: Re: [BUG 4.2-rc8] Interrupt occurs while apply_alternatives() is patching the handler Message-ID: <20150903085046.GA19397@nazgul.tnic> References: <20150830223757.6e4c5c02@as> <20150901062022.GA19002@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 02, 2015 at 11:11:55AM +0200, Thomas Gleixner wrote: > On Tue, 1 Sep 2015, Richard W.M. Jones wrote: > > On Sun, Aug 30, 2015 at 10:37:57PM -0400, Chuck Ebbert wrote: > > > This is from https://bugzilla.redhat.com/show_bug.cgi?id=1258223 > > > > > > [ 0.036000] BUG: unable to handle kernel paging request at 55501e06 > > [...] > > > [ 0.036000] [] ? add_nops+0x90/0xa0 > > > [ 0.036000] [] apply_alternatives+0x274/0x630 > > > [ 0.036000] [] ? wait_for_xmitr+0xa0/0xa0 > > > [ 0.036000] [] ? sprintf+0x1c/0x20 > > > [ 0.036000] [] ? irq_entries_start+0x698/0x698 > > > [ 0.036000] [] ? memcpy+0xb/0x30 > > > [ 0.036000] [] ? serial8250_set_termios+0x20/0x20 > > [...] > > > Interrupt 0x30 occurred while the alternatives code was replacing the > > > initial 0x90,0x90,0x90 NOPs (from the ASM_CLAC macro) with the optimized > > > version, 0x8d,0x76,0x00. Only the first byte has been replaced so far, > > > and it makes a mess out of the insn decoding. > > apply_alternatives() has two ways to modify the code: > > 1) text_poke_early() > > 2) optimize_nops() > > The former disables interrupts, the latter not. The patch below should > fix the issue. > > Thanks, > > tglx > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index c42827eb86cf..6a2f93e029f4 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -257,6 +257,9 @@ void __init arch_init_ideal_nops(void) > /* Use this to add nops to a buffer, then text_poke the whole buffer. */ > static void __init_or_module add_nops(void *insns, unsigned int len) > { > + unsigned long flags; > + > + local_irq_save(flags); > while (len > 0) { I guess you want to optimize the len==0 case to not disable interrupts needlessly: if (!len) return; local_irq_save(flags); while (len > 0) ... Other than that, good catch! Thanks. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --