From patchwork Sat Mar 9 03:08:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 779149 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp581706wrt; Fri, 8 Mar 2024 19:11:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU2hY0bPu2XhZM4YH6uX79NY3q5AF4EaY5dkhEa83vc2Et7srb0JSNIxw2ZsEMcpPMrc8GKnedVV6gZ1dbeoyaG X-Google-Smtp-Source: AGHT+IFuTv/Ro2HtinLGI39XcXxbpSyOepoRescbRDdVhQ6jhAU/44f66uupafPtj2CT04fAov+k X-Received: by 2002:a05:6214:2cc8:b0:690:af2e:5c2c with SMTP id lf8-20020a0562142cc800b00690af2e5c2cmr798529qvb.16.1709953886721; Fri, 08 Mar 2024 19:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709953886; cv=none; d=google.com; s=arc-20160816; b=ceaH/FBy2FBnpkTzQwWTdEjapoKaAx1+dhW9b0nM9coB4QeB2YsX6IuNODBMFa98zB OKCocvDhFO+8rJ+pQBkE0zDwjLxM1oDbj4MYPgFMZ4tkaxwdiUW6d1J/SZSqSs1ovVsa 8Snsle2GX4Ld7mxtAta/vTC7nVdygttzHcHJ8xa8KrT98cfbnWI6fHTFr1MaG5n87Egd RgXCkW0okyK1LfSa4cap4TkpU6jLmR5tI6QrS/o9TK+3jRDPkTZGaFTmDVKdKnPnNVCt 0Sq88stNg25i7glR+fKDDr36xenh/T77ODEw1guFbtFnvRjrIDH9Ov0nOK/rDHhE4gey ON2Q== 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=8tpJAfxQcRF8joD00NGmo1iAef1vo78TLl0CoONZU1s=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=BR58ycCKsaqEuZkxtcH/e/4QVXbFhW/YrOrYGmNsi4kO7W15ZBbz0NWdy8JFUzfv8Y 733I1LVMKC0agFFAYdCeN08gVK7aW+QFG5Ee+aCJ3Ty/YwYyRVyr1zulyB7YQWNI3uaR Kt5FOC7vXbg2xA2Kh10VLMGwHxBoXqlq28eTcaAXNxnSkuOLpCDif8nOY0U6FI1cvJwq YKpitCiyh6+dv2ewTl/HdTiYimJFeUZYpryGmwvCiLdSq6L8IydfZgsNBhVMJ4vskMGV jPeBS+2JE2+iaCBw3894sm7ke/YX+xmJo6Bak+ZrAB+wbiprpf66wkO2nfoQL2M35Tk4 XHqQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="E9zdb/F5"; 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 5-20020ad45ba5000000b0068cd964819asi822009qvq.392.2024.03.08.19.11.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2024 19:11:26 -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="E9zdb/F5"; 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 1rin6f-0000tv-4Y; Fri, 08 Mar 2024 22:10:41 -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 1rin6V-0000tE-VO for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:32 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rin6T-00046q-9l for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:30 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dca3951ad9so21694695ad.3 for ; Fri, 08 Mar 2024 19:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709953825; x=1710558625; 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=8tpJAfxQcRF8joD00NGmo1iAef1vo78TLl0CoONZU1s=; b=E9zdb/F5RetjM7U0NsLcedWnsTjdgUyqUgzVQenfdFymRscTerk46t8argR1XzRHuK MZNxkRSiNeSyqArjGZv+GdDrWz2QLoSv8XG48gLRgckuFyOWdUptGS1nOi/N2TAhNYml DUEqk4KzXH6LONL00cZPw8Cy0G6wy9daui6xcxE6ZZlD5eDlAuVa+s2GS3y6/hNk7CKo OLI6n6kfxf92M07y7obgt587/OXCWILmskDz+wAEMrmc049LVwWW7jhNxqvaOL5dt2cR prQG9f4FS6oZEWIp513GY2FpXoD9/6GBdUQHJKdYfQvr+R8Y4sIH75SDvt1MU0+BUlNf w2IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709953825; x=1710558625; 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=8tpJAfxQcRF8joD00NGmo1iAef1vo78TLl0CoONZU1s=; b=eTtYLYjqV1W6cPvk0jcyKU/tra0Sexm7Pj5W6oWR1aq/eOgjUgRHQk4qhrkZCsd7YB StsS6tFcafq957H27arZZGtpIU5xZIEQeGa+QN30qLv78DwDl52BH0ypaqpqs0NMQjzH lTumzpC/YlY5f/NwB72amUm7OGuuR01AVvFG0DIlwv6cGo9oClWK2HD5CrWW7RBykaIE y9Ot+o3cGf11Y9kyPxy1Yhv40FyWvQSK1ikTai4Ly8RLVPm3AVVsavm/M89SP4x+eScm 8yv3myJ+36XDXH1Fn9+ilMXUI678QlMJDCH8Dndq4Ayo8ySSIRvswKzU5B9Wl6uj7mC1 Qt6A== X-Gm-Message-State: AOJu0YyWCqRgF8yWvNLrh4fGm/RAYa77SDUHgbEXY3lRzHAiBREd/9S1 /vIyFHyqwfKsI+4SfvHpVFUNdow0+ekpEgs9AxWS0XZclw25vb2ladb8PBrlScSdseaLIW/JA+S 0cKc= X-Received: by 2002:a17:903:244b:b0:1dd:4cf3:5771 with SMTP id l11-20020a170903244b00b001dd4cf35771mr541487pls.60.1709953825429; Fri, 08 Mar 2024 19:10:25 -0800 (PST) Received: from amd.. ([2804:7f0:b401:7e8e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id w13-20020a170902d3cd00b001dd707d5fe6sm349566plb.158.2024.03.08.19.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 19:10:24 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 1/5] gdbstub: Rename back gdb_handlesig Date: Sat, 9 Mar 2024 03:08:57 +0000 Message-Id: <20240309030901.1726211-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309030901.1726211-1-gustavo.romero@linaro.org> References: <20240309030901.1726211-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x632.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 Rename gdb_handlesig_reason back to gdb_handlesig. There is no need to add a wrapper for gdb_handlesig and rename it when a new parameter is added. Signed-off-by: Gustavo Romero Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- gdbstub/user.c | 8 ++++---- include/gdbstub/user.h | 15 ++------------- linux-user/main.c | 2 +- linux-user/signal.c | 2 +- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index 14918d1a21..a157e67f95 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -131,7 +131,7 @@ void gdb_qemu_exit(int code) exit(code); } -int gdb_handlesig_reason(CPUState *cpu, int sig, const char *reason) +int gdb_handlesig(CPUState *cpu, int sig, const char *reason) { char buf[256]; int n; @@ -510,7 +510,7 @@ void gdb_breakpoint_remove_all(CPUState *cs) void gdb_syscall_handling(const char *syscall_packet) { gdb_put_packet(syscall_packet); - gdb_handlesig(gdbserver_state.c_cpu, 0); + gdb_handlesig(gdbserver_state.c_cpu, 0, NULL); } static bool should_catch_syscall(int num) @@ -528,7 +528,7 @@ void gdb_syscall_entry(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_entry:%x;", num); - gdb_handlesig_reason(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason); } } @@ -536,7 +536,7 @@ void gdb_syscall_return(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_return:%x;", num); - gdb_handlesig_reason(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason); } } diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 68b6534130..6647af2123 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -10,7 +10,7 @@ #define GDBSTUB_USER_H /** - * gdb_handlesig_reason() - yield control to gdb + * gdb_handlesig() - yield control to gdb * @cpu: CPU * @sig: if non-zero, the signal number which caused us to stop * @reason: stop reason for stop reply packet or NULL @@ -25,18 +25,7 @@ * or 0 if no signal should be delivered, ie the signal that caused * us to stop should be ignored. */ -int gdb_handlesig_reason(CPUState *, int, const char *); - -/** - * gdb_handlesig() - yield control to gdb - * @cpu CPU - * @sig: if non-zero, the signal number which caused us to stop - * @see gdb_handlesig_reason() - */ -static inline int gdb_handlesig(CPUState *cpu, int sig) -{ - return gdb_handlesig_reason(cpu, sig, NULL); -} +int gdb_handlesig(CPUState *, int, const char *); /** * gdb_signalled() - inform remote gdb of sig exit diff --git a/linux-user/main.c b/linux-user/main.c index 551acf1661..049fd85a2a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1014,7 +1014,7 @@ int main(int argc, char **argv, char **envp) gdbstub); exit(EXIT_FAILURE); } - gdb_handlesig(cpu, 0); + gdb_handlesig(cpu, 0, NULL); } #ifdef CONFIG_SEMIHOSTING diff --git a/linux-user/signal.c b/linux-user/signal.c index d3e62ab030..a57c45de35 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1180,7 +1180,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, /* dequeue signal */ k->pending = 0; - sig = gdb_handlesig(cpu, sig); + sig = gdb_handlesig(cpu, sig, NULL); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; From patchwork Sat Mar 9 03:08:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 779150 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp581724wrt; Fri, 8 Mar 2024 19:11:31 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX75kbD7aFVd6DQsYD9/VAguxiEQSYoMMz8rzuXss5BkfH5IoIpTmuS+Q/RI/wLdxo409Pcsny1jPr3NN0gvOpI X-Google-Smtp-Source: AGHT+IHAgflMaTxcxgUwupLvP8+LHr9gnszdnjBH5A83FBpMRK17AaJ/745J2uQOG6AzK4n3DyoQ X-Received: by 2002:ac8:5c96:0:b0:42e:fb69:1a33 with SMTP id r22-20020ac85c96000000b0042efb691a33mr1329116qta.22.1709953891448; Fri, 08 Mar 2024 19:11:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709953891; cv=none; d=google.com; s=arc-20160816; b=tXLzQXUhacoUZI+9D4tdDgYCO55E5KXqScDjO0oaCsiGcHo6oM/9t2ochlULCxVUqP POafRCiZ1LCxTgT7uNqB9JZW5ehIM847+40PI+zPFk6240B77EOsdpiRrso7MNH3rlVL 9q2rPmD5Q4TrB7DPu9Tt0tx/v2b2n7Dj+ZX8CIa7hku6uvfUbM6RN33jwxZI85JkHlXI V2N2G/4E6ZB5DkZB8zBFie6BkVDJ5pwxrDFvS+l4OxM105AhswBbQ8qh7vnJuAUmn/z3 ENhhbCGy28k9BJ7yiZzg7LQd/tyEKptGIV13Ig5oZnSD5JYZ/PsGkYiJ+Ypv1Nx1M42T SGFg== 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=rpvmnnGR33OemgaPY86jYY+4gXsKrPyYTTvPi511lbk=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=L7JNvPEDwbsdlpdzFz6uwvoxUU+joP693n2hQBfYJGouchdMUYGTGIDGEjgVsjHAhB kQNbl+xE3lCZfMFosDOrPjgodmsgbat/NNqaMQzuE6xspZPao32f/113GerXpdgmB0fI Az5QMa0YOMTPIyE5gLInBZAMghSjKZX3mbu3/0ICWcyWMsMik2H8ifoypU+ltmxXyFEt 5uMYIEiV9yK8YnJrqEO3p2xEgrO47pdR/p15Jb2kfc4LZ2DQ2GauMEScREGti7lz9vZa Pixu7seGt8YskbuuFRxqa4q85p0WBhbacPxZLpBKZecP2VVcZ67YAsxGr9kEvqLvpd/o /bTg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mzyuKvEy; 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 y21-20020a37e315000000b007882880a699si828317qki.227.2024.03.08.19.11.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2024 19:11:31 -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=mzyuKvEy; 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 1rin6l-0000vB-Rr; Fri, 08 Mar 2024 22:10:47 -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 1rin6a-0000tZ-9j for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:37 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rin6T-000473-Up for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:33 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1dcab44747bso20798625ad.1 for ; Fri, 08 Mar 2024 19:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709953828; x=1710558628; 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=rpvmnnGR33OemgaPY86jYY+4gXsKrPyYTTvPi511lbk=; b=mzyuKvEygqGID2H5RKcRe1VfLRYiYbgfGGm8coXoAIEIqsUHYDg4gIE2079baMo5fE 3VozlziBYYZYUsLpN4ErRcIe42+jkWZHc+06b8U5GkXzfcO194J0y8BRpYi8dyCgEo4E J1FbNIhLbaj/JP+bA90CB37Ma463vMsedga7F6eaPxdgENCfhkd/AuvZhZScDTA/Ljp2 AKsjNEBRlV5g8WW2R8O50U9hrl3WzwAuE7jYr3g0bSF+dNUm8KSGNAe9SqmY+ECQfeft Og5ODALvjlMbZnKrBZxkURtjDck/TaCVpwvGmig0fBtHKbhGAPREsNxf/pEE6b+UrCjl 6XVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709953828; x=1710558628; 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=rpvmnnGR33OemgaPY86jYY+4gXsKrPyYTTvPi511lbk=; b=jDhpFh6zmIggdVVhGn5y4f77RnGpZxpaxx8kyfY+CcdJY5xqBtpM1Bgv61aLTO5MV0 lFrDeMQp9xIQRoTsJfno3FBHylpdbwH0sGIChy89znc1YzgdhLOcBmrBr+gSO4EkJFk3 TsYyynUeuOdzQJZPELx/xs+BMB7qKHJCwugWvqyZN7xi4KobPpQm+Qpeb5qNLUxG7OIF YhDfk5byHNkh3DxxWMius5v/9bZajXAcYZs1vaIe9MrNvOBQUcz5ir3D1nYGWfFuXq/A Bmp/1lJ5QUp/vbDDkdrjfg+2BYzlHq/YvogdlDsud4958I7iunV6iNxwmapllNRTvihO 1Mvg== X-Gm-Message-State: AOJu0YwrbztVc8hHDWe33mnh3gnu8wcyhTVCZV65HVvnMx9osBTN5o3a iNNsiT3+XVvNrqqlR4tOeXWLOZe0gQhoVtIrIdBa5iaDyIvYQhG9gTutQgAEL/0SoPkhMEfmRZP X9d0= X-Received: by 2002:a17:902:ccc5:b0:1db:5ee2:a772 with SMTP id z5-20020a170902ccc500b001db5ee2a772mr699971ple.11.1709953827930; Fri, 08 Mar 2024 19:10:27 -0800 (PST) Received: from amd.. ([2804:7f0:b401:7e8e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id w13-20020a170902d3cd00b001dd707d5fe6sm349566plb.158.2024.03.08.19.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 19:10:27 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 2/5] linux-user: Move tswap_siginfo out of target code Date: Sat, 9 Mar 2024 03:08:58 +0000 Message-Id: <20240309030901.1726211-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309030901.1726211-1-gustavo.romero@linaro.org> References: <20240309030901.1726211-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x630.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 Move tswap_siginfo from target code to handle_pending_signal. This will allow some cleanups and having the siginfo ready to be used in gdbstub. Signed-off-by: Gustavo Romero Suggested-by: Richard Henderson Reviewed-by: Richard Henderson --- linux-user/aarch64/signal.c | 2 +- linux-user/alpha/signal.c | 2 +- linux-user/arm/signal.c | 2 +- linux-user/hexagon/signal.c | 2 +- linux-user/hppa/signal.c | 2 +- linux-user/i386/signal.c | 6 +++--- linux-user/loongarch64/signal.c | 2 +- linux-user/m68k/signal.c | 4 ++-- linux-user/microblaze/signal.c | 2 +- linux-user/mips/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/openrisc/signal.c | 2 +- linux-user/ppc/signal.c | 4 ++-- linux-user/riscv/signal.c | 2 +- linux-user/s390x/signal.c | 2 +- linux-user/sh4/signal.c | 2 +- linux-user/signal-common.h | 2 -- linux-user/signal.c | 10 ++++++++-- linux-user/sparc/signal.c | 2 +- linux-user/xtensa/signal.c | 2 +- 20 files changed, 31 insertions(+), 27 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index a1e22d526d..bc7a13800d 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -670,7 +670,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); if (info) { - tswap_siginfo(&frame->info, info); + frame->info = *info; env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->xregs[2] = frame_addr + offsetof(struct target_rt_sigframe, uc); } diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 4ec42994d4..896c2c148a 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -173,7 +173,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->info, info); + frame->info = *info; __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index f77f692c63..420fc04cfa 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -357,7 +357,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, info_addr = frame_addr + offsetof(struct rt_sigframe, info); uc_addr = frame_addr + offsetof(struct rt_sigframe, sig.uc); - tswap_siginfo(&frame->info, info); + frame->info = *info; setup_sigframe(&frame->sig.uc, set, env); diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index 60fa7e1bce..492b51f155 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -162,7 +162,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } setup_ucontext(&frame->uc, env, set); - tswap_siginfo(&frame->info, info); + frame->info = *info; /* * The on-stack signal trampoline is no longer executed; * however, the libgcc signal frame unwinding code checks diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index d08a97dae6..8960175da3 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -127,7 +127,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->info, info); + frame->info = *info; frame->uc.tuc_flags = 0; frame->uc.tuc_link = 0; diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index bc5d45302e..cfe70fc5cf 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -430,7 +430,7 @@ void setup_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->sc, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct sigframe, fpstate)); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { + for (i = 1; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->extramask[i - 1]); } @@ -490,7 +490,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(addr, &frame->puc); #endif if (ka->sa_flags & TARGET_SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info = *info; } /* Create the ucontext. */ @@ -504,7 +504,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signal.c index 39ea82c814..1a322f9697 100644 --- a/linux-user/loongarch64/signal.c +++ b/linux-user/loongarch64/signal.c @@ -376,7 +376,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, extctx.end.haddr = (void *)frame + (extctx.end.gaddr - frame_addr); } - tswap_siginfo(&frame->rs_info, info); + frame->rs_info = *info; __put_user(0, &frame->rs_uc.tuc_flags); __put_user(0, &frame->rs_uc.tuc_link); diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index 5f35354487..77555781aa 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -295,7 +295,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, uc_addr = frame_addr + offsetof(struct target_rt_sigframe, uc); __put_user(uc_addr, &frame->puc); - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create the ucontext */ @@ -307,7 +307,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (err) goto give_sigsegv; - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c index 5188d74025..f6d47d76ff 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -147,7 +147,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, return; } - tswap_siginfo(&frame->info, info); + frame->info = *info; __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 58a9d7a8a3..d69a5d73dd 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -303,7 +303,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->rs_info, info); + frame->rs_info = *info; __put_user(0, &frame->rs_uc.tuc_flags); __put_user(0, &frame->rs_uc.tuc_link); @@ -311,7 +311,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_sigcontext(env, &frame->rs_uc.tuc_mcontext); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->rs_uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 32b3dc99c6..64c345f409 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -157,7 +157,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, return; } - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index be8b68784a..cb74a9fe5e 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -103,7 +103,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info = *info; } __put_user(0, &frame->uc.tuc_flags); diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 7e7302823b..0ebfc0b26b 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -493,7 +493,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1)) goto sigsegv; - tswap_siginfo(&rt_sf->info, info); + rt_sf->info = *info; __put_user(0, &rt_sf->uc.tuc_flags); __put_user(0, &rt_sf->uc.tuc_link); @@ -502,7 +502,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(h2g (&rt_sf->uc.tuc_mcontext), &rt_sf->uc.tuc_regs); #endif - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &rt_sf->uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index 941eadce87..358fa1d82d 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -125,7 +125,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } setup_ucontext(&frame->uc, env, set); - tswap_siginfo(&frame->info, info); + frame->info = *info; env->pc = ka->_sa_handler; env->gpr[xSP] = frame_addr; diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index b40f738a70..df49c24708 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -267,7 +267,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Create siginfo on the signal stack. */ - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create ucontext on the signal stack. */ uc_flags = 0; diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index c16c2c2d57..9ecc026fae 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -233,7 +233,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 3e2dc604c2..f02d2b6b64 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -43,8 +43,6 @@ void host_to_target_sigset_internal(target_sigset_t *d, const sigset_t *s); void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s); -void tswap_siginfo(target_siginfo_t *tinfo, - const target_siginfo_t *info); void set_sigmask(const sigset_t *set); void force_sig(int sig); void force_sigsegv(int oldsig); diff --git a/linux-user/signal.c b/linux-user/signal.c index a57c45de35..7a4c8e416e 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -409,8 +409,8 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, tinfo->si_code = deposit32(si_code, 16, 16, si_type); } -void tswap_siginfo(target_siginfo_t *tinfo, - const target_siginfo_t *info) +static void tswap_siginfo(target_siginfo_t *tinfo, + const target_siginfo_t *info) { int si_type = extract32(info->si_code, 16, 16); int si_code = sextract32(info->si_code, 0, 16); @@ -1180,6 +1180,12 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, /* dequeue signal */ k->pending = 0; + /* + * Writes out siginfo values byteswapped, accordingly to the target. It also + * cleans the si_type from si_code making it correct for the target. + */ + tswap_siginfo(&k->info, &k->info); + sig = gdb_handlesig(cpu, sig, NULL); if (!sig) { sa = NULL; diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index c2dc1000e2..f164b74032 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -333,7 +333,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(0, &sf->rwin_save); /* TODO: save_rwin_state */ - tswap_siginfo(&sf->info, info); + sf->info = *info; tswap_sigset(&sf->mask, set); target_save_altstack(&sf->stack, env); diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 32dcfa5229..11e60c3c82 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -184,7 +184,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info = *info; } __put_user(0, &frame->uc.tuc_flags); From patchwork Sat Mar 9 03:08:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 779153 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp581911wrt; Fri, 8 Mar 2024 19:12:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVYV8w3Ww776M7zVnw/qaHJdXGd+bKWVHhDd7VJ9/UGi+WrfisOb/qIHnqVJltElLllLW+jfk3oVr0YfUcjud1I X-Google-Smtp-Source: AGHT+IGFI56/NYEvgQ6Zbg+Rf/hPNFN7tPCJRXLR5zkhffWXlmcjHnsKnM6QWNCqNTWNmKaRh+4R X-Received: by 2002:a05:622a:3c9:b0:42e:b457:b882 with SMTP id k9-20020a05622a03c900b0042eb457b882mr1504475qtx.37.1709953946188; Fri, 08 Mar 2024 19:12:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709953946; cv=none; d=google.com; s=arc-20160816; b=dEKy96BfBkjO7D3IjNAZF7Vq8sO2YYWR94XdItbT4OV95ir5/iiXawppEkLuKa+tQ/ rc3Zl6uggnPID5n0unS6Dj8F/VX2b1dw78e2W4eCLSLBpC/c4oEGmxmos7hCSIZG7Mpz VMSC7Ulye8c5/9+4BUUOK7YOdlkvAenvn1h7TE4oQGgq6VbmWCCdLrBUy64saGwVSU8n t8rpMcGLh9bEa7mY9VG5hRxxWG4DooqGCoIzJB81xSFgX/hFANuFaj9gN5lA6dNRmc7g jrboMdeBP2pxjWBhtumvfwnYkW4iLr0Ky/0WlKQOKssIf77gcz6xIdZ9PSSS2xb9qTHp kkgA== 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=sDSh+jXFo2Wr9YtYdh0sZ1LM65dfvglJvDrANjjOKdw=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=YvuRKTCxhdib6c20OIqGPBoLomY9f4hJwFdZi60FLSxD5WkNZofCZQrbNkIsOajjgI bXTQQJ4fU1jybC4XNiifXO7Is9/yN/L9xUGcADlYNUvD8M3nDLuWtjjcczM33oypxWvl gkaSwsz56Cw3JSpaZ+wqTS93Hv5BEb/DBdmxaxONxwxIkE1EtAH5anxVZd6N9PUwQahc sJzDQ2K0H6lW7oazZvxIBfbRIm4+knSQpauUjEBP15bgRw6W6ESHDjHrkwZcEP+lU6Dm 7hYWTlOpPfApyyVOZ+lEkz5Pb7WCGrR1Eb8TkYFS7vJwwCUyqNwSXAoBHNPDfHdN9epI rVfw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kHfzrzxc; 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 o4-20020ac85a44000000b0042ef596db7bsi913723qta.372.2024.03.08.19.12.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2024 19:12:26 -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=kHfzrzxc; 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 1rin6r-0000yC-7b; Fri, 08 Mar 2024 22:10:53 -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 1rin6b-0000to-Rp for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:39 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rin6Y-00047l-MN for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:37 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1dd0d46ecc3so19863115ad.2 for ; Fri, 08 Mar 2024 19:10:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709953830; x=1710558630; 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=sDSh+jXFo2Wr9YtYdh0sZ1LM65dfvglJvDrANjjOKdw=; b=kHfzrzxc5UlQqq7t2Gp3pKEHVdNnSeKXfGWTenUkiJ+PPoObwvXl4arEE2UZ94Sz+H DnpqH6mVWjPxZTqGObluFnlKHDpba3BNGx7/gYIzOhk2/rfh3gU6v84KC9+vW9QJudLt 39AmyB03xluGGF3wwxnOTf/ud6GcJMERiT/kjhdcQQ8fF85c90uEeXH0KFj9oMFQM1bS t5YLX4BKZwtXGiaBOcR3yRToHCazF+oB8ekeDXNLOysbHca4u3ot22eYNKgQfX2l3Ump IAz36j5Wp208fII4iiS5MV3yj74auIGCAXEyL7HIbgfOG3YZVR/mgUO5NCYhwpm7qQgV ppTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709953830; x=1710558630; 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=sDSh+jXFo2Wr9YtYdh0sZ1LM65dfvglJvDrANjjOKdw=; b=B/UM+w54Z2R9nBOz11qhGrPvODBArOC9YPu8EKL+LW9Z0AB2RVfgfcj9JO99SwQl07 feaAtTHidngELs54qWzyofNAAF+q1v6pLXENDFP7YibQNDrnBjOBeOnexZAvgZzhCGej viM3WZS4U43qPV8JajiiKfZ9sBARJT7nDARq48BbDQlHwb28/Fqwa8+sYyYFdT/X79d1 a8Ws5AP/PRog2GyHiLdKepyiwi5PTIjS6smUVxMZfXl1DDcIB/xcmO8DEEjmHjl67IMJ LhPRh2U8IB7HdNjIz5fUcnXIy4v+iKrcFVApQD3AqDltj6lYN+30lJoG7ezn+m9mgVL4 +XTA== X-Gm-Message-State: AOJu0Yx0JRSGAmds91wOiJWodRDEvGUXajpQ+1er4N1w62vrHXfsOw2t OJwtaF6LONMFoA3rETZL5AsTI/JtohzhTITXyezjiSWT+da/WhMPWi01TYKXMdAo/ED2FVuAIDP SSag= X-Received: by 2002:a17:902:dacc:b0:1dd:758f:2d33 with SMTP id q12-20020a170902dacc00b001dd758f2d33mr794780plx.4.1709953830375; Fri, 08 Mar 2024 19:10:30 -0800 (PST) Received: from amd.. ([2804:7f0:b401:7e8e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id w13-20020a170902d3cd00b001dd707d5fe6sm349566plb.158.2024.03.08.19.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 19:10:29 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 3/5] gdbstub: Save target's siginfo Date: Sat, 9 Mar 2024 03:08:59 +0000 Message-Id: <20240309030901.1726211-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309030901.1726211-1-gustavo.romero@linaro.org> References: <20240309030901.1726211-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x635.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 Save target's siginfo into gdbserver_state so it can be used later, for example, in any stub that requires the target's si_signo and si_code. This change affects only linux-user mode. Signed-off-by: Gustavo Romero Suggested-by: Richard Henderson Reviewed-by: Richard Henderson --- bsd-user/main.c | 2 +- bsd-user/signal.c | 5 ++++- gdbstub/user.c | 23 +++++++++++++++++++---- include/gdbstub/user.h | 6 +++++- linux-user/main.c | 2 +- linux-user/signal.c | 5 ++++- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 512d4ab69f..04b18eee27 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -601,7 +601,7 @@ int main(int argc, char **argv) if (gdbstub) { gdbserver_start(gdbstub); - gdb_handlesig(cpu, 0); + gdb_handlesig(cpu, 0, NULL, NULL, 0); } cpu_loop(env); /* never exits */ diff --git a/bsd-user/signal.c b/bsd-user/signal.c index f4352e4530..ad738def70 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -27,6 +27,9 @@ #include "hw/core/tcg-cpu-ops.h" #include "host-signal.h" +/* target_siginfo_t must fit in gdbstub's siginfo save area. */ +QEMU_BUILD_BUG_ON(sizeof(target_siginfo_t) > MAX_SIGINFO_LENGTH); + static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_sig, siginfo_t *info, void *puc); static void target_to_host_sigset_internal(sigset_t *d, @@ -890,7 +893,7 @@ static void handle_pending_signal(CPUArchState *env, int sig, k->pending = 0; - sig = gdb_handlesig(cpu, sig); + sig = gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; diff --git a/gdbstub/user.c b/gdbstub/user.c index a157e67f95..df040c6ffa 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -36,6 +36,8 @@ typedef struct { */ bool catch_all_syscalls; GDBSyscallsMask catch_syscalls_mask; + uint8_t siginfo[MAX_SIGINFO_LENGTH]; + unsigned long siginfo_len; } GDBUserState; static GDBUserState gdbserver_user_state; @@ -131,7 +133,8 @@ void gdb_qemu_exit(int code) exit(code); } -int gdb_handlesig(CPUState *cpu, int sig, const char *reason) +int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginfo, + int siginfo_len) { char buf[256]; int n; @@ -140,6 +143,18 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *reason) return sig; } + if (siginfo) { + /* + * Save target-specific siginfo. + * + * siginfo size, i.e. siginfo_len, is asserted at compile-time to fit in + * gdbserver_user_state.siginfo, usually in the source file calling + * gdb_handlesig. See, for instance, {linux,bsd}-user/signal.c. + */ + memcpy(gdbserver_user_state.siginfo, siginfo, siginfo_len); + gdbserver_user_state.siginfo_len = siginfo_len; + } + /* disable single step if it was enabled */ cpu_single_step(cpu, 0); tb_flush(cpu); @@ -510,7 +525,7 @@ void gdb_breakpoint_remove_all(CPUState *cs) void gdb_syscall_handling(const char *syscall_packet) { gdb_put_packet(syscall_packet); - gdb_handlesig(gdbserver_state.c_cpu, 0, NULL); + gdb_handlesig(gdbserver_state.c_cpu, 0, NULL, NULL, 0); } static bool should_catch_syscall(int num) @@ -528,7 +543,7 @@ void gdb_syscall_entry(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_entry:%x;", num); - gdb_handlesig(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason, NULL, 0); } } @@ -536,7 +551,7 @@ void gdb_syscall_return(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_return:%x;", num); - gdb_handlesig(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason, NULL, 0); } } diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 6647af2123..0ec9a7e596 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -9,11 +9,15 @@ #ifndef GDBSTUB_USER_H #define GDBSTUB_USER_H +#define MAX_SIGINFO_LENGTH 128 + /** * gdb_handlesig() - yield control to gdb * @cpu: CPU * @sig: if non-zero, the signal number which caused us to stop * @reason: stop reason for stop reply packet or NULL + * @siginfo: target-specific siginfo struct + * @siginfo_len: target-specific siginfo struct length * * This function yields control to gdb, when a user-mode-only target * needs to stop execution. If @sig is non-zero, then we will send a @@ -25,7 +29,7 @@ * or 0 if no signal should be delivered, ie the signal that caused * us to stop should be ignored. */ -int gdb_handlesig(CPUState *, int, const char *); +int gdb_handlesig(CPUState *, int, const char *, void *, int); /** * gdb_signalled() - inform remote gdb of sig exit diff --git a/linux-user/main.c b/linux-user/main.c index 049fd85a2a..3187be48d6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1014,7 +1014,7 @@ int main(int argc, char **argv, char **envp) gdbstub); exit(EXIT_FAILURE); } - gdb_handlesig(cpu, 0, NULL); + gdb_handlesig(cpu, 0, NULL, NULL, 0); } #ifdef CONFIG_SEMIHOSTING diff --git a/linux-user/signal.c b/linux-user/signal.c index 7a4c8e416e..98d1eacffe 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -34,6 +34,9 @@ #include "user/safe-syscall.h" #include "tcg/tcg.h" +/* target_siginfo_t must fit in gdbstub's siginfo save area. */ +QEMU_BUILD_BUG_ON(sizeof(target_siginfo_t) > MAX_SIGINFO_LENGTH); + static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_signum, siginfo_t *info, @@ -1186,7 +1189,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, */ tswap_siginfo(&k->info, &k->info); - sig = gdb_handlesig(cpu, sig, NULL); + sig = gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; From patchwork Sat Mar 9 03:09:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 779152 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp581873wrt; Fri, 8 Mar 2024 19:12:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUZU1oZQ3Cy9w860oMRkZqtXxUVRoqr8Sq0JZcHA0KUq7JiPFGUG4b63twfhgviOPu56YgEihxCD75+wHLdkCYY X-Google-Smtp-Source: AGHT+IHo+PluYZzsAF3mkjufTmklD0fK2hTVbJlYbHwY8ojoWh4M8h8lytf4DoHzZ2Zth4YnnP3w X-Received: by 2002:a05:6214:5008:b0:690:aba2:d1fd with SMTP id jo8-20020a056214500800b00690aba2d1fdmr1366242qvb.15.1709953934192; Fri, 08 Mar 2024 19:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709953934; cv=none; d=google.com; s=arc-20160816; b=T2eMnL0LsjyuVTX+Va+mCBzoAqsDM4fvqy/648THKmNnC1DIrr9/vR20iDcoEigUmM 3SukYUP1320rQUOTfsnFNp2n0NIn1KE6U742X3abN6WiUUQUb+V6BAOTtFuUF/DKbNIj X0ShmQoTTVl3wolb/VyeHBdf+j2CjwHsOlf1yW3cesrOC7mdSumCQ9iwch0DQ1LEdG9X NBN0tVEzsUfGc9q0iIdZOt83NtkRhaEI9Ou1v1AABXdVMQ6bXB/R+GcSA1Vvv8+EpqDP XdgyNcR8ol565W4fFnw5mY6tZjt/K8LjHmVzhMhaDxGVcAsZRGdz8PKqKuFTxaiUIja+ hgAQ== 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=cJ2k7mY3US4N+1K4KGAFenl+VPGVVipLS3o/9vKMmQg=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=F1hteJDsgnu0UuoFGMJmsbZfKwvCh0TnN+zTGLYfHRKaqT53mwhP4H2sV7YUvJjfNp Xm6kr25hki8dsSsiRYp4MPAcISTLWEr+Y3b3+jizFuE9O4Q6hFfroN8vYiShXhOUZjjd zhiZ6GIrm06tTrZlKT566Q6WTqUa581q7wwu4Y8SfktwnVxKEYjoB7dj/ZkvIe3koKug yeZQ1A8Oqy8ljyp32/dsXDaHjiW8BT2lNoaJ3FIrhM3S3jqfXdhTdVWEd6kJMAXFfwub cMuEirHPcSSKytIa5/7id1AeTgI1cTLo5YKpIK30u3rtkDahq9dxC17JlrdJcW+v0a44 wvPg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PD1l+Lvq; 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 kr12-20020a0562142b8c00b00690bfb207fesi611278qvb.279.2024.03.08.19.12.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2024 19:12:14 -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=PD1l+Lvq; 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 1rin6n-0000xc-O1; Fri, 08 Mar 2024 22:10:49 -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 1rin6b-0000tr-SF for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:39 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rin6a-00049D-19 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:37 -0500 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-29acdf99d5aso1885546a91.2 for ; Fri, 08 Mar 2024 19:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709953833; x=1710558633; 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=cJ2k7mY3US4N+1K4KGAFenl+VPGVVipLS3o/9vKMmQg=; b=PD1l+LvqdDS3GAC+Kw6RzqxYJ9EK+wF5A4drr8Oj0KDOGDtIA/lerfjzez0bAs56p5 Frk75iynltR0qz1n/uxtpHYT1sPPJGxo4f4TIKqde+GQPRNn322Pvf1MKWVG6hhuEtOp I1+5qh+pacjyCY5+yBGy8MLQx/0GzbnMQOlS3LPfOY5C1GbANhx5gSP5IDUCLti2VrV9 4h0UvkFxmE6EDIDGPySjN/7gZCDMbebDBQfkPgVWm2CghG583FW+EAXGqCoHHsMiw/zb u/EE3Q7doZsx0o7JDscffs/yi9Tq9II1jxFGZK07teAdc38SToxhIPHZEN+uOly7UV7J jTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709953833; x=1710558633; 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=cJ2k7mY3US4N+1K4KGAFenl+VPGVVipLS3o/9vKMmQg=; b=isIdKYL5f2HKSwOQRcttHKEozIChFhsbKbWItREdInzGgM9EiEhBWXZyHPkJO1UU3C nmdy6K1zW2MmrzbQs1dabhDsoHA7CfiPltfV3hcNe5CNZYAYL/UlrZOD23iXzjo2Lnbi qjpdKpsHv2ETrWRfGUQMCxjIDsDsq9SBaAmbqaak1hNrSZbQ5Htoupib7rVeXaAyTC8M 9QiyxDOmaZ/hCRLrgKDOIK7IO+FFZd212cS6crRrdZy7YtVs/CcpIxcyY/tDzlYLjVYZ +szwrKbLFt3STlauMpq945ErbxgmWLpRjKnwJB6xevlIYmCRDfcSd0v/DP8CB6SJNDHQ U9vw== X-Gm-Message-State: AOJu0YxmcDnPHODLfvHLIRZlE1WMMQW/9OKojgh1KdMWn6JPjiKGbYvr B9CJDimR6qFgt0H/CUFc+l2pwOkBi5/d1v7j4mGbXbsRajMnKOx9geh97zc8iSimfh6EW+SnlQG wY4U= X-Received: by 2002:a17:903:1103:b0:1dc:f91b:5e96 with SMTP id n3-20020a170903110300b001dcf91b5e96mr570599plh.59.1709953832868; Fri, 08 Mar 2024 19:10:32 -0800 (PST) Received: from amd.. ([2804:7f0:b401:7e8e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id w13-20020a170902d3cd00b001dd707d5fe6sm349566plb.158.2024.03.08.19.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 19:10:32 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 4/5] gdbstub: Add Xfer:siginfo:read stub Date: Sat, 9 Mar 2024 03:09:00 +0000 Message-Id: <20240309030901.1726211-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309030901.1726211-1-gustavo.romero@linaro.org> References: <20240309030901.1726211-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=gustavo.romero@linaro.org; helo=mail-pj1-x102b.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 Add stub to handle Xfer:siginfo:read packet query that requests the machine's siginfo data. This is used when GDB user executes 'print $_siginfo' and when the machine stops due to a signal, for instance, on SIGSEGV. The information in siginfo allows GDB to determiner further details on the signal, like the fault address/insn when the SIGSEGV is caught. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson --- gdbstub/gdbstub.c | 8 ++++++++ gdbstub/internals.h | 1 + gdbstub/user.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2909bc8c69..ab38cea46b 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1651,6 +1651,8 @@ static void handle_query_supported(GArray *params, void *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+"); } g_string_append(gdbserver_state.str_buf, ";QCatchSyscalls+"); + + g_string_append(gdbserver_state.str_buf, ";qXfer:siginfo:read+"); #endif g_string_append(gdbserver_state.str_buf, ";qXfer:exec-file:read+"); #endif @@ -1799,6 +1801,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { .cmd_startswith = 1, .schema = "l,l0" }, + { + .handler = gdb_handle_query_xfer_siginfo, + .cmd = "Xfer:siginfo:read::", + .cmd_startswith = 1, + .schema = "l,l0" + }, #endif { .handler = gdb_handle_query_xfer_exec_file, diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 56b7c13b75..fcfe7c2d26 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -190,6 +190,7 @@ typedef union GdbCmdVariant { void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ +void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx); /*user */ void gdb_handle_v_file_open(GArray *params, void *user_ctx); /* user */ void gdb_handle_v_file_close(GArray *params, void *user_ctx); /* user */ void gdb_handle_v_file_pread(GArray *params, void *user_ctx); /* user */ diff --git a/gdbstub/user.c b/gdbstub/user.c index df040c6ffa..5e175b5d62 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -616,3 +616,26 @@ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx) err: gdb_put_packet("E00"); } + +void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx) +{ + unsigned long offset, len; + uint8_t *siginfo_offset; + + offset = get_param(params, 0)->val_ul; + len = get_param(params, 1)->val_ul; + + if (offset + len > gdbserver_user_state.siginfo_len) { + /* Invalid offset and/or requested length. */ + gdb_put_packet("E01"); + return; + } + + siginfo_offset = (uint8_t *)gdbserver_user_state.siginfo + offset; + + /* Reply */ + g_string_assign(gdbserver_state.str_buf, "l"); + gdb_memtox(gdbserver_state.str_buf, (const char *)siginfo_offset, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} From patchwork Sat Mar 9 03:09:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 779151 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp581727wrt; Fri, 8 Mar 2024 19:11:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVql/N3/AZfRxBef2QlxfoL217Lh0HsIx3DpiSKKWjDVxscS4pQTBTFJI6wdlbzaeVK3TmaEZmCx4pYTvd1apIZ X-Google-Smtp-Source: AGHT+IHZpOdIKpqdPKI/hT+EVEF9FxvrAaX6Uwb2DE/UPutxtvIxzgMb50ECGbv4zLLHFa6BYZFq X-Received: by 2002:ac8:5d10:0:b0:42e:b8e8:dcd9 with SMTP id f16-20020ac85d10000000b0042eb8e8dcd9mr1409709qtx.15.1709953892653; Fri, 08 Mar 2024 19:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709953892; cv=none; d=google.com; s=arc-20160816; b=AoOH5MdIusbQFPPaEekc2clmpGafOqYO+e4nYNpHnyzdp5+uOEL1ima8oQvkLdjFk3 w0OYBOdXk3VTcFlfDyMSDxZkjJwmgTefcB2rPVOSQYbYfp/l5SW12L82Ob++MMhamt62 +uAh3oazjNNRs0WNF7U/7ASlq7P+QFnSpf9qmacnplPhZ/YflL98VrJXq8KCCXEGIbeS lfnUBrY0rJiNI4haKC5NV1/oH6ZEp2ZHzw8GMqcDLBCtkS+hBSFEQsFsuNJVFsc84eee XGXNJRdB5e/onBLFn5mz93m6SzKBXwvjvM2VsArhg9yKG6jeMCE0Jhre5JMg3MmniCMr d6xA== 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=QNibj7GeqOVAWR9r/zV93h8cU6ZpKh+4GZhI7/K8upo=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=rS8zdBHPuwlW6q02qQlH6Ic8pHHgJD7Gm3WTA49FJaDUQHLQo9NgtGnDUK/yh/+F2T kDbNoPwX+PhVmLOK9BHgDc94mpKh4wogxHurRso21IjwDV7REnI7sb0wOAjDBNMizi5b ze6IhZkQ0QqAjBb4N/n5BSOlKctwnetGj6utAU2+4NEvDiiaCj8PvfoYK5q5au//rFSG lU4dG+/6ARyDX1gsTzYeDTPWkmUXfiDK2PDxh7dMkBvxaEL7cr8aV8+N5iX/6vFhzmtv Sm7b+eLdacHudfArFv/WgzMl3dhFbnuoPkOxp+imtKlEU0OiSyvW5xhuB+ODzNpfGNCx o+WQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tfqGqg+a; 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 z6-20020a05622a028600b0042f210f4b4fsi926340qtw.157.2024.03.08.19.11.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2024 19:11:32 -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=tfqGqg+a; 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 1rin6t-0000yR-UQ; Fri, 08 Mar 2024 22:10:56 -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 1rin6d-0000u6-6w for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:40 -0500 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rin6b-0004AS-JL for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:38 -0500 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3c2313de2ceso610697b6e.1 for ; Fri, 08 Mar 2024 19:10:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709953835; x=1710558635; 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=QNibj7GeqOVAWR9r/zV93h8cU6ZpKh+4GZhI7/K8upo=; b=tfqGqg+aOdEetvBGqy25S33KHmS9Nk2ZxA6cJO06boPn7mMM7qHpfd7lEgpwvR0nwO K146YB1owlalZBNHFsBvxdyJ4KGzti6u45F7ejxNIED6NvSYfaPtiaTyl98DbaNc7KGi qEuNZ+7Q2OmBU9/5ThtK1b45jyD3hsst6Jcfmi8VzeMVmUAq1UcIkKgSWEFneCCfjPGB I3IysZpgq9O30e9RkuTVdB54eCYs6Z7dQRl6+R1iqmmUPoRr2RfCncnSPRJuGWa7Um5h aSqwYw+YbF/WuZcqXQOx7tiiDBRdxzEKT3pH030aTpCJs3ODyGdyvadjZs4UC9mstA5c kkVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709953835; x=1710558635; 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=QNibj7GeqOVAWR9r/zV93h8cU6ZpKh+4GZhI7/K8upo=; b=PJdUo1EB0JBU6tXESpUB7alb1sUv1/9/CSimB+bqPOYbfMVjL6/PWmKQPYsxHjeYjp LnP2Em0oMoMrFQUJgBklSovBbd79Dm77+KQquwZYVlTTSPefvveK4bQJbrvxfc4Gh0rP SUwUSoUCRyqOhOeP3sBSqB6GkbzPk9XCydHvCemvjeZ+FSCOZ39an2ThhKJLnyeDIZKu S1ZCwCmBpf1TpCFAbWHHFUt3wJW+YxjJ4Cd/xPEJbVvJfMjgyNyV1b+ZQufzFh3YkCHM lOBtD9kMZP3s+eriwq2pvtOUtkTLg/n31pTIbNIIgwK957vpHl42Wtr4NDmO+YDgPcD9 /uPQ== X-Gm-Message-State: AOJu0Yxg+noAkLzFalzOoGtK5FABh4UOGmH6jx1wR+9vo08yqO8g6mfL mX2J6hrsTMGGziutGNrOkp3RnzuVbJoJjRlL9fPa4owfc3p1PaVB0xareah00hlsgqKcu/uBWQ8 /T/E= X-Received: by 2002:a05:6808:118c:b0:3c2:1868:d9cf with SMTP id j12-20020a056808118c00b003c21868d9cfmr1151769oil.16.1709953835423; Fri, 08 Mar 2024 19:10:35 -0800 (PST) Received: from amd.. ([2804:7f0:b401:7e8e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id w13-20020a170902d3cd00b001dd707d5fe6sm349566plb.158.2024.03.08.19.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 19:10:34 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 5/5] tests/tcg: Add multiarch test for Xfer:siginfo:read stub Date: Sat, 9 Mar 2024 03:09:01 +0000 Message-Id: <20240309030901.1726211-6-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309030901.1726211-1-gustavo.romero@linaro.org> References: <20240309030901.1726211-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=gustavo.romero@linaro.org; helo=mail-oi1-x22e.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 Add multiarch test for testing if Xfer:siginfo:read query is properly handled by gdbstub. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson --- tests/tcg/multiarch/Makefile.target | 10 ++++++- .../gdbstub/test-qxfer-siginfo-read.py | 26 +++++++++++++++++++ tests/tcg/multiarch/segfault.c | 14 ++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py create mode 100644 tests/tcg/multiarch/segfault.c diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index f11f3b084d..5ab4ba89b2 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -71,6 +71,13 @@ run-gdbstub-qxfer-auxv-read: sha1 --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ basic gdbstub qXfer:auxv:read support) +run-gdbstub-qxfer-siginfo-read: segfault + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin "$< -s" --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \ + basic gdbstub qXfer:siginfo:read support) + run-gdbstub-proc-mappings: sha1 $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(GDB) \ @@ -113,7 +120,8 @@ endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ run-gdbstub-registers run-gdbstub-prot-none \ - run-gdbstub-catch-syscalls + run-gdbstub-catch-syscalls \ + run-gdbstub-qxfer-siginfo-read # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py new file mode 100644 index 0000000000..862596b07a --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py @@ -0,0 +1,26 @@ +from __future__ import print_function +# +# Test gdbstub Xfer:siginfo:read stub. +# +# The test runs a binary that causes a SIGSEGV and then looks for additional +# info about the signal through printing GDB's '$_siginfo' special variable, +# which sends a Xfer:siginfo:read query to the gdbstub. +# +# The binary causes a SIGSEGV at dereferencing a pointer with value 0xdeadbeef, +# so the test looks for and checks if this address is correctly reported by the +# gdbstub. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +from test_gdbstub import main, report + +def run_test(): + "Run through the test" + + gdb.execute("continue", False, True) + resp = gdb.execute("print/x $_siginfo", False, True) + report(resp.find("si_addr = 0xdeadbeef"), "Found fault address.") + +main(run_test) diff --git a/tests/tcg/multiarch/segfault.c b/tests/tcg/multiarch/segfault.c new file mode 100644 index 0000000000..e6c8ff31ca --- /dev/null +++ b/tests/tcg/multiarch/segfault.c @@ -0,0 +1,14 @@ +#include +#include + +/* Cause a segfault for testing purposes. */ + +int main(int argc, char *argv[]) +{ + int *ptr = (void *)0xdeadbeef; + + if (argc == 2 && strcmp(argv[1], "-s") == 0) { + /* Cause segfault. */ + printf("%d\n", *ptr); + } +}