On 2025/11/21 19:02, Mohamed Mediouni wrote:
winhvemulation is x86_64 only.

In the future, we might want to get rid of winhvemulation usage
entirely.

Signed-off-by: Mohamed Mediouni <[email protected]>

Reviewed-by: Pierrick Bouvier <[email protected]>
---
  accel/whpx/whpx-common.c       | 14 ++++++++++++--
  include/system/whpx-common.h   |  2 ++
  include/system/whpx-internal.h |  7 ++++++-
  3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 66c9238586..95664a1df7 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -41,7 +41,9 @@
  bool whpx_allowed;
  static bool whp_dispatch_initialized;
  static HMODULE hWinHvPlatform;
+#ifdef __x86_64__

Please use: HOST_X86_64

Rationale: scripts/checkpatch.pl has the following code:

# check of hardware specific defines
# we have e.g. CONFIG_LINUX and CONFIG_WIN32 for common cases
# where they might be necessary.
                if ($line =~ m@^.\s*\#\s*if.*\b__@) {
                        WARN("architecture specific defines should be 
avoided\n" .  $herecurr);
                }

  static HMODULE hWinHvEmulation;
+#endif
struct whpx_state whpx_global;
  struct WHPDispatch whp_dispatch;
@@ -236,8 +238,10 @@ void whpx_destroy_vcpu(CPUState *cpu)
      struct whpx_state *whpx = &whpx_global;
whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index);
+#ifdef __x86_64__
      AccelCPUState *vcpu = cpu->accel;
      whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator);
+#endif
      g_free(cpu->accel);
  }
@@ -412,8 +416,12 @@ static bool load_whp_dispatch_fns(HMODULE *handle,
          LIST_WINHVPLATFORM_FUNCTIONS(WHP_LOAD_FIELD)
          break;
      case WINHV_EMULATION_FNS_DEFAULT:
+#ifdef __x86_64__
          WHP_LOAD_LIB(WINHV_EMULATION_DLL, hLib)
          LIST_WINHVEMULATION_FUNCTIONS(WHP_LOAD_FIELD)
+#else
+        g_assert_not_reached();
+#endif
          break;
      case WINHV_PLATFORM_FNS_SUPPLEMENTAL:
          WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib)
@@ -539,11 +547,11 @@ bool init_whp_dispatch(void)
      if (!load_whp_dispatch_fns(&hWinHvPlatform, WINHV_PLATFORM_FNS_DEFAULT)) {
          goto error;
      }
-
+#ifdef __x86_64__
      if (!load_whp_dispatch_fns(&hWinHvEmulation, 
WINHV_EMULATION_FNS_DEFAULT)) {
          goto error;
      }
-
+#endif
      assert(load_whp_dispatch_fns(&hWinHvPlatform,
          WINHV_PLATFORM_FNS_SUPPLEMENTAL));
      whp_dispatch_initialized = true;
@@ -553,9 +561,11 @@ error:
      if (hWinHvPlatform) {
          FreeLibrary(hWinHvPlatform);
      }
+#ifdef __x86_64__
      if (hWinHvEmulation) {
          FreeLibrary(hWinHvEmulation);
      }
+#endif
      return false;
  }
diff --git a/include/system/whpx-common.h b/include/system/whpx-common.h
index e549c7539c..7a7c607e0a 100644
--- a/include/system/whpx-common.h
+++ b/include/system/whpx-common.h
@@ -3,7 +3,9 @@
  #define SYSTEM_WHPX_COMMON_H
struct AccelCPUState {
+#ifdef __x86_64__
      WHV_EMULATOR_HANDLE emulator;
+#endif
      bool window_registered;
      bool interruptable;
      bool ready_for_pic_interrupt;
diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h
index c59f9de091..4565436682 100644
--- a/include/system/whpx-internal.h
+++ b/include/system/whpx-internal.h
@@ -4,8 +4,9 @@
#include <windows.h>
  #include <winhvplatform.h>
+#ifdef __x86_64__
  #include <winhvemulation.h>
-
+#endif
  #include "hw/i386/apic.h"
typedef enum WhpxBreakpointState {
@@ -100,12 +101,16 @@ void whpx_apic_get(APICCommonState *s);
/* Define function typedef */
  LIST_WINHVPLATFORM_FUNCTIONS(WHP_DEFINE_TYPE)
+#ifdef __x86_64__
  LIST_WINHVEMULATION_FUNCTIONS(WHP_DEFINE_TYPE)
+#endif
  LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_DEFINE_TYPE)
struct WHPDispatch {
      LIST_WINHVPLATFORM_FUNCTIONS(WHP_DECLARE_MEMBER)
+#ifdef __x86_64__
      LIST_WINHVEMULATION_FUNCTIONS(WHP_DECLARE_MEMBER)
+#endif
      LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_DECLARE_MEMBER)
  };


Reply via email to