qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: gengdongjiu <gengdongjiu@huawei.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Wuquanming <wuquanming@huawei.com>,
	Huangshaoyu <huangshaoyu@huawei.com>
Subject: Re: [Qemu-devel] [question] mask SIGBUS in qemu main thread
Date: Mon, 20 Nov 2017 14:23:01 +0000	[thread overview]
Message-ID: <877eulxc56.fsf@linaro.org> (raw)
In-Reply-To: <CAFEAcA9pg-yRfNJg5uFqU=pve9ypboisB5jo3piZ+ffLVy2xwQ@mail.gmail.com>


Peter Maydell <peter.maydell@linaro.org> writes:

> On 20 November 2017 at 12:50, Alex Bennée <alex.bennee@linaro.org> wrote:
>> What exactly do you expect the main thread to do with a SIGBUS signal?
>
> For KVM, we (can) use SIGBUS for handling machine check exceptions:
> see qemu_init_sigbus() in cpus.c, where we use prctl(PR_MCE_KILL)
> to ask the host kernel to send us a SIGBUS if the memory used
> by the VM has memory corruption detected by the hardwar. This
> then lets us inform the guest (see kvm_mce_inject() in target/i386).
> (This will probably be coming to Arm KVM at some point, as part
> of the RAS extension support. See various threads in kvmarm list.)
>
> Because asynchronous signals are a pain to deal with, for the
> main thread we handle all our signals via signalfd(), which is
> why the main thread shows SIGBUS as blocked. The main thread
> will pick the signal up via the fd at some point. For KVM vcpu
> threads, the signal arrives asynchronously. See sigbus_handler()
> in cpus.c.

Well TIL ;-)

I wonder why the choice was made to re-use SIGBUS for this. I guess the
meaning is semantically the same (some hardware fault) but surprising
they are now asynchronously delivered. When it eventually arrives at the
vCPU it won't be directly tied to what tripped up the machine checking
logic to trigger? Maybe this was never always the case?

I was slightly confused seeing sigbus_handler() only mentioned once in a
sigaction call but grepping around I can now see sigfd_handler()
directly queries the sigaction for a signal before invoking the handler
which I guess makes sense.

>
> thanks
> -- PMM


--
Alex Bennée

  parent reply	other threads:[~2017-11-20 14:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20 12:32 [Qemu-devel] [question] mask SIGBUS in qemu main thread gengdongjiu
2017-11-20 12:50 ` Alex Bennée
2017-11-20 13:00   ` Peter Maydell
2017-11-20 13:32     ` gengdongjiu
2017-11-20 14:23     ` Alex Bennée [this message]
2017-11-20 14:33       ` Peter Maydell

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=877eulxc56.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=gengdongjiu@huawei.com \
    --cc=huangshaoyu@huawei.com \
    --cc=mingo@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wuquanming@huawei.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;
as well as URLs for NNTP newsgroup(s).