[PATCH v2 08/14] target/mips: Protect objects with CONFIG_TCG

Richard Henderson posted 14 patches 2 months ago
There is a newer version of this series
[PATCH v2 08/14] target/mips: Protect objects with CONFIG_TCG
Posted by Richard Henderson 2 months ago
Hack around mips32 host allowing kvm acceleration
of mips64 guest, but tcg is disabled.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/mips/tcg/meson.build        | 4 ++--
 target/mips/tcg/system/meson.build | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build
index fff9cd6c7f..e5574f177b 100644
--- a/target/mips/tcg/meson.build
+++ b/target/mips/tcg/meson.build
@@ -10,7 +10,7 @@ gen = [
 ]
 
 mips_ss.add(gen)
-mips_ss.add(files(
+mips_ss.add(when: 'CONFIG_TCG', if_true: files(
   'dsp_helper.c',
   'exception.c',
   'fpu_helper.c',
@@ -26,7 +26,7 @@ mips_ss.add(files(
   'vr54xx_helper.c',
   'vr54xx_translate.c',
 ))
-mips_ss.add(when: 'TARGET_MIPS64', if_true: files(
+mips_ss.add(when: ['CONFIG_TCG', 'TARGET_MIPS64'], if_true: files(
   'tx79_translate.c',
   'octeon_translate.c',
   'lcsr_translate.c',
diff --git a/target/mips/tcg/system/meson.build b/target/mips/tcg/system/meson.build
index 911341ac37..606ccacebc 100644
--- a/target/mips/tcg/system/meson.build
+++ b/target/mips/tcg/system/meson.build
@@ -1,12 +1,12 @@
-mips_system_ss.add(files(
+mips_system_ss.add(when: 'CONFIG_TCG', if_true: files(
   'cp0_helper.c',
   'special_helper.c',
   'tlb_helper.c',
 ))
-mips_system_ss.add(when: ['CONFIG_SEMIHOSTING'],
+mips_system_ss.add(when: ['CONFIG_TCG', 'CONFIG_SEMIHOSTING'],
   if_true: files('mips-semi.c'),
   if_false: files('semihosting-stub.c')
 )
-mips_system_ss.add(when: 'TARGET_MIPS64', if_true: files(
+mips_system_ss.add(when: ['CONFIG_TCG', 'TARGET_MIPS64'], if_true: files(
   'lcsr_helper.c',
 ))
-- 
2.43.0
Re: [PATCH v2 08/14] target/mips: Protect objects with CONFIG_TCG
Posted by Philippe Mathieu-Daudé 2 months ago
Hi Richard,

On 3/2/25 04:18, Richard Henderson wrote:
> Hack around mips32 host allowing kvm acceleration
> of mips64 guest, but tcg is disabled.

We have in target/mips/meson.build:

if 'CONFIG_TCG' in config_all_accel
   subdir('tcg')
endif

What is the problem you are trying to address here?

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/mips/tcg/meson.build        | 4 ++--
>   target/mips/tcg/system/meson.build | 6 +++---
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build
> index fff9cd6c7f..e5574f177b 100644
> --- a/target/mips/tcg/meson.build
> +++ b/target/mips/tcg/meson.build
> @@ -10,7 +10,7 @@ gen = [
>   ]
>   
>   mips_ss.add(gen)
> -mips_ss.add(files(
> +mips_ss.add(when: 'CONFIG_TCG', if_true: files(
>     'dsp_helper.c',
>     'exception.c',
>     'fpu_helper.c',
> @@ -26,7 +26,7 @@ mips_ss.add(files(
>     'vr54xx_helper.c',
>     'vr54xx_translate.c',
>   ))
> -mips_ss.add(when: 'TARGET_MIPS64', if_true: files(
> +mips_ss.add(when: ['CONFIG_TCG', 'TARGET_MIPS64'], if_true: files(
>     'tx79_translate.c',
>     'octeon_translate.c',
>     'lcsr_translate.c',
> diff --git a/target/mips/tcg/system/meson.build b/target/mips/tcg/system/meson.build
> index 911341ac37..606ccacebc 100644
> --- a/target/mips/tcg/system/meson.build
> +++ b/target/mips/tcg/system/meson.build
> @@ -1,12 +1,12 @@
> -mips_system_ss.add(files(
> +mips_system_ss.add(when: 'CONFIG_TCG', if_true: files(
>     'cp0_helper.c',
>     'special_helper.c',
>     'tlb_helper.c',
>   ))
> -mips_system_ss.add(when: ['CONFIG_SEMIHOSTING'],
> +mips_system_ss.add(when: ['CONFIG_TCG', 'CONFIG_SEMIHOSTING'],
>     if_true: files('mips-semi.c'),
>     if_false: files('semihosting-stub.c')
>   )
> -mips_system_ss.add(when: 'TARGET_MIPS64', if_true: files(
> +mips_system_ss.add(when: ['CONFIG_TCG', 'TARGET_MIPS64'], if_true: files(
>     'lcsr_helper.c',
>   ))
Re: [PATCH v2 08/14] target/mips: Protect objects with CONFIG_TCG
Posted by Richard Henderson 2 months ago
On 2/3/25 09:25, Philippe Mathieu-Daudé wrote:
> Hi Richard,
> 
> On 3/2/25 04:18, Richard Henderson wrote:
>> Hack around mips32 host allowing kvm acceleration
>> of mips64 guest, but tcg is disabled.
> 
> We have in target/mips/meson.build:
> 
> if 'CONFIG_TCG' in config_all_accel
>    subdir('tcg')
> endif
> 
> What is the problem you are trying to address here?

That test is for CONFIG_TCG enabled for *any* target (config_all_accel).

E.g. qemu-system-mips on mipsel host has TCG enabled.

>> +mips_ss.add(when: 'CONFIG_TCG', if_true: files(

This test is for CONFIG_TCG enabled for a specific target (config_target).

E.g. qemu-system-mips64 on mipsel host does not have TCG enabled.
But it does have kvm enabled, so the target isn't entirely disabled.

Paolo's reply to the cover suggests this usage might be killable as well, so that we 
require a mips64el host to spawn mips64el guests, and all of this goes away.


r~

Re: [PATCH v2 08/14] target/mips: Protect objects with CONFIG_TCG
Posted by Thomas Huth 2 months ago
On 03/02/2025 04.18, Richard Henderson wrote:
> Hack around mips32 host allowing kvm acceleration
> of mips64 guest, but tcg is disabled.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/mips/tcg/meson.build        | 4 ++--
>   target/mips/tcg/system/meson.build | 6 +++---
>   2 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>