From: "Wu, Fei" <fei2.wu@intel.com>
To: Richard Henderson <richard.henderson@linaro.org>,
<alex.bennee@linaro.org>, <qemu-devel@nongnu.org>
Cc: "Vanderson M. do Rosario" <vandersonmr2@gmail.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Dr. David Alan Gilbert" <dave@treblig.org>
Subject: Re: [PATCH v14 08/10] Adding info [tb-list|tb] commands to HMP (WIP)
Date: Thu, 8 Jun 2023 15:38:17 +0800 [thread overview]
Message-ID: <ffe308e6-8d20-3282-a3b8-a9d6474fe7eb@intel.com> (raw)
In-Reply-To: <dddb5c1d-be72-15a7-97c3-eb306acd656f@intel.com>
On 6/7/2023 8:49 PM, Wu, Fei wrote:
> On 6/1/2023 10:40 AM, Richard Henderson wrote:
>>> +static int
>>> +__attribute__((format(printf, 2, 3)))
>>> +fprintf_log(FILE *a, const char *b, ...)
>>> +{
>>> + va_list ap;
>>> + va_start(ap, b);
>>> +
>>> + if (!to_string) {
>>> + vfprintf(a, b, ap);
>>> + } else {
>>> + qemu_vlog(b, ap);
>>> + }
>>> +
>>> + va_end(ap);
>>> +
>>> + return 1;
>>> +}
>>> +
>>
>> Not need on this either. Global variable being checked on each
>> callback, instead of selecting the proper callback earlier -- preferably
>> without the global variable.
>>
>> Did you really need something different than monitor_disas? You almost
>> certainly want to read physical memory and not virtual anyway.
>>
> Yes, it's usually okay for kernel address, but cannot re-gen the code
> for userspace virtual address (guest kernel panic on riscv guest). I
> tried monitor_disas() but it failed to disas too:
> monitor_disas(mon, mon_get_cpu(mon), tbs->phys_pc, num_inst, true);
>
> How to use this function correctly?
>
'phys_pc' in tbs is returned by get_page_addr_code_hostp(), which is not
guest phys address actually, but ram_addr_t instead, so it's always
wrong for monitor_disas. After some dirty changes, tbs can record the
guest pa. Now we can disas both kernel and user space code. But still,
no code is regenerated, disas in 'info tb' is just a convenient way to 'xp'.
Is there any existing function to convert ram_addr_t to guest pa?
(qemu) info tb-list 2
TB id:0 | phys:0x11b97762e virt:0x00aaaaaab76c262e flags:0x00024010 0 inv/1
| exec:4447539979/0 guest inst cov:69.06%
| trans:1 ints: g:8 op:28 op_opt:23 spills:0
| h/g (host bytes / guest insts): 37.000000
TB id:1 | phys:0x8063474e virt:0xffffffff8043474e flags:0x01024001 0 inv/1
| exec:131719290/0 guest inst cov:2.38%
| trans:1 ints: g:9 op:37 op_opt:35 spills:0
| h/g (host bytes / guest insts): 51.555557
(qemu) info tb 0
------------------------------
TB id:0 | phys:0x11b97762e virt:0x00aaaaaab76c262e flags:0x00024010 0 inv/1
| exec:5841751800/0 guest inst cov:69.06%
| trans:1 ints: g:8 op:28 op_opt:23 spills:0
| h/g (host bytes / guest insts): 37.000000
0x11b97762e: 00002797 auipc a5,8192
# 0x11b97962e
0x11b977632: a2278793 addi a5,a5,-1502
0x11b977636: 639c ld a5,0(a5)
0x11b977638: 00178713 addi a4,a5,1
0x11b97763c: 00002797 auipc a5,8192
# 0x11b97963c
0x11b977640: a1478793 addi a5,a5,-1516
0x11b977644: e398 sd a4,0(a5)
0x11b977646: b7e5 j -24
# 0x11b97762e
------------------------------
(qemu) xp/8i 0x11b97762e
0x11b97762e: 00002797 auipc a5,8192
# 0x11b97962e
0x11b977632: a2278793 addi a5,a5,-1502
0x11b977636: 639c ld a5,0(a5)
0x11b977638: 00178713 addi a4,a5,1
0x11b97763c: 00002797 auipc a5,8192
# 0x11b97963c
0x11b977640: a1478793 addi a5,a5,-1516
0x11b977644: e398 sd a4,0(a5)
0x11b977646: b7e5 j -24
# 0x11b97762e
(qemu)
(qemu) info tb 1
------------------------------
TB id:1 | phys:0x8063474e virt:0xffffffff8043474e flags:0x01024001 0 inv/1
| exec:131719290/0 guest inst cov:2.38%
| trans:1 ints: g:9 op:37 op_opt:35 spills:0
| h/g (host bytes / guest insts): 51.555557
0x8063474e: 00194a83 lbu s5,1(s2)
0x80634752: 00094803 lbu a6,0(s2)
0x80634756: 0b09 addi s6,s6,2
0x80634758: 008a9a9b slliw s5,s5,8
0x8063475c: 01586833 or a6,a6,s5
0x80634760: ff0b1f23 sh a6,-2(s6)
0x80634764: 1c7d addi s8,s8,-1
0x80634766: 0909 addi s2,s2,2
0x80634768: fe0c13e3 bnez s8,-26
# 0x8063474e
------------------------------
(qemu) xp/9i 0x8063474e
0x8063474e: 00194a83 lbu s5,1(s2)
0x80634752: 00094803 lbu a6,0(s2)
0x80634756: 0b09 addi s6,s6,2
0x80634758: 008a9a9b slliw s5,s5,8
0x8063475c: 01586833 or a6,a6,s5
0x80634760: ff0b1f23 sh a6,-2(s6)
0x80634764: 1c7d addi s8,s8,-1
0x80634766: 0909 addi s2,s2,2
0x80634768: fe0c13e3 bnez s8,-26
# 0x8063474e
Thanks,
Fei.
> Thanks,
> Fei.
>
>>> +void qemu_log_to_monitor(bool enable)
>>> +{
>>> + to_monitor = enable;
>>> +}
>>> +
>>> +void qemu_log_to_string(bool enable, GString *s)
>>> +{
>>> + to_string = enable;
>>> + string = s;
>>> +}
>>
>> What are these for, and why do you need them?
>> Why would to_string ever be anything other than (string != NULL)?
>> Why are you using such very generic names for global variables?
>>
>>
>> r~
>
next prev parent reply other threads:[~2023-06-08 7:44 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 8:35 [PATCH v14 00/10] TCG code quality tracking Fei Wu
2023-05-30 8:35 ` [PATCH v14 01/10] accel/tcg: remove CONFIG_PROFILER Fei Wu
2023-05-30 8:35 ` [PATCH v14 02/10] accel/tcg: introduce TBStatistics structure Fei Wu
2023-05-31 23:59 ` Richard Henderson
2023-06-01 1:30 ` Wu, Fei
2023-06-01 2:48 ` Richard Henderson
2023-06-01 0:01 ` Richard Henderson
2023-06-01 3:19 ` Wu, Fei
2023-06-01 4:16 ` Richard Henderson
2023-06-01 5:36 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 03/10] accel: collecting TB execution count Fei Wu
2023-06-01 0:05 ` Richard Henderson
2023-06-01 5:44 ` Wu, Fei
2023-06-01 14:03 ` Richard Henderson
2023-06-02 1:54 ` Wu, Fei
2023-06-02 4:02 ` Richard Henderson
2023-05-30 8:35 ` [PATCH v14 04/10] accel/tcg: add jit stats and time to TBStatistics Fei Wu
2023-05-30 9:37 ` Markus Armbruster
2023-05-31 0:54 ` Wu, Fei
2023-06-01 1:08 ` Richard Henderson
2023-06-01 6:48 ` Wu, Fei
2023-06-01 14:10 ` Richard Henderson
2023-06-01 15:10 ` Richard Henderson
2023-05-30 8:35 ` [PATCH v14 05/10] debug: add -d tb_stats to control TBStatistics collection: Fei Wu
2023-06-01 1:18 ` Richard Henderson
2023-06-01 6:59 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 06/10] monitor: adding tb_stats hmp command Fei Wu
2023-06-01 1:23 ` Richard Henderson
2023-06-01 7:20 ` Wu, Fei
2023-06-01 14:25 ` Richard Henderson
2023-05-30 8:35 ` [PATCH v14 07/10] tb-stats: reset the tracked TBs on a tb_flush Fei Wu
2023-06-01 1:30 ` Richard Henderson
2023-06-01 7:22 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 08/10] Adding info [tb-list|tb] commands to HMP (WIP) Fei Wu
2023-06-01 2:40 ` Richard Henderson
2023-06-01 12:12 ` Wu, Fei
2023-06-06 7:30 ` Wu, Fei
2023-06-07 12:49 ` Wu, Fei
2023-06-08 7:38 ` Wu, Fei [this message]
2023-06-08 9:23 ` Peter Maydell
2023-06-08 12:06 ` Dr. David Alan Gilbert
2023-06-08 12:22 ` Peter Maydell
2023-06-09 14:32 ` Wu, Fei
2023-06-09 15:51 ` Peter Maydell
2023-06-12 1:20 ` Wu, Fei
2023-05-30 8:35 ` [PATCH v14 09/10] tb-stats: dump hot TBs at the end of the execution Fei Wu
2023-05-30 8:35 ` [PATCH v14 10/10] docs: add tb-stats how to Fei Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffe308e6-8d20-3282-a3b8-a9d6474fe7eb@intel.com \
--to=fei2.wu@intel.com \
--cc=alex.bennee@linaro.org \
--cc=dave@treblig.org \
--cc=dgilbert@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=vandersonmr2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).