From patchwork Wed Jul 12 10:52:15 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: 107477 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp649243qge; Wed, 12 Jul 2017 03:56:20 -0700 (PDT) X-Received: by 10.200.55.208 with SMTP id e16mr5326426qtc.198.1499856980017; Wed, 12 Jul 2017 03:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499856980; cv=none; d=google.com; s=arc-20160816; b=cRxdc978U44iN7ivihECfpaFqT9Jdha5rzxrEwiTKjpw++cMPyHq/yaed0EliI/85i s0qOHrJVa6bfCZ9EuBFUDevjAL/jRxpGkuABIb2Q/jINNb9uQY+qJrd4SaMi0FUqHosm srv/GGKsJYPVaptpo6E07Tck2uMx5s/5KPntIVJLyblaa+d926N7HXwdkY4wTjtMAH3K utTZmQOdcnJ9O+lMcKwmQsEJsU0kelel7lgBUBWPkZIw1SoaBpIVInBXjGVU2a+jVp1a 0pQWrrfQWz8sTHbrcw4ykajaKJqnYRgesO/pqfFtZaZDuQrwW60RFVYWqMkV5n65TqTS 8i/A== 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=TS4LOcMtR8F8ENWKcSA6UF3p+XUn+M+VO0pxw9VOPco=; b=i91olOHJryCIcxCeCHy5OzBL3JGzB+qGaGAylqqsRMfQK8Ig+nYV1v1lBQrAgIyT91 RPUf3aw03PjYgds/n2kXp97BSDe+3LoV2xdwNC9VdiuS66RpbCzmJBPFap+axzlx9ceU CYc4AzR8Yy7b9yRy6X+mfNBL/rch81U/+ArIZEMlXhbYKcmnj2cyBdUeNjMJQZ5aU2zs /H6BWlrbE2E35V1Cv4uIrAXqannJNwWMU+T7FD11YEyvpdevriIh4HIYiKauLZ2+V2tM 5AREwEVAthQYWtzK/PXumEnzuTptRSTY6Fkn9h4xHn35znZzAYxxAc9z3NnuU1EJpZeF Ljkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=kgejAX7h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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. [208.118.235.17]) by mx.google.com with ESMTPS id v75si1929319qkl.144.2017.07.12.03.56.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 12 Jul 2017 03:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=kgejAX7h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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]:51703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVFJZ-0006yK-Na for patch@linaro.org; Wed, 12 Jul 2017 06:56:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVFGo-0004jK-QV for qemu-devel@nongnu.org; Wed, 12 Jul 2017 06:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVFGl-00020F-NZ for qemu-devel@nongnu.org; Wed, 12 Jul 2017 06:53:26 -0400 Received: from mail-wr0-f176.google.com ([209.85.128.176]:34058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVFGl-0001zh-HS for qemu-devel@nongnu.org; Wed, 12 Jul 2017 06:53:23 -0400 Received: by mail-wr0-f176.google.com with SMTP id 77so28342456wrb.1 for ; Wed, 12 Jul 2017 03:53:23 -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=TS4LOcMtR8F8ENWKcSA6UF3p+XUn+M+VO0pxw9VOPco=; b=kgejAX7hYxl+sUoeD4tT9QLmWCTmcyq+F3gpawCXrMH60LXOjKRlhqljUWka+Sr5eW LEauwKWk58O02Gub3gwxXi8UT1rv5RlCjDkC2LiaVS9Ogt+8ARBSgJ9uX1SK11KuLXeC kfOC2p/B4Tjcww9afy5mYlwlwQ7IcjMLsk9Rw= 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=TS4LOcMtR8F8ENWKcSA6UF3p+XUn+M+VO0pxw9VOPco=; b=i7rSl2zGq+WtR1N7wuOyE5pv7832So1Qvc5RYnSv7Aao1euPXBFeFuJrKUyXYC6No3 KP/waGEt6n6yhJYN/GgzI4by+QHHs8EebT2d9OrF96WuHgNHf/SgiBgRJmbrHUkHo3Uv rSnIfFjWGcjuQf6YOfmfEXZIncDXgTvY+VSXyjGy6548x8MFloNdHnnCgqDzB3cDQ86P i0kapn1P31yYgWZZCQ4M1i2a3E7UsWf6p7Aqeyx5LfGCCuQfKy32rF1NmfMdNJc6ZnNR Pp1aTf/7joGJQth2nNJA866WEP4Td/Q14OYQgqjvEZgyPbvx+6/FbyhiI4fbEOugIkYt NO7A== X-Gm-Message-State: AIVw110wkswMbEXQyZv2GW57y5/XaVoUMndphNj882astmNjmjcprHbT 3y51IwGhVIyg5Pb68KnVCQ== X-Received: by 10.28.221.85 with SMTP id u82mr1880367wmg.40.1499856742175; Wed, 12 Jul 2017 03:52:22 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 143sm2469838wmg.9.2017.07.12.03.52.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 03:52:19 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 335823E08FA; Wed, 12 Jul 2017 11:52:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: pbonzini@redhat.com Date: Wed, 12 Jul 2017 11:52:15 +0100 Message-Id: <20170712105216.747-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170712105216.747-1-alex.bennee@linaro.org> References: <20170712105216.747-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.176 Subject: [Qemu-devel] [PATCH v4 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. To prevent BSD failing to build I've included ts_tid into its TaskStruct but not populated it - which was the same state as the old cpu->host_tid. I'll leave it up to the BSD maintainers to actually populate this properly if they want a working gdbstub with user-threads. Signed-off-by: Alex Bennée Reviewed-by: Greg Kurz Reviewed-by: Claudio Imbrenda Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier --- v4 - add host_tid field for BSD (but don't populate it) v3 - fix merge, did move of function in previous commit --- bsd-user/qemu.h | 2 ++ gdbstub.c | 3 ++- include/qom/cpu.h | 2 -- linux-user/syscall.c | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) -- 2.13.0 diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index b550cee0cb..19b2b8fecb 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -85,6 +85,8 @@ struct emulated_sigtable { /* NOTE: we force a big alignment so that the stack stored after is aligned too */ typedef struct TaskState { + pid_t ts_tid; /* tid (or pid) of this task */ + struct TaskState *next; int used; /* non zero if used */ struct image_info *info; diff --git a/gdbstub.c b/gdbstub.c index 6b56f55eba..484e96dbd9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -64,7 +64,8 @@ static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, static inline int cpu_gdb_index(CPUState *cpu) { #if defined(CONFIG_USER_ONLY) - return cpu->host_tid; + TaskState *ts = (TaskState *) cpu->opaque; + return ts->ts_tid; #else return cpu->cpu_index + 1; #endif diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 7bfd50cc32..d3c783b4b5 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -265,7 +265,6 @@ struct qemu_work_item; * @cpu_index: CPU index (informative). * @nr_cores: Number of cores within this CPU package. * @nr_threads: Number of threads within this CPU. - * @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. @@ -319,7 +318,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 925ae11ea6..003943b736 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6219,7 +6219,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);