On 6/9/25 12:38 PM, Rowan Hart wrote:
From: novafacing <rowanbh...@gmail.com>
This patch adds a plugin that implements a simple form of hypercalls
from guest code to the plugin by using the register read API. It accepts
only one hypercall, which writes a magic value to guest memory.
Signed-off-by: Rowan Hart <rowanbh...@gmail.com>
---
tests/tcg/Makefile.target | 1 +
tests/tcg/plugins/hypercalls.c | 547 ++++++++++++++++++
tests/tcg/plugins/meson.build | 2 +-
tests/tcg/x86_64/Makefile.softmmu-target | 6 +-
tests/tcg/x86_64/system/hypercalls-target.c | 40 ++
.../tcg/x86_64/system/validate-hypercalls.py | 40 ++
6 files changed, 634 insertions(+), 2 deletions(-)
create mode 100644 tests/tcg/plugins/hypercalls.c
create mode 100644 tests/tcg/x86_64/system/hypercalls-target.c
create mode 100755 tests/tcg/x86_64/system/validate-hypercalls.py
Hypercalls are a very nice idea, and could help to write code aware of
instrumentation, to send specific events to a plugin.
Introducing this in a specific plugin is an excellent proof of concept,
but if we want something upstream, we'll need a proper plugin API
implementation. That means one where a plugin can register a specific
hypercall_nr (checking it's only registered once), and can read
arguments and return values: in short, reinventing a proper syscall
convention. This is what has been achieved in the current patch, the
idea would to wrap all that on QEMU plugins side.
In more, we should provide a portable header, allowing any code to
include it. All that with fixed width types, so it's not affected by
differences between architectures. This way, any system code, or user
code, can include this, and communicate with a (compatible) plugin easily.
No need to cover all architectures at once, we can start with only i386*
and arm* targets, and extend that later.
That said, I think we should leave this out of the current series for
now, as it's not directly related to what is introduced, but it's
definitely something that would be nice to see in the future, with the
requirements above.
Thanks,
Pierrick