From: Huang Ying Subject: Re: [PATCH -v2] QEMU-KVM: MCE: Relay UCR MCE to guest Date: Thu, 10 Sep 2009 10:40:06 +0800 Message-ID: <1252550406.5212.133.camel@yhuang-dev.sh.intel.com> References: <1252463282.5212.44.camel@yhuang-dev.sh.intel.com> <4AA79A31.9070600@redhat.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Andi Kleen , Anthony Liguori , "kvm@vger.kernel.org" To: Avi Kivity Return-path: Received: from mga09.intel.com ([134.134.136.24]:8370 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbZIJCkF (ORCPT ); Wed, 9 Sep 2009 22:40:05 -0400 In-Reply-To: <4AA79A31.9070600@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, 2009-09-09 at 20:06 +0800, Avi Kivity wrote: [snip] > > > > int kvm_init_ap(void) > > { > > + struct sigaction action; > > + > > #ifdef TARGET_I386 > > kvm_tpr_opt_setup(); > > #endif > > qemu_add_vm_change_state_handler(kvm_vm_state_change_handler, NULL); > > > > signal(SIG_IPI, sig_ipi_handler); > > + > > + memset(&action, 0, sizeof(action)); > > + action.sa_flags = SA_SIGINFO; > > + action.sa_sigaction = (void (*)(int, siginfo_t*, void*))sigbus_handler; > > + sigaction(SIGBUS,&action, NULL); > > + prctl(PR_MCE_KILL, 1, 1); > > return 0; > > } > > > > Why do we need a SIGBUS handler? kvm vcpu threads will block and > dequeue a SIGBUG in guest mode, so the handler will never be called, and > we can't really handle SIGBUS in user mode. There are two kinds of SIGBUS, corresponding to two kinds of UCR MCE. One kind of UCR MCE is caused by user space (guest mode) read/write, and will send SIGBUS to vcpu threads. And that will be processed by vcpu thread sigbus handler just like SIG_IPI processing. The other kind of UCR MCE is caused by asynchronously detected errors (e.g. patrol scrubbing), and will send SIGBUS to main thread instead of vcpu threads. > (also, I if we can't handle guest-mode SIGBUS I think it would be nice > to raise it again so the process terminates due to the SIGBUS). For SIGBUS we can not relay to guest as MCE, we can either abort or reset SIGBUS to SIGDFL and re-raise it. Both are OK for me. You prefer the latter one? Best Regards, Huang Ying