Skip to contentSkip to conversation

Fix i386 HVF compilation failures

PATCH Superseded [email protected] 2 participants 5 messages Nov 26, 2025 – Nov 28, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix i386 HVF compilation failures

From: Nguyen Dinh Phi <[email protected]>

Recent changes introduced build errors in the i386 HVF backend:

- ../accel/hvf/hvf-accel-ops.c:163:17: error: no member named 'guest_debug_enabled' in 'struct AccelCPUState'
163 | cpu->accel->guest_debug_enabled = false;

- ../accel/hvf/hvf-accel-ops.c:151:51
error: no member named 'unblock_ipi_mask' in 'struct AccelCPUState'

- ../target/i386/hvf/hvf.c:736:5
error: use of undeclared identifier 'rip'

- ../target/i386/hvf/hvf.c:737:5
error: use of undeclared identifier 'env'

This patch corrects the field usage and move identifier to correct function ensuring successful compilation of the i386 HVF backend.

These issues were caused by:

Fixes 2ad756383e1b (“accel/hvf: Restrict ARM-specific fields of AccelCPUState”)
Fixes 2a21c9244740 (“target/i386/hvf: Factor hvf_handle_vmexit() out”)
---
 accel/hvf/hvf-accel-ops.c | 5 +++--
 target/i386/hvf/hvf.c     | 6 ++----
 2 files changed, 5 insertions(+), 6 deletions(-)
accel/hvf/hvf-accel-ops.c +3 -2
index 3e5feecd8a..e2cb8f202b 100644
@@ -148,19 +148,20 @@ static int hvf_init_vcpu(CPUState *cpu)
     sigact.sa_handler = dummy_signal;
     sigaction(SIG_IPI, &sigact, NULL);
 
+#ifdef __aarch64__
     pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);
     sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);
 
