From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH -v2] QEMU-KVM: MCE: Relay UCR MCE to guest Date: Wed, 09 Sep 2009 15:06:09 +0300 Message-ID: <4AA79A31.9070600@redhat.com> References: <1252463282.5212.44.camel@yhuang-dev.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Andi Kleen , Anthony Liguori , "kvm@vger.kernel.org" To: Huang Ying Return-path: Received: from mx1.redhat.com ([209.132.183.28]:24971 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582AbZIIMGO (ORCPT ); Wed, 9 Sep 2009 08:06:14 -0400 In-Reply-To: <1252463282.5212.44.camel@yhuang-dev.sh.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/09/2009 05:28 AM, Huang Ying wrote: > UCR (uncorrected recovery) MCE is supported in recent Intel CPUs, > where some hardware error such as some memory error can be reported > without PCC (processor context corrupted). To recover from such MCE, > the corresponding memory will be unmapped, and all processes accessing > the memory will be killed via SIGBUS. > > For KVM, if QEMU/KVM is killed, all guest processes will be killed > too. So we relay SIGBUS from host OS to guest system via a UCR MCE > injection. Then guest OS can isolate corresponding memory and kill > necessary guest processes only. SIGBUS sent to main thread (not VCPU > threads) will be broadcast to all VCPU threads as UCR MCE. > > v2: > > - Use qemu_ram_addr_from_host instead of self made one to covert from > host address to guest RAM address. Thanks Anthony Liguori. > > Patch looks good, but can you clarify the following: > @@ -1877,12 +1995,20 @@ void kvm_hpet_enable_kpit(void) > > 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. (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). -- error compiling committee.c: too many arguments to function