From patchwork Mon Dec 3 18:06:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10710247 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 6B7191057 for ; Mon, 3 Dec 2018 18:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EA92B47E for ; Mon, 3 Dec 2018 18:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 553B22B49D; Mon, 3 Dec 2018 18:07:35 +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 093F22B47E for ; Mon, 3 Dec 2018 18:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D4246B6A81; Mon, 3 Dec 2018 13:07:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 684766B6A82; Mon, 3 Dec 2018 13:07:25 -0500 (EST) 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 5261A6B6A83; Mon, 3 Dec 2018 13:07:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 1DFC56B6A81 for ; Mon, 3 Dec 2018 13:07:25 -0500 (EST) Received: by mail-oi1-f200.google.com with SMTP id u63so6800129oie.17 for ; Mon, 03 Dec 2018 10:07:25 -0800 (PST) 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=xBPdcCdKy7IgM0fyCHO8+ryv1fkn+Icc11ZQeY9VFPY=; b=RXbpre2htrUqujmvzxw2CYXVcEmkrmxvQJp7RL0MGTcKGrAAjKvaQqRb1ygmjyykQY cQFMJazbB2WlUQdO0rilJLfpRKJPl3xgTN2+6EHeNMAl05RbZkefZkn+ieutpYtcxSNm 3ugBewGk99MFHiRttR+HiNN+h+2uUnt9YT/91spMsnuGsi/A0Hp2zj7z/YX31Ig3MEuf Y6+b5TEXUSGkwSOmeh2Bae5no5i33Q4U+jSvrrJ6Vsk0AJP+I91Hqw00Hj12nxPBe4G2 s8B3QiIfQAL9eOMJmmNor81r5th/NyRoCODMmdxVaX1saQwt6nmKbWMgR9SoNn6e5tdO FdOg== 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: AA+aEWagEf7h2ijmjLS6btvZQWfvMhXjTfdOBD+QnUy6flWV0wsnH9Sa ClPuepEWdurowEH9t/aD+A1jfflIvOe0oyWWOI7+DHFZ+1MGPBj8rduTW5BtdcriPN5lcwrMI42 L0HBN+fGgN4AcbSN0RWOoFTxFgTsFk2e8N82dhQakOHXEyoJtNZTD+TUYGhR7x6Siww== X-Received: by 2002:a9d:1eea:: with SMTP id n97mr10061615otn.248.1543860444847; Mon, 03 Dec 2018 10:07:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VECdGtfKMfJglsxp5iVZlYLcuBN/HLOcwOrw0bwj4fWpoIon1S2JBMcNGXeDNSnI6ff30H X-Received: by 2002:a9d:1eea:: with SMTP id n97mr10061569otn.248.1543860443955; Mon, 03 Dec 2018 10:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860443; cv=none; d=google.com; s=arc-20160816; b=Lh9xik3SUks3RtGvrqmkVhRYmsaIqB0wCblY8cQifyL2PaGdinxyPoBxcdoasXfoYi 8fkb9vvxBZJROTqndedFUsOwOAP1CRJDZKgC69aOxBckMlzwh97RwZM5CsGGWHDjviyH LNN6RMuhIfAijNpFHCdsAcIRhds6VIUOee/4no0domVgG3s8ORFTnpL3ts628xpD6fEv EtQ+YsRx9zA9fq+OYc+5L/nBYkYoFyZ7dBygFKYB4chIimmDcGQ5zvqFPhoJDj7DwtRV wH455iGAMh3VraovB2RvygRJZ6cIyKbCz/rd+rxAVmsrqIrx1cVy6pCGbqm31X9owJ22 36/w== 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=xBPdcCdKy7IgM0fyCHO8+ryv1fkn+Icc11ZQeY9VFPY=; b=qFrG1XXL8nbZuyUvUVE5lXrS8OYcChJK6KsC7FU1VFq5FuYyu4LnFhHhU1Q6LjiMY7 WPX7n8ENLa2+Wp1oQiNJn3Wm2DOadMdAlxsj2g1+qDw+xjpY+FkRyuWn34iyMhCm0LEX PRH1hBV2DbxuOV4L0LaK6VTf8tBPYcb78ZQCvZPL3so8pAw2zopqCg8EQU7yODNmLkVi ucwVplXohRtHdr0SDprfpti+uUf9jzTMd77qIXrzIjwktQDwuIXpDkEsFLCXMPuDXD1l ZsXjR1Hl3tetkKDdZj4YXtA83Odi/AGJxOuJvqE4ANxdX5F2JnMN2dhxdKzCWTuHK5TD oh0A== 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 w16si6194093otl.261.2018.12.03.10.07.23 for ; Mon, 03 Dec 2018 10:07:23 -0800 (PST) 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 81A67168F; Mon, 3 Dec 2018 10:07:23 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B0DCC3F59C; Mon, 3 Dec 2018 10:07:20 -0800 (PST) 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 , Dongjiu Geng , Xie XiuQi , Fan Wu , James Morse Subject: [PATCH v7 13/25] KVM: arm/arm64: Add kvm_ras.h to collect kvm specific RAS plumbing Date: Mon, 3 Dec 2018 18:06:01 +0000 Message-Id: <20181203180613.228133-14-james.morse@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181203180613.228133-1-james.morse@arm.com> References: <20181203180613.228133-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, the caller needs 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 the kernel supports 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 Acked-by: Catalin Marinas --- Changes since v6: * Tinkered with the commit message --- 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..e9577292dfe4 --- /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..6096f0251812 --- /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 0e2a0ecaf484..32693f34f431 100644 --- a/arch/arm64/include/asm/system_misc.h +++ b/arch/arm64/include/asm/system_misc.h @@ -46,8 +46,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 7d9571f4ae3d..eeeb576b33d7 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -720,7 +720,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 5eca48bdb1a6..f322b66ef975 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" @@ -1703,7 +1703,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)) {