From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DDADD6EBF1 for ; Fri, 29 Nov 2024 09:59:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGxmH-0004pO-RL; Fri, 29 Nov 2024 04:59:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGxmF-0004p3-9e for qemu-riscv@nongnu.org; Fri, 29 Nov 2024 04:59:07 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGxmB-0003xP-IE for qemu-riscv@nongnu.org; Fri, 29 Nov 2024 04:59:06 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-434a2033562so15276455e9.1 for ; Fri, 29 Nov 2024 01:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732874342; x=1733479142; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0hI/xxTgjum7R5i6Ad97JEX8w3FQEhDpVP9eXMuQUKU=; b=hPDbYVFW0Xl8/xs0riBGXdG47pLzdyX68CHMcrM7KCI7g29xyjjBuLzEHAVYBPyK+a lGOual2xyCmjzlHFCxgustu+WwsWjjp9EDPu88RN5ad8GrixvXHYFL4fsUQjj1s74PuO Zwn/1zyD5pQF9E/QFFogEuad/ml5Daez3SDyJ6Qz0seQuzQVMvoi/aQ9F6rNXBqJ/oM+ 0Zmt/z1v9N+Vg1/OmYKlbDtMl2opwUUsa+b9EGmNRar+OH56FhuDYsdNV1Pe5bUHcZuu U0EwQGUYAWur2XlE5EQET5r/6E+k/RrIYgyfaB1E6NZkMKcjyZu5xSZPYX+F8kx9DLTZ LJug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732874342; x=1733479142; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0hI/xxTgjum7R5i6Ad97JEX8w3FQEhDpVP9eXMuQUKU=; b=K6b+TjbctiL3B7r7CdxLKtf9oMWK7i/KNksrA8rMoWWqXZcRsQ+iR9lYZhW7W3/GtT mPDbQy7xS6+iC7PKvTcxGIz/381DzUJcp7EZJZ9RdURwkngIAlkRw5EB1TLnN4E9xGIL I0gYv/clUyetDgx0Ei5HCDbyxEt5AKw8sIR7EF9lP0hySbc4K22QmLw6q23tqCwhVOoD yWsGpJIUhPkwQxzxmVAL4wTVp8Y3RxHGFgSBYD+3VT4o4nIhHsXcxo2BQRkCrwGRhDNn leiPJQGa1c+iMA6HihAuv2U5RYmu2tSPEWqNa64IzqRqzZJi4AlakyUlLcAs7l8T9L4T zQIg== X-Gm-Message-State: AOJu0YyutMsa2U2OU5ZRXC69552FUSK8Huzo+JN6OkP3/pm7UqOmJojI i+VkcPz3lv1Y6RXt1QQ3JIemKuOtJM5glZw3h7+EvEeH46LFDqnadElTWqZxrKg= X-Gm-Gg: ASbGncvEzYxEwNkuumSta9luEaU1Dmv21B77rmOEztT7e6bugFF8D9YpMCUWZsMEtyC VXFokvRbwsZDZv4w5UIxQ2X6tHokgCn6kh0pqZb5HWE2wcMqtCgbs5NQFsjfEpehBqsezvRYlwZ kL60N1Pr+LWB73zSD2Zbq4AU9hMVQ+C3X7/uXce3obEHsiStwZQLgn5he8qS1RU2FfJ8VDthJ61 VLBHGr7oAUg1vXIoEdj795rjVONTq96PDZuX1m4Z6IWy25c X-Google-Smtp-Source: AGHT+IE+QjE//GjxQG5ehLPNQ7Y/5dFBdFL7WdGne2/KQihWP4rnsuxbBbj2ZHn2imVQF/3GpjCCrw== X-Received: by 2002:a05:600c:524d:b0:434:9be8:6cb5 with SMTP id 5b1f17b1804b1-434a9dd0052mr113841215e9.17.1732874341658; Fri, 29 Nov 2024 01:59:01 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-385df63255bsm988347f8f.86.2024.11.29.01.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2024 01:59:01 -0800 (PST) Received: from draig (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3778D5F858; Fri, 29 Nov 2024 09:59:00 +0000 (GMT) From: =?utf-8?Q?Alex_Benn=C3=A9e?= To: Yanfeng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, alistair.francis@wdc.com Subject: Re: [PATCH v2] riscv/gdb: add virt mode debug interface In-Reply-To: (Yanfeng's message of "Fri, 29 Nov 2024 10:11:22 +0800") References: <8734jbh21e.fsf@draig.linaro.org> User-Agent: mu4e 1.12.7; emacs 29.4 Date: Fri, 29 Nov 2024 09:59:00 +0000 Message-ID: <87r06ufjiz.fsf@draig.linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.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-riscv@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-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Yanfeng writes: > On Thu, 2024-11-28 at 14:21 +0000, Alex Benn=C3=A9e wrote: >> Yanfeng Liu writes: >>=20 >> > This adds `virt` virtual register on debug interface so that users >> > can access current virtualization mode for debugging purposes. >> >=20 >> > Signed-off-by: Yanfeng Liu >> > --- >> > =C2=A0gdb-xml/riscv-32bit-virtual.xml |=C2=A0 1 + >> > =C2=A0gdb-xml/riscv-64bit-virtual.xml |=C2=A0 1 + >> > =C2=A0target/riscv/gdbstub.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 | 18 ++++++++++++------ >> > =C2=A03 files changed, 14 insertions(+), 6 deletions(-) >> >=20 >> > diff --git a/gdb-xml/riscv-32bit-virtual.xml b/gdb-xml/riscv-32bit- >> > virtual.xml >> > index 905f1c555d..d44b6ca2dc 100644 >> > --- a/gdb-xml/riscv-32bit-virtual.xml >> > +++ b/gdb-xml/riscv-32bit-virtual.xml >> > @@ -8,4 +8,5 @@ >> > =C2=A0 >> > =C2=A0 >> > =C2=A0=C2=A0 >> > +=C2=A0 >> > =C2=A0 >> > diff --git a/gdb-xml/riscv-64bit-virtual.xml b/gdb-xml/riscv-64bit- >> > virtual.xml >> > index 62d86c237b..7c9b63d5b6 100644 >> > --- a/gdb-xml/riscv-64bit-virtual.xml >> > +++ b/gdb-xml/riscv-64bit-virtual.xml >> > @@ -8,4 +8,5 @@ >> > =C2=A0 >> > =C2=A0 >> > =C2=A0=C2=A0 >> > +=C2=A0 >> > =C2=A0 >>=20 >> I assume these are mirrored in gdb not a QEMU only extension? > > So far I think it is a QEMU extension and the `gdb-multiarch` doesn't tre= at is > specially. My tests shows it basically works: > > ``` > (gdb) ir virt > priv 0x3 prv:3 [Machine] > virt 0x0 0 > (gdb) set $priv =3D 2 > (gdb) ir virt > priv 0x1 prv:1 [Supervisor] > virt 0x0 0 > (gdb) set $virt =3D 1 > (gdb) ir virt > priv 0x1 prv:1 [Supervisor] > virt 0x1 1 > (gdb) set $virt =3D 0 > (gdb) ir virt > priv 0x1 prv:1 [Supervisor] > virt 0x0 0 > (gdb) set $virt =3D 1 > (gdb) ir virt > priv 0x1 prv:1 [Supervisor] > virt 0x1 1 > (gdb) set $priv =3D 3 > (gdb) ir virt > priv 0x3 prv:3 [Machine] > virt 0x0 0 > ``` A gdbstub test case would be useful for this although I don't know if the RiscV check-tcg tests switch mode at all. > > As I am rather new to QEMU, please teach how we can add it as a QEMU only > extension. You don't need to extend the XML from GDB, you can build a specific one for QEMU extensions. For example: gdb_feature_builder_init(¶m.builder, &cpu->dyn_sysreg_feature.desc, "org.qemu.gdb.arm.sys.regs", "system-registers.xml", base_reg); This exports all the system registers QEMU knows about and GDB can access generically. Note the id is org.qemu..., indicating its our schema not gdbs. --=20 Alex Benn=C3=A9e Virtualisation Tech Lead @ Linaro