From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Matt Borgerson <contact@mborgerson.com>, qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH] accel/tcg: Fix guest instruction address in output assembly log
Date: Tue, 18 Jul 2023 08:17:28 +0200 [thread overview]
Message-ID: <2799e03f-3083-469b-fced-d92f6e3f1954@linaro.org> (raw)
In-Reply-To: <20230718013531.1669100-1-contact@mborgerson.com>
Hi Matt,
On 18/7/23 03:35, Matt Borgerson wrote:
> If CF_PCREL is enabled, generated host assembly logging (command line
> option `-d out_asm`) may incorrectly report guest instruction virtual
> addresses as page offsets instead of absolute addresses. This patch
> corrects the reported guest address.
>
> Signed-off-by: Matt Borgerson <contact@mborgerson.com>
> ---
> accel/tcg/translate-all.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index a1782db5dd..859db95cf7 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -283,6 +283,24 @@ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb,
> return tcg_gen_code(tcg_ctx, tb, pc);
> }
>
> +static vaddr get_guest_insn_vaddr(TranslationBlock *tb, vaddr pc, size_t insn)
> +{
> + g_assert(insn < tb->icount);
> +
> + /* FIXME: This replicates the restore_state_to_opc() logic. */
Hmmm maybe we could have a public helper defined in accel/tcg/cpu-exec.c
so we cat re-use it in accel/tcg/perf.c::perf_report_code().
> + vaddr addr = tcg_ctx->gen_insn_data[insn * TARGET_INSN_START_WORDS];
> +
> + if (tb_cflags(tb) & CF_PCREL) {
> + addr |= (pc & TARGET_PAGE_MASK);
> + } else {
> +#if defined(TARGET_I386)
> + addr -= tb->cs_base;
> +#endif
> + }
> +
> + return addr;
> +}
next prev parent reply other threads:[~2023-07-18 6:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 1:35 [PATCH] accel/tcg: Fix guest instruction address in output assembly log Matt Borgerson
2023-07-18 6:17 ` Philippe Mathieu-Daudé [this message]
2023-07-22 10:11 ` Richard Henderson
2023-07-23 3:42 ` Matt Borgerson
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=2799e03f-3083-469b-fced-d92f6e3f1954@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=contact@mborgerson.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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).