From patchwork Tue Jun 26 17:01:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10489599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E45D660386 for ; Tue, 26 Jun 2018 17:04:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11F8203B9 for ; Tue, 26 Jun 2018 17:04:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2EED25F3E; Tue, 26 Jun 2018 17:04:00 +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=ham 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 6BE6128759 for ; Tue, 26 Jun 2018 17:02:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFC636B0273; Tue, 26 Jun 2018 13:02:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DAC536B0274; Tue, 26 Jun 2018 13:02:17 -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 C74626B0276; Tue, 26 Jun 2018 13:02:17 -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 9E0306B0273 for ; Tue, 26 Jun 2018 13:02:17 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id t192-v6so7802975oie.15 for ; Tue, 26 Jun 2018 10:02:17 -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; bh=sroP0t8OHczbghzuUi/sxZSnfKW57//sZQDRHbGE0Sk=; b=cjUOQDE0BuqrMs70gXrV3XubMp/N1/eVgDBUDPs1jq57IXxNQ61F6L5rdZCoJAmF3g Danvjc4V7pWKBhRp2zf5Rj1B4UwQxD6bJLs1SaGL4bpICu474bpCRCPxu2BA//jbvDly 5q9qthEkL01qsAwWyYMq+gW/yi7p1Ga/oQ7JlsiU/qRFTUqFWnciu7P924MvvgHm4oqC Tkz6Jxh++ATjNfKEOFXBx80Nb85c3iOY5JhHc40R2d0aAm4m2PXHRFef/kBhaQYxH6Yk pY/z72g8hIZTq69F57QVtyWXyWT54l4Lfmg1t2XUd00hZd/BtPnfmyGCmWGw17+yqMnY BUTA== 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: APt69E3vlTbIhRXVruZdFA2UCGDy0WEOefOVTWiJTLD9rb6wbbCFhL3W 5chsYN0eZClmKX4vTE+PLDVHRct7ZbRdjnICwJmCagJ2I/yhrjuI7kK/JORY7qO8ZOZ56I7V7UT 7RPMl4y1PgrXwze04unVPzcCJDhDrqWcQEFkdzWska7m1ORHL3si07RtWHAlfbdGxCQ== X-Received: by 2002:a9d:12c:: with SMTP id 41-v6mr918758otu.310.1530032537375; Tue, 26 Jun 2018 10:02:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdlTQfxzT6Wvk+KKxjMdd2CkNC4jn7kKKh/yA7HMttl3j/e9eppc/fjy15JrL0WWdVjEK6Y X-Received: by 2002:a9d:12c:: with SMTP id 41-v6mr918646otu.310.1530032535449; Tue, 26 Jun 2018 10:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530032535; cv=none; d=google.com; s=arc-20160816; b=Rne6i6bhisbV1B9aMwIJxe813oJy86fshvDHMzTIpsZE1i7D5yZbX1SqRhgfkYA6D0 tZTocpfjsoVZwBtASBKzQi/8sHJNum/VRqLnZfdjqQMgmkNT1mcL5m9dCg8nE+MiKVQf XwMuEq8q7EMD68ZP65xsqWmHT93EtTWm4U4Y+kzu/DnIIHj1thHTx/jePaU/5XKBUUrQ P7Z22o0jz9JnxKuBEQVs1ySN9MJPGb5f7z8wUfQZ6nLX/tgcUbS0bPwPbG699EOGmS4M O/RBANf4h6jfMgGf4bUos5PZezqcyNkxsaHDnVLUWLuysECWmUFL+bpVEnZBJgFMRXJV PDBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sroP0t8OHczbghzuUi/sxZSnfKW57//sZQDRHbGE0Sk=; b=vrmq/CPb1SDlI4VF3sIeMaPgOXZnbZLsxHsdFCIIDBLDxU1ES0mRy+Qzl/oHJl85TL vNFv51BZYdAYAaWuVs4sf7VPiDqqPvBWPP6Nl5sTYOjB5uUja6CmgAdGu2ZQJ24fwTZQ bVYkJUvKN2eosO3GGIf4VFBZdEwOCke9TBdBkho4xDY8Rx/ug2W2xaKONCx2xgfZ7Bot +01I2dAEFbI5N4UGvObTrqdcx7S6jbB0yUCs4f2B7UNjKhVQsCxsNtdWRaU0SKRjfWEN KQ3F5qj6NuWDaA0VDLEuzdZVuNBCyp35fvkQP1zwCQHAOVQZ8J6t4y0bbvrQeTYHTzUQ TIvA== 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 (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id i1-v6si587347oiy.369.2018.06.26.10.02.15 for ; Tue, 26 Jun 2018 10:02:15 -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 F3AD4ED1; Tue, 26 Jun 2018 10:02:14 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.206.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DB7A13F318; Tue, 26 Jun 2018 10:02:11 -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 v5 06/20] KVM: arm/arm64: Add kvm_ras.h to collect kvm specific RAS plumbing Date: Tue, 26 Jun 2018 18:01:02 +0100 Message-Id: <20180626170116.25825-7-james.morse@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626170116.25825-1-james.morse@arm.com> References: <20180626170116.25825-1-james.morse@arm.com> 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 b8eecc7b9531..167772fe4360 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) { int ret = -ENOENT; diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 1d90d79706bd..15b85c10f6db 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" @@ -1650,7 +1650,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)) {