From: Richard Henderson <richard.henderson@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: David Hildenbrand <david@redhat.com>,
Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>,
"open list:S390 TCG CPUs" <qemu-s390x@nongnu.org>
Subject: Re: [RFC PATCH] target/s390x: fake instruction loading when handling 'ex'
Date: Thu, 20 Oct 2022 01:55:47 +1000 [thread overview]
Message-ID: <d11fbd88-5607-be2a-b5ee-2f34b9eece71@linaro.org> (raw)
In-Reply-To: <20221019113552.1051940-1-alex.bennee@linaro.org>
On 10/19/22 21:35, Alex Bennée wrote:
> The s390x EXecute instruction is a bit weird as we synthesis the
> executed instruction from what we have stored in memory. When plugins
> are enabled this breaks because we detect the ld_code2() loading from
> a non zero offset without the rest of the instruction being there.
Hmm. The fact that you see an ld_code2 at all is incorrect.
(1) translator_lduw, which ld_code2 is using, is supposed to
be only for instructions that we're executing, per plugins.
But the usage you are seeing is a probe for the next insn,
which should not be included.
(2) We always exit the tb after EX, so the probe for the next
insn is also wrong. We've got the tests in the wrong order:
if (!is_same_page(dcbase, dc->base.pc_next) ||
!is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next)) ||
dc->ex_value) {
None of that takes away from the fact that we *should* have a way to report the EX
instruction to the plugin.
> +/**
> + * translator_fake_ldw - fake instruction load
> + * @insn16: 2 byte instruction
> + * @pc: program counter of instruction
> + *
> + * This is a special case helper used where the instruction we are
> + * about to translate comes from somewhere else (e.g. being
> + * re-synthesised for s390x "ex"). It ensures we update other areas of
> + * the translator with details of the executed instruction.
> + */
> +
> +static inline void translator_fake_ldw(uint16_t insn16, abi_ptr pc)
> +{
> + plugin_insn_append(pc, &insn16, sizeof(insn16));
> +}
You're not handing the endianness of the two bytes.
I think you should just decompose all the way to fake_ldb.
I don't know much sense you're going to get out of the PC. The EX instruction is at a
particular address A, having loaded data from B. The EX instruction is 4 bytes, but the
insn at B may be 6 bytes. The next insn executed may well be PC = A+4, apparently
overlapping with the 6 byte insn you gave to the plugin just a minute ago.
But I don't know what else to report except [PC, PC+5], as you're doing.
r~
next prev parent reply other threads:[~2022-10-19 23:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 11:35 [RFC PATCH] target/s390x: fake instruction loading when handling 'ex' Alex Bennée
2022-10-19 15:55 ` Richard Henderson [this message]
2022-10-19 20:03 ` Philippe Mathieu-Daudé
2022-10-20 11:09 ` Alex Bennée
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=d11fbd88-5607-be2a-b5ee-2f34b9eece71@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@redhat.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).