public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org,
	Huang Ying <ying.huang@intel.com>,
	Dean Nelson <dnelson@redhat.com>
Subject: Re: [patch uq/master 7/8] MCE: Relay UCR MCE to guest
Date: Wed, 06 Oct 2010 10:10:51 +0900	[thread overview]
Message-ID: <4CABCC9B.10101@jp.fujitsu.com> (raw)
In-Reply-To: <20101004185715.167557459@redhat.com>

(2010/10/05 3:54), Marcelo Tosatti wrote:
> Port qemu-kvm's
> 
> commit 4b62fff1101a7ad77553147717a8bd3bf79df7ef
> Author: Huang Ying <ying.huang@intel.com>
> Date:   Mon Sep 21 10:43:25 2009 +0800
> 
>     MCE: Relay UCR MCE to guest
>     
>     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.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> 

(snip)

> +static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo,
> +                           void *ctx)
> +{
> +#if defined(TARGET_I386)
> +    if (kvm_on_sigbus_vcpu(siginfo->ssi_code, (void *)(intptr_t)siginfo->ssi_addr))
> +#endif
> +        sigbus_reraise();
> +}
> +
>  static void qemu_kvm_eat_signal(CPUState *env, int timeout)
>  {
>      struct timespec ts;
>      int r, e;
>      siginfo_t siginfo;
>      sigset_t waitset;
> +    sigset_t chkset;
>  
>      ts.tv_sec = timeout / 1000;
>      ts.tv_nsec = (timeout % 1000) * 1000000;
>  
>      sigemptyset(&waitset);
>      sigaddset(&waitset, SIG_IPI);
> +    sigaddset(&waitset, SIGBUS);
>  
> -    qemu_mutex_unlock(&qemu_global_mutex);
> -    r = sigtimedwait(&waitset, &siginfo, &ts);
> -    e = errno;
> -    qemu_mutex_lock(&qemu_global_mutex);
> +    do {
> +        qemu_mutex_unlock(&qemu_global_mutex);
>  
> -    if (r == -1 && !(e == EAGAIN || e == EINTR)) {
> -        fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
> -        exit(1);
> -    }
> +        r = sigtimedwait(&waitset, &siginfo, &ts);
> +        e = errno;
> +
> +        qemu_mutex_lock(&qemu_global_mutex);
> +
> +        if (r == -1 && !(e == EAGAIN || e == EINTR)) {
> +            fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
> +            exit(1);
> +        }
> +
> +        switch (r) {
> +        case SIGBUS:
> +#ifdef TARGET_I386
> +            if (kvm_on_sigbus(env, siginfo.si_code, siginfo.si_addr))
> +#endif
> +                sigbus_reraise();
> +            break;
> +        default:
> +            break;
> +        }
> +
> +        r = sigpending(&chkset);
> +        if (r == -1) {
> +            fprintf(stderr, "sigpending: %s\n", strerror(e));
> +            exit(1);
> +        }
> +    } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS));
>  }
>  
>  static void qemu_kvm_wait_io_event(CPUState *env)

(snip)

> Index: qemu/kvm.h
> ===================================================================
> --- qemu.orig/kvm.h
> +++ qemu/kvm.h
> @@ -110,6 +110,9 @@ int kvm_arch_init_vcpu(CPUState *env);
>  
>  void kvm_arch_reset_vcpu(CPUState *env);
>  
> +int kvm_on_sigbus(CPUState *env, int code, void *addr);
> +int kvm_on_sigbus_vcpu(int code, void *addr);
> +
>  struct kvm_guest_debug;
>  struct kvm_debug_exit_arch;
>  

So kvm_on_sigbus() is called from qemu_kvm_eat_signal() that is
called on vcpu thread, while kvm_on_sigbus_vcpu() is called via
sigbus_handler that invoked on iothread using signalfd.

... Inverse naming?


Thanks,
H.Seto


  reply	other threads:[~2010-10-06  1:11 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04 18:54 [patch uq/master 0/8] port qemu-kvm's MCE support Marcelo Tosatti
2010-10-04 18:54 ` [patch uq/master 1/8] signalfd compatibility Marcelo Tosatti
2010-10-04 18:54 ` [patch uq/master 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-04 18:54 ` [patch uq/master 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-04 18:54 ` [patch uq/master 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-04 18:54 ` [patch uq/master 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-05 12:57   ` Anthony Liguori
2010-10-05 20:13     ` Marcelo Tosatti
2010-10-05 20:48       ` Anthony Liguori
2010-10-04 18:54 ` [patch uq/master 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-04 18:54 ` [patch uq/master 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-06  1:10   ` Hidetoshi Seto [this message]
2010-10-06 16:02     ` Marcelo Tosatti
2010-10-06  1:58   ` Hidetoshi Seto
2010-10-06 16:05     ` Marcelo Tosatti
2010-10-06 18:10       ` Dean Nelson
2010-10-07  3:41         ` Hidetoshi Seto
2010-10-07 15:23           ` Dean Nelson
2010-10-08  3:15           ` Huang Ying
2010-10-08  5:54             ` Hidetoshi Seto
2010-10-08 12:02             ` Dean Nelson
2010-10-08  2:50       ` Huang Ying
2010-10-04 18:54 ` [patch uq/master 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-05 16:31 ` [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support Andreas Färber
2010-10-05 18:58   ` Chris Wright
2010-10-05 20:24     ` Marcelo Tosatti
2010-10-06 17:34 ` [patch uq/master 0/8] port qemu-kvm's MCE support (v2) Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 1/8] signalfd compatibility Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-06 19:32     ` Anthony Liguori
2010-10-06 17:34   ` [patch uq/master 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-06 17:34   ` [patch uq/master 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-11 18:31   ` [patch 0/8] port qemu-kvm's MCE support (v3) Marcelo Tosatti
2010-10-11 18:31     ` [patch 1/8] signalfd compatibility Marcelo Tosatti
2010-10-11 18:31     ` [patch 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-11 18:31     ` [patch 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-11 18:31     ` [patch 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-11 18:31     ` [patch 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-11 18:31     ` [patch 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-11 18:31     ` [patch 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-11 18:31     ` [patch 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-14 10:25     ` [patch 0/8] port qemu-kvm's MCE support (v3) Avi Kivity
2010-10-14 16:21       ` Marcelo Tosatti
2010-10-17  9:32     ` [patch 0/8] port qemu-kvm's MCE support (v3 resend) Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CABCC9B.10101@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=dnelson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox