From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [PATCH v6 07/18] arm64: KVM/mm: Move SEA handling behind a single 'claim' interface Date: Fri, 12 Oct 2018 12:02:12 +0200 Message-ID: <20181012100212.GA580@zn.tnic> References: <20180921221705.6478-1-james.morse@arm.com> <20180921221705.6478-8-james.morse@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20180921221705.6478-8-james.morse@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu To: James Morse Cc: jonathan.zhang@cavium.com, Rafael Wysocki , Tony Luck , linux-mm@kvack.org, Marc Zyngier , Catalin Marinas , Tyler Baicar , Will Deacon , Dongjiu Geng , linux-acpi@vger.kernel.org, Punit Agrawal , Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown List-Id: linux-acpi@vger.kernel.org On Fri, Sep 21, 2018 at 11:16:54PM +0100, James Morse wrote: > To split up APEIs in_nmi() path, we need the nmi-like callers to always > be in_nmi(). Add a helper to do the work and claim the notification. > > When KVM or the arch code takes an exception that might be a RAS > notification, it asks the APEI firmware-first code whether it wants > to claim the exception. We can then go on to see if (a future) > kernel-first mechanism wants to claim the notification, before > falling through to the existing default behaviour. > > The NOTIFY_SEA code was merged before we had multiple, possibly > interacting, NMI-like notifications and the need to consider kernel > first in the future. Make the 'claiming' behaviour explicit. > > As we're restructuring the APEI code to allow multiple NMI-like > notifications, any notification that might interrupt interrupts-masked > code must always be wrapped in nmi_enter()/nmi_exit(). This allows APEI > to use in_nmi() to use the right fixmap entries. > > We mask SError over this window to prevent an asynchronous RAS error > arriving and tripping 'nmi_enter()'s BUG_ON(in_nmi()). > > Signed-off-by: James Morse > Acked-by: Marc Zyngier > Tested-by: Tyler Baicar ... > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > index ed46dc188b22..a9b8bba014b5 100644 > --- a/arch/arm64/kernel/acpi.c > +++ b/arch/arm64/kernel/acpi.c > @@ -28,8 +28,10 @@ > #include > #include > > +#include > #include > #include > +#include > #include > #include > > @@ -257,3 +259,30 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) > return __pgprot(PROT_NORMAL_NC); > return __pgprot(PROT_DEVICE_nGnRnE); > } > + > +/* > + * Claim Synchronous External Aborts as a firmware first notification. > + * > + * Used by KVM and the arch do_sea handler. > + * @regs may be NULL when called from process context. > + */ > +int apei_claim_sea(struct pt_regs *regs) > +{ > + int err = -ENOENT; > + unsigned long current_flags = arch_local_save_flags(); > + > + if (!IS_ENABLED(CONFIG_ACPI_APEI_SEA)) > + return err; I don't know what side effects arch_local_save_flags() has on ARM but if we return here, it looks to me like useless work. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id 2F5686B0006 for ; Fri, 12 Oct 2018 06:02:15 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id y14-v6so7197993wmd.1 for ; Fri, 12 Oct 2018 03:02:15 -0700 (PDT) Received: from mail.skyhub.de (mail.skyhub.de. [2a01:4f8:190:11c2::b:1457]) by mx.google.com with ESMTPS id q2-v6si794707wmf.180.2018.10.12.03.02.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 03:02:13 -0700 (PDT) Date: Fri, 12 Oct 2018 12:02:12 +0200 From: Borislav Petkov Subject: Re: [PATCH v6 07/18] arm64: KVM/mm: Move SEA handling behind a single 'claim' interface Message-ID: <20181012100212.GA580@zn.tnic> References: <20180921221705.6478-1-james.morse@arm.com> <20180921221705.6478-8-james.morse@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180921221705.6478-8-james.morse@arm.com> Sender: owner-linux-mm@kvack.org List-ID: To: James Morse Cc: linux-acpi@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Tyler Baicar , Dongjiu Geng , Xie XiuQi , Punit Agrawal , jonathan.zhang@cavium.com On Fri, Sep 21, 2018 at 11:16:54PM +0100, James Morse wrote: > To split up APEIs in_nmi() path, we need the nmi-like callers to always > be in_nmi(). Add a helper to do the work and claim the notification. > > When KVM or the arch code takes an exception that might be a RAS > notification, it asks the APEI firmware-first code whether it wants > to claim the exception. We can then go on to see if (a future) > kernel-first mechanism wants to claim the notification, before > falling through to the existing default behaviour. > > The NOTIFY_SEA code was merged before we had multiple, possibly > interacting, NMI-like notifications and the need to consider kernel > first in the future. Make the 'claiming' behaviour explicit. > > As we're restructuring the APEI code to allow multiple NMI-like > notifications, any notification that might interrupt interrupts-masked > code must always be wrapped in nmi_enter()/nmi_exit(). This allows APEI > to use in_nmi() to use the right fixmap entries. > > We mask SError over this window to prevent an asynchronous RAS error > arriving and tripping 'nmi_enter()'s BUG_ON(in_nmi()). > > Signed-off-by: James Morse > Acked-by: Marc Zyngier > Tested-by: Tyler Baicar ... > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > index ed46dc188b22..a9b8bba014b5 100644 > --- a/arch/arm64/kernel/acpi.c > +++ b/arch/arm64/kernel/acpi.c > @@ -28,8 +28,10 @@ > #include > #include > > +#include > #include > #include > +#include > #include > #include > > @@ -257,3 +259,30 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) > return __pgprot(PROT_NORMAL_NC); > return __pgprot(PROT_DEVICE_nGnRnE); > } > + > +/* > + * Claim Synchronous External Aborts as a firmware first notification. > + * > + * Used by KVM and the arch do_sea handler. > + * @regs may be NULL when called from process context. > + */ > +int apei_claim_sea(struct pt_regs *regs) > +{ > + int err = -ENOENT; > + unsigned long current_flags = arch_local_save_flags(); > + > + if (!IS_ENABLED(CONFIG_ACPI_APEI_SEA)) > + return err; I don't know what side effects arch_local_save_flags() has on ARM but if we return here, it looks to me like useless work. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply. From mboxrd@z Thu Jan 1 00:00:00 1970 From: bp@alien8.de (Borislav Petkov) Date: Fri, 12 Oct 2018 12:02:12 +0200 Subject: [PATCH v6 07/18] arm64: KVM/mm: Move SEA handling behind a single 'claim' interface In-Reply-To: <20180921221705.6478-8-james.morse@arm.com> References: <20180921221705.6478-1-james.morse@arm.com> <20180921221705.6478-8-james.morse@arm.com> Message-ID: <20181012100212.GA580@zn.tnic> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, Sep 21, 2018 at 11:16:54PM +0100, James Morse wrote: > To split up APEIs in_nmi() path, we need the nmi-like callers to always > be in_nmi(). Add a helper to do the work and claim the notification. > > When KVM or the arch code takes an exception that might be a RAS > notification, it asks the APEI firmware-first code whether it wants > to claim the exception. We can then go on to see if (a future) > kernel-first mechanism wants to claim the notification, before > falling through to the existing default behaviour. > > The NOTIFY_SEA code was merged before we had multiple, possibly > interacting, NMI-like notifications and the need to consider kernel > first in the future. Make the 'claiming' behaviour explicit. > > As we're restructuring the APEI code to allow multiple NMI-like > notifications, any notification that might interrupt interrupts-masked > code must always be wrapped in nmi_enter()/nmi_exit(). This allows APEI > to use in_nmi() to use the right fixmap entries. > > We mask SError over this window to prevent an asynchronous RAS error > arriving and tripping 'nmi_enter()'s BUG_ON(in_nmi()). > > Signed-off-by: James Morse > Acked-by: Marc Zyngier > Tested-by: Tyler Baicar ... > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > index ed46dc188b22..a9b8bba014b5 100644 > --- a/arch/arm64/kernel/acpi.c > +++ b/arch/arm64/kernel/acpi.c > @@ -28,8 +28,10 @@ > #include > #include > > +#include > #include > #include > +#include > #include > #include > > @@ -257,3 +259,30 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) > return __pgprot(PROT_NORMAL_NC); > return __pgprot(PROT_DEVICE_nGnRnE); > } > + > +/* > + * Claim Synchronous External Aborts as a firmware first notification. > + * > + * Used by KVM and the arch do_sea handler. > + * @regs may be NULL when called from process context. > + */ > +int apei_claim_sea(struct pt_regs *regs) > +{ > + int err = -ENOENT; > + unsigned long current_flags = arch_local_save_flags(); > + > + if (!IS_ENABLED(CONFIG_ACPI_APEI_SEA)) > + return err; I don't know what side effects arch_local_save_flags() has on ARM but if we return here, it looks to me like useless work. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.