[PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition

Philippe Mathieu-Daudé posted 19 patches 6 months ago
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Igor Mitsyanko <i.mitsyanko@gmail.com>, Bernhard Beschow <shentey@gmail.com>, Rob Herring <robh@kernel.org>, Jean-Christophe Dubois <jcd@tribudubois.net>, Andrey Smirnov <andrew.smirnov@gmail.com>, Tyrone Ting <kfting@nuvoton.com>, Hao Wu <wuhaotsh@google.com>, Niek Linnenbank <nieklinnenbank@gmail.com>, Radoslaw Biernacki <rad@semihalf.com>, Leif Lindholm <leif.lindholm@oss.qualcomm.com>, Eric Auger <eric.auger@redhat.com>, Shannon Zhao <shannon.zhaosl@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Alistair Francis <alistair@alistair23.me>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alexander Graf <agraf@csgraf.de>, Phil Dennis-Jordan <phil@philjordan.eu>, Paolo Bonzini <pbonzini@redhat.com>
[PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
Posted by Philippe Mathieu-Daudé 6 months ago
In order to allow non-target specific code to include
"hvf_arm.h", define the stubs in hvf-stub.c.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 MAINTAINERS            |  1 +
 target/arm/hvf_arm.h   | 16 ----------------
 target/arm/hvf-stub.c  | 20 ++++++++++++++++++++
 target/arm/meson.build |  1 +
 4 files changed, 22 insertions(+), 16 deletions(-)
 create mode 100644 target/arm/hvf-stub.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 6dacd6d004d..7431f88b5d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -509,6 +509,7 @@ Apple Silicon HVF CPUs
 M: Alexander Graf <agraf@csgraf.de>
 S: Maintained
 F: target/arm/hvf/
+F: target/arm/hvf-stub.c
 
 X86 HVF CPUs
 M: Cameron Esfahani <dirty@apple.com>
diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h
index 26c717b3826..7a44e092620 100644
--- a/target/arm/hvf_arm.h
+++ b/target/arm/hvf_arm.h
@@ -22,23 +22,7 @@ void hvf_arm_init_debug(void);
 
 void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu);
 
-#ifdef CONFIG_HVF
-
 uint32_t hvf_arm_get_default_ipa_bit_size(void);
 uint32_t hvf_arm_get_max_ipa_bit_size(void);
 
-#else
-
-static inline uint32_t hvf_arm_get_default_ipa_bit_size(void)
-{
-    return 0;
-}
-
-static inline uint32_t hvf_arm_get_max_ipa_bit_size(void)
-{
-    return 0;
-}
-
-#endif
-
 #endif
diff --git a/target/arm/hvf-stub.c b/target/arm/hvf-stub.c
new file mode 100644
index 00000000000..ff137267a03
--- /dev/null
+++ b/target/arm/hvf-stub.c
@@ -0,0 +1,20 @@
+/*
+ * QEMU Hypervisor.framework (HVF) stubs for ARM
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hvf_arm.h"
+
+uint32_t hvf_arm_get_default_ipa_bit_size(void)
+{
+    g_assert_not_reached();
+}
+
+uint32_t hvf_arm_get_max_ipa_bit_size(void)
+{
+    g_assert_not_reached();
+}
diff --git a/target/arm/meson.build b/target/arm/meson.build
index e568dfb706a..2747f4b404c 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -32,6 +32,7 @@ arm_common_system_ss.add(files('cpu.c'), capstone)
 arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
   'cpu32-stubs.c'))
 arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
 arm_common_system_ss.add(files(
   'arch_dump.c',
   'arm-powerctl.c',
-- 
2.47.1


Re: [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
Posted by Richard Henderson 6 months ago
On 5/13/25 18:39, Philippe Mathieu-Daudé wrote:
> In order to allow non-target specific code to include
> "hvf_arm.h", define the stubs in hvf-stub.c.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   MAINTAINERS            |  1 +
>   target/arm/hvf_arm.h   | 16 ----------------
>   target/arm/hvf-stub.c  | 20 ++++++++++++++++++++
>   target/arm/meson.build |  1 +
>   4 files changed, 22 insertions(+), 16 deletions(-)
>   create mode 100644 target/arm/hvf-stub.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

Re: [PATCH 02/19] target/arm/hvf_arm: Avoid using poisoned CONFIG_HVF definition
Posted by Pierrick Bouvier 6 months ago
On 5/13/25 10:39 AM, Philippe Mathieu-Daudé wrote:
> In order to allow non-target specific code to include
> "hvf_arm.h", define the stubs in hvf-stub.c.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   MAINTAINERS            |  1 +
>   target/arm/hvf_arm.h   | 16 ----------------
>   target/arm/hvf-stub.c  | 20 ++++++++++++++++++++
>   target/arm/meson.build |  1 +
>   4 files changed, 22 insertions(+), 16 deletions(-)
>   create mode 100644 target/arm/hvf-stub.c

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>