qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access target TranslatorOps


From: Alex Bennée
Subject: Re: Access target TranslatorOps
Date: Fri, 22 Jul 2022 10:18:33 +0100
User-agent: mu4e 1.7.27; emacs 28.1.90

Kenneth Adam Miller <kennethadammiller@gmail.com> writes:

> I need to determine the set of instruction encodings that the TCG can support 
> for a given platform. I am not bothered
> whether the target runs at all, and in fact it is better if it
> doesn't, so runtime or translate time doesn't bother me.

Which architectures are you interested in? For the ones that have been
converted to use decode tree it should be easy enough to update the
script to emit the uncovered opcode space. However decode tree targets
regular encoding - I think it has gained support for multiple encoding
modes but I don't know if it can handle the irregular madness of x86.

> Imagine I were adding support for more instructions for a given platform. I 
> would like to check that I'm using the API
> right. It's amazing that it's been so far and there's no way to check that 
> the correct behavior occurs when a given
> encoding is encountered regarding the TCG. A boolean result from a 
> can_translate called just when the target encounters
> the instruction would be good.

Generally when the translator encounters an instruction it can't
translate it would emit a illegal instruction exception. While you might
be able to peek into the TCG opcode stream to see such calls to the
relevant helpers I doubt it would be up-streamable as each front end
will deal with illegal instructions their own way (including
instructions that are illegal due to the current CPU operating mode).

> Additionally, the ability to force the translation of arbitrary encodings 
> would be good. I
> would like to not have to engineer some binary file format.

You don't need a new binary file format - just to construct an ELF with
the stream you want. A possibly adjacent project you might want to look
at is RISU:

  https://git.linaro.org/people/peter.maydell/risu.git/about/

which we've used for testing the range of the translator for a number of
architectures.

>
> On Wed, Jul 20, 2022 at 1:37 PM Peter Maydell <peter.maydell@linaro.org> 
> wrote:
>
>  On Wed, 20 Jul 2022 at 17:39, Kenneth Adam Miller
>  <kennethadammiller@gmail.com> wrote:
>  > That I know of, the TCG plugins do not allow me to feed the
>  > QEMU instance dynamically changing opcodes. I wouldn't use
>  > TranslatorOps if I don't have to. I want to facilitate a
>  > use case in which the contents of the target being emulated
>  > are changing, but it is not a self modifying target. I have
>  > to query and interact with the TCG to find out what opcodes
>  > are supported or not.
>
>  I agree that feeding opcodes into the translator isn't what
>  TCG plugins are intended for.
>
>  I'm definitely not clear on what you're trying to do here,
>  so it's hard to suggest some other approach, but linux-user
>  code shouldn't be messing with the internals of the translator
>  by grabbing the TranslatorOps struct. Among other things,
>  linux-user code is runtime and TranslatorOps is for
>  translate-time.
>
>  Sometimes code in linux-user needs to be a bit over-familiar
>  with the CPU state, but we try to keep that to a minimum.
>  Generally that involves code in target/foo/ providing some
>  set of interface functions that code in linux-user/foo/
>  can work with, typically passing it the CPU state struct.
>
>  thanks
>  -- PMM


-- 
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]