From patchwork Thu Jun 1 14:49:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 100934 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp842145qge; Thu, 1 Jun 2017 07:50:23 -0700 (PDT) X-Received: by 10.237.59.20 with SMTP id p20mr2401008qte.95.1496328623373; Thu, 01 Jun 2017 07:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496328623; cv=none; d=google.com; s=arc-20160816; b=dINt4Taow2sZu6zUPcQGMlw0oQvB5/lR0dD1RsA857d7i4Ig0u/csfJvM2+eXODBQH gfc66y5wXBuguMNfc41jSeqe9LPTrXPGG4DyULGy02Y+bqYNdqQPAW0G362xzK7l4oP+ jxsGUYH2hc9R+j3ao1LgcCeEucpIHSXFQ4/mN4hD/Xa8ONHi3Xct/Z1TP5vWgdxhrsnh d0l5wZASNiNmJipiV4kh88gw+kVLxxtxqgr0KjlMLOlFJiyAoZ9td5aS/K+tC4f8Gok9 +P2akMIJALXEGPIr/E6THHIKPestiw6BBbidYvj2AMlSNnfsYMtwNwaiKf1w/tPtASYK r7/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=HhZLgiZIYSbWdRfyBX/zeaHilTG24DkAtqRdhfxEMJg=; b=uXoJmndGw62GZAHwP6Jn1Axbpu9X7iSWDpI/pHvnMZ96gWqI6ARjSaEp5bSMUWC4V7 4/JSiVpF+3XUqMFuFqfZJRsUcOPhws32iMQNHSHe7Omz8GfKOEYP6UYWbp33ell0ke6c 4JXSxh8GPe/jRohWiRfcEhM2g15cZx7BttXJGxOKEAE4F1WhWbxesJjDP8dF2GOWxVuh B2A/dtpWI8ZlGez/mRQo10xuAO0eAtDborFP+mwKGH5T12JoJA4YWudEHpLGTaAzATTc xwVHDEuY6pMIq51f3ECrDVuJkK/dThin3V9SJcEbCPYemaPWjcfJDmHw+KWQwoYPX3OX 6ySQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k36si1569210qtd.264.2017.06.01.07.50.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Jun 2017 07:50:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRQZ-0005CW-Of for patch@linaro.org; Thu, 01 Jun 2017 10:50:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGRPM-0004Xp-4i for qemu-devel@nongnu.org; Thu, 01 Jun 2017 10:49:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGRPK-0002VR-B4 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 10:49:04 -0400 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:37314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGRPK-0002U3-4Y for qemu-devel@nongnu.org; Thu, 01 Jun 2017 10:49:02 -0400 Received: by mail-wm0-x22f.google.com with SMTP id d127so63402976wmf.0 for ; Thu, 01 Jun 2017 07:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HhZLgiZIYSbWdRfyBX/zeaHilTG24DkAtqRdhfxEMJg=; b=SGT7Q2ILJxL5l2Z6H3WzIqwRNQgRX9TcTYLK7Qu4zzv02sx/0TLdpV0uhQDZYXFjZa kV5OjGGUBfTZ6r3+f7JoB0RaKcB+nZYMXB52E4CfFUgogh6Nj0h9sNH2DAiZthesL6HP nht1D0/DudnW2pkIl/2EBwie7dc4gf5erh9s4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HhZLgiZIYSbWdRfyBX/zeaHilTG24DkAtqRdhfxEMJg=; b=nUAi/iX7CHaaP0nC9Y59KSlTO6//5ICC2zvtn7JGKauoApzPj9jF68Jw5nEyGVGWUl AYQ+GSxB72wnc6W0UkEJ0sGkVq2KRsyPlWzPUrFoeMfpRWHP1eDtkY8ZwMQGJrIS1Jr+ dnuzLVGpieJltCN4/i894MSaiAaz7r7cIUdUu40aqEjp6OR0grJPt0Y0x+xqXO3cyHyk xhR4Kv/v9AOABpzK/3QfdqFsHQ3CAY3ookGVJ9y5vkIcV7ysv8TVpK1asQ3hv1dWHeC8 /3hK9SuMzyWi7zRS/EChU6EMqXzT/oE7bflNXLQp0gBFHLkVQR2zkK1PijmeRvIsxtzD mVbQ== X-Gm-Message-State: AODbwcAv9fEgao6vc9OHtcdC/S9coy7jHwSi5zTtcOO0SZf4gPemUL5b F8QgDeNfYywwuEYr X-Received: by 10.28.7.16 with SMTP id 16mr9605106wmh.16.1496328539014; Thu, 01 Jun 2017 07:48:59 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l30sm13817208wre.25.2017.06.01.07.48.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 07:48:57 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 84D7C3E0496; Thu, 1 Jun 2017 15:49:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com, doug16k@gmail.com, imbrenda@linux.vnet.ibm.com Date: Thu, 1 Jun 2017 15:49:14 +0100 Message-Id: <20170601144915.20778-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170601144915.20778-1-alex.bennee@linaro.org> References: <20170601144915.20778-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22f Subject: [Qemu-devel] [PATCH v2 3/4] qom/cpu: remove host_tid field 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: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This was only used by the gdbstub and even then was only being set for subsequent threads. Rather the continue duplicating the number just make the gdbstub get the information from TaskState structure. Now the tid is correctly reported for all threads the bug I was seeing with "vCont;C04:0;c" packets is fixed as the correct tid is reported to gdb. I moved cpu_gdb_index into the gdbstub to facilitate easy access to the TaskState which is used elsewhere in gdbstub. Signed-off-by: Alex Bennée --- gdbstub.c | 15 +++++++++++++++ include/exec/gdbstub.h | 14 -------------- include/qom/cpu.h | 2 -- linux-user/syscall.c | 1 - 4 files changed, 15 insertions(+), 17 deletions(-) -- 2.13.0 Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Claudio Imbrenda Reviewed-by: Laurent Vivier diff --git a/gdbstub.c b/gdbstub.c index 026d1fe6bb..45a3a0b16b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -55,6 +55,21 @@ static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } +/* Return the GDB index for a given vCPU state. + * + * For user mode this is simply the thread id. In system mode GDB + * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. + */ +static inline int cpu_gdb_index(CPUState *cpu) +{ +#if defined(CONFIG_USER_ONLY) + TaskState *ts = (TaskState *) cpu->opaque; + return ts->ts_tid; +#else + return cpu->cpu_index + 1; +#endif +} + enum { GDB_SIGNAL_0 = 0, GDB_SIGNAL_INT = 2, diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index c4fe567600..9aa7756d92 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -58,20 +58,6 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_reg_cb get_reg, gdb_reg_cb set_reg, int num_regs, const char *xml, int g_pos); -/* Return the GDB index for a given vCPU state. - * - * For user mode this is simply the thread id. In system mode GDB - * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. - */ -static inline int cpu_gdb_index(CPUState *cpu) -{ -#if defined(CONFIG_USER_ONLY) - return cpu->host_tid; -#else - return cpu->cpu_index + 1; -#endif -} - /* The GDB remote protocol transfers values in target byte order. This means * we can use the raw memory access routines to access the value buffer. * Conveniently, these also handle the case where the buffer is mis-aligned. diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 55214ce131..909e7ae994 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -266,7 +266,6 @@ struct qemu_work_item; * @nr_cores: Number of cores within this CPU package. * @nr_threads: Number of threads within this CPU. * @numa_node: NUMA node this CPU is belonging to. - * @host_tid: Host thread ID. * @running: #true if CPU is currently running (lockless). * @has_waiter: #true if a CPU is currently waiting for the cpu_exec_end; * valid under cpu_list_lock. @@ -321,7 +320,6 @@ struct CPUState { HANDLE hThread; #endif int thread_id; - uint32_t host_tid; bool running, has_waiter; struct QemuCond *halt_cond; bool thread_kicked; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cec8428589..cada188e58 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6216,7 +6216,6 @@ static void *clone_func(void *arg) thread_cpu = cpu; ts = (TaskState *)cpu->opaque; info->tid = gettid(); - cpu->host_tid = info->tid; task_settid(ts); if (info->child_tidptr) put_user_u32(info->tid, info->child_tidptr);