From patchwork Wed Mar 6 14:40:14 2024 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: 778299 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp324979wrx; Wed, 6 Mar 2024 06:42:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUCSDbRawgiheaR6LWU03KzMkStfmcok7+U+JnFFFFTLBM2YgtEUvPVLKQGvw9mGW96TY/GTqxAdZY60V4ZAmYA X-Google-Smtp-Source: AGHT+IFig9zEOQnlkYdndamuqZUe8d+2K4cTCZcytyzAgiSllEEpvui42301DThLu2g6WhrKQHIy X-Received: by 2002:a05:6122:917:b0:4d3:3446:6bcb with SMTP id j23-20020a056122091700b004d334466bcbmr5222182vka.16.1709736123980; Wed, 06 Mar 2024 06:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709736123; cv=none; d=google.com; s=arc-20160816; b=T6N5dViLNp/BR0OcrlADRLNbE9qddggpLQhcLyvyYGdZQ55DfPkKe50FpfcdB7suag jnoiFLFwMf9WEXUbVwdEJiGufh7VXu8no7tkWWdu+VyaqJG54jcpTX/2OXFb2MSwOEz/ EgBmboNIcXVFuyCZ7sin8cys34M9KngBYwyTNDL+9f8mgxPpSFMPn5F9lnAKpMTop1GY HjUric8zhPkTsi+oZP2xkevIAIfXhDhitOBJukhLIg8oPWqzmTwCMu4cU7XxJMocaSjJ 2uokZ5q33fsul1002APcxkk/g9i2xNQwxIBc1zre5QLc77/bh7X3cBv4Y+oTmy2IrMa8 GLLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k2Ye6Zrq5ycHJhjf1w+zvDuLih/aI2ewQNO57VPgIhs=; fh=KdHlcw9708PWsJa5cdH8eHDJYSc563Z7JsroucyeR6Y=; b=ca/tudjbWVOk/29rygVaBqws06DVrv2hhX7Yi7/G9qOz9D43dMse00Zd9nPr2kyQaV lOkrmEXxoekYZbgfFj2QV3p6w+Et+IQAD0N/M/5K8M/yXdln1zBgWyeGXhrSSGVXog+h lJOIVDg/FHvmqTMNi6JGMsmSBkKJSKkWaM1TjRjvR9kCbU7fdHNrtBu6TDL3XCpJodb4 uc+I/2EsZW0uHnfY4ZEmYq8jlnXZIa86ZQDlsGZW90bBtbvD/LvI67B3q3uP8TM7Uql7 07IKRuSRJiaG2hsxqNewedis0I9z2q4W/VUwNWsEugculCawFwPUtO3YvyAkbAyWVxVs H65g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=btNnCXZM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bj38-20020a0561220e6600b004c02ae72941si2059380vkb.213.2024.03.06.06.42.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Mar 2024 06:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=btNnCXZM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS3-0007Ij-0t; Wed, 06 Mar 2024 09:40:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS0-00078A-Bp for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:56 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001TJ-9C for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:56 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-412e784060cso5720475e9.1 for ; Wed, 06 Mar 2024 06:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736043; x=1710340843; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k2Ye6Zrq5ycHJhjf1w+zvDuLih/aI2ewQNO57VPgIhs=; b=btNnCXZM20Nr3KsNk9UDxk57AOFcAn1Rqb+eJyngGJ5cpZApvJ4SIjY7kHG7RcRthI d9hKcAIBzzuClkPnymwpUJD8fKjiKVvSl6eeuPnzAhFvHxnqymqyL79CNjeN7f2DuFeq pyI+AkfqXPT8QhRedhzDE4ivrj2mQtl3MPBTF8Dm7w9KzvL4o8f/Mad7AnlfM07cfSUq EAQsMRRrH64+99eD8HbTElx35/WFw27tEzEMq/wcUD6dCZiu4K1sa5O2QCNsrXG2C/8V 4p5bjnxYXt9bsUpyysCT0HZUQJEK6FaH5idbl1HSZvy3glVbwp6Z1k1yfl2r4OFxhnWX qNWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736043; x=1710340843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k2Ye6Zrq5ycHJhjf1w+zvDuLih/aI2ewQNO57VPgIhs=; b=uEhhkKJZ5hiLuHYrYHSPEk3cXKPCCYIhwcS2s8Xzt7rhCWwsdyJwymb/egllckFJI2 WRoON4EBass75GNJCo4twd5dZxdW8kQmDFZpoEidTmFiQsZWmIkEuVJ0HXwqsUz4m9ku CytYaw1SxYK0hqfJTLR8eiDvSqb79GuWPvneHRgLcNsrM4Qs7XUI/c8s2P+3/bq8Mmwr 2gYIyuLUoXOOnFct10v0K4UDwqSMhcLWe59tysH6ZUS6VNfK0DDj0rYD45WGc2BYsues 7RCDXXndpQI2skXy6MRj1liAagmqvd/FNzm+StuM0lws7pTe5uxAKy3+31YSgnkvg+SC 0yYw== X-Gm-Message-State: AOJu0YwjKgB0B3zUwzRFZ4jNb739s/pj9Cp86mBNScnBTfb/7YsB/UkV VF4Ign/lHQ4wEWhK6vpvfstCpRU558Whi4WxmFCdvgjxcaQvyfa1MTKhls7PVHE= X-Received: by 2002:a05:600c:1d09:b0:412:c285:1091 with SMTP id l9-20020a05600c1d0900b00412c2851091mr4915995wms.7.1709736042789; Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id d8-20020a05600c3ac800b00412e84e59d8sm7327075wms.44.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B71465F94F; Wed, 6 Mar 2024 14:40:41 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 02/29] gdbstub: Support disablement in a multi-threaded process Date: Wed, 6 Mar 2024 14:40:14 +0000 Message-Id: <20240306144041.3787188-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich The upcoming follow-fork-mode child support will require disabling gdbstub in the parent process, which may have multiple threads (which are represented as CPUs). Loop over all CPUs in order to remove breakpoints and disable single-step. Move the respective code into a separate function. Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-2-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20240305121005.3528075-3-alex.bennee@linaro.org> diff --git a/gdbstub/user.c b/gdbstub/user.c index 14918d1a217..3ce20b7bbfc 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -356,16 +356,27 @@ int gdbserver_start(const char *port_or_path) return -1; } +static void disable_gdbstub(CPUState *thread_cpu) +{ + CPUState *cpu; + + close(gdbserver_user_state.fd); + gdbserver_user_state.fd = -1; + CPU_FOREACH(cpu) { + cpu_breakpoint_remove_all(cpu, BP_GDB); + /* no cpu_watchpoint_remove_all for user-mode */ + cpu_single_step(cpu, 0); + } + tb_flush(thread_cpu); +} + /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - close(gdbserver_user_state.fd); - gdbserver_user_state.fd = -1; - cpu_breakpoint_remove_all(cpu, BP_GDB); - /* no cpu_watchpoint_remove_all for user-mode */ + disable_gdbstub(cpu); } /*