From patchwork Thu Mar 30 10:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie XiuQi X-Patchwork-Id: 9653663 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 5E14060113 for ; Thu, 30 Mar 2017 10:34:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4682F28574 for ; Thu, 30 Mar 2017 10:34:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3867D2856D; Thu, 30 Mar 2017 10:34:57 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBC1C2856D for ; Thu, 30 Mar 2017 10:34:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933479AbdC3Key (ORCPT ); Thu, 30 Mar 2017 06:34:54 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:4914 "EHLO dggrg03-dlp.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933372AbdC3Kev (ORCPT ); Thu, 30 Mar 2017 06:34:51 -0400 Received: from 172.30.72.55 (EHLO DGGEML403-HUB.china.huawei.com) ([172.30.72.55]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AKX60257; Thu, 30 Mar 2017 18:34:44 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEML403-HUB.china.huawei.com (10.3.17.33) with Microsoft SMTP Server id 14.3.301.0; Thu, 30 Mar 2017 18:34:35 +0800 From: Xie XiuQi To: , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v3 5/8] arm64: KVM: add guest SEI support Date: Thu, 30 Mar 2017 18:31:14 +0800 Message-ID: <1490869877-118713-15-git-send-email-xiexiuqi@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490869877-118713-1-git-send-email-xiexiuqi@huawei.com> References: <1490869877-118713-1-git-send-email-xiexiuqi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.58DCDF44.0145, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7a5824320cbd991dae0f165ee0de4663 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add ghes handling for SEI so that the host kernel could parse and report detailed error information for SEI which occur in the guest kernel. If there were no CPER records, (or the system doesn't support SEI as a GHES notification mechanism), then yes we should still call kvm_inject_vabt(). Signed-off-by: Xie XiuQi --- arch/arm64/include/asm/system_misc.h | 1 + arch/arm64/kernel/traps.c | 14 ++++++++++++++ arch/arm64/kvm/handle_exit.c | 22 ++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h index 5b2cecd..d68d61f 100644 --- a/arch/arm64/include/asm/system_misc.h +++ b/arch/arm64/include/asm/system_misc.h @@ -59,5 +59,6 @@ void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned int, #endif /* __ASSEMBLY__ */ int handle_guest_sea(unsigned long addr, unsigned int esr); +int handle_guest_sei(unsigned long addr, unsigned int esr); #endif /* __ASM_SYSTEM_MISC_H */ diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 955dc8c..b6d6727 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -618,6 +618,20 @@ const char *esr_get_class_string(u32 esr) DEFINE_PER_CPU(int, sei_in_process); /* + * Handle asynchronous SError interrupt that occur in a guest kernel. + */ +int handle_guest_sei(unsigned long addr, unsigned int esr) +{ + int ret = -ENOENT; + + if(IS_ENABLED(CONFIG_ACPI_APEI_SEI)) { + ret = ghes_notify_sei(); + } + + return ret; +} + +/* * bad_mode handles the impossible case in the exception vector. This is always * fatal. */ diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index fa1b18e..c89d83a 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -28,6 +28,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include "trace.h" @@ -177,6 +178,23 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) return arm_exit_handlers[hsr_ec]; } +static int kvm_handle_guest_sei(struct kvm_vcpu *vcpu, struct kvm_run *run) +{ + unsigned long fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); + + if (handle_guest_sei((unsigned long)fault_ipa, + kvm_vcpu_get_hsr(vcpu))) { + kvm_err("Failed to handle guest SEI, FSC: EC=%#x xFSC=%#lx ESR_EL2=%#lx\n", + kvm_vcpu_trap_get_class(vcpu), + (unsigned long)kvm_vcpu_trap_get_fault(vcpu), + (unsigned long)kvm_vcpu_get_hsr(vcpu)); + + kvm_inject_vabt(vcpu); + } + + return 0; +} + /* * Return > 0 to return to guest, < 0 on error, 0 (and set exit_reason) on * proper exit to userspace. @@ -200,7 +218,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, *vcpu_pc(vcpu) -= adj; } - kvm_inject_vabt(vcpu); + kvm_handle_guest_sei(vcpu, run); return 1; } @@ -210,7 +228,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, case ARM_EXCEPTION_IRQ: return 1; case ARM_EXCEPTION_EL1_SERROR: - kvm_inject_vabt(vcpu); + kvm_handle_guest_sei(vcpu, run); return 1; case ARM_EXCEPTION_TRAP: /*