kvm: Move x86-specific functions into target-i386/kvm.c
PATCH 1/1 kvm: Move x86-specific functions into target-i386/kvm.c
The functions for checking xcrs, xsave and pit_state2 are only used on x86, so they should reside in target-i386/kvm.c.
Signed-off-by Thomas Huth <[email protected]>
--- include/sysemu/kvm.h | 2 -- kvm-all.c | 29 ----------------------------- kvm-stub.c | 5 ----- target-i386/kvm.c | 31 ++++++++++++++++++++++++++----- 4 files changed, 26 insertions(+), 41 deletions(-)
include/sysemu/kvm.h +0 -2
@@ -182,8 +182,6 @@ int kvm_has_sync_mmu(void);int kvm_has_vcpu_events (void );int kvm_has_robust_singlestep (void );int kvm_has_debugregs (void ); -int kvm_has_xsave (void ); -int kvm_has_xcrs (void );int kvm_has_pit_state2 (void );int kvm_has_many_ioeventfds (void );int kvm_has_gsi_routing (void );
kvm-all.c +0 -29
@@ -77,8 +77,6 @@ struct KVMState#ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint_head kvm_sw_breakpoints;#endif -int pit_state2; -int xsave, xcrs;int many_ioeventfds;int intx_set_mask;/* The man page (and posix) say ioctl numbers are signed int, but
@@ -1585,18 +1583,6 @@ static int kvm_init(MachineState *ms) s->debugregs =kvm_check_extension (s,KVM_CAP_DEBUGREGS );#endif -#ifdef KVM_CAP_XSAVE - s->xsave =kvm_check_extension (s,KVM_CAP_XSAVE ); -#endif - -#ifdef KVM_CAP_XCRS - s->xcrs =kvm_check_extension (s,KVM_CAP_XCRS ); -#endif - -#ifdef KVM_CAP_PIT_STATE2 - s->pit_state2 =kvm_check_extension (s,KVM_CAP_PIT_STATE2 ); -#endif -#ifdef KVM_CAP_IRQ_ROUTING s->direct_msi = (kvm_check_extension (s,KVM_CAP_SIGNAL_MSI ) >0 );#endif
@@ -2062,21 +2048,6 @@ int kvm_has_debugregs(void)return kvm_state->debugregs; } -int kvm_has_xsave (void ) -{ -return kvm_state->xsave; -} - -int kvm_has_xcrs (void ) -{ -return kvm_state->xcrs; -} - -int kvm_has_pit_state2 (void ) -{ -return kvm_state->pit_state2; -} -int kvm_has_many_ioeventfds (void ) {if (!kvm_enabled ()) {
kvm-stub.c +0 -5
@@ -67,11 +67,6 @@ int kvm_has_many_ioeventfds(void)return 0 ; } -int kvm_has_pit_state2 (void ) -{ -return 0 ; -} -void kvm_setup_guest_memory (void *start,size_t size) { }
target-i386/kvm.c +26 -5
@@ -88,6 +88,15 @@ static bool has_msr_xss;static bool has_msr_architectural_pmu;static uint32_t num_architectural_pmu_counters; +static int has_xsave; +static int has_xcrs; +static int has_pit_state2; + +int kvm_has_pit_state2 (void ) +{ +return has_pit_state2; +} +bool kvm_has_smm (void ) {return kvm_check_extension (kvm_state,KVM_CAP_X86_SMM );
@@ -752,7 +761,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } } -if (kvm_has_xsave ()) { +if (has_xsave) { env->kvm_xsave_buf =qemu_memalign (4096 ,sizeof (struct kvm_xsave )); }
@@ -908,6 +917,18 @@ int kvm_arch_init(MachineState *ms, KVMState *s)int ret;struct utsname utsname; +#ifdef KVM_CAP_XSAVE + has_xsave =kvm_check_extension (s,KVM_CAP_XSAVE ); +#endif + +#ifdef KVM_CAP_XCRS + has_xcrs =kvm_check_extension (s,KVM_CAP_XCRS ); +#endif + +#ifdef KVM_CAP_PIT_STATE2 + has_pit_state2 =kvm_check_extension (s,KVM_CAP_PIT_STATE2 ); +#endif + ret =kvm_get_supported_msrs (s);if (ret <0 ) {return ret;
@@ -1116,7 +1137,7 @@ static int kvm_put_xsave(X86CPU *cpu)uint8_t *xmm, *ymmh, *zmmh;int i, r; -if (!kvm_has_xsave ()) { +if (!has_xsave) {return kvm_put_fpu (cpu); }
@@ -1170,7 +1191,7 @@ static int kvm_put_xcrs(X86CPU *cpu)CPUX86State *env = &cpu->env;struct kvm_xcrs xcrs = {}; -if (!kvm_has_xcrs ()) { +if (!has_xcrs) {return 0 ; }
@@ -1495,7 +1516,7 @@ static int kvm_get_xsave(X86CPU *cpu)const uint8_t *xmm, *ymmh, *zmmh;uint16_t cwd, swd, twd; -if (!kvm_has_xsave ()) { +if (!has_xsave) {return kvm_get_fpu (cpu); }
@@ -1554,7 +1575,7 @@ static int kvm_get_xcrs(X86CPU *cpu)int i, ret;struct kvm_xcrs xcrs; -if (!kvm_has_xcrs ()) { +if (!has_xcrs) {return 0 ; }
Signature · 1 line
1.8.3.1
Paolo Bonzini
AppliedQuoted 171 lines · Thomas Huth
The functions for checking xcrs, xsave and
pit_state2are only used on x86, so they should reside intarget-i386/kvm.c.Signed-off-by Thomas Huth <[email protected]>--- include/sysemu/kvm.h | 2 -- kvm-all.c | 29 ----------------------------- kvm-stub.c | 5 ----- target-i386/kvm.c | 31 ++++++++++++++++++++++++++----- 4 files changed, 26 insertions(+), 41 deletions(-)include/sysemu/kvm.h +0
-2@@ -182,8 +182,6 @@ int kvm_has_sync_mmu(void);int kvm_has_vcpu_events (void );int kvm_has_robust_singlestep (void );int kvm_has_debugregs (void ); -int kvm_has_xsave (void ); -int kvm_has_xcrs (void );int kvm_has_pit_state2 (void );int kvm_has_many_ioeventfds (void );int kvm_has_gsi_routing (void );kvm-all.c +0
-29@@ -77,8 +77,6 @@ struct KVMState#ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint_head kvm_sw_breakpoints;#endif -int pit_state2; -int xsave, xcrs;int many_ioeventfds;int intx_set_mask;/* The man page (and posix) say ioctl numbers are signed int, but @@ -1585,18 +1583,6 @@ static int kvm_init(MachineState *ms) s->debugregs =kvm_check_extension (s,KVM_CAP_DEBUGREGS );#endif -#ifdef KVM_CAP_XSAVE - s->xsave =kvm_check_extension (s,KVM_CAP_XSAVE ); -#endif - -#ifdef KVM_CAP_XCRS - s->xcrs =kvm_check_extension (s,KVM_CAP_XCRS ); -#endif - -#ifdef KVM_CAP_PIT_STATE2 - s->pit_state2 =kvm_check_extension (s,KVM_CAP_PIT_STATE2 ); -#endif -#ifdef KVM_CAP_IRQ_ROUTING s->direct_msi = (kvm_check_extension (s,KVM_CAP_SIGNAL_MSI ) >0 );#endif @@ -2062,21 +2048,6 @@ int kvm_has_debugregs(void)return kvm_state->debugregs; } -int kvm_has_xsave (void ) -{ -return kvm_state->xsave; -} - -int kvm_has_xcrs (void ) -{ -return kvm_state->xcrs; -} - -int kvm_has_pit_state2 (void ) -{ -return kvm_state->pit_state2; -} -int kvm_has_many_ioeventfds (void ) {if (!kvm_enabled ()) {kvm-stub.c +0
-5@@ -67,11 +67,6 @@ int kvm_has_many_ioeventfds(void)return 0 ; } -int kvm_has_pit_state2 (void ) -{ -return 0 ; -} -void kvm_setup_guest_memory (void *start,size_t size) { }target-i386/kvm.c +25
-4@@ -88,6 +88,15 @@ static bool has_msr_xss;static bool has_msr_architectural_pmu;static uint32_t num_architectural_pmu_counters; +static int has_xsave; +static int has_xcrs; +static int has_pit_state2; + +int kvm_has_pit_state2 (void ) +{ +return has_pit_state2; +} +bool kvm_has_smm (void ) {return kvm_check_extension (kvm_state,KVM_CAP_X86_SMM );@@ -752,7 +761,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } } -if (kvm_has_xsave ()) { +if (has_xsave) { env->kvm_xsave_buf =qemu_memalign (4096 ,sizeof (struct kvm_xsave )); }@@ -908,6 +917,18 @@ int kvm_arch_init(MachineState *ms, KVMState *s)int ret;struct utsname utsname; +#ifdef KVM_CAP_XSAVE + has_xsave =kvm_check_extension (s,KVM_CAP_XSAVE ); +#endif + +#ifdef KVM_CAP_XCRS + has_xcrs =kvm_check_extension (s,KVM_CAP_XCRS ); +#endif + +#ifdef KVM_CAP_PIT_STATE2 + has_pit_state2 =kvm_check_extension (s,KVM_CAP_PIT_STATE2 ); +#endif + ret =kvm_get_supported_msrs (s);if (ret <0 ) {return ret;@@ -1116,7 +1137,7 @@ static int kvm_put_xsave(X86CPU *cpu)uint8_t *xmm, *ymmh, *zmmh;int i, r; -if (!kvm_has_xsave ()) { +if (!has_xsave) {return kvm_put_fpu (cpu); }@@ -1170,7 +1191,7 @@ static int kvm_put_xcrs(X86CPU *cpu)CPUX86State *env = &cpu->env;struct kvm_xcrs xcrs = {}; -if (!kvm_has_xcrs ()) { +if (!has_xcrs) {return 0 ; }@@ -1495,7 +1516,7 @@ static int kvm_get_xsave(X86CPU *cpu)const uint8_t *xmm, *ymmh, *zmmh;uint16_t cwd, swd, twd; -if (!kvm_has_xsave ()) { +if (!has_xsave) {return kvm_get_fpu (cpu); }
target-i386/kvm.c static int kvm_get_xcrs(X86CPU *cpu) · line 1581
Quoted 8 lines
target-i386/kvm.c +1
-1@@ -1554,7 +1575,7 @@ static int kvm_get_xcrs(X86CPU *cpu)int i, ret;struct kvm_xcrs xcrs; -if (!kvm_has_xcrs ()) { +if (!has_xcrs) {return 0 ; }
Applied, thanks.
Paolo