summary refs log tree commit diff stats
path: root/include/qemu/plugin.h
diff options
context:
space:
mode:
authorRowan Hart <rowanbhart@gmail.com>2025-06-27 12:25:03 +0100
committerAlex Bennée <alex.bennee@linaro.org>2025-07-02 10:09:48 +0100
commit766e00bd570f54c8d08023a46cd3386e96ecd39f (patch)
tree7e8f4afc7cbc4f0799ce565d5384d9a81dbc880f /include/qemu/plugin.h
parent1a92b65859e2d58dbf4b8356940c42c5834e9710 (diff)
downloadfocaccia-qemu-766e00bd570f54c8d08023a46cd3386e96ecd39f.tar.gz
focaccia-qemu-766e00bd570f54c8d08023a46cd3386e96ecd39f.zip
plugins: Add enforcement of QEMU_PLUGIN_CB flags in register R/W callbacks
This patch adds functionality to enforce the requested QEMU_PLUGIN_CB_
flags level passed when registering a callback function using the
plugins API. Each time a callback is about to be invoked, a thread-local
variable will be updated with the level that callback requested. Then,
called API functions (in particular, the register read and write API)
will call qemu_plugin_get_cb_flags() to check the level is at least the
level they require.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Rowan Hart <rowanbhart@gmail.com>
Message-ID: <20250624175351.440780-4-rowanbhart@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-ID: <20250627112512.1880708-8-alex.bennee@linaro.org>
Diffstat (limited to 'include/qemu/plugin.h')
-rw-r--r--include/qemu/plugin.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index 9726a9ebf3..f355c7cb8a 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -209,6 +209,21 @@ void qemu_plugin_user_prefork_lock(void);
  */
 void qemu_plugin_user_postfork(bool is_child);
 
+enum qemu_plugin_cb_flags tcg_call_to_qemu_plugin_cb_flags(int flags);
+
+static inline void qemu_plugin_set_cb_flags(CPUState *cpu,
+                                            enum qemu_plugin_cb_flags flags)
+{
+    assert(cpu);
+    cpu->neg.plugin_cb_flags = flags;
+}
+
+static inline enum qemu_plugin_cb_flags qemu_plugin_get_cb_flags(void)
+{
+    assert(current_cpu);
+    return current_cpu->neg.plugin_cb_flags;
+}
+
 #else /* !CONFIG_PLUGIN */
 
 static inline void qemu_plugin_add_opts(void)