From: "Alex Bennée" <alex.bennee@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PULL 09/23] gdbstub: Fix vCont behaviour
Date: Wed, 31 May 2017 15:47:53 +0100 [thread overview]
Message-ID: <871sr5t752.fsf@linaro.org> (raw)
In-Reply-To: <1487255507-106654-10-git-send-email-pbonzini@redhat.com>
Paolo Bonzini <pbonzini@redhat.com> writes:
> From: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
>
> When GDB issues a "vCont", QEMU was not handling it correctly when
> multiple VCPUs are active.
> For vCont, for each thread (VCPU), it can be specified whether to
> single step, continue or stop that thread. The default is to stop a
> thread.
<snip>
>
> +/**
> + * gdb_handle_vcont - Parses and handles a vCont packet.
> + * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is
> + * a format error, 0 on success.
> + */
> +static int gdb_handle_vcont(GDBState *s, const char *p)
> +{
> + int res, idx, signal = 0;
> + char cur_action;
> + char *newstates;
> + unsigned long tmp;
> + CPUState *cpu;
> +#ifdef CONFIG_USER_ONLY
> + int max_cpus = 1; /* global variable max_cpus exists only in system mode */
> +
> + CPU_FOREACH(cpu) {
> + max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus;
> + }
> +#endif
> + /* uninitialised CPUs stay 0 */
> + newstates = g_new0(char, max_cpus);
> +
> + /* mark valid CPUs with 1 */
> + CPU_FOREACH(cpu) {
> + newstates[cpu->cpu_index] = 1;
> + }
> +
> + /*
> + * res keeps track of what error we are returning, with -ENOTSUP meaning
> + * that the command is unknown or unsupported, thus returning an empty
> + * packet, while -EINVAL and -ERANGE cause an E22 packet, due to invalid,
> + * or incorrect parameters passed.
> + */
> + res = 0;
> + while (*p) {
> + if (*p++ != ';') {
> + res = -ENOTSUP;
> + goto out;
> + }
> +
> + cur_action = *p++;
> + if (cur_action == 'C' || cur_action == 'S') {
> + cur_action = tolower(cur_action);
> + res = qemu_strtoul(p + 1, &p, 16, &tmp);
> + if (res) {
> + goto out;
> + }
> + signal = gdb_signal_to_target(tmp);
> + } else if (cur_action != 'c' && cur_action != 's') {
> + /* unknown/invalid/unsupported command */
> + res = -ENOTSUP;
> + goto out;
> + }
> + /* thread specification. special values: (none), -1 = all; 0 = any */
> + if ((p[0] == ':' && p[1] == '-' && p[2] == '1') || (p[0] != ':')) {
> + if (*p == ':') {
> + p += 3;
> + }
> + for (idx = 0; idx < max_cpus; idx++) {
> + if (newstates[idx] == 1) {
> + newstates[idx] = cur_action;
> + }
> + }
> + } else if (*p == ':') {
> + p++;
> + res = qemu_strtoul(p, &p, 16, &tmp);
> + if (res) {
> + goto out;
> + }
> + idx = tmp;
> + /* 0 means any thread, so we pick the first valid CPU */
> + if (!idx) {
> + idx = cpu_index(first_cpu);
> + }
> +
> + /*
> + * If we are in user mode, the thread specified is actually a
> + * thread id, and not an index. We need to find the actual
> + * CPU first, and only then we can use its index.
> + */
> + cpu = find_cpu(idx);
> + /* invalid CPU/thread specified */
> + if (!idx || !cpu) {
> + res = -EINVAL;
> + goto out;
> + }
This fails on a packet like vCont;C04:0;c where we do find a cpu but it
happens to have a internal cpu_index of 0.
I'm sending a patch.
--
Alex Bennée
next prev parent reply other threads:[~2017-05-31 14:47 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-16 14:31 [Qemu-devel] [PULL 00/23] Misc patches for 2017-02-16 Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 01/23] kvm/ioapic: dump real object instead of a fake one Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 02/23] ioapic: fix error report value of def version Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 03/23] kvm/ioapic: correct kvm ioapic version Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 04/23] test-vmstate: remove yield_until_fd_readable Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 05/23] qemu-char: socket backend: disconnect on write error Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 06/23] apic: reset apic_delivered global variable on machine reset Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 07/23] char: drop data written to a disconnected pty Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 08/23] move vm_start to cpus.c Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 09/23] gdbstub: Fix vCont behaviour Paolo Bonzini
2017-05-31 14:47 ` Alex Bennée [this message]
2018-02-17 8:56 ` Jan Kiszka
2018-02-17 9:07 ` Jan Kiszka
2018-02-17 13:27 ` Alex Bennée
2018-02-17 17:00 ` Jan Kiszka
2018-02-19 18:15 ` Claudio Imbrenda
2018-02-20 13:01 ` Jan Kiszka
2017-02-16 14:31 ` [Qemu-devel] [PULL 10/23] hw/char/mcf_uart: QOMify the ColdFire UART Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 11/23] cpu-exec: fix icount out-of-bounds access Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 12/23] cpu-exec: tighten barrier on TCG_EXIT_REQUESTED Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 13/23] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 14/23] cpu-exec: avoid repeated sigsetjmp on interrupts Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 15/23] cpu-exec: remove outermost infinite loop Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 16/23] qemu-doc: Clarify that -vga std is now the default Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 17/23] qemu-nbd: Implement socket activation Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 18/23] vl: Move the cpu_synchronize_all_post_init() after generic devices initialization Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 19/23] Makefile: avoid leaving the temporary QEMU_PKGVERSION header file Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 20/23] i386/cpu: add crash-information QOM property Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 21/23] report guest crash information in GUEST_PANICKED event Paolo Bonzini
2017-02-16 16:07 ` Eric Blake
2017-02-16 16:08 ` Denis V. Lunev
2017-02-16 16:30 ` [Qemu-devel] [PATCH] qmp-events: fix GUEST_PANICKED description formatting Anton Nefedov
2017-02-16 16:56 ` Eric Blake
2017-02-16 14:31 ` [Qemu-devel] [PULL 22/23] vl: log available guest crash information Paolo Bonzini
2017-02-16 14:31 ` [Qemu-devel] [PULL 23/23] target-i386: correctly propagate retaddr into SVM helpers Paolo Bonzini
2017-02-16 16:07 ` [Qemu-devel] [PULL 00/23] Misc patches for 2017-02-16 no-reply
2017-02-16 17:32 ` Peter Maydell
2017-02-16 17:34 ` Paolo Bonzini
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=871sr5t752.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=imbrenda@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--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).