From: Michal Novotny <minovotn@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] vl.c: Implement SIGILL signal handler for triggering SIGSEGV
Date: Fri, 06 Sep 2013 15:24:13 +0200 [thread overview]
Message-ID: <5229D77D.2000503@redhat.com> (raw)
In-Reply-To: <CA+aC4kuPq7dyWYdp06qRC=-Hvn0iCaH=jLt4TpCKg-fez75KBA@mail.gmail.com>
On 09/06/2013 12:50 AM, Anthony Liguori wrote:
> On Thu, Sep 5, 2013 at 7:20 AM, Michal Novotny <minovotn@redhat.com> wrote:
>> This is the patch to introduce SIGILL handler to be able to trigger
>> SIGSEGV signal in qemu. This has been written to help debugging
>> state when qemu crashes by SIGSEGV as a simple reproducer to
>> emulate such situation in case of need.
>>
>> Signed-off-by: Michal Novotny <minovotn@redhat.com>
>> ---
>> vl.c | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>>
>> diff --git a/vl.c b/vl.c
>> index 7e04641..3966271 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2897,6 +2897,26 @@ static int object_create(QemuOpts *opts, void *opaque)
>> return 0;
>> }
>>
>> +#ifdef CONFIG_POSIX
>> +static void signal_handler(int signal)
>> +{
>> + int *p = NULL;
>> +
>> + *p = 0xDEADBEEF;
> I won't repeat the questions from Paolo and Lazlo (I share their
> confusion) but will simply add that you cannot rely on NULL address
> accessing causing a SEGV. Even with all the use of volatile in the
> world, there's no guarantee this is going to crash.
>
> Regards,
>
> Anthony Liguori
The idea was to trigger SIGSEGV (working at least at test conditions) to
find out current qemu state. Of course, using gdb is also an option.
Please ignore this patch, it was rather one purpose patch used in testing...
Thanks,
Michal
>
>> +}
>> +
>> +static void setup_signal_handlers(void)
>> +{
>> + struct sigaction action;
>> +
>> + memset(&action, 0, sizeof(action));
>> + sigfillset(&action.sa_mask);
>> + action.sa_handler = signal_handler;
>> + action.sa_flags = 0;
>> + sigaction(SIGILL, &action, NULL);
>> +}
>> +#endif
>> +
>> int main(int argc, char **argv, char **envp)
>> {
>> int i;
>> @@ -2945,6 +2965,10 @@ int main(int argc, char **argv, char **envp)
>> #endif
>> }
>>
>> +#ifdef CONFIG_POSIX
>> + setup_signal_handlers();
>> +#endif
>> +
>> module_call_init(MODULE_INIT_QOM);
>>
>> qemu_add_opts(&qemu_drive_opts);
>> --
>> 1.7.11.7
>>
--
Michal Novotny <minovotn@redhat.com>, RHCE, Red Hat
Virtualization | libvirt-php bindings | php-virt-control.org
prev parent reply other threads:[~2013-09-06 13:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 12:19 [Qemu-devel] [PATCH] vl.c: Implement SIGILL signal handler for triggering SIGSEGV Michal Novotny
2013-09-05 13:26 ` Paolo Bonzini
2013-09-05 22:37 ` Laszlo Ersek
2013-09-05 22:50 ` Anthony Liguori
2013-09-05 23:06 ` Eric Blake
2013-09-06 13:24 ` Michal Novotny [this message]
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=5229D77D.2000503@redhat.com \
--to=minovotn@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/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).