diff mbox series

[v2,07/14] accel/stubs: Expand stubs for TCG

Message ID 20250203031821.741477-8-richard.henderson@linaro.org
State New
Headers show
Series meson: Deprecate 32-bit host support | expand

Commit Message

Richard Henderson Feb. 3, 2025, 3:18 a.m. UTC
Add tcg_allowed, qmp_x_query_jit, qmp_x_query_opcount.
These are referenced when CONFIG_TCG is enabled globally,
but not for a specific target.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/stubs/tcg-stub.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Thomas Huth Feb. 3, 2025, 10:22 a.m. UTC | #1
On 03/02/2025 04.18, Richard Henderson wrote:
> Add tcg_allowed, qmp_x_query_jit, qmp_x_query_opcount.
> These are referenced when CONFIG_TCG is enabled globally,
> but not for a specific target.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   accel/stubs/tcg-stub.c | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
> 
> diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
> index 7f4208fddf..9c2e2dc6e1 100644
> --- a/accel/stubs/tcg-stub.c
> +++ b/accel/stubs/tcg-stub.c
> @@ -13,6 +13,18 @@
>   #include "qemu/osdep.h"
>   #include "exec/tb-flush.h"
>   #include "exec/exec-all.h"
> +#include "qapi/error.h"
> +
> +/*
> + * This file *ought* to be built once and linked only when required.
> + * However, it is built per-target, which means qemu/osdep.h has already
> + * undef'ed CONFIG_TCG, which hides the auto-generated declaration.

So why don't we only build this file once?

  Thomas


> + */
> +#define CONFIG_TCG
> +#include "qapi/qapi-commands-machine.h"
> +
> +
> +const bool tcg_allowed = false;
>   
>   void tb_flush(CPUState *cpu)
>   {
> @@ -27,3 +39,15 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)
>   {
>       g_assert_not_reached();
>   }
> +
> +HumanReadableText *qmp_x_query_jit(Error **errp)
> +{
> +    error_setg(errp, "JIT information is only available with accel=tcg");
> +    return NULL;
> +}
> +
> +HumanReadableText *qmp_x_query_opcount(Error **errp)
> +{
> +    error_setg(errp, "Opcode count information is only available with accel=tcg");
> +    return NULL;
> +}
Richard Henderson Feb. 3, 2025, 4:43 p.m. UTC | #2
On 2/3/25 02:22, Thomas Huth wrote:
> On 03/02/2025 04.18, Richard Henderson wrote:
>> Add tcg_allowed, qmp_x_query_jit, qmp_x_query_opcount.
>> These are referenced when CONFIG_TCG is enabled globally,
>> but not for a specific target.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   accel/stubs/tcg-stub.c | 24 ++++++++++++++++++++++++
>>   1 file changed, 24 insertions(+)
>>
>> diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
>> index 7f4208fddf..9c2e2dc6e1 100644
>> --- a/accel/stubs/tcg-stub.c
>> +++ b/accel/stubs/tcg-stub.c
>> @@ -13,6 +13,18 @@
>>   #include "qemu/osdep.h"
>>   #include "exec/tb-flush.h"
>>   #include "exec/exec-all.h"
>> +#include "qapi/error.h"
>> +
>> +/*
>> + * This file *ought* to be built once and linked only when required.
>> + * However, it is built per-target, which means qemu/osdep.h has already
>> + * undef'ed CONFIG_TCG, which hides the auto-generated declaration.
> 
> So why don't we only build this file once?

I think we'd have to create a static library for it.
It didn't seem worth the effort at the time.
I can re-investigate if you like.


r~
Thomas Huth Feb. 3, 2025, 5:38 p.m. UTC | #3
On 03/02/2025 17.43, Richard Henderson wrote:
> On 2/3/25 02:22, Thomas Huth wrote:
>> On 03/02/2025 04.18, Richard Henderson wrote:
>>> Add tcg_allowed, qmp_x_query_jit, qmp_x_query_opcount.
>>> These are referenced when CONFIG_TCG is enabled globally,
>>> but not for a specific target.
>>>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>>   accel/stubs/tcg-stub.c | 24 ++++++++++++++++++++++++
>>>   1 file changed, 24 insertions(+)
>>>
>>> diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
>>> index 7f4208fddf..9c2e2dc6e1 100644
>>> --- a/accel/stubs/tcg-stub.c
>>> +++ b/accel/stubs/tcg-stub.c
>>> @@ -13,6 +13,18 @@
>>>   #include "qemu/osdep.h"
>>>   #include "exec/tb-flush.h"
>>>   #include "exec/exec-all.h"
>>> +#include "qapi/error.h"
>>> +
>>> +/*
>>> + * This file *ought* to be built once and linked only when required.
>>> + * However, it is built per-target, which means qemu/osdep.h has already
>>> + * undef'ed CONFIG_TCG, which hides the auto-generated declaration.
>>
>> So why don't we only build this file once?
> 
> I think we'd have to create a static library for it.
> It didn't seem worth the effort at the time.
> I can re-investigate if you like.

I think something like this might work:

diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
--- a/accel/stubs/meson.build
+++ b/accel/stubs/meson.build
@@ -1,6 +1,9 @@
  system_stubs_ss = ss.source_set()
-system_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
-system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
  system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
+system_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)
+
+specific_stubs_ss = ss.source_set()
+specific_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
+specific_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: specific_stubs_ss)

-specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)

?

  Thomas
Richard Henderson Feb. 3, 2025, 8 p.m. UTC | #4
On 2/3/25 09:38, Thomas Huth wrote:
> On 03/02/2025 17.43, Richard Henderson wrote:
>> On 2/3/25 02:22, Thomas Huth wrote:
>>> On 03/02/2025 04.18, Richard Henderson wrote:
>>>> Add tcg_allowed, qmp_x_query_jit, qmp_x_query_opcount.
>>>> These are referenced when CONFIG_TCG is enabled globally,
>>>> but not for a specific target.
>>>>
>>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>>> ---
>>>>   accel/stubs/tcg-stub.c | 24 ++++++++++++++++++++++++
>>>>   1 file changed, 24 insertions(+)
>>>>
>>>> diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
>>>> index 7f4208fddf..9c2e2dc6e1 100644
>>>> --- a/accel/stubs/tcg-stub.c
>>>> +++ b/accel/stubs/tcg-stub.c
>>>> @@ -13,6 +13,18 @@
>>>>   #include "qemu/osdep.h"
>>>>   #include "exec/tb-flush.h"
>>>>   #include "exec/exec-all.h"
>>>> +#include "qapi/error.h"
>>>> +
>>>> +/*
>>>> + * This file *ought* to be built once and linked only when required.
>>>> + * However, it is built per-target, which means qemu/osdep.h has already
>>>> + * undef'ed CONFIG_TCG, which hides the auto-generated declaration.
>>>
>>> So why don't we only build this file once?
>>
>> I think we'd have to create a static library for it.
>> It didn't seem worth the effort at the time.
>> I can re-investigate if you like.
> 
> I think something like this might work:

I think we need some of Philippe's include/exec/ cleanup work first. We currently use 
exec/exec-all.h, which requires cpu.h, which requires building per-target.


r~
diff mbox series

Patch

diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
index 7f4208fddf..9c2e2dc6e1 100644
--- a/accel/stubs/tcg-stub.c
+++ b/accel/stubs/tcg-stub.c
@@ -13,6 +13,18 @@ 
 #include "qemu/osdep.h"
 #include "exec/tb-flush.h"
 #include "exec/exec-all.h"
+#include "qapi/error.h"
+
+/*
+ * This file *ought* to be built once and linked only when required.
+ * However, it is built per-target, which means qemu/osdep.h has already
+ * undef'ed CONFIG_TCG, which hides the auto-generated declaration.
+ */
+#define CONFIG_TCG
+#include "qapi/qapi-commands-machine.h"
+
+
+const bool tcg_allowed = false;
 
 void tb_flush(CPUState *cpu)
 {
@@ -27,3 +39,15 @@  G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)
 {
     g_assert_not_reached();
 }
+
+HumanReadableText *qmp_x_query_jit(Error **errp)
+{
+    error_setg(errp, "JIT information is only available with accel=tcg");
+    return NULL;
+}
+
+HumanReadableText *qmp_x_query_opcount(Error **errp)
+{
+    error_setg(errp, "Opcode count information is only available with accel=tcg");
+    return NULL;
+}