All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org,
	Huang Ying <ying.huang@intel.com>
Subject: Re: [PATCH 07/18] kvm: Add MCE signal support for !CONFIG_IOTHREAD
Date: Wed, 26 Jan 2011 09:09:25 +0100	[thread overview]
Message-ID: <4D3FD6B5.4030303@web.de> (raw)
In-Reply-To: <4D3D7254.1030102@web.de>

[-- Attachment #1: Type: text/plain, Size: 3037 bytes --]

On 2011-01-24 13:36, Jan Kiszka wrote:
> On 2011-01-24 12:17, Marcelo Tosatti wrote:
>> On Mon, Jan 10, 2011 at 09:32:00AM +0100, Jan Kiszka wrote:
>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>
>>> Currently, we only configure and process MCE-related SIGBUS events if
>>> CONFIG_IOTHREAD is enabled. Fix this by factoring out the required
>>> handler registration and system configuration. Make sure that events
>>> happening over a VCPU context in non-threaded mode get dispatched as
>>> VCPU MCEs.
>>>
>>> We also need to call qemu_kvm_eat_signals in non-threaded mode now, so
>>> move it (unmodified) and add the required Windows stub.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> CC: Huang Ying <ying.huang@intel.com>
>>> ---
>>>  cpus.c |  200 +++++++++++++++++++++++++++++++++++++++------------------------
>>>  1 files changed, 124 insertions(+), 76 deletions(-)
>>>
>>> diff --git a/cpus.c b/cpus.c
>>> index 6da0f8f..b6f1cfb 100644
>>> --- a/cpus.c
>>> +++ b/cpus.c
>>> @@ -34,9 +34,6 @@
>>>  
>>>  #include "cpus.h"
>>>  #include "compatfd.h"
>>> -#ifdef CONFIG_LINUX
>>> -#include <sys/prctl.h>
>>> -#endif
>>>  
>>>  #ifdef SIGRTMIN
>>>  #define SIG_IPI (SIGRTMIN+4)
>>> @@ -44,10 +41,24 @@
>>>  #define SIG_IPI SIGUSR1
>>>  #endif
>>>  
>>
>>> @@ -912,6 +954,8 @@ static int qemu_cpu_exec(CPUState *env)
>>>  
>>>  bool cpu_exec_all(void)
>>>  {
>>> +    int r;
>>> +
>>>      if (next_cpu == NULL)
>>>          next_cpu = first_cpu;
>>>      for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
>>> @@ -923,7 +967,11 @@ bool cpu_exec_all(void)
>>>          if (qemu_alarm_pending())
>>>              break;
>>>          if (cpu_can_run(env)) {
>>> -            if (qemu_cpu_exec(env) == EXCP_DEBUG) {
>>> +            r = qemu_cpu_exec(env);
>>> +            if (kvm_enabled()) {
>>> +                qemu_kvm_eat_signals(env);
>>> +            }
>>> +            if (r == EXCP_DEBUG) {
>>>                  break;
>>>              }
>>
>> SIGBUS should be processed outside of vcpu execution context, think of a
>> non MCE SIGBUS while vm is stopped. Could use signalfd for that.
> 
> signalfd - that's the missing bit. I was thinking of how to handle
> SIGBUS events raised outside the vcpu context. We need to handle them
> synchronously, and signalfd should allow this.

This was straightforward. But now I wonder what actually makes this
pattern work. Doesn't the kernel force-inject SIGBUS, i.e. ignores any
blocking? Or does this only apply to BUS_MCEERR_AR?

> 
>>
>> But the SIGBUS handler for !IOTHREAD case should not ignore Action
>> Required, since it might have been generated in vcpu context.
>>
> 
> Yes, the sigbus handler will require some rework when we actually start
> using it for !IOTHREAD.

And this no longer makes sense to me. The current version simply uses
the same sigbus handler for both modes, an that forwards the error code
properly. What did you mean?

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@web.de>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Huang Ying <ying.huang@intel.com>, Avi Kivity <avi@redhat.com>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 07/18] kvm: Add MCE signal support for !CONFIG_IOTHREAD
Date: Wed, 26 Jan 2011 09:09:25 +0100	[thread overview]
Message-ID: <4D3FD6B5.4030303@web.de> (raw)
In-Reply-To: <4D3D7254.1030102@web.de>

[-- Attachment #1: Type: text/plain, Size: 3037 bytes --]

On 2011-01-24 13:36, Jan Kiszka wrote:
> On 2011-01-24 12:17, Marcelo Tosatti wrote:
>> On Mon, Jan 10, 2011 at 09:32:00AM +0100, Jan Kiszka wrote:
>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>
>>> Currently, we only configure and process MCE-related SIGBUS events if
>>> CONFIG_IOTHREAD is enabled. Fix this by factoring out the required
>>> handler registration and system configuration. Make sure that events
>>> happening over a VCPU context in non-threaded mode get dispatched as
>>> VCPU MCEs.
>>>
>>> We also need to call qemu_kvm_eat_signals in non-threaded mode now, so
>>> move it (unmodified) and add the required Windows stub.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> CC: Huang Ying <ying.huang@intel.com>
>>> ---
>>>  cpus.c |  200 +++++++++++++++++++++++++++++++++++++++------------------------
>>>  1 files changed, 124 insertions(+), 76 deletions(-)
>>>
>>> diff --git a/cpus.c b/cpus.c
>>> index 6da0f8f..b6f1cfb 100644
>>> --- a/cpus.c
>>> +++ b/cpus.c
>>> @@ -34,9 +34,6 @@
>>>  
>>>  #include "cpus.h"
>>>  #include "compatfd.h"
>>> -#ifdef CONFIG_LINUX
>>> -#include <sys/prctl.h>
>>> -#endif
>>>  
>>>  #ifdef SIGRTMIN
>>>  #define SIG_IPI (SIGRTMIN+4)
>>> @@ -44,10 +41,24 @@
>>>  #define SIG_IPI SIGUSR1
>>>  #endif
>>>  
>>
>>> @@ -912,6 +954,8 @@ static int qemu_cpu_exec(CPUState *env)
>>>  
>>>  bool cpu_exec_all(void)
>>>  {
>>> +    int r;
>>> +
>>>      if (next_cpu == NULL)
>>>          next_cpu = first_cpu;
>>>      for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
>>> @@ -923,7 +967,11 @@ bool cpu_exec_all(void)
>>>          if (qemu_alarm_pending())
>>>              break;
>>>          if (cpu_can_run(env)) {
>>> -            if (qemu_cpu_exec(env) == EXCP_DEBUG) {
>>> +            r = qemu_cpu_exec(env);
>>> +            if (kvm_enabled()) {
>>> +                qemu_kvm_eat_signals(env);
>>> +            }
>>> +            if (r == EXCP_DEBUG) {
>>>                  break;
>>>              }
>>
>> SIGBUS should be processed outside of vcpu execution context, think of a
>> non MCE SIGBUS while vm is stopped. Could use signalfd for that.
> 
> signalfd - that's the missing bit. I was thinking of how to handle
> SIGBUS events raised outside the vcpu context. We need to handle them
> synchronously, and signalfd should allow this.

This was straightforward. But now I wonder what actually makes this
pattern work. Doesn't the kernel force-inject SIGBUS, i.e. ignores any
blocking? Or does this only apply to BUS_MCEERR_AR?

> 
>>
>> But the SIGBUS handler for !IOTHREAD case should not ignore Action
>> Required, since it might have been generated in vcpu context.
>>
> 
> Yes, the sigbus handler will require some rework when we actually start
> using it for !IOTHREAD.

And this no longer makes sense to me. The current version simply uses
the same sigbus handler for both modes, an that forwards the error code
properly. What did you mean?

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2011-01-26  8:09 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10  8:31 [PATCH 00/18] [uq/master] MCE & IO exit fixes, prepare for VCPU loop reuse Jan Kiszka
2011-01-10  8:31 ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:31 ` [PATCH 01/18] Revert "kvm: Drop return value of kvm_cpu_exec" Jan Kiszka
2011-01-10  8:31   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:31 ` [PATCH 02/18] kvm: Drop redundant kvm_enabled from kvm_cpu_thread_fn Jan Kiszka
2011-01-10  8:31   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:31 ` [PATCH 03/18] kvm: Provide sigbus services arch-independently Jan Kiszka
2011-01-10  8:31   ` [Qemu-devel] " Jan Kiszka
2011-01-10 10:13   ` Paolo Bonzini
2011-01-10 10:13     ` [Qemu-devel] " Paolo Bonzini
2011-01-10 10:30     ` Jan Kiszka
2011-01-10 10:30       ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:31 ` [PATCH 04/18] Refactor signal setup functions in cpus.c Jan Kiszka
2011-01-10  8:31   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:31 ` [PATCH 05/18] kvm: Set up signal mask also for !CONFIG_IOTHREAD Jan Kiszka
2011-01-10  8:31   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:31 ` [PATCH 06/18] kvm: Refactor qemu_kvm_eat_signals Jan Kiszka
2011-01-10  8:31   ` [Qemu-devel] " Jan Kiszka
2011-01-10 10:15   ` Paolo Bonzini
2011-01-10 10:15     ` [Qemu-devel] " Paolo Bonzini
2011-01-10  8:32 ` [PATCH 07/18] kvm: Add MCE signal support for !CONFIG_IOTHREAD Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-24 11:17   ` Marcelo Tosatti
2011-01-24 11:17     ` [Qemu-devel] " Marcelo Tosatti
2011-01-24 12:36     ` Jan Kiszka
2011-01-24 12:36       ` [Qemu-devel] " Jan Kiszka
2011-01-26  8:09       ` Jan Kiszka [this message]
2011-01-26  8:09         ` Jan Kiszka
2011-01-26 12:01         ` Marcelo Tosatti
2011-01-26 12:01           ` [Qemu-devel] " Marcelo Tosatti
2011-01-26 12:06           ` Jan Kiszka
2011-01-26 12:06             ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 08/18] kvm: Handle kvm_init_vcpu errors Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 09/18] Refactor kvm&tcg function names in cpus.c Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 10/18] Fix a few coding style violations " Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 11/18] Introduce VCPU self-signaling service Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-24 11:47   ` Marcelo Tosatti
2011-01-24 11:47     ` [Qemu-devel] " Marcelo Tosatti
2011-01-24 12:36     ` Jan Kiszka
2011-01-24 12:36       ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 12/18] kvm: Move irqchip event processing out of inner loop Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 13/18] kvm: Unconditionally reenter kernel after IO exits Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 14/18] kvm: Remove static return code of kvm_handle_io Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 15/18] kvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 16/18] kvm: Separate TCG from KVM cpu execution Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 17/18] kvm: x86: Prepare VCPU loop for in-kernel irqchip Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10  8:32 ` [PATCH 18/18] kvm: Drop return values from kvm_arch_pre/post_run Jan Kiszka
2011-01-10  8:32   ` [Qemu-devel] " Jan Kiszka
2011-01-10 10:10 ` [PATCH 00/18] [uq/master] MCE & IO exit fixes, prepare for VCPU loop reuse Jan Kiszka
2011-01-10 10:10   ` [Qemu-devel] " Jan Kiszka

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=4D3FD6B5.4030303@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.