kvm: Combine all kvm stubs in a single file and compile it only once
PATCH 1/1 kvm: Combine all kvm stubs in a single file and compile it only once
The KVM stub variables and functions don't depend on target specific data types, so it is possible to compile kvm-stub.c only once.
Integrating the target specific KVM stubs for ARM, I386 and PPC in the common kvm-stub.c further simplifies the build environment and allows removing CONFIG_NO_KVM.
Instead of 53 kvm-stub.o files, there is now only one file.
abort() is replaced by g_assert_not_reached() which gives better diagnostic messages when it is called.
---
The resulting binary is slightly larger than before because it includes more stub functions. It could be made smaller by adding separate stubs/kvm-stub-arm.c, stubs/kvm-stub-i386.c and stubs/kvm-stub-ppc.c files. Using alias symbols for the stub functions would reduce the size further, but I don't think the size is critical here.
Should we call g_assert_not_reached() in more (all?) stub functions?
If the patch is accepted, a similar modification could be done for xen-stub.c.
Stefan
Makefile.target | 1 - stubs/Makefile.objs | 1 + kvm-stub.c => stubs/kvm-stub.c | 70 ++++++++++++++++++++++++++++++++++++---- target-arm/Makefile.objs | 1 - target-arm/kvm-stub.c | 23 ------------- target-i386/Makefile.objs | 1 - target-i386/kvm-stub.c | 18 ----------- target-ppc/Makefile.objs | 1 - target-ppc/kvm-stub.c | 18 ----------- 9 files changed, 64 insertions(+), 70 deletions(-) rename kvm-stub.c => stubs/kvm-stub.c (63%) delete mode 100644 target-arm/kvm-stub.c delete mode 100644 target-i386/kvm-stub.c delete mode 100644 target-ppc/kvm-stub.c
Makefile.target +0 -1
@@ -84,7 +84,6 @@ obj-y += fpu/softfloat.o obj-y += target-$(TARGET_BASE_ARCH)/ obj-y += disas.o obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o -obj-$(CONFIG_NO_KVM) += kvm-stub.o ######################################################### # Linux user emulator target
stubs/Makefile.objs +1 -0
@@ -10,6 +10,7 @@ stub-obj-y += fdset-remove-fd.o stub-obj-y += get-fd.o stub-obj-y += get-vm-name.o stub-obj-y += iothread-lock.o +stub-obj-y += kvm-stub.o stub-obj-y += migr-blocker.o stub-obj-y += mon-is-qmp.o stub-obj-y += mon-printf.o
stubs/kvm-stub.c renamed from kvm-stub.c +63 -7
101 lines not on this page · raw message
target-arm/Makefile.objs +0 -1
@@ -1,6 +1,5 @@ obj-y += arm-semi.o obj-$(CONFIG_SOFTMMU) += machine.o obj-$(CONFIG_KVM) += kvm.o -obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-y += translate.o op_helper.o helper.o cpu.o obj-y += neon_helper.o iwmmxt_helper.o
target-arm/kvm-stub.c deleted +0 -23
@@ -1,23 +0,0 @@ -/* -* QEMU KVM ARM specific function stubs -* -* Copyright Linaro Limited 2013 -* -* Author: Peter Maydell <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ -#include "qemu-common.h" -#include "kvm_arm.h" - -bool write_kvmstate_to_list (ARMCPU *cpu) -{ -abort (); -} - -bool write_list_to_kvmstate (ARMCPU *cpu) -{ -abort (); -}
target-i386/Makefile.objs +0 -1
@@ -3,6 +3,5 @@ obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o obj-$(CONFIG_KVM) += kvm.o hyperv.o -obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-$(CONFIG_LINUX_USER) += ioport-user.o obj-$(CONFIG_BSD_USER) += ioport-user.o
target-i386/kvm-stub.c deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* QEMU KVM x86 specific function stubs -* -* Copyright Linaro Limited 2012 -* -* Author: Peter Maydell <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ -#include "qemu-common.h" -#include "kvm_i386.h" - -bool kvm_allows_irq0_override (void ) -{ -return 1 ; -}
target-ppc/Makefile.objs +0 -1
@@ -5,7 +5,6 @@ obj-y += machine.o mmu_helper.o mmu-hash32.o obj-$(TARGET_PPC64) += mmu-hash64.o endif obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o -obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-y += excp_helper.o obj-y += fpu_helper.o obj-y += int_helper.o
target-ppc/kvm-stub.c deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* QEMU KVM PPC specific function stubs -* -* Copyright Freescale Inc. 2013 -* -* Author: Alexander Graf <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ -#include "qemu-common.h" -#include "hw/ppc/openpic.h" - -int kvm_openpic_connect_vcpu (DeviceState *d,CPUState *cs) -{ -return -EINVAL ; -}
Signature · 1 line
1.7.10.4
Hi Stefan,
Am 21.07.2013 12:57, schrieb Stefan Weil:
Quoted 22 lines
The KVM stub variables and functions don't depend on target specific data types, so it is possible to compile
kvm-stub.conly once.Integrating the target specific KVM stubs for ARM, I386 and PPC in the common
kvm-stub.cfurther simplifies the build environment and allows removingCONFIG_NO_KVM.Instead of 53 kvm-stub.o files, there is now only one file.
abort()is replaced byg_assert_not_reached()which gives better diagnostic messages when it is called.Signed-off-by Stefan Weil <[email protected]>---
The resulting binary is slightly larger than before because it includes more stub functions. It could be made smaller by adding separate
stubs/kvm-stub-arm.c,stubs/kvm-stub-i386.candstubs/kvm-stub-ppc.cfiles. Using alias symbols for the stub functions would reduce the size further, but I don't think the size is critical here.
Quoted 4 lines
Should we call
g_assert_not_reached()in more (all?) stub functions?If the patch is accepted, a similar modification could be done for
xen-stub.c.
I had thought about turning kvm-stub.c into stubs/kvm.c but rejected that idea at the time due to CPU dependencies beyond CPUState. Also I was wondering whether all stubs are actually from kvm-all.c (fine then) or whether we would be opening a door for silently forgetting to implement some functions in a new KVM target such as MIPS.
In the current form I think it's a gross hack wrt target_ulong and HW_POISON_H. ;)
And yes, I would prefer to keep target stubs in separate files.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 21.07.2013 13:20, schrieb Andreas Färber:
Quoted 35 lines
Hi Stefan,
Am 21.07.2013 12:57, schrieb Stefan Weil:
Quoted 22 lines
The KVM stub variables and functions don't depend on target specific data types, so it is possible to compile
kvm-stub.conly once.Integrating the target specific KVM stubs for ARM, I386 and PPC in the common
kvm-stub.cfurther simplifies the build environment and allows removingCONFIG_NO_KVM.Instead of 53 kvm-stub.o files, there is now only one file.
abort()is replaced byg_assert_not_reached()which gives better diagnostic messages when it is called.Signed-off-by Stefan Weil <[email protected]>---
The resulting binary is slightly larger than before because it includes more stub functions. It could be made smaller by adding separate
stubs/kvm-stub-arm.c,stubs/kvm-stub-i386.candstubs/kvm-stub-ppc.cfiles. Using alias symbols for the stub functions would reduce the size further, but I don't think the size is critical here.Quoted 4 lines
Should we call
g_assert_not_reached()in more (all?) stub functions?If the patch is accepted, a similar modification could be done for
xen-stub.c.I had thought about turning
kvm-stub.cintostubs/kvm.cbut rejected that idea at the time due to CPU dependencies beyond CPUState. Also I was wondering whether all stubs are actually fromkvm-all.c(fine then) or whether we would be opening a door for silently forgetting to implement some functions in a new KVM target such as MIPS.
Quoted 7 lines
In the current form I think it's a gross hack wrt
target_ulongandHW_POISON_H. ;)And yes, I would prefer to keep target stubs in separate files.
Regards,
Andreas
The hack could be removed if the include files were cleaned. Do we still have to poison "env", for example? It is no longer a global variable. The handling of cpu.h is also a mess.
The hack for target_ulong could also be avoided by using modified kvm_insert_breakpoint, kvm_remove_breakpoint.
Fixing the existing include files was beyond the scope of my patch.
Mixing kvm-all.o and kvm-stub.o would be detected by the linker, so missing KVM interfaces for new KVM targets is not possible.
Regards,
Stefan