Skip to contentSkip to conversation

sysemu/accel: Simplify sysemu/hvf.h

PATCH Superseded Philippe Mathieu-Daudé 2 participants 6 messages Sep 5, 2023 – Oct 4, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover sysemu/accel: Simplify sysemu/hvf.h

Trivial cleanups which simplify "sysemu/hvf.h".

Philippe Mathieu-Daudé (2):
target/i386/hvf: Remove unused includes in 'hvf-i386.h' sysemu/kvm: Restrict hvf_get_supported_cpuid() to x86 targets

 include/sysemu/hvf.h       | 3 ---
 target/i386/hvf/hvf-i386.h | 6 +-----
 target/i386/cpu.c          | 1 +
 3 files changed, 2 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 target/i386/hvf: Remove unused includes in 'hvf-i386.h'

The only non standard type -- CPUArchState -- is forward declared in "qemu/typedefs.h", so no particular header is required here.

---
 target/i386/hvf/hvf-i386.h | 6 ------
 1 file changed, 6 deletions(-)
target/i386/hvf/hvf-i386.h +0 -6
index 95b47c1c2e..243bc111cc 100644
@@ -16,12 +16,6 @@
 #ifndef HVF_I386_H
 #define HVF_I386_H
 
-#include "qemu/accel.h"
-#include "sysemu/hvf.h"
-#include "sysemu/hvf_int.h"
-#include "cpu.h"
-#include "x86.h"
-
 void hvf_handle_io(CPUArchState *, uint16_t, void *, int, int, int);
 
 /* Host specific functions */
Signature · 1 line
2.41.0
#3 lore raw

PATCH 2/2 sysemu/kvm: Restrict hvf_get_supported_cpuid() to x86 targets

In reply to Philippe Mathieu-Daudé

hvf_get_supported_cpuid() is only defined for x86 targets (in target/i386/hvf/x86_cpuid.c).
Its declaration is pointless on all other targets.

All the calls to it in target/i386/cpu.c are guarded by a call on hvf_enabled(), so are elided when HVF is not built in. Therefore we can remove the unnecessary function stub.

---
 include/sysemu/hvf.h       | 3 ---
 target/i386/hvf/hvf-i386.h | 2 ++
 target/i386/cpu.c          | 1 +
 3 files changed, 3 insertions(+), 3 deletions(-)
include/sysemu/hvf.h +0 -3
index 4037cd6a73..4a7c6af3a5 100644
@@ -20,13 +20,10 @@
 #include "cpu.h"
 
 #ifdef CONFIG_HVF
-uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
-                                 int reg);
 extern bool hvf_allowed;
 #define hvf_enabled() (hvf_allowed)
 #else /* !CONFIG_HVF */
 #define hvf_enabled() 0
-#define hvf_get_supported_cpuid(func, idx, reg) 0
 #endif /* !CONFIG_HVF */
 
 #endif /* NEED_CPU_H */
target/i386/hvf/hvf-i386.h +2 -0
index 243bc111cc..e99c02cd4b 100644
@@ -16,6 +16,8 @@
 #ifndef HVF_I386_H
 #define HVF_I386_H
 
+uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx, int reg);
+
 void hvf_handle_io(CPUArchState *, uint16_t, void *, int, int, int);
 
 /* Host specific functions */
target/i386/cpu.c +1 -0
index 00f913b638..6789384bec 100644
@@ -26,6 +26,7 @@
 #include "tcg/helper-tcg.h"
 #include "sysemu/reset.h"
 #include "sysemu/hvf.h"
+#include "hvf/hvf-i386.h"
 #include "kvm/kvm_i386.h"
 #include "sev.h"
 #include "qapi/error.h"
Signature · 1 line
2.41.0
#4 lore raw

Re: [PATCH 2/2] sysemu/kvm: Restrict hvf_get_supported_cpuid() to x86 targets

Quoted 9 lines · Philippe Mathieu-Daudé

hvf_get_supported_cpuid() is only defined for x86 targets (in target/i386/hvf/x86_cpuid.c).
Its declaration is pointless on all other targets.

All the calls to it in target/i386/cpu.c are guarded by a call on hvf_enabled(), so are elided when HVF is not built in. Therefore we can remove the unnecessary function stub.

Looks good but you also need to include "hvf/hvf-i386.h" to target/i386/hvf/hvf-cpu.c, otherwise the build fails.

--Roman

#5 lore raw

Re: [PATCH 2/2] sysemu/kvm: Restrict hvf_get_supported_cpuid() to x86 targets

Quoted 5 lines · Roman Bolshakov
Quoted 4 lines · Philippe Mathieu-Daudé

hvf_get_supported_cpuid() is only defined for x86 targets (in target/i386/hvf/x86_cpuid.c).
Its declaration is pointless on all other targets.

Quoted 8 lines
Quoted 5 lines

All the calls to it in target/i386/cpu.c are guarded by a call on hvf_enabled(), so are elided when HVF is not built in. Therefore we can remove the unnecessary function stub.

Looks good but you also need to include "hvf/hvf-i386.h" to target/i386/hvf/hvf-cpu.c, otherwise the build fails.

Oops, thanks for testing!