From patchwork Thu Mar 23 13:01:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongjiu Geng X-Patchwork-Id: 9640975 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 5945F601E9 for ; Thu, 23 Mar 2017 12:46:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 437F12823E for ; Thu, 23 Mar 2017 12:46:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37C8528445; Thu, 23 Mar 2017 12:46:37 +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 371C22823E for ; Thu, 23 Mar 2017 12:46:36 +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: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:In-Reply-To:References: List-Owner; bh=g8+LXT7bIvZibZ9GS9X1OQz6JgbzxQgl303PT7DEQvU=; b=L7h5+vgc3qE6RE N9qF2gGboxmxDVGYqJEQ9mCl1wxbmDQ6lM1sXnpwiBd+/RGL5u/PSBCj0eWdx64h4GGrL5rkAEQgy OLcC87CVyRzNfZkvpG+NtV8/+05WNhkWS1rB/ZornS7rVk6YzcdG4EQiRuZi8hAlI0g78Y2oGY9Zq 7Fj+Nh3hagVM1ZbFCnOZPFLzj+QH8sfWMpn287lVr+R2cc+CCNGfnSo4irh2oA3z4Y5pdYZNNjims 8cP8/RrtmP+7ki74bzf9zIuBZFXbq0i+azeajrHsRyw0Oa8L0CQ4B8Y5ggLe2aAaQb8CSRIETz3m+ ZitYOUDOQf5u3lTVF1zg==; 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 1cr28O-0003Es-Ph; Thu, 23 Mar 2017 12:46:32 +0000 Received: from [45.249.212.187] (helo=dggrg01-dlp.huawei.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cr28K-000310-4U for linux-arm-kernel@lists.infradead.org; Thu, 23 Mar 2017 12:46:30 +0000 Received: from 172.30.72.57 (EHLO DGGEML401-HUB.china.huawei.com) ([172.30.72.57]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ALG36171; Thu, 23 Mar 2017 20:45:37 +0800 (CST) Received: from linux.huawei.com (10.67.187.203) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Thu, 23 Mar 2017 20:45:29 +0800 From: Dongjiu Geng To: , , , , , , , , Subject: [PATCH] arm/arm64: KVM: send SIGBUS error to qemu Date: Thu, 23 Mar 2017 21:01:01 +0800 Message-ID: <1490274061-487-1-git-send-email-gengdongjiu@huawei.com> X-Mailer: git-send-email 1.7.7 MIME-Version: 1.0 X-Originating-IP: [10.67.187.203] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.58D3C373.0243, 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: d5963c71841fc08d37df01736530680b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170323_054628_501861_C211B0B2 X-CRM114-Status: UNSURE ( 9.09 ) X-CRM114-Notice: Please train this message. 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: wuquanming@huawei.com, huangshaoyu@huawei.com, wangxiongfeng2@huawei.com, xiexiuqi@huawei.com 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 when the pfn is KVM_PFN_ERR_HWPOISON, it indicates to send SIGBUS signal from KVM's fault-handling code to qemu, qemu can handle this signal according to the fault address. Signed-off-by: Dongjiu Geng --- arch/arm/kvm/mmu.c | 20 ++++++++++++++++++++ include/linux/kvm_host.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 962616fd4ddd..1307ec400de3 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -1237,6 +1237,20 @@ static void coherent_cache_guest_page(struct kvm_vcpu *vcpu, kvm_pfn_t pfn, __coherent_cache_guest_page(vcpu, pfn, size); } +static void kvm_send_hwpoison_signal(unsigned long address, + struct task_struct *tsk) +{ + siginfo_t info; + + info.si_signo = SIGBUS; + info.si_errno = 0; + info.si_code = BUS_MCEERR_AR; + info.si_addr = (void __user *)address; + info.si_addr_lsb = PAGE_SHIFT; + + send_sig_info(SIGBUS, &info, tsk); +} + static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, struct kvm_memory_slot *memslot, unsigned long hva, unsigned long fault_status) @@ -1309,6 +1323,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (is_error_noslot_pfn(pfn)) return -EFAULT; + if (is_error_hwpoison_pfn(pfn)) { + kvm_send_hwpoison_signal(kvm_vcpu_gfn_to_hva(vcpu, gfn), + current); + return -EFAULT; + } + if (kvm_is_device_pfn(pfn)) { mem_type = PAGE_S2_DEVICE; flags |= KVM_S2PTE_FLAG_IS_IOMAP; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 2c14ad9809da..610ded9ebe9b 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -91,6 +91,11 @@ static inline bool is_noslot_pfn(kvm_pfn_t pfn) { return pfn == KVM_PFN_NOSLOT; } +/* hwpoison pfn indicates that it needs to send SIGBUS */ +static inline bool is_error_hwpoison_pfn(kvm_pfn_t pfn) +{ + return pfn == KVM_PFN_ERR_HWPOISON; +} /* * architectures with KVM_HVA_ERR_BAD other than PAGE_OFFSET (e.g. s390)