[PATCH 09/29] tcg/module: add tcg-module.[ch] infrastructure

Gerd Hoffmann posted 29 patches 4 years, 5 months ago
Maintainers: Mahmoud Mandour <ma.mandourr@gmail.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Alexandre Iooss <erdnaxe@crans.org>, Aurelien Jarno <aurelien@aurel32.net>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Halil Pasic <pasic@linux.ibm.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Peter Xu <peterx@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Bin Meng <bin.meng@windriver.com>, "Michael S. Tsirkin" <mst@redhat.com>, Alistair Francis <alistair.francis@wdc.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Thomas Huth <thuth@redhat.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Laurent Vivier <laurent@vivier.eu>, Huacai Chen <chenhuacai@kernel.org>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Max Filippov <jcmvbkbc@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Greg Kurz <groug@kaod.org>, Christian Borntraeger <borntraeger@de.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, "Alex Bennée" <alex.bennee@linaro.org>, Stafford Horne <shorne@gmail.com>, Richard Henderson <richard.henderson@linaro.org>
[PATCH 09/29] tcg/module: add tcg-module.[ch] infrastructure
Posted by Gerd Hoffmann 4 years, 5 months ago
Add TCGModuleOps struct, empty for now, followup patches will fill it.
This struct has pointers for tcg functions which are called by core
qemu.

The struct is initialized (at compile time) with pointers to stub
functions.  When the tcg module loads it will update the function
pointers to point to the real functions instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/tcg/tcg-module.h | 8 ++++++++
 accel/tcg/tcg-module.c   | 5 +++++
 accel/tcg/meson.build    | 4 ++++
 3 files changed, 17 insertions(+)
 create mode 100644 include/tcg/tcg-module.h
 create mode 100644 accel/tcg/tcg-module.c

diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
new file mode 100644
index 000000000000..7e87aecb2357
--- /dev/null
+++ b/include/tcg/tcg-module.h
@@ -0,0 +1,8 @@
+#ifndef TCG_MODULE_H
+#define TCG_MODULE_H
+
+struct TCGModuleOps {
+};
+extern struct TCGModuleOps tcg;
+
+#endif /* TCG_MODULE_H */
diff --git a/accel/tcg/tcg-module.c b/accel/tcg/tcg-module.c
new file mode 100644
index 000000000000..e864fb20c141
--- /dev/null
+++ b/accel/tcg/tcg-module.c
@@ -0,0 +1,5 @@
+#include "qemu/osdep.h"
+#include "tcg/tcg-module.h"
+
+struct TCGModuleOps tcg = {
+};
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index ec74e17a8285..93cbbf9f3926 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -1,3 +1,7 @@
+specific_ss.add(files(
+  'tcg-module.c',
+))
+
 specific_ss.add(when: 'CONFIG_TCG', if_true: files(
   'cpu-exec-common.c',
 ))
-- 
2.31.1


Re: [PATCH 09/29] tcg/module: add tcg-module.[ch] infrastructure
Posted by Philippe Mathieu-Daudé 4 years, 4 months ago
On 8/31/21 14:15, Gerd Hoffmann wrote:
> Add TCGModuleOps struct, empty for now, followup patches will fill it.
> This struct has pointers for tcg functions which are called by core
> qemu.
> 
> The struct is initialized (at compile time) with pointers to stub
> functions.  When the tcg module loads it will update the function
> pointers to point to the real functions instead.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/tcg/tcg-module.h | 8 ++++++++
>  accel/tcg/tcg-module.c   | 5 +++++
>  accel/tcg/meson.build    | 4 ++++
>  3 files changed, 17 insertions(+)
>  create mode 100644 include/tcg/tcg-module.h
>  create mode 100644 accel/tcg/tcg-module.c
> 
> diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
> new file mode 100644
> index 000000000000..7e87aecb2357
> --- /dev/null
> +++ b/include/tcg/tcg-module.h
> @@ -0,0 +1,8 @@
> +#ifndef TCG_MODULE_H
> +#define TCG_MODULE_H
> +
> +struct TCGModuleOps {
> +};
> +extern struct TCGModuleOps tcg;

TCG functions taking a CPUState argument should reside in
CPUClass's AccelCPUClass/TCGCPUOps, not a global struct.


Re: [PATCH 09/29] tcg/module: add tcg-module.[ch] infrastructure
Posted by Gerd Hoffmann 4 years, 4 months ago
  Hi,

> > +struct TCGModuleOps {
> > +};
> > +extern struct TCGModuleOps tcg;
> 
> TCG functions taking a CPUState argument should reside in
> CPUClass's AccelCPUClass/TCGCPUOps, not a global struct.

It's not that easy.  Tried that first, but using TCGCPUOps outside cpu
code doesn't work.

take care,
  Gerd