From patchwork Wed Mar 8 04:09:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie XiuQi X-Patchwork-Id: 9610315 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 98A3360414 for ; Wed, 8 Mar 2017 04:14:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B36D7285B5 for ; Wed, 8 Mar 2017 04:14:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6578285B9; Wed, 8 Mar 2017 04:14:15 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E407285B5 for ; Wed, 8 Mar 2017 04:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8g1XEkK4GLuMVCgePntw7oozH/G3p2VAopJTY9tufVU=; b=jXCTy/DOPeWf/r pBDkz+EEWjkqCgaKfL7bXkZBLcW0N2ue605lEdGdenJR6sWoBixBEky4SEkeI9ekcPdfxikcIgcY1 AwjTcp0rnJhz/AgVFj3PvvV6oMuuymT4zncbX9vhSeVFYMal9H+vwV1eL4RCVmJWW81QitVentJMw 0+OM7xu8oEgB9OGybB+V6nH9IAl1Vtkc17c25Bh/EsC/q99YlGN4qMG2ycZe/Com4cQaAJHwvMN0z KtRecHisMCta8Ec9NqPMI0boh5JyCGPQyi13L+62se6NJ7TZj5kAaKFWbqXqn2vK0TACT69Y4LACy clYzAUWA++oOUB7QHQqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clSzK-0005bq-N7; Wed, 08 Mar 2017 04:14:10 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clSyf-00053W-9N for linux-arm-kernel@bombadil.infradead.org; Wed, 08 Mar 2017 04:13:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FJL5UagCdMzymu82zt3/yX+SDkfSM0vaI/ZYtZ95bL8=; b=PfQsZmvcicQ2AJwxLHWCiirw8 lpmq7nC57LycBByZ8cxotxz1x9SvtpNQXwVSdsTBrJj3RLuQMLC5wtmUjIcLI7qBFBRQTPfWX+OZY e49b2uTrlRyJbQ5aZdUnJHIEU6rNmmj6/E5/knDi4gGhV7BVswXVWQd6ltrpnVxaNpR2dmcUxJ7Si mj7vo9OF8zyxCyePiHOalLL47uLPJKsaT1geuSV5RAk56L+skYoIM5b+B9Vxa4pzK3pBM/NBdjgvA qJNz7v42ieZvCWLWb9M/QyMmKwuWOfnvyabHDOn6ogHt0x3nlZua+4N6rM1O7pMBvp7UND4Tj3b5V l8oWv4omQ==; Received: from [45.249.212.188] (helo=dggrg02-dlp.huawei.com) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clSyb-0003AV-2K for linux-arm-kernel@lists.infradead.org; Wed, 08 Mar 2017 04:13:27 +0000 Received: from 172.30.72.55 (EHLO DGGEML401-HUB.china.huawei.com) ([172.30.72.55]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AJO85417; Wed, 08 Mar 2017 12:11:46 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Wed, 8 Mar 2017 12:11:35 +0800 From: Xie XiuQi To: , , , , , , , , , Subject: [PATCH v2 3/3] arm64: KVM: add guest SEI support Date: Wed, 8 Mar 2017 12:09:41 +0800 Message-ID: <1488946181-130774-4-git-send-email-xiexiuqi@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488946181-130774-1-git-send-email-xiexiuqi@huawei.com> References: <1488946181-130774-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.0A090201.58BF8482.0023, 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: dd094021352fe2f2deb1a7a4b72bc766 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170308_041326_330062_8B62C465 X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xie XiuQi , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.org, guohanjun@huawei.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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. Signed-off-by: Xie XiuQi --- arch/arm64/include/asm/system_misc.h | 1 + arch/arm64/kernel/traps.c | 18 ++++++++++++++++++ arch/arm64/kvm/handle_exit.c | 22 ++++++++++++++++++++-- 3 files changed, 39 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 65dbfa9..cf9f569 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -616,6 +616,24 @@ const char *esr_get_class_string(u32 esr) } /* + * Handle asynchronous SError interrupt that occur in a guest kernel. + */ +int handle_guest_sei(unsigned long addr, unsigned int esr) +{ + /* + * synchronize_rcu() will wait for nmi_exit(), so no need to + * rcu_read_lock(). + */ + if(IS_ENABLED(CONFIG_ACPI_APEI_SEI)) { + rcu_read_lock(); + ghes_notify_sei(); + rcu_read_unlock(); + } + + return 0; +} + +/* * 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 1bfe30d..8c7dba0 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" @@ -172,6 +173,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. @@ -195,7 +213,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; } @@ -205,7 +223,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: /*