From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381584; cv=none; d=zohomail.com; s=zohoarc; b=WzTcc20y6Pa5PnYi7vNZJEhaBDenf7zKbBtG0WVndHturOdZTRQ2+Tpa9R546ziYvGuwDukHE1QgLDGZmrPW0lsE37SEbuar2+4mqNLpZwMIBJRueZjxwG53MVVoftKI/pao2BU2JI9oEyb50uO5NGNjTpMKP6UYbFksvOluAsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=opP09aUpVqbLeEIEW2//0Q0JIWRT0FGPjndrXn93n2Y=; b=MPC9zllrZ/Z3FS5QTdNGGaBhLZRmzYvWV460l4Gayb0xMI2jlS4X5q2yKm/rZg/ICDkEEG1j+NCmSeEkSTfN71eKXLQ0jXLr/SedEVyOupkg4g//mFSxrYXlifE2ME57wrlK/XPje6DrJUBlNxCPrNnHEfg0rTK2obBqXoI48LI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381584147261.8594398885856; Mon, 16 Mar 2020 10:59:44 -0700 (PDT) Received: from localhost ([::1]:45108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDu1f-0001bU-4E for importer@patchew.org; Mon, 16 Mar 2020 13:59:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44979) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRI-0000XH-Mo for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRF-0007uA-Op for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:08 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:55825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRF-0007lt-83 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:05 -0400 Received: by mail-wm1-x332.google.com with SMTP id 6so18580789wmi.5 for ; Mon, 16 Mar 2020 10:22:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h10sm799676wrb.24.2020.03.16.10.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:21:57 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3CBFE1FF87; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=opP09aUpVqbLeEIEW2//0Q0JIWRT0FGPjndrXn93n2Y=; b=RLfnecc9q9W9f/t6YLGjgLi8IE2c+N90x3XNg2h3ASHSWWmq3CA4ldNH//P3LhMywr tjvlZwdS8ZRRwDe40QWpm+2/OcqevIm6Nyq8r0BLCBDISHh1QXeYJIKFOdQirWiEipfp J16SJ4e5bhrv7fbmOOkGpExN/ufO8J9Llit07o9QzRE2tslkhTLg7jlXzdK3SuHsphYs EZ4gGhHo7RmVER0EhJO+uD2kiAplbQWHji/S0KAtBWsYyq0gQtaqt2iDboGCuNS3npvI 4rmpsp0UWmp/EQtJmJI/vM7YEDyxHxugFPqiKn1QnOQroICuvVkymZ4vmIYOyDXhHAXl B+bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=opP09aUpVqbLeEIEW2//0Q0JIWRT0FGPjndrXn93n2Y=; b=nrZiD8WvC3i0ans8LnOirjE2b91OzQWdxTb1nDTKHQtUrEoOO5OzJjH4vmTousktLc 8OI3uPaNtlNMH+NspX6jxPRqUaKQvOXmkNLwW/EhWkbggApZeytODzpZyNO03pkQHXqQ wv5IaTQ+nT+qNBle0xkRDh6U8fUe+1yiBxffhC12ar/lXGXQVTS2zOgRerqLVoOD1Hm5 dY5zLuhJPhjm7/MKEnpvrigNY7gUMbovBuAfAEeSah6jGGStZacts8QWJXy4CWv0rYdP A81HfQFWt57Hh+XIbwmr3cvaOeCQqL1RWq7er+BjJbLFydBK+Oovytxj/Ks7jOi3slxa o/Xg== X-Gm-Message-State: ANhLgQ1pqpGL9KZsPWIAIFjs/ioR64J5UTekF7tY/EomV6kl8IjchcKj PGRaMomifEQZt6w8SN5n6qMlyw== X-Google-Smtp-Source: ADFU+vuDjDWa+Pbc84MzS/Zdv4r7Q+WA0L6WS1s5qmn7AVlx+9TKlwh7h7ll81SlydcAj9O02Pzurw== X-Received: by 2002:a1c:7d88:: with SMTP id y130mr163415wmc.5.1584379321751; Mon, 16 Mar 2020 10:22:01 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 01/28] tests/docker: Install tools to cross-debug and build Linux kernels Date: Mon, 16 Mar 2020 17:21:28 +0000 Message-Id: <20200316172155.971-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 We often run Linux kernels to test QEMU. We sometimes need to build them manually to use non-default features. We only miss the tiny 'bc' tool. The ncurses library is helpful to run 'make menuconfig'. Finally, gdb-multiarch allow us to debug a TCG guest when its architecture is different than the host. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200212202738.12986-1-philmd@redhat.com> --- tests/docker/dockerfiles/debian10.docker | 3 +++ tests/docker/dockerfiles/debian9.docker | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/docker/dockerfiles/debian10.docker b/tests/docker/docker= files/debian10.docker index 5de79ae5527..2fcdc406e83 100644 --- a/tests/docker/dockerfiles/debian10.docker +++ b/tests/docker/dockerfiles/debian10.docker @@ -17,14 +17,17 @@ RUN apt update && \ DEBIAN_FRONTEND=3Dnoninteractive apt install -yy eatmydata && \ DEBIAN_FRONTEND=3Dnoninteractive eatmydata \ apt install -y --no-install-recommends \ + bc \ bison \ build-essential \ ca-certificates \ clang \ dbus \ flex \ + gdb-multiarch \ gettext \ git \ + libncurses5-dev \ pkg-config \ psmisc \ python3 \ diff --git a/tests/docker/dockerfiles/debian9.docker b/tests/docker/dockerf= iles/debian9.docker index 8cbd742bb5f..92edbbf0f48 100644 --- a/tests/docker/dockerfiles/debian9.docker +++ b/tests/docker/dockerfiles/debian9.docker @@ -17,13 +17,16 @@ RUN apt update && \ DEBIAN_FRONTEND=3Dnoninteractive apt install -yy eatmydata && \ DEBIAN_FRONTEND=3Dnoninteractive eatmydata \ apt install -y --no-install-recommends \ + bc \ bison \ build-essential \ ca-certificates \ clang \ flex \ + gdb-multiarch \ gettext \ git \ + libncurses5-dev \ pkg-config \ psmisc \ python3 \ --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381882; cv=none; d=zohomail.com; s=zohoarc; b=jSVi/6CHC+lDLlNWOSsgyV3ooG6WNLNjn+Kb6wdyuoPpHr0CncPF01HqwJkg19vjnBvLarPU3z3ZmU4zBMqShnBHUgjtFsELda96Mv6dYEbkWc1aXlmqSNlHE3M9yDxBr2XSYYq7zYvkSn/V3/ZYpxILO8hYICZQa2OhxKlFPx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZZCLDV01NVJMn0TsI5hdBQQvWUb6UiKnEo9bNWpw6gs=; b=D/d/Ssok4aCvyMOCDVx1f326tvraT7f2YVmCHYqAfNg4+mRcnMOEbGdq0jRF/+/Iq6HkWVSRm/jQWvHx0bQr6rFhj2cT/alXQMpL+7+Mfbfqiacs4DADlp2OORpXtcWbKZzLB+WgL7y/zpau2yfo0xFVflpIhxTchTydUtA3+JQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381882629153.65759135635687; Mon, 16 Mar 2020 11:04:42 -0700 (PDT) Received: from localhost ([::1]:45224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDu6T-00005P-Gr for importer@patchew.org; Mon, 16 Mar 2020 14:04:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45121) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRM-0000eI-JJ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRI-0008GJ-RP for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:12 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:51349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRI-00082C-Fs for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:08 -0400 Received: by mail-wm1-x331.google.com with SMTP id a132so18580312wme.1 for ; Mon, 16 Mar 2020 10:22:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f187sm457188wme.31.2020.03.16.10.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5295E1FF8C; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZZCLDV01NVJMn0TsI5hdBQQvWUb6UiKnEo9bNWpw6gs=; b=rZ63sTDlVfAcYzRWg00N/5cdhSxvYq8tQ7rIJdD2Hjwlh5YZsaGi/lTL6eKel5Zxco LVVY1UfozQXF7JgHynTJQyzibiqzpIU+DHAmoiUQU9x62S7gCKSAjYBG4VIh4qaNRdyl 7s1XkCMLw7O91Y507W2qtcAbZ0oSX1bxmcw/EqCR8MGvIByh7Fzfk4tbbYFFcQKCBu6g +EUjYCmmNaTXB62y47o6Pc0RCS5/LSfWNqENnfUPuaSu1+WnAK12fYEkfWUCdVyR9H+l fZclHfZvnuQKyHW8QXtebbjk95yQXqgnXdNgAqG5XuhKRKUrW/2Uer+oTWO4uifwGMqu l3hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZZCLDV01NVJMn0TsI5hdBQQvWUb6UiKnEo9bNWpw6gs=; b=dAIF/2WTdzuMetgooInDmq2072IZtv7WekzK6rgP10g3yW39k/2YdV37hrOydO0r0s d9FpKRp7+LqCOhKCeu9z8UuWi2i73v5bCLX63EOLwGKJQmTUOIFw+STe38VwZFhJaOTB +ZvkVB7bJUosz1ht1sLc5KXRFm4St/yn5j01w2rhV+uBTPN1UjliiUpFGWdv/U3U5aNt 4MSdy1iYLPMuEZqFFzT3K25ha3GVzYoxrxjelx15OU9T+lCZmjE3jJh8dX2WAsFmSl/2 CeiOiSVw57c8/31DuMzvP3hQk2r1qEzHR59pZfwHvRvlRq+4PBRhxEF3lMP9ZFbsPZnn eFlg== X-Gm-Message-State: ANhLgQ1ZEvGr75oFNZtd72J+wWyX10FStxnBSKp8/OA3HVbaMpqJqbf7 NUDrVeARfYDrHh9MCQfmReb5qA== X-Google-Smtp-Source: ADFU+vvyAHLXN1VLmBH1AYEhQ7T8o/iXogIIBJfEd8MeQ9as9PXJ2jSPURLbW17Fd+D3G3zW3+7WJA== X-Received: by 2002:a05:600c:2c06:: with SMTP id q6mr177487wmg.52.1584379326311; Mon, 16 Mar 2020 10:22:06 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 02/28] tests/docker: Update VirGL git repository URL Date: Mon, 16 Mar 2020 17:21:29 +0000 Message-Id: <20200316172155.971-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 freedesktop.org is moving to a GitLab instance, use the new url. - https://www.fooishbar.org/blog/gitlab-fdo-introduction/ - https://gitlab.freedesktop.org/freedesktop/freedesktop/-/wikis/home Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200212202709.12665-2-philmd@redhat.com> --- tests/docker/dockerfiles/debian-amd64.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/do= ckerfiles/debian-amd64.docker index 3b860af1068..b67fad54cb7 100644 --- a/tests/docker/dockerfiles/debian-amd64.docker +++ b/tests/docker/dockerfiles/debian-amd64.docker @@ -27,7 +27,7 @@ RUN apt update && \ libegl1-mesa-dev \ libepoxy-dev \ libgbm-dev -RUN git clone https://anongit.freedesktop.org/git/virglrenderer.git /usr/s= rc/virglrenderer && \ +RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git /usr/= src/virglrenderer && \ cd /usr/src/virglrenderer && git checkout virglrenderer-0.7.0 RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --with-glx --= disable-tests && make install =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584380603; cv=none; d=zohomail.com; s=zohoarc; b=EXcoQhr5DeD9TKy6psBrmfC6Zh6DknazK+Yp2lHuX9ibwQZxjowiPfKni5tVcMEWc/i0XvzlfePGsKU+Y2gb05rJmnq08vOA/+isaLxgHjhkVAX/fUuOoQdbRMa+x/W173InLzbgpuDgQ0EmER5hGsQ268gke/1MUFOVvS52rTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584380603; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ckXsB/S4+Zc7QwguSZl38+7FV9JObasmn6KmK05PN2I=; b=Nqofcb56dgqDkkJv4jhoIUlK4uIbswFlfgFfXLXCaw3f271vmQML8Jn/6+Zr1KXfRaekoUGGzf5NeBFTWhspcLKiwseW/3lfaFv7A51C9ti1YxHqT8RKMOeprdVEjP4ufhdHJjWKFuEusfQa8wXsq/CFnrutsj7+yp0ZN78YJXw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584380603579201.1714773684812; Mon, 16 Mar 2020 10:43:23 -0700 (PDT) Received: from localhost ([::1]:44680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtlq-0004VH-Bg for importer@patchew.org; Mon, 16 Mar 2020 13:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44937) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRH-0000Vu-H1 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRF-0007rf-Dk for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:07 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:54989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRF-0007Wy-3H for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:05 -0400 Received: by mail-wm1-x32b.google.com with SMTP id n8so18569638wmc.4 for ; Mon, 16 Mar 2020 10:22:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y11sm795781wrd.65.2020.03.16.10.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:21:57 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6A8831FF8F; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ckXsB/S4+Zc7QwguSZl38+7FV9JObasmn6KmK05PN2I=; b=U9gpQuDZSoHiMSNkIob/UcNE23sofRmo+WyVlwbLSOVSLYPY9cpES5F6+xWwGU8qPs Dcs2ErAoEw/BR0vxStXnSGqT6UOfFqU+RyTwblpCIPDIGTzwt0iiXvs3+/4f1Rxb/Qay NpogoGBs71Ufxjxgsn75czGSNLVdhr8x0zceSaM9j7ieN+UBqVcLVOrERNZKftxMh1dw UYA90OY8xI9GspDApS35WsavYN/MuDmHijjYTx8FkuBVBm+LecnoccmI/uJtFLclm3hN nH8D4WbgPdIJwHIBPGY6ZgO2SWDeg6MteFy1HRmlS9jfk9uWDXmMu11bSdrZZATskgNp Cr6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ckXsB/S4+Zc7QwguSZl38+7FV9JObasmn6KmK05PN2I=; b=PRlbKvVHHmFiSek99yqCqdykhoynuJua4P0VHJ21iR6vcdq9mZj5BXcBJwSQV1Mv9X +7+S8Yo6ktWMu3EHNHc0HP5oNfIfgxOaFrjhu7lIpbbb5ZOGlhWDQFxGOhS3Y43WQAaV 4F8lhPDfNEgDqUONoQ8BfDh3kJiO0jUF5EpgPVfS/Z20xCxcyVMOa9tgwfdn1Z5j6M7q /SduJ/IEae30gDJA4jK+9r64TivhKJKniaE1lRi2zeiKmO6qW/YnpPVIMUcwfQIY859m g5X5IEyQAX5weRBR0R//YIoi96frUkKzeA9zKfZhlKYqFP86QLn+ZPVM8q7bio4xaQOi IDPg== X-Gm-Message-State: ANhLgQ2KNL/IEcnmJGeWpumRuFHAj3vMoeObb+VN2WDQm9CR45pthxME N8lMIqGc/uRMZRVEZBoKuOfFUw== X-Google-Smtp-Source: ADFU+vvVQNMq458oCnF5U/MZF8V++Aa5oKgQluweiGAFQpme5y1g9ANkk+0N2ahyGaX4b8RrjhsODg== X-Received: by 2002:a1c:2045:: with SMTP id g66mr152066wmg.15.1584379319199; Mon, 16 Mar 2020 10:21:59 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 03/28] tests/docker: Remove obsolete VirGL --with-glx configure option Date: Mon, 16 Mar 2020 17:21:30 +0000 Message-Id: <20200316172155.971-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The GLX configure option has been removed in 71c75f201d [*]. We missed that when updating to v0.7.0 in commit fab3220f97. This silents: configure: creating ./config.status config.status: creating virglrenderer.pc ... configure: WARNING: unrecognized options: --with-glx [*] https://gitlab.freedesktop.org/virgl/virglrenderer/commit/71c75f201d Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200212202709.12665-3-philmd@redhat.com> --- tests/docker/dockerfiles/debian-amd64.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/do= ckerfiles/debian-amd64.docker index b67fad54cb7..a1d40a56fa1 100644 --- a/tests/docker/dockerfiles/debian-amd64.docker +++ b/tests/docker/dockerfiles/debian-amd64.docker @@ -29,7 +29,7 @@ RUN apt update && \ libgbm-dev RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git /usr/= src/virglrenderer && \ cd /usr/src/virglrenderer && git checkout virglrenderer-0.7.0 -RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --with-glx --= disable-tests && make install +RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --disable-tes= ts && make install =20 # netmap RUN apt update && \ --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381748; cv=none; d=zohomail.com; s=zohoarc; b=m8d4gkS0hkdf5XHhTHO8Gv5ofP/uJJkdWbBPtDe1MKqB95tjUgy3zyr+VVH7X4SpEqyhCuJnsWvD2pdbxEnUB3mYX60Ig1SuWa89pJfNBKuMwinr4Gtu2ov3nG6N3ot1ZKTTlbQgRi85L118kqNBylU+qhqb2RtPj8y/4s8wGjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GepS+RBgIfLthS0hHsFgjFpLev7UFXBivw+uaPGBApc=; b=dTLHfw1mzK3E6XSbqEWcyfJj5G8Uo1XvNPfB+yh+VI4fdK+rrWhWhBD9yuY2qyxBhN4XJ62Qsv+qM89VK9fTSSj07JGJ0dx7H5Bl8jW2KkxrZp5lUElpaQJeLix5x8cMW5xHHUKrbBft6MuUyx2Hu31qS4Td/kixeJgbGeHbfIc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381748938212.38033251736329; Mon, 16 Mar 2020 11:02:28 -0700 (PDT) Received: from localhost ([::1]:45172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDu4J-000599-OK for importer@patchew.org; Mon, 16 Mar 2020 14:02:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44995) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRJ-0000Xy-F5 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRF-0007uz-Qs for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:08 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:40536) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRF-0007mM-DC for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:05 -0400 Received: by mail-wr1-x42f.google.com with SMTP id f3so15285632wrw.7 for ; Mon, 16 Mar 2020 10:22:04 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o5sm483071wmb.8.2020.03.16.10.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:21:57 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7E7B01FF90; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GepS+RBgIfLthS0hHsFgjFpLev7UFXBivw+uaPGBApc=; b=qUx6dsgqVC2U0YNRqa+a3JBiPqNaMAKBGYqmHIoPjpBSZZclRm15foe2xZeH0I1ccm /R1qADFU1V7mZ6zJBW7jbPRKjxdLi48H/+ZCeCSsVPKxyrCK7o4b+QTAVpijmGQjlaKJ VsOwtDrymGoxoE1B1GjQnVyHCafQVnPmaFoFny19hulQ5Ach6B7xDRyVPjNFRS/UfYuz +VrX9vsD4XATfGzi2xVfH5Yw4e85c4GrVUxWaNX80L0rb2V/ZVevnMg7PTt5VbLGcLnz SqJHFP7MFcVINRN8zm3pAdwztVeSFoqt9ELeM6bEKuEkw75zMhr7lNPBXCsgA/QySyPX Tk1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GepS+RBgIfLthS0hHsFgjFpLev7UFXBivw+uaPGBApc=; b=s9F4HAW769B7w+nIQVGHq1yM0Esdj5grN8jgmsnSusXLM2hJCZRYGrVkj0gP6rBYqw mPfjnjaJ2Zv1ks/v11mH4c6fluJgkhh6evdV1qYi4A7werlPvKtMzng9SOA1OdIGRijO UQC3oBYOEnkg9TFGP9bVPCA6H9i3XJ9l4l47njq3erUASpSpZ37ZcvKsQBvULQ9Cg4HT soMOc1ZteIvM2fNzSq/RQniXDj0mlxUbHlD+hyNVINJRYzzVdg/ofH1q8XjcFK9AfxJg x1X2KRVRp2BwU8clSI57xLVrSFi72sdyCfNv2mPII//ekMORD7wjBi+6xDf+OGf51gHN icBw== X-Gm-Message-State: ANhLgQ3lSaVzPK4eQYnlbFEZ+F76znHYKYR/Dhh2nd11nRle3mglMSKe fe1wW3GiQEFca4rCGe4OBPxgE3Eu3Mg= X-Google-Smtp-Source: ADFU+vunb8f+NCXHLrZ4yIAkGI7wyPJBJcb6fuPiaZ0cJkgAilJFfkyv+ig0Q6CUQopY3rUGIg4QdQ== X-Received: by 2002:a05:6000:189:: with SMTP id p9mr353182wrx.391.1584379323180; Mon, 16 Mar 2020 10:22:03 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 04/28] tests/docker: Update VirGL to v0.8.0 Date: Mon, 16 Mar 2020 17:21:31 +0000 Message-Id: <20200316172155.971-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Building the qemu:debian-amd64 fails when building VirGL: make[2]: Entering directory '/usr/src/virglrenderer/src/gallium/auxiliary' CC cso_cache/cso_cache.lo CC cso_cache/cso_hash.lo CC os/os_misc.lo CC util/u_debug.lo CC util/u_debug_describe.lo CC util/u_format.lo GEN util/u_format_table.c Traceback (most recent call last): File "./util/u_format_table.py", line 168, in main() File "./util/u_format_table.py", line 164, in main write_format_table(formats) File "./util/u_format_table.py", line 132, in write_format_table print(" %s,\t/* is_array */" % (bool_map(format.is_array()),)) File "/usr/src/virglrenderer/src/gallium/auxiliary/util/u_format_parse.= py", line 164, in is_array return self.array_element() !=3D None File "/usr/src/virglrenderer/src/gallium/auxiliary/util/u_format_parse.= py", line 73, in __eq__ return self.type =3D=3D other.type and self.norm =3D=3D other.norm an= d self.pure =3D=3D other.pure and self.size =3D=3D other.size AttributeError: 'NoneType' object has no attribute 'type' make[2]: Leaving directory '/usr/src/virglrenderer/src/gallium/auxiliary' make[2]: *** [Makefile:906: util/u_format_table.c] Error 1 make[1]: *** [Makefile:631: install-recursive] Error 1 VirGL commits a8962eda1..a613dcc82 fix this problem. Update to VirGL 0.8.0 which contains them. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200212202709.12665-4-philmd@redhat.com> --- tests/docker/dockerfiles/debian-amd64.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/do= ckerfiles/debian-amd64.docker index a1d40a56fa1..c70c916343e 100644 --- a/tests/docker/dockerfiles/debian-amd64.docker +++ b/tests/docker/dockerfiles/debian-amd64.docker @@ -28,7 +28,7 @@ RUN apt update && \ libepoxy-dev \ libgbm-dev RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git /usr/= src/virglrenderer && \ - cd /usr/src/virglrenderer && git checkout virglrenderer-0.7.0 + cd /usr/src/virglrenderer && git checkout virglrenderer-0.8.0 RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --disable-tes= ts && make install =20 # netmap --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381997; cv=none; d=zohomail.com; s=zohoarc; b=O8Y39mEtzZvuDwjGS/z+7Ry2aHeE8+btsCCsSP4AYs/plSkD7fbdDP3oLN8517rqCJE4AHOx3J/dIL5gPObewlLl43MtrKx1Bz9+rdcrvMoALQ3LDcR+Sir+gsW/c60GOIry3TR/yYeENrI+lrqNEihY8pcfAEYSdZqaTf8EDvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381997; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FAKlYLQafHN49zgZlDmm+hNC2Vq+rR/wo91Hdl/dBwk=; b=QqO8aXROHfQbyv5VmlxdaFLNwZfN2/40cBBqqGbxuF5rcqPxXNVPfQw6CQNO5aS6oD6G1lFvD03gNHjMT7sHb7uOZHAvx/5jbUYMfGrF/6FuOQ7CNZE34e0OgQG8J5AjjNlqSWHVTDBMlM5iqQpA7HlQfrETf2jrep+Bo024N4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158438199720692.8826266275887; Mon, 16 Mar 2020 11:06:37 -0700 (PDT) Received: from localhost ([::1]:45272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDu8J-0003js-5j for importer@patchew.org; Mon, 16 Mar 2020 14:06:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45202) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRP-0000kd-F3 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRN-0000Lr-L8 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:15 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:36952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRN-0000Ck-BO for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:13 -0400 Received: by mail-wr1-x430.google.com with SMTP id 6so22257718wre.4 for ; Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 98sm746549wrk.52.2020.03.16.10.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9323E1FF91; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FAKlYLQafHN49zgZlDmm+hNC2Vq+rR/wo91Hdl/dBwk=; b=x7lrWLGnK97VKUZLUXuSvvsjuTHXN28l31yfxZldqXgcNPIDBlGNBI6iPMR9sDD1sY AS4OzLCfN3194/S19iZPBd0sv+5SA4V91v3PwqKjlQ46R5iKLS+5+ROjLTV1mSsbyZKO IEQdJGMv4gQkXuoj/1TNisbfk3NewJtfVSh4RA23oU7di2mjefCe9IzwGfU/i/FZfa+o c6baKonuZLcHNacU+18fW6RZDmoQqBee2vO/QmkDH2YyNfPdRbQaOplbYSbdE2o1m8j4 ihK3T0TaaxsB4u+VpzkTw4MhA20wclEopPT4IHGwH/QfOC9UNBaT85xjk8wNwKNANeNi Vfqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FAKlYLQafHN49zgZlDmm+hNC2Vq+rR/wo91Hdl/dBwk=; b=r+nZjVeWjBWiovGAXaILhVZVOBDqPnZqVlglJZOlBL4SpW21NRWMFq3z2rQ+XLlRnq 6H7LU7CCHJ2CF97fF8jmzwtlu4V0WvB/cbOMJHKCYYTuiri/KSV+ytX5trYSCq6ruFb+ exljxjBi8mIwgr1Dztwh4xIA+IZzU4MrbqZ2qnvElss5Rxi7CESR8QF6Ix0Wv725I59l pckhgz55MkSpGoGEcK2kJiA6pcvG2lNLbsf35/oEKqJMvdqKFG4eQ7kCjzW2LXC7qymr VJQAUHoeBD68JWzA3u8IZws2976vDH/Ru+ow/lzXkxDVwX+02Qehhof1FI9R1qH4pc+O 5gLg== X-Gm-Message-State: ANhLgQ36h+dlR/AAdZeaCxaxpy0mvBsrKrj3IIzDFyC/fHi5NJLFmfTK 0BbNPp/bxr//8nATJvQtAZSw5A== X-Google-Smtp-Source: ADFU+vsLyKiFHGPNFqDAYaVgipKMray1v17M+C1r9oXBQkjK2hkRy4Tvfv+IebZ0M9oK8TlqIECP+w== X-Received: by 2002:adf:e5d2:: with SMTP id a18mr421223wrn.334.1584379332179; Mon, 16 Mar 2020 10:22:12 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 05/28] travis.yml: Set G_MESSAGES_DEBUG do report GLib errors Date: Mon, 16 Mar 2020 17:21:32 +0000 Message-Id: <20200316172155.971-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Since commit f5852efa293 we can display GLib errors with the QEMU error reporting API. Set it to the 'error' level, as this helps understanding failures from QEMU calls to GLib on Travis-CI. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200316101544.22361-1-philmd@redhat.com> --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b92798ac3b9..ccf68aa9abc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,6 +79,7 @@ env: - MAIN_SOFTMMU_TARGETS=3D"aarch64-softmmu,mips64-softmmu,ppc64-softmmu= ,riscv64-softmmu,s390x-softmmu,x86_64-softmmu" - CCACHE_SLOPPINESS=3D"include_file_ctime,include_file_mtime" - CCACHE_MAXSIZE=3D1G + - G_MESSAGES_DEBUG=3Derror =20 =20 git: --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584380987; cv=none; d=zohomail.com; s=zohoarc; b=WlWXLHof3mP+3VS1ETxsfO9ShX61YR7yExu6hwKblXCyo2XACyEVi692FiMcDpraQAkb3BNvg0StMeOLXGwcdKIs/0qAtmPVcysziWLveuB7rOKkCbXZ5qpBcwzrv1YZgnA7HNa00SmUV2VNex7RGtP6Yd64Y33Ed0F9Y3bTXK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584380987; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mhAKDLwevRgUwbK/Yj2EAj4vkZTmlFwtudl8wSKqu+o=; b=Isz+v6J3+sKBeInMuy5Jp6DlNZkvMh7LGSADFnYrO/BsnWnc2jOy4WW3RgMcDYnAb+WHPkPsvPUdduOcHpntzhms8x/2jpDHOhGO0J7LJkeEoDaikTSs1SsnRTimdE0TB1bf0wf1F46kN8A2zHBi2o/2IVg3fmgFEIKRvD4N8/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584380987729167.68552216135606; Mon, 16 Mar 2020 10:49:47 -0700 (PDT) Received: from localhost ([::1]:44808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDts2-00075H-Lz for importer@patchew.org; Mon, 16 Mar 2020 13:49:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45066) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRL-0000aw-8n for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRG-000822-PO for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:10 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:33299) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRG-0007us-EU for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:06 -0400 Received: by mail-wr1-x443.google.com with SMTP id a25so22273754wrd.0 for ; Mon, 16 Mar 2020 10:22:06 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k3sm712373wro.59.2020.03.16.10.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A9A611FF92; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mhAKDLwevRgUwbK/Yj2EAj4vkZTmlFwtudl8wSKqu+o=; b=kLBYm0oI9tPnsVU0NUlIQGInfIQpjjcBhrmUmPqkrDdJdozWRkMG+XpGMv6vm9ycUN zzV5OaTCuLf33iovWS8PkN0F1Ip5XjaqCyqPNuZdhR32FfbPWe/4+SgPchC9o2iLRVj9 sjsQjOY8/Nv9tztmr5WZc+c/kTTpzsnLWT1sIGpizKWkAiknpQnEiyspKzDqBH1mNjqV vXNKm6n94l1ggzkZyISIBOWV0uqhgAwI+yozgPHM5z6z+dFKuKRLurzy53WcrRknsIXG YIeahQonKiSp0J6uu1rDjfb5gWZC5tWbgQd6CgQdTrqiU3+aPfvMYm7fZHUn73Y6x8C6 KLCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mhAKDLwevRgUwbK/Yj2EAj4vkZTmlFwtudl8wSKqu+o=; b=fCScTolTvQAkY6QwCETop3RDoAvNWrhowIwSlEGwpA7EBbDFq485ju4lvOiNtVu4wd WZ9GlyefNwxMvxlKhVMlZyy0Noe6Df3A4AMeLEhLKo4G43l0R8G6uptA1GHO0LQMYhIz D5f1GgEqlX/M2hfB3w3MH0XeINQWge3zHeW0USP0ZptsXj526suQEc404B4p3PjsussW 2sR6hYNPFbFR2RsJQK2kiIhu39en3t9lBMw2LNpg2ZnnwQZibeN3lRLJTlBTpm+/VV0R fkcivWqxQAGp4eHEfFcr5NkyqqQVt1D4KLfsOg7ZyMQLY1zBYphoQJNhN4ZRUhQ/d5BN JGJw== X-Gm-Message-State: ANhLgQ1Yzu9JRg/FfDffEHRirYXChehfPmt5PGRGQz4eLyrvL+iYXmYd uR0yUggr8Xufb85pu90NXRBlwA== X-Google-Smtp-Source: ADFU+vvxrR8H34wp6yQPe/lfc1OEAVKFSEg2ROT9kVTGnXm4hYUZJsiJ/nRlSa9NqqpfKhKmBCFlog== X-Received: by 2002:a5d:55c7:: with SMTP id i7mr420375wrw.252.1584379325191; Mon, 16 Mar 2020 10:22:05 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 06/28] gdbstub: make GDBState static and have common init function Date: Mon, 16 Mar 2020 17:21:33 +0000 Message-Id: <20200316172155.971-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Instead of allocating make this entirely static. We shall reduce the size of the structure in later commits and dynamically allocate parts of it. We introduce an init and reset helper function to keep all the manipulation in one place. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde --- v2 - made entirely static, dropped dh/rth r-b tags due to changes --- gdbstub.c | 168 ++++++++++++++++++++++++++---------------------------- 1 file changed, 81 insertions(+), 87 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 22a2d630cdc..57d6e50ddfc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -342,6 +342,7 @@ enum RSState { RS_CHKSUM2, }; typedef struct GDBState { + bool init; /* have we been initialised? */ CPUState *c_cpu; /* current CPU for step/continue ops */ CPUState *g_cpu; /* current CPU for other ops */ CPUState *query_cpu; /* for q{f|s}ThreadInfo */ @@ -372,7 +373,23 @@ typedef struct GDBState { */ static int sstep_flags =3D SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER; =20 -static GDBState *gdbserver_state; +static GDBState gdbserver_state; + +static void init_gdbserver_state(void) +{ + g_assert(!gdbserver_state.init); + memset(&gdbserver_state, 0, sizeof(GDBState)); + gdbserver_state.init =3D true; +} + +#ifndef CONFIG_USER_ONLY +static void reset_gdbserver_state(void) +{ + g_free(gdbserver_state.processes); + gdbserver_state.processes =3D NULL; + gdbserver_state.process_num =3D 0; +} +#endif =20 bool gdb_has_xml; =20 @@ -425,8 +442,8 @@ int use_gdb_syscalls(void) /* -semihosting-config target=3Dauto */ /* On the first call check if gdb is connected and remember. */ if (gdb_syscall_mode =3D=3D GDB_SYS_UNKNOWN) { - gdb_syscall_mode =3D (gdbserver_state ? GDB_SYS_ENABLED - : GDB_SYS_DISABLED); + gdb_syscall_mode =3D gdbserver_state.init ? + GDB_SYS_ENABLED : GDB_SYS_DISABLED; } return gdb_syscall_mode =3D=3D GDB_SYS_ENABLED; } @@ -984,7 +1001,7 @@ static int gdb_breakpoint_insert(int type, target_ulon= g addr, target_ulong len) int err =3D 0; =20 if (kvm_enabled()) { - return kvm_insert_breakpoint(gdbserver_state->c_cpu, addr, len, ty= pe); + return kvm_insert_breakpoint(gdbserver_state.c_cpu, addr, len, typ= e); } =20 switch (type) { @@ -1021,7 +1038,7 @@ static int gdb_breakpoint_remove(int type, target_ulo= ng addr, target_ulong len) int err =3D 0; =20 if (kvm_enabled()) { - return kvm_remove_breakpoint(gdbserver_state->c_cpu, addr, len, ty= pe); + return kvm_remove_breakpoint(gdbserver_state.c_cpu, addr, len, typ= e); } =20 switch (type) { @@ -1074,7 +1091,7 @@ static void gdb_breakpoint_remove_all(void) CPUState *cpu; =20 if (kvm_enabled()) { - kvm_remove_all_breakpoints(gdbserver_state->c_cpu); + kvm_remove_all_breakpoints(gdbserver_state.c_cpu); return; } =20 @@ -2601,7 +2618,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) =20 void gdb_set_stop_cpu(CPUState *cpu) { - GDBProcess *p =3D gdb_get_cpu_process(gdbserver_state, cpu); + GDBProcess *p =3D gdb_get_cpu_process(&gdbserver_state, cpu); =20 if (!p->attached) { /* @@ -2611,14 +2628,14 @@ void gdb_set_stop_cpu(CPUState *cpu) return; } =20 - gdbserver_state->c_cpu =3D cpu; - gdbserver_state->g_cpu =3D cpu; + gdbserver_state.c_cpu =3D cpu; + gdbserver_state.g_cpu =3D cpu; } =20 #ifndef CONFIG_USER_ONLY static void gdb_vm_state_change(void *opaque, int running, RunState state) { - GDBState *s =3D gdbserver_state; + GDBState *s =3D &gdbserver_state; CPUState *cpu =3D s->c_cpu; char buf[256]; char thread_id[16]; @@ -2722,17 +2739,16 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, co= nst char *fmt, va_list va) char *p_end; target_ulong addr; uint64_t i64; - GDBState *s; =20 - s =3D gdbserver_state; - if (!s) + if (!gdbserver_state.init) return; - s->current_syscall_cb =3D cb; + + gdbserver_state.current_syscall_cb =3D cb; #ifndef CONFIG_USER_ONLY vm_stop(RUN_STATE_DEBUG); #endif - p =3D s->syscall_buf; - p_end =3D &s->syscall_buf[sizeof(s->syscall_buf)]; + p =3D &gdbserver_state.syscall_buf[0]; + p_end =3D &gdbserver_state.syscall_buf[sizeof(gdbserver_state.syscall_= buf)]; *(p++) =3D 'F'; while (*fmt) { if (*fmt =3D=3D '%') { @@ -2765,14 +2781,14 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, co= nst char *fmt, va_list va) } *p =3D 0; #ifdef CONFIG_USER_ONLY - put_packet(s, s->syscall_buf); + put_packet(&gdbserver_state, gdbserver_state.syscall_buf); /* Return control to gdb for it to process the syscall request. * Since the protocol requires that gdb hands control back to us * using a "here are the results" F packet, we don't need to check * gdb_handlesig's return value (which is the signal to deliver if * execution was resumed via a continue packet). */ - gdb_handlesig(s->c_cpu, 0); + gdb_handlesig(gdbserver_state.c_cpu, 0); #else /* In this case wait to send the syscall packet until notification that the CPU has stopped. This must be done because if the packet is se= nt @@ -2780,7 +2796,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, cons= t char *fmt, va_list va) is still in the running state, which can cause packets to be dropped and state transition 'T' packets to be sent while the syscall is st= ill being processed. */ - qemu_cpu_kick(s->c_cpu); + qemu_cpu_kick(gdbserver_state.c_cpu); #endif } =20 @@ -2941,15 +2957,13 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) /* Tell the remote gdb that the process has exited. */ void gdb_exit(CPUArchState *env, int code) { - GDBState *s; char buf[4]; =20 - s =3D gdbserver_state; - if (!s) { + if (!gdbserver_state.init) { return; } #ifdef CONFIG_USER_ONLY - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return; } #endif @@ -2957,10 +2971,10 @@ void gdb_exit(CPUArchState *env, int code) trace_gdbstub_op_exiting((uint8_t)code); =20 snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(s, buf); + put_packet(&gdbserver_state, buf); =20 #ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&s->chr, true); + qemu_chr_fe_deinit(&gdbserver_state.chr, true); #endif } =20 @@ -2993,12 +3007,10 @@ static void create_default_process(GDBState *s) int gdb_handlesig(CPUState *cpu, int sig) { - GDBState *s; char buf[256]; int n; =20 - s =3D gdbserver_state; - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return sig; } =20 @@ -3008,58 +3020,55 @@ gdb_handlesig(CPUState *cpu, int sig) =20 if (sig !=3D 0) { snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); - put_packet(s, buf); + put_packet(&gdbserver_state, buf); } /* put_packet() might have detected that the peer terminated the connection. */ - if (s->fd < 0) { + if (gdbserver_state.fd < 0) { return sig; } =20 sig =3D 0; - s->state =3D RS_IDLE; - s->running_state =3D 0; - while (s->running_state =3D=3D 0) { - n =3D read(s->fd, buf, 256); + gdbserver_state.state =3D RS_IDLE; + gdbserver_state.running_state =3D 0; + while (gdbserver_state.running_state =3D=3D 0) { + n =3D read(gdbserver_state.fd, buf, 256); if (n > 0) { int i; =20 for (i =3D 0; i < n; i++) { - gdb_read_byte(s, buf[i]); + gdb_read_byte(&gdbserver_state, buf[i]); } } else { /* XXX: Connection closed. Should probably wait for another connection before continuing. */ if (n =3D=3D 0) { - close(s->fd); + close(gdbserver_state.fd); } - s->fd =3D -1; + gdbserver_state.fd =3D -1; return sig; } } - sig =3D s->signal; - s->signal =3D 0; + sig =3D gdbserver_state.signal; + gdbserver_state.signal =3D 0; return sig; } =20 /* Tell the remote gdb that the process has exited due to SIG. */ void gdb_signalled(CPUArchState *env, int sig) { - GDBState *s; char buf[4]; =20 - s =3D gdbserver_state; - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return; } =20 snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - put_packet(s, buf); + put_packet(&gdbserver_state, buf); } =20 static bool gdb_accept(void) { - GDBState *s; struct sockaddr_in sockaddr; socklen_t len; int fd; @@ -3083,15 +3092,13 @@ static bool gdb_accept(void) return false; } =20 - s =3D g_malloc0(sizeof(GDBState)); - create_default_process(s); - s->processes[0].attached =3D true; - s->c_cpu =3D gdb_first_attached_cpu(s); - s->g_cpu =3D s->c_cpu; - s->fd =3D fd; + init_gdbserver_state(); + create_default_process(&gdbserver_state); + gdbserver_state.processes[0].attached =3D true; + gdbserver_state.c_cpu =3D gdb_first_attached_cpu(&gdbserver_state); + gdbserver_state.g_cpu =3D gdbserver_state.c_cpu; + gdbserver_state.fd =3D fd; gdb_has_xml =3D false; - - gdbserver_state =3D s; return true; } =20 @@ -3144,13 +3151,11 @@ int gdbserver_start(int port) /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { - GDBState *s =3D gdbserver_state; - - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return; } - close(s->fd); - s->fd =3D -1; + close(gdbserver_state.fd); + gdbserver_state.fd =3D -1; cpu_breakpoint_remove_all(cpu, BP_GDB); cpu_watchpoint_remove_all(cpu, BP_GDB); } @@ -3167,7 +3172,7 @@ static void gdb_chr_receive(void *opaque, const uint8= _t *buf, int size) int i; =20 for (i =3D 0; i < size; i++) { - gdb_read_byte(gdbserver_state, buf[i]); + gdb_read_byte(&gdbserver_state, buf[i]); } } =20 @@ -3210,13 +3215,13 @@ static int gdb_monitor_write(Chardev *chr, const ui= nt8_t *buf, int len) const char *p =3D (const char *)buf; int max_sz; =20 - max_sz =3D (sizeof(gdbserver_state->last_packet) - 2) / 2; + max_sz =3D (sizeof(gdbserver_state.last_packet) - 2) / 2; for (;;) { if (len <=3D max_sz) { - gdb_monitor_output(gdbserver_state, p, len); + gdb_monitor_output(&gdbserver_state, p, len); break; } - gdb_monitor_output(gdbserver_state, p, max_sz); + gdb_monitor_output(&gdbserver_state, p, max_sz); p +=3D max_sz; len -=3D max_sz; } @@ -3308,18 +3313,10 @@ static void create_processes(GDBState *s) create_default_process(s); } =20 -static void cleanup_processes(GDBState *s) -{ - g_free(s->processes); - s->process_num =3D 0; - s->processes =3D NULL; -} - int gdbserver_start(const char *device) { trace_gdbstub_op_start(device); =20 - GDBState *s; char gdbstub_device_name[128]; Chardev *chr =3D NULL; Chardev *mon_chr; @@ -3357,10 +3354,8 @@ int gdbserver_start(const char *device) return -1; } =20 - s =3D gdbserver_state; - if (!s) { - s =3D g_malloc0(sizeof(GDBState)); - gdbserver_state =3D s; + if (!gdbserver_state.init) { + init_gdbserver_state(); =20 qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); =20 @@ -3369,31 +3364,30 @@ int gdbserver_start(const char *device) NULL, NULL, &error_abort); monitor_init_hmp(mon_chr, false, &error_abort); } else { - qemu_chr_fe_deinit(&s->chr, true); - mon_chr =3D s->mon_chr; - cleanup_processes(s); - memset(s, 0, sizeof(GDBState)); - s->mon_chr =3D mon_chr; + qemu_chr_fe_deinit(&gdbserver_state.chr, true); + mon_chr =3D gdbserver_state.mon_chr; + reset_gdbserver_state(); } =20 - create_processes(s); + create_processes(&gdbserver_state); =20 if (chr) { - qemu_chr_fe_init(&s->chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_rec= eive, - gdb_chr_event, NULL, s, NULL, true); + qemu_chr_fe_init(&gdbserver_state.chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&gdbserver_state.chr, gdb_chr_can_receive, + gdb_chr_receive, gdb_chr_event, + NULL, &gdbserver_state, NULL, true); } - s->state =3D chr ? RS_IDLE : RS_INACTIVE; - s->mon_chr =3D mon_chr; - s->current_syscall_cb =3D NULL; + gdbserver_state.state =3D chr ? RS_IDLE : RS_INACTIVE; + gdbserver_state.mon_chr =3D mon_chr; + gdbserver_state.current_syscall_cb =3D NULL; =20 return 0; } =20 void gdbserver_cleanup(void) { - if (gdbserver_state) { - put_packet(gdbserver_state, "W00"); + if (gdbserver_state.init) { + put_packet(&gdbserver_state, "W00"); } } =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584384107; cv=none; d=zohomail.com; s=zohoarc; b=Nf7csfFXRoL76VXK0snF8jThJw9n2Q+E7Mlva0riZ5A8bipW3MX4OmBJzT+J0c0eC2pBRU5VfXEcy6mbVE63Ln7CQqi4o/hNYpziYtQSgmvcUh4IpoNrL7kZQD51IL7y0fOKKgEXLEloidXBWQqljYDbUqUl5e6/5qKqqr74jtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584384107; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rx2PgorG9wNsCNwKpB9RX4PUuS/lmkCjxMOpePB3RnQ=; b=JeMZJ0oYmi0nK8H3CgEyMnQ2kv05s+ZXVK8Ja6YC1CTyk6tw4//hG5cEM2hZc0EBJSFa55yuICd0c9bAGMqueXNdTNoVtL8cZ5V0QTZqxkGKzzmteh6D+Ziqp9fbIg/UuK0n5E027SmMCMKMN3POGVMgSPunOap4HbK9gwhk6A4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584384107172121.81603247493331; Mon, 16 Mar 2020 11:41:47 -0700 (PDT) Received: from localhost ([::1]:46330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDugL-0007IJ-OL for importer@patchew.org; Mon, 16 Mar 2020 14:41:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45292) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRV-0000qo-Gt for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRM-0000CN-Ii for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:21 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33302) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRL-0008Th-TE for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:12 -0400 Received: by mail-wr1-x444.google.com with SMTP id a25so22274115wrd.0 for ; Mon, 16 Mar 2020 10:22:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z6sm720924wrp.95.2020.03.16.10.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C30EF1FF93; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rx2PgorG9wNsCNwKpB9RX4PUuS/lmkCjxMOpePB3RnQ=; b=DJWHn1vEYZR4TQezZaGCP0IyFRwzN5aYbBHWS0fLivhnN864dVBpeOodjjAjLPY09U FKG3VAZP0NiFKGpn6R1wFneADBH3OwTccrmsCGkX7LuZ6KUY9f++j3F9PPoi2TbUJtmz vQeKdyR7jSF+MlbGjvZ5/XTqExZfEIrEmUv+AJtfIL5x+VkzVivKMUjQVRMkuvnDisjK qjRDIt8LZQLcsuie8vHqjhJrstINFn9bHyuiRD/eH85c+McHgprMSBRMip1vQmslQ/De 8CVH5Pj1fn3TRt18xnQVHvzpHGEQBV4TiviZgig57gfBC7/J8sIb4fs8qX33/Mz95YKj cXnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rx2PgorG9wNsCNwKpB9RX4PUuS/lmkCjxMOpePB3RnQ=; b=L5hlqT4G6zY6AbCKqlknBso0ErTfHkW7oC4J+v8utrudy0h1iWXPeDC5SPU4HJ5ohA g/duPcGXjAcCvgdewBWMKVGi2wUTRy3H/m8sjb6u2kYdSYWPr14iZFudWfnci51Ipm0V GCiKJVyhKDgS8/tIHAelsD/aXGaGMtYB/S2vkif+HbsuhsUMl09KAPJvJK6KwZiEg0/r z3JwpnN4QZ76Gk8F4zGMUYNmtDAQCjhSmnluRA8YKuAnkc0+965sFzdhQxaVPZtTFFOJ s+iM+wYP0Yge1W2fELGFAToZGEmYSWr7a5Hcr0oErjlN+GUKRZosb5bStCNu/C6ziurN oZFg== X-Gm-Message-State: ANhLgQ2+H/NxMjL3nVrDuC1YQvJnfng1NVzExGEA4H0oabtISJ5v6F68 4O5UUuKxAKr/sCvMI0JVmip4cg== X-Google-Smtp-Source: ADFU+vs94FjjtoX/Q06+6f+YVsZC/ytHh74c/V5LXUPMzytO44kBzpRN0KgDIs+9L04wOags2UUyZg== X-Received: by 2002:a5d:62d0:: with SMTP id o16mr339873wrv.337.1584379329559; Mon, 16 Mar 2020 10:22:09 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 07/28] gdbstub: stop passing GDBState * around and use global Date: Mon, 16 Mar 2020 17:21:34 +0000 Message-Id: <20200316172155.971-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We only have one GDBState which should be allocated at the time we process any commands. This will make further clean-up a bit easier. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v3 - remove final *s paramters from function calls v4 - a few fixups for coding style --- gdbstub.c | 561 +++++++++++++++++++++++++++--------------------------- 1 file changed, 278 insertions(+), 283 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 57d6e50ddfc..7243a2f7af9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -397,21 +397,21 @@ bool gdb_has_xml; /* XXX: This is not thread safe. Do we care? */ static int gdbserver_fd =3D -1; =20 -static int get_char(GDBState *s) +static int get_char(void) { uint8_t ch; int ret; =20 for(;;) { - ret =3D qemu_recv(s->fd, &ch, 1, 0); + ret =3D qemu_recv(gdbserver_state.fd, &ch, 1, 0); if (ret < 0) { if (errno =3D=3D ECONNRESET) - s->fd =3D -1; + gdbserver_state.fd =3D -1; if (errno !=3D EINTR) return -1; } else if (ret =3D=3D 0) { - close(s->fd); - s->fd =3D -1; + close(gdbserver_state.fd); + gdbserver_state.fd =3D -1; return -1; } else { break; @@ -449,11 +449,11 @@ int use_gdb_syscalls(void) } =20 /* Resume execution. */ -static inline void gdb_continue(GDBState *s) +static inline void gdb_continue(void) { =20 #ifdef CONFIG_USER_ONLY - s->running_state =3D 1; + gdbserver_state.running_state =3D 1; trace_gdbstub_op_continue(); #else if (!runstate_needs_reset()) { @@ -467,7 +467,7 @@ static inline void gdb_continue(GDBState *s) * Resume execution, per CPU actions. For user-mode emulation it's * equivalent to gdb_continue. */ -static int gdb_continue_partial(GDBState *s, char *newstates) +static int gdb_continue_partial(char *newstates) { CPUState *cpu; int res =3D 0; @@ -482,7 +482,7 @@ static int gdb_continue_partial(GDBState *s, char *news= tates) cpu_single_step(cpu, sstep_flags); } } - s->running_state =3D 1; + gdbserver_state.running_state =3D 1; #else int flag =3D 0; =20 @@ -520,13 +520,13 @@ static int gdb_continue_partial(GDBState *s, char *ne= wstates) return res; } =20 -static void put_buffer(GDBState *s, const uint8_t *buf, int len) +static void put_buffer(const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY int ret; =20 while (len > 0) { - ret =3D send(s->fd, buf, len, 0); + ret =3D send(gdbserver_state.fd, buf, len, 0); if (ret < 0) { if (errno !=3D EINTR) return; @@ -538,7 +538,7 @@ static void put_buffer(GDBState *s, const uint8_t *buf,= int len) #else /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, buf, len); + qemu_chr_fe_write_all(&gdbserver_state.chr, buf, len); #endif } =20 @@ -620,17 +620,18 @@ static void hexdump(const char *buf, int len, } =20 /* return -1 if error, 0 if OK */ -static int put_packet_binary(GDBState *s, const char *buf, int len, bool d= ump) +static int put_packet_binary(const char *buf, int len, bool dump) { int csum, i; uint8_t *p; + uint8_t *ps =3D &gdbserver_state.last_packet[0]; =20 if (dump && trace_event_get_state_backends(TRACE_GDBSTUB_IO_BINARYREPL= Y)) { hexdump(buf, len, trace_gdbstub_io_binaryreply); } =20 for(;;) { - p =3D s->last_packet; + p =3D ps; *(p++) =3D '$'; memcpy(p, buf, len); p +=3D len; @@ -642,11 +643,11 @@ static int put_packet_binary(GDBState *s, const char = *buf, int len, bool dump) *(p++) =3D tohex((csum >> 4) & 0xf); *(p++) =3D tohex((csum) & 0xf); =20 - s->last_packet_len =3D p - s->last_packet; - put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); + gdbserver_state.last_packet_len =3D p - ps; + put_buffer(ps, gdbserver_state.last_packet_len); =20 #ifdef CONFIG_USER_ONLY - i =3D get_char(s); + i =3D get_char(); if (i < 0) return -1; if (i =3D=3D '+') @@ -659,11 +660,11 @@ static int put_packet_binary(GDBState *s, const char = *buf, int len, bool dump) } =20 /* return -1 if error, 0 if OK */ -static int put_packet(GDBState *s, const char *buf) +static int put_packet(const char *buf) { trace_gdbstub_io_reply(buf); =20 - return put_packet_binary(s, buf, strlen(buf), false); + return put_packet_binary(buf, strlen(buf), false); } =20 /* Encode data using the encoding for 'x' packets. */ @@ -687,37 +688,38 @@ static int memtox(char *buf, const char *mem, int len) return p - buf; } =20 -static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) +static uint32_t gdb_get_cpu_pid(CPUState *cpu) { /* TODO: In user mode, we should use the task state PID */ if (cpu->cluster_index =3D=3D UNASSIGNED_CLUSTER_INDEX) { /* Return the default process' PID */ - return s->processes[s->process_num - 1].pid; + int index =3D gdbserver_state.process_num - 1; + return gdbserver_state.processes[index].pid; } return cpu->cluster_index + 1; } =20 -static GDBProcess *gdb_get_process(const GDBState *s, uint32_t pid) +static GDBProcess *gdb_get_process(uint32_t pid) { int i; =20 if (!pid) { /* 0 means any process, we take the first one */ - return &s->processes[0]; + return &gdbserver_state.processes[0]; } =20 - for (i =3D 0; i < s->process_num; i++) { - if (s->processes[i].pid =3D=3D pid) { - return &s->processes[i]; + for (i =3D 0; i < gdbserver_state.process_num; i++) { + if (gdbserver_state.processes[i].pid =3D=3D pid) { + return &gdbserver_state.processes[i]; } } =20 return NULL; } =20 -static GDBProcess *gdb_get_cpu_process(const GDBState *s, CPUState *cpu) +static GDBProcess *gdb_get_cpu_process(CPUState *cpu) { - return gdb_get_process(s, gdb_get_cpu_pid(s, cpu)); + return gdb_get_process(gdb_get_cpu_pid(cpu)); } =20 static CPUState *find_cpu(uint32_t thread_id) @@ -733,13 +735,12 @@ static CPUState *find_cpu(uint32_t thread_id) return NULL; } =20 -static CPUState *get_first_cpu_in_process(const GDBState *s, - GDBProcess *process) +static CPUState *get_first_cpu_in_process(GDBProcess *process) { CPUState *cpu; =20 CPU_FOREACH(cpu) { - if (gdb_get_cpu_pid(s, cpu) =3D=3D process->pid) { + if (gdb_get_cpu_pid(cpu) =3D=3D process->pid) { return cpu; } } @@ -747,13 +748,13 @@ static CPUState *get_first_cpu_in_process(const GDBSt= ate *s, return NULL; } =20 -static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) +static CPUState *gdb_next_cpu_in_process(CPUState *cpu) { - uint32_t pid =3D gdb_get_cpu_pid(s, cpu); + uint32_t pid =3D gdb_get_cpu_pid(cpu); cpu =3D CPU_NEXT(cpu); =20 while (cpu) { - if (gdb_get_cpu_pid(s, cpu) =3D=3D pid) { + if (gdb_get_cpu_pid(cpu) =3D=3D pid) { break; } =20 @@ -764,12 +765,12 @@ static CPUState *gdb_next_cpu_in_process(const GDBSta= te *s, CPUState *cpu) } =20 /* Return the cpu following @cpu, while ignoring unattached processes. */ -static CPUState *gdb_next_attached_cpu(const GDBState *s, CPUState *cpu) +static CPUState *gdb_next_attached_cpu(CPUState *cpu) { cpu =3D CPU_NEXT(cpu); =20 while (cpu) { - if (gdb_get_cpu_process(s, cpu)->attached) { + if (gdb_get_cpu_process(cpu)->attached) { break; } =20 @@ -780,29 +781,29 @@ static CPUState *gdb_next_attached_cpu(const GDBState= *s, CPUState *cpu) } =20 /* Return the first attached cpu */ -static CPUState *gdb_first_attached_cpu(const GDBState *s) +static CPUState *gdb_first_attached_cpu(void) { CPUState *cpu =3D first_cpu; - GDBProcess *process =3D gdb_get_cpu_process(s, cpu); + GDBProcess *process =3D gdb_get_cpu_process(cpu); =20 if (!process->attached) { - return gdb_next_attached_cpu(s, cpu); + return gdb_next_attached_cpu(cpu); } =20 return cpu; } =20 -static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) +static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) { GDBProcess *process; CPUState *cpu; =20 if (!pid && !tid) { /* 0 means any process/thread, we take the first attached one */ - return gdb_first_attached_cpu(s); + return gdb_first_attached_cpu(); } else if (pid && !tid) { /* any thread in a specific process */ - process =3D gdb_get_process(s, pid); + process =3D gdb_get_process(pid); =20 if (process =3D=3D NULL) { return NULL; @@ -812,7 +813,7 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_= t pid, uint32_t tid) return NULL; } =20 - return get_first_cpu_in_process(s, process); + return get_first_cpu_in_process(process); } else { /* a specific thread */ cpu =3D find_cpu(tid); @@ -821,7 +822,7 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_= t pid, uint32_t tid) return NULL; } =20 - process =3D gdb_get_cpu_process(s, cpu); + process =3D gdb_get_cpu_process(cpu); =20 if (pid && process->pid !=3D pid) { return NULL; @@ -835,13 +836,13 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint3= 2_t pid, uint32_t tid) } } =20 -static const char *get_feature_xml(const GDBState *s, const char *p, - const char **newp, GDBProcess *process) +static const char *get_feature_xml(const char *p, const char **newp, + GDBProcess *process) { size_t len; int i; const char *name; - CPUState *cpu =3D get_first_cpu_in_process(s, process); + CPUState *cpu =3D get_first_cpu_in_process(process); CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 len =3D 0; @@ -1076,13 +1077,13 @@ static inline void gdb_cpu_breakpoint_remove_all(CP= UState *cpu) #endif } =20 -static void gdb_process_breakpoint_remove_all(const GDBState *s, GDBProces= s *p) +static void gdb_process_breakpoint_remove_all(GDBProcess *p) { - CPUState *cpu =3D get_first_cpu_in_process(s, p); + CPUState *cpu =3D get_first_cpu_in_process(p); =20 while (cpu) { gdb_cpu_breakpoint_remove_all(cpu); - cpu =3D gdb_next_cpu_in_process(s, cpu); + cpu =3D gdb_next_cpu_in_process(cpu); } } =20 @@ -1100,20 +1101,19 @@ static void gdb_breakpoint_remove_all(void) } } =20 -static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) +static void gdb_set_cpu_pc(target_ulong pc) { - CPUState *cpu =3D s->c_cpu; + CPUState *cpu =3D gdbserver_state.c_cpu; =20 cpu_synchronize_state(cpu); cpu_set_pc(cpu, pc); } =20 -static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, - char *buf, size_t buf_size) +static char *gdb_fmt_thread_id(CPUState *cpu, char *buf, size_t buf_size) { - if (s->multiprocess) { + if (gdbserver_state.multiprocess) { snprintf(buf, buf_size, "p%02x.%02x", - gdb_get_cpu_pid(s, cpu), cpu_gdb_index(cpu)); + gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); } else { snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); } @@ -1180,7 +1180,7 @@ static GDBThreadIdKind read_thread_id(const char *buf= , const char **end_buf, * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if the= re is * a format error, 0 on success. */ -static int gdb_handle_vcont(GDBState *s, const char *p) +static int gdb_handle_vcont(const char *p) { int res, signal =3D 0; char cur_action; @@ -1255,36 +1255,36 @@ static int gdb_handle_vcont(GDBState *s, const char= *p) goto out; =20 case GDB_ALL_PROCESSES: - cpu =3D gdb_first_attached_cpu(s); + cpu =3D gdb_first_attached_cpu(); while (cpu) { if (newstates[cpu->cpu_index] =3D=3D 1) { newstates[cpu->cpu_index] =3D cur_action; } =20 - cpu =3D gdb_next_attached_cpu(s, cpu); + cpu =3D gdb_next_attached_cpu(cpu); } break; =20 case GDB_ALL_THREADS: - process =3D gdb_get_process(s, pid); + process =3D gdb_get_process(pid); =20 if (!process->attached) { res =3D -EINVAL; goto out; } =20 - cpu =3D get_first_cpu_in_process(s, process); + cpu =3D get_first_cpu_in_process(process); while (cpu) { if (newstates[cpu->cpu_index] =3D=3D 1) { newstates[cpu->cpu_index] =3D cur_action; } =20 - cpu =3D gdb_next_cpu_in_process(s, cpu); + cpu =3D gdb_next_cpu_in_process(cpu); } break; =20 case GDB_ONE_THREAD: - cpu =3D gdb_get_cpu(s, pid, tid); + cpu =3D gdb_get_cpu(pid, tid); =20 /* invalid CPU/thread specified */ if (!cpu) { @@ -1299,8 +1299,8 @@ static int gdb_handle_vcont(GDBState *s, const char *= p) break; } } - s->signal =3D signal; - gdb_continue_partial(s, newstates); + gdbserver_state.signal =3D signal; + gdb_continue_partial(newstates); =20 out: g_free(newstates); @@ -1409,7 +1409,6 @@ static int cmd_parse_params(const char *data, const c= har *schema, } =20 typedef struct GdbCmdContext { - GDBState *s; GdbCmdVariant *params; int num_params; uint8_t mem_buf[MAX_PACKET_LENGTH]; @@ -1453,7 +1452,7 @@ static inline int startswith(const char *string, cons= t char *pattern) return !strncmp(string, pattern, strlen(pattern)); } =20 -static int process_string_cmd(GDBState *s, void *user_ctx, const char *dat= a, +static int process_string_cmd(void *user_ctx, const char *data, const GdbCmdParseEntry *cmds, int num_cmds) { int i, schema_len, max_num_params =3D 0; @@ -1490,7 +1489,6 @@ static int process_string_cmd(GDBState *s, void *user= _ctx, const char *data, return -1; } =20 - gdb_ctx.s =3D s; cmd->handler(&gdb_ctx, user_ctx); return 0; } @@ -1498,8 +1496,7 @@ static int process_string_cmd(GDBState *s, void *user= _ctx, const char *data, return -1; } =20 -static void run_cmd_parser(GDBState *s, const char *data, - const GdbCmdParseEntry *cmd) +static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) { if (!data) { return; @@ -1507,44 +1504,43 @@ static void run_cmd_parser(GDBState *s, const char = *data, =20 /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ - if (process_string_cmd(s, NULL, data, cmd, 1)) { - put_packet(s, ""); + if (process_string_cmd(NULL, data, cmd, 1)) { + put_packet(""); } } =20 static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) { GDBProcess *process; - GDBState *s =3D gdb_ctx->s; uint32_t pid =3D 1; =20 - if (s->multiprocess) { + if (gdbserver_state.multiprocess) { if (!gdb_ctx->num_params) { - put_packet(s, "E22"); + put_packet("E22"); return; } =20 pid =3D gdb_ctx->params[0].val_ul; } =20 - process =3D gdb_get_process(s, pid); - gdb_process_breakpoint_remove_all(s, process); + process =3D gdb_get_process(pid); + gdb_process_breakpoint_remove_all(process); process->attached =3D false; =20 - if (pid =3D=3D gdb_get_cpu_pid(s, s->c_cpu)) { - s->c_cpu =3D gdb_first_attached_cpu(s); + if (pid =3D=3D gdb_get_cpu_pid(gdbserver_state.c_cpu)) { + gdbserver_state.c_cpu =3D gdb_first_attached_cpu(); } =20 - if (pid =3D=3D gdb_get_cpu_pid(s, s->g_cpu)) { - s->g_cpu =3D gdb_first_attached_cpu(s); + if (pid =3D=3D gdb_get_cpu_pid(gdbserver_state.g_cpu)) { + gdbserver_state.g_cpu =3D gdb_first_attached_cpu(); } =20 - if (!s->c_cpu) { + if (!gdbserver_state.c_cpu) { /* No more process attached */ gdb_syscall_mode =3D GDB_SYS_DISABLED; - gdb_continue(s); + gdb_continue(); } - put_packet(s, "OK"); + put_packet("OK"); } =20 static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1552,33 +1548,33 @@ static void handle_thread_alive(GdbCmdContext *gdb_= ctx, void *user_ctx) CPUState *cpu; =20 if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 if (gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 - cpu =3D gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + cpu =3D gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, gdb_ctx->params[0].thread_id.tid); if (!cpu) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } =20 static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params) { - gdb_set_cpu_pc(gdb_ctx->s, gdb_ctx->params[0].val_ull); + gdb_set_cpu_pc(gdb_ctx->params[0].val_ull); } =20 - gdb_ctx->s->signal =3D 0; - gdb_continue(gdb_ctx->s); + gdbserver_state.signal =3D 0; + gdb_continue(); } =20 static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1593,11 +1589,11 @@ static void handle_cont_with_sig(GdbCmdContext *gdb= _ctx, void *user_ctx) signal =3D gdb_ctx->params[0].val_ul; } =20 - gdb_ctx->s->signal =3D gdb_signal_to_target(signal); - if (gdb_ctx->s->signal =3D=3D -1) { - gdb_ctx->s->signal =3D 0; + gdbserver_state.signal =3D gdb_signal_to_target(signal); + if (gdbserver_state.signal =3D=3D -1) { + gdbserver_state.signal =3D 0; } - gdb_continue(gdb_ctx->s); + gdb_continue(); } =20 static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1605,24 +1601,24 @@ static void handle_set_thread(GdbCmdContext *gdb_ct= x, void *user_ctx) CPUState *cpu; =20 if (gdb_ctx->num_params !=3D 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 if (gdb_ctx->params[1].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 if (gdb_ctx->params[1].thread_id.kind !=3D GDB_ONE_THREAD) { - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); return; } =20 - cpu =3D gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[1].thread_id.pid, + cpu =3D gdb_get_cpu(gdb_ctx->params[1].thread_id.pid, gdb_ctx->params[1].thread_id.tid); if (!cpu) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 @@ -1632,15 +1628,15 @@ static void handle_set_thread(GdbCmdContext *gdb_ct= x, void *user_ctx) */ switch (gdb_ctx->params[0].opcode) { case 'c': - gdb_ctx->s->c_cpu =3D cpu; - put_packet(gdb_ctx->s, "OK"); + gdbserver_state.c_cpu =3D cpu; + put_packet("OK"); break; case 'g': - gdb_ctx->s->g_cpu =3D cpu; - put_packet(gdb_ctx->s, "OK"); + gdbserver_state.g_cpu =3D cpu; + put_packet("OK"); break; default: - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); break; } } @@ -1650,7 +1646,7 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx, = void *user_ctx) int res; =20 if (gdb_ctx->num_params !=3D 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 @@ -1658,14 +1654,14 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx= , void *user_ctx) gdb_ctx->params[1].val_ull, gdb_ctx->params[2].val_ull); if (res >=3D 0) { - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); return; } else if (res =3D=3D -ENOSYS) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } =20 - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); } =20 static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1673,7 +1669,7 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, = void *user_ctx) int res; =20 if (gdb_ctx->num_params !=3D 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 @@ -1681,14 +1677,14 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx= , void *user_ctx) gdb_ctx->params[1].val_ull, gdb_ctx->params[2].val_ull); if (res >=3D 0) { - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); return; } else if (res =3D=3D -ENOSYS) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } =20 - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); } =20 /* @@ -1707,20 +1703,20 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, = void *user_ctx) int reg_size; =20 if (!gdb_has_xml) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } =20 if (gdb_ctx->num_params !=3D 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 reg_size =3D strlen(gdb_ctx->params[1].data) / 2; hextomem(gdb_ctx->mem_buf, gdb_ctx->params[1].data, reg_size); - gdb_write_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_write_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, gdb_ctx->params[0].val_ull); - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } =20 static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1728,73 +1724,73 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, = void *user_ctx) int reg_size; =20 if (!gdb_has_xml) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } =20 if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } =20 - reg_size =3D gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + reg_size =3D gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, gdb_ctx->params[0].val_ull); if (!reg_size) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } =20 memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params !=3D 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 /* hextomem() reads 2*len bytes */ if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, gdb_ctx->params[1].val_ull); - if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_u= ll, + if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].v= al_ull, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull, true)) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } =20 - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } =20 static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params !=3D 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 /* memtohex() doubles the required space */ if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 - if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_u= ll, + if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].v= al_ull, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull, false)) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } =20 memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ul= l); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1807,37 +1803,37 @@ static void handle_write_all_regs(GdbCmdContext *gd= b_ctx, void *user_ctx) return; } =20 - cpu_synchronize_state(gdb_ctx->s->g_cpu); + cpu_synchronize_state(gdbserver_state.g_cpu); registers =3D gdb_ctx->mem_buf; len =3D strlen(gdb_ctx->params[0].data) / 2; hextomem(registers, gdb_ctx->params[0].data, len); - for (addr =3D 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs && len > 0; + for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len >= 0; addr++) { - reg_size =3D gdb_write_register(gdb_ctx->s->g_cpu, registers, addr= ); + reg_size =3D gdb_write_register(gdbserver_state.g_cpu, registers, = addr); len -=3D reg_size; registers +=3D reg_size; } - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } =20 static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) { target_ulong addr, len; =20 - cpu_synchronize_state(gdb_ctx->s->g_cpu); + cpu_synchronize_state(gdbserver_state.g_cpu); len =3D 0; - for (addr =3D 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs; addr++) { - len +=3D gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf + l= en, + for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++)= { + len +=3D gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf= + len, addr); } =20 memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) { - if (gdb_ctx->num_params >=3D 1 && gdb_ctx->s->current_syscall_cb) { + if (gdb_ctx->num_params >=3D 1 && gdbserver_state.current_syscall_cb) { target_ulong ret, err; =20 ret =3D (target_ulong)gdb_ctx->params[0].val_ull; @@ -1846,31 +1842,31 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, = void *user_ctx) } else { err =3D 0; } - gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err); - gdb_ctx->s->current_syscall_cb =3D NULL; + gdbserver_state.current_syscall_cb(gdbserver_state.c_cpu, ret, err= ); + gdbserver_state.current_syscall_cb =3D NULL; } =20 if (gdb_ctx->num_params >=3D 3 && gdb_ctx->params[2].opcode =3D=3D (ui= nt8_t)'C') { - put_packet(gdb_ctx->s, "T02"); + put_packet("T02"); return; } =20 - gdb_continue(gdb_ctx->s); + gdb_continue(); } =20 static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params) { - gdb_set_cpu_pc(gdb_ctx->s, (target_ulong)gdb_ctx->params[0].val_ul= l); + gdb_set_cpu_pc((target_ulong)gdb_ctx->params[0].val_ull); } =20 - cpu_single_step(gdb_ctx->s->c_cpu, sstep_flags); - gdb_continue(gdb_ctx->s); + cpu_single_step(gdbserver_state.c_cpu, sstep_flags); + gdb_continue(); } =20 static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, "vCont;c;C;s;S"); + put_packet("vCont;c;C;s;S"); } =20 static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1881,11 +1877,11 @@ static void handle_v_cont(GdbCmdContext *gdb_ctx, v= oid *user_ctx) return; } =20 - res =3D gdb_handle_vcont(gdb_ctx->s, gdb_ctx->params[0].data); + res =3D gdb_handle_vcont(gdb_ctx->params[0].data); if ((res =3D=3D -EINVAL) || (res =3D=3D -ERANGE)) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); } else if (res) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } =20 @@ -1900,31 +1896,31 @@ static void handle_v_attach(GdbCmdContext *gdb_ctx,= void *user_ctx) goto cleanup; } =20 - process =3D gdb_get_process(gdb_ctx->s, gdb_ctx->params[0].val_ul); + process =3D gdb_get_process(gdb_ctx->params[0].val_ul); if (!process) { goto cleanup; } =20 - cpu =3D get_first_cpu_in_process(gdb_ctx->s, process); + cpu =3D get_first_cpu_in_process(process); if (!cpu) { goto cleanup; } =20 process->attached =3D true; - gdb_ctx->s->g_cpu =3D cpu; - gdb_ctx->s->c_cpu =3D cpu; + gdbserver_state.g_cpu =3D cpu; + gdbserver_state.c_cpu =3D cpu; =20 - gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, thread_id); cleanup: - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) { /* Kill the target */ - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); error_report("QEMU: Terminated via GDBstub"); exit(0); } @@ -1961,10 +1957,10 @@ static void handle_v_commands(GdbCmdContext *gdb_ct= x, void *user_ctx) return; } =20 - if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_v_commands_table, ARRAY_SIZE(gdb_v_commands_table))) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } =20 @@ -1973,7 +1969,7 @@ static void handle_query_qemu_sstepbits(GdbCmdContext= *gdb_ctx, void *user_ctx) snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "ENABLE=3D%x,NOIRQ=3D%x,NOTIMER=3D%x", SSTEP_ENABLE, SSTEP_NOIRQ, SSTEP_NOTIMER); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1983,13 +1979,13 @@ static void handle_set_qemu_sstep(GdbCmdContext *gd= b_ctx, void *user_ctx) } =20 sstep_flags =3D gdb_ctx->params[0].val_ul; - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } =20 static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) { snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%x", sstep_fla= gs); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2003,33 +1999,32 @@ static void handle_query_curr_tid(GdbCmdContext *gd= b_ctx, void *user_ctx) * the first thread of the current process (gdb returns the * first thread). */ - process =3D gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); - cpu =3D get_first_cpu_in_process(gdb_ctx->s, process); - gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + process =3D gdb_get_cpu_process(gdbserver_state.g_cpu); + cpu =3D get_first_cpu_in_process(process); + gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "QC%s", thread_id= ); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) { char thread_id[16]; =20 - if (!gdb_ctx->s->query_cpu) { - put_packet(gdb_ctx->s, "l"); + if (!gdbserver_state.query_cpu) { + put_packet("l"); return; } =20 - gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->query_cpu, thread_id, + gdb_fmt_thread_id(gdbserver_state.query_cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "m%s", thread_id); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); - gdb_ctx->s->query_cpu =3D - gdb_next_attached_cpu(gdb_ctx->s, gdb_ctx->s->query_cpu); + put_packet(gdb_ctx->str_buf); + gdbserver_state.query_cpu =3D gdb_next_attached_cpu(gdbserver_state.qu= ery_cpu); } =20 static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_= ctx) { - gdb_ctx->s->query_cpu =3D gdb_first_attached_cpu(gdb_ctx->s); + gdbserver_state.query_cpu =3D gdb_first_attached_cpu(); handle_query_threads(gdb_ctx, user_ctx); } =20 @@ -2040,11 +2035,11 @@ static void handle_query_thread_extra(GdbCmdContext= *gdb_ctx, void *user_ctx) =20 if (!gdb_ctx->num_params || gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 - cpu =3D gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + cpu =3D gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, gdb_ctx->params[0].thread_id.tid); if (!cpu) { return; @@ -2052,7 +2047,7 @@ static void handle_query_thread_extra(GdbCmdContext *= gdb_ctx, void *user_ctx) =20 cpu_synchronize_state(cpu); =20 - if (gdb_ctx->s->multiprocess && (gdb_ctx->s->process_num > 1)) { + if (gdbserver_state.multiprocess && (gdbserver_state.process_num > 1))= { /* Print the CPU model and name in multiprocess mode */ ObjectClass *oc =3D object_get_class(OBJECT(cpu)); const char *cpu_model =3D object_class_get_name(oc); @@ -2069,7 +2064,7 @@ static void handle_query_thread_extra(GdbCmdContext *= gdb_ctx, void *user_ctx) } trace_gdbstub_op_extra_info((char *)gdb_ctx->mem_buf); memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 #ifdef CONFIG_USER_ONLY @@ -2077,14 +2072,14 @@ static void handle_query_offsets(GdbCmdContext *gdb= _ctx, void *user_ctx) { TaskState *ts; =20 - ts =3D gdb_ctx->s->c_cpu->opaque; + ts =3D gdbserver_state.c_cpu->opaque; snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "Text=3D" TARGET_ABI_FMT_lx ";Data=3D" TARGET_ABI_FMT_lx ";Bss=3D" TARGET_ABI_FMT_lx, ts->info->code_offset, ts->info->data_offset, ts->info->data_offset); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } #else static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2092,21 +2087,21 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ct= x, void *user_ctx) int len; =20 if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 len =3D strlen(gdb_ctx->params[0].data); if (len % 2) { - put_packet(gdb_ctx->s, "E01"); + put_packet("E01"); return; } =20 len =3D len / 2; hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); gdb_ctx->mem_buf[len++] =3D 0; - qemu_chr_be_write(gdb_ctx->s->mon_chr, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->s, "OK"); + qemu_chr_be_write(gdbserver_state.mon_chr, gdb_ctx->mem_buf, len); + put_packet("OK"); =20 } #endif @@ -2125,11 +2120,11 @@ static void handle_query_supported(GdbCmdContext *g= db_ctx, void *user_ctx) =20 if (gdb_ctx->num_params && strstr(gdb_ctx->params[0].data, "multiprocess+")) { - gdb_ctx->s->multiprocess =3D true; + gdbserver_state.multiprocess =3D true; } =20 pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_= ctx) @@ -2141,22 +2136,22 @@ static void handle_query_xfer_features(GdbCmdContex= t *gdb_ctx, void *user_ctx) const char *p; =20 if (gdb_ctx->num_params < 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 - process =3D gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); - cc =3D CPU_GET_CLASS(gdb_ctx->s->g_cpu); + process =3D gdb_get_cpu_process(gdbserver_state.g_cpu); + cc =3D CPU_GET_CLASS(gdbserver_state.g_cpu); if (!cc->gdb_core_xml_file) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } =20 gdb_has_xml =3D true; p =3D gdb_ctx->params[0].data; - xml =3D get_feature_xml(gdb_ctx->s, p, &p, process); + xml =3D get_feature_xml(p, &p, process); if (!xml) { - put_packet(gdb_ctx->s, "E00"); + put_packet("E00"); return; } =20 @@ -2164,7 +2159,7 @@ static void handle_query_xfer_features(GdbCmdContext = *gdb_ctx, void *user_ctx) len =3D gdb_ctx->params[2].val_ul; total_len =3D strlen(xml); if (addr > total_len) { - put_packet(gdb_ctx->s, "E00"); + put_packet("E00"); return; } =20 @@ -2180,12 +2175,12 @@ static void handle_query_xfer_features(GdbCmdContex= t *gdb_ctx, void *user_ctx) len =3D memtox(gdb_ctx->str_buf + 1, xml + addr, total_len - addr); } =20 - put_packet_binary(gdb_ctx->s, gdb_ctx->str_buf, len + 1, true); + put_packet_binary(gdb_ctx->str_buf, len + 1, true); } =20 static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, GDB_ATTACHED); + put_packet(GDB_ATTACHED); } =20 static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user= _ctx) @@ -2194,7 +2189,7 @@ static void handle_query_qemu_supported(GdbCmdContext= *gdb_ctx, void *user_ctx) #ifndef CONFIG_USER_ONLY pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";PhyMemMode"); #endif - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 #ifndef CONFIG_USER_ONLY @@ -2202,13 +2197,13 @@ static void handle_query_qemu_phy_mem_mode(GdbCmdCo= ntext *gdb_ctx, void *user_ctx) { snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_= mode); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } =20 static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *use= r_ctx) { if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } =20 @@ -2217,7 +2212,7 @@ static void handle_set_qemu_phy_mem_mode(GdbCmdContex= t *gdb_ctx, void *user_ctx) } else { phy_memory_mode =3D 1; } - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } #endif =20 @@ -2333,16 +2328,16 @@ static void handle_gen_query(GdbCmdContext *gdb_ctx= , void *user_ctx) return; } =20 - if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } =20 - if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_query_table, ARRAY_SIZE(gdb_gen_query_table))) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } =20 @@ -2352,16 +2347,16 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, = void *user_ctx) return; } =20 - if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } =20 - if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } =20 @@ -2369,11 +2364,11 @@ static void handle_target_halt(GdbCmdContext *gdb_c= tx, void *user_ctx) { char thread_id[16]; =20 - gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->c_cpu, thread_id, + gdb_fmt_thread_id(gdbserver_state.c_cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, thread_id); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2382,7 +2377,7 @@ static void handle_target_halt(GdbCmdContext *gdb_ctx= , void *user_ctx) gdb_breakpoint_remove_all(); } =20 -static int gdb_handle_packet(GDBState *s, const char *line_buf) +static int gdb_handle_packet(const char *line_buf) { const GdbCmdParseEntry *cmd_parser =3D NULL; =20 @@ -2390,7 +2385,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) =20 switch (line_buf[0]) { case '!': - put_packet(s, "OK"); + put_packet("OK"); break; case '?': { @@ -2605,12 +2600,12 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) break; default: /* put empty packet */ - put_packet(s, ""); + put_packet(""); break; } =20 if (cmd_parser) { - run_cmd_parser(s, line_buf, cmd_parser); + run_cmd_parser(line_buf, cmd_parser); } =20 return RS_IDLE; @@ -2618,7 +2613,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) =20 void gdb_set_stop_cpu(CPUState *cpu) { - GDBProcess *p =3D gdb_get_cpu_process(&gdbserver_state, cpu); + GDBProcess *p =3D gdb_get_cpu_process(cpu); =20 if (!p->attached) { /* @@ -2635,19 +2630,18 @@ void gdb_set_stop_cpu(CPUState *cpu) #ifndef CONFIG_USER_ONLY static void gdb_vm_state_change(void *opaque, int running, RunState state) { - GDBState *s =3D &gdbserver_state; - CPUState *cpu =3D s->c_cpu; + CPUState *cpu =3D gdbserver_state.c_cpu; char buf[256]; char thread_id[16]; const char *type; int ret; =20 - if (running || s->state =3D=3D RS_INACTIVE) { + if (running || gdbserver_state.state =3D=3D RS_INACTIVE) { return; } /* Is there a GDB syscall waiting to be sent? */ - if (s->current_syscall_cb) { - put_packet(s, s->syscall_buf); + if (gdbserver_state.current_syscall_cb) { + put_packet(gdbserver_state.syscall_buf); return; } =20 @@ -2656,7 +2650,7 @@ static void gdb_vm_state_change(void *opaque, int run= ning, RunState state) return; } =20 - gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id)); + gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); =20 switch (state) { case RUN_STATE_DEBUG: @@ -2721,7 +2715,7 @@ static void gdb_vm_state_change(void *opaque, int run= ning, RunState state) snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); =20 send_packet: - put_packet(s, buf); + put_packet(buf); =20 /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -2740,8 +2734,9 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, cons= t char *fmt, va_list va) target_ulong addr; uint64_t i64; =20 - if (!gdbserver_state.init) + if (!gdbserver_state.init) { return; + } =20 gdbserver_state.current_syscall_cb =3D cb; #ifndef CONFIG_USER_ONLY @@ -2781,7 +2776,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, cons= t char *fmt, va_list va) } *p =3D 0; #ifdef CONFIG_USER_ONLY - put_packet(&gdbserver_state, gdbserver_state.syscall_buf); + put_packet(gdbserver_state.syscall_buf); /* Return control to gdb for it to process the syscall request. * Since the protocol requires that gdb hands control back to us * using a "here are the results" F packet, we don't need to check @@ -2809,17 +2804,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, con= st char *fmt, ...) va_end(va); } =20 -static void gdb_read_byte(GDBState *s, uint8_t ch) +static void gdb_read_byte(uint8_t ch) { uint8_t reply; =20 #ifndef CONFIG_USER_ONLY - if (s->last_packet_len) { + if (gdbserver_state.last_packet_len) { /* Waiting for a response to the last packet. If we see the start of a new command then abandon the previous response. */ if (ch =3D=3D '-') { trace_gdbstub_err_got_nack(); - put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); + put_buffer((uint8_t *)gdbserver_state.last_packet, gdbserver_s= tate.last_packet_len); } else if (ch =3D=3D '+') { trace_gdbstub_io_got_ack(); } else { @@ -2827,7 +2822,7 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) } =20 if (ch =3D=3D '+' || ch =3D=3D '$') - s->last_packet_len =3D 0; + gdbserver_state.last_packet_len =3D 0; if (ch !=3D '$') return; } @@ -2838,13 +2833,13 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) } else #endif { - switch(s->state) { + switch(gdbserver_state.state) { case RS_IDLE: if (ch =3D=3D '$') { /* start of command packet */ - s->line_buf_index =3D 0; - s->line_sum =3D 0; - s->state =3D RS_GETLINE; + gdbserver_state.line_buf_index =3D 0; + gdbserver_state.line_sum =3D 0; + gdbserver_state.state =3D RS_GETLINE; } else { trace_gdbstub_err_garbage(ch); } @@ -2852,37 +2847,37 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) case RS_GETLINE: if (ch =3D=3D '}') { /* start escape sequence */ - s->state =3D RS_GETLINE_ESC; - s->line_sum +=3D ch; + gdbserver_state.state =3D RS_GETLINE_ESC; + gdbserver_state.line_sum +=3D ch; } else if (ch =3D=3D '*') { /* start run length encoding sequence */ - s->state =3D RS_GETLINE_RLE; - s->line_sum +=3D ch; + gdbserver_state.state =3D RS_GETLINE_RLE; + gdbserver_state.line_sum +=3D ch; } else if (ch =3D=3D '#') { /* end of command, start of checksum*/ - s->state =3D RS_CHKSUM1; - } else if (s->line_buf_index >=3D sizeof(s->line_buf) - 1) { + gdbserver_state.state =3D RS_CHKSUM1; + } else if (gdbserver_state.line_buf_index >=3D sizeof(gdbserve= r_state.line_buf) - 1) { trace_gdbstub_err_overrun(); - s->state =3D RS_IDLE; + gdbserver_state.state =3D RS_IDLE; } else { /* unescaped command character */ - s->line_buf[s->line_buf_index++] =3D ch; - s->line_sum +=3D ch; + gdbserver_state.line_buf[gdbserver_state.line_buf_index++]= =3D ch; + gdbserver_state.line_sum +=3D ch; } break; case RS_GETLINE_ESC: if (ch =3D=3D '#') { /* unexpected end of command in escape sequence */ - s->state =3D RS_CHKSUM1; - } else if (s->line_buf_index >=3D sizeof(s->line_buf) - 1) { + gdbserver_state.state =3D RS_CHKSUM1; + } else if (gdbserver_state.line_buf_index >=3D sizeof(gdbserve= r_state.line_buf) - 1) { /* command buffer overrun */ trace_gdbstub_err_overrun(); - s->state =3D RS_IDLE; + gdbserver_state.state =3D RS_IDLE; } else { /* parse escaped character and leave escape state */ - s->line_buf[s->line_buf_index++] =3D ch ^ 0x20; - s->line_sum +=3D ch; - s->state =3D RS_GETLINE; + gdbserver_state.line_buf[gdbserver_state.line_buf_index++]= =3D ch ^ 0x20; + gdbserver_state.line_sum +=3D ch; + gdbserver_state.state =3D RS_GETLINE; } break; case RS_GETLINE_RLE: @@ -2893,25 +2888,25 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) if (ch < ' ' || ch =3D=3D '#' || ch =3D=3D '$' || ch > 126) { /* invalid RLE count encoding */ trace_gdbstub_err_invalid_repeat(ch); - s->state =3D RS_GETLINE; + gdbserver_state.state =3D RS_GETLINE; } else { /* decode repeat length */ int repeat =3D ch - ' ' + 3; - if (s->line_buf_index + repeat >=3D sizeof(s->line_buf) - = 1) { + if (gdbserver_state.line_buf_index + repeat >=3D sizeof(gd= bserver_state.line_buf) - 1) { /* that many repeats would overrun the command buffer = */ trace_gdbstub_err_overrun(); - s->state =3D RS_IDLE; - } else if (s->line_buf_index < 1) { + gdbserver_state.state =3D RS_IDLE; + } else if (gdbserver_state.line_buf_index < 1) { /* got a repeat but we have nothing to repeat */ trace_gdbstub_err_invalid_rle(); - s->state =3D RS_GETLINE; + gdbserver_state.state =3D RS_GETLINE; } else { /* repeat the last character */ - memset(s->line_buf + s->line_buf_index, - s->line_buf[s->line_buf_index - 1], repeat); - s->line_buf_index +=3D repeat; - s->line_sum +=3D ch; - s->state =3D RS_GETLINE; + memset(gdbserver_state.line_buf + gdbserver_state.line= _buf_index, + gdbserver_state.line_buf[gdbserver_state.line_b= uf_index - 1], repeat); + gdbserver_state.line_buf_index +=3D repeat; + gdbserver_state.line_sum +=3D ch; + gdbserver_state.state =3D RS_GETLINE; } } break; @@ -2919,33 +2914,33 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) /* get high hex digit of checksum */ if (!isxdigit(ch)) { trace_gdbstub_err_checksum_invalid(ch); - s->state =3D RS_GETLINE; + gdbserver_state.state =3D RS_GETLINE; break; } - s->line_buf[s->line_buf_index] =3D '\0'; - s->line_csum =3D fromhex(ch) << 4; - s->state =3D RS_CHKSUM2; + gdbserver_state.line_buf[gdbserver_state.line_buf_index] =3D '= \0'; + gdbserver_state.line_csum =3D fromhex(ch) << 4; + gdbserver_state.state =3D RS_CHKSUM2; break; case RS_CHKSUM2: /* get low hex digit of checksum */ if (!isxdigit(ch)) { trace_gdbstub_err_checksum_invalid(ch); - s->state =3D RS_GETLINE; + gdbserver_state.state =3D RS_GETLINE; break; } - s->line_csum |=3D fromhex(ch); + gdbserver_state.line_csum |=3D fromhex(ch); =20 - if (s->line_csum !=3D (s->line_sum & 0xff)) { - trace_gdbstub_err_checksum_incorrect(s->line_sum, s->line_= csum); + if (gdbserver_state.line_csum !=3D (gdbserver_state.line_sum &= 0xff)) { + trace_gdbstub_err_checksum_incorrect(gdbserver_state.line_= sum, gdbserver_state.line_csum); /* send NAK reply */ reply =3D '-'; - put_buffer(s, &reply, 1); - s->state =3D RS_IDLE; + put_buffer(&reply, 1); + gdbserver_state.state =3D RS_IDLE; } else { /* send ACK reply */ reply =3D '+'; - put_buffer(s, &reply, 1); - s->state =3D gdb_handle_packet(s, s->line_buf); + put_buffer(&reply, 1); + gdbserver_state.state =3D gdb_handle_packet(gdbserver_stat= e.line_buf); } break; default: @@ -2971,7 +2966,7 @@ void gdb_exit(CPUArchState *env, int code) trace_gdbstub_op_exiting((uint8_t)code); =20 snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(&gdbserver_state, buf); + put_packet(buf); =20 #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&gdbserver_state.chr, true); @@ -2988,7 +2983,7 @@ static void create_default_process(GDBState *s) GDBProcess *process; int max_pid =3D 0; =20 - if (s->process_num) { + if (gdbserver_state.process_num) { max_pid =3D s->processes[s->process_num - 1].pid; } =20 @@ -3020,7 +3015,7 @@ gdb_handlesig(CPUState *cpu, int sig) =20 if (sig !=3D 0) { snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); - put_packet(&gdbserver_state, buf); + put_packet(buf); } /* put_packet() might have detected that the peer terminated the connection. */ @@ -3037,7 +3032,7 @@ gdb_handlesig(CPUState *cpu, int sig) int i; =20 for (i =3D 0; i < n; i++) { - gdb_read_byte(&gdbserver_state, buf[i]); + gdb_read_byte(buf[i]); } } else { /* XXX: Connection closed. Should probably wait for another @@ -3064,7 +3059,7 @@ void gdb_signalled(CPUArchState *env, int sig) } =20 snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - put_packet(&gdbserver_state, buf); + put_packet(buf); } =20 static bool gdb_accept(void) @@ -3095,7 +3090,7 @@ static bool gdb_accept(void) init_gdbserver_state(); create_default_process(&gdbserver_state); gdbserver_state.processes[0].attached =3D true; - gdbserver_state.c_cpu =3D gdb_first_attached_cpu(&gdbserver_state); + gdbserver_state.c_cpu =3D gdb_first_attached_cpu(); gdbserver_state.g_cpu =3D gdbserver_state.c_cpu; gdbserver_state.fd =3D fd; gdb_has_xml =3D false; @@ -3172,7 +3167,7 @@ static void gdb_chr_receive(void *opaque, const uint8= _t *buf, int size) int i; =20 for (i =3D 0; i < size; i++) { - gdb_read_byte(&gdbserver_state, buf[i]); + gdb_read_byte(buf[i]); } } =20 @@ -3188,7 +3183,7 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent = event) s->processes[i].attached =3D !i; } =20 - s->c_cpu =3D gdb_first_attached_cpu(s); + s->c_cpu =3D gdb_first_attached_cpu(); s->g_cpu =3D s->c_cpu; =20 vm_stop(RUN_STATE_PAUSED); @@ -3199,7 +3194,7 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent = event) } } =20 -static void gdb_monitor_output(GDBState *s, const char *msg, int len) +static void gdb_monitor_output(const char *msg, int len) { char buf[MAX_PACKET_LENGTH]; =20 @@ -3207,7 +3202,7 @@ static void gdb_monitor_output(GDBState *s, const cha= r *msg, int len) if (len > (MAX_PACKET_LENGTH/2) - 1) len =3D (MAX_PACKET_LENGTH/2) - 1; memtohex(buf + 1, (uint8_t *)msg, len); - put_packet(s, buf); + put_packet(buf); } =20 static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) @@ -3218,10 +3213,10 @@ static int gdb_monitor_write(Chardev *chr, const ui= nt8_t *buf, int len) max_sz =3D (sizeof(gdbserver_state.last_packet) - 2) / 2; for (;;) { if (len <=3D max_sz) { - gdb_monitor_output(&gdbserver_state, p, len); + gdb_monitor_output(p, len); break; } - gdb_monitor_output(&gdbserver_state, p, max_sz); + gdb_monitor_output(p, max_sz); p +=3D max_sz; len -=3D max_sz; } @@ -3305,9 +3300,9 @@ static void create_processes(GDBState *s) { object_child_foreach(object_get_root(), find_cpu_clusters, s); =20 - if (s->processes) { + if (gdbserver_state.processes) { /* Sort by PID */ - qsort(s->processes, s->process_num, sizeof(s->processes[0]), pid_o= rder); + qsort(gdbserver_state.processes, gdbserver_state.process_num, size= of(gdbserver_state.processes[0]), pid_order); } =20 create_default_process(s); @@ -3387,7 +3382,7 @@ int gdbserver_start(const char *device) void gdbserver_cleanup(void) { if (gdbserver_state.init) { - put_packet(&gdbserver_state, "W00"); + put_packet("W00"); } } =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383676; cv=none; d=zohomail.com; s=zohoarc; b=Tb0E0vMAxGsee/eMvJjMfaWwrQeYNSGcoeGbxUdbrUXpXPsjnQhjeJDj+PRv7io3Jri2BczGFVDpFYKD8fnilyTCcdK7USuTX1KN1sfUIS40hekzF27a+pdjBXN3AzRuQ6eyokOUFqSImjt2nSO5inXSJ6wxUaRVw48gOl6TMpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383676; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AW0T0cvnFAF8zal0q3tlses1jKRluFOtig9nPVvZpM8=; b=HeGEVP7rquysVz7fPHrquMMGW86y3GfRrR3Mlno/SGEI5m3cwvYuVOoMTY36GWTa3od01q8bMGNE49PIFBcZTnO+X1bx+n8x3nw/hKJ7MsIUE3fvp97PfzW1VgtsKBBphOGdh+Tvx3ECtOVtn8JX4ddxpeQ5+dEGfu/TnLB3V6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383676795208.0357819596702; Mon, 16 Mar 2020 11:34:36 -0700 (PDT) Received: from localhost ([::1]:46060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuZP-00037a-Na for importer@patchew.org; Mon, 16 Mar 2020 14:34:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45244) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRQ-0000o9-Nj for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRM-0000Cc-Ls for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:16 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40479) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRM-0008Vm-4n for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:12 -0400 Received: by mail-wr1-x442.google.com with SMTP id f3so15286103wrw.7 for ; Mon, 16 Mar 2020 10:22:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t126sm507486wmb.27.2020.03.16.10.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DBB311FF96; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AW0T0cvnFAF8zal0q3tlses1jKRluFOtig9nPVvZpM8=; b=ZwoWICHTOgiQRk7sHMpM8uX5Ogn+N+D2BrADhBN2QvSMV5BAbUc9dKNAYDzNShinUs ff1iFL6lT0HSpNH7dg4fPzDTgngUp9N/d/J8VXwpazR7zwWSfwTH21GXB3rJYssPo6lY 7H5NfugRSzjw7ivQCr3KX4z04vLFGgPwE2zBJC3DMIEnPxI0sWpSCsdkeg/0x3fzn/dc dpakgtGOn3XnsEE7nGQjvsU0t7uxc1+RoHISjU0UXEjQ7QR3srEoR885PmhvSmRoECxH 2cYqsfCvNjUwnhvlo1XF8gX8CTBR0RH+N2iPAru/KxYVbuXg0dHDh4ZZAHh9JH3oRzmq IXvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AW0T0cvnFAF8zal0q3tlses1jKRluFOtig9nPVvZpM8=; b=a+1gQA+6WG+QMGnySDfCmquLa3EGSA5VeOfPQo0IaRt4Rhaz0SJ7Efl+LLMXEABVdW DT/1AmU+Ul2O0FXzoh0T16BGfGZLAo60RiQmsIBqtmDFX9HVJAOWuRv18ogp0s1OvPvu fNgy/4ajzfCfSqouQhg6o02b2T1744O3c7rkE9Gn/F39YHfQNrKJ07NjMyA2S9iEaig6 oC7UDc0NEfKouqyiPjzNcBo1L1bYRKlAyS5qg/aA2Lbkcojpf+Ewv/ZGBEfTk3L2Oaqk gNRbs3c/gMc2IUzfn5IfS/JwG5xLFc7Y77eDfCHLpbPdmXgY7KFOMd4psxtPCVV0+qUV wZsw== X-Gm-Message-State: ANhLgQ1aynBZw0OtvJpP0H4kF3p+dwZN9uK+dIAwzN/iTa6HxNYYR2C3 lhdE9lHl60DB4w/QaTg+/I9oUw== X-Google-Smtp-Source: ADFU+vsSbg0norhAZunpgHW7++KcZMTM4dw/M6oZdX5CgDUMc5KrEsgD+g8QEqB2UkiOiUcphg1ayA== X-Received: by 2002:adf:f80d:: with SMTP id s13mr408528wrp.426.1584379330975; Mon, 16 Mar 2020 10:22:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 08/28] gdbstub: move str_buf to GDBState and use GString Date: Mon, 16 Mar 2020 17:21:35 +0000 Message-Id: <20200316172155.971-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Rather than having a static buffer replace str_buf with a GString which we know can grow on demand. Convert the internal functions to take a GString instead of a char * and length. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Tested-by: Damien Hedde --- v2 - fix conflict from status gdbserver_state - add put_strbuf helper v3 - remove double ;; --- gdbstub.c | 195 +++++++++++++++++++++++++----------------------------- 1 file changed, 90 insertions(+), 105 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 7243a2f7af9..f6b42825445 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -366,6 +366,7 @@ typedef struct GDBState { int process_num; char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; + GString *str_buf; } GDBState; =20 /* By default use no IRQs and no timers while single stepping so as to @@ -380,6 +381,7 @@ static void init_gdbserver_state(void) g_assert(!gdbserver_state.init); memset(&gdbserver_state, 0, sizeof(GDBState)); gdbserver_state.init =3D true; + gdbserver_state.str_buf =3D g_string_new(NULL); } =20 #ifndef CONFIG_USER_ONLY @@ -563,17 +565,15 @@ static inline int tohex(int v) } =20 /* writes 2*len+1 bytes in buf */ -static void memtohex(char *buf, const uint8_t *mem, int len) +static void memtohex(GString *buf, const uint8_t *mem, int len) { int i, c; - char *q; - q =3D buf; for(i =3D 0; i < len; i++) { c =3D mem[i]; - *q++ =3D tohex(c >> 4); - *q++ =3D tohex(c & 0xf); + g_string_append_c(buf, tohex(c >> 4)); + g_string_append_c(buf, tohex(c & 0xf)); } - *q =3D '\0'; + g_string_append_c(buf, '\0'); } =20 static void hextomem(uint8_t *mem, const char *buf, int len) @@ -667,25 +667,28 @@ static int put_packet(const char *buf) return put_packet_binary(buf, strlen(buf), false); } =20 +static void put_strbuf(void) +{ + put_packet(gdbserver_state.str_buf->str); +} + /* Encode data using the encoding for 'x' packets. */ -static int memtox(char *buf, const char *mem, int len) +static void memtox(GString *buf, const char *mem, int len) { - char *p =3D buf; char c; =20 while (len--) { c =3D *(mem++); switch (c) { case '#': case '$': case '*': case '}': - *(p++) =3D '}'; - *(p++) =3D c ^ 0x20; + g_string_append_c(buf, '}'); + g_string_append_c(buf, c ^ 0x20); break; default: - *(p++) =3D c; + g_string_append_c(buf, c); break; } } - return p - buf; } =20 static uint32_t gdb_get_cpu_pid(CPUState *cpu) @@ -1109,16 +1112,14 @@ static void gdb_set_cpu_pc(target_ulong pc) cpu_set_pc(cpu, pc); } =20 -static char *gdb_fmt_thread_id(CPUState *cpu, char *buf, size_t buf_size) +static void gdb_append_thread_id(CPUState *cpu, GString *buf) { if (gdbserver_state.multiprocess) { - snprintf(buf, buf_size, "p%02x.%02x", - gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); + g_string_append_printf(buf, "p%02x.%02x", + gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); } else { - snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); + g_string_append_printf(buf, "%02x", cpu_gdb_index(cpu)); } - - return buf; } =20 typedef enum GDBThreadIdKind { @@ -1412,7 +1413,6 @@ typedef struct GdbCmdContext { GdbCmdVariant *params; int num_params; uint8_t mem_buf[MAX_PACKET_LENGTH]; - char str_buf[MAX_PACKET_LENGTH + 1]; } GdbCmdContext; =20 typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); @@ -1502,6 +1502,8 @@ static void run_cmd_parser(const char *data, const Gd= bCmdParseEntry *cmd) return; } =20 + g_string_set_size(gdbserver_state.str_buf, 0); + /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ if (process_string_cmd(NULL, data, cmd, 1)) { @@ -1740,8 +1742,8 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, vo= id *user_ctx) return; } =20 - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); - put_packet(gdb_ctx->str_buf); + memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, reg_size); + put_strbuf(); } =20 static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1789,8 +1791,8 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, v= oid *user_ctx) return; } =20 - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ul= l); - put_packet(gdb_ctx->str_buf); + memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1]= .val_ull); + put_strbuf(); } =20 static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1827,8 +1829,8 @@ static void handle_read_all_regs(GdbCmdContext *gdb_c= tx, void *user_ctx) addr); } =20 - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->str_buf); + memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, len); + put_strbuf(); } =20 static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1889,9 +1891,8 @@ static void handle_v_attach(GdbCmdContext *gdb_ctx, v= oid *user_ctx) { GDBProcess *process; CPUState *cpu; - char thread_id[16]; =20 - pstrcpy(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "E22"); + g_string_assign(gdbserver_state.str_buf, "E22"); if (!gdb_ctx->num_params) { goto cleanup; } @@ -1910,11 +1911,11 @@ static void handle_v_attach(GdbCmdContext *gdb_ctx,= void *user_ctx) gdbserver_state.g_cpu =3D cpu; gdbserver_state.c_cpu =3D cpu; =20 - gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", - GDB_SIGNAL_TRAP, thread_id); + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TR= AP); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); cleanup: - put_packet(gdb_ctx->str_buf); + put_strbuf(); } =20 static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1966,10 +1967,9 @@ static void handle_v_commands(GdbCmdContext *gdb_ctx= , void *user_ctx) =20 static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user= _ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), - "ENABLE=3D%x,NOIRQ=3D%x,NOTIMER=3D%x", SSTEP_ENABLE, - SSTEP_NOIRQ, SSTEP_NOTIMER); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "ENABLE=3D%x,NOIRQ=3D%x,NOTIM= ER=3D%x", + SSTEP_ENABLE, SSTEP_NOIRQ, SSTEP_NOTIMER); + put_strbuf(); } =20 static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1984,15 +1984,14 @@ static void handle_set_qemu_sstep(GdbCmdContext *gd= b_ctx, void *user_ctx) =20 static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%x", sstep_fla= gs); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "0x%x", sstep_flags); + put_strbuf(); } =20 static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) { CPUState *cpu; GDBProcess *process; - char thread_id[16]; =20 /* * "Current thread" remains vague in the spec, so always return @@ -2001,24 +2000,21 @@ static void handle_query_curr_tid(GdbCmdContext *gd= b_ctx, void *user_ctx) */ process =3D gdb_get_cpu_process(gdbserver_state.g_cpu); cpu =3D get_first_cpu_in_process(process); - gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "QC%s", thread_id= ); - put_packet(gdb_ctx->str_buf); + g_string_assign(gdbserver_state.str_buf, "QC"); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + put_strbuf(); } =20 static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) { - char thread_id[16]; - if (!gdbserver_state.query_cpu) { put_packet("l"); return; } =20 - gdb_fmt_thread_id(gdbserver_state.query_cpu, thread_id, - sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "m%s", thread_id); - put_packet(gdb_ctx->str_buf); + g_string_assign(gdbserver_state.str_buf, "m"); + gdb_append_thread_id(gdbserver_state.query_cpu, gdbserver_state.str_bu= f); + put_strbuf(); gdbserver_state.query_cpu =3D gdb_next_attached_cpu(gdbserver_state.qu= ery_cpu); } =20 @@ -2030,8 +2026,8 @@ static void handle_query_first_threads(GdbCmdContext = *gdb_ctx, void *user_ctx) =20 static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_c= tx) { + g_autoptr(GString) rs =3D g_string_new(NULL); CPUState *cpu; - int len; =20 if (!gdb_ctx->num_params || gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { @@ -2051,20 +2047,17 @@ static void handle_query_thread_extra(GdbCmdContext= *gdb_ctx, void *user_ctx) /* Print the CPU model and name in multiprocess mode */ ObjectClass *oc =3D object_get_class(OBJECT(cpu)); const char *cpu_model =3D object_class_get_name(oc); - char *cpu_name =3D object_get_canonical_path_component(OBJECT(cpu)= ); - len =3D snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf= ) / 2, - "%s %s [%s]", cpu_model, cpu_name, - cpu->halted ? "halted " : "running"); - g_free(cpu_name); + g_autofree char *cpu_name; + cpu_name =3D object_get_canonical_path_component(OBJECT(cpu)); + g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name, + cpu->halted ? "halted " : "running"); } else { - /* memtohex() doubles the required space */ - len =3D snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf= ) / 2, - "CPU#%d [%s]", cpu->cpu_index, + g_string_printf(rs, "CPU#%d [%s]", cpu->cpu_index, cpu->halted ? "halted " : "running"); } - trace_gdbstub_op_extra_info((char *)gdb_ctx->mem_buf); - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->str_buf); + trace_gdbstub_op_extra_info(rs->str); + memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len); + put_strbuf(); } =20 #ifdef CONFIG_USER_ONLY @@ -2073,13 +2066,14 @@ static void handle_query_offsets(GdbCmdContext *gdb= _ctx, void *user_ctx) TaskState *ts; =20 ts =3D gdbserver_state.c_cpu->opaque; - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), - "Text=3D" TARGET_ABI_FMT_lx ";Data=3D" TARGET_ABI_FMT_lx - ";Bss=3D" TARGET_ABI_FMT_lx, - ts->info->code_offset, - ts->info->data_offset, - ts->info->data_offset); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, + "Text=3D" TARGET_ABI_FMT_lx + ";Data=3D" TARGET_ABI_FMT_lx + ";Bss=3D" TARGET_ABI_FMT_lx, + ts->info->code_offset, + ts->info->data_offset, + ts->info->data_offset); + put_strbuf(); } #else static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2110,12 +2104,10 @@ static void handle_query_supported(GdbCmdContext *g= db_ctx, void *user_ctx) { CPUClass *cc; =20 - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "PacketSize=3D%x", - MAX_PACKET_LENGTH); + g_string_printf(gdbserver_state.str_buf, "PacketSize=3D%x", MAX_PACKET= _LENGTH); cc =3D CPU_GET_CLASS(first_cpu); if (cc->gdb_core_xml_file) { - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), - ";qXfer:features:read+"); + g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } =20 if (gdb_ctx->num_params && @@ -2123,8 +2115,8 @@ static void handle_query_supported(GdbCmdContext *gdb= _ctx, void *user_ctx) gdbserver_state.multiprocess =3D true; } =20 - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); - put_packet(gdb_ctx->str_buf); + g_string_append(gdbserver_state.str_buf, ";multiprocess+"); + put_strbuf(); } =20 static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_= ctx) @@ -2168,14 +2160,15 @@ static void handle_query_xfer_features(GdbCmdContex= t *gdb_ctx, void *user_ctx) } =20 if (len < total_len - addr) { - gdb_ctx->str_buf[0] =3D 'm'; - len =3D memtox(gdb_ctx->str_buf + 1, xml + addr, len); + g_string_assign(gdbserver_state.str_buf, "m"); + memtox(gdbserver_state.str_buf, xml + addr, len); } else { - gdb_ctx->str_buf[0] =3D 'l'; - len =3D memtox(gdb_ctx->str_buf + 1, xml + addr, total_len - addr); + g_string_assign(gdbserver_state.str_buf, "l"); + memtox(gdbserver_state.str_buf, xml + addr, total_len - addr); } =20 - put_packet_binary(gdb_ctx->str_buf, len + 1, true); + put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); } =20 static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2185,19 +2178,19 @@ static void handle_query_attached(GdbCmdContext *gd= b_ctx, void *user_ctx) =20 static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user= _ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "sstepbits;sstep"= ); + g_string_printf(gdbserver_state.str_buf, "sstepbits;sstep"); #ifndef CONFIG_USER_ONLY - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";PhyMemMode"); + g_string_append(gdbserver_state.str_buf, ";PhyMemMode"); #endif - put_packet(gdb_ctx->str_buf); + put_strbuf(); } =20 #ifndef CONFIG_USER_ONLY static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_= mode); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); + put_strbuf(); } =20 static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *use= r_ctx) @@ -2362,13 +2355,10 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, = void *user_ctx) =20 static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) { - char thread_id[16]; - - gdb_fmt_thread_id(gdbserver_state.c_cpu, thread_id, - sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", - GDB_SIGNAL_TRAP, thread_id); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TR= AP); + gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + put_strbuf(); /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2631,8 +2621,8 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { CPUState *cpu =3D gdbserver_state.c_cpu; - char buf[256]; - char thread_id[16]; + g_autoptr(GString) buf =3D g_string_new(NULL); + g_autoptr(GString) tid =3D g_string_new(NULL); const char *type; int ret; =20 @@ -2650,7 +2640,7 @@ static void gdb_vm_state_change(void *opaque, int run= ning, RunState state) return; } =20 - gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); + gdb_append_thread_id(cpu, tid); =20 switch (state) { case RUN_STATE_DEBUG: @@ -2668,10 +2658,9 @@ static void gdb_vm_state_change(void *opaque, int ru= nning, RunState state) } trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); - snprintf(buf, sizeof(buf), - "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, thread_id, type, - (target_ulong)cpu->watchpoint_hit->vaddr); + g_string_printf(buf, "T%02xthread:%s;%swatch:" TARGET_FMT_lx "= ;", + GDB_SIGNAL_TRAP, tid->str, type, + (target_ulong)cpu->watchpoint_hit->vaddr); cpu->watchpoint_hit =3D NULL; goto send_packet; } else { @@ -2712,10 +2701,10 @@ static void gdb_vm_state_change(void *opaque, int r= unning, RunState state) break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); + g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); =20 send_packet: - put_packet(buf); + put_packet(buf->str); =20 /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -3196,13 +3185,9 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent= event) =20 static void gdb_monitor_output(const char *msg, int len) { - char buf[MAX_PACKET_LENGTH]; - - buf[0] =3D 'O'; - if (len > (MAX_PACKET_LENGTH/2) - 1) - len =3D (MAX_PACKET_LENGTH/2) - 1; - memtohex(buf + 1, (uint8_t *)msg, len); - put_packet(buf); + g_autoptr(GString) buf =3D g_string_new("O"); + memtohex(buf, (uint8_t *)msg, len); + put_packet(buf->str); } =20 static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584382133; cv=none; d=zohomail.com; s=zohoarc; b=Yt/AEeMz6tJCUppOsfxYAt5qw4dZf6etggqzZ992MsuEyVH7cvZ6tflFQQ84mdr7jql6WnTHZCp40Zp/Nso5Q/QffDOwf/NenV9N3eQJOLBGjGPak0inIf8zq+BS/q0RCswo5JlTDmay2L7+Wcf9fXVcFNv9GwMO/zb2YUtp/ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584382133; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YMlB9rnlkVZWq7aBeAA4aFi+84nzrz8PdlJho1DInq4=; b=TYHnUF7b8GvQOngJP96lvCPuR0e2aWauE3Xi795amgjcy+Pvx/oWDj3pOGs3ieAAaWhiGjC4skmNGEKi1I+y9EvBrg2jaY67pg2ZaHyCk1ApsXWUt69cHe1/XnS0Oq0j6wZiDg+1UbuBHWDt+Uas6ayGBRVME+qWQ9AarRWyNYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584382133131692.5772826934666; Mon, 16 Mar 2020 11:08:53 -0700 (PDT) Received: from localhost ([::1]:45326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuAV-00004v-W5 for importer@patchew.org; Mon, 16 Mar 2020 14:08:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45374) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRY-0000vU-5q for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRW-00012A-77 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:23 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36699) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRV-0000vP-Iv for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:21 -0400 Received: by mail-wr1-x444.google.com with SMTP id s5so22319150wrg.3 for ; Mon, 16 Mar 2020 10:22:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l26sm417018wmi.37.2020.03.16.10.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F07D21FF98; Mon, 16 Mar 2020 17:21:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YMlB9rnlkVZWq7aBeAA4aFi+84nzrz8PdlJho1DInq4=; b=eycMvEjub0i5emzZ1DOfsnTttyLBPiy5DmlNj5r6vpWOvo0NWSboY1G7RzK0qCnuCx 3zcqL0fAedsyKdgCVXm0gTjlCmuowoPOGYWpQdltcKbwULEXeYKSJBZ1yItjwX6aPhFo 3VU1osJPm42L0U6tqTZe+cE3VtSVR+AOK/qJJ1ejWhMYuEx80P75zHcfeuK7kH/T84J+ 89rYg8GTKCP/gGJY07w4yup+r8vnnsYjc+u2n5ccc0/c3mPCiNQO5f6fdApGFChpMLWF XKVwXY3V+RwA7UMlDH2TjLnBUbV7vGyAk8A5O8qIyHYa6hGZjOCuXyKd+/mDdVjb+5W0 KEnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YMlB9rnlkVZWq7aBeAA4aFi+84nzrz8PdlJho1DInq4=; b=f3Y8BB7xUa3t62po4LVUNWK4LI4w0TcV24CVJC6e5DzT9SCIQQooEVhuLq5+27eiIJ VlzyWp2Q+ZPeEDsmIR5BudYv6fLeDs+Oa9deRffneVEuGHIslyhGKlx9Wm34HFUV/NXJ jzoboPrbasD728XJHL1Wph1YaCvkSS6sFUy/Mi+LCZkr4FwYAKiCEPkzdgyzVWJmgvtQ TXvO7kyBwUUWO94Z9EnpdFlkHyeHZGOKZLeVF2R7m87lzk1VnHx1ymQ5HsS6jkxzu4Wv Wb9t4zlficPBzicsHObkxpaE1oLkzF+tTEPFTvzomyOpfZVqxruA9M7fkrb3WqdSxUB4 fO9Q== X-Gm-Message-State: ANhLgQ330utMXVLuT4hsdnefH18vsCeDJTKK6C07tJffaicuwmLhMlOQ T1XgtLR1Dj5RkWAPVC5FZ9/nzg== X-Google-Smtp-Source: ADFU+vt8uFGwoe5APsmUStPp4qEec6TZDxyjy4aZUvNb4VeRBhgGxxmJwRa69Nq9I4K26PCWLqrcqg== X-Received: by 2002:a5d:4ad1:: with SMTP id y17mr370285wrs.119.1584379340279; Mon, 16 Mar 2020 10:22:20 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 09/28] gdbstub: move mem_buf to GDBState and use GByteArray Date: Mon, 16 Mar 2020 17:21:36 +0000 Message-Id: <20200316172155.971-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is in preparation for further re-factoring of the register API with the rest of the code. Theoretically the read register function could overwrite the MAX_PACKET_LENGTH buffer although currently all registers are well within the size range. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Tested-by: Damien Hedde --- v4 - don't set_set to len on rcmd (it's zeroed before we get here) v3 - fixed up email on Damien's tags --- gdbstub.c | 56 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index f6b42825445..db537a712cc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -367,6 +367,7 @@ typedef struct GDBState { char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; GString *str_buf; + GByteArray *mem_buf; } GDBState; =20 /* By default use no IRQs and no timers while single stepping so as to @@ -382,6 +383,7 @@ static void init_gdbserver_state(void) memset(&gdbserver_state, 0, sizeof(GDBState)); gdbserver_state.init =3D true; gdbserver_state.str_buf =3D g_string_new(NULL); + gdbserver_state.mem_buf =3D g_byte_array_sized_new(MAX_PACKET_LENGTH); } =20 #ifndef CONFIG_USER_ONLY @@ -576,12 +578,13 @@ static void memtohex(GString *buf, const uint8_t *mem= , int len) g_string_append_c(buf, '\0'); } =20 -static void hextomem(uint8_t *mem, const char *buf, int len) +static void hextomem(GByteArray *mem, const char *buf, int len) { int i; =20 for(i =3D 0; i < len; i++) { - mem[i] =3D (fromhex(buf[0]) << 4) | fromhex(buf[1]); + guint8 byte =3D fromhex(buf[0]) << 4 | fromhex(buf[1]); + g_byte_array_append(mem, &byte, 1); buf +=3D 2; } } @@ -1412,7 +1415,6 @@ static int cmd_parse_params(const char *data, const c= har *schema, typedef struct GdbCmdContext { GdbCmdVariant *params; int num_params; - uint8_t mem_buf[MAX_PACKET_LENGTH]; } GdbCmdContext; =20 typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); @@ -1503,6 +1505,7 @@ static void run_cmd_parser(const char *data, const Gd= bCmdParseEntry *cmd) } =20 g_string_set_size(gdbserver_state.str_buf, 0); + g_byte_array_set_size(gdbserver_state.mem_buf, 0); =20 /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ @@ -1715,8 +1718,8 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, vo= id *user_ctx) } =20 reg_size =3D strlen(gdb_ctx->params[1].data) / 2; - hextomem(gdb_ctx->mem_buf, gdb_ctx->params[1].data, reg_size); - gdb_write_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[1].data, reg_size); + gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->dat= a, gdb_ctx->params[0].val_ull); put_packet("OK"); } @@ -1735,14 +1738,17 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, = void *user_ctx) return; } =20 - reg_size =3D gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, + reg_size =3D gdb_read_register(gdbserver_state.g_cpu, + gdbserver_state.mem_buf->data, gdb_ctx->params[0].val_ull); if (!reg_size) { put_packet("E14"); return; + } else { + g_byte_array_set_size(gdbserver_state.mem_buf, reg_size); } =20 - memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, reg_size); + memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, reg_s= ize); put_strbuf(); } =20 @@ -1759,11 +1765,11 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx= , void *user_ctx) return; } =20 - hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[2].data, gdb_ctx->params[1].val_ull); if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].v= al_ull, - gdb_ctx->mem_buf, - gdb_ctx->params[1].val_ull, true)) { + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, true)) { put_packet("E14"); return; } @@ -1784,14 +1790,17 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx,= void *user_ctx) return; } =20 + g_byte_array_set_size(gdbserver_state.mem_buf, gdb_ctx->params[1].val_= ull); + if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].v= al_ull, - gdb_ctx->mem_buf, - gdb_ctx->params[1].val_ull, false)) { + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, false)) { put_packet("E14"); return; } =20 - memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1]= .val_ull); + memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len); put_strbuf(); } =20 @@ -1806,9 +1815,9 @@ static void handle_write_all_regs(GdbCmdContext *gdb_= ctx, void *user_ctx) } =20 cpu_synchronize_state(gdbserver_state.g_cpu); - registers =3D gdb_ctx->mem_buf; len =3D strlen(gdb_ctx->params[0].data) / 2; - hextomem(registers, gdb_ctx->params[0].data, len); + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + registers =3D gdbserver_state.mem_buf->data; for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len >= 0; addr++) { reg_size =3D gdb_write_register(gdbserver_state.g_cpu, registers, = addr); @@ -1825,11 +1834,14 @@ static void handle_read_all_regs(GdbCmdContext *gdb= _ctx, void *user_ctx) cpu_synchronize_state(gdbserver_state.g_cpu); len =3D 0; for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++)= { - len +=3D gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf= + len, + len +=3D gdb_read_register(gdbserver_state.g_cpu, + gdbserver_state.mem_buf->data + len, addr); } + /* FIXME: This is after the fact sizing */ + g_byte_array_set_size(gdbserver_state.mem_buf, len); =20 - memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, len); + memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); put_strbuf(); } =20 @@ -2078,6 +2090,7 @@ static void handle_query_offsets(GdbCmdContext *gdb_c= tx, void *user_ctx) #else static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) { + const guint8 zero =3D 0; int len; =20 if (!gdb_ctx->num_params) { @@ -2091,12 +2104,13 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ct= x, void *user_ctx) return; } =20 + g_assert(gdbserver_state.mem_buf->len =3D=3D 0); len =3D len / 2; - hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); - gdb_ctx->mem_buf[len++] =3D 0; - qemu_chr_be_write(gdbserver_state.mon_chr, gdb_ctx->mem_buf, len); + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); + qemu_chr_be_write(gdbserver_state.mon_chr, gdbserver_state.mem_buf->da= ta, + gdbserver_state.mem_buf->len); put_packet("OK"); - } #endif =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584380854; cv=none; d=zohomail.com; s=zohoarc; b=DJs5R8fTZ3oUQ6PbXD4/sD53XyakVpImD3g6ZbI6iPSClZ2M+WcDPk4jNZ/9vSjFFUBda5o0d10KSD4fZgpXkEwyKrt6fbQSCALI0don+Ltf6Y2pLlbwuLhHWHGwBTe64bCxwvYzMoqPhXlt1wHyYUOZPELb4Y72aPiO3gvjDwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584380854; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KcowZQvidWsL6K9vNr5PA0mK1ZdxCgzSQNRXFm9TCF8=; b=LYZ0SMdEbmFIlNXdG/xDCCerrDD+rgRoZFf0WuScx0aiE+HHEoTJjjZvpcBSxUxpVcudlsGpDuxWu7ElnLyxjb6OMlndqTY99ajmNCaPDtUFY4MMCvY7Xhvgv30JjTkbLOt9xSDw59FKYe/sdGy2FdyrvcdZ2UudODO9eYIpwXQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584380854435159.56332475504792; Mon, 16 Mar 2020 10:47:34 -0700 (PDT) Received: from localhost ([::1]:44775 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtpt-0003FT-BO for importer@patchew.org; Mon, 16 Mar 2020 13:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45108) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRM-0000dT-9K for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRJ-0008Hm-3f for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:12 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38045) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRI-0008Af-PD for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:08 -0400 Received: by mail-wr1-x442.google.com with SMTP id s1so537139wrv.5 for ; Mon, 16 Mar 2020 10:22:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n6sm460988wmn.13.2020.03.16.10.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 11E4B1FF99; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KcowZQvidWsL6K9vNr5PA0mK1ZdxCgzSQNRXFm9TCF8=; b=O65mI6S1wghhbDmZGb4kMT2DANfOqEHorC4qwoQPHMJCzjoMPAkjP4jqfPM/05mU/U spKNsYXasfvwGbMI0VTaWHGB8cVg+hDrHJSSoXHgBp+7Kj2uCKhGgxjIA6w2EkPlT+Qy ZqkDGgJspqo7mRjDTuFoDaNXkO6ORIxVABgd9iJVlUyKf+JuH+p+K0l9zRF5iwP+Gj+K MwQT2CittElXYO7F4qppuCGAMtpbp6A1ESzR8dkJ+M7nOviS94PS0DzJ77VY8UlgnQMj EE0CtM5aQieW01lY80gxxTzVH6N3om9IOUmlqqddFIRf10OSMkXbII9ZkS+zWeh3RaFe A1Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KcowZQvidWsL6K9vNr5PA0mK1ZdxCgzSQNRXFm9TCF8=; b=uEJNCYsBp8gCxy/Cj6tY6NhZDD9U2Mf/1ruNcSJFKeBn1rTBRKwPh9k1+Ri6ZI9gmo IiQaZx9BYiMKrfbJRzDCzIDsO/Mqu5FZcUHyyeeY3lQzk69sU7GXwr6Jm07kwDC9rByk S/30/jMDoZ+Y2KAHOpxUTkRwTeetXTrwxeTXLTk3FLNEfVLQY0f1FQoqGccDqiA72ltf DFfUUhsGYrjLbnrb98TvfWFIqJPBURmtarNznCsnQ5gH8/DT3FuhfXBmzx8qkh5jTWZx W1PF87FliHYOZzFto/jnZZd3LSKvU8VDhsbDGXWolXakdkCD/aycJIdUlR40UX8x/p1l SKoA== X-Gm-Message-State: ANhLgQ3esbOQbpt919/gQIg+ikOAadaxBz4BkwoaI1L3mdN1Zxlm6E9a msYrkDvlK6JpoMNT376/bhxOvQ== X-Google-Smtp-Source: ADFU+vtqfxNnNe9C4oS0NYzhtcXzWASHHXW36WvL0X0M1eTUondQrZmNah97qVvcfm9lCI4LFc4RWQ== X-Received: by 2002:adf:e50d:: with SMTP id j13mr431884wrm.34.1584379327687; Mon, 16 Mar 2020 10:22:07 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 10/28] gdbstub: add helper for 128 bit registers Date: Mon, 16 Mar 2020 17:21:37 +0000 Message-Id: <20200316172155.971-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2 - take care of endianess of the whole 128 bit word --- include/exec/gdbstub.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 08363969c14..59e366ba3af 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -102,6 +102,19 @@ static inline int gdb_get_reg64(uint8_t *mem_buf, uint= 64_t val) return 8; } =20 +static inline int gdb_get_reg128(uint8_t *mem_buf, uint64_t val_hi, + uint64_t val_lo) +{ +#ifdef TARGET_WORDS_BIGENDIAN + stq_p(mem_buf, val_hi); + stq_p(mem_buf + 8, val_lo); +#else + stq_p(mem_buf, val_lo); + stq_p(mem_buf + 8, val_hi); +#endif + return 16; +} + #if TARGET_LONG_BITS =3D=3D 64 #define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) #define ldtul_p(addr) ldq_p(addr) --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383912; cv=none; d=zohomail.com; s=zohoarc; b=aLrKWJuKqaYa1d4KlwLhrs96DwzhrbFb07KdOFsyQn3BnE5Xkb5fKFsgByfSrt85IfaF2tyzLs2jmpSA8qdDihJl8KYoMQvsOlbXFrnh+qUAIkjkF87gO/2qGwaAUhRzaSByI1VocbcIEpuLze7/2UMjHF/4+aEYAIFjSZcPvxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383912; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=52E0x1HbvIq1AGgecckQBDYD7WRAAr/qdglgq3wleWk=; b=ffq/vRp0OmwSp3nQFoElpugXq52mNY06/S3Z1yaTwWqRun9q3m8QRF0w+vzwE8EG+6nAasPcNrHGwMFfRRB3QuKJfxp8F/dRyz2+6kEB34MXFcYkpx9NsSoAKpXroLC4yqIOqpMGOSQRsx6jVMVxjG+gxh+R7JPnKQv98P4SXZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383912309170.10767940145945; Mon, 16 Mar 2020 11:38:32 -0700 (PDT) Received: from localhost ([::1]:46196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDudD-0001lZ-AR for importer@patchew.org; Mon, 16 Mar 2020 14:38:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45363) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRX-0000un-Rk for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRW-00012S-4y for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:23 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36695) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRV-0000up-II for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:21 -0400 Received: by mail-wr1-x441.google.com with SMTP id s5so22318941wrg.3 for ; Mon, 16 Mar 2020 10:22:18 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l64sm463140wmf.30.2020.03.16.10.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 265BA1FF9A; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=52E0x1HbvIq1AGgecckQBDYD7WRAAr/qdglgq3wleWk=; b=ASD5c37Hp/yOpT2AMQ8G8x7ETDDTSgCgW9W9dcT7bYZSdBHHDLBEic0bcLYorgB0tM jGT31fT9VMqBfTFQ4kk/6mXERJc5swGAsqFZVnniyCJP7AyLbzqQ4fWItCaSfG9s1HQk 8yg50aD5Ui5UPR7GsxkdJ4CYhcgoLy/foE4Gs/OltB8dzzXz7JJj5TQOQYkjgFaZA9z5 k9wIq3AT9G0hfo6zd4WmSHFP+vKa8J8AsubpgFD/Gvgmbx8IPvAPIhSBAR90wnEfvCVr rEmzDK3lD+EqYbW00BfGx3VVED5KqWv1mn2FMpfmmTl+wgW6pXPD4qxMBl3y0gGPFg/i K7aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=52E0x1HbvIq1AGgecckQBDYD7WRAAr/qdglgq3wleWk=; b=SgGvoFmd0qSmyd3GIotBn+MmLF4pJBWHETLAU0XN3MhCuETQ5dEMJynI3SY/kR70Ll 7ZPH2Hj8XYb6FOJo0/p6B4C2pT+VT1/U/qhOD9fl2caUHzSgGOIyuB4h5vfveZkLeR6r QdHCpMw0kupktL+QtIItbLav/Hg9tGevgAjJyTPpc2gV/kqpHYQe0jer4/iJ4ILtJdou apa08JLvn3M//XFYTcGhbocVqNuMKJUEZkIcxO0uNPSVJqUXHA+LonK0aGak3pck97Df tv35JknAhAFahIZdgyQlakWqtE60ICehi3CpkBv54xsSVzz1Pva6cM28XFtukkySYLsh KCrQ== X-Gm-Message-State: ANhLgQ19/L9aG5i8A/1/q5AxRhLUpCXkSA0wIk4mGMRryVTslOB18iFw qjzF1G9l9abyrEkBfPhDOk/dug== X-Google-Smtp-Source: ADFU+vsXYlOPAvvYhX10BRcGGDmhSdyN/NQH01aDX1wJvplH3Pjvrl5RuGZg9SXwsNkaTr7JjjXQXw== X-Received: by 2002:adf:f688:: with SMTP id v8mr405847wrp.344.1584379337878; Mon, 16 Mar 2020 10:22:17 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 11/28] target/arm: use gdb_get_reg helpers Date: Mon, 16 Mar 2020 17:21:38 +0000 Message-Id: <20200316172155.971-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is cleaner than poking memory directly and will make later clean-ups easier. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2 - make sure we pass hi/lo correctly as quads are stored in LE order --- target/arm/helper.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index b61ee73d18a..69104fb351d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -106,21 +106,17 @@ static int aarch64_fpu_gdb_get_reg(CPUARMState *env, = uint8_t *buf, int reg) { switch (reg) { case 0 ... 31: - /* 128 bit FP register */ - { - uint64_t *q =3D aa64_vfp_qreg(env, reg); - stq_le_p(buf, q[0]); - stq_le_p(buf + 8, q[1]); - return 16; - } + { + /* 128 bit FP register - quads are in LE order */ + uint64_t *q =3D aa64_vfp_qreg(env, reg); + return gdb_get_reg128(buf, q[1], q[0]); + } case 32: /* FPSR */ - stl_p(buf, vfp_get_fpsr(env)); - return 4; + return gdb_get_reg32(buf, vfp_get_fpsr(env)); case 33: /* FPCR */ - stl_p(buf, vfp_get_fpcr(env)); - return 4; + return gdb_get_reg32(buf,vfp_get_fpcr(env)); default: return 0; } --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584382225; cv=none; d=zohomail.com; s=zohoarc; b=dp9cQKCqcLYXgm10JnSMVY496FKXDgYT+lWIvZdixygDUxQLLmoD3Pzhyy0DRbd3PaWcy3oKAtPDAMeG5ba6MXlsdnPi4XkQclH1XSU87W6rz9WE9LB1SKAHgU1MMJVVGo5GMTIu5AqOMJfLzz8k1G1aTs1W1T8zgZONcbGc3OM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584382225; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5wBDeZKmYofKOsnZiNwMAFl1gvv88UQfd1fG073rc/U=; b=AqJ+LgGsD/3DWwOw9/AskX3szy3VCNygR/mNhllMpCOemugW47LPcXKKocpfRq9N3TbMKlqV0Jwo32tfyGNO75x3j2pl4K2LI4ROd4UDbPcpdMl6Hw5I9WuNYpZlrwV19MY/26aHqIUwkyDBYgxf18Z3zJYeHvfq8GaQHiMnCYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584382225037917.7462181918257; Mon, 16 Mar 2020 11:10:25 -0700 (PDT) Received: from localhost ([::1]:45388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuBz-00049h-Vj for importer@patchew.org; Mon, 16 Mar 2020 14:10:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45434) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRZ-0000z0-R0 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRW-00015y-SV for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:25 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:35360) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRW-00011D-Lw for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:22 -0400 Received: by mail-wm1-x344.google.com with SMTP id m3so18986520wmi.0 for ; Mon, 16 Mar 2020 10:22:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s131sm417588wmf.35.2020.03.16.10.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3A6731FF9B; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5wBDeZKmYofKOsnZiNwMAFl1gvv88UQfd1fG073rc/U=; b=O/ZHaq+4jqJ1zeOhhv8adHC0sTLb41OJphB8gOFfwFNIKK95KvhUhpcoZx1htTfaph 3EzpkoPgrc92HV79JPkUZe709WIGflu3o5NOD8MYgtFSuI7frK5hb0sI8tg0cN6to/GE jH8P5+JC+glZ0b52Za1WCK3Jp4NNo6erz7TTLV5rjwXE8BU0k6j3898SnN5+DLn1X4W+ rdHqYQH/aPcvPSPwzbT2f1ROyt69pU+Y0IfI1Y25I6w6NC3kIvBX7F8FL3FNLhUuXVCs MSY5WSeisnVTkBDbEV832Q2VGMLYYYvHf70kvvGWsablTuYkvKHKlYmN2D6FVNgxzZeb jLsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5wBDeZKmYofKOsnZiNwMAFl1gvv88UQfd1fG073rc/U=; b=BHXpytI6j7bdQK1Xewrw+CYuc3Uwzw5Zy4kH1l4O1KpMSVzNG5ft4RWmds3qmhqR+N 8+TaPodj6WU7i68IFhEw3huyaHjFFxEW2zZUfxlnYLGN4VhdAzDwKClIun/oc4cI/O86 HiKiQQawIWQSRULRpiMlh/DQT7xoWtX2UaG/ZjfUlGHZnLKTzsEJCOiM2WTEfpWt2A6V VxUB2MmprjyM2KnaujyxzBe8EXYChq1zsmckDy5dJAgwgTjD3D/w9EEHQpoIbQf5bmBN Td5MPKWfvpe/RSFJ51slai8+gCAJHh9LUVSumLzr7tYMW5yz//UiLhsni0CGLtln9KPP I8fA== X-Gm-Message-State: ANhLgQ3tU3oDuaBjh0Nw6fRDBQbKXmbSgqeTc2i+po56THJYc10V9isB xXoQ9y43gODOwZCUhaKejw0Sng== X-Google-Smtp-Source: ADFU+vtepgVND9dXrAr3lAHeZb1+zcrFt059iGnfun1ovyDggTxuhLjwSvm26r+2aJzf4HmXxKpT1Q== X-Received: by 2002:a7b:c5cd:: with SMTP id n13mr156570wmk.172.1584379341542; Mon, 16 Mar 2020 10:22:21 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 12/28] target/m68k: use gdb_get_reg helpers Date: Mon, 16 Mar 2020 17:21:39 +0000 Message-Id: <20200316172155.971-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is cleaner than poking memory directly and will make later clean-ups easier. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v3 - fix mem_buf references - fix mem_buf + len cases --- target/m68k/helper.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index baf7729af00..c23b70f854d 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -72,19 +72,15 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, uint8_= t *mem_buf, int n) { if (n < 8) { float_status s; - stfq_p(mem_buf, floatx80_to_float64(env->fregs[n].d, &s)); - return 8; + return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d,= &s)); } switch (n) { case 8: /* fpcontrol */ - stl_be_p(mem_buf, env->fpcr); - return 4; + return gdb_get_reg32(mem_buf, env->fpcr); case 9: /* fpstatus */ - stl_be_p(mem_buf, env->fpsr); - return 4; + return gdb_get_reg32(mem_buf, env->fpsr); case 10: /* fpiar, not implemented */ - memset(mem_buf, 0, 4); - return 4; + return gdb_get_reg32(mem_buf, 0); } return 0; } @@ -112,21 +108,18 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint= 8_t *mem_buf, int n) static int m68k_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) { if (n < 8) { - stw_be_p(mem_buf, env->fregs[n].l.upper); - memset(mem_buf + 2, 0, 2); - stq_be_p(mem_buf + 4, env->fregs[n].l.lower); - return 12; + int len =3D gdb_get_reg16(mem_buf, env->fregs[n].l.upper); + len +=3D gdb_get_reg16(mem_buf + len, 0); + len +=3D gdb_get_reg64(mem_buf + len, env->fregs[n].l.lower); + return len; } switch (n) { case 8: /* fpcontrol */ - stl_be_p(mem_buf, env->fpcr); - return 4; + return gdb_get_reg32(mem_buf, env->fpcr); case 9: /* fpstatus */ - stl_be_p(mem_buf, env->fpsr); - return 4; + return gdb_get_reg32(mem_buf, env->fpsr); case 10: /* fpiar, not implemented */ - memset(mem_buf, 0, 4); - return 4; + return gdb_get_reg32(mem_buf, 0); } return 0; } --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584382351; cv=none; d=zohomail.com; s=zohoarc; b=c3Hbsw2AxrZ9/p6m4c8NciepYJgpGQHIbEyQFbFqJnDc/w+VWvue0dbcMRiBvhqIzFsSwnKKJM+2Y+LJOmglDyJ7wFoc7+z+yOj+eORsu/PIYNjvM+oY7tUVTs68jA3SytEgMdfHzA6GBuGccUuhWJgom2MOmvoUEEvFJUQwfNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584382351; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Iavl1t+1hLO1HhNMpopBwo5UBi82XsMo5friXiEmqcA=; b=QMMcXGImYr/lwLFmOVO/Iq5TsmtCo/sRyxzFsJZK3X0OlNm+a43ENhJnLBkDDYFpQLGRN5aF0dvUXM7nU9VHPwpA3/TzNpm2hgiI/T/JPLqDyM0tRiFd4M0m7JpjS0oTKDuLuItkw88hpO+g7IbMaKQSiukjugsS92uLunkpKdc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584382351317125.77675904613739; Mon, 16 Mar 2020 11:12:31 -0700 (PDT) Received: from localhost ([::1]:45433 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuE2-0007B1-7y for importer@patchew.org; Mon, 16 Mar 2020 14:12:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRe-00019q-TL for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRa-0001ZO-OE for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:30 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRa-0001S0-CU for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:26 -0400 Received: by mail-wm1-x341.google.com with SMTP id a132so18581313wme.1 for ; Mon, 16 Mar 2020 10:22:26 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y200sm447043wmc.20.2020.03.16.10.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4EA8E1FF9C; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iavl1t+1hLO1HhNMpopBwo5UBi82XsMo5friXiEmqcA=; b=ohAtQFEbqBJOfQLMC2YL9mpAkl10cKUrKnnCI5uxbDY5KZKAwUDW7GCxTvRnbRnfSZ 7osy9E5PzJCLe2zTKZ/wpNpsvkmA4c27o5TrAXDeKdTgUizvbbvDoRwiTDtwb4MROzjk siGc11OnvgUCBWYBDo5VzPkCXiRVwObkSa0xNm4pV7KkxfnfyTrnn5lJk/ArtZd1PLow Kehy3iuwG/ueAAmffaw+Js0juiyyfKHVgBRpIm85uIdI5WTqEvwDFvO8jkl3YW7ZGEgX fT5Wj1r+hKc0ampZE1YIg93ys+wJ5ymnJo5lL3OpLWu+B7+R/YoIzFqlldKsIcHjHAnx p62A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Iavl1t+1hLO1HhNMpopBwo5UBi82XsMo5friXiEmqcA=; b=ZehOWhGLSOVRfwuh6pjQKZ9YgfsK0AZwyxlvLcHzNOEufYFgvHA6tTmSOYlS7je3K2 sYXWBB8m2uTJeJmBcxs/ckDHgrbIs92g95sSbTv0TGlwsuYJJzt78w8bqXovMuRWtNoy bgPxSaPQchx/LL1/rhDAlSamqvKfbHLsK08d3e9ysvSxn5gZBkq2nF32xQqJeX8cQKgH eoQwh1gexFcSP8Ut1JfqXi5Lsmm16iBFkAe3w7vGaO6AyugqVLsC1WweIJbTLQv1DkSB XWeVOnI5TdIHt9txh+ERfBUhuY1rAFVEAIdBHzMXOpFaSIY/zOGY2kymWk/+ZdfBZDUi sbGA== X-Gm-Message-State: ANhLgQ23dZR4QO3YH28CuuajS4PfW7W7+uQUzx+G+o47Fb9qYgIyuPtR tUunDaUb0yUpjmdZABm+a/tImw== X-Google-Smtp-Source: ADFU+vv7TxjPh5K/iMTQDvoIqhsOLvWaB0jr/IrO94OHJ72eIHncksqJWT7V+6oNkXqncOpT5PCLsg== X-Received: by 2002:a1c:9815:: with SMTP id a21mr154919wme.11.1584379345135; Mon, 16 Mar 2020 10:22:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 13/28] target/i386: use gdb_get_reg helpers Date: Mon, 16 Mar 2020 17:21:40 +0000 Message-Id: <20200316172155.971-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is cleaner than poking memory directly and will make later clean-ups easier. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v7 - remove stray space - fixup the floatx80 set/get routines --- target/i386/gdbstub.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 572ead641ca..e4d8cb66c00 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -98,26 +98,22 @@ int x86_cpu_gdb_read_register(CPUState *cs, uint8_t *me= m_buf, int n) return gdb_get_reg64(mem_buf, env->regs[gpr_map[n]] & 0xffffffffUL); } else { - memset(mem_buf, 0, sizeof(target_ulong)); - return sizeof(target_ulong); + return gdb_get_regl(mem_buf, 0); } } else { return gdb_get_reg32(mem_buf, env->regs[gpr_map32[n]]); } } else if (n >=3D IDX_FP_REGS && n < IDX_FP_REGS + 8) { -#ifdef USE_X86LDOUBLE - /* FIXME: byteswap float values - after fixing fpregs layout. */ - memcpy(mem_buf, &env->fpregs[n - IDX_FP_REGS], 10); -#else - memset(mem_buf, 0, 10); -#endif - return 10; + floatx80 *fp =3D (floatx80 *) &env->fpregs[n - IDX_FP_REGS]; + int len =3D gdb_get_reg64(mem_buf, cpu_to_le64(fp->low)); + len +=3D gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high)); + return len; } else if (n >=3D IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) { n -=3D IDX_XMM_REGS; if (n < CPU_NB_REGS32 || TARGET_LONG_BITS =3D=3D 64) { - stq_p(mem_buf, env->xmm_regs[n].ZMM_Q(0)); - stq_p(mem_buf + 8, env->xmm_regs[n].ZMM_Q(1)); - return 16; + return gdb_get_reg128(mem_buf, + env->xmm_regs[n].ZMM_Q(0), + env->xmm_regs[n].ZMM_Q(1)); } } else { switch (n) { @@ -290,10 +286,9 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *= mem_buf, int n) return 4; } } else if (n >=3D IDX_FP_REGS && n < IDX_FP_REGS + 8) { -#ifdef USE_X86LDOUBLE - /* FIXME: byteswap float values - after fixing fpregs layout. */ - memcpy(&env->fpregs[n - IDX_FP_REGS], mem_buf, 10); -#endif + floatx80 *fp =3D (floatx80 *) &env->fpregs[n - IDX_FP_REGS]; + fp->low =3D le64_to_cpu(* (uint64_t *) mem_buf); + fp->high =3D le16_to_cpu(* (uint16_t *) (mem_buf + 8)); return 10; } else if (n >=3D IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) { n -=3D IDX_XMM_REGS; --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584384061; cv=none; d=zohomail.com; s=zohoarc; b=DGnOau4fq/fo64e9Umu2Ygs67cpLj29scJqECtKa3xSDB9Mz6NPoESE+jmA9P46wwvokuIJVgA+R5A0Stifaf3IirscagzMrDKp2nuHdf4F88geVcTcs14uakqBzp4L/oeybzprOxdF2DEZpq3xSuJ5OkIrCVuYe9g3/8VQq9rI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584384061; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WLNIZj3cnPDj3s/Uqj/ZpGg7EFBhzF1GZpdh+YhYmoE=; b=VA1sJXa93KR/88d3tx1ej6DLlPAGs3CgkJ+Z/mvj360xfMMdvzp1GPQ+hALgTkrlWFRhNJOdaltxCwW8Ee1mtt8mSIyl15uZ2lncFL8AqO1ClcID/j6uFNVZB8vlrpM6kKvCkusxSgKUGSindjMBT9E2LvaNWUNOEs5nkAsc234= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584384061937872.3031227275821; Mon, 16 Mar 2020 11:41:01 -0700 (PDT) Received: from localhost ([::1]:46306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDufc-00069D-Hm for importer@patchew.org; Mon, 16 Mar 2020 14:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45729) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRj-0001Jn-RW for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRa-0001Ui-23 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:35 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42656) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRZ-0001Kk-G1 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id v11so22296092wrm.9 for ; Mon, 16 Mar 2020 10:22:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g127sm491853wmf.10.2020.03.16.10.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE64F1FF9D; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WLNIZj3cnPDj3s/Uqj/ZpGg7EFBhzF1GZpdh+YhYmoE=; b=JxG3+9NIzkVo+tUdoLhlqVkwUeRn+Tr64AqFMm49U73/x6WN9ZI16q3SGJ4iXL1K2T akMh9ikIu5ZhpkKNEmoG4kZ58h5Oq4y4+I8DpAKZoayw/UPd1b0XIBE2xezlaBg+BYHW ekvnlRWWwUzERNafTQVR2HhRtGNxTga3xF8Td2V9dzzERnBcKD3QZZ2ENc9DTfmyDMWb 0MnsZDBj45ETE4jye/BOo7SC10put69wItDAhkcOkFV7G6uDPw6jh9PZA9LjlZFtDlf2 nSGXAJvny43U6fl788WSs76x0pytOE76/vD5yWh0xzlxRj+SsNq8RpLHKlu1TT0VdlQg vBsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WLNIZj3cnPDj3s/Uqj/ZpGg7EFBhzF1GZpdh+YhYmoE=; b=f+llmxBqshQcFeJ8UJNBSkh4OF3m9bylNGmGnvB9oL4Qj1UpbimecsPVR4DFFqrjjd MBP2znit84YiI94/DhnynO3uBKl6Zs9qFtBAwarwchp7HkXvBOjs8R2FHYYJf/rGlCaY rG1ZXu0NdYMh/fplI/h9LTwn29X8TXvlgj4pOw5i8Jb2L5hrYBIvqowYUcdEEi74y9Z5 mJ5SRWEM2tBvkW14XNlkhr5UgGXd2XAhnOnrgmdwz//RhqnyAHkuUfpKyI2msorSGyok RHrJJhUzfjk15DrEaWT8/ZD9/n012cKyd5+rCVUIGkbZTU00ME2C3NcJ+LVfWOryHxae zZwg== X-Gm-Message-State: ANhLgQ2YwXKNWVY11gFFRnEKHnU2+fEtgbWKaIi1QoULAo/obI2SXqKP aMSd0M6MS4dv6PHZrouCyId2zg== X-Google-Smtp-Source: ADFU+vvbS8TDc72ukzwIOhmAVwuBR35OdFd0Sn4GMUPdKJtl0io6d8JSuJGdSoaJQQYbYDK2ISVIUA== X-Received: by 2002:adf:f148:: with SMTP id y8mr400717wro.322.1584379343589; Mon, 16 Mar 2020 10:22:23 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 14/28] gdbstub: extend GByteArray to read register helpers Date: Mon, 16 Mar 2020 17:21:41 +0000 Message-Id: <20200316172155.971-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cornelia Huck , Sagar Karandikar , David Hildenbrand , Mark Cave-Ayland , Max Filippov , Alistair Francis , "Edgar E. Iglesias" , Marek Vasut , "open list:PowerPC TCG CPUs" , Aleksandar Rikalo , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Artyom Tarasenko , Eduardo Habkost , Richard Henderson , "open list:S390 TCG CPUs" , qemu-arm@nongnu.org, Stafford Horne , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Damien Hedde , "open list:RISC-V TCG CPUs" , Bastian Koppelmann , Chris Wulff , Laurent Vivier , Michael Walle , Palmer Dabbelt , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Instead of passing a pointer to memory now just extend the GByteArray to all the read register helpers. They can then safely append their data through the normal way. We don't bother with this abstraction for write registers as we have already ensured the buffer being copied from is the correct size. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Acked-by: David Gibson Reviewed-by: Damien Hedde --- v4 - fix mem_buf calculation for ppc_maybe_bswap_register v5 - introduce gdb_get_reg_ptr and use for ppc --- include/exec/gdbstub.h | 59 +++++++++++++++++++++++---------- include/hw/core/cpu.h | 2 +- target/alpha/cpu.h | 2 +- target/arm/cpu.h | 4 +-- target/cris/cpu.h | 4 +-- target/hppa/cpu.h | 2 +- target/i386/cpu.h | 2 +- target/lm32/cpu.h | 2 +- target/m68k/cpu.h | 2 +- target/microblaze/cpu.h | 2 +- target/mips/internal.h | 2 +- target/openrisc/cpu.h | 2 +- target/ppc/cpu.h | 4 +-- target/riscv/cpu.h | 2 +- target/s390x/internal.h | 2 +- target/sh4/cpu.h | 2 +- target/sparc/cpu.h | 2 +- target/xtensa/cpu.h | 2 +- gdbstub.c | 20 +++++------ hw/core/cpu.c | 2 +- target/alpha/gdbstub.c | 2 +- target/arm/gdbstub.c | 2 +- target/arm/gdbstub64.c | 2 +- target/arm/helper.c | 19 +++++------ target/cris/gdbstub.c | 4 +-- target/hppa/gdbstub.c | 2 +- target/i386/gdbstub.c | 2 +- target/lm32/gdbstub.c | 2 +- target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 4 +-- target/microblaze/gdbstub.c | 2 +- target/mips/gdbstub.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/gdbstub.c | 2 +- target/ppc/gdbstub.c | 48 +++++++++++++++------------ target/ppc/translate_init.inc.c | 54 ++++++++++++++++-------------- target/riscv/gdbstub.c | 20 +++++------ target/s390x/gdbstub.c | 30 ++++++++--------- target/sh4/gdbstub.c | 2 +- target/sparc/gdbstub.c | 2 +- target/xtensa/gdbstub.c | 2 +- 41 files changed, 179 insertions(+), 149 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 59e366ba3af..30b909ebd27 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -68,53 +68,76 @@ void gdb_signalled(CPUArchState *, int); void gdbserver_fork(CPUState *); #endif /* Get or set a register. Returns the size of the register. */ -typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); +typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); +typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); void gdb_register_coprocessor(CPUState *cpu, - gdb_reg_cb get_reg, gdb_reg_cb set_reg, + gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, int num_regs, const char *xml, int g_pos); =20 -/* The GDB remote protocol transfers values in target byte order. This me= ans - * we can use the raw memory access routines to access the value buffer. - * Conveniently, these also handle the case where the buffer is mis-aligne= d. +/* + * The GDB remote protocol transfers values in target byte order. As + * the gdbstub may be batching up several register values we always + * append to the array. */ =20 -static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val) +static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) { - stb_p(mem_buf, val); + g_byte_array_append(buf, &val, 1); return 1; } =20 -static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val) +static inline int gdb_get_reg16(GByteArray *buf, uint16_t val) { - stw_p(mem_buf, val); + uint16_t to_word =3D tswap16(val); + g_byte_array_append(buf, (uint8_t *) &to_word, 2); return 2; } =20 -static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val) +static inline int gdb_get_reg32(GByteArray *buf, uint32_t val) { - stl_p(mem_buf, val); + uint32_t to_long =3D tswap32(val); + g_byte_array_append(buf, (uint8_t *) &to_long, 4); return 4; } =20 -static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val) +static inline int gdb_get_reg64(GByteArray *buf, uint64_t val) { - stq_p(mem_buf, val); + uint64_t to_quad =3D tswap64(val); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); return 8; } =20 -static inline int gdb_get_reg128(uint8_t *mem_buf, uint64_t val_hi, +static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi, uint64_t val_lo) { + uint64_t to_quad; #ifdef TARGET_WORDS_BIGENDIAN - stq_p(mem_buf, val_hi); - stq_p(mem_buf + 8, val_lo); + to_quad =3D tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad =3D tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); #else - stq_p(mem_buf, val_lo); - stq_p(mem_buf + 8, val_hi); + to_quad =3D tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad =3D tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); #endif return 16; } =20 +/** + * gdb_get_reg_ptr: get pointer to start of last element + * @len: length of element + * + * This is a helper function to extract the pointer to the last + * element for additional processing. Some front-ends do additional + * dynamic swapping of the elements based on CPU state. + */ +static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len) +{ + return buf->data + buf->len - len; +} + #if TARGET_LONG_BITS =3D=3D 64 #define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) #define ldtul_p(addr) ldq_p(addr) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 73e9a869a41..e1d6ee00b40 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -195,7 +195,7 @@ typedef struct CPUClass { hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs); - int (*gdb_read_register)(CPUState *cpu, uint8_t *buf, int reg); + int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); void (*debug_excp_handler)(CPUState *cpu); diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 3f782c0efe4..be29bdd5301 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -280,7 +280,7 @@ void alpha_cpu_do_interrupt(CPUState *cpu); bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req); void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags); hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int alpha_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4ffd991b6fc..4ab2cbfd417 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -968,7 +968,7 @@ bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); =20 -int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 /* Dynamically generates for gdb stub an XML description of the sysregs fr= om @@ -988,7 +988,7 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, C= PUState *cs, int cpuid, void *opaque); =20 #ifdef TARGET_AARCH64 -int aarch64_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, diff --git a/target/cris/cpu.h b/target/cris/cpu.h index ca240bc7881..8f08d7628b2 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -195,8 +195,8 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, int fla= gs); =20 hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); =20 -int crisv10_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); -int cris_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); +int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int cris_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 /* you can call this signal handler from your SIGBUS and SIGSEGV diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 6713d04f111..801a4fb1bae 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -321,7 +321,7 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env); =20 int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc); hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr); -int hppa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 576f309bbfc..c2d89315b92 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1766,7 +1766,7 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags); hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); =20 -int x86_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 void x86_cpu_exec_enter(CPUState *cpu); diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h index 064c6b1267e..01d408eb55d 100644 --- a/target/lm32/cpu.h +++ b/target/lm32/cpu.h @@ -202,7 +202,7 @@ void lm32_cpu_do_interrupt(CPUState *cpu); bool lm32_cpu_exec_interrupt(CPUState *cs, int int_req); void lm32_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr lm32_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int lm32_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int lm32_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int lm32_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 typedef enum { diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 3de8e06dfec..521ac67cdd0 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -168,7 +168,7 @@ void m68k_cpu_do_interrupt(CPUState *cpu); bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req); void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int m68k_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 void m68k_tcg_init(void); diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 32522f606bd..1a700a880c5 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -313,7 +313,7 @@ void mb_cpu_do_interrupt(CPUState *cs); bool mb_cpu_exec_interrupt(CPUState *cs, int int_req); void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int mb_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 void mb_tcg_init(void); diff --git a/target/mips/internal.h b/target/mips/internal.h index df55f845baf..1bf274b3ef5 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -82,7 +82,7 @@ void mips_cpu_do_interrupt(CPUState *cpu); bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req); void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 0ad02eab794..d9484b802f3 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -320,7 +320,7 @@ void openrisc_cpu_do_interrupt(CPUState *cpu); bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req); void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int openrisc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg= ); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void openrisc_translate_init(void); bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index b283042515f..5fd081573ef 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1218,8 +1218,8 @@ bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_re= q); void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); void ppc_cpu_dump_statistics(CPUState *cpu, int flags); hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int ppc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); -int ppc_cpu_gdb_read_register_apple(CPUState *cpu, uint8_t *buf, int reg); +int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); +int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int re= g); int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 3dcdf922272..31458c5b4a7 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -293,7 +293,7 @@ extern const char * const riscv_excp_names[]; extern const char * const riscv_intr_names[]; =20 void riscv_cpu_do_interrupt(CPUState *cpu); -int riscv_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); bool riscv_cpu_exec_interrupt(CPUState *cs, int interrupt_request); bool riscv_cpu_fp_enabled(CPURISCVState *env); diff --git a/target/s390x/internal.h b/target/s390x/internal.h index d37816104dd..8c95c734dbe 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -292,7 +292,7 @@ uint16_t float128_dcmask(CPUS390XState *env, float128 f= 1); =20 =20 /* gdbstub.c */ -int s390_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int s390_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int s390_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void s390_cpu_gdb_init(CPUState *cs); =20 diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 452a596e671..dbe58c7888f 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -208,7 +208,7 @@ void superh_cpu_do_interrupt(CPUState *cpu); bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req); void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int superh_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ae97c7d9f79..b9369398f24 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -571,7 +571,7 @@ extern const VMStateDescription vmstate_sparc_cpu; void sparc_cpu_do_interrupt(CPUState *cpu); void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int sparc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 493f4fc80c5..c0d69fad96c 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -569,7 +569,7 @@ void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int = flags); hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs); -int xtensa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/gdbstub.c b/gdbstub.c index db537a712cc..0bcfc47a7c5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -319,8 +319,8 @@ static int gdb_signal_to_target (int sig) typedef struct GDBRegisterState { int base_reg; int num_regs; - gdb_reg_cb get_reg; - gdb_reg_cb set_reg; + gdb_get_reg_cb get_reg; + gdb_set_reg_cb set_reg; const char *xml; struct GDBRegisterState *next; } GDBRegisterState; @@ -905,19 +905,19 @@ static const char *get_feature_xml(const char *p, con= st char **newp, return name ? xml_builtin[i][1] : NULL; } =20 -static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg) +static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchState *env =3D cpu->env_ptr; GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { - return cc->gdb_read_register(cpu, mem_buf, reg); + return cc->gdb_read_register(cpu, buf, reg); } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { - return r->get_reg(env, mem_buf, reg - r->base_reg); + return r->get_reg(env, buf, reg - r->base_reg); } } return 0; @@ -948,7 +948,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) */ =20 void gdb_register_coprocessor(CPUState *cpu, - gdb_reg_cb get_reg, gdb_reg_cb set_reg, + gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, int num_regs, const char *xml, int g_pos) { GDBRegisterState *s; @@ -1739,7 +1739,7 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, vo= id *user_ctx) } =20 reg_size =3D gdb_read_register(gdbserver_state.g_cpu, - gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf, gdb_ctx->params[0].val_ull); if (!reg_size) { put_packet("E14"); @@ -1832,14 +1832,14 @@ static void handle_read_all_regs(GdbCmdContext *gdb= _ctx, void *user_ctx) target_ulong addr, len; =20 cpu_synchronize_state(gdbserver_state.g_cpu); + g_byte_array_set_size(gdbserver_state.mem_buf, 0); len =3D 0; for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++)= { len +=3D gdb_read_register(gdbserver_state.g_cpu, - gdbserver_state.mem_buf->data + len, + gdbserver_state.mem_buf, addr); } - /* FIXME: This is after the fact sizing */ - g_byte_array_set_size(gdbserver_state.mem_buf, len); + g_assert(len =3D=3D gdbserver_state.mem_buf->len); =20 memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); put_strbuf(); diff --git a/hw/core/cpu.c b/hw/core/cpu.c index fe65ca62ace..3b2363f0431 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -177,7 +177,7 @@ static int cpu_common_write_elf64_note(WriteCoreDumpFun= ction f, } =20 =20 -static int cpu_common_gdb_read_register(CPUState *cpu, uint8_t *buf, int r= eg) +static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, in= t reg) { return 0; } diff --git a/target/alpha/gdbstub.c b/target/alpha/gdbstub.c index 7f9cc092a9c..0cd76ddaa9e 100644 --- a/target/alpha/gdbstub.c +++ b/target/alpha/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int alpha_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { AlphaCPU *cpu =3D ALPHA_CPU(cs); CPUAlphaState *env =3D &cpu->env; diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 1239abd9842..4557775d245 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -32,7 +32,7 @@ typedef struct RegisterSysregXmlParam { We hack round this by giving the FPA regs zero size when talking to a newer gdb. */ =20 -int arm_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 665ebb3ef64..35d0b80c2de 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int aarch64_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; diff --git a/target/arm/helper.c b/target/arm/helper.c index 69104fb351d..c0e1ba17272 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -48,30 +48,27 @@ static bool get_phys_addr_lpae(CPUARMState *env, target= _ulong address, =20 static void switch_mode(CPUARMState *env, int mode); =20 -static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) +static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu =3D env_archcpu(env); int nregs =3D cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; =20 /* VFP data registers are always little-endian. */ if (reg < nregs) { - stq_le_p(buf, *aa32_vfp_dreg(env, reg)); - return 8; + return gdb_get_reg64(buf, *aa32_vfp_dreg(env, reg)); } if (arm_feature(env, ARM_FEATURE_NEON)) { /* Aliases for Q regs. */ nregs +=3D 16; if (reg < nregs) { uint64_t *q =3D aa32_vfp_qreg(env, reg - 32); - stq_le_p(buf, q[0]); - stq_le_p(buf + 8, q[1]); - return 16; + return gdb_get_reg128(buf, q[0], q[1]); } } switch (reg - nregs) { - case 0: stl_p(buf, env->vfp.xregs[ARM_VFP_FPSID]); return 4; - case 1: stl_p(buf, vfp_get_fpscr(env)); return 4; - case 2: stl_p(buf, env->vfp.xregs[ARM_VFP_FPEXC]); return 4; + case 0: return gdb_get_reg32(buf, env->vfp.xregs[ARM_VFP_FPSID]); brea= k; + case 1: return gdb_get_reg32(buf, vfp_get_fpscr(env)); break; + case 2: return gdb_get_reg32(buf, env->vfp.xregs[ARM_VFP_FPEXC]); brea= k; } return 0; } @@ -102,7 +99,7 @@ static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *bu= f, int reg) return 0; } =20 -static int aarch64_fpu_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) +static int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int = reg) { switch (reg) { case 0 ... 31: @@ -205,7 +202,7 @@ static void write_raw_cp_reg(CPUARMState *env, const AR= MCPRegInfo *ri, } } =20 -static int arm_gdb_get_sysreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu =3D env_archcpu(env); const ARMCPRegInfo *ri; diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index a3d76d2e8c2..b01b2aa0811 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int crisv10_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; @@ -53,7 +53,7 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, uint8_t *= mem_buf, int n) return 0; } =20 -int cris_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; diff --git a/target/hppa/gdbstub.c b/target/hppa/gdbstub.c index 341888a9da0..a6428a2893f 100644 --- a/target/hppa/gdbstub.c +++ b/target/hppa/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int hppa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { HPPACPU *cpu =3D HPPA_CPU(cs); CPUHPPAState *env =3D &cpu->env; diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index e4d8cb66c00..f3d23b614ee 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -79,7 +79,7 @@ static const int gpr_map32[8] =3D { 0, 1, 2, 3, 4, 5, 6, = 7 }; #endif =20 =20 -int x86_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; diff --git a/target/lm32/gdbstub.c b/target/lm32/gdbstub.c index 82ede436e12..b6fe12e1d61 100644 --- a/target/lm32/gdbstub.c +++ b/target/lm32/gdbstub.c @@ -22,7 +22,7 @@ #include "exec/gdbstub.h" #include "hw/lm32/lm32_pic.h" =20 -int lm32_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int lm32_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { LM32CPU *cpu =3D LM32_CPU(cs); CPULM32State *env =3D &cpu->env; diff --git a/target/m68k/gdbstub.c b/target/m68k/gdbstub.c index fdc96f57fff..eb2d030e148 100644 --- a/target/m68k/gdbstub.c +++ b/target/m68k/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int m68k_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; diff --git a/target/m68k/helper.c b/target/m68k/helper.c index c23b70f854d..014657c6372 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -68,7 +68,7 @@ void m68k_cpu_list(void) g_slist_free(list); } =20 -static int cf_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int = n) { if (n < 8) { float_status s; @@ -105,7 +105,7 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_= t *mem_buf, int n) return 0; } =20 -static int m68k_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, in= t n) { if (n < 8) { int len =3D gdb_get_reg16(mem_buf, env->fregs[n].l.upper); diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 30677b6d1f4..f41ebf1f33b 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int mb_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); CPUMBState *env =3D &cpu->env; diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index bbb25449391..98f56e660d2 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -22,7 +22,7 @@ #include "internal.h" #include "exec/gdbstub.h" =20 -int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 1c0c855a6f0..1856b7fcc7a 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -124,7 +124,7 @@ static void nios2_cpu_disas_set_info(CPUState *cpu, dis= assemble_info *info) #endif } =20 -static int nios2_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int= n) +static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, = int n) { Nios2CPU *cpu =3D NIOS2_CPU(cs); CPUClass *cc =3D CPU_GET_CLASS(cs); diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index 0fcdb79668c..095bf76c12c 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" =20 -int openrisc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int = n) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); CPUOpenRISCState *env =3D &cpu->env; diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 823759c92e7..eb362dd9aec 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -114,10 +114,11 @@ void ppc_maybe_bswap_register(CPUPPCState *env, uint8= _t *mem_buf, int len) * the FP regs zero size when talking to a newer gdb. */ =20 -int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; + uint8_t *mem_buf; int r =3D ppc_gdb_register_len(n); =20 if (!r) { @@ -126,17 +127,17 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *= mem_buf, int n) =20 if (n < 32) { /* gprs */ - gdb_get_regl(mem_buf, env->gpr[n]); + gdb_get_regl(buf, env->gpr[n]); } else if (n < 64) { /* fprs */ - stfq_p(mem_buf, *cpu_fpr_ptr(env, n - 32)); + gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); } else { switch (n) { case 64: - gdb_get_regl(mem_buf, env->nip); + gdb_get_regl(buf, env->nip); break; case 65: - gdb_get_regl(mem_buf, env->msr); + gdb_get_regl(buf, env->msr); break; case 66: { @@ -145,31 +146,33 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *= mem_buf, int n) for (i =3D 0; i < 8; i++) { cr |=3D env->crf[i] << (32 - ((i + 1) * 4)); } - gdb_get_reg32(mem_buf, cr); + gdb_get_reg32(buf, cr); break; } case 67: - gdb_get_regl(mem_buf, env->lr); + gdb_get_regl(buf, env->lr); break; case 68: - gdb_get_regl(mem_buf, env->ctr); + gdb_get_regl(buf, env->ctr); break; case 69: - gdb_get_reg32(mem_buf, env->xer); + gdb_get_reg32(buf, env->xer); break; case 70: - gdb_get_reg32(mem_buf, env->fpscr); + gdb_get_reg32(buf, env->fpscr); break; } } + mem_buf =3D buf->data + buf->len - r; ppc_maybe_bswap_register(env, mem_buf, r); return r; } =20 -int ppc_cpu_gdb_read_register_apple(CPUState *cs, uint8_t *mem_buf, int n) +int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; + uint8_t *mem_buf; int r =3D ppc_gdb_register_len_apple(n); =20 if (!r) { @@ -178,21 +181,21 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, uin= t8_t *mem_buf, int n) =20 if (n < 32) { /* gprs */ - gdb_get_reg64(mem_buf, env->gpr[n]); + gdb_get_reg64(buf, env->gpr[n]); } else if (n < 64) { /* fprs */ - stfq_p(mem_buf, *cpu_fpr_ptr(env, n - 32)); + gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); } else if (n < 96) { /* Altivec */ - stq_p(mem_buf, n - 64); - stq_p(mem_buf + 8, 0); + gdb_get_reg64(buf, n - 64); + gdb_get_reg64(buf, 0); } else { switch (n) { case 64 + 32: - gdb_get_reg64(mem_buf, env->nip); + gdb_get_reg64(buf, env->nip); break; case 65 + 32: - gdb_get_reg64(mem_buf, env->msr); + gdb_get_reg64(buf, env->msr); break; case 66 + 32: { @@ -201,23 +204,24 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, uin= t8_t *mem_buf, int n) for (i =3D 0; i < 8; i++) { cr |=3D env->crf[i] << (32 - ((i + 1) * 4)); } - gdb_get_reg32(mem_buf, cr); + gdb_get_reg32(buf, cr); break; } case 67 + 32: - gdb_get_reg64(mem_buf, env->lr); + gdb_get_reg64(buf, env->lr); break; case 68 + 32: - gdb_get_reg64(mem_buf, env->ctr); + gdb_get_reg64(buf, env->ctr); break; case 69 + 32: - gdb_get_reg32(mem_buf, env->xer); + gdb_get_reg32(buf, env->xer); break; case 70 + 32: - gdb_get_reg64(mem_buf, env->fpscr); + gdb_get_reg64(buf, env->fpscr); break; } } + mem_buf =3D buf->data + buf->len - r; ppc_maybe_bswap_register(env, mem_buf, r); return r; } diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 53995f62eab..04ad54cff69 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -9857,7 +9857,7 @@ static int gdb_find_spr_idx(CPUPPCState *env, int n) return -1; } =20 -static int gdb_get_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_spr_reg(CPUPPCState *env, GByteArray *buf, int n) { int reg; int len; @@ -9868,8 +9868,8 @@ static int gdb_get_spr_reg(CPUPPCState *env, uint8_t = *mem_buf, int n) } =20 len =3D TARGET_LONG_SIZE; - stn_p(mem_buf, len, env->spr[reg]); - ppc_maybe_bswap_register(env, mem_buf, len); + gdb_get_regl(buf, env->spr[reg]); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, len), len); return len; } =20 @@ -9891,15 +9891,18 @@ static int gdb_set_spr_reg(CPUPPCState *env, uint8_= t *mem_buf, int n) } #endif =20 -static int gdb_get_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n) { + uint8_t *mem_buf; if (n < 32) { - stfq_p(mem_buf, *cpu_fpr_ptr(env, n)); + gdb_get_reg64(buf, *cpu_fpr_ptr(env, n)); + mem_buf =3D gdb_get_reg_ptr(buf, 8); ppc_maybe_bswap_register(env, mem_buf, 8); return 8; } if (n =3D=3D 32) { - stl_p(mem_buf, env->fpscr); + gdb_get_reg32(buf, env->fpscr); + mem_buf =3D gdb_get_reg_ptr(buf, 4); ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } @@ -9921,28 +9924,31 @@ static int gdb_set_float_reg(CPUPPCState *env, uint= 8_t *mem_buf, int n) return 0; } =20 -static int gdb_get_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_avr_reg(CPUPPCState *env, GByteArray *buf, int n) { + uint8_t *mem_buf; + if (n < 32) { ppc_avr_t *avr =3D cpu_avr_ptr(env, n); if (!avr_need_swap(env)) { - stq_p(mem_buf, avr->u64[0]); - stq_p(mem_buf + 8, avr->u64[1]); + gdb_get_reg128(buf, avr->u64[0] , avr->u64[1]); } else { - stq_p(mem_buf, avr->u64[1]); - stq_p(mem_buf + 8, avr->u64[0]); + gdb_get_reg128(buf, avr->u64[1] , avr->u64[0]); } + mem_buf =3D gdb_get_reg_ptr(buf, 16); ppc_maybe_bswap_register(env, mem_buf, 8); ppc_maybe_bswap_register(env, mem_buf + 8, 8); return 16; } if (n =3D=3D 32) { - stl_p(mem_buf, helper_mfvscr(env)); + gdb_get_reg32(buf, helper_mfvscr(env)); + mem_buf =3D gdb_get_reg_ptr(buf, 4); ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } if (n =3D=3D 33) { - stl_p(mem_buf, (uint32_t)env->spr[SPR_VRSAVE]); + gdb_get_reg32(buf, (uint32_t)env->spr[SPR_VRSAVE]); + mem_buf =3D gdb_get_reg_ptr(buf, 4); ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } @@ -9977,25 +9983,25 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint8_= t *mem_buf, int n) return 0; } =20 -static int gdb_get_spe_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_spe_reg(CPUPPCState *env, GByteArray *buf, int n) { if (n < 32) { #if defined(TARGET_PPC64) - stl_p(mem_buf, env->gpr[n] >> 32); - ppc_maybe_bswap_register(env, mem_buf, 4); + gdb_get_reg32(buf, env->gpr[n] >> 32); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 4), 4); #else - stl_p(mem_buf, env->gprh[n]); + gdb_get_reg32(buf, env->gprh[n]); #endif return 4; } if (n =3D=3D 32) { - stq_p(mem_buf, env->spe_acc); - ppc_maybe_bswap_register(env, mem_buf, 8); + gdb_get_reg64(buf, env->spe_acc); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 8), 8); return 8; } if (n =3D=3D 33) { - stl_p(mem_buf, env->spe_fscr); - ppc_maybe_bswap_register(env, mem_buf, 4); + gdb_get_reg32(buf, env->spe_fscr); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 4), 4); return 4; } return 0; @@ -10030,11 +10036,11 @@ static int gdb_set_spe_reg(CPUPPCState *env, uint= 8_t *mem_buf, int n) return 0; } =20 -static int gdb_get_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_vsx_reg(CPUPPCState *env, GByteArray *buf, int n) { if (n < 32) { - stq_p(mem_buf, *cpu_vsrl_ptr(env, n)); - ppc_maybe_bswap_register(env, mem_buf, 8); + gdb_get_reg64(buf, *cpu_vsrl_ptr(env, n)); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 8), 8); return 8; } return 0; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 2f32750f2fb..eba12a86f2e 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -270,7 +270,7 @@ static int csr_register_map[] =3D { CSR_MHCOUNTEREN, }; =20 -int riscv_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; @@ -301,14 +301,14 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_= t *mem_buf, int n) return 0; } =20 -static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) { if (n < 32) { if (env->misa & RVD) { - return gdb_get_reg64(mem_buf, env->fpr[n]); + return gdb_get_reg64(buf, env->fpr[n]); } if (env->misa & RVF) { - return gdb_get_reg32(mem_buf, env->fpr[n]); + return gdb_get_reg32(buf, env->fpr[n]); } /* there is hole between ft11 and fflags in fpu.xml */ } else if (n < 36 && n > 32) { @@ -322,7 +322,7 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_= t *mem_buf, int n) result =3D riscv_csrrw_debug(env, n - 33 + csr_register_map[8], &v= al, 0, 0); if (result =3D=3D 0) { - return gdb_get_regl(mem_buf, val); + return gdb_get_regl(buf, val); } } return 0; @@ -351,7 +351,7 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_= t *mem_buf, int n) return 0; } =20 -static int riscv_gdb_get_csr(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) { if (n < ARRAY_SIZE(csr_register_map)) { target_ulong val =3D 0; @@ -359,7 +359,7 @@ static int riscv_gdb_get_csr(CPURISCVState *env, uint8_= t *mem_buf, int n) =20 result =3D riscv_csrrw_debug(env, csr_register_map[n], &val, 0, 0); if (result =3D=3D 0) { - return gdb_get_regl(mem_buf, val); + return gdb_get_regl(buf, val); } } return 0; @@ -379,13 +379,13 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint= 8_t *mem_buf, int n) return 0; } =20 -static int riscv_gdb_get_virtual(CPURISCVState *cs, uint8_t *mem_buf, int = n) +static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n) { if (n =3D=3D 0) { #ifdef CONFIG_USER_ONLY - return gdb_get_regl(mem_buf, 0); + return gdb_get_regl(buf, 0); #else - return gdb_get_regl(mem_buf, cs->priv); + return gdb_get_regl(buf, cs->priv); #endif } return 0; diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index e24a49f4a91..d6fce5ff1e1 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -27,7 +27,7 @@ #include "sysemu/hw_accel.h" #include "sysemu/tcg.h" =20 -int s390_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; @@ -82,11 +82,11 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *= mem_buf, int n) /* total number of registers in s390-acr.xml */ #define S390_NUM_AC_REGS 16 =20 -static int cpu_read_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) { switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: - return gdb_get_reg32(mem_buf, env->aregs[n]); + return gdb_get_reg32(buf, env->aregs[n]); default: return 0; } @@ -111,13 +111,13 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8= _t *mem_buf, int n) /* total number of registers in s390-fpr.xml */ #define S390_NUM_FP_REGS 17 =20 -static int cpu_read_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) { switch (n) { case S390_FPC_REGNUM: - return gdb_get_reg32(mem_buf, env->fpc); + return gdb_get_reg32(buf, env->fpc); case S390_F0_REGNUM ... S390_F15_REGNUM: - return gdb_get_reg64(mem_buf, *get_freg(env, n - S390_F0_REGNUM)); + return gdb_get_reg64(buf, *get_freg(env, n - S390_F0_REGNUM)); default: return 0; } @@ -145,17 +145,17 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8= _t *mem_buf, int n) /* total number of registers in s390-vx.xml */ #define S390_NUM_VREGS 32 =20 -static int cpu_read_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) { int ret; =20 switch (n) { case S390_V0L_REGNUM ... S390_V15L_REGNUM: - ret =3D gdb_get_reg64(mem_buf, env->vregs[n][1]); + ret =3D gdb_get_reg64(buf, env->vregs[n][1]); break; case S390_V16_REGNUM ... S390_V31_REGNUM: - ret =3D gdb_get_reg64(mem_buf, env->vregs[n][0]); - ret +=3D gdb_get_reg64(mem_buf + 8, env->vregs[n][1]); + ret =3D gdb_get_reg64(buf, env->vregs[n][0]); + ret +=3D gdb_get_reg64(buf, env->vregs[n][1]); break; default: ret =3D 0; @@ -186,11 +186,11 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t= *mem_buf, int n) #define S390_NUM_C_REGS 16 =20 #ifndef CONFIG_USER_ONLY -static int cpu_read_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) { switch (n) { case S390_C0_REGNUM ... S390_C15_REGNUM: - return gdb_get_regl(mem_buf, env->cregs[n]); + return gdb_get_regl(buf, env->cregs[n]); default: return 0; } @@ -223,7 +223,7 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t = *mem_buf, int n) /* total number of registers in s390-virt.xml */ #define S390_NUM_VIRT_REGS 8 =20 -static int cpu_read_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int = n) { switch (n) { case S390_VIRT_CKC_REGNUM: @@ -296,9 +296,9 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8= _t *mem_buf, int n) /* total number of registers in s390-gs.xml */ #define S390_NUM_GS_REGS 4 =20 -static int cpu_read_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) { - return gdb_get_regl(mem_buf, env->gscb[n]); + return gdb_get_regl(buf, env->gscb[n]); } =20 static int cpu_write_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n) diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index 44c1679e9db..49fc4a0cc69 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -24,7 +24,7 @@ /* Hint: Use "set architecture sh4" in GDB to see fpu registers */ /* FIXME: We should use XML for this. */ =20 -int superh_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { SuperHCPU *cpu =3D SUPERH_CPU(cs); CPUSH4State *env =3D &cpu->env; diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index 8be742b5a3d..78dc8dcc980 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -27,7 +27,7 @@ #define gdb_get_rega(buf, val) gdb_get_regl(buf, val) #endif =20 -int sparc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index 54727881f38..0ee3feabe54 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -63,7 +63,7 @@ void xtensa_count_regs(const XtensaConfig *config, } } =20 -int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { XtensaCPU *cpu =3D XTENSA_CPU(cs); CPUXtensaState *env =3D &cpu->env; --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584382488; cv=none; d=zohomail.com; s=zohoarc; b=GBxdJMzo17sOpadnZ5WpQo57UlXFzZiKnZOETjgiLMw46UN8cY4qS1S6Tj7A7Yh16tSQ8YWbrDbJFuFBIY6hF9vFWLNRXlllEdjpS31NxFrkvquO32T5QU/q6KvPthiI8MRQ3lMo50L2jiAkfug0nhjZ2Yu/UxKr90vin/61Tbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584382488; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OAqoYZ6AoMn8SDyKfeJtk3cy7lCgGq0zc51fSuhUDjQ=; b=OQZEaw7sClqhQ6JKAiQhdtuWS71Ojq7K0etQN3MXKNOHEz4z0/VA9x4c5QcU7576rXaTFyts+rugpNFHFPDBFx7dG0JymAU+ZZR75Zwui7mR+yNcNrZmEkv9eahN0iTFVUVxepy3GmeXLXZ+qM6B2Z1RRnqiJc8qDyxyKf1NVNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584382488590978.7019831912611; Mon, 16 Mar 2020 11:14:48 -0700 (PDT) Received: from localhost ([::1]:45476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuGF-0001sZ-GL for importer@patchew.org; Mon, 16 Mar 2020 14:14:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45648) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRh-0001Ex-A6 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRd-0001tW-3F for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:33 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRc-0001lD-MJ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:28 -0400 Received: by mail-wm1-x344.google.com with SMTP id 6so18582204wmi.5 for ; Mon, 16 Mar 2020 10:22:28 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n4sm725973wrs.64.2020.03.16.10.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C98E91FF9E; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OAqoYZ6AoMn8SDyKfeJtk3cy7lCgGq0zc51fSuhUDjQ=; b=tm8/qtKCPPKAj8I18/kHxp0Zsv8l8MHKVYjwDkVulW9JL9KtGKvApsDuXWqzg1PowY ombb8tRnmceBrPM0roX3tv18cRiIsOmtE0Vdj72/Jc6JGq0skPUNJROTJ6xdX6Jme8+W Pc4PopL2d/KZIfAz+tTCmZTxLnVcb9uF/0GGwGEpfXOquxSekjcVNAKzdEpklMf8C9B1 HfGCZn+X8hP0NKwQENJSH/KTtMh9XhloK1XrshlBwtpVhtVjedjBYwUFzNkweIIWbP5z ZCXFrSlzDH2nnpDmlUfPR7+WDvp0yeg4fHJq6Q2hW9j7kqfCJUpdPSFFh5uBZwa+DH/y 1YYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OAqoYZ6AoMn8SDyKfeJtk3cy7lCgGq0zc51fSuhUDjQ=; b=RPzTGh2iBuc2n+XpoSzjQI0cWf5hYTTWWqB8Y5zv2gyAkSAwMeV/iETqlOZ01BQn2b cxeOmVax9GUMos9MeMO6cE6Tw1lu/Mx3TW6cDlxxb98yROOkCPr5CfCCxXUnC8yQN9UN IMCV3Gwt6cxPwXOal9BLlp2dUr+s53PfpUL0DsHq0rtnTl8Tm2944njXAd9nsjEjnPlp vOVeCNZj5nN1A4XgyyvHfEwmEgmQ9Zn3vLbDvIawfLGnwfW2idHrxBSXWpV7BZUaHU7f YOlLo4Ki4VtiFuwXh8c+ZMLAu+oWjWglkKzAX6Oe1EZeAHLcbraPpz5NqOJzcnIPL771 t72Q== X-Gm-Message-State: ANhLgQ0lr9FkVF/a/oa5mxnSLtYELR2hwxGNCfzTuYih35zWNEp1xxw5 RTcUAC7g0y0XCPQM25k8lkNuqQ== X-Google-Smtp-Source: ADFU+vvCw6jNyM6N/YuvOmeMmPi7QWnOC/boHF+rOTe+81uMwK4xVXX8d63kBvimyLNk6ip8sZo3HQ== X-Received: by 2002:a1c:f204:: with SMTP id s4mr135951wmc.127.1584379347502; Mon, 16 Mar 2020 10:22:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 15/28] target/arm: prepare for multiple dynamic XMLs Date: Mon, 16 Mar 2020 17:21:42 +0000 Message-Id: <20200316172155.971-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We will want to generate similar dynamic XML for gdbstub support of SVE registers (the upstream doesn't use XML). To that end lightly rename a few things to make the distinction. Signed-off-by: Alex Benn=C3=A9e Acked-by: Richard Henderson --- target/arm/cpu.h | 20 +++++++++++++------- target/arm/gdbstub.c | 30 +++++++++++++++--------------- target/arm/helper.c | 4 ++-- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4ab2cbfd417..0ab82c987c3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -128,14 +128,20 @@ enum { /** * DynamicGDBXMLInfo: * @desc: Contains the XML descriptions. - * @num_cpregs: Number of the Coprocessor registers seen by GDB. - * @cpregs_keys: Array that contains the corresponding Key of - * a given cpreg with the same order of the cpreg in the XML description. + * @num: Number of the registers in this XML seen by GDB. + * @data: A union with data specific to the set of registers + * @cpregs_keys: Array that contains the corresponding Key of + * a given cpreg with the same order of the cpreg + * in the XML description. */ typedef struct DynamicGDBXMLInfo { char *desc; - int num_cpregs; - uint32_t *cpregs_keys; + int num; + union { + struct { + uint32_t *keys; + } cpregs; + } data; } DynamicGDBXMLInfo; =20 /* CPU state for each instance of a generic timer (in cp15 c14) */ @@ -749,7 +755,7 @@ struct ARMCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; =20 - DynamicGDBXMLInfo dyn_xml; + DynamicGDBXMLInfo dyn_sysreg_xml; =20 /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; @@ -974,7 +980,7 @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *= buf, int reg); /* Dynamically generates for gdb stub an XML description of the sysregs fr= om * the cp_regs hashtable. Returns the registered sysregs number. */ -int arm_gen_dynamic_xml(CPUState *cpu); +int arm_gen_dynamic_sysreg_xml(CPUState *cpu); =20 /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 4557775d245..1f68ab98c3b 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -106,15 +106,15 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t = *mem_buf, int n) return 0; } =20 -static void arm_gen_one_xml_reg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, - ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize) +static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_= xml, + ARMCPRegInfo *ri, uint32_t ri_key, + int bitsize) { g_string_append_printf(s, "name); g_string_append_printf(s, " bitsize=3D\"%d\"", bitsize); g_string_append_printf(s, " group=3D\"cp_regs\"/>"); - dyn_xml->num_cpregs++; - dyn_xml->cpregs_keys[dyn_xml->num_cpregs - 1] =3D ri_key; + dyn_xml->data.cpregs.keys[dyn_xml->num] =3D ri_key; + dyn_xml->num++; } =20 static void arm_register_sysreg_for_xml(gpointer key, gpointer value, @@ -126,12 +126,12 @@ static void arm_register_sysreg_for_xml(gpointer key,= gpointer value, GString *s =3D param->s; ARMCPU *cpu =3D ARM_CPU(param->cs); CPUARMState *env =3D &cpu->env; - DynamicGDBXMLInfo *dyn_xml =3D &cpu->dyn_xml; + DynamicGDBXMLInfo *dyn_xml =3D &cpu->dyn_sysreg_xml; =20 if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state =3D=3D ARM_CP_STATE_AA64) { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); } } else { if (ri->state =3D=3D ARM_CP_STATE_AA32) { @@ -140,30 +140,30 @@ static void arm_register_sysreg_for_xml(gpointer key,= gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64= ); } else { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 32); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32= ); } } } } } =20 -int arm_gen_dynamic_xml(CPUState *cs) +int arm_gen_dynamic_sysreg_xml(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); RegisterSysregXmlParam param =3D {cs, s}; =20 - cpu->dyn_xml.num_cpregs =3D 0; - cpu->dyn_xml.cpregs_keys =3D g_new(uint32_t, g_hash_table_size(cpu->cp= _regs)); + cpu->dyn_sysreg_xml.num =3D 0; + cpu->dyn_sysreg_xml.data.cpregs.keys =3D g_new(uint32_t, g_hash_table_= size(cpu->cp_regs)); g_string_printf(s, ""); g_string_append_printf(s, "= "); g_string_append_printf(s, ""); g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m= ); g_string_append_printf(s, ""); - cpu->dyn_xml.desc =3D g_string_free(s, false); - return cpu->dyn_xml.num_cpregs; + cpu->dyn_sysreg_xml.desc =3D g_string_free(s, false); + return cpu->dyn_sysreg_xml.num; } =20 const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) @@ -171,7 +171,7 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, const= char *xmlname) ARMCPU *cpu =3D ARM_CPU(cs); =20 if (strcmp(xmlname, "system-registers.xml") =3D=3D 0) { - return cpu->dyn_xml.desc; + return cpu->dyn_sysreg_xml.desc; } return NULL; } diff --git a/target/arm/helper.c b/target/arm/helper.c index c0e1ba17272..b0e2a85b005 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -208,7 +208,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteAr= ray *buf, int reg) const ARMCPRegInfo *ri; uint32_t key; =20 - key =3D cpu->dyn_xml.cpregs_keys[reg]; + key =3D cpu->dyn_sysreg_xml.data.cpregs.keys[reg]; ri =3D get_arm_cp_reginfo(cpu->cp_regs, key); if (ri) { if (cpreg_field_is_64bit(ri)) { @@ -7973,7 +7973,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) 19, "arm-vfp.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_xml(cs), + arm_gen_dynamic_sysreg_xml(cs), "system-registers.xml", 0); } =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383587; cv=none; d=zohomail.com; s=zohoarc; b=P3DPbif6eZFtHQ0QJmZ7MsEz/3Pfdh+knjBbpo6gr6451CzxFD4P9HdI4x0pMubEauNUXVqzyHVsRTZw0xlIhZwAtrGU7SOgOjbBOhzKPb5LOPznpEmD0aP6M/BDh6UNbb1fRcb+n8cRdyNWo0JA5qWjv6xv0eiWwPsATVTliaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383587; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rf/LMvxII2heeNzCF6U3r1/xn5UIkwc7L0VgJUldqH8=; b=NxvHenxfmPzueq2VkaQgHJkArk49BbanJ3kg7rroV1hPnpryQtlVI97ZynCdcLxeFky2vNygr/cSwc9fZyhzEp7mnolAQ+RuRD4BPx6qiycl1vu+bJUpfquG3WCbiiIHyaftGcgsRBJx9k+P6zvMGEDebaVDQYkx1fdg6v8pm0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383587508104.64226725820913; Mon, 16 Mar 2020 11:33:07 -0700 (PDT) Received: from localhost ([::1]:45996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuXy-0000MW-CB for importer@patchew.org; Mon, 16 Mar 2020 14:33:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53051) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXs-0003sW-8P for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXq-0002fN-Ho for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:56 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:50261) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXp-0002XG-JT for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:54 -0400 Received: by mail-wm1-x342.google.com with SMTP id z13so2550054wml.0 for ; Mon, 16 Mar 2020 10:28:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b187sm456863wmb.42.2020.03.16.10.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E0B951FF9F; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rf/LMvxII2heeNzCF6U3r1/xn5UIkwc7L0VgJUldqH8=; b=svhVWCHGR8twC23DwKqhWUWsC5Fwxk9kUMcyb3gsJ/9E469eDvQA5aW0EaL8gMK9lA 3oT9H8MtVQY/C8JS3+dbvZy726y3jPRqByRdoG8CaRfBryheqQYwT78jC5rwZ5Ayd/rV ktlnMREt2+/poFGyTkJZ2q0n6PavTEeszv3PccVrO6tAiunQFI6BImtbEtZ2iG3zQgN2 ZueReaYDJqGQEy69Y/9ANmseVvysLi2m0gijzFcQYBFIMe5R6urB2v65HtQ+GYDsjl+d xuLL1N0P4eaR+3paItwiaNVr2OovTqEax18m2S0ZyBqrkJO/OJGDZUBk5tYEE7dgvEO5 IJMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rf/LMvxII2heeNzCF6U3r1/xn5UIkwc7L0VgJUldqH8=; b=Cj+PZi9Fcs6u+Z2A0pn1DyunaVil/5LneCMkfBS3FZwT4guCf0xsO8mpfXwzwPaEi6 5AiiOhj5NvHUtbfO9LiXif23U5aUcdL73Rq5TzshlxnkqbhekGY4jfIKmHajCEhtSX/r SlY8YzJyYDaVMn3Vzg1fsuQrKfVU+8fAFn7E6WdfQTA0+WNVMclT+m/UW9yPEqWlG7uh wMC/5bvR4gUF0VBVuaUHf1qy4OJm/SejDq/3k147MyW0xDCltW3hoYtt1bWcSG/WwNv3 Ji3iKpcChPEa8Jl//Sj7falMFetsYrPY+ruvaUC02FRXo69ZQpv3wOgAH9n4YlSQZUam WvuA== X-Gm-Message-State: ANhLgQ1A5/oJPK0zjbzW8zllqA+8lOhsMo/lJuJenRvZCctLZyV7gReY I6srx7KMU1j9HcSDQA9Q7dFWnA== X-Google-Smtp-Source: ADFU+vtOPkrwmUwL9yr9TObk2KPDCiru4aZHcVIdEQvPw2w0DwWcH314P1iR7FJG7fbYleiB1ptkgA== X-Received: by 2002:a1c:b4c6:: with SMTP id d189mr180321wmf.132.1584379732510; Mon, 16 Mar 2020 10:28:52 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 16/28] target/arm: explicitly encode regnum in our XML Date: Mon, 16 Mar 2020 17:21:43 +0000 Message-Id: <20200316172155.971-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is described as optional but I'm not convinced of the numbering when multiple target fragments are sent. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v2 - post inc param->n in place so we don't get out count wrong --- target/arm/cpu.h | 2 +- target/arm/gdbstub.c | 17 +++++++++++------ target/arm/helper.c | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0ab82c987c3..fbfd73a7b5b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -980,7 +980,7 @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *= buf, int reg); /* Dynamically generates for gdb stub an XML description of the sysregs fr= om * the cp_regs hashtable. Returns the registered sysregs number. */ -int arm_gen_dynamic_sysreg_xml(CPUState *cpu); +int arm_gen_dynamic_sysreg_xml(CPUState *cpu, int base_reg); =20 /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 1f68ab98c3b..69c35462a63 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -24,6 +24,7 @@ typedef struct RegisterSysregXmlParam { CPUState *cs; GString *s; + int n; } RegisterSysregXmlParam; =20 /* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expect @@ -108,10 +109,11 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t = *mem_buf, int n) =20 static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_= xml, ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize) + int bitsize, int regnum) { g_string_append_printf(s, "name); g_string_append_printf(s, " bitsize=3D\"%d\"", bitsize); + g_string_append_printf(s, " regnum=3D\"%d\"", regnum); g_string_append_printf(s, " group=3D\"cp_regs\"/>"); dyn_xml->data.cpregs.keys[dyn_xml->num] =3D ri_key; dyn_xml->num++; @@ -131,7 +133,8 @@ static void arm_register_sysreg_for_xml(gpointer key, g= pointer value, if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state =3D=3D ARM_CP_STATE_AA64) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, + param->n++); } } else { if (ri->state =3D=3D ARM_CP_STATE_AA32) { @@ -140,20 +143,22 @@ static void arm_register_sysreg_for_xml(gpointer key,= gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64= ); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, + param->n++); } else { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32= ); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32, + param->n++); } } } } } =20 -int arm_gen_dynamic_sysreg_xml(CPUState *cs) +int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); - RegisterSysregXmlParam param =3D {cs, s}; + RegisterSysregXmlParam param =3D {cs, s, base_reg}; =20 cpu->dyn_sysreg_xml.num =3D 0; cpu->dyn_sysreg_xml.data.cpregs.keys =3D g_new(uint32_t, g_hash_table_= size(cpu->cp_regs)); diff --git a/target/arm/helper.c b/target/arm/helper.c index b0e2a85b005..90135731353 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7973,7 +7973,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) 19, "arm-vfp.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_xml(cs), + arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_re= gs), "system-registers.xml", 0); } =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584384352; cv=none; d=zohomail.com; s=zohoarc; b=gJVi64ks5OVCcjOaR7hf18SrmAwuCxDKxi3FTBHmJkxlELZbRYFkG1KCNBmd6dEfa0H3nFKoFHksCaaIdO1fYwFD+7tMDSkd95OEpRpR2qnR60tvAPud5SH4brX7eBXATmsKZqG2GfRyWOLiDIM+2TOVyHjv+7fc8FOdaDozc/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584384352; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UdceRZMx4YDGn36m/TuGYIDWW+EU+85/3c2Xpq92Mq4=; b=PA0xYveNwSyHhcDbWkWiHg7LbAXeJNooq8tngwoeba+IzbOxw96Y4Z1djSUkayxZISLZFwal2NijfEI8UMiJNVRE3mlBOxtC2hBnWzoL7YwFFSXc/f2YIQuAlWBgpI7sd7I5neIV4JhvAmAHpUUR1qE8ocmG5vos3B9hsTIJN40= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158438435284382.82673381390032; Mon, 16 Mar 2020 11:45:52 -0700 (PDT) Received: from localhost ([::1]:46468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDukJ-0006TI-Pq for importer@patchew.org; Mon, 16 Mar 2020 14:45:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52820) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXm-0003hx-VJ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXl-0002El-AS for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:50 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:38472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXk-0001zm-Ft for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:48 -0400 Received: by mail-wm1-x341.google.com with SMTP id t13so12653886wmi.3 for ; Mon, 16 Mar 2020 10:28:43 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g14sm440424wme.32.2020.03.16.10.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0010B1FFA5; Mon, 16 Mar 2020 17:21:56 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UdceRZMx4YDGn36m/TuGYIDWW+EU+85/3c2Xpq92Mq4=; b=MulPUpNL8G/3/1U06g8BTkaE+/mzMxNTnL2VmFXU8p7nCCYilNDJvsQWkcXAQijNCM 89wsw19RD1O8qdK1qOHJqwreYyG6IaR/ooK4lju1Xq4ZHPDqoaGcky05pZ2h73FFhGar Kuj/1lPL7i0j0umFV6f5/BjZM9dS3OcyE60bDKdz4VHIQ13ALq3xEjeWKlYbWyITquao AaulHVfT/M0+CDdXXhUJsHfXnEJQF7dik0XM8jGXIh5R/LHNxOMAEL+O3YgLf79SOOgy 9W+K3G97GnNYB+vA1GyG+zVBlc7nagtS0yvlMIw33/uTrNgOUxq6cj6gpgjb1D1Oo6T3 otZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UdceRZMx4YDGn36m/TuGYIDWW+EU+85/3c2Xpq92Mq4=; b=dihgJ+TUyUkzg5HSzG1HWTLMqjf+uXMkYu19mZw3PK9Ypl/wB/jlYC93iMdvo+BH6n G7HuCpZtdrgcbKLTCUidVtKJdY2tJckyMcq3V9Hwt1ZebYuH6GRQ0zG36UCdWmvBBfb1 yY3ka4SyzwMVE+bulbQDl2S6I+1hkA3CV/q5AAKh4iBN1RRU7TOb1sPu+Uryk9uSCAuz DVEVrC+taNArITT0BV+bSSjw6eJn2ObOgX0YqkYiDJY02RwMRaWqAtqjRmjaUq4sYZZT QwVUcr8pO3WcwotBAdqKRmU2shMMPD8ZGGdnnSS7QuZaWY3JiCvSg/ufyp5NKrpauvWa 3Tkw== X-Gm-Message-State: ANhLgQ0tgbC6Y6AgHlSgo4YmGF2DKHMmAv5LaLR1+uCtn5Mt+bkCvUTg qDygQU5uhbaeeRUcQz7FOqNbhA== X-Google-Smtp-Source: ADFU+vv2jDKSKL3Rarpps/8WQFaa6eZxefrGPoWqJveV/Uz99vq/uO5cqjYJ/pwH76k52abi5IkyjQ== X-Received: by 2002:a7b:c454:: with SMTP id l20mr154054wmi.189.1584379722327; Mon, 16 Mar 2020 10:28:42 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 17/28] target/arm: default SVE length to 64 bytes for linux-user Date: Mon, 16 Mar 2020 17:21:44 +0000 Message-Id: <20200316172155.971-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The Linux kernel chooses the default of 64 bytes for SVE registers on the basis that it is the largest size on known hardware that won't grow the signal frame. We still honour the sve-max-vq property and userspace can expand the number of lanes by calling PR_SVE_SET_VL. This should not make any difference to SVE enabled software as the SVE is of course vector length agnostic. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v2 - tweak zcr_el[1] instead v7 - better form --- target/arm/cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 3623ecefbd9..0909ce86a12 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -195,9 +195,10 @@ static void arm_cpu_reset(CPUState *s) env->cp15.cpacr_el1 =3D deposit64(env->cp15.cpacr_el1, 20, 2, 3); /* and to the SVE instructions */ env->cp15.cpacr_el1 =3D deposit64(env->cp15.cpacr_el1, 16, 2, 3); - /* with maximum vector length */ - env->vfp.zcr_el[1] =3D cpu_isar_feature(aa64_sve, cpu) ? - cpu->sve_max_vq - 1 : 0; + /* with reasonable vector length */ + if (cpu_isar_feature(aa64_sve, cpu)) { + env->vfp.zcr_el[1] =3D MIN(cpu->sve_max_vq - 1, 3); + } /* * Enable TBI0 and TBI1. While the real kernel only enables TBI0, * turning on both here will produce smaller code and otherwise --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383064; cv=none; d=zohomail.com; s=zohoarc; b=dO73bfyeExP5N90aKrRGxWJDY58+SuhiKVzBlQQPnpxPg3fM9+glN9WLQXhlKGrSmR3RXhC53VNjU6JLU7Y9UsjytU+HItS0mR6VYObWDc4VypeMTdh0AnRahy1LAoLaAotYkxLMOgah5JVe80qPG50HTbyyTLNdEk9DB6WVc44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383064; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yUqZL/+EsOIhpSixaMOYl0gTsp0kyBV675HHFe8iFMo=; b=XMD9yyXxhP8ijvhAyXEMf+t4TBswjzRjkXFkn8rmO7Hm3KbT8C8/EMYUVIr9BYfwvtkD1e+P6gypj0uVjk6/ohmcAivmahmAaYIwrTxrPrnt4cpTj37/dXpASfUyOCPwdVR7UzBdL79xhm2HHvjQB8EVN7fuw7gWGLONjBMKdkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383064864809.2375996538063; Mon, 16 Mar 2020 11:24:24 -0700 (PDT) Received: from localhost ([::1]:45736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuPX-0002m7-PO for importer@patchew.org; Mon, 16 Mar 2020 14:24:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52805) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXm-0003hP-O2 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXj-00023c-HP for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:50 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35441) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXf-0001xk-E8 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:44 -0400 Received: by mail-wm1-x342.google.com with SMTP id m3so19006973wmi.0 for ; Mon, 16 Mar 2020 10:28:39 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x17sm465210wmi.28.2020.03.16.10.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 17D241FFA6; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yUqZL/+EsOIhpSixaMOYl0gTsp0kyBV675HHFe8iFMo=; b=iV90Vo5zQtHo+/3KEwDM+d2FBYneCuuNVz8T4cqYF7PpyzXfLxiUjcUR0wvmV0GfvY +/OBoRORhWOTMX7FqIg/EwZ2iaxt/K7B6F9Wu2xfFuhDo5YZgxLCP6fznU3zHb9lWjQ+ rkBuFehiHClM13lSss4v+Repuu8e39M4kzYgtw3NqU5Bhdse5tkEuxaIOcSiC0E0kNeO btGkMcIql6d4ZrqQUmY+y9xI3yfclLQeqK4zhpViH+E/7AXf4dovBglp82kqo7iCt4HL Eh3WHQJ39Ll8CQsV19w089Jh8uCqx6rP1rZcBi9uzRKEd7K7CmCpAdP9kvjx+Q+ueTWW 9qwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yUqZL/+EsOIhpSixaMOYl0gTsp0kyBV675HHFe8iFMo=; b=nWlsLyxibn++Iz/2Q4W7bVpuT/fLl9Jev/sNutrCkuU9o1v9Nix7ndqsm+G2TeWqru X6gKODiTiXbfk8TMsWi1v0CfeOTW7RHWQts32WzFyhaApT+QmxEOEjK/Frj0fTqO0vmo 4CUAWifuU8XwcIvWKDceM9rpdV3cdKPu3JFI1PG/22l7LZcsqJxC2sv6akXqefD72FIA /6/gbZ98EzBRE90RcRmYuMW2HVVzYiGi/bYw/wadenEoi6X0Ky8uc003Pj0K/R+yCTFw 6Goc6wjzTQ+t9QVqh6x+HJkOIk2zHvIlnOnNYgLjwrfFXJgzan2mN7CaRoDQ4HNSTC+2 joRA== X-Gm-Message-State: ANhLgQ2XjvrLGLp62/KLqQzGL3tXGNlUX+qAIPEyvz50nx4WDk56Hj3t 7J/4FzIMUGrwZEGvui+UUnmxwQ== X-Google-Smtp-Source: ADFU+vsTbxJ0mDaj7IKSkZgExZLDl3LO+cxeuSbsqOtEuiRkeysTsjWFfXSx+eC8+gXh4f2hwj1QCw== X-Received: by 2002:a05:600c:258:: with SMTP id 24mr163187wmj.59.1584379718264; Mon, 16 Mar 2020 10:28:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 18/28] target/arm: generate xml description of our SVE registers Date: Mon, 16 Mar 2020 17:21:45 +0000 Message-Id: <20200316172155.971-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We also expose a the helpers to read/write the the registers. Signed-off-by: Alex Benn=C3=A9e Acked-by: Richard Henderson --- v2 - instead of zNpM expose zN at sve_max_vq width - wrap union in union q(us), d(usf), s(usf), h(usf), b(us) v3 - add a vg pseudo register for current width - spacing fixes - use switch/case for whole group - drop fpsr_pos marker - remove unused variables v4 - const-ify vec_lanes - drop vg v6 - restore vg based on sve_zcr_len_for_el(env, arm_current_el(env)) + 1) v7 - vg =3D vq * 2 --- target/arm/cpu.h | 7 ++- target/arm/gdbstub.c | 134 +++++++++++++++++++++++++++++++++++++++++++ target/arm/helper.c | 125 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 261 insertions(+), 5 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index fbfd73a7b5b..8b9f2961ba0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -756,6 +756,7 @@ struct ARMCPU { int32_t cpreg_vmstate_array_len; =20 DynamicGDBXMLInfo dyn_sysreg_xml; + DynamicGDBXMLInfo dyn_svereg_xml; =20 /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; @@ -977,10 +978,12 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cp= u, vaddr addr, int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 -/* Dynamically generates for gdb stub an XML description of the sysregs fr= om - * the cp_regs hashtable. Returns the registered sysregs number. +/* + * Helpers to dynamically generates XML descriptions of the sysregs + * and SVE registers. Returns the number of registers in each set. */ int arm_gen_dynamic_sysreg_xml(CPUState *cpu, int base_reg); +int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); =20 /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 69c35462a63..d9ef7d2187c 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -171,12 +171,146 @@ int arm_gen_dynamic_sysreg_xml(CPUState *cs, int bas= e_reg) return cpu->dyn_sysreg_xml.num; } =20 +struct TypeSize { + const char *gdb_type; + int size; + const char sz, suffix; +}; + +static const struct TypeSize vec_lanes[] =3D { + /* quads */ + { "uint128", 128, 'q', 'u' }, + { "int128", 128, 'q', 's' }, + /* 64 bit */ + { "uint64", 64, 'd', 'u' }, + { "int64", 64, 'd', 's' }, + { "ieee_double", 64, 'd', 'f' }, + /* 32 bit */ + { "uint32", 32, 's', 'u' }, + { "int32", 32, 's', 's' }, + { "ieee_single", 32, 's', 'f' }, + /* 16 bit */ + { "uint16", 16, 'h', 'u' }, + { "int16", 16, 'h', 's' }, + { "ieee_half", 16, 'h', 'f' }, + /* bytes */ + { "uint8", 8, 'b', 'u' }, + { "int8", 8, 'b', 's' }, +}; + + +int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + GString *s =3D g_string_new(NULL); + DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; + g_autoptr(GString) ts =3D g_string_new(""); + int i, bits, reg_width =3D (cpu->sve_max_vq * 128); + info->num =3D 0; + g_string_printf(s, ""); + g_string_append_printf(s, "= "); + g_string_append_printf(s, ""); + + /* First define types and totals in a whole VL */ + for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { + int count =3D reg_width / vec_lanes[i].size; + g_string_printf(ts, "vq%d%c%c", count, + vec_lanes[i].sz, vec_lanes[i].suffix); + g_string_append_printf(s, + "", + ts->str, vec_lanes[i].gdb_type, count); + } + /* + * Now define a union for each size group containing unsigned and + * signed and potentially float versions of each size from 128 to + * 8 bits. + */ + for (bits =3D 128; bits >=3D 8; bits /=3D 2) { + int count =3D reg_width / bits; + g_string_append_printf(s, "", count); + for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { + if (vec_lanes[i].size =3D=3D bits) { + g_string_append_printf(s, "", + vec_lanes[i].suffix, + count, + vec_lanes[i].sz, vec_lanes[i].suffi= x); + } + } + g_string_append(s, ""); + } + /* And now the final union of unions */ + g_string_append(s, ""); + for (bits =3D 128; bits >=3D 8; bits /=3D 2) { + int count =3D reg_width / bits; + for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { + if (vec_lanes[i].size =3D=3D bits) { + g_string_append_printf(s, "", + vec_lanes[i].sz, count); + break; + } + } + } + g_string_append(s, ""); + + /* Then define each register in parts for each vq */ + for (i =3D 0; i < 32; i++) { + g_string_append_printf(s, + "", + i, reg_width, base_reg++); + info->num++; + } + /* fpscr & status registers */ + g_string_append_printf(s, "", base_reg++); + g_string_append_printf(s, "", base_reg++); + info->num +=3D 2; + /* + * Predicate registers aren't so big they are worth splitting up + * but we do need to define a type to hold the array of quad + * references. + */ + g_string_append_printf(s, + "", + cpu->sve_max_vq); + for (i =3D 0; i < 16; i++) { + g_string_append_printf(s, + "", + i, cpu->sve_max_vq * 16, base_reg++); + info->num++; + } + g_string_append_printf(s, + "", + cpu->sve_max_vq * 16, base_reg++); + g_string_append_printf(s, + "", + base_reg++); + info->num +=3D 2; + g_string_append_printf(s, ""); + cpu->dyn_svereg_xml.desc =3D g_string_free(s, false); + + return cpu->dyn_svereg_xml.num; +} + + const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) { ARMCPU *cpu =3D ARM_CPU(cs); =20 if (strcmp(xmlname, "system-registers.xml") =3D=3D 0) { return cpu->dyn_sysreg_xml.desc; + } else if (strcmp(xmlname, "sve-registers.xml") =3D=3D 0) { + return cpu->dyn_svereg_xml.desc; } return NULL; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 90135731353..7e560ea7db6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -202,6 +202,15 @@ static void write_raw_cp_reg(CPUARMState *env, const A= RMCPRegInfo *ri, } } =20 +/** + * arm_get/set_gdb_*: get/set a gdb register + * @env: the CPU state + * @buf: a buffer to copy to/from + * @reg: register number (offset from start of group) + * + * We return the number of bytes copied + */ + static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu =3D env_archcpu(env); @@ -225,6 +234,102 @@ static int arm_gdb_set_sysreg(CPUARMState *env, uint8= _t *buf, int reg) return 0; } =20 +#ifdef TARGET_AARCH64 +static int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg) +{ + ARMCPU *cpu =3D env_archcpu(env); + + switch (reg) { + /* The first 32 registers are the zregs */ + case 0 ... 31: + { + int vq, len =3D 0; + for (vq =3D 0; vq < cpu->sve_max_vq; vq++) { + len +=3D gdb_get_reg128(buf, + env->vfp.zregs[reg].d[vq * 2 + 1], + env->vfp.zregs[reg].d[vq * 2]); + } + return len; + } + case 32: + return gdb_get_reg32(buf, vfp_get_fpsr(env)); + case 33: + return gdb_get_reg32(buf, vfp_get_fpcr(env)); + /* then 16 predicates and the ffr */ + case 34 ... 50: + { + int preg =3D reg - 34; + int vq, len =3D 0; + for (vq =3D 0; vq < cpu->sve_max_vq; vq =3D vq + 4) { + len +=3D gdb_get_reg64(buf, env->vfp.pregs[preg].p[vq / 4]); + } + return len; + } + case 51: + { + /* + * We report in Vector Granules (VG) which is 64bit in a Z reg + * while the ZCR works in Vector Quads (VQ) which is 128bit chunks. + */ + int vq =3D sve_zcr_len_for_el(env, arm_current_el(env)) + 1; + return gdb_get_reg32(buf, vq * 2); + } + default: + /* gdbstub asked for something out our range */ + qemu_log_mask(LOG_UNIMP, "%s: out of range register %d", __func__,= reg); + break; + } + + return 0; +} + +static int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg) +{ + ARMCPU *cpu =3D env_archcpu(env); + + /* The first 32 registers are the zregs */ + switch (reg) { + /* The first 32 registers are the zregs */ + case 0 ... 31: + { + int vq, len =3D 0; + uint64_t *p =3D (uint64_t *) buf; + for (vq =3D 0; vq < cpu->sve_max_vq; vq++) { + env->vfp.zregs[reg].d[vq * 2 + 1] =3D *p++; + env->vfp.zregs[reg].d[vq * 2] =3D *p++; + len +=3D 16; + } + return len; + } + case 32: + vfp_set_fpsr(env, *(uint32_t *)buf); + return 4; + case 33: + vfp_set_fpcr(env, *(uint32_t *)buf); + return 4; + case 34 ... 50: + { + int preg =3D reg - 34; + int vq, len =3D 0; + uint64_t *p =3D (uint64_t *) buf; + for (vq =3D 0; vq < cpu->sve_max_vq; vq =3D vq + 4) { + env->vfp.pregs[preg].p[vq / 4] =3D *p++; + len +=3D 8; + } + return len; + } + case 51: + /* cannot set vg via gdbstub */ + return 0; + default: + /* gdbstub asked for something out our range */ + break; + } + + return 0; +} +#endif /* TARGET_AARCH64 */ + static bool raw_accessors_invalid(const ARMCPRegInfo *ri) { /* Return true if the regdef would cause an assertion if you called @@ -7959,9 +8064,22 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *= cpu) CPUARMState *env =3D &cpu->env; =20 if (arm_feature(env, ARM_FEATURE_AARCH64)) { - gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, - aarch64_fpu_gdb_set_reg, - 34, "aarch64-fpu.xml", 0); + /* + * The lower part of each SVE register aliases to the FPU + * registers so we don't need to include both. + */ +#ifdef TARGET_AARCH64 + if (isar_feature_aa64_sve(&cpu->isar)) { + gdb_register_coprocessor(cs, arm_gdb_get_svereg, arm_gdb_set_s= vereg, + arm_gen_dynamic_svereg_xml(cs, cs->gd= b_num_regs), + "sve-registers.xml", 0); + } else +#endif + { + gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, + aarch64_fpu_gdb_set_reg, + 34, "aarch64-fpu.xml", 0); + } } else if (arm_feature(env, ARM_FEATURE_NEON)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, 51, "arm-neon.xml", 0); @@ -7975,6 +8093,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_re= gs), "system-registers.xml", 0); + } =20 /* Sort alphabetically by type name, except for "any". */ --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381452; cv=none; d=zohomail.com; s=zohoarc; b=T6fdMK6YkmVpvXXtl0XoG3oSjG0WN68V8lMaqooqLFYLNj1ilER5ca6+ZtNbsgp+6mZaT/XxFhAa/Y9yGh1jNUZFWj0xlAMk9BHoFxriMPUtx1RJurwW6VrlSVGtGLa+JliUzJV3QNO+vFjwiF9iFwIVRrKpLMCwOjooQGZdO0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381452; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rvaiifYyk1RViqBZpnA3TLxfK5zQc95A6+zRBD5/52M=; b=O4Ehe1hA2Qj8WyYFQgJvXkHJeN8nSyzebomIFX/o7uQOhbfAN3p7H1b6B9A8qa3IsqUiL9fAss6cXTPB/N8aIyjJ+onFr6Llhx+aNh+5qPhGWLqs+TRskQTYCkMehER3SeFAM/Ksb2dylGYiWWRosMnTmchJOhjoetS6DG3islo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381452123204.2150508834327; Mon, 16 Mar 2020 10:57:32 -0700 (PDT) Received: from localhost ([::1]:45056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtzX-00069g-3G for importer@patchew.org; Mon, 16 Mar 2020 13:57:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52897) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXo-0003lR-J7 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXn-0002Jo-1A for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:52 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:38476) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXm-0002A3-MZ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:50 -0400 Received: by mail-wm1-x344.google.com with SMTP id t13so12654169wmi.3 for ; Mon, 16 Mar 2020 10:28:48 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 19sm497839wma.3.2020.03.16.10.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2C17A1FFA9; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rvaiifYyk1RViqBZpnA3TLxfK5zQc95A6+zRBD5/52M=; b=FPos7bLbtVGgbCB5ORjcjH1hMavXhVb44sAoP/fHBoS2tEKejLToGziqcOqnhKYWdn 47cA+PK2PMnN9QR8ojn0Hs4OrpO3HSceXk/aBU79ACfwljwAhav0FAAGu0myjrmVLIW2 kCDR+DdkMnSmMBaYzRkhBWmRw9bJDjp9M98DpV9gmbP9a859RWBFA8Z/vcVCrMVIJTyu sY+U5iXTYbMpkIp4PkEgpPl74up/3eAUVEvpqL1eJqi6DzmHRc7NYNwHRrmtACDaKSee q/xJgYbeJXr7ZbSfgH7a4epo+ts2fQXDCjPVNNpqmxCSNCA01sS5lGH6b6hQ7XBmqG8P begA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rvaiifYyk1RViqBZpnA3TLxfK5zQc95A6+zRBD5/52M=; b=CB60BIatgXog1f6hQHrvCevh07v/4VHCrcG2IKDB/ogKW8TjwZS5EeYgJSz0DUStcv 91X0MxJLAU8iwsXw2sPKp2Ry2vnnigRTdbN2Sh7ob7LbfkPlTUkBgbMsPo+usLiVVsb3 yB168uERuGbYcLAPAdW8TBgGwC3R1hoOuTsBJk4K0w4014i9K+vixVZfFb7zNOGAOjR+ AS3yOJQw6fAHi3VRr6c026TLMQSYowDWuwROAsKBkMrncSJiRZiuLSp0iRV9du1hk+1d Hz+6L2MviK00hPj0n15870vRUOWWyFd/cYI20SUDw63xuuo3xM2YMFdWPpLRj6HzoHSy 3OQw== X-Gm-Message-State: ANhLgQ2YB7WV1C5z4QCOAvU6IuiOSV79jI8D6VZSuUYh3y2AMWMbJdbO jK/NSukg9bHDmx39qj5/8ejH9Q== X-Google-Smtp-Source: ADFU+vsoILpgjQ4Ub1NvESZwH0gNTN69XRh69vh8mikRXMAhTz2ctFJi0b5swPmodo7e5M9/Lo/L4w== X-Received: by 2002:a7b:c4cc:: with SMTP id g12mr206700wmk.104.1584379728017; Mon, 16 Mar 2020 10:28:48 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 19/28] target/arm: don't bother with id_aa64pfr0_read for USER_ONLY Date: Mon, 16 Mar 2020 17:21:46 +0000 Message-Id: <20200316172155.971-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) For system emulation we need to check the state of the GIC before we report the value. However this isn't relevant to exporting of the value to linux-user and indeed breaks the exported value as set by modify_arm_cp_regs. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v2 - extend the ifdef and make type CONST with no accessfn --- target/arm/helper.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7e560ea7db6..d2ec2c53510 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6697,6 +6697,7 @@ static uint64_t id_pfr1_read(CPUARMState *env, const = ARMCPRegInfo *ri) return pfr1; } =20 +#ifndef CONFIG_USER_ONLY static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) { ARMCPU *cpu =3D env_archcpu(env); @@ -6707,6 +6708,7 @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, co= nst ARMCPRegInfo *ri) } return pfr0; } +#endif =20 /* Shared logic between LORID and the rest of the LOR* registers. * Secure state has already been delt with. @@ -7280,16 +7282,24 @@ void register_cp_regs_for_features(ARMCPU *cpu) * define new registers here. */ ARMCPRegInfo v8_idregs[] =3D { - /* ID_AA64PFR0_EL1 is not a plain ARM_CP_CONST because we don't - * know the right value for the GIC field until after we - * define these regs. + /* + * ID_AA64PFR0_EL1 is not a plain ARM_CP_CONST in system + * emulation because we don't know the right value for the + * GIC field until after we define these regs. */ { .name =3D "ID_AA64PFR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 4, .opc2 =3D = 0, - .access =3D PL1_R, .type =3D ARM_CP_NO_RAW, + .access =3D PL1_R, +#ifdef CONFIG_USER_ONLY + .type =3D ARM_CP_CONST, + .resetvalue =3D cpu->isar.id_aa64pfr0 +#else + .type =3D ARM_CP_NO_RAW, .accessfn =3D access_aa64_tid3, .readfn =3D id_aa64pfr0_read, - .writefn =3D arm_cp_write_ignore }, + .writefn =3D arm_cp_write_ignore +#endif + }, { .name =3D "ID_AA64PFR1_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 4, .opc2 =3D = 1, .access =3D PL1_R, .type =3D ARM_CP_CONST, --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381585; cv=none; d=zohomail.com; s=zohoarc; b=QeYlNDPUQBNsqijcKhf74zcMJEui38sgW68B2JNCX0UelxZ1Ee1VXwZrfFuE3fy08Cd3vJJlkwAvknKLesJcM6QylG6Oh9virgzhzX0cUd7jwadX8kPMAUBxtQ797h471OJw61JforbbcRUPX2qjFfGeuplrd9bEcoetv4Ks1Cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MAHQhCP1EsmDE6wKXYKQ2zDHbwGxedIVpJYdWHpls/o=; b=ld85pMTLYWWvrTZxZzNrfIEusCEt8xCMyZlZJmcr9AC8aEXbYOvhJHkE3UewqQyueC9K1igBdlKpjRIIPJJIYTLhXDnotvQP0Ace3cfD8F+MSTQ3KaSBnVm18AAXqDVT9yBqeBpBITEiW4pO235pWKph6d7e/eORnYct0wNtdfI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381585422426.3658691740029; Mon, 16 Mar 2020 10:59:45 -0700 (PDT) Received: from localhost ([::1]:45112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDu1g-0001fa-BV for importer@patchew.org; Mon, 16 Mar 2020 13:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52872) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXo-0003jw-0F for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXm-0002GG-3m for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:51 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:39437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXk-00020M-Pm for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:48 -0400 Received: by mail-wm1-x343.google.com with SMTP id f7so18999895wml.4 for ; Mon, 16 Mar 2020 10:28:44 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a186sm446743wmh.33.2020.03.16.10.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 422431FFAA; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MAHQhCP1EsmDE6wKXYKQ2zDHbwGxedIVpJYdWHpls/o=; b=ww+aZF5OpnWN5e2C6qHOIqmZLHQtZ/WjQ9gNDlJN6ZyLGJQvihBhJzt+1zwEazRh8p r7tDOpd8UDrNO5y9aZr3+LpewTVUztHfSqtPBxbSSIJIHwaGYoepg/DLpeIZbRLh+lNR MUF/bf3YKfk2ONZphBbgNm+ey7E1ejYFzF3UXrf65Dk+F/qKxTup0VsFr+M2CJlxfine ekWJq3oRVcs8sfCiZf9CWTXQWmd1NHMFOAHfzudiZL+bAkgE6XzmVRGom4vwFX7+0txb 9I21iGbPicaklv1ynaccdJd5ZE7LIoOKP87+5c7KGk3U68CXHek9WnZtpNiuP60JINoD 3/kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MAHQhCP1EsmDE6wKXYKQ2zDHbwGxedIVpJYdWHpls/o=; b=EH9u3/3RaS7/eSzTSHSblYxZsRXhVci42u2TR8ewsE1Dio4RZ08DpNP1+OAIFOGE11 49sqxChHvnHw8AfYVc1wSf/BA96XsDXetfqecCT3ZvaX/VkMcFtqgWoJ2n5ElFFSZ3nr 1JGCuVGAvxuXxRidhRdbb51tjQ5CAhn778+QPsTg9pvxYECws9AbVpmC9Roo+wF0gyKO RIFfV25VnOQhZDtW9rVIvuklcC3dnyXJfpIehYbvKmsI3Vl9RNdiw6WUUh5R/jsQhPVc DB9B1Bg0Z24AYCzZm21sQn63JZw9jx69/0LOrRMaHcjTC18Cb56vxqvLrWDOx3+Tu6XD jTkQ== X-Gm-Message-State: ANhLgQ0sgvQ75jHcbdQIPo3ULSTEpdOOqZlJRODLbjGRKkr6K5kAOXW4 WPuyPYL40WIEPfI1DX2cY2392Q== X-Google-Smtp-Source: ADFU+vvimbDUmZ5ULfnXKeABWmJ5G5n/o51aolPJk+z6auQ+u5hZbNkHtum4VgZV/o9S929KmS8iFg== X-Received: by 2002:a1c:750e:: with SMTP id o14mr178869wmc.156.1584379723271; Mon, 16 Mar 2020 10:28:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 20/28] tests/tcg/aarch64: userspace system register test Date: Mon, 16 Mar 2020 17:21:47 +0000 Message-Id: <20200316172155.971-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This tests a bunch of registers that the kernel allows userspace to read including the CPUID registers. We need a SVE aware compiler as we are testing the id_aa64zfr0_el1 register in the set. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20190205190224.2198-7-alex.bennee@linaro.org> --- vgdbstub - don't build unless using docker or CROSS_CC_HAS_SVE --- tests/tcg/aarch64/sysregs.c | 172 ++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 6 ++ 2 files changed, 178 insertions(+) create mode 100644 tests/tcg/aarch64/sysregs.c diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c new file mode 100644 index 00000000000..40cf8d2877e --- /dev/null +++ b/tests/tcg/aarch64/sysregs.c @@ -0,0 +1,172 @@ +/* + * Check emulated system register access for linux-user mode. + * + * See: https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registe= rs.txt + * + * Copyright (c) 2019 Linaro + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_CPUID +#define HWCAP_CPUID (1 << 11) +#endif + +int failed_bit_count; + +/* Read and print system register `id' value */ +#define get_cpu_reg(id) ({ \ + unsigned long __val =3D 0xdeadbeef; \ + asm("mrs %0, "#id : "=3Dr" (__val)); \ + printf("%-20s: 0x%016lx\n", #id, __val); \ + __val; \ + }) + +/* As above but also check no bits outside of `mask' are set*/ +#define get_cpu_reg_check_mask(id, mask) ({ \ + unsigned long __cval =3D get_cpu_reg(id); \ + unsigned long __extra =3D __cval & ~mask; \ + if (__extra) { \ + printf("%-20s: 0x%016lx\n", " !!extra bits!!", __extra); = \ + failed_bit_count++; \ + } \ +}) + +/* As above but check RAZ */ +#define get_cpu_reg_check_zero(id) ({ \ + unsigned long __val =3D 0xdeadbeef; \ + asm("mrs %0, "#id : "=3Dr" (__val)); \ + if (__val) { \ + printf("%-20s: 0x%016lx (not RAZ!)\n", #id, __val); = \ + failed_bit_count++; \ + } \ +}) + +/* Chunk up mask into 63:48, 47:32, 31:16, 15:0 to ease counting */ +#define _m(a, b, c, d) (0x ## a ## b ## c ## d ##ULL) + +bool should_fail; +int should_fail_count; +int should_not_fail_count; +uintptr_t failed_pc[10]; + +void sigill_handler(int signo, siginfo_t *si, void *data) +{ + ucontext_t *uc =3D (ucontext_t *)data; + + if (should_fail) { + should_fail_count++; + } else { + uintptr_t pc =3D (uintptr_t) uc->uc_mcontext.pc; + failed_pc[should_not_fail_count++] =3D pc; + } + uc->uc_mcontext.pc +=3D 4; +} + +int main(void) +{ + struct sigaction sa; + + /* Hook in a SIGILL handler */ + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_flags =3D SA_SIGINFO; + sa.sa_sigaction =3D &sigill_handler; + sigemptyset(&sa.sa_mask); + + if (sigaction(SIGILL, &sa, 0) !=3D 0) { + perror("sigaction"); + return 1; + } + + /* Counter values have been exposed since Linux 4.12 */ + printf("Checking Counter registers\n"); + + get_cpu_reg(ctr_el0); + get_cpu_reg(cntvct_el0); + get_cpu_reg(cntfrq_el0); + + /* HWCAP_CPUID indicates we can read feature registers, since Linux 4.= 11 */ + if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { + printf("CPUID registers unavailable\n"); + return 1; + } else { + printf("Checking CPUID registers\n"); + } + + /* + * Some registers only expose some bits to user-space. Anything + * that is IMPDEF is exported as 0 to user-space. The _mask checks + * assert no extra bits are set. + * + * This check is *not* comprehensive as some fields are set to + * minimum valid fields - for the purposes of this check allowed + * to have non-zero values. + */ + get_cpu_reg_check_mask(id_aa64isar0_el1, _m(00ff,ffff,f0ff,fff0)); + get_cpu_reg_check_mask(id_aa64isar1_el1, _m(0000,00f0,ffff,ffff)); + /* TGran4 & TGran64 as pegged to -1 */ + get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(0000,0000,ff00,0000)); + get_cpu_reg_check_zero(id_aa64mmfr1_el1); + /* EL1/EL0 reported as AA64 only */ + get_cpu_reg_check_mask(id_aa64pfr0_el1, _m(000f,000f,00ff,0011)); + get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0000,00f0)); + /* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */ + get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006)); + get_cpu_reg_check_zero(id_aa64dfr1_el1); + get_cpu_reg_check_zero(id_aa64zfr0_el1); + + get_cpu_reg_check_zero(id_aa64afr0_el1); + get_cpu_reg_check_zero(id_aa64afr1_el1); + + get_cpu_reg_check_mask(midr_el1, _m(0000,0000,ffff,ffff)); + /* mpidr sets bit 31, everything else hidden */ + get_cpu_reg_check_mask(mpidr_el1, _m(0000,0000,8000,0000)); + /* REVIDR is all IMPDEF so should be all zeros to user-space */ + get_cpu_reg_check_zero(revidr_el1); + + /* + * There are a block of more registers that are RAZ in the rest of + * the Op0=3D3, Op1=3D0, CRn=3D0, CRm=3D0,4,5,6,7 space. However for + * brevity we don't check stuff that is currently un-allocated + * here. Feel free to add them ;-) + */ + + printf("Remaining registers should fail\n"); + should_fail =3D true; + + /* Unexposed register access causes SIGILL */ + get_cpu_reg(id_mmfr0_el1); + get_cpu_reg(id_mmfr1_el1); + get_cpu_reg(id_mmfr2_el1); + get_cpu_reg(id_mmfr3_el1); + + get_cpu_reg(mvfr0_el1); + get_cpu_reg(mvfr1_el1); + + if (should_not_fail_count > 0) { + int i; + for (i =3D 0; i < should_not_fail_count; i++) { + uintptr_t pc =3D failed_pc[i]; + uint32_t insn =3D *(uint32_t *) pc; + printf("insn %#x @ %#lx unexpected FAIL\n", insn, pc); + } + return 1; + } + + if (failed_bit_count > 0) { + printf("Extra information leaked to user-space!\n"); + return 1; + } + + return should_fail_count =3D=3D 6 ? 0 : 1; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index 8ed477d0d51..a25afc071cc 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -42,4 +42,10 @@ run-semiconsole: semiconsole run-plugin-semiconsole-with-%: $(call skip-test, $<, "MANUAL ONLY") =20 +ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) +# System Registers Tests +AARCH64_TESTS +=3D sysregs +sysregs: CFLAGS+=3D-march=3Darmv8.1-a+sve +endif + TESTS +=3D $(AARCH64_TESTS) --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383184; cv=none; d=zohomail.com; s=zohoarc; b=Dk6boJsShsmUNqJ/9Gsmmds4HrILna86l+8GrsGwNTqNr+3lPGXkIa+sEyrJaVj5s82hQ1pyjfTwYPLqOrSjcBxMoIw8PYO+IKXJNVsMXO81SPXPjBrr1llh3N0SeljpBP70HE2t8yqpGxk4pfnkS/+f4Hdu0wj3PApdgKLCUQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383184; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r0mbXI1FyMLDM5RVM9EU8oKyEvhKwmvfb7Yp7qK5ioM=; b=P21hnhvlGCv9x9Gxq+fapdBWRsa1XbtsGHtYt4CGikeEG/ccNF6UCrhcw3ZLYfqMQK1gJK6Ym60OSPof9iUNd4mvMS8sKzWCPNbLcNFUIIoKD6bCS49k5B++5p1Uwhg3wonxHPvuJvtCRCci2LObWS0T1soDDDCW6HHCzvRDvK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383184633827.9856384229882; Mon, 16 Mar 2020 11:26:24 -0700 (PDT) Received: from localhost ([::1]:45792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuRT-0006Db-JL for importer@patchew.org; Mon, 16 Mar 2020 14:26:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52836) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXn-0003id-9Y for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXl-0002FC-Vz for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:51 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:43158) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXk-00022H-Bp for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:48 -0400 Received: by mail-wr1-x42a.google.com with SMTP id b2so16053190wrj.10 for ; Mon, 16 Mar 2020 10:28:45 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b10sm818520wrm.30.2020.03.16.10.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 557E01FFAB; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r0mbXI1FyMLDM5RVM9EU8oKyEvhKwmvfb7Yp7qK5ioM=; b=OzCWNNwBak8yE/Fcxhd/ZyQc84pbSqzsgLqCwWEyoTaPSF/6PBsb4TQzTODE9OzSY7 V0suokH+dKOpBm0HqUyCDx2NtxaTub0xdwffooACl44ZRmYiIr5m23/lbER5HBHsA4Lz o9uHtH6Duc/UhaZqYmMO1X2PbaFCVYA8yqMH64eJSS/20b3YrODRLCA8FZU/jHLferkY haFwMBHJnjPbdGpdmrNiJxnyj5S52hm0qgGslBnmtfdxPzYA8HAC1ndvCmI0CuTelxBw hl4A9AByXeOsugr9EPpGsVl0WLujJuiVdLl0b8xrUYx8k71soKPEuTPawsha1xysJYZN O+Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r0mbXI1FyMLDM5RVM9EU8oKyEvhKwmvfb7Yp7qK5ioM=; b=Ohcg4y7K4RHmQtB5n1MEIsYEY1nH3xJwhuQuaoQc2K2T6D6XbUURFBsDsEhfWuuVXY VRv70VIhE8v/4QuFUza3lv4lR2O/vW54xHnfkNedf6Zz6GzYZ57MmrrLzErIickA1/EP fuwDjHfeI+BVLy+RV5u83r4vjk65kljga6uWm2mxkJToVvUlLD1gN8JFzv3y0ZLdbdEZ Vpy9kSI30cjRjOWq0bEx/gLhKW5aYD7bhqIuH0zUe1kO2bGknDoYNPbdnn++xLiefgRp uiWwSspO/cSWx6OSIovLtJtmsQfUW3XHHx63mLFsOpUjFV6hdMn/xoxfIi8DEl3aRT9u 3jAg== X-Gm-Message-State: ANhLgQ2KF8G+vqbBucDxHL5hhBKlrjAg073zYL7ln2obOhd1w9d0SlUY kemDDWtEwQbWqBRI3xwnMYC3Ow== X-Google-Smtp-Source: ADFU+vsedf7pCBxcX3pKcwKlrigpbFkclCGcCE2ZHjXoceF+3e0pByy6V08kj2Aw81yfb4PutD1kfg== X-Received: by 2002:adf:f40f:: with SMTP id g15mr431292wro.213.1584379724372; Mon, 16 Mar 2020 10:28:44 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 21/28] configure: allow user to specify what gdb to use Date: Mon, 16 Mar 2020 17:21:48 +0000 Message-Id: <20200316172155.971-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is useful, especially when testing relatively new gdbstub features that might not be in distro packages yet. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- configure | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure b/configure index eb49bb6680c..6724158fde1 100755 --- a/configure +++ b/configure @@ -303,6 +303,7 @@ libs_qga=3D"" debug_info=3D"yes" stack_protector=3D"" use_containers=3D"yes" +gdb_bin=3D$(command -v "gdb") =20 if test -e "$source_path/.git" then @@ -1588,6 +1589,8 @@ for opt do ;; --disable-fuzzing) fuzzing=3Dno ;; + --with-gdb=3D*) gdb_bin=3D"$optarg" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1773,6 +1776,7 @@ Advanced options (experts only): --enable-plugins enable plugins via shared library loading --disable-containers don't use containers for cross-building + --with-gdb=3DGBB-path gdb to use for gdbstub tests [$gdb_bin] =20 Optional features, enabled with --enable-FEATURE and disabled with --disable-FEATURE, default is enabled if available: @@ -6734,6 +6738,7 @@ echo "libudev $libudev" echo "default devices $default_devices" echo "plugin support $plugins" echo "fuzzing support $fuzzing" +echo "gdb $gdb_bin" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7608,6 +7613,10 @@ if test "$plugins" =3D "yes" ; then fi fi =20 +if test -n "$gdb_bin" ; then + echo "HAVE_GDB_BIN=3D$gdb_bin" >> $config_host_mak +fi + if test "$tcg_interpreter" =3D "yes"; then QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" =3D "sparc64" ; then --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584384247; cv=none; d=zohomail.com; s=zohoarc; b=PALW96AssGGjJ2rW3jmR+CucXvWX3yX5W6ZfCk7DtWyRRYFgHxRrqsl7qJVSbz54IVafhcPj/MO0uYVjwlKEhXQm3IpO1BlWnE30RHqfrKldOYBLEgc6EvNRrg/p+kUx212HQjQYA0dBYSY1625SEQ2uQRvBcD0KRCZOkxuAY+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584384247; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f5dTlYsFtNp/wmtrOeuFSuNIyqa263n2dovazYjJJJU=; b=lpKUZRA5643hn/z+zqKlucluej1G6v0VM86KYjOUeUe6z3mMmXzsVcfn18LJzGmzV45UF3Uuh1U/y/gB9eQhlQbUiAePgz0jr3qGSlDZ6HQEqJtWr/qTo08+kBODaUMeywrD62Zi675GoWkrFVXo/8jO/NM3qAtV8SggoWt9SzU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584384247003802.4959159163186; Mon, 16 Mar 2020 11:44:07 -0700 (PDT) Received: from localhost ([::1]:46408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuib-0003UB-Sy for importer@patchew.org; Mon, 16 Mar 2020 14:44:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52736) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXl-0003fj-0l for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXj-00024K-Kp for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:48 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:45394) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXg-0001yA-6y for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:44 -0400 Received: by mail-wr1-x434.google.com with SMTP id t2so12232285wrx.12 for ; Mon, 16 Mar 2020 10:28:40 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y12sm404883wmi.48.2020.03.16.10.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 692801FFAC; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f5dTlYsFtNp/wmtrOeuFSuNIyqa263n2dovazYjJJJU=; b=Py5JM8aePmg8I++6NhioriUf53N9eGZQXcXpJmnaxSYWoBvzwoQphPMQVJ48kUq3zL h4u9xeJEWRDlnCwGGKWZViQRhiv9QZUoT//2jWO7zI6SxgD2JkgVQ1icT02/HwhBWtZ/ tbTK5lh8ia7NcFwTXj6tgy02Cbu8HG32bsjmiUOuf4B6ePK00KKo2V8WWmp488cBnGuM GPrUeFLLerY1SDE/OMy1KL9ZhrcKwehfp4LHgWyeJMlGzgFaH9/htEFpwItq9lY8GpBV EN7JKkYbXHpIUvZhpJzRO4ekQ54EySvszZm8r2HjloO8dgsIRdk9sglSSaRDz8vP7Hcu UQWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f5dTlYsFtNp/wmtrOeuFSuNIyqa263n2dovazYjJJJU=; b=HFatLPBvKEbYxXT3f1OnvAeWsVzuC7VXyb7ZBYJqu131ZM9EuDEFSZ2WVbXgQKG0KO pBtr6M7wIm0K8uciiLEKc7SNZ5a4XOucvQJVdgV8Ww3fZ7evxawvIs+7kz0fUef7w6yV GVz5h6yLAWOb2l7l5frQ27W5eBADBdSyVYtiJSB9gMBw/426Kzr5Er3nI5uJUfx5WYQK WeCyDN4QvXQ3wZx5Gbr1Go+Mxsu5uP3ZrelWrIZzTrqO+9Fc9Vop6qpaaUKeDe2Gfq4D /cI1NtZbeVOqn7mOIlpGcIO/tOHkjIFT2vLcknmpgxF9SOTrOZNxJu9465tJwStLqEHK sz1g== X-Gm-Message-State: ANhLgQ1anCAGNzrDFmypbJxYWiqUzuuavr43uedrONBZTBoVwQG0lavK tm6cLAcLyNDn8fi2jdWyo4vduw== X-Google-Smtp-Source: ADFU+vs0f131Tm1liahJHdO5Vf0/PT/a2k/tUY43ud9kNiyoL2usKa6JZaR8SGjt4JsCrROKiIAYRg== X-Received: by 2002:a05:6000:41:: with SMTP id k1mr440549wrx.53.1584379719457; Mon, 16 Mar 2020 10:28:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 22/28] tests/guest-debug: add a simple test runner Date: Mon, 16 Mar 2020 17:21:49 +0000 Message-Id: <20200316172155.971-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The test runners job is to start QEMU with guest debug enabled and then spawn a gdb process running a test script that exercises the functionality it wants to test. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/guest-debug/run-test.py | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 tests/guest-debug/run-test.py diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py new file mode 100755 index 00000000000..8c49ee2f225 --- /dev/null +++ b/tests/guest-debug/run-test.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# +# Run a gdbstub test case +# +# Copyright (c) 2019 Linaro +# +# Author: Alex Benn=C3=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import subprocess +import shutil +import shlex + +def get_args(): + parser =3D argparse.ArgumentParser(description=3D"A gdbstub test runne= r") + parser.add_argument("--qemu", help=3D"Qemu binary for test", + required=3DTrue) + parser.add_argument("--qargs", help=3D"Qemu arguments for test") + parser.add_argument("--binary", help=3D"Binary to debug", + required=3DTrue) + parser.add_argument("--test", help=3D"GDB test script", + required=3DTrue) + parser.add_argument("--gdb", help=3D"The gdb binary to use", default= =3DNone) + + return parser.parse_args() + +if __name__ =3D=3D '__main__': + args =3D get_args() + + # Search for a gdb we can use + if not args.gdb: + args.gdb =3D shutil.which("gdb-multiarch") + if not args.gdb: + args.gdb =3D shutil.which("gdb") + if not args.gdb: + print("We need gdb to run the test") + exit(-1) + + # Launch QEMU with binary + if "system" in args.qemu: + cmd =3D "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary) + else: + cmd =3D "%s %s -g 1234 %s" % (args.qemu, args.qargs, args.binary) + + inferior =3D subprocess.Popen(shlex.split(cmd)) + + # Now launch gdb with our test and collect the result + gdb_cmd =3D "%s %s -ex 'target remote localhost:1234' -x %s" % (args.g= db, args.binary, args.test) + + result =3D subprocess.call(gdb_cmd, shell=3DTrue); + + exit(result) --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584384476; cv=none; d=zohomail.com; s=zohoarc; b=WEsQeJMCZmQRuB1p4wJYYEj05C7ZLkqvpGU67mGh5obiq6CLJkOl/jWj/GUAo06aJkXDG5LsvpO8dJcpru2jyipmnfTo3refEc3SF6NyqDjoFhqpNpAiLLp4CUQkzAn2FG3bWjNj0uClQjzo0yrvk/3hkqquCbmCoXT/mZc4Afk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584384476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m8trnK4dsJcOAkqMwuDk8oN/65638+mbTVeX6RjAM68=; b=lGYvh/ARDiWwf6k6LHI/YFi7+9RH0Vz5dJ5NxxVoBU8LFPKG/l1C3Cfp9NSxSu0ql0+nYUsgd/UGx74qOJ8nNsWKrb7CwBZ8UOjOWhdTgka81OhoWhj4oAIBkWU2DdEgGDWJyv1v08DcCXpjK7nxqXUiAuJZtVd94MtbCP1j8NY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158438447647785.74424810654648; Mon, 16 Mar 2020 11:47:56 -0700 (PDT) Received: from localhost ([::1]:46520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDumI-0002EA-EB for importer@patchew.org; Mon, 16 Mar 2020 14:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53013) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXr-0003qg-Cn for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXn-0002Qk-UD for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:42894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXn-0002Ji-HR for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:51 -0400 Received: by mail-wr1-x432.google.com with SMTP id v11so22320923wrm.9 for ; Mon, 16 Mar 2020 10:28:51 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 9sm443006wmx.32.2020.03.16.10.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 815581FFAE; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m8trnK4dsJcOAkqMwuDk8oN/65638+mbTVeX6RjAM68=; b=HBvq+Gr1rLXtJLvRVXx6L79nqcvJ2B+xPBsegPXIx70/Li1laLUTPSzyQ7N1knJBT9 A5hB/O6zxN0U6SAyyL4of8l97vq2fOvasvtL8DId2Q9vwr1TWF0+VnP7oGFNX/h6GPXb K0BIJ6QsrFkChDqvYM2KEnqNVl8LvwWuQsHbfdNaDTqyhSKUvqXwJI1PSTCt6R3x0H+C VfPQ0WYwkE1VkYcmjGF20YNhFKw0K5vMoPlsnCnHKL4F07cU+ytdwdznYHsYtNwcUl+A j3aR7YnTUUSa6MNtR62gvnuBrnQuxIuWp7S9xPx7ErAwbDE2s7dfpS2KosyP4vjntqyd QbDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m8trnK4dsJcOAkqMwuDk8oN/65638+mbTVeX6RjAM68=; b=Y7MkFhfseBzA3eeH8heWVlGH3eSKUlXjpG/XmdzPkV7YN5xz9ETjiZH8v5oqPREwQN yRoJBPiW6rBhEcHuow13WofH9M8LDVpj09rWbi7s09mws/8Ovk55GAFRcg3u+AOYtP5w TguueUXR9Sl81/oGWvQWHcwA8zTibCkORFBjPIQDkSY8G1GcJKtUEXPtHDKGWAyPOUA7 A+yKR8r9YS14bFvK/KWz7ASKy7ENpte7gZr7YiBZjFlOYlVQfrrDwwxpXVUdcKyc3opt ksOSKyRFsVbpiYLpesN57jZSxiAD/k/6ORb5m4iPacDBypP1/oJtAwMYIsTEkOnzTyLz tbbg== X-Gm-Message-State: ANhLgQ3/4MdwefmpYhewBz8vmZL4GJKrk8Q+7XFTsJm6GqMEQ0PsQzYg Pqasp8SqAemJ/XQBT2qq9kopew== X-Google-Smtp-Source: ADFU+vuZHzlkb3X9TGWbTjsEEpevcVTZ7Ke10xn8DgpeFvoA4hK1S37CzkczmHtXeNtOh4BrSUjPQA== X-Received: by 2002:a5d:5342:: with SMTP id t2mr456320wrv.104.1584379730464; Mon, 16 Mar 2020 10:28:50 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 23/28] tests/tcg/aarch64: add a gdbstub testcase for SVE registers Date: Mon, 16 Mar 2020 17:21:50 +0000 Message-Id: <20200316172155.971-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) A very simple test case which sets and reads SVE registers while running a test case. We don't really need to compile a SVE binary for this case but we will later so keep it simple for now. Signed-off-by: Alex Benn=C3=A9e Tested-by: Philippe Mathieu-Daud=C3=A9 --- v5 - properly plumb in - skip if fails to connect --- tests/.gitignore | 1 + tests/tcg/aarch64/Makefile.target | 15 +++++ tests/tcg/aarch64/gdbstub/test-sve.py | 81 +++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/tcg/aarch64/gdbstub/test-sve.py diff --git a/tests/.gitignore b/tests/.gitignore index 7306866f216..d03c037d772 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -10,6 +10,7 @@ qht-bench rcutorture test-* !test-*.c +!test-*.py !docker/test-* test-qapi-commands.[ch] test-qapi-init-commands.[ch] diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index a25afc071cc..b61b53e4dd1 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -46,6 +46,21 @@ ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) # System Registers Tests AARCH64_TESTS +=3D sysregs sysregs: CFLAGS+=3D-march=3Darmv8.1-a+sve + +ifneq ($(HAVE_GDB_BIN),) +GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py + +AARCH64_TESTS +=3D gdbstub-sysregs + +.PHONY: gdbstub-sysregs +run-gdbstub-sysregs: sysregs + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve.py, \ + "basic gdbstub SVE support") +endif + endif =20 TESTS +=3D $(AARCH64_TESTS) diff --git a/tests/tcg/aarch64/gdbstub/test-sve.py b/tests/tcg/aarch64/gdbs= tub/test-sve.py new file mode 100644 index 00000000000..90201d80094 --- /dev/null +++ b/tests/tcg/aarch64/gdbstub/test-sve.py @@ -0,0 +1,81 @@ +from __future__ import print_function +# +# Test the SVE registers are visable and changeable via gdbstub +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +MAGIC =3D 0xDEADBEEF + +failcount =3D 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print ("PASS: %s" % (msg)) + else: + print ("FAIL: %s" % (msg)) + global failcount + failcount +=3D 1 + +def run_test(): + "Run through the tests one by one" + + gdb.execute("info registers") + report(True, "info registers") + + gdb.execute("info registers vector") + report(True, "info registers vector") + + # Now all the zregs + frame =3D gdb.selected_frame() + for i in range(0, 32): + rname =3D "z%d" % (i) + zreg =3D frame.read_register(rname) + report(True, "Reading %s" % rname) + for j in range(0, 4): + cmd =3D "set $%s.q.u[%d] =3D 0x%x" % (rname, j, MAGIC) + gdb.execute(cmd) + report(True, "%s" % cmd) + for j in range(0, 4): + reg =3D "$%s.q.u[%d]" % (rname, j) + v =3D gdb.parse_and_eval(reg) + report(str(v.type) =3D=3D "uint128_t", "size of %s" % (reg)) + for j in range(0, 8): + cmd =3D "set $%s.d.u[%d] =3D 0x%x" % (rname, j, MAGIC) + gdb.execute(cmd) + report(True, "%s" % cmd) + for j in range(0, 8): + reg =3D "$%s.d.u[%d]" % (rname, j) + v =3D gdb.parse_and_eval(reg) + report(str(v.type) =3D=3D "uint64_t", "size of %s" % (reg)) + report(int(v) =3D=3D MAGIC, "%s is 0x%x" % (reg, MAGIC)) + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior =3D gdb.selected_inferior() + arch =3D inferior.architecture() + report(arch.name() =3D=3D "aarch64", "connected to aarch64") +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=3Dsys.stderr) + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except: + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount +=3D 1 + +print("All tests complete: %d failures" % failcount) + +exit(failcount) --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584384345; cv=none; d=zohomail.com; s=zohoarc; b=kmu6fwY0lBGLV+u2WiK2mPBDP6VtMC5ofnj0NzS+C8X3AbDP28kjc4WCGU+3wrT/0QMIQB5sbGPqa3rnEiQ3qNyJNALkh+zW9SAnucccUAsRxk9Yc7I0gOl95UEZ69xrvCH3mdGzhCrHbG/W3ULAoeJiCv7M5clzti6gC9wd/lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584384345; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=06upHfcJvurHEqRqXZxgM7CdWpLdWAWn6DtNQywwJZ8=; b=KeoXeHJUH3prn6kSBtc2NiDH96zQtk9/SQ2YUGmQnPGSXsPOHwIVatWnGOCSWWpnTm/4X9I6s1DHkaksFbNM0PC6lFZv81vQRbMqe8EOGXCUDpTGjt4dapao47pFM3Qb1GhT+mpQIK53jvx/KKSwrO8TOUxMq/Rcj7N9eFDA6nI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584384345935127.11525475165956; Mon, 16 Mar 2020 11:45:45 -0700 (PDT) Received: from localhost ([::1]:46456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDukC-0006Ft-Pu for importer@patchew.org; Mon, 16 Mar 2020 14:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52654) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXg-0003cL-GJ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXd-0001zN-Ju for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:43 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXa-0001vS-AJ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:39 -0400 Received: by mail-wm1-x344.google.com with SMTP id n8so18592653wmc.4 for ; Mon, 16 Mar 2020 10:28:37 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l12sm770079wrt.73.2020.03.16.10.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 978F41FFAF; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=06upHfcJvurHEqRqXZxgM7CdWpLdWAWn6DtNQywwJZ8=; b=rxCt8s5OoOLvHRbo/k7sI7lrYMCY235QQ56t3odLROKNvVD40SD87Iv25oeI0Yvvav yOxQV/hgROD8DxYEOUS3nt0HenrKKQxE2cU0mU0xi4IjyXkQhs9l32Rbcp4sndPdD9az M5+Cq4Nq47g9GL51vJUuJrbz3DLclu9OLysvOYQUm4mD4j/NQ9V+aND5up8OhLrX8grh ia3JKvkeuZzyWdGNiQQs2ZTV2JKe/jvJnVCh7OcgN76gNuiK6lyJp95PSUgKNK2f0YTo CFKOCSOnz+nOfoiG1gqwbp6wYopaa7wwr9MDEVXrfmVKzs0dhcKAr1VZwl5Cs4qYEnsr Tjgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=06upHfcJvurHEqRqXZxgM7CdWpLdWAWn6DtNQywwJZ8=; b=hCXT9Ayvyw/S6KW/ECsEmKUpWgUeLQjoipWBW+T94wj/B5xi0S9nqrazfE+az3TRh1 Vf9EMHLGMQ5ojBogdOMzutg8oJ6dmB+HRH4S2sBN7ymk+DmyYNWVUzgijuCo4IRsqPC2 fNyy8UIIvhUxWSEZeosJAK7DSRJUVrq+kN6fIAOUrGv+0i1OPUhGFMnV9HI2Oe+7kF1t 9KgWvUTz5+Srk0yKz/9t7PWzygybdyD0sb7mFWGE1ZCcn/oNEK5MWpqlGyCFJqJjiWEt HfskwXx6uhH0e0Ozp990tDSg+L2tA8u48VdDc73rid3IuFETtG3UsODua27BtwdGReKO 1KsA== X-Gm-Message-State: ANhLgQ0Iz8s1fcCWPorfjtJEFalCNjPNivhsLnUjNoTQcd8AI6pchUc6 nBpfU5btHHfEn3pGwqj+SkJfvA== X-Google-Smtp-Source: ADFU+vuBA3uteprROJQ5kvIqO2S/z5P3CI22HY9shQgGF7TReHRRy49ZzIPQn2TgzCfnRIBPJ2v7eA== X-Received: by 2002:a05:600c:214f:: with SMTP id v15mr201958wml.110.1584379716962; Mon, 16 Mar 2020 10:28:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 24/28] tests/tcg/aarch64: add SVE iotcl test Date: Mon, 16 Mar 2020 17:21:51 +0000 Message-Id: <20200316172155.971-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is a fairly bare-bones test of setting the various vector sizes for SVE which will only fail if the PR_SVE_SET_VL can't reduce the user-space vector length by powers of 2. However we will also be able to use it in a future test which exercises the GDB stub. Signed-off-by: Alex Benn=C3=A9e Tested-by: Philippe Mathieu-Daud=C3=A9 --- v3 - use index to fill zreg - CROSS_CC_HAS_SVE v5 - merge conflicts v6 - drop id check --- tests/tcg/aarch64/sve-ioctls.c | 70 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 4 ++ 2 files changed, 74 insertions(+) create mode 100644 tests/tcg/aarch64/sve-ioctls.c diff --git a/tests/tcg/aarch64/sve-ioctls.c b/tests/tcg/aarch64/sve-ioctls.c new file mode 100644 index 00000000000..9544dffa0ee --- /dev/null +++ b/tests/tcg/aarch64/sve-ioctls.c @@ -0,0 +1,70 @@ +/* + * SVE ioctls tests + * + * Test the SVE width setting ioctls work and provide a base for + * testing the gdbstub. + * + * Copyright (c) 2019 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_CPUID +#define HWCAP_CPUID (1 << 11) +#endif + +#define SVE_MAX_QUADS (2048 / 128) +#define BYTES_PER_QUAD (128 / 8) + +#define get_cpu_reg(id) ({ \ + unsigned long __val; \ + asm("mrs %0, "#id : "=3Dr" (__val)); \ + __val; \ + }) + +static int do_sve_ioctl_test(void) +{ + int i, res, init_vq; + + res =3D prctl(PR_SVE_GET_VL, 0, 0, 0, 0); + if (res < 0) { + printf("FAILED to PR_SVE_GET_VL (%d)", res); + return -1; + } + init_vq =3D res & PR_SVE_VL_LEN_MASK; + + for (i =3D init_vq; i > 15; i /=3D 2) { + printf("Checking PR_SVE_SET_VL=3D%d\n", i); + res =3D prctl(PR_SVE_SET_VL, i, 0, 0, 0, 0); + if (res < 0) { + printf("FAILED to PR_SVE_SET_VL (%d)", res); + return -1; + } + asm("index z0.b, #0, #1\n" + ".global __sve_ld_done\n" + "__sve_ld_done:\n" + "mov z0.b, #0\n" + : /* no outputs kept */ + : /* no inputs */ + : "memory", "z0"); + } + printf("PASS\n"); + return 0; +} + +int main(int argc, char **argv) +{ + /* we also need to probe for the ioctl support */ + if (getauxval(AT_HWCAP) & HWCAP_SVE) { + return do_sve_ioctl_test(); + } else { + printf("SKIP: no HWCAP_SVE on this system\n"); + return 0; + } +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index b61b53e4dd1..c879932ff6c 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -47,6 +47,10 @@ ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) AARCH64_TESTS +=3D sysregs sysregs: CFLAGS+=3D-march=3Darmv8.1-a+sve =20 +# SVE ioctl test +AARCH64_TESTS +=3D sve-ioctls +sve-ioctls: CFLAGS+=3D-march=3Darmv8.1-a+sve + ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381341; cv=none; d=zohomail.com; s=zohoarc; b=ZODhPPGvZanJicr1ibmk1d3rddI4WANJoUn3TaYk0NT2mGk8bJeJjICYdy0DrmUhEKcXD7ec7JdvYL+yWU4Rz+t/25jyYKSrJXH17ZT2z1I1sjdMgvFTCvbmyxOeLfvi3wMS7QH1vtdOfk792X7VtVYIKIvvrwnLNkHaGOaeDQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b9yQeDMo6CQGzL1Yr1rFXA4YMGbWAVcmyiV4TWBxgDU=; b=KrFkm77h1seKJNSYFITxNqdC4wM6kl0/7koAHytbSDyfUQGBHAC7R/hCHffveXRNVDjjvetEndh3oqJt41jONAUz9PAe9RAG0RXPNY7xByOliLGV8E6ZSk5M0yx4GNgN59Ll9Ims/W6Y3cqmGTD42qPvtFskaNxAz29KhRCJZv0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381341061958.5854210021189; Mon, 16 Mar 2020 10:55:41 -0700 (PDT) Received: from localhost ([::1]:45012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtxk-0002ey-0n for importer@patchew.org; Mon, 16 Mar 2020 13:55:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52819) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXm-0003hw-VN for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXl-0002Ep-AK for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:50 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXk-00023S-OX for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:48 -0400 Received: by mail-wr1-x443.google.com with SMTP id b2so16053339wrj.10 for ; Mon, 16 Mar 2020 10:28:47 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c4sm475531wml.7.2020.03.16.10.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AD1B21FFB1; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b9yQeDMo6CQGzL1Yr1rFXA4YMGbWAVcmyiV4TWBxgDU=; b=UzGVJA38FrgRXPYqRd9qFU5QN+JVNIH4Rk1dz1ECkR5tSFk4F51dtJUpARKHA7oOQB urX8wYBDH2EWqbpJyCs5DlnBivTE/kKxeCZT7pAFWsJttILgMwizSdi5muE2+aoLBUQ1 PyNE7y/Ejz0qoQrWlDcFbr4dIv2s4P5r0NSeOBgTgeuhJDmRY4AXzvGmGawPwr2g9v/j NN4N3yrQLJK8ca1QaXpjuOHf69xgIewllJELxv1lyi9df0XoG8nRHMLkRAVYHWW+f27V K8xKqFSziI/uXZXdBKOhpR11eRmmGd5q2QKEcw+R4lPg5e2s4ZbhteLCcTh9h/gHeJqs rjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b9yQeDMo6CQGzL1Yr1rFXA4YMGbWAVcmyiV4TWBxgDU=; b=m9DIm7WDKVJBjtIDEo7xrPq+zadNAji5mj4/8zE+tV6w0GnXy46JBmkAOKYEaXRQvE 4NvBa8Ay+GBLNVdJSg/MGDkzDQWPiOUQuSlNwqQtWSOfZMDeFtqd5DkEhOa4cs3AaGKw PZEElyR1lqz8F4lc8ou18/6x2JuF/sQcAyDTqi8TtO0kmFiVbwrj+rSMYgUh2Yxj8ij6 SuowbpAY+DBn4BX2ietR8RFFkM3PpwvqNFkdZ6WwPRZ7jgRINZk0QU9cL+2GV3WLg+Ae BrDRelqRIsMe6nz5IQlS1913QxsnpKrZqggrAXCs4DyQudkq5V4Q0IWahbZ2AG+gIqKq +DKw== X-Gm-Message-State: ANhLgQ1Noj4AdKx/Pz0qhGBQcMhU5MLPNQWtUSsiY77Q94H1r8k8PIUY R/oYXhA/R8FDha4QVN5+7hZoHg== X-Google-Smtp-Source: ADFU+vvAsvbtGMl640m8WOF53HNVI2Bai+tIuV6IVMRsQdmswlyMNZ6bq9Qh9ETC1C4LwlSIuXe0lA== X-Received: by 2002:a5d:4a10:: with SMTP id m16mr370895wrq.333.1584379726370; Mon, 16 Mar 2020 10:28:46 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 25/28] tests/tcg/aarch64: add test-sve-ioctl guest-debug test Date: Mon, 16 Mar 2020 17:21:52 +0000 Message-Id: <20200316172155.971-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This test exercises the gdbstub while runing the sve-iotcl test. I haven't plubmed it into make system as we need a way of verifying if gdb has the right support for SVE. Signed-off-by: Alex Benn=C3=A9e --- v4 - interrogate ZCR_EL1 directly as no longer have vg v5 - plumb in - skip if fails to connect v6 - fix for vg v7 - change to vg size, also better trap failure in zreg access --- tests/tcg/aarch64/Makefile.target | 11 ++- tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 82 +++++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/aarch64/gdbstub/test-sve-ioctl.py diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index c879932ff6c..d99b2a9eced 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -54,15 +54,22 @@ sve-ioctls: CFLAGS+=3D-march=3Darmv8.1-a+sve ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 -AARCH64_TESTS +=3D gdbstub-sysregs +AARCH64_TESTS +=3D gdbstub-sysregs gdbstub-sve-ioctls =20 -.PHONY: gdbstub-sysregs +.PHONY: gdbstub-sysregs gdbstub-sve-ioctls run-gdbstub-sysregs: sysregs $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(HAVE_GDB_BIN) \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve.py, \ "basic gdbstub SVE support") + +run-gdbstub-sve-ioctls: sve-ioctls + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve-ioctl.py, \ + "basic gdbstub SVE ZLEN support") endif =20 endif diff --git a/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py b/tests/tcg/aarch6= 4/gdbstub/test-sve-ioctl.py new file mode 100644 index 00000000000..5824abe09ac --- /dev/null +++ b/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py @@ -0,0 +1,82 @@ +from __future__ import print_function +# +# Test the SVE ZReg reports the right amount of data. It uses the +# sve-ioctl test and examines the register data each time the +# __sve_ld_done breakpoint is hit. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +initial_vlen =3D 0 +failcount =3D 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print ("PASS: %s" % (msg)) + else: + print ("FAIL: %s" % (msg)) + global failcount + failcount +=3D 1 + +class TestBreakpoint(gdb.Breakpoint): + def __init__(self, sym_name=3D"__sve_ld_done"): + super(TestBreakpoint, self).__init__(sym_name) + # self.sym, ok =3D gdb.lookup_symbol(sym_name) + + def stop(self): + val_i =3D gdb.parse_and_eval('i') + global initial_vlen + try: + for i in range(0, int(val_i)): + val_z =3D gdb.parse_and_eval("$z0.b.u[%d]" % i) + report(int(val_z) =3D=3D i, "z0.b.u[%d] =3D=3D %d" % (i, i= )) + for i in range(i + 1, initial_vlen): + val_z =3D gdb.parse_and_eval("$z0.b.u[%d]" % i) + report(int(val_z) =3D=3D 0, "z0.b.u[%d] =3D=3D 0" % (i)) + except gdb.error: + report(False, "checking zregs (out of range)") + + +def run_test(): + "Run through the tests one by one" + + print ("Setup breakpoint") + bp =3D TestBreakpoint() + + global initial_vlen + vg =3D gdb.parse_and_eval("$vg") + initial_vlen =3D int(vg) * 8 + + gdb.execute("c") + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior =3D gdb.selected_inferior() + arch =3D inferior.architecture() + report(arch.name() =3D=3D "aarch64", "connected to aarch64") +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=3Dsys.stderr) + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except: + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount +=3D 1 + import code + code.InteractiveConsole(locals=3Dglobals()).interact() + raise + +print("All tests complete: %d failures" % failcount) +exit(failcount) --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383438; cv=none; d=zohomail.com; s=zohoarc; b=AjISiB/7nUXdzbGLuU2Z7A1CmFLaaLJhty/YAuuB1hW8ZAkzf77E3ygtC5E4oSqRyby5RAaewr99zW0aRl9BiwBWdrAaQ0WXPHAqi4bE1SRVZYQUB3TKxAC3sgWgswxrgiVuKbZNwPVf67cCJ2z6ZIKcT/MByj8gKkq142zOW+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383438; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SgHi9WXNUZHnLRBdy+Pgdln+YAHhnpTOiH4IIfKf4LU=; b=QZ1mnK0myzbLa4GybRI/0unGUVhqh+bwL05WXPQyWgS0J4oG0xZNUn1VH8wls8p6Rbpze7TfglmEpJ18HeLZp84ynbjjNcnEfHskXeFM0NrhYZ3MSP8FHX8Lbr4CHe0vMMlRh9xzDtH3SNDPi8ucq++Ymk71xPYIAROxuHDKH1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383438523592.9096938204575; Mon, 16 Mar 2020 11:30:38 -0700 (PDT) Received: from localhost ([::1]:45884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDuVZ-0004yU-9x for importer@patchew.org; Mon, 16 Mar 2020 14:30:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52969) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtXq-0003oh-JG for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtXn-0002L4-4A for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:54 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:33395) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtXm-0002F1-PH for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:28:50 -0400 Received: by mail-wr1-x443.google.com with SMTP id a25so22300652wrd.0 for ; Mon, 16 Mar 2020 10:28:50 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x16sm830249wrg.44.2020.03.16.10.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:28:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C289E1FFB3; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SgHi9WXNUZHnLRBdy+Pgdln+YAHhnpTOiH4IIfKf4LU=; b=eXNwtFkfRK1OE5wL3+rkMk3r7YTcZSQ25+S57cODagsMvJgbUjwABlplfOoZb2n60P gYM2UBQiJINb+Jbn4hqqjNjgEZwNh+FGahMs5JCW230DTlRBPRRBP+sigVCZ2JV4Y0r0 XAJMFXBE0nI0vpCSNPs5xptZGBcwIqRAV992kW4ZFXt6hZH+tMDwU88rylOY7pNmPM/c btcrzlP3JrS1HpMEuQUutcIKX6hDhw1sAfLVWDSy7d6MICRDJJlm8Gv6mE0vLpIlSEkb ssox60Ym9g0ip63IOvNa/gWqMxXxBg0oWdmZTyh1EPl13LmSFKunCJ7sFmEtVEr7JmYf IPyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SgHi9WXNUZHnLRBdy+Pgdln+YAHhnpTOiH4IIfKf4LU=; b=NK4qqr1Vp/8Wa2fNWBeNsm0fIsriQzL1TH2Mb6IKLcxFrw/rxbVlH56xSEEzhuZdrG NJFekI0MqQAezl+Y8qauTiBeAZRzQzB55dXgizJWbYoQt+IRTTPbkRsK0L+QL8S4Uf7R nTrrmx1UkMzsZDLfqpHpnUfilyLe2+IZA/7AB4TnbVRMnigRy7eiQWYVRvq1tTu8Wc1O UAYQcB8qAdod0X+P/2001zb2EUFrTyL2n/Kz9ZP72UuRJfvq7Zz3GfZzNN9bnX9XGdLv RHop23PJQjnv1JvdzH2Tj024NDm5gIK8x8699yiV8g3xbPiHqodicBhQFzuiRjnyuoP9 Ki0A== X-Gm-Message-State: ANhLgQ0RkJdI3WG6WiCQHxd7br17mqejYS8NV50J68I1IHTPsM7AhKeK fAlhWZml4ovSwY5X8bImj7+FBA== X-Google-Smtp-Source: ADFU+vs4ikaRMeN/D02OpBRLv1FcC9APqiASJrZVD8Wtx15ry/VdjBstKW98JXyvazLBgjiAfwqk4g== X-Received: by 2002:adf:f652:: with SMTP id x18mr386201wrp.299.1584379729112; Mon, 16 Mar 2020 10:28:49 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 26/28] gdbstub: change GDBState.last_packet to GByteArray Date: Mon, 16 Mar 2020 17:21:53 +0000 Message-Id: <20200316172155.971-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Damien Hedde Remove the packet size upper limit by using a GByteArray instead of a statically allocated array for last_packet. Thus we can now send big packets. Also remove the last_packet_len field and use last_packet->len instead. Signed-off-by: Damien Hedde Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191211160514.58373-2-damien.hedde@greensocs.com> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- gdbstub.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 0bcfc47a7c5..a60ef5125eb 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -351,8 +351,7 @@ typedef struct GDBState { int line_buf_index; int line_sum; /* running checksum */ int line_csum; /* checksum at the end of the packet */ - uint8_t last_packet[MAX_PACKET_LENGTH + 4]; - int last_packet_len; + GByteArray *last_packet; int signal; #ifdef CONFIG_USER_ONLY int fd; @@ -384,6 +383,7 @@ static void init_gdbserver_state(void) gdbserver_state.init =3D true; gdbserver_state.str_buf =3D g_string_new(NULL); gdbserver_state.mem_buf =3D g_byte_array_sized_new(MAX_PACKET_LENGTH); + gdbserver_state.last_packet =3D g_byte_array_sized_new(MAX_PACKET_LENG= TH + 4); } =20 #ifndef CONFIG_USER_ONLY @@ -626,28 +626,29 @@ static void hexdump(const char *buf, int len, static int put_packet_binary(const char *buf, int len, bool dump) { int csum, i; - uint8_t *p; - uint8_t *ps =3D &gdbserver_state.last_packet[0]; + uint8_t footer[3]; =20 if (dump && trace_event_get_state_backends(TRACE_GDBSTUB_IO_BINARYREPL= Y)) { hexdump(buf, len, trace_gdbstub_io_binaryreply); } =20 for(;;) { - p =3D ps; - *(p++) =3D '$'; - memcpy(p, buf, len); - p +=3D len; + g_byte_array_set_size(gdbserver_state.last_packet, 0); + g_byte_array_append(gdbserver_state.last_packet, + (const uint8_t *) "$", 1); + g_byte_array_append(gdbserver_state.last_packet, + (const uint8_t *) buf, len); csum =3D 0; for(i =3D 0; i < len; i++) { csum +=3D buf[i]; } - *(p++) =3D '#'; - *(p++) =3D tohex((csum >> 4) & 0xf); - *(p++) =3D tohex((csum) & 0xf); + footer[0] =3D '#'; + footer[1] =3D tohex((csum >> 4) & 0xf); + footer[2] =3D tohex((csum) & 0xf); + g_byte_array_append(gdbserver_state.last_packet, footer, 3); =20 - gdbserver_state.last_packet_len =3D p - ps; - put_buffer(ps, gdbserver_state.last_packet_len); + put_buffer(gdbserver_state.last_packet->data, + gdbserver_state.last_packet->len); =20 #ifdef CONFIG_USER_ONLY i =3D get_char(); @@ -2812,20 +2813,22 @@ static void gdb_read_byte(uint8_t ch) uint8_t reply; =20 #ifndef CONFIG_USER_ONLY - if (gdbserver_state.last_packet_len) { + if (gdbserver_state.last_packet->len) { /* Waiting for a response to the last packet. If we see the start of a new command then abandon the previous response. */ if (ch =3D=3D '-') { trace_gdbstub_err_got_nack(); - put_buffer((uint8_t *)gdbserver_state.last_packet, gdbserver_s= tate.last_packet_len); + put_buffer(gdbserver_state.last_packet->data, + gdbserver_state.last_packet->len); } else if (ch =3D=3D '+') { trace_gdbstub_io_got_ack(); } else { trace_gdbstub_io_got_unexpected(ch); } =20 - if (ch =3D=3D '+' || ch =3D=3D '$') - gdbserver_state.last_packet_len =3D 0; + if (ch =3D=3D '+' || ch =3D=3D '$') { + g_byte_array_set_size(gdbserver_state.last_packet, 0); + } if (ch !=3D '$') return; } @@ -3209,7 +3212,7 @@ static int gdb_monitor_write(Chardev *chr, const uint= 8_t *buf, int len) const char *p =3D (const char *)buf; int max_sz; =20 - max_sz =3D (sizeof(gdbserver_state.last_packet) - 2) / 2; + max_sz =3D (MAX_PACKET_LENGTH / 2) + 1; for (;;) { if (len <=3D max_sz) { gdb_monitor_output(p, len); --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584383812; cv=none; d=zohomail.com; s=zohoarc; b=UL/1EYdIsyykJI+W1UPT1+tEuG0SvNR9QxqCYjRnJe5Az6cO3XAZ3yp+X64yOLcRIdUxVDl++eJvX+CaC/KUfvFa287tV8LUc/4uS3muIFjPe8Nhq56ujzl80zf8S+OD6vhpFBKGKxwtP50sx4F/gEE8xUUSDU+iYBI9pRYU5QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584383812; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S3cTxjypFmfXtVw2dMUn9D7l9wF5YaNxrf+weztp0sk=; b=IzagIMrDg1/C9IYZHHviSBPMowYuHUnHswJ8NnE6Bk9+e71xy8OXhthfmFeZa6ORVpaLRGe4RZAzHV+TSvsslEA9o/P5upGm+qiwM4IIUbW9ij2b5SzKyjj+P0OZW4ECyf9pO5ybSQPYLnbfiEzgm/8p2Y6tWs8jZWMalQtdl/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584383812855761.6011744723048; Mon, 16 Mar 2020 11:36:52 -0700 (PDT) Received: from localhost ([::1]:46146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDubb-0006hl-Qm for importer@patchew.org; Mon, 16 Mar 2020 14:36:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45350) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRX-0000uF-Bu for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRV-00011G-VQ for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:23 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRV-0000v9-Gt for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:21 -0400 Received: by mail-wr1-x442.google.com with SMTP id y2so6782930wrn.11 for ; Mon, 16 Mar 2020 10:22:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p10sm782836wrx.81.2020.03.16.10.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D78331FFB4; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S3cTxjypFmfXtVw2dMUn9D7l9wF5YaNxrf+weztp0sk=; b=Hgw6+ti92jYqYDNj/zW6KJUIBUAHwBPyqvaKpNo2UlET7sTMfqtLW2/Dmcn9z37RAJ NSNnhw6XJfYOt8fStg3SjzO+rHN9RN6tTdtIHCcXA09z8CyDm9dro6dPoUr/fh33ROsZ jBhTpnF3KcOjnBjFsWy8gOGBtmMMQYl2BCOsDHyWMSrZwfz1bQ5rYcze8ajs215PvFk9 OJMrnirbERecQw2y4VINeZsE3i/A7Qd1j+3QvN4zQvUKVbzOmTQLumtns+j55Nd2PQQW tZRVpAnsoOKZd22IKL3l9pw+TEs1z7F6IqbURq/TH9Sbdyxj212Wfr7URYVt23nMv4em ziGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3cTxjypFmfXtVw2dMUn9D7l9wF5YaNxrf+weztp0sk=; b=T46YP/Zebl75YOVB1q5nUWWAcRBZ7Xs/VLp/B3+FefQZ0T0mDsvm8+yUwchFZI5Amn jUCKrkxsvzLZrOnEvKWP2RtsEyM2z2YLv2fH7LDOd1W6jATB5HNVndIJMbmvRTGVw0EO tgu0EqP8d4la+FIDCMUuHAU3SINFP1EeGSO/oBCrtyZkAGhqQeOtc+LNgnwYlnCDezXE DNn1cop49aBlZGrg9f5PjUJ3i1imgnth8u4J7m6B2EFP85fQ8VvIGvy3y3o0Fn4upIUi VNMIjZMhXAFVAqGAsYmiC/CoONiwa4cR/Qqc8Yvw9dJtM1ucOP1UEcIeXXh+cwNEzCYK k9fg== X-Gm-Message-State: ANhLgQ0HIL2voXX7C4naZqemeEf+yJ2OvfHm69yL9cYjQ3XfRC+08PQJ 9uGfWG1VisVvaCNsXkStI9gInw== X-Google-Smtp-Source: ADFU+vu5PXXwCYpp9+vjXDpB+n4QRutI3kkzx27vdMnnwR18hV50lsOEWmSVVU0x40kvWoNOObVfwQ== X-Received: by 2002:adf:ab1d:: with SMTP id q29mr356744wrc.233.1584379338851; Mon, 16 Mar 2020 10:22:18 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 27/28] gdbstub: do not split gdb_monitor_write payload Date: Mon, 16 Mar 2020 17:21:54 +0000 Message-Id: <20200316172155.971-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Damien Hedde Since we can now send packets of arbitrary length: simplify gdb_monitor_write() and send the whole payload in one packet. Suggested-by: Luc Michel Signed-off-by: Damien Hedde Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20191211160514.58373-3-damien.hedde@greensocs.com> --- gdbstub.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a60ef5125eb..9ae148cd1ff 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3200,28 +3200,11 @@ static void gdb_chr_event(void *opaque, QEMUChrEven= t event) } } =20 -static void gdb_monitor_output(const char *msg, int len) -{ - g_autoptr(GString) buf =3D g_string_new("O"); - memtohex(buf, (uint8_t *)msg, len); - put_packet(buf->str); -} - static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) { - const char *p =3D (const char *)buf; - int max_sz; - - max_sz =3D (MAX_PACKET_LENGTH / 2) + 1; - for (;;) { - if (len <=3D max_sz) { - gdb_monitor_output(p, len); - break; - } - gdb_monitor_output(p, max_sz); - p +=3D max_sz; - len -=3D max_sz; - } + g_autoptr(GString) hex_buf =3D g_string_new("O"); + memtohex(hex_buf, buf, len); + put_packet(hex_buf->str); return len; } =20 --=20 2.20.1 From nobody Fri May 3 03:35:30 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584381145; cv=none; d=zohomail.com; s=zohoarc; b=EhLKN+VuZi/HP/eFnxDN8mdB0shOxRTMp6EC2Cn8ZDPhCqaqVXP7t0Sep3kow5RiipraON8MmfW9jup97jboDZxTMdm9GKQgqHEvivQRv0BDvXkfYL3NZs50t517MFJJn405C+jWQz8HlszFYJvRd9TrDy4oC/wz8byCht6Wry8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584381145; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7aNXZAoL0fEr8CHp9NIvYI/wCGleSQwEmfp3SuRJ1II=; b=mbXpCouImw5hwUJ78u9JQwuqEytUA4udgeD7EhLWhoxtGxwAV8Nj99V+MgmWEdV2FO9iVzsLhALWkvzmZuVBjoxhId3Q15jNq5Lon6rPjVewFpO/3iwGNauNkEElcscMRIRQ38+0jgeILlsf0E320OwpdyqiM33MZ5Rk8JZgdQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584381145962587.0544518096895; Mon, 16 Mar 2020 10:52:25 -0700 (PDT) Received: from localhost ([::1]:44908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtua-0005YU-SQ for importer@patchew.org; Mon, 16 Mar 2020 13:52:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45711) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDtRj-0001Io-AO for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDtRf-00024w-4p for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:35 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:33096) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDtRe-0001uD-Q7 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 13:22:30 -0400 Received: by mail-wm1-x343.google.com with SMTP id r7so13797952wmg.0 for ; Mon, 16 Mar 2020 10:22:30 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s22sm414601wmc.16.2020.03.16.10.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 10:22:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EC0801FFB5; Mon, 16 Mar 2020 17:21:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7aNXZAoL0fEr8CHp9NIvYI/wCGleSQwEmfp3SuRJ1II=; b=GZ3O3rJrzhGNg0CM8AEaKyrEvYVxBCL51fXVE/7hRqQr1tt/5Ncc6kWQAFdf+m8Glw tQYL6Kf42n+Za4+rA7MrmCCWJMYriBqjUX58jEr1jL/ZVnTvONbtZpqJWtCvm+eb7H86 7f1FJxZhmaVNqES1vYNeuAgKhQYZF68R5Lfz6VHlc9zGY/74c/ZqFD/bfs+cWtJgZGA1 YixPbCgtH/iY6scDl3mmK9qOUBKzQdil9xGrHtOISIWRdlXzsFgryw1ZDRgh06Vg3Oo0 BxAytqJ3hN6tX8z20HhII2qudjjpkRYSThlWqB2eLVMMUOuH08Vas1H2NuzAFDx3H/AD Wv/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7aNXZAoL0fEr8CHp9NIvYI/wCGleSQwEmfp3SuRJ1II=; b=RJlM6zjBiPDUEg7yXpVf26GNQxBd55ZmfFxDRx34vei7ckTmWH9MK7KQolwQr62L+u hefGi+kS/OI0pSCVOPtfdEg2uhqAQAdcAwUSl/uQ75hoWNRJ+gZrSO0pjj285+4xwORO AOVtduLhJehRnxeHPmXbSDAO9ZaCbl8vt1O78Unqzl9f6v3Jqc5ld/roUxJwnzpFH01G iangcy0E0ATezzdCTYvCDpDOH0WYwoxAnPiCY+DR+5/W0bqRI3UOF7h3Vw16jbVC5n2x CiTM6qCnzyhGXtt0XiwKYfO55UC1EuE9d7m2Xm9q4ViGAYro0O+PtcHInzm9bBcYMoVj mDEg== X-Gm-Message-State: ANhLgQ2eeSW1e3kRjM9UVvCId+7KDsq6DxTqqohXp3ktBCXPbk91RXx1 /omkoMMyNguvsTGermHcZVoHNA== X-Google-Smtp-Source: ADFU+vsdrorSCRHex1nb95ebvHsRyd/B8fRk97wi5pQPeCfiK2sgXn0zQeixDGN9JIeVdgNC9ekPEg== X-Received: by 2002:a1c:6605:: with SMTP id a5mr194207wmc.32.1584379348650; Mon, 16 Mar 2020 10:22:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 28/28] gdbstub: Fix single-step issue by confirming 'vContSupported+' feature to gdb Date: Mon, 16 Mar 2020 17:21:55 +0000 Message-Id: <20200316172155.971-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316172155.971-1-alex.bennee@linaro.org> References: <20200316172155.971-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel , Changbin Du Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Changbin Du Recently when debugging an arm32 system on qemu, I found sometimes the single-step command (stepi) is not working. This can be reproduced by below steps: 1) start qemu-system-arm -s -S .. and wait for gdb connection. 2) start gdb and connect to qemu. In my case, gdb gets a wrong value (0x60) for PC, which is an another bug. 3) After connected, type 'stepi' and expect it will stop at next ins. But, it has never stopped. This because: 1) We doesn't report =E2=80=98vContSupported=E2=80=99 feature to gdb expli= citly and gdb think we do not support it. In this case, gdb use a software breakpoint to emulate single-step. 2) Since gdb gets a wrong initial value of PC, then gdb inserts a breakpoint to wrong place (PC+4). Not only for the arm target, Philippe has also encountered this on MIPS. Probably gdb has different assumption for different architectures. Since we do support =E2=80=98vContSupported=E2=80=99 query command, so let'= s tell gdb that we support it. Before this change, gdb send below 'Z0' packet to implement single-step: gdb_handle_packet: Z0,4,4 After this change, gdb send "vCont;s.." which is expected: gdb_handle_packet: vCont? put_packet: vCont;c;C;s;S gdb_handle_packet: vCont;s:p1.1;c:p1.-1 Signed-off-by: Changbin Du Tested-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200221002559.6768-1-changbin.du@gmail.com> [AJB: fix for static gdbstub] Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Luc Michel --- gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index 9ae148cd1ff..013fb1ac0f1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2130,7 +2130,7 @@ static void handle_query_supported(GdbCmdContext *gdb= _ctx, void *user_ctx) gdbserver_state.multiprocess =3D true; } =20 - g_string_append(gdbserver_state.str_buf, ";multiprocess+"); + g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiproces= s+"); put_strbuf(); } =20 --=20 2.20.1