From nobody Thu May 9 20:15:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709953887; cv=none; d=zohomail.com; s=zohoarc; b=afi59MJlxXivAiD0bMkxFzQJhrWJnT5Md7+RpmPu3VO99OMBFP90OVZm9CpIPSxC9Hf4m6efpq6tsG/UXemD2uo/2YAOaPDhnD4PwTCsz7/PECs2XrH6bVVWznBb+W63orDB74oPeBOs1yKUo0bLNaJ3vAw6efVO+h9HuVWmceM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709953887; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8tpJAfxQcRF8joD00NGmo1iAef1vo78TLl0CoONZU1s=; b=S86WA0QBH1Sq8KYlvNJ6/Bi+KXXRZNVoAS038Ep75Rnr6u+09syKiJqCBU9ibciqfdEk3X48EQftfYm0Kai9odVdvQ7NCvh5qz+u4EEw3jyXiHAkGqMIzLtgoxRaaV54LPyTVdTrqrMCyvysPlf+ghT952cvqSkHDigOd5m32pU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17099538874481010.6612203873351; Fri, 8 Mar 2024 19:11:27 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEAFXsghp1vEOf+FwX6nOK9Lbe8K8cHjH0cW/3eD8l9d4I36KOtpLHplye1KfiGRdxBpYpF/g== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709953889413100001 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=C3=A9e 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); } =20 -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); } =20 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 =3D g_strdup_printf("syscall_entry:%x;", n= um); - gdb_handlesig_reason(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason); } } =20 @@ -536,7 +536,7 @@ void gdb_syscall_return(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason =3D g_strdup_printf("syscall_return:%x;", = num); - gdb_handlesig_reason(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason); } } =20 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 =20 /** - * 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 *); =20 /** * 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); } =20 #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_e= nv, int sig, /* dequeue signal */ k->pending =3D 0; =20 - sig =3D gdb_handlesig(cpu, sig); + sig =3D gdb_handlesig(cpu, sig, NULL); if (!sig) { sa =3D NULL; handler =3D TARGET_SIG_IGN; --=20 2.34.1 From nobody Thu May 9 20:15:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709953891; cv=none; d=zohomail.com; s=zohoarc; b=HUlVrntQa4nvLSJ0eiisa5EJk4u9aeulsT26KF2bDBJpG1THgCr64IN7+bgkuhLYVvTdvgfRDuNY8BrRZzImzEkuSxFu7xTSLpkrz8d7GdPNrXjaXhTEZ6b/E1gT/q2G+AirVdTJgKJI+5bkRqUwtdsnvS4aVeMasju72XJDD8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709953891; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rpvmnnGR33OemgaPY86jYY+4gXsKrPyYTTvPi511lbk=; b=fRSfYExkVPoE+dHzm4TyaKql8AYtS2rllTG18UxpPOyDFHSBRMzWE5doixLsW5jpYeBAbOoP/Gkad6RBuXWDN6qSZOlR6aB7+UgTBDSLg4DhWb0xgZwbxmxX+AC81D0YCg2L/s3310RBBNlUXa/pd3p5QTDeV15r1mN4Rjbn5Uw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709953891852926.4277610257953; Fri, 8 Mar 2024 19:11:31 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEf3qDQVJtR9bRzbe5HRI/trbZjR+c5JM05xtHbhvboXtUde0KOBhBPH3IvX7Nf320AgexnUQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709953893221100001 Content-Type: text/plain; charset="utf-8" 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); =20 if (info) { - tswap_siginfo(&frame->info, info); + frame->info =3D *info; env->xregs[1] =3D frame_addr + offsetof(struct target_rt_sigframe,= info); env->xregs[2] =3D 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 *k= a, goto give_sigsegv; } =20 - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 __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, =20 info_addr =3D frame_addr + offsetof(struct rt_sigframe, info); uc_addr =3D frame_addr + offsetof(struct rt_sigframe, sig.uc); - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 setup_sigframe(&frame->sig.uc, set, env); =20 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 *k= a, } =20 setup_ucontext(&frame->uc, env, set); - tswap_siginfo(&frame->info, info); + frame->info =3D *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 *k= a, goto give_sigsegv; } =20 - tswap_siginfo(&frame->info, info); + frame->info =3D *info; frame->uc.tuc_flags =3D 0; frame->uc.tuc_link =3D 0; =20 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)); =20 - for(i =3D 1; i < TARGET_NSIG_WORDS; i++) { + for (i =3D 1; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->extramask[i - 1]); } =20 @@ -490,7 +490,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, __put_user(addr, &frame->puc); #endif if (ka->sa_flags & TARGET_SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info =3D *info; } =20 /* Create the ucontext. */ @@ -504,7 +504,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate= )); =20 - for(i =3D 0; i < TARGET_NSIG_WORDS; i++) { + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } =20 diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signa= l.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 *k= a, extctx.end.haddr =3D (void *)frame + (extctx.end.gaddr - frame_add= r); } =20 - tswap_siginfo(&frame->rs_info, info); + frame->rs_info =3D *info; =20 __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 *k= a, uc_addr =3D frame_addr + offsetof(struct target_rt_sigframe, uc); __put_user(uc_addr, &frame->puc); =20 - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 /* Create the ucontext */ =20 @@ -307,7 +307,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, if (err) goto give_sigsegv; =20 - for(i =3D 0; i < TARGET_NSIG_WORDS; i++) { + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } =20 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 *k= a, return; } =20 - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 __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 *k= a, goto give_sigsegv; } =20 - tswap_siginfo(&frame->rs_info, info); + frame->rs_info =3D *info; =20 __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 *k= a, =20 setup_sigcontext(env, &frame->rs_uc.tuc_mcontext); =20 - for(i =3D 0; i < TARGET_NSIG_WORDS; i++) { + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->rs_uc.tuc_sigmask.sig[i]); } =20 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 *k= a, return; } =20 - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 /* 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 *k= a, } =20 if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info =3D *info; } =20 __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 *k= a, if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1)) goto sigsegv; =20 - tswap_siginfo(&rt_sf->info, info); + rt_sf->info =3D *info; =20 __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 *k= a, __put_user(h2g (&rt_sf->uc.tuc_mcontext), &rt_sf->uc.tuc_regs); #endif - for(i =3D 0; i < TARGET_NSIG_WORDS; i++) { + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &rt_sf->uc.tuc_sigmask.sig[i]); } =20 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 *k= a, } =20 setup_ucontext(&frame->uc, env, set); - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 env->pc =3D ka->_sa_handler; env->gpr[xSP] =3D 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 *k= a, } =20 /* Create siginfo on the signal stack. */ - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 /* Create ucontext on the signal stack. */ uc_flags =3D 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 *k= a, goto give_sigsegv; } =20 - tswap_siginfo(&frame->info, info); + frame->info =3D *info; =20 /* 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 =3D deposit32(si_code, 16, 16, si_type); } =20 -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 =3D extract32(info->si_code, 16, 16); int si_code =3D sextract32(info->si_code, 0, 16); @@ -1180,6 +1180,12 @@ static void handle_pending_signal(CPUArchState *cpu_= env, int sig, /* dequeue signal */ k->pending =3D 0; =20 + /* + * Writes out siginfo values byteswapped, accordingly to the target. I= t also + * cleans the si_type from si_code making it correct for the target. + */ + tswap_siginfo(&k->info, &k->info); + sig =3D gdb_handlesig(cpu, sig, NULL); if (!sig) { sa =3D 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 *k= a, =20 __put_user(0, &sf->rwin_save); /* TODO: save_rwin_state */ =20 - tswap_siginfo(&sf->info, info); + sf->info =3D *info; tswap_sigset(&sf->mask, set); target_save_altstack(&sf->stack, env); =20 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 *k= a, } =20 if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info =3D *info; } =20 __put_user(0, &frame->uc.tuc_flags); --=20 2.34.1 From nobody Thu May 9 20:15:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709953946; cv=none; d=zohomail.com; s=zohoarc; b=UiAGOUwb51jxAONbGaJUSUtOPpdR1NL3LZnpONhSHNjzcjqtrMiXele0ylTtkHQPhWQ/6ny0EhhgkL9pfDbAeFz4gX2tWlQRhaiDAW0h9jojdnFSrtgiZiyhmq+kBrCgwXI5AWwiuM8Cb8KLw71X7NGgGomqdjkFeumeyUtvReA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709953946; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sDSh+jXFo2Wr9YtYdh0sZ1LM65dfvglJvDrANjjOKdw=; b=NlJPKpn+pt5wstbcbZx8aaj30qY4UAjGZyr14TiAULRe83GtsefUkwLBgDaxT0S2FZrOY8LbO2L/siiIjz7QZxZ3XyFpL41ZxCW1IuN3Zt/AkvTUv2zwF2qYB4hOfFBTSVGX0EPMpuoDl+qx7/1KI7HFWO5zKndm7MMPIlh58K8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170995394657542.70446061361281; Fri, 8 Mar 2024 19:12:26 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGXnqbW/hVpTPNCoNmyG+0SV0TPfayWQYMcQmUj8bGc6hKGjURkBASSX3eFY4O7o596EzwUGg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709953947387100001 Content-Type: text/plain; charset="utf-8" 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) =20 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" =20 +/* 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, in= t sig, =20 k->pending =3D 0; =20 - sig =3D gdb_handlesig(cpu, sig); + sig =3D gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); if (!sig) { sa =3D NULL; handler =3D 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; =20 static GDBUserState gdbserver_user_state; @@ -131,7 +133,8 @@ void gdb_qemu_exit(int code) exit(code); } =20 -int gdb_handlesig(CPUState *cpu, int sig, const char *reason) +int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginf= o, + int siginfo_len) { char buf[256]; int n; @@ -140,6 +143,18 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *= reason) return sig; } =20 + 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 =3D 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); } =20 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 =3D g_strdup_printf("syscall_entry:%x;", n= um); - gdb_handlesig(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason, NULL, 0); } } =20 @@ -536,7 +551,7 @@ void gdb_syscall_return(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason =3D g_strdup_printf("syscall_return:%x;", = num); - gdb_handlesig(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason, NULL, 0); } } =20 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 =20 +#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); =20 /** * 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); } =20 #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" =20 +/* 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]; =20 static void host_signal_handler(int host_signum, siginfo_t *info, @@ -1186,7 +1189,7 @@ static void handle_pending_signal(CPUArchState *cpu_e= nv, int sig, */ tswap_siginfo(&k->info, &k->info); =20 - sig =3D gdb_handlesig(cpu, sig, NULL); + sig =3D gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); if (!sig) { sa =3D NULL; handler =3D TARGET_SIG_IGN; --=20 2.34.1 From nobody Thu May 9 20:15:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709953934; cv=none; d=zohomail.com; s=zohoarc; b=KpzIGHTrWUCYZSFx6CGRhiChiYBcQvLWalHDhZRX1d6cRFkEAZ+jEsIGCcmskxDj5fsp6GNO7zsUq8RfXTza8GezzujNDXJKbmuS7Fm75amdJduu9VC07Zw7lYPZ17WHRpBjM7gqurmvp7fqbChkpXU8nOuz5zys9hp7j1fpWNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709953934; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cJ2k7mY3US4N+1K4KGAFenl+VPGVVipLS3o/9vKMmQg=; b=BwAMW/nJJf7i0gT7igB/XUGpYw+cVnpZq5k+iabQgP8gWONswgfy0k2T+XyGhhBItkVjtFZVA525rD1BzS8twcxj8NGFNFqENFKhq23jhbstWOXr05e2jvaWXwpi1078J9IbyqR8eq7k2JPrC9Cm7iBv2HxvvZug1wj9Z5tIwgQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709953934529165.46736380798916; Fri, 8 Mar 2024 19:12:14 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IG75RuJTzTotx3d5QE9H4+l4xE3JCI1kwO98e8sfnkSF5PDYie08RpRCWl6UprtNQhhYs9PsA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709953935324100001 Content-Type: text/plain; charset="utf-8" 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, vo= id *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[] = =3D { .cmd_startswith =3D 1, .schema =3D "l,l0" }, + { + .handler =3D gdb_handle_query_xfer_siginfo, + .cmd =3D "Xfer:siginfo:read::", + .cmd_startswith =3D 1, + .schema =3D "l,l0" + }, #endif { .handler =3D 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, voi= d *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 =3D get_param(params, 0)->val_ul; + len =3D 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 =3D (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); +} --=20 2.34.1 From nobody Thu May 9 20:15:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709953893; cv=none; d=zohomail.com; s=zohoarc; b=CkBStY8pClHuL/lw1jm3gSTcz/LAKxqgvjGN4SWJsuHq4+Ne5/hzjcrIZ4OnrVfCoeLV2xHPYHUlqjEldhtiwMPba0INOwmrsSStX1s95n26gTdDWo7ixX+MC528OszKbTaLwJAlK7i17ya91WMW1UiFDm99oFX9CXrFBIb9lYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709953893; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QNibj7GeqOVAWR9r/zV93h8cU6ZpKh+4GZhI7/K8upo=; b=DY9+uNMmOcaZ9g5q2Db5tpSbUDEFb9wy0jN2Pc2vGfP20lHzx/94qI8OOj/t8fP7sIuhJ3pn2kBn14gvnFIUKYldR5l7dDAJqL6HepUnndm4mUILdfG5PLDwyxW8Cum5OG0XqubVU3+qGfw+mrzmbJtbMz0j7Y80LuJE7jSKctE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709953893059946.0855130719063; Fri, 8 Mar 2024 19:11:33 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHRimvnBR/wyLhtkIwunOHerYCdZFbwV0cdRgFkXoxLAW6UMCHSGys0bLB6OAcxMog6IwCzsQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709953895326100007 Content-Type: text/plain; charset="utf-8" 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/Make= file.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) =20 +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 +=3D 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 =20 # 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 addition= al +# info about the signal through printing GDB's '$_siginfo' special variabl= e, +# which sends a Xfer:siginfo:read query to the gdbstub. +# +# The binary causes a SIGSEGV at dereferencing a pointer with value 0xdead= beef, +# so the test looks for and checks if this address is correctly reported b= y 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 =3D gdb.execute("print/x $_siginfo", False, True) + report(resp.find("si_addr =3D 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 =3D (void *)0xdeadbeef; + + if (argc =3D=3D 2 && strcmp(argv[1], "-s") =3D=3D 0) { + /* Cause segfault. */ + printf("%d\n", *ptr); + } +} --=20 2.34.1