qemu-discuss
[Top][All Lists]
Advanced

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

Re: Qemu TCG Plugins - how to access guest registers?


From: Alex Bennée
Subject: Re: Qemu TCG Plugins - how to access guest registers?
Date: Wed, 01 Apr 2020 09:00:11 +0100
User-agent: mu4e 1.3.10; emacs 28.0.50

Benjamin <address@hidden> writes:

<snip>
>>
>> You don't need the registers at that point because at run time QEMU will
>> have already resolved the address and will pass it via the
>> qemu_plugin_register_vcpu_mem_cb. The hotpages and mem plugin examples
>> demonstrate the use of the API.
>>
>
> The way you explained this, although it might seem simple, really helped me
> understand better the level at which the TCG plugins operate.
> I went and changed my code to be more based on the code in hotpages.c, and
> it is much simpler now.
> I'm going to go look at that Dinero Cache Simulator you linked to see if I
> can get any ideas on how to improve my cache code.

Glad it was of help ;-)
>> > All of this being said, if you think my project is too complicated, to
>> > implement a cache emulator with TCG plugins, then I could always try just
>> > hacking together some custom helper functions.
>>
>> As I said above I don't think you need register values to do cache
>> emulation as you have the addresses. You will need to decode some of the
>> cache management instructions though. Fortunately you can do that at
>> translation time and only instrument the ones you need. See howvec for
>> examples.
>>
>
> I'm not familiar with cache management instructions.  What exactly do you
> mean by that?  It sounds like something that would be dependent on the
> guest architecture.
> Or maybe it's things like pre-fetching hints?  Then the plugin would need
> to take into account cache latencies, something my code doesn't deal with
> right now.

There are architecture dependent instructions that do things like flush
d and icaches. As QEMU doesn't expose those semantics to the plugin
(behaviour is very specific to each guest architecture) then the plugin
would have to deal with it itself. You would do this by checking each
translated instruction and inserting a call back in front of those that
do cache operations to make whatever internal changes you need to do
inside of the plugin.

> I would be glad to share my implementation once it's in a better working
> state.
> Where can I find guidelines on the coding standard expected of QEMU
> software?
> Thanks

CODING_STYLE.rst in the top level of the source tree is the canonical
document. Also "make check-tcg" will include a plugin test for each
plugin in the tree for each test (assuming you have compilers available
for each guest architecture - see docs/devel/testing.rst).

Good luck!

-- 
Alex Bennée



reply via email to

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