From patchwork Sat Mar 9 03:08:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 779148 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp581705wrt; Fri, 8 Mar 2024 19:11:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUtpx+us084P52y9+PO0xawl1RcIkdQzDEBPuxYVSI0XcY/oJrjiuttRTMoO6sj0CfamJh8K2LUYyVePHrPWocg X-Google-Smtp-Source: AGHT+IGB38C6JOe88mB2rD/TM2smWADi8M/Y9HytTrPoICzZ7nuyNI9YtIbRIBN69mJ5Ps4pB+BN X-Received: by 2002:ae9:e713:0:b0:788:2f70:a1a1 with SMTP id m19-20020ae9e713000000b007882f70a1a1mr1056975qka.15.1709953886714; 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=ee/o0Ynclu+KJjWzkr0ypAlffGMi158SRoIu5XDp0nTCX4YPuFUA6OFlRfgz8G7IS2 E5jJrYwjrzY/UW1Jax+alvZopjjGps85dowm2ncKCBj/mWmheo2bzqHRASgxQST6amjx 6nrI72m5qFQtBjpyxrlmqLwNBzybOxPiidAurAcDdViscepBmXVKpktt2/Atmd4PB9VZ Ct6L27yEBGxfUpss3snVabbXuE3BUW6iidVryUvSFgt7ugnnPO4NHt3UdYcOIBnBDQuv QbOy22YAKQZc8k4VhVyj5FZo7AXUdJLL1rOS57Mm3/trXXPM2sV3RQFHMCryBpz6PVgs 4KMQ== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=SakRcwnp8Yh1EyT2Wa8Byn2WbR8UlACvso8EHydivPE=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=nW/mRa519CpL2+1JPuu4RAyltH21ewLm4Cs8Jgjdsi7BcfE1T9XYD4nF+/d9LqyuoF NEEhjotVjSNu/oaT3H8mBKxaI8iMJOvyBtd/m6Wl0PUjeh/sjTw3kdObNnlpbk0TPwoW r8gCbXS8VSbuO/6SgRsuJlGmCB40/cBy0aNW0dv60xDjIoe5n1+DJGWnSey4uoFkdc7X oyRU9JfUps+XFZ3jKRGnXLpiJCctk8jrh8+Z4BhuqSfA9OnuUy7QLwAb+ebvg0n1neeu 33WcQl4RztiX/qiJ8x3ODYDsr/fu0WLcdamqScZGKC5cXW6BbEqXg7dsxcBtGJqOsNSp R/lA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DEeRhSxU; 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 xy3-20020a05620a5dc300b0078847a8eeb0si820133qkn.300.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=DEeRhSxU; 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 1rin6j-0000vA-Uo; Fri, 08 Mar 2024 22:10:45 -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 1rin6W-0000tM-ME for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:35 -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 1rin6P-00045l-QG for qemu-devel@nongnu.org; Fri, 08 Mar 2024 22:10:31 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dd10ae77d8so22904155ad.0 for ; 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=1709953823; x=1710558623; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SakRcwnp8Yh1EyT2Wa8Byn2WbR8UlACvso8EHydivPE=; b=DEeRhSxUHyFQfWXl9Ojid6TbdRVAtTHFVmbuz60aU8wN0ytfV/uFP+7SUV66u6RIt8 VtDR4+ALSn2haQVVffpSBoAeK1jlMPOP/sKb2EnFiXrYnBLbC0Mc77FNrNkFgyDffqy9 y7wpbY+MA2WlBFQ0y0JDtiiE+xsDS3NDFPRTxp+0qtF7WNIBfhkLyDzg3ntu5y0CzAcn Rf1Ax65UT2h6vBQ89xK0fkIYhxDbEGLC9g7tPubBFAZ19H4pDb82PGWB6I0PgdbZ4hsu io8vlkYXQEU1eLVw3MRbH8Zuhjnq0IDDZ4C8eJOw6LLEJexUFN5pIpvM197Z+nNrLkif FPJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709953823; x=1710558623; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SakRcwnp8Yh1EyT2Wa8Byn2WbR8UlACvso8EHydivPE=; b=NvkUZAUMqp9xpScGdHsdyqgl7CrQ6Fs5telavc/PvYAOw3csVO7QM++2wjPNnzCIQq v+zIGvjHFnEQN35SdT7QYQVsNV+v9nTQjoX7cZRs9ioGJumg7ozUoZs9H6kqWT6w8hzX X0ZZyF/0UQYbrRab8gAMP6xOaAU4AAWRt2DeqEyV+INL7oCqHBRrtIVAEz37a5vod8T7 u4vXXW9JAqr2Z9kE7Q+w11qjaartfusCtqlBGIELUdR5AcIvN+NnqjN3oRh9G6FgfGj7 SxiBeXf3IdQ58n1RbXU8LGgIrtHkj+NshCLH+r774+Ap5tmVrBCXCQDvZfF2KK5Eiuao dQ8Q== X-Gm-Message-State: AOJu0Yx1VcEMtbm9Q6ZQOk+UVGdmEB6pQ2NRYVGsUJISE+S91SSDYjkZ L2I4BgzLWG4977EOpW04/9xVhq5lvOeMkQMKbxuEw7FmGlvu/y8EjajNeQZ8o3Mgi1yNR6gKjK1 XCIs= X-Received: by 2002:a17:902:e884:b0:1dd:7e2b:ab39 with SMTP id w4-20020a170902e88400b001dd7e2bab39mr28859plg.33.1709953822893; Fri, 08 Mar 2024 19:10:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 19:10:22 -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 0/5] Add stub to handle Xfer:siginfo:read query Date: Sat, 9 Mar 2024 03:08:56 +0000 Message-Id: <20240309030901.1726211-1-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 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 Xfer:siginfo:read query is received, usually, when GDB catches a signal and needs additional info about it, like the si_code and the si_addr, so GDB can show the user interesting info about the signal. This query can also be received when an user explicitly asks for more information via printing GBD's special purpose variable '$_siginfo'. This series adds the stub to handle Xfer:siginfo:read queries. To achieve this, it is first necessary to stash the target-specific siginfo in the gdbstub server state struct when handling a signal, so it requires modifying the gdb_handlesig function to accept the target's siginfo struct and its length. Later, when replying to a Xfer:siginfo:read query (i.e., after a signal is caught), the query handler utilizes the stashed siginfo to form the packet for replying to the query. Finally, a test is added to check if the stub correctly responds to the query when a simple binary causes a SIGSEGV. Since the si_addr must be available in the case of a SIGSEGV, the value of si_addr is checked against the expected faulting address, corresponding to the dereferenced pointer value in the binary. v1: https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg00423.html v2: https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg01858.html Cheers, Gustavo Gustavo Romero (5): gdbstub: Rename back gdb_handlesig linux-user: Move tswap_siginfo out of target code gdbstub: Save target's siginfo gdbstub: Add Xfer:siginfo:read stub tests/tcg: Add multiarch test for Xfer:siginfo:read stub bsd-user/main.c | 2 +- bsd-user/signal.c | 5 +- gdbstub/gdbstub.c | 8 ++++ gdbstub/internals.h | 1 + gdbstub/user.c | 46 +++++++++++++++++-- include/gdbstub/user.h | 19 +++----- 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/main.c | 2 +- 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 | 15 ++++-- linux-user/sparc/signal.c | 2 +- linux-user/xtensa/signal.c | 2 +- tests/tcg/multiarch/Makefile.target | 10 +++- .../gdbstub/test-qxfer-siginfo-read.py | 26 +++++++++++ tests/tcg/multiarch/segfault.c | 14 ++++++ 30 files changed, 147 insertions(+), 49 deletions(-) create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py create mode 100644 tests/tcg/multiarch/segfault.c