From patchwork Mon Mar 25 11:04:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 1064163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.b="LmxE2pxu"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="Sp7Tz1RB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="Sp7Tz1RB"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44SWx63ypPz9sQt for ; Mon, 25 Mar 2019 22:19:03 +1100 (AEDT) Received: from localhost ([127.0.0.1]:40743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Nd7-0001MH-01 for incoming@patchwork.ozlabs.org; Mon, 25 Mar 2019 07:19:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8NPz-0007fl-DV for qemu-devel@nongnu.org; Mon, 25 Mar 2019 07:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8NPx-0000Zr-EH for qemu-devel@nongnu.org; Mon, 25 Mar 2019 07:05:27 -0400 Received: from greensocs.com ([193.104.36.180]:38713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8NPv-0000Yt-AV for qemu-devel@nongnu.org; Mon, 25 Mar 2019 07:05:23 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id DEC337D78AA; Mon, 25 Mar 2019 12:05:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1553511921; bh=jMsdF1/7njOw+ibE9Ehl3HJ5ykuTl7a7rchbEnW+tTg=; h=From:To:Cc:Subject:Date; b=LmxE2pxu+LOtYZ0ujNOUvYTRhU4ngW+kgGU0lsJ6/HqDemBVQxdGhvS0/eK0Ct3mX unEBRvrubRBiKNIt12sXwESChh5fzO6vfwtJennAI0zP5P0lbpPNo30uHYt3iijewI G0AqtJHv/NivX0psDokDWmNyw4qfRsDH6vvHKEfk= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=Sp7Tz1RB; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Sp7Tz1RB Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g-67o7Tw_o2q; Mon, 25 Mar 2019 12:05:20 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 9092F7D788E; Mon, 25 Mar 2019 12:05:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1553511920; bh=jMsdF1/7njOw+ibE9Ehl3HJ5ykuTl7a7rchbEnW+tTg=; h=From:To:Cc:Subject:Date; b=Sp7Tz1RBtkikzp0qF1gh3KIuTkJb5BOi4ZnAEWDEG5GFE+e1qyuJxdrKdAvCgZ3Sz KCEz/PCkSualImyi6fZrYPLNvSt1pcfb9c3qISTrCxC4CTH4VkW2ygFEQ0q8NVKRKy Ep4ctujVkLOWgHIjwBcT6niYbF5KwU/NKO8CPSd0= Received: from michell-laptop.bar.greensocs.com (antfield.tima.u-ga.fr [147.171.129.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 16D617D7887; Mon, 25 Mar 2019 12:05:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1553511920; bh=jMsdF1/7njOw+ibE9Ehl3HJ5ykuTl7a7rchbEnW+tTg=; h=From:To:Cc:Subject:Date; b=Sp7Tz1RBtkikzp0qF1gh3KIuTkJb5BOi4ZnAEWDEG5GFE+e1qyuJxdrKdAvCgZ3Sz KCEz/PCkSualImyi6fZrYPLNvSt1pcfb9c3qISTrCxC4CTH4VkW2ygFEQ0q8NVKRKy Ep4ctujVkLOWgHIjwBcT6niYbF5KwU/NKO8CPSd0= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 25 Mar 2019 12:04:52 +0100 Message-Id: <20190325110452.6756-1-luc.michel@greensocs.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH for-4.0] gdbstub: fix vCont packet handling when no thread is specified X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Lucien Murray-Pitts , Luc Michel , Jan Kiszka Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The vCont packet accepts a series of actions, each being applied on a given thread ID. Giving no thread ID for an action is valid and means "all threads". This commit fixes vCont packets being incorrectly rejected when no thread ID was given for an action. In multiprocess mode, the GDB Remote Protocol specification is unclear on what "all threads" means. We choose to apply the action on all threads of all attached processes. This commit is based on the initial fix by Lucien Murray-Pitts. Fixes: e40e5204af8388 Reported-by: Lucien Murray-Pitts Reported-by: Jan Kiszka Signed-off-by: Luc Michel Reviewed-by: Richard Henderson --- gdbstub.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index bc774ae992..d54abd17cc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1150,10 +1150,11 @@ static int gdb_handle_vcont(GDBState *s, const char *p) char *newstates; unsigned long tmp; uint32_t pid, tid; GDBProcess *process; CPUState *cpu; + GDBThreadIdKind kind; #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; @@ -1192,16 +1193,25 @@ static int gdb_handle_vcont(GDBState *s, const char *p) /* unknown/invalid/unsupported command */ res = -ENOTSUP; goto out; } - if (*p++ != ':') { + if (*p == '\0' || *p == ';') { + /* + * No thread specifier, action is on "all threads". The + * specification is unclear regarding the process to act on. We + * choose all processes. + */ + kind = GDB_ALL_PROCESSES; + } else if (*p++ == ':') { + kind = read_thread_id(p, &p, &pid, &tid); + } else { res = -ENOTSUP; goto out; } - switch (read_thread_id(p, &p, &pid, &tid)) { + switch (kind) { case GDB_READ_THREAD_ERR: res = -EINVAL; goto out; case GDB_ALL_PROCESSES: