From nobody Sat Nov 23 23:45:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1728858010; cv=none; d=zohomail.com; s=zohoarc; b=jmTKnxqpd1a6vb2/mWGTcGwX0rEtd/uQq+nouvKeERJG7Y1czPUsR3UdOZ21iZHrrGxufWhO0outUn77JLfwI2A0i9Bq8wkPs+SMqzb3TDPFVQ8ZtjFvqnl7KOBjnC2cyHtqSgXMaTjDJ9mtSkDlKS3ViYGjUG3nBF8BTfXrTOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728858010; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t8ym6NLxoNvu+SOj1YsRaeOvfI7iJrafTEN4muCnoIE=; b=DGhf3NLYFTlSVM60y026xnTUh9EOBtNo9Y2wQoC5RgLGImTv795fi3cd395bkbGTijbeNv8reGTnN7fQ36eCsH+jU+s3wFDAepNqGHVMM2EpNFV/lhszX1FQrfqBQPKb/3Rz3fsh4DbMmTRCIF78WmkfPTX8lADi/6HRIjmNrU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728858010943737.3149312385467; Sun, 13 Oct 2024 15:20:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t06pR-00077k-2N; Sun, 13 Oct 2024 18:12:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t06pQ-00077J-75 for qemu-devel@nongnu.org; Sun, 13 Oct 2024 18:12:44 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t06pO-0000tt-CK for qemu-devel@nongnu.org; Sun, 13 Oct 2024 18:12:43 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2e2a999b287so2850979a91.0 for ; Sun, 13 Oct 2024 15:12:42 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2d5df1eebsm7271958a91.17.2024.10.13.15.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 15:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728857561; x=1729462361; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t8ym6NLxoNvu+SOj1YsRaeOvfI7iJrafTEN4muCnoIE=; b=PqXzSt9nkLrEQLmFXdYaeSzAtNrSSJ9aM3c5+Ohl8HPp2NH/HPuI8xQuiKe6urdXr3 Y/859erIANdDpfnjIoD6pUf4VeuTNPYW5PSGoSViQqws/qNCYvBvef/4FD/6JmJbe8Mq HQa2++Y5ZxamOP5OZ/v8il+EU16xgZB1F9JYhA9jfUGhlYT+rPgyjXvDcxJA+tx5sa5D MPN4kGM6OePuxcQ6xmL2nCFaS/Tee+S6q1qlkpoWRlSQQ7fI+gF6BPLNNGDLFFsec75R J+kA9WaaB+kUxxlkncUeVSN1H7+9+fBcSemw/Vhx3RNpNGVShuLUvUN72yANFWIRBr2q ILRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728857561; x=1729462361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t8ym6NLxoNvu+SOj1YsRaeOvfI7iJrafTEN4muCnoIE=; b=JvP4+SiZI8eb71x82ddPeLzlK6glFbxa5z74ZJWBwo7Cr2wYglcy7+18YKjA16Vugr xsdXPjdih+gEDjEZ/JaDzz4g8ZEsgoz/XBCCizCkgNBZYBD8KSPmIfCnTzObX1V+PoFv hZQItCqecjiXBs1iprMQPXNxNb7cHi/v4pzBeyrdH0H+gcnH+UqX/Jz7goe/VIihlX7e 0UcBVMYcBWnFQs8FNKWSxxCXeQW7SKiMi/pCriiPeuxVVzbAsBH7toiutf4MOf2gt5T0 Bmd9YcCfTJybbeymySGDV48ARZ/cBWxFFdWl0cj9nGpPYzYahzpqafxLrFx4D4xfu6G1 2MTw== X-Gm-Message-State: AOJu0YxqWMLs1oJgnDfqvudmQqTSahPvQWrOqIWtuBTMdU9N+vQ423nA xRIxCukaEtMsCTpOFCeL/z0wLW9n4kSzlISZXJeJ7z8l4BWPwiJZmsjtOBjnia58BVREdEGgqnV 9 X-Google-Smtp-Source: AGHT+IHWnNiIXpnTD8cm8+35JeXmrYMBP90R1Lxi3XKuJdKRPVisipex8kl+OarBqksPeznQczuUnA== X-Received: by 2002:a17:90b:d97:b0:2e2:ebbb:7619 with SMTP id 98e67ed59e1d1-2e2f0ab98cfmr11287608a91.9.1728857561006; Sun, 13 Oct 2024 15:12:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 05/27] target/i386/gdbstub: Expose orig_ax Date: Sun, 13 Oct 2024 15:12:13 -0700 Message-ID: <20241013221235.1585193-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241013221235.1585193-1-richard.henderson@linaro.org> References: <20241013221235.1585193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1728858013160116600 Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich Copy XML files describing orig_ax from GDB and glue them with CPUX86State.orig_ax. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-ID: <20240912093012.402366-5-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- target/i386/cpu.h | 1 + target/i386/cpu.c | 1 + target/i386/gdbstub.c | 51 +++++++++++++++++++++++++++ configs/targets/i386-linux-user.mak | 2 +- configs/targets/x86_64-linux-user.mak | 2 +- gdb-xml/i386-32bit-linux.xml | 11 ++++++ gdb-xml/i386-64bit-linux.xml | 11 ++++++ 7 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 gdb-xml/i386-32bit-linux.xml create mode 100644 gdb-xml/i386-64bit-linux.xml diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 9c39384ac0..4c63e7b045 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2226,6 +2226,7 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags); =20 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); +void x86_cpu_gdb_init(CPUState *cs); =20 void x86_cpu_list(void); int cpu_x86_support_mca_broadcast(CPUX86State *env); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ff227a8c5c..0d30191482 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7831,6 +7831,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) =20 mce_init(cpu); =20 + x86_cpu_gdb_init(cs); qemu_init_vcpu(cs); =20 /* diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index cc5eceeb7e..04c49e802d 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -18,8 +18,13 @@ * License along with this library; if not, see . */ #include "qemu/osdep.h" +#include "accel/tcg/vcpu-state.h" #include "cpu.h" +#include "exec/gdbstub.h" #include "gdbstub/helpers.h" +#ifdef CONFIG_LINUX_USER +#include "linux-user/qemu.h" +#endif =20 #ifdef TARGET_X86_64 static const int gpr_map[16] =3D { @@ -406,3 +411,49 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *= mem_buf, int n) /* Unrecognised register. */ return 0; } + +#ifdef CONFIG_LINUX_USER + +#define IDX_ORIG_AX 0 + +static int x86_cpu_gdb_read_linux_register(CPUState *cs, GByteArray *mem_b= uf, + int n) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + switch (n) { + case IDX_ORIG_AX: + return gdb_get_reg(env, mem_buf, get_task_state(cs)->orig_ax); + } + return 0; +} + +static int x86_cpu_gdb_write_linux_register(CPUState *cs, uint8_t *mem_buf, + int n) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + switch (n) { + case IDX_ORIG_AX: + return gdb_write_reg(env, mem_buf, &get_task_state(cs)->orig_ax); + } + return 0; +} + +#endif + +void x86_cpu_gdb_init(CPUState *cs) +{ +#ifdef CONFIG_LINUX_USER + gdb_register_coprocessor(cs, x86_cpu_gdb_read_linux_register, + x86_cpu_gdb_write_linux_register, +#ifdef TARGET_X86_64 + gdb_find_static_feature("i386-64bit-linux.xml= "), +#else + gdb_find_static_feature("i386-32bit-linux.xml= "), +#endif + 0); +#endif +} diff --git a/configs/targets/i386-linux-user.mak b/configs/targets/i386-lin= ux-user.mak index 5b2546a430..b72a156473 100644 --- a/configs/targets/i386-linux-user.mak +++ b/configs/targets/i386-linux-user.mak @@ -1,4 +1,4 @@ TARGET_ARCH=3Di386 TARGET_SYSTBL_ABI=3Di386 TARGET_SYSTBL=3Dsyscall_32.tbl -TARGET_XML_FILES=3D gdb-xml/i386-32bit.xml +TARGET_XML_FILES=3D gdb-xml/i386-32bit.xml gdb-xml/i386-32bit-linux.xml diff --git a/configs/targets/x86_64-linux-user.mak b/configs/targets/x86_64= -linux-user.mak index 9ceefbb615..86042814d3 100644 --- a/configs/targets/x86_64-linux-user.mak +++ b/configs/targets/x86_64-linux-user.mak @@ -2,4 +2,4 @@ TARGET_ARCH=3Dx86_64 TARGET_BASE_ARCH=3Di386 TARGET_SYSTBL_ABI=3Dcommon,64 TARGET_SYSTBL=3Dsyscall_64.tbl -TARGET_XML_FILES=3D gdb-xml/i386-64bit.xml +TARGET_XML_FILES=3D gdb-xml/i386-64bit.xml gdb-xml/i386-64bit-linux.xml diff --git a/gdb-xml/i386-32bit-linux.xml b/gdb-xml/i386-32bit-linux.xml new file mode 100644 index 0000000000..5ffe5616e6 --- /dev/null +++ b/gdb-xml/i386-32bit-linux.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/gdb-xml/i386-64bit-linux.xml b/gdb-xml/i386-64bit-linux.xml new file mode 100644 index 0000000000..0f26990d2f --- /dev/null +++ b/gdb-xml/i386-64bit-linux.xml @@ -0,0 +1,11 @@ + + + + + + + --=20 2.43.0