From patchwork Fri Sep 21 22:16:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10611029 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 52C505A4 for ; Fri, 21 Sep 2018 22:18:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45D5A2D238 for ; Fri, 21 Sep 2018 22:18:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39F582D2DB; Fri, 21 Sep 2018 22:18:13 +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 A7B412D238 for ; Fri, 21 Sep 2018 22:18:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9285F8E0017; Fri, 21 Sep 2018 18:18:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D8058E0001; Fri, 21 Sep 2018 18:18:11 -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 7EF338E0017; Fri, 21 Sep 2018 18:18:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by kanga.kvack.org (Postfix) with ESMTP id 5023B8E0001 for ; Fri, 21 Sep 2018 18:18:11 -0400 (EDT) Received: by mail-oi0-f69.google.com with SMTP id b8-v6so13459691oib.4 for ; Fri, 21 Sep 2018 15:18:11 -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:in-reply-to:references:mime-version :content-transfer-encoding; bh=hFs2zpmTOS7tfV4GbEaJY2QzACMTsqtMSbp0U45C8jE=; b=SRSAt9vwnxFDtEJL8tLOBlZ/V4soBzQqmbXarJb5KRtg7Xeqk/1fxf0h05RJYlmLF8 FhN6qWLaBcWGIxNAxDvzFD3z8e0IeV8bEq+Flva2TFxYpy2X2hAFd+Vm/k5qmBt0hPN4 a2BpW/HdUNrZCunHjjPCPuMtJNql/TqQmjcg0ZWpc5vjaR6Sslb/bGGqJUc9uDdDGo7p msZKDIC0dFLx9Jbc+a5mGpFx7AFh8ZmpPk2Iq/IVsGuNK6fc5caR7umNbFW3BxcJ4Pl+ eNwolyTgq4Obmkhc1vdGrrsHDEov50NHES3fayxoSBdu3kL1CjgVjttK4wa2tcXsvF34 svgQ== 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: APzg51Bs17Eqw1/k+FAcJkrdElkwgoMGhQdvVo4UcQ8RW2CyNNtJEGhL Qroymtlobju8K74rOvvQRET4S5x98fZ2eWn5gOoZKmlpIPC9mZp0BbLxB/TqS6kQUgUmptXSB0D dYB82EIpN2UwZek7aGaPWv1oS1Qd2GJU5OlNpolJ/vv5a5VGFWwMZWn/RnjosyEhhgg== X-Received: by 2002:a9d:3bf5:: with SMTP id k108-v6mr27817219otc.349.1537568291007; Fri, 21 Sep 2018 15:18:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaM30SRQHmvtpIxnGtRFkimW1mAzxk9Br9YljEfjIJDoumA3lZ83bnSeNxr3qhoBO4OixOF X-Received: by 2002:a9d:3bf5:: with SMTP id k108-v6mr27817181otc.349.1537568289930; Fri, 21 Sep 2018 15:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537568289; cv=none; d=google.com; s=arc-20160816; b=Rjfl07fi0IXEFSaxEJz9A3Oes6wGiUFqsRBHNainUDFKbwLvwqEWvlEy8dNUTIXWCk eDmm1nt7zsnkos8qXoRpxuzoR1b6koPVVKjqi+j9MiUjaBgoOI9B/YpfcBzQWM1kcbBh IBGRoC14qVXZBP82o5bKNtZi6u3rXQw+aJ4W/jL4GpU0DDAwk/zR9f5PF/lpwP6/3WBJ otETg858rkhAc8y9IiDDD9BZ+5FGSO9WgtffuVUlyr1SC/HD7orVBo0Z03QW4x4Bcr99 FDEQSzgvfPOuq70yWyzlCf6RFXVgeS6wO5xWUzt8/0l7QFrnoaxhK27JLIC3SwS6ahUJ NDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=hFs2zpmTOS7tfV4GbEaJY2QzACMTsqtMSbp0U45C8jE=; b=XTccCmfuTSKxBBUA4d3u3L0CmxUFQa0LRDdPPrgljHt2mTWEMYt2sQd7qASpXKXWjP cE6rVEzH39FXKTQQqWDk+wpsJSa3pKb36aiDrYFx62m77GXv91XT15h/oTRU6/w/mUaf QU2YUaBbYk5V9d2mjSp6RPBome9o4gwf27q8DIJEYdvbo70rPmQADC/pUBAWsYjq/GcW rICE4GuHSrzN83s2BFczLSyy5l4cBQQK2C4j9j1aygQIQMId+BYBsBamosIrN/VmQaPA cUoqOm0vrLk3yMCm+OYPietBshnYfIV/knoM2zcT6Qmr/+uvGxKXis04vTyT731cOCy6 Suqw== 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 r204-v6si12032213oih.29.2018.09.21.15.18.09 for ; Fri, 21 Sep 2018 15:18:09 -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 662C718A; Fri, 21 Sep 2018 15:18:09 -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 5173B3F557; Fri, 21 Sep 2018 15:18:06 -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 06/18] KVM: arm/arm64: Add kvm_ras.h to collect kvm specific RAS plumbing Date: Fri, 21 Sep 2018 23:16:53 +0100 Message-Id: <20180921221705.6478-7-james.morse@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180921221705.6478-1-james.morse@arm.com> References: <20180921221705.6478-1-james.morse@arm.com> 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 To split up APEIs in_nmi() path, we need any nmi-like callers to always be in_nmi(). KVM shouldn't have to know about this, pull the RAS plumbing out into a header file. Currently guest synchronous external aborts are claimed as RAS notifications by handle_guest_sea(), which is hidden in the arch codes mm/fault.c. 32bit gets a dummy declaration in system_misc.h. There is going to be more of this in the future if/when we support the SError-based firmware-first notification mechanism and/or kernel-first notifications for both synchronous external abort and SError. Each of these will come with some Kconfig symbols and a handful of header files. Create a header file for all this. This patch gives handle_guest_sea() a 'kvm_' prefix, and moves the declarations to kvm_ras.h as preparation for a future patch that moves the ACPI-specific RAS code out of mm/fault.c. Signed-off-by: James Morse Reviewed-by: Punit Agrawal Acked-by: Marc Zyngier Tested-by: Tyler Baicar --- arch/arm/include/asm/kvm_ras.h | 14 ++++++++++++++ arch/arm/include/asm/system_misc.h | 5 ----- arch/arm64/include/asm/kvm_ras.h | 11 +++++++++++ arch/arm64/include/asm/system_misc.h | 2 -- arch/arm64/mm/fault.c | 2 +- virt/kvm/arm/mmu.c | 4 ++-- 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 arch/arm/include/asm/kvm_ras.h create mode 100644 arch/arm64/include/asm/kvm_ras.h diff --git a/arch/arm/include/asm/kvm_ras.h b/arch/arm/include/asm/kvm_ras.h new file mode 100644 index 000000000000..aaff56bf338f --- /dev/null +++ b/arch/arm/include/asm/kvm_ras.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 - Arm Ltd + +#ifndef __ARM_KVM_RAS_H__ +#define __ARM_KVM_RAS_H__ + +#include + +static inline int kvm_handle_guest_sea(phys_addr_t addr, unsigned int esr) +{ + return -1; +} + +#endif /* __ARM_KVM_RAS_H__ */ diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h index 8e76db83c498..66f6a3ae68d2 100644 --- a/arch/arm/include/asm/system_misc.h +++ b/arch/arm/include/asm/system_misc.h @@ -38,11 +38,6 @@ static inline void harden_branch_predictor(void) extern unsigned int user_debug; -static inline int handle_guest_sea(phys_addr_t addr, unsigned int esr) -{ - return -1; -} - #endif /* !__ASSEMBLY__ */ #endif /* __ASM_ARM_SYSTEM_MISC_H */ diff --git a/arch/arm64/include/asm/kvm_ras.h b/arch/arm64/include/asm/kvm_ras.h new file mode 100644 index 000000000000..5f72b07b7912 --- /dev/null +++ b/arch/arm64/include/asm/kvm_ras.h @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 - Arm Ltd + +#ifndef __ARM64_KVM_RAS_H__ +#define __ARM64_KVM_RAS_H__ + +#include + +int kvm_handle_guest_sea(phys_addr_t addr, unsigned int esr); + +#endif /* __ARM64_KVM_RAS_H__ */ diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h index 28893a0b141d..48ded3628a89 100644 --- a/arch/arm64/include/asm/system_misc.h +++ b/arch/arm64/include/asm/system_misc.h @@ -45,8 +45,6 @@ extern void __show_regs(struct pt_regs *); extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd); -int handle_guest_sea(phys_addr_t addr, unsigned int esr); - #endif /* __ASSEMBLY__ */ #endif /* __ASM_SYSTEM_MISC_H */ diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 50b30ff30de4..1a30d7a8c9bf 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -725,7 +725,7 @@ static const struct fault_info fault_info[] = { { do_bad, SIGKILL, SI_KERNEL, "unknown 63" }, }; -int handle_guest_sea(phys_addr_t addr, unsigned int esr) +int kvm_handle_guest_sea(phys_addr_t addr, unsigned int esr) { return ghes_notify_sea(); } diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index ed162a6c57c5..100c8f2d67ac 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -27,10 +27,10 @@ #include #include #include +#include #include #include #include -#include #include "trace.h" @@ -1699,7 +1699,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) * For RAS the host kernel may handle this abort. * There is no need to pass the error into the guest. */ - if (!handle_guest_sea(fault_ipa, kvm_vcpu_get_hsr(vcpu))) + if (!kvm_handle_guest_sea(fault_ipa, kvm_vcpu_get_hsr(vcpu))) return 1; if (unlikely(!is_iabt)) {