qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Simon Hamelin" <Simon.Hamelin@grenoble-inp.org>,
	"Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, Alexandre Iooss <erdnaxe@crans.org>,
	Mahmoud Mandour <ma.mandourr@gmail.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2] plugins/stoptrigger: TCG plugin to stop execution under conditions
Date: Tue, 16 Jul 2024 08:35:39 -0700	[thread overview]
Message-ID: <da5e6235-311e-4dc2-ad01-fc4fd12b22df@linaro.org> (raw)
In-Reply-To: <b964ae7b-6ae4-43a4-b886-70e8e9875f58@grenoble-inp.org>

On 7/16/24 02:02, Simon Hamelin wrote:
> 
> 
> On 7/16/24 01:08, Pierrick Bouvier wrote:
>> On 7/15/24 01:09, Simon Hamelin wrote:
>>> Hello Pierrick,
>>>
>>>> Could you share a bit more information on the final goal, if possible?
>>>> Is that used for fuzzing binaries, security analysis, or other things?
>>>
>>> I'm currently using this plugin for security analysis purposes.
>>> Basically my goal is to simulate fault injection using QEMU. To do so
>>> I'm using this plugin along with another plugin that skips an
>>> instruction at a given address. With this plugin I'm able to see how the
>>> program reacts to the fault and stop it with a custom return code.
>>> Basically there are 4 cases:
>>>       - The fault does not disrupt the program and it reaches the expected
>>> address.
>>>       - The fault disrupt the program and it reaches an unexpected address
>>> known as the "target" address.
>>>       - The fault disrupt the program in such a way that it executes a lot
>>> of instructions without reaching the expected address, this situation is
>>> known as a "timeout".
>>>       - The fault crashes the guest, causing it to reach an error handler
>>> address.
>>>
>>
>> Thanks for sharing this, it's an interesting use case.
>>
>> How did you implement instruction skipping?
>> Is that based on current API, or do you have a QEMU fork?
>>
> 
> I had to extend the current API to support writing guest registers,
> specifically I'm skipping instructions by writing to the PC register. To
> do this I use the set_pc function of the CPUClass struct. This requires
> a bit of a hack to make the TCG react to the PC change as it's normal
> behavior is to execute the entire TB and ignore the PC change. To make
> the TCG react to this modification the only way I've found is to leave
> it midway it's execution using the `cpu_loop_exit` function.
> 

Ok.
So far, our API is designed to not allow modification on guest side 
(code or data wise). It's definitely a discussion we should start at 
some point, as it may be needed for specific use cases.

Thanks!

      reply	other threads:[~2024-07-16 15:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10 12:08 [PATCH v2] plugins/stoptrigger: TCG plugin to stop execution under conditions Simon Hamelin
2024-07-11 10:03 ` Alex Bennée
2024-07-12  7:53   ` Simon Hamelin
2024-07-12 17:23     ` Pierrick Bouvier
2024-07-15  8:09       ` Simon Hamelin
2024-07-15  8:25         ` Simon Hamelin
2024-07-15 23:08         ` Pierrick Bouvier
2024-07-16  9:02           ` Simon Hamelin
2024-07-16 15:35             ` Pierrick Bouvier [this message]

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=da5e6235-311e-4dc2-ad01-fc4fd12b22df@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=Simon.Hamelin@grenoble-inp.org \
    --cc=alex.bennee@linaro.org \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.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).