From patchwork Fri Sep 21 22:16:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10611003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDDB45A4 for ; Fri, 21 Sep 2018 22:17:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C01DC2E6DC for ; Fri, 21 Sep 2018 22:17:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1FCD2E6E3; Fri, 21 Sep 2018 22:17:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8442E6DC for ; Fri, 21 Sep 2018 22:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAF7F8E0011; Fri, 21 Sep 2018 18:17:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A5ED98E0001; Fri, 21 Sep 2018 18:17:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94DB88E0011; Fri, 21 Sep 2018 18:17:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id 6CE938E0001 for ; Fri, 21 Sep 2018 18:17:25 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id t3-v6so13388632oif.20 for ; Fri, 21 Sep 2018 15:17:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=FabYY4+FI6FbdpxMc67DZ8vgSc3WSLe7u2mlTGsBo4s=; b=KwLc6pTenHvmnjmLk8NICTzmDkX/fMuPzwWdKto3jrcDfIGYHhlQ9YZfaNrOAHnjFr opJ+T+/WoXtUMO2g3ZgsLw1Qto/i7MgGj4LJAti8+bonFWHYwH2zIj82Roj1zwQB6Ysy M9WXeziBdLWQl/Ei0k5b/RRBx4Trpsg2zv3ZLOJZ4A+dzuUfb1Lxc2VojBnBNdLHxHUq 1rYuDm14Thm+9l1x+xR6JbDXRDNXtMiVc6YTy0kCJtJmr8eJafuGInj7U8ebaV1YiXv8 JRBz0HzlbdRQAbfAF8DkJY/cSCXbmLwtw1tYKcgqich31fA1rVKlEzEC33kI97gW7HkD fADg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: ABuFfojdcvvpiysy5zWCJDGwOF3GumCDw0QQsvRKQhtQWZ8QEza98Zd+ xiMbS99g+e4k+TeoVrjLF7x2Z4ifj5j+orLF02wt7uKX4sWLOxM/s7Y/CmA+n4YtFhsk7zB/JdB sol08LFJz/7DcmPAKm1reJXid/oaG6ld37eKPz9nphFq+wvY4+m0VRyKuURqGyiU2dA== X-Received: by 2002:a9d:2827:: with SMTP id m36-v6mr1091603otb.79.1537568245092; Fri, 21 Sep 2018 15:17:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV601Quw8/q+Qcqgu06eKR6/mle92FVAb/ijq/qJ2s/hU2YOaeICfrv69muN3kjaeBzlpVv8Z X-Received: by 2002:a9d:2827:: with SMTP id m36-v6mr1091568otb.79.1537568243993; Fri, 21 Sep 2018 15:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537568243; cv=none; d=google.com; s=arc-20160816; b=vloizkJeFW7hPrYkWaauxZ87TZO85jdiqTaceb9z6NXzrxnOSdsPFVOINsh0Q37xL9 1bAWt19Pe8RBtIqFJZ5cWwT3D99oxwJ21P2VlektFMbaAUBJepVd++IhEx4PNKwXxMGq veNAdXvYQ+HPsH64QjcjpIJydFH+MuSMCsYRrneSiceQ+cyWuehdAi2acXN2WyDezZ0G 3mzQ6K627YTJxkM6h3yBbKty77sWbTVUKu/FTQiTVdSS4/eE8bfVlDSx++scxWVVlk8B SME3C/kPzpD1ZDtgufpphsUeR0NH8FMHSUxIIVGWafm++zNw4ClRFseXUrxbpuN03xJL Pw3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=FabYY4+FI6FbdpxMc67DZ8vgSc3WSLe7u2mlTGsBo4s=; b=HXVOUFcM6NY2TSCl2BLF5MB+3YJmfzpHPsuaRZA+R1yUGHD6urkSeRWAm14EOS/9kC 3Ax+QxwuRSkqy2+CkpdLcpwN/2HnRTMe787K/z3ftVgR1h2qEGqwGv4+Z2Ilw8NsvHsy y8rgHKo01Iv5baFTYuFCHc510GycFsDT7dFmPdC07bQ2GO0WLMwGoALTx/e1AJOVKb9Z CfWcfkbVditmdq372dnSoMuMhgjNE5rN3J2k0hPmxpgP/0WBKS+mUeyqPj/+gRyRPRAY ZtATheCMqzc67lAc9qjWs7Zt2EFbf521MqzULclWXBujTj4xd0jjv6Lt3uYODyYZ1Ely 50Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id e15-v6si8532976oti.441.2018.09.21.15.17.23 for ; Fri, 21 Sep 2018 15:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 981AC18A; Fri, 21 Sep 2018 15:17:22 -0700 (PDT) Received: from melchizedek.Emea.Arm.com (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 80CE13F557; Fri, 21 Sep 2018 15:17:19 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , 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, James Morse Subject: [PATCH v6 00/18] APEI in_nmi() rework Date: Fri, 21 Sep 2018 23:16:47 +0100 Message-Id: <20180921221705.6478-1-james.morse@arm.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Hello, The GHES driver has collected quite a few bugs: ghes_proc() at ghes_probe() time can be interrupted by an NMI that will clobber the ghes->estatus fields, flags, and the buffer_paddr. ghes_copy_tofrom_phys() uses in_nmi() to decide which path to take. arm64's SEA taking both paths, depending on what it interrupted. There is no guarantee that queued memory_failure() errors will be processed before this CPU returns to user-space. x86 can't TLBI from interrupt-masked code which this driver does all the time. This series aims to fix the first three, with an eye to fixing the last one with a follow-up series. Previous postings included the SDEI notification calls, which I haven't finished re-testing. This series is big enough as it is. Any NMIlike notification should always be in_nmi(), and should use the ghes estatus cache to hold the CPER records until they can be processed. The path through GHES should be nmi-safe, without the need to look at in_nmi(). Abstract the estatus cache, and re-plumb arm64 to always nmi_enter() before making the ghes_notify_sea() call. To remove the use of in_nmi(), the locks are pushed out to the notification helpers, and the fixmap slot to use is passed in. (A future series could change as many nnotification helpers as possible to not mask-irqs, and pass in some GHES_FIXMAP_NONE that indicates ioremap() should be used) Change the now common _in_nmi_notify_one() to use local estatus/paddr/flags, instead of clobbering those in the struct ghes. Finally we try and ensure the memory_failure() work will run before this CPU returns to user-space where the error may be triggered again. Changes since v5: * Fixed phys_addr_t/u64 that failed to build on 32bit x86. * Removed buffer/flags from struct ghes, these are now on the stack. To make future irq/tlbi fixes easier: * Moved the locking further out to make it easier to avoid masking interrupts for notifications where it isn't needed. * Restored map/unmap helpers so they can use ioremap() when interrupts aren't masked. Feedback welcome, Thanks James Morse (18): ACPI / APEI: Move the estatus queue code up, and under its own ifdef ACPI / APEI: Generalise the estatus queue's add/remove and notify code ACPI / APEI: don't wait to serialise with oops messages when panic()ing ACPI / APEI: Switch NOTIFY_SEA to use the estatus queue ACPI / APEI: Make estatus queue a Kconfig symbol KVM: arm/arm64: Add kvm_ras.h to collect kvm specific RAS plumbing arm64: KVM/mm: Move SEA handling behind a single 'claim' interface ACPI / APEI: Move locking to the notification helper ACPI / APEI: Let the notification helper specify the fixmap slot ACPI / APEI: preparatory split of ghes->estatus ACPI / APEI: Remove silent flag from ghes_read_estatus() ACPI / APEI: Don't store CPER records physical address in struct ghes ACPI / APEI: Don't update struct ghes' flags in read/clear estatus ACPI / APEI: Split ghes_read_estatus() to read CPER length ACPI / APEI: Only use queued estatus entry during _in_nmi_notify_one() ACPI / APEI: Split fixmap pages for arm64 NMI-like notifications mm/memory-failure: increase queued recovery work's priority arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work arch/arm/include/asm/kvm_ras.h | 14 + arch/arm/include/asm/system_misc.h | 5 - arch/arm64/include/asm/acpi.h | 4 + arch/arm64/include/asm/daifflags.h | 1 + arch/arm64/include/asm/fixmap.h | 4 +- arch/arm64/include/asm/kvm_ras.h | 25 ++ arch/arm64/include/asm/system_misc.h | 2 - arch/arm64/kernel/acpi.c | 48 +++ arch/arm64/mm/fault.c | 25 +- drivers/acpi/apei/Kconfig | 6 + drivers/acpi/apei/ghes.c | 564 +++++++++++++++------------ include/acpi/ghes.h | 2 - mm/memory-failure.c | 11 +- virt/kvm/arm/mmu.c | 4 +- 14 files changed, 426 insertions(+), 289 deletions(-) create mode 100644 arch/arm/include/asm/kvm_ras.h create mode 100644 arch/arm64/include/asm/kvm_ras.h