Skip to contentSkip to conversation

i386: hvf: Remove hvf_disabled

PATCH Applied Roman Bolshakov 3 participants 3 messages Oct 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386: hvf: Remove hvf_disabled

accel_init_machine sets *(acc->allowed) to true if acc->init_machine(ms) succeeds. There's no need to have both hvf_allowed and hvf_disabled.

---
 include/sysemu/hvf.h  | 4 ++--
 target/i386/hvf/hvf.c | 9 +--------
 2 files changed, 3 insertions(+), 10 deletions(-)
include/sysemu/hvf.h +2 -2
index 241118845c..aaa51d2c51 100644
@@ -17,7 +17,7 @@
 #include "exec/memory.h"
 #include "sysemu/accel.h"
 
-extern int hvf_disabled;
+extern bool hvf_allowed;
 #ifdef CONFIG_HVF
 #include <Hypervisor/hv.h>
 #include <Hypervisor/hv_vmx.h>
@@ -26,7 +26,7 @@ extern int hvf_disabled;
 #include "hw/hw.h"
 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                                  int reg);
-#define hvf_enabled() !hvf_disabled
+#define hvf_enabled() (hvf_allowed)
 #else
 #define hvf_enabled() 0
 #define hvf_get_supported_cpuid(func, idx, reg) 0
target/i386/hvf/hvf.c +1 -8
index 9f52bc413a..e193022c03 100644
@@ -73,7 +73,6 @@
 #include "target/i386/cpu.h"
 
 HVFState *hvf_state;
-int hvf_disabled = 1;
 
 static void assert_hvf_ok(hv_return_t ret)
 {
@@ -604,11 +603,6 @@ int hvf_init_vcpu(CPUState *cpu)
     return 0;
 }
 
-void hvf_disable(int shouldDisable)
-{
-    hvf_disabled = shouldDisable;
-}
-
 static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_info)
 {
     X86CPU *x86_cpu = X86_CPU(cpu);
@@ -934,7 +928,7 @@ int hvf_vcpu_exec(CPUState *cpu)
     return ret;
 }
 
-static bool hvf_allowed;
+bool hvf_allowed;
 
 static int hvf_accel_init(MachineState *ms)
 {
@@ -942,7 +936,6 @@ static int hvf_accel_init(MachineState *ms)
     hv_return_t ret;
     HVFState *s;
 
-    hvf_disable(0);
     ret = hv_vm_create(HV_VM_DEFAULT);
     assert_hvf_ok(ret);
 
Signature · 1 line
2.17.1 (Apple Git-112)
#1 lore raw
Quoted 66 lines · Roman Bolshakov

accel_init_machine sets *(acc->allowed) to true if acc->init_machine(ms) succeeds. There's no need to have both hvf_allowed and hvf_disabled.

---
 include/sysemu/hvf.h  | 4 ++--
 target/i386/hvf/hvf.c | 9 +--------
 2 files changed, 3 insertions(+), 10 deletions(-)
include/sysemu/hvf.h +2 -2
index 241118845c..aaa51d2c51 100644
@@ -17,7 +17,7 @@
 #include "exec/memory.h"
 #include "sysemu/accel.h"
 
-extern int hvf_disabled;
+extern bool hvf_allowed;
 #ifdef CONFIG_HVF
 #include <Hypervisor/hv.h>
 #include <Hypervisor/hv_vmx.h>
@@ -26,7 +26,7 @@ extern int hvf_disabled;
 #include "hw/hw.h"
 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                                  int reg);
-#define hvf_enabled() !hvf_disabled
+#define hvf_enabled() (hvf_allowed)
 #else
 #define hvf_enabled() 0
 #define hvf_get_supported_cpuid(func, idx, reg) 0
target/i386/hvf/hvf.c +1 -7
index 9f52bc413a..e193022c03 100644
@@ -73,7 +73,6 @@
 #include "target/i386/cpu.h"
 
 HVFState *hvf_state;
-int hvf_disabled = 1;
 
 static void assert_hvf_ok(hv_return_t ret)
 {
@@ -604,11 +603,6 @@ int hvf_init_vcpu(CPUState *cpu)
     return 0;
 }
 
-void hvf_disable(int shouldDisable)
-{
-    hvf_disabled = shouldDisable;
-}
-
 static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_info)
 {
     X86CPU *x86_cpu = X86_CPU(cpu);
@@ -934,7 +928,7 @@ int hvf_vcpu_exec(CPUState *cpu)
     return ret;
 }
 
-static bool hvf_allowed;
+bool hvf_allowed;
 
 static int hvf_accel_init(MachineState *ms)
 {

target/i386/hvf/hvf.c static int hvf_accel_init(MachineState *ms) · line 941

Quoted 7 lines
target/i386/hvf/hvf.c +0 -1
@@ -942,7 +936,6 @@ static int hvf_accel_init(MachineState *ms)
     hv_return_t ret;
     HVFState *s;
 
-    hvf_disable(0);
     ret = hv_vm_create(HV_VM_DEFAULT);
     assert_hvf_ok(ret);
 

Queued, thanks.

Paolo

Reviewed-by on v1 1/1
#2 lore raw
In reply to Roman Bolshakov
Quoted 8 lines · Roman Bolshakov

accel_init_machine sets *(acc->allowed) to true if acc->init_machine(ms) succeeds. There's no need to have both hvf_allowed and hvf_disabled.

---
 include/sysemu/hvf.h  | 4 ++--
 target/i386/hvf/hvf.c | 9 +--------
 2 files changed, 3 insertions(+), 10 deletions(-)

This brings HVF into line with all the other accelerators, which define the foo_enabled() function or macro to look at a foo_allowed flag.

thanks
-- PMM