From patchwork Fri Oct 8 08:24:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 240831 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o988Ox1L024101 for ; Fri, 8 Oct 2010 08:24:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756106Ab0JHIY0 (ORCPT ); Fri, 8 Oct 2010 04:24:26 -0400 Received: from mga14.intel.com ([143.182.124.37]:45881 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756066Ab0JHIYX (ORCPT ); Fri, 8 Oct 2010 04:24:23 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 08 Oct 2010 01:24:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.57,302,1283756400"; d="scan'208";a="333675744" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.2]) ([10.239.13.2]) by azsmga001.ch.intel.com with ESMTP; 08 Oct 2010 01:24:20 -0700 Subject: [PATCH 2/2] kvm, MCE, Send SRAR SIGBUS directly From: Huang Ying To: Avi Kivity , Marcelo Tosatti Cc: "kvm@vger.kernel.org" , Andi Kleen , "linux-kernel@vger.kernel.org" , Dean Nelson Date: Fri, 08 Oct 2010 16:24:15 +0800 Message-ID: <1286526255.7768.96.camel@yhuang-dev> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Oct 2010 08:25:00 +0000 (UTC) --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h @@ -258,6 +258,9 @@ struct pt_regs; #define ptrace_signal_deliver(regs, cookie) do { } while (0) +void force_sig_info_fault(int si_signo, int si_code, unsigned long address, + struct task_struct *tsk); + #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -158,9 +158,8 @@ is_prefetch(struct pt_regs *regs, unsign return prefetch; } -static void -force_sig_info_fault(int si_signo, int si_code, unsigned long address, - struct task_struct *tsk) +void force_sig_info_fault(int si_signo, int si_code, unsigned long address, + struct task_struct *tsk) { siginfo_t info; @@ -172,6 +171,7 @@ force_sig_info_fault(int si_signo, int s force_sig_info(si_signo, &info, tsk); } +EXPORT_SYMBOL_GPL(force_sig_info_fault); DEFINE_SPINLOCK(pgd_lock); LIST_HEAD(pgd_list); --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -39,6 +39,7 @@ #include #include #include +#include /* * When setting this variable to true it enables Two-Dimensional-Paging @@ -2104,22 +2105,12 @@ static int __direct_map(struct kvm_vcpu return pt_write; } -static void kvm_send_hwpoison_signal(struct kvm *kvm, gfn_t gfn) -{ - char buf[1]; - void __user *hva; - int r; - - /* Touch the page, so send SIGBUS */ - hva = (void __user *)gfn_to_hva(kvm, gfn); - r = copy_from_user(buf, hva, 1); -} - static int kvm_handle_bad_page(struct kvm *kvm, gfn_t gfn, pfn_t pfn) { kvm_release_pfn_clean(pfn); if (is_hwpoison_pfn(pfn)) { - kvm_send_hwpoison_signal(kvm, gfn); + force_sig_info_fault(SIGBUS, BUS_MCEERR_AR, + gfn_to_hva(kvm, gfn), current); return 0; } else if (is_fault_pfn(pfn)) return -EFAULT;