-#ifdef __aarch64__
     r = hv_vcpu_create(&cpu->accel->fd,
                        (hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
 #else
     r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
 #endif
     assert_hvf_ok(r);
+#ifdef __aarch64__
     cpu->vcpu_dirty = true;
-
     cpu->accel->guest_debug_enabled = false;
+#endif
 
     return hvf_arch_init_vcpu(cpu);
 }
target/i386/hvf/hvf.c +2 -4
index 16febbac48..2023a7bfbb 100644
@@ -728,7 +728,8 @@ static int hvf_handle_vmexit(CPUState *cpu)
     uint64_t exit_qual = rvmcs(cpu->accel->fd, VMCS_EXIT_QUALIFICATION);
     uint32_t ins_len = (uint32_t)rvmcs(cpu->accel->fd,
                                        VMCS_EXIT_INSTRUCTION_LENGTH);
-
+    CPUX86State *env = &x86_cpu->env;
+    uint64_t rip = 0;
     uint64_t idtvec_info = rvmcs(cpu->accel->fd, VMCS_IDT_VECTORING_INFO);
     int ret = 0;
 
@@ -966,10 +967,7 @@ static int hvf_handle_vmexit(CPUState *cpu)
 
 int hvf_arch_vcpu_exec(CPUState *cpu)
 {
-    X86CPU *x86_cpu = X86_CPU(cpu);
-    CPUX86State *env = &x86_cpu->env;
     int ret = 0;
-    uint64_t rip = 0;
 
     if (hvf_process_events(cpu)) {
         return EXCP_HLT;
Signature · 1 line
2.50.1 (Apple Git-155)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · On 26/11/25 10:46, [email protected] wrote:

From: Nguyen Dinh Phi <[email protected]>

Recent changes introduced build errors in the i386 HVF backend:

- ../accel/hvf/hvf-accel-ops.c:163:17: error: no member named 'guest_debug_enabled' in 'struct AccelCPUState'
163 | cpu->accel->guest_debug_enabled = false;

- ../accel/hvf/hvf-accel-ops.c:151:51
error: no member named 'unblock_ipi_mask' in 'struct AccelCPUState'

- ../target/i386/hvf/hvf.c:736:5
error: use of undeclared identifier 'rip'

- ../target/i386/hvf/hvf.c:737:5
error: use of undeclared identifier 'env'

Quoted 7 lines

This patch corrects the field usage and move identifier to correct function ensuring successful compilation of the i386 HVF backend.

These issues were caused by:

Fixes 2ad756383e1b (“accel/hvf: Restrict ARM-specific fields of AccelCPUState”)
Fixes 2a21c9244740 (“target/i386/hvf: Factor hvf_handle_vmexit() out”)

Oops.

Quoted 18 lines
---
  accel/hvf/hvf-accel-ops.c | 5 +++--
  target/i386/hvf/hvf.c     | 6 ++----
  2 files changed, 5 insertions(+), 6 deletions(-)
accel/hvf/hvf-accel-ops.c +1 -0
index 3e5feecd8a..e2cb8f202b 100644
@@ -148,19 +148,20 @@ static int hvf_init_vcpu(CPUState *cpu)
      sigact.sa_handler = dummy_signal;
      sigaction(SIG_IPI, &sigact, NULL);
 
+#ifdef __aarch64__
      pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);
      sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);

accel/hvf/hvf-accel-ops.c static int hvf_init_vcpu(CPUState *cpu) · line 162

Quoted 10 lines
accel/hvf/hvf-accel-ops.c +1 -1
 
-#ifdef __aarch64__
      r = hv_vcpu_create(&cpu->accel->fd,
                         (hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
  #else
      r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
  #endif
      assert_hvf_ok(r);
+#ifdef __aarch64__
      cpu->vcpu_dirty = true;

Don't we want the ifdef *after* this line?

Quoted 21 lines
accel/hvf/hvf-accel-ops.c +1 -1
-
      cpu->accel->guest_debug_enabled = false;
+#endif
 
      return hvf_arch_init_vcpu(cpu);
  }
target/i386/hvf/hvf.c +2 -1
index 16febbac48..2023a7bfbb 100644
@@ -728,7 +728,8 @@ static int hvf_handle_vmexit(CPUState *cpu)
      uint64_t exit_qual = rvmcs(cpu->accel->fd, VMCS_EXIT_QUALIFICATION);
      uint32_t ins_len = (uint32_t)rvmcs(cpu->accel->fd,
                                         VMCS_EXIT_INSTRUCTION_LENGTH);
-
+    CPUX86State *env = &x86_cpu->env;
+    uint64_t rip = 0;
      uint64_t idtvec_info = rvmcs(cpu->accel->fd, VMCS_IDT_VECTORING_INFO);
      int ret = 0;
 

target/i386/hvf/hvf.c static int hvf_handle_vmexit(CPUState *cpu) · line 973

Quoted 10 lines
target/i386/hvf/hvf.c +0 -3
@@ -966,10 +967,7 @@ static int hvf_handle_vmexit(CPUState *cpu)
 
  int hvf_arch_vcpu_exec(CPUState *cpu)
  {
-    X86CPU *x86_cpu = X86_CPU(cpu);
-    CPUX86State *env = &x86_cpu->env;
      int ret = 0;
-    uint64_t rip = 0;
 
      if (hvf_process_events(cpu)) {
          return EXCP_HLT;

Otherwise:

#2 lore raw
Quoted 48 lines · Philippe Mathieu-Daudé
Quoted 17 lines · On 26/11/25 10:46, [email protected] wrote:

From: Nguyen Dinh Phi <[email protected]>

Recent changes introduced build errors in the i386 HVF backend:

- ../accel/hvf/hvf-accel-ops.c:163:17: error: no member named 'guest_debug_enabled' in 'struct AccelCPUState'
   163 |     cpu->accel->guest_debug_enabled = false;

- ../accel/hvf/hvf-accel-ops.c:151:51
   error: no member named 'unblock_ipi_mask' in 'struct AccelCPUState'

- ../target/i386/hvf/hvf.c:736:5
   error: use of undeclared identifier 'rip'

- ../target/i386/hvf/hvf.c:737:5
   error: use of undeclared identifier 'env'

Quoted 7 lines

This patch corrects the field usage and move identifier to correct function ensuring successful compilation of the i386 HVF backend.

These issues were caused by:

Fixes 2ad756383e1b (“accel/hvf: Restrict ARM-specific fields of AccelCPUState”)
Fixes 2a21c9244740 (“target/i386/hvf: Factor hvf_handle_vmexit() out”)

Oops.

Quoted 20 lines

---
  accel/hvf/hvf-accel-ops.c | 5 +++--
  target/i386/hvf/hvf.c     | 6 ++----

  2 files changed, 5 insertions(+), 6 deletions(-)
accel/hvf/hvf-accel-ops.c +1 -1
index 3e5feecd8a..e2cb8f202b 100644
@@ -148,19 +148,20 @@ static int hvf_init_vcpu(CPUState *cpu)
       sigact.sa_handler = dummy_signal;
       sigaction(SIG_IPI, &sigact, NULL);
+#ifdef __aarch64__
       pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);
       sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);
-#ifdef __aarch64__
       r = hv_vcpu_create(&cpu->accel->fd,
                          (hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
Quoted 8 lines

accel/hvf/hvf-accel-ops.c static int hvf_init_vcpu(CPUState *cpu) · line 162

Quoted 6 lines
accel/hvf/hvf-accel-ops.c +1 -0
   #else
       r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
   #endif
       assert_hvf_ok(r);
+#ifdef __aarch64__
       cpu->vcpu_dirty = true;

Don't we want the ifdef *after* this line?

Oops, that was acutally that I meant to do, I think I made mistake when formatting the code. I will send a new version to move the #ifdef line. Somehow the vm still work normally on my intel Macbook.

Thanks,
Phi

#3 lore raw
Quoted 57 lines · Nguyen Dinh Phi [SG]
Quoted 48 lines · Philippe Mathieu-Daudé
Quoted 17 lines · On 26/11/25 10:46, [email protected] wrote:

From: Nguyen Dinh Phi <[email protected]>

Recent changes introduced build errors in the i386 HVF backend:

- ../accel/hvf/hvf-accel-ops.c:163:17: error: no member named 'guest_debug_enabled' in 'struct AccelCPUState'
   163 |     cpu->accel->guest_debug_enabled = false;

- ../accel/hvf/hvf-accel-ops.c:151:51
   error: no member named 'unblock_ipi_mask' in 'struct AccelCPUState'

- ../target/i386/hvf/hvf.c:736:5
   error: use of undeclared identifier 'rip'

- ../target/i386/hvf/hvf.c:737:5
   error: use of undeclared identifier 'env'

Quoted 7 lines

This patch corrects the field usage and move identifier to correct function ensuring successful compilation of the i386 HVF backend.

These issues were caused by:

Fixes 2ad756383e1b (“accel/hvf: Restrict ARM-specific fields of AccelCPUState”)
Fixes 2a21c9244740 (“target/i386/hvf: Factor hvf_handle_vmexit() out”)

Oops.

Quoted 20 lines

---
  accel/hvf/hvf-accel-ops.c | 5 +++--
  target/i386/hvf/hvf.c     | 6 ++----

  2 files changed, 5 insertions(+), 6 deletions(-)
accel/hvf/hvf-accel-ops.c +1 -1
index 3e5feecd8a..e2cb8f202b 100644
@@ -148,19 +148,20 @@ static int hvf_init_vcpu(CPUState *cpu)
       sigact.sa_handler = dummy_signal;
       sigaction(SIG_IPI, &sigact, NULL);
+#ifdef __aarch64__
       pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);
       sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);
-#ifdef __aarch64__
       r = hv_vcpu_create(&cpu->accel->fd,
                          (hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
Quoted 8 lines

accel/hvf/hvf-accel-ops.c static int hvf_init_vcpu(CPUState *cpu) · line 162

Quoted 6 lines
accel/hvf/hvf-accel-ops.c +1 -0
   #else
       r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
   #endif
       assert_hvf_ok(r);
+#ifdef __aarch64__
       cpu->vcpu_dirty = true;

Don't we want the ifdef *after* this line?

Quoted 1 line

Oops, that was acutally that I meant to do, I think I made mistake when formatting the code. I will send a new version to move the #ifdef line. Somehow the vm still work normally on my intel Macbook.

Does that mean you tested this patch and it works for you? I posted v2:
https://lore.kernel.org/qemu-devel/[email protected]/
What do you plan to change with it?

Thanks,

Phil.

#4 lore raw
Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 57 lines · Nguyen Dinh Phi [SG]
Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 17 lines · On 26/11/25 10:46, [email protected] wrote:

From: Nguyen Dinh Phi <[email protected]>

Recent changes introduced build errors in the i386 HVF backend:

- ../accel/hvf/hvf-accel-ops.c:163:17: error: no member named 'guest_debug_enabled' in 'struct AccelCPUState'
   163 |     cpu->accel->guest_debug_enabled = false;

- ../accel/hvf/hvf-accel-ops.c:151:51
   error: no member named 'unblock_ipi_mask' in 'struct AccelCPUState'

- ../target/i386/hvf/hvf.c:736:5
   error: use of undeclared identifier 'rip'

- ../target/i386/hvf/hvf.c:737:5
   error: use of undeclared identifier 'env'

Quoted 7 lines

This patch corrects the field usage and move identifier to correct function ensuring successful compilation of the i386 HVF backend.

These issues were caused by:

Fixes 2ad756383e1b (“accel/hvf: Restrict ARM-specific fields of AccelCPUState”)
Fixes 2a21c9244740 (“target/i386/hvf: Factor hvf_handle_vmexit() out”)

Oops.

Quoted 16 lines

---
  accel/hvf/hvf-accel-ops.c | 5 +++--
  target/i386/hvf/hvf.c     | 6 ++----

  2 files changed, 5 insertions(+), 6 deletions(-)
accel/hvf/hvf-accel-ops.c +1 -0
index 3e5feecd8a..e2cb8f202b 100644
@@ -148,19 +148,20 @@ static int hvf_init_vcpu(CPUState *cpu)
       sigact.sa_handler = dummy_signal;
       sigaction(SIG_IPI, &sigact, NULL);
+#ifdef __aarch64__
       pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);

accel/hvf/hvf-accel-ops.c static int hvf_init_vcpu(CPUState *cpu) · line 160

Quoted 10 lines
accel/hvf/hvf-accel-ops.c +1 -1
       sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);
-#ifdef __aarch64__
       r = hv_vcpu_create(&cpu->accel->fd,
                          (hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
   #else
       r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
   #endif
       assert_hvf_ok(r);
+#ifdef __aarch64__
       cpu->vcpu_dirty = true;

Don't we want the ifdef *after* this line?

Quoted 4 lines
Quoted 1 line

Oops, that was acutally that I meant to do, I think I made mistake when formatting the code. I will send a new version to move the #ifdef line. Somehow the vm still work normally on my intel Macbook.

Does that mean you tested this patch and it works for you? I posted v2:
https://lore.kernel.org/qemu-devel/20251126134434.14355-1- [email protected]/

Aw, sorry, I didn't aware of this.

Quoted 1 line

What do you plan to change with it?

Generally,it is them same as your post.
Yes, I tested my patch and it works fine, however, my original plan was to make the change similar to what you posted. I tried your patch too, and it works as expected, I think your patch does it better.

Thanks,
Phi