Xen: introduce Xen PV target
cover Xen: introduce Xen PV target
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
The first 3 patches refactor some code to disentangle Xen PV and HVM guest. The 4th patch has the real meat. It introduces Xen PV target, which contains basically a dummy CPU, then hooks up this Xen PV CPU to QEMU internal structures.
The last patch introduces xenpv-softmmu, which contains *no* emulation code. I know that in previous discussion people said that every device emulation should be included if the target architecture is called null. But since this target CPU is now called xenpv I don't feel obliged to include any device emulation in this prototype anymore. :-)
Please note that the existing Xen QEMU build is not affected at all. You can still use "--disable-tcg --enable-xen --target-list=i386-softmmu" (or x86_64-softmmu") to build qemu-system-{i386,x86_64} and use it for both HVM and PV guest. This series adds another option to build QEMU with "--disable-tcg --enable-xen --target-list=xenpv-softmmu" and get a QEMU binary tailored for Xen PV guest. The effect is that we reduce the binary size from 14MB to 7.3MB.
What do you think of this idea? I'm all ears.
Wei.
Wei Liu (5):
xen: move Xen PV machine files to hw/xenpv
xen: factor out common functions
exec: guard Xen HVM hooks with CONFIG_XEN_I386
xen: implement Xen PV target
xen: introduce xenpv-softmmu.mak
Makefile.target | 3 +-
arch_init.c | 2 +
configure | 12 ++-
cpu-exec.c | 2 +
default-configs/i386-softmmu.mak | 1 -
default-configs/x86_64-softmmu.mak | 1 -
default-configs/xenpv-softmmu.mak | 2 +
exec.c | 16 ++++
hw/i386/Makefile.objs | 2 +-
hw/xenpv/Makefile.objs | 2 +
hw/{i386 => xenpv}/xen_domainbuild.c | 0
hw/{i386 => xenpv}/xen_domainbuild.h | 0
hw/{i386 => xenpv}/xen_machine_pv.c | 0
include/exec/memory-internal.h | 2 +
include/sysemu/arch_init.h | 1 +
target-xenpv/Makefile.objs | 1 +
target-xenpv/cpu-qom.h | 64 ++++++++++++++++
target-xenpv/cpu.h | 66 ++++++++++++++++
target-xenpv/helper.c | 32 ++++++++
target-xenpv/translate.c | 27 +++++++
xen-common.c | 137 ++++++++++++++++++++++++++++++++++
xen-all.c => xen-hvm.c | 112 +--------------------------
xen-stub.c | 4 -
23 files changed, 368 insertions(+), 121 deletions(-)
create mode 100644 default-configs/xenpv-softmmu.mak
create mode 100644 hw/xenpv/Makefile.objs
rename hw/{i386 => xenpv}/xen_domainbuild.c (100%)
rename hw/{i386 => xenpv}/xen_domainbuild.h (100%)
rename hw/{i386 => xenpv}/xen_machine_pv.c (100%)
create mode 100644 target-xenpv/Makefile.objs
create mode 100644 target-xenpv/cpu-qom.h
create mode 100644 target-xenpv/cpu.h
create mode 100644 target-xenpv/helper.c
create mode 100644 target-xenpv/helper.h
create mode 100644 target-xenpv/translate.c
create mode 100644 xen-common.c
rename xen-all.c => xen-hvm.c (92%)Signature · 1 line
1.7.10.4
RFC PATCH 1/5 xen: move Xen PV machine files to hw/xenpv
---
hw/i386/Makefile.objs | 2 +-
hw/xenpv/Makefile.objs | 2 ++
hw/{i386 => xenpv}/xen_domainbuild.c | 0
hw/{i386 => xenpv}/xen_domainbuild.h | 0
hw/{i386 => xenpv}/xen_machine_pv.c | 0
5 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 hw/xenpv/Makefile.objs
rename hw/{i386 => xenpv}/xen_domainbuild.c (100%)
rename hw/{i386 => xenpv}/xen_domainbuild.h (100%)
rename hw/{i386 => xenpv}/xen_machine_pv.c (100%)hw/i386/Makefile.objs +1 -1
@@ -2,7 +2,7 @@ obj-$(CONFIG_KVM) += kvm/ obj-y += multiboot.o smbios.o obj-y += pc.o pc_piix.o pc_q35.o obj-y += pc_sysfw.o -obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o +obj-$(CONFIG_XEN) += ../xenpv/ obj-y += kvmvapic.o obj-y += acpi-build.o
hw/xenpv/Makefile.objs new file +2 -0
@@ -0,0 +1,2 @@ +# Xen PV machine support +obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
hw/xenpv/xen_domainbuild.c renamed from hw/i386/xen_domainbuild.c +0 -0
hw/xenpv/xen_domainbuild.h renamed from hw/i386/xen_domainbuild.h +0 -0
hw/xenpv/xen_machine_pv.c renamed from hw/i386/xen_machine_pv.c +0 -0
Signature · 1 line
1.7.10.4
RFC PATCH 1/5 xen: move Xen PV machine files to hw/xenpv
In reply to Wei Liu---
hw/i386/Makefile.objs | 2 +-
hw/xenpv/Makefile.objs | 2 ++
hw/{i386 => xenpv}/xen_domainbuild.c | 0
hw/{i386 => xenpv}/xen_domainbuild.h | 0
hw/{i386 => xenpv}/xen_machine_pv.c | 0
5 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 hw/xenpv/Makefile.objs
rename hw/{i386 => xenpv}/xen_domainbuild.c (100%)
rename hw/{i386 => xenpv}/xen_domainbuild.h (100%)
rename hw/{i386 => xenpv}/xen_machine_pv.c (100%)hw/i386/Makefile.objs +1 -1
@@ -2,7 +2,7 @@ obj-$(CONFIG_KVM) += kvm/ obj-y += multiboot.o smbios.o obj-y += pc.o pc_piix.o pc_q35.o obj-y += pc_sysfw.o -obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o +obj-$(CONFIG_XEN) += ../xenpv/ obj-y += kvmvapic.o obj-y += acpi-build.o
hw/xenpv/Makefile.objs new file +2 -0
@@ -0,0 +1,2 @@ +# Xen PV machine support +obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
hw/xenpv/xen_domainbuild.c renamed from hw/i386/xen_domainbuild.c +0 -0
hw/xenpv/xen_domainbuild.h renamed from hw/i386/xen_domainbuild.h +0 -0
hw/xenpv/xen_machine_pv.c renamed from hw/i386/xen_machine_pv.c +0 -0
Signature · 1 line
1.7.10.4
RFC PATCH 2/5 xen: factor out common functions
In reply to Wei LiuSo common functions used by both HVM and PV are factored out from xen-all.c to xen-common.c.
Also extract a QMP function from xen-all.c and xen-stub.c to xen-common.c
Finally rename xen-all.c to xen-hvm.c, as those functions are only useful to HVM guest.
--- Makefile.target | 3 +- xen-common.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ xen-all.c => xen-hvm.c | 112 +-------------------------------------- xen-stub.c | 4 -- 4 files changed, 141 insertions(+), 115 deletions(-) create mode 100644 xen-common.c rename xen-all.c => xen-hvm.c (92%)
Makefile.target +2 -1
@@ -123,7 +123,8 @@ obj-y += dump.o LIBS+=$(libs_softmmu) # xen support -obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o +obj-$(CONFIG_XEN) += xen-common.o +obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o obj-$(call lnot,$(CONFIG_XEN)) += xen-stub.o # Hardware support
xen-common.c new file +137 -0
137 lines not on this page · raw message
xen-hvm.c renamed from xen-all.c +2 -110
143 lines not on this page · raw message
xen-stub.c +0 -4
@@ -56,10 +56,6 @@ void xen_register_framebuffer(MemoryRegion *mr) { } -void qmp_xen_set_global_dirty_log (bool enable,Error **errp) -{ -} -void xen_modified_memory (ram_addr_t start,ram_addr_t length) { }
Signature · 1 line
1.7.10.4
RFC PATCH 2/5 xen: factor out common functions
In reply to Wei LiuSo common functions used by both HVM and PV are factored out from xen-all.c to xen-common.c.
Also extract a QMP function from xen-all.c and xen-stub.c to xen-common.c
Finally rename xen-all.c to xen-hvm.c, as those functions are only useful to HVM guest.
--- Makefile.target | 3 +- xen-common.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ xen-all.c => xen-hvm.c | 112 +-------------------------------------- xen-stub.c | 4 -- 4 files changed, 141 insertions(+), 115 deletions(-) create mode 100644 xen-common.c rename xen-all.c => xen-hvm.c (92%)
Makefile.target +2 -1
@@ -123,7 +123,8 @@ obj-y += dump.o LIBS+=$(libs_softmmu) # xen support -obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o +obj-$(CONFIG_XEN) += xen-common.o +obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o obj-$(call lnot,$(CONFIG_XEN)) += xen-stub.o # Hardware support
xen-common.c new file +137 -0
137 lines not on this page · raw message
xen-hvm.c renamed from xen-all.c +2 -110
143 lines not on this page · raw message
xen-stub.c +0 -4
@@ -56,10 +56,6 @@ void xen_register_framebuffer(MemoryRegion *mr) { } -void qmp_xen_set_global_dirty_log (bool enable,Error **errp) -{ -} -void xen_modified_memory (ram_addr_t start,ram_addr_t length) { }
Signature · 1 line
1.7.10.4
RFC PATCH 3/5 exec: guard Xen HVM hooks with CONFIG_XEN_I386
In reply to Wei LiuThose are only useful when building QEMU with HVM support.
We need to expose CONFIG_XEN_I386 to source code so we modify configure and i386/x86_64-softmmu.mak.
--- configure | 1 + default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - exec.c | 16 ++++++++++++++++ include/exec/memory-internal.h | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-)
configure +1 -0
@@ -4472,6 +4472,7 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak if supported_xen_target; then echo "CONFIG_XEN=y" >> $config_target_mak + echo "CONFIG_XEN_I386=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" fi
default-configs/i386-softmmu.mak +0 -1
@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=y
default-configs/x86_64-softmmu.mak +0 -1
@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=y
exec.c +16 -0
@@ -1228,7 +1228,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,fprintf (stderr,"-mem-path not supported with Xen\n" );exit (1 ); } +#ifdef CONFIG_XEN_I386 xen_ram_alloc (new_block->offset, size, mr); +#endif }else {if (mem_path) {if (phys_mem_alloc != qemu_anon_ram_alloc) {
@@ -1324,7 +1326,9 @@ void qemu_ram_free(ram_addr_t addr)if (block->flags &RAM_PREALLOC_MASK ) { ; }else if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (block->host); +#endif #ifndef _WIN32 }else if (block->fd >=0 ) {munmap (block->host, block->length);
@@ -1409,6 +1413,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)RAMBlock *block =qemu_get_ram_block (addr);if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 /* We need to check if the requested address is in the RAM * because we don't want to map the entire memory in QEMU. * In that case just map until the end of the page.
@@ -1419,6 +1424,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr) block->host = xen_map_cache(block->offset, block->length, 1); } +#endif }return block->host + (addr - block->offset); }
@@ -1431,7 +1437,11 @@ static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size)return NULL ; }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 return xen_map_cache (addr, *size,1 ); +#else +return NULL ; +#endif }else {RAMBlock *block;
@@ -1456,8 +1466,10 @@ MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)uint8_t *host = ptr;if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 *ram_addr =xen_ram_addr_from_mapcache (ptr);return qemu_get_ram_block (*ram_addr)->mr; +#endif } block = ram_list.mru_block;
@@ -1921,7 +1933,9 @@ static void invalidate_and_set_dirty(hwaddr addr,/* set dirty bit */ cpu_physical_memory_set_dirty_flags (addr, (0xff & ~CODE_DIRTY_FLAG )); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif }static inline bool memory_access_is_direct (MemoryRegion *mr,bool is_write)
@@ -2298,7 +2312,9 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, } }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (buffer); +#endif }memory_region_unref (mr);return ;
include/exec/memory-internal.h +2 -0
@@ -100,7 +100,9 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,for (addr = start; addr < end; addr +=TARGET_PAGE_SIZE ) {cpu_physical_memory_set_dirty_flags (addr, dirty_flags); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif } static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
Signature · 1 line
1.7.10.4
RFC PATCH 3/5 exec: guard Xen HVM hooks with CONFIG_XEN_I386
In reply to Wei LiuThose are only useful when building QEMU with HVM support.
We need to expose CONFIG_XEN_I386 to source code so we modify configure and i386/x86_64-softmmu.mak.
--- configure | 1 + default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - exec.c | 16 ++++++++++++++++ include/exec/memory-internal.h | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-)
configure +1 -0
@@ -4472,6 +4472,7 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak if supported_xen_target; then echo "CONFIG_XEN=y" >> $config_target_mak + echo "CONFIG_XEN_I386=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" fi
default-configs/i386-softmmu.mak +0 -1
@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=y
default-configs/x86_64-softmmu.mak +0 -1
@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=y
exec.c +16 -0
@@ -1228,7 +1228,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,fprintf (stderr,"-mem-path not supported with Xen\n" );exit (1 ); } +#ifdef CONFIG_XEN_I386 xen_ram_alloc (new_block->offset, size, mr); +#endif }else {if (mem_path) {if (phys_mem_alloc != qemu_anon_ram_alloc) {
@@ -1324,7 +1326,9 @@ void qemu_ram_free(ram_addr_t addr)if (block->flags &RAM_PREALLOC_MASK ) { ; }else if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (block->host); +#endif #ifndef _WIN32 }else if (block->fd >=0 ) {munmap (block->host, block->length);
@@ -1409,6 +1413,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)RAMBlock *block =qemu_get_ram_block (addr);if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 /* We need to check if the requested address is in the RAM * because we don't want to map the entire memory in QEMU. * In that case just map until the end of the page.
@@ -1419,6 +1424,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr) block->host = xen_map_cache(block->offset, block->length, 1); } +#endif }return block->host + (addr - block->offset); }
@@ -1431,7 +1437,11 @@ static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size)return NULL ; }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 return xen_map_cache (addr, *size,1 ); +#else +return NULL ; +#endif }else {RAMBlock *block;
@@ -1456,8 +1466,10 @@ MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)uint8_t *host = ptr;if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 *ram_addr =xen_ram_addr_from_mapcache (ptr);return qemu_get_ram_block (*ram_addr)->mr; +#endif } block = ram_list.mru_block;
@@ -1921,7 +1933,9 @@ static void invalidate_and_set_dirty(hwaddr addr,/* set dirty bit */ cpu_physical_memory_set_dirty_flags (addr, (0xff & ~CODE_DIRTY_FLAG )); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif }static inline bool memory_access_is_direct (MemoryRegion *mr,bool is_write)
@@ -2298,7 +2312,9 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, } }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (buffer); +#endif }memory_region_unref (mr);return ;
include/exec/memory-internal.h +2 -0
@@ -100,7 +100,9 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,for (addr = start; addr < end; addr +=TARGET_PAGE_SIZE ) {cpu_physical_memory_set_dirty_flags (addr, dirty_flags); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif } static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
Signature · 1 line
1.7.10.4
Re: [PATCH RFC 3/5] exec: guard Xen HVM hooks with CONFIG_XEN_I386
Il 23/01/2014 23:16, Wei Liu ha scritto:
Quoted 4 lines
Those are only useful when building QEMU with HVM support.
We need to expose
CONFIG_XEN_I386to source code so we modify configure and i386/x86_64-softmmu.mak.
I think the right way is to add a xen-hvm-stub.c file and include it in xenpv-softmmu.
Since you are at it, xen_platform.o xen_apic.o xen_pvdevice.o can be moved to hw/i386/xen and you can drop CONFIG_XEN_I386 completely.
Paolo
Quoted 143 lines
Signed-off-by Wei Liu <[email protected]>--- configure | 1 + default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - exec.c | 16 ++++++++++++++++ include/exec/memory-internal.h | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-)configure +1
-0@@ -4472,6 +4472,7 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak if supported_xen_target; then echo "CONFIG_XEN=y" >> $config_target_mak + echo "CONFIG_XEN_I386=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" fidefault-configs/i386-softmmu.mak +0
-1@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=ydefault-configs/x86_64-softmmu.mak +0
-1@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=yexec.c +16
-0@@ -1228,7 +1228,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,fprintf (stderr,"-mem-path not supported with Xen\n" );exit (1 ); } +#ifdef CONFIG_XEN_I386 xen_ram_alloc (new_block->offset, size, mr); +#endif }else {if (mem_path) {if (phys_mem_alloc != qemu_anon_ram_alloc) {@@ -1324,7 +1326,9 @@ void qemu_ram_free(ram_addr_t addr)if (block->flags &RAM_PREALLOC_MASK ) { ; }else if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (block->host); +#endif #ifndef _WIN32 }else if (block->fd >=0 ) {munmap (block->host, block->length);@@ -1409,6 +1413,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)RAMBlock *block =qemu_get_ram_block (addr);if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 /* We need to check if the requested address is in the RAM * because we don't want to map the entire memory in QEMU. * In that case just map until the end of the page. @@ -1419,6 +1424,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr) block->host = xen_map_cache(block->offset, block->length, 1); } +#endif }return block->host + (addr - block->offset); }@@ -1431,7 +1437,11 @@ static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size)return NULL ; }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 return xen_map_cache (addr, *size,1 ); +#else +return NULL ; +#endif }else {RAMBlock *block;@@ -1456,8 +1466,10 @@ MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)uint8_t *host = ptr;if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 *ram_addr =xen_ram_addr_from_mapcache (ptr);return qemu_get_ram_block (*ram_addr)->mr; +#endif } block = ram_list.mru_block;@@ -1921,7 +1933,9 @@ static void invalidate_and_set_dirty(hwaddr addr,/* set dirty bit */ cpu_physical_memory_set_dirty_flags (addr, (0xff & ~CODE_DIRTY_FLAG )); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif }static inline bool memory_access_is_direct (MemoryRegion *mr,bool is_write)@@ -2298,7 +2312,9 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, } }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (buffer); +#endif }memory_region_unref (mr);return ;include/exec/memory-internal.h +2
-0@@ -100,7 +100,9 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,for (addr = start; addr < end; addr +=TARGET_PAGE_SIZE ) {cpu_physical_memory_set_dirty_flags (addr, dirty_flags); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif } static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
Re: [Qemu-devel] [PATCH RFC 3/5] exec: guard Xen HVM hooks with CONFIG_XEN_I386
In reply to Wei LiuIl 23/01/2014 23:16, Wei Liu ha scritto:
Quoted 4 lines
Those are only useful when building QEMU with HVM support.
We need to expose
CONFIG_XEN_I386to source code so we modify configure and i386/x86_64-softmmu.mak.
I think the right way is to add a xen-hvm-stub.c file and include it in xenpv-softmmu.
Since you are at it, xen_platform.o xen_apic.o xen_pvdevice.o can be moved to hw/i386/xen and you can drop CONFIG_XEN_I386 completely.
Paolo
Quoted 143 lines
Signed-off-by Wei Liu <[email protected]>--- configure | 1 + default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - exec.c | 16 ++++++++++++++++ include/exec/memory-internal.h | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-)configure +1
-0@@ -4472,6 +4472,7 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak if supported_xen_target; then echo "CONFIG_XEN=y" >> $config_target_mak + echo "CONFIG_XEN_I386=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" fidefault-configs/i386-softmmu.mak +0
-1@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=ydefault-configs/x86_64-softmmu.mak +0
-1@@ -33,7 +33,6 @@ CONFIG_MC146818RTC=y CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y -CONFIG_XEN_I386=$(CONFIG_XEN) CONFIG_ISA_DEBUG=y CONFIG_ISA_TESTDEV=y CONFIG_VMPORT=yexec.c +16
-0@@ -1228,7 +1228,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,fprintf (stderr,"-mem-path not supported with Xen\n" );exit (1 ); } +#ifdef CONFIG_XEN_I386 xen_ram_alloc (new_block->offset, size, mr); +#endif }else {if (mem_path) {if (phys_mem_alloc != qemu_anon_ram_alloc) {@@ -1324,7 +1326,9 @@ void qemu_ram_free(ram_addr_t addr)if (block->flags &RAM_PREALLOC_MASK ) { ; }else if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (block->host); +#endif #ifndef _WIN32 }else if (block->fd >=0 ) {munmap (block->host, block->length);@@ -1409,6 +1413,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)RAMBlock *block =qemu_get_ram_block (addr);if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 /* We need to check if the requested address is in the RAM * because we don't want to map the entire memory in QEMU. * In that case just map until the end of the page. @@ -1419,6 +1424,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr) block->host = xen_map_cache(block->offset, block->length, 1); } +#endif }return block->host + (addr - block->offset); }@@ -1431,7 +1437,11 @@ static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size)return NULL ; }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 return xen_map_cache (addr, *size,1 ); +#else +return NULL ; +#endif }else {RAMBlock *block;@@ -1456,8 +1466,10 @@ MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)uint8_t *host = ptr;if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 *ram_addr =xen_ram_addr_from_mapcache (ptr);return qemu_get_ram_block (*ram_addr)->mr; +#endif } block = ram_list.mru_block;@@ -1921,7 +1933,9 @@ static void invalidate_and_set_dirty(hwaddr addr,/* set dirty bit */ cpu_physical_memory_set_dirty_flags (addr, (0xff & ~CODE_DIRTY_FLAG )); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif }static inline bool memory_access_is_direct (MemoryRegion *mr,bool is_write)@@ -2298,7 +2312,9 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, } }if (xen_enabled ()) { +#ifdef CONFIG_XEN_I386 xen_invalidate_map_cache_entry (buffer); +#endif }memory_region_unref (mr);return ;include/exec/memory-internal.h +2
-0@@ -100,7 +100,9 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,for (addr = start; addr < end; addr +=TARGET_PAGE_SIZE ) {cpu_physical_memory_set_dirty_flags (addr, dirty_flags); } +#ifdef CONFIG_XEN_I386 xen_modified_memory (addr, length); +#endif } static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
RFC PATCH 4/5 xen: implement Xen PV target
In reply to Wei LiuBasically it's a dummy CPU that doens't do anything. This patch contains necessary hooks to make QEMU compile.
--- arch_init.c | 2 ++ cpu-exec.c | 2 ++ include/sysemu/arch_init.h | 1 + target-xenpv/Makefile.objs | 1 + target-xenpv/cpu-qom.h | 64 ++++++++++++++++++++++++++++++++++++++++++ target-xenpv/cpu.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ target-xenpv/helper.c | 32 +++++++++++++++++++++ target-xenpv/translate.c | 27 ++++++++++++++++++ 8 files changed, 195 insertions(+) create mode 100644 target-xenpv/Makefile.objs create mode 100644 target-xenpv/cpu-qom.h create mode 100644 target-xenpv/cpu.h create mode 100644 target-xenpv/helper.c create mode 100644 target-xenpv/helper.h create mode 100644 target-xenpv/translate.c
arch_init.c +2 -0
@@ -101,6 +101,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_XTENSA#elif defined(TARGET_UNICORE32 )#define QEMU_ARCH QEMU_ARCH_UNICORE32 +#elif defined(TARGET_XENPV ) +#define QEMU_ARCH QEMU_ARCH_XENPV#endif const uint32_t arch_type =QEMU_ARCH ;
cpu-exec.c +2 -0
@@ -255,6 +255,7 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_CRIS )#elif defined(TARGET_S390X )#elif defined(TARGET_XTENSA ) +#elif defined(TARGET_XENPV )/* XXXXX */ #else #error unsupported target CPU
@@ -710,6 +711,7 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_CRIS )#elif defined(TARGET_S390X )#elif defined(TARGET_XTENSA ) +#elif defined(TARGET_XENPV )/* XXXXX */ #else #error unsupported target CPU
include/sysemu/arch_init.h +1 -0
@@ -22,6 +22,7 @@ enum {QEMU_ARCH_OPENRISC =8192 ,QEMU_ARCH_UNICORE32 =0x4000 ,QEMU_ARCH_MOXIE =0x8000 , + QEMU_ARCH_XENPV = 0x10000, };extern const uint32_t arch_type;
target-xenpv/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_TCG) += helper.o translate.o
target-xenpv/cpu-qom.h new file +64 -0
64 lines not on this page · raw message
target-xenpv/cpu.h new file +66 -0
66 lines not on this page · raw message
target-xenpv/helper.c new file +32 -0
@@ -0,0 +1,32 @@ +#include "cpu.h" +#include "helper.h" +#if !defined(CONFIG_USER_ONLY ) +#include "exec/softmmu_exec.h" +#endif + +#if !defined(CONFIG_USER_ONLY ) + +#define MMUSUFFIX _mmu + +#define SHIFT 0 +#include "exec/softmmu_template.h" + +#define SHIFT 1 +#include "exec/softmmu_template.h" + +#define SHIFT 2 +#include "exec/softmmu_template.h" + +#define SHIFT 3 +#include "exec/softmmu_template.h" + +#endif + +#if !defined(CONFIG_USER_ONLY ) +void tlb_fill (CPUXenPVState *env,target_ulong addr,int is_write, +int mmu_idx,uintptr_t retaddr) +{ +abort (); +} +#endif +
target-xenpv/helper.h new file +0 -0
target-xenpv/translate.c new file +27 -0
@@ -0,0 +1,27 @@ +#include <inttypes.h> +#include "qemu/host-utils.h" +#include "cpu.h" +#include "disas/disas.h" +#include "tcg-op.h" + +#include "helper.h" +#define GEN_HELPER 1 +#include "helper.h" + +void gen_intermediate_code (CPUXenPVState *env,TranslationBlock *tb) +{ +abort (); +} + +void gen_intermediate_code_pc (CPUXenPVState *env,TranslationBlock *tb) +{ +abort (); +} + +void restore_state_to_opc (CPUXenPVState *env,TranslationBlock *tb, +int pc_pos) +{ +abort (); +} + +
Signature · 1 line
1.7.10.4
RFC PATCH 4/5 xen: implement Xen PV target
In reply to Wei LiuBasically it's a dummy CPU that doens't do anything. This patch contains necessary hooks to make QEMU compile.
--- arch_init.c | 2 ++ cpu-exec.c | 2 ++ include/sysemu/arch_init.h | 1 + target-xenpv/Makefile.objs | 1 + target-xenpv/cpu-qom.h | 64 ++++++++++++++++++++++++++++++++++++++++++ target-xenpv/cpu.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ target-xenpv/helper.c | 32 +++++++++++++++++++++ target-xenpv/translate.c | 27 ++++++++++++++++++ 8 files changed, 195 insertions(+) create mode 100644 target-xenpv/Makefile.objs create mode 100644 target-xenpv/cpu-qom.h create mode 100644 target-xenpv/cpu.h create mode 100644 target-xenpv/helper.c create mode 100644 target-xenpv/helper.h create mode 100644 target-xenpv/translate.c
arch_init.c +2 -0
@@ -101,6 +101,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_XTENSA#elif defined(TARGET_UNICORE32 )#define QEMU_ARCH QEMU_ARCH_UNICORE32 +#elif defined(TARGET_XENPV ) +#define QEMU_ARCH QEMU_ARCH_XENPV#endif const uint32_t arch_type =QEMU_ARCH ;
cpu-exec.c +2 -0
@@ -255,6 +255,7 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_CRIS )#elif defined(TARGET_S390X )#elif defined(TARGET_XTENSA ) +#elif defined(TARGET_XENPV )/* XXXXX */ #else #error unsupported target CPU
@@ -710,6 +711,7 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_CRIS )#elif defined(TARGET_S390X )#elif defined(TARGET_XTENSA ) +#elif defined(TARGET_XENPV )/* XXXXX */ #else #error unsupported target CPU
include/sysemu/arch_init.h +1 -0
@@ -22,6 +22,7 @@ enum {QEMU_ARCH_OPENRISC =8192 ,QEMU_ARCH_UNICORE32 =0x4000 ,QEMU_ARCH_MOXIE =0x8000 , + QEMU_ARCH_XENPV = 0x10000, };extern const uint32_t arch_type;
target-xenpv/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_TCG) += helper.o translate.o
target-xenpv/cpu-qom.h new file +64 -0
64 lines not on this page · raw message
target-xenpv/cpu.h new file +66 -0
66 lines not on this page · raw message
target-xenpv/helper.c new file +32 -0
@@ -0,0 +1,32 @@ +#include "cpu.h" +#include "helper.h" +#if !defined(CONFIG_USER_ONLY ) +#include "exec/softmmu_exec.h" +#endif + +#if !defined(CONFIG_USER_ONLY ) + +#define MMUSUFFIX _mmu + +#define SHIFT 0 +#include "exec/softmmu_template.h" + +#define SHIFT 1 +#include "exec/softmmu_template.h" + +#define SHIFT 2 +#include "exec/softmmu_template.h" + +#define SHIFT 3 +#include "exec/softmmu_template.h" + +#endif + +#if !defined(CONFIG_USER_ONLY ) +void tlb_fill (CPUXenPVState *env,target_ulong addr,int is_write, +int mmu_idx,uintptr_t retaddr) +{ +abort (); +} +#endif +
target-xenpv/helper.h new file +0 -0
target-xenpv/translate.c new file +27 -0
@@ -0,0 +1,27 @@ +#include <inttypes.h> +#include "qemu/host-utils.h" +#include "cpu.h" +#include "disas/disas.h" +#include "tcg-op.h" + +#include "helper.h" +#define GEN_HELPER 1 +#include "helper.h" + +void gen_intermediate_code (CPUXenPVState *env,TranslationBlock *tb) +{ +abort (); +} + +void gen_intermediate_code_pc (CPUXenPVState *env,TranslationBlock *tb) +{ +abort (); +} + +void restore_state_to_opc (CPUXenPVState *env,TranslationBlock *tb, +int pc_pos) +{ +abort (); +} + +
Signature · 1 line
1.7.10.4
RFC PATCH 5/5 xen: introduce xenpv-softmmu.mak
In reply to Wei LiuThe modification to configure is rebased on Paolo's change.
--- configure | 13 +++++++++---- default-configs/xenpv-softmmu.mak | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 default-configs/xenpv-softmmu.mak
configure +9 -4
@@ -4283,7 +4283,7 @@ supported_xen_target() { test "$xen" = "yes" || return 1 test "$target_softmmu" = "yes" || return 1 case "$target_name:$cpu" in - i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64) + i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64 | xenpv:*) return 0 ;; esac
@@ -4443,6 +4443,9 @@ case "$target_name" in ;; unicore32) ;; + xenpv) + TARGET_ARCH=xenpv + ;; xtensa|xtensaeb) TARGET_ARCH=xtensa ;;
@@ -4472,9 +4475,11 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak if supported_xen_target; then echo "CONFIG_XEN=y" >> $config_target_mak - echo "CONFIG_XEN_I386=y" >> $config_target_mak - if test "$xen_pci_passthrough" = yes; then - echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + if test "$target_name" != "xenpv"; then + echo "CONFIG_XEN_I386=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + fi fi fi if supported_kvm_target; then
default-configs/xenpv-softmmu.mak new file +2 -0
@@ -0,0 +1,2 @@ +# Default configuration for xenpv-softmmu +# Yes it is empty as we don't need to include any device emulation code
Signature · 1 line
1.7.10.4
Re: [PATCH RFC 5/5] xen: introduce xenpv-softmmu.mak
Il 23/01/2014 23:16, Wei Liu ha scritto:
configure echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak · line 4482
Quoted 6 lines
configure +5
-1- echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + if test "$target_name" != "xenpv"; then + echo "CONFIG_XEN_I386=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + fi
You can add
CONFIG_XEN_PCI_PASSTHROUGH=$(CONFIG_XEN)
to i386-softmmu.mak and x86_64-softmmu.mak, and drop this setting from config-target.mak too.
Paolo
Re: [Qemu-devel] [PATCH RFC 5/5] xen: introduce xenpv-softmmu.mak
In reply to Wei LiuIl 23/01/2014 23:16, Wei Liu ha scritto:
configure echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak · line 4482
Quoted 6 lines
configure +5
-1- echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + if test "$target_name" != "xenpv"; then + echo "CONFIG_XEN_I386=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + fi
You can add
CONFIG_XEN_PCI_PASSTHROUGH=$(CONFIG_XEN)
to i386-softmmu.mak and x86_64-softmmu.mak, and drop this setting from config-target.mak too.
Paolo
Re: [PATCH RFC 5/5] xen: introduce xenpv-softmmu.mak
Quoted 8 lines · Paolo Bonzini
Il 23/01/2014 23:16, Wei Liu ha scritto:
configure echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak · line 4482
Quoted 6 lines
configure +5
-1- echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + if test "$target_name" != "xenpv"; then + echo "CONFIG_XEN_I386=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + fi
Quoted 7 lines
You can add
CONFIG_XEN_PCI_PASSTHROUGH=$(CONFIG_XEN)to i386-softmmu.mak and x86_64-softmmu.mak, and drop this setting from config-target.mak too.
I'm afraid not. CONFIG_XEN is prerequiste for CONFIG_XEN_PCI_PASSTHROUGH but doens't imply the feature is enabled by the user.
Wei.
Quoted 1 line
Paolo
Re: [Qemu-devel] [PATCH RFC 5/5] xen: introduce xenpv-softmmu.mak
In reply to Paolo BonziniQuoted 8 lines · Paolo Bonzini
Il 23/01/2014 23:16, Wei Liu ha scritto:
configure echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak · line 4482
Quoted 6 lines
configure +5
-1- echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + if test "$target_name" != "xenpv"; then + echo "CONFIG_XEN_I386=y" >> $config_target_mak + if test "$xen_pci_passthrough" = yes; then + echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak" + fi
Quoted 7 lines
You can add
CONFIG_XEN_PCI_PASSTHROUGH=$(CONFIG_XEN)to i386-softmmu.mak and x86_64-softmmu.mak, and drop this setting from config-target.mak too.
I'm afraid not. CONFIG_XEN is prerequiste for CONFIG_XEN_PCI_PASSTHROUGH but doens't imply the feature is enabled by the user.
Wei.
Quoted 1 line
Paolo
Quoted 3 lines · Wei Liu
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and "the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
thanks
-- PMM
Quoted 3 lines · Wei Liu
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and "the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 3 lines · Wei Liu
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and
Thanks for being blunt. ;-)
Quoted 6 lines
"the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
I think about this deeper. From Xen's (and I speculate this applies to other hardware assisted virtulization solution as well) PoV only the native endianess is supported, does it make sense to have a target-native thing?
Wei.
Quoted 1 line
thanks -- PMM
Quoted 6 lines · Peter Maydell
Quoted 3 lines · Wei Liu
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and
Thanks for being blunt. ;-)
Quoted 6 lines
"the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
I think about this deeper. From Xen's (and I speculate this applies to other hardware assisted virtulization solution as well) PoV only the native endianess is supported, does it make sense to have a target-native thing?
Wei.
Quoted 1 line
thanks -- PMM
Il 24/01/2014 15:23, Wei Liu ha scritto:
Quoted 17 lines · Peter Maydell
Quoted 6 lines · Wei Liu
Quoted 3 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and
Thanks for being blunt. ;-)
Quoted 6 lines
"the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
Quoted 4 lines
I think about this deeper. From Xen's (and I speculate this applies to other hardware assisted virtulization solution as well) PoV only the native endianess is supported, does it make sense to have a target-native thing?
I think this is wrong, for a few reasons:
(1) xenpv is not hardware assisted virtualization
(2) supporting only native endianness leads to complications when systems are bi-endian, as is the case for PPC. For example, virtio 1.0 will always be little endian.
(3) there's a precedent for supporting different guests between the guest and the host in blkback, you can do the same for endianness.
Paolo
Il 24/01/2014 15:23, Wei Liu ha scritto:
Quoted 17 lines · Peter Maydell
Quoted 6 lines · Wei Liu
Quoted 3 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and
Thanks for being blunt. ;-)
Quoted 6 lines
"the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
Quoted 4 lines
I think about this deeper. From Xen's (and I speculate this applies to other hardware assisted virtulization solution as well) PoV only the native endianess is supported, does it make sense to have a target-native thing?
I think this is wrong, for a few reasons:
(1) xenpv is not hardware assisted virtualization
(2) supporting only native endianness leads to complications when systems are bi-endian, as is the case for PPC. For example, virtio 1.0 will always be little endian.
(3) there's a precedent for supporting different guests between the guest and the host in blkback, you can do the same for endianness.
Paolo
Quoted 18 lines · Paolo Bonzini
Il 24/01/2014 15:23, Wei Liu ha scritto:
Quoted 17 lines · Peter Maydell
Quoted 6 lines · Wei Liu
Quoted 3 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and
Thanks for being blunt. ;-)
Quoted 6 lines
"the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
Quoted 9 lines
Quoted 4 lines
I think about this deeper. From Xen's (and I speculate this applies to other hardware assisted virtulization solution as well) PoV only the native endianess is supported, does it make sense to have a target-native thing?
I think this is wrong, for a few reasons:
(1) xenpv is not hardware assisted virtualization
Correct... What I really meant was "those virtualization solutions don't care much about CPU emulation" (if there's any other than Xen).
Quoted 4 lines
(2) supporting only native endianness leads to complications when systems are bi-endian, as is the case for PPC. For example, virtio 1.0 will always be little endian.
OK, good to know.
Quoted 3 lines
(3) there's a precedent for supporting different guests between the guest and the host in blkback, you can do the same for endianness.
Yes. But this is still open question at the moment, as there's no canonical protocol for this (it hasn't even been discussed).
Your second point is the thing I missed though. Thanks for reminding.
Wei.
Quoted 1 line
Paolo
Quoted 18 lines · Paolo Bonzini
Il 24/01/2014 15:23, Wei Liu ha scritto:
Quoted 17 lines · Peter Maydell
Quoted 6 lines · Wei Liu
Quoted 3 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and
Thanks for being blunt. ;-)
Quoted 6 lines
"the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
Quoted 9 lines
Quoted 4 lines
I think about this deeper. From Xen's (and I speculate this applies to other hardware assisted virtulization solution as well) PoV only the native endianess is supported, does it make sense to have a target-native thing?
I think this is wrong, for a few reasons:
(1) xenpv is not hardware assisted virtualization
Correct... What I really meant was "those virtualization solutions don't care much about CPU emulation" (if there's any other than Xen).
Quoted 4 lines
(2) supporting only native endianness leads to complications when systems are bi-endian, as is the case for PPC. For example, virtio 1.0 will always be little endian.
OK, good to know.
Quoted 3 lines
(3) there's a precedent for supporting different guests between the guest and the host in blkback, you can do the same for endianness.
Yes. But this is still open question at the moment, as there's no canonical protocol for this (it hasn't even been discussed).
Your second point is the thing I missed though. Thanks for reminding.
Wei.
Quoted 1 line
Paolo
Il 23/01/2014 23:30, Peter Maydell ha scritto:
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and "the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
(1) decide that the Xen ring buffers are little-endian even on big-endian CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore, just like we do for sizeof(long), and let the guest use either endianness on any architecture.
Paolo
Il 23/01/2014 23:30, Peter Maydell ha scritto:
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and "the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
(1) decide that the Xen ring buffers are little-endian even on big-endian CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore, just like we do for sizeof(long), and let the guest use either endianness on any architecture.
Paolo
Quoted 9 lines · Paolo Bonzini
Il 23/01/2014 23:30, Peter Maydell ha scritto:
Quoted 6 lines
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and "the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
Quoted 6 lines
(1) decide that the Xen ring buffers are little-endian even on big-endian CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore, just like we do for sizeof(long), and let the guest use either endianness on any architecture.
You still have to make a choice about what you think TARGET_WORDS_BIGENDIAN should be, and it's still going to be wrong half the time and horribly confusing. I just think this is completely the wrong solution to the problem.
If Xen really wants a totally standalone binary of the smallest possible size with just paravirtualized hardware and minimal to no dependency on guest CPU architecture then they should write one, along the lines of kvmtool :-)
thanks
-- PMM
Quoted 9 lines · Paolo Bonzini
Il 23/01/2014 23:30, Peter Maydell ha scritto:
Quoted 6 lines
I'm afraid I still think this is a terrible idea. "Xen" isn't a CPU, and "the binary is smaller" isn't IMHO sufficient justification for breaking QEMU's basic structure of "target-* define target CPUs and we have a lot of compile time constants which are specific to a CPU which get defined there". How would you support a bigendian Xen CPU, just to pick one example of where this falls down?
Quoted 6 lines
(1) decide that the Xen ring buffers are little-endian even on big-endian CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore, just like we do for sizeof(long), and let the guest use either endianness on any architecture.
You still have to make a choice about what you think TARGET_WORDS_BIGENDIAN should be, and it's still going to be wrong half the time and horribly confusing. I just think this is completely the wrong solution to the problem.
If Xen really wants a totally standalone binary of the smallest possible size with just paravirtualized hardware and minimal to no dependency on guest CPU architecture then they should write one, along the lines of kvmtool :-)
thanks
-- PMM
Il 24/01/2014 15:35, Peter Maydell ha scritto:
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
(1) decide that the Xen ring buffers are little-endian even on big-endian CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore, just like we do for sizeof(long), and let the guest use either endianness on any architecture.
You still have to make a choice about what you think
TARGET_WORDS_BIGENDIANshould be, and it's still going to be wrong half the time and horribly confusing. I just think this is completely the wrong solution to the problem.
Theoretically the xenpv-softmmu machine shouldn't need any code that depends on TARGET_WORDS_BIGENDIAN.
If we changed every #ifdef TARGET_WORDS_BIGENDIAN to if(), we could compile it with "#define TARGET_WORDS_BIGENDIAN abort()".
Paolo
Il 24/01/2014 15:35, Peter Maydell ha scritto:
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
(1) decide that the Xen ring buffers are little-endian even on big-endian CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore, just like we do for sizeof(long), and let the guest use either endianness on any architecture.
You still have to make a choice about what you think
TARGET_WORDS_BIGENDIANshould be, and it's still going to be wrong half the time and horribly confusing. I just think this is completely the wrong solution to the problem.
Theoretically the xenpv-softmmu machine shouldn't need any code that depends on TARGET_WORDS_BIGENDIAN.
If we changed every #ifdef TARGET_WORDS_BIGENDIAN to if(), we could compile it with "#define TARGET_WORDS_BIGENDIAN abort()".
Paolo
Quoted 16 lines · Paolo Bonzini
Il 24/01/2014 15:35, Peter Maydell ha scritto:
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
(1) decide that the Xen ring buffers are little-endian even on
big-endian
Quoted 3 lines
CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore,
just
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
like we do for sizeof(long), and let the guest use either endianness on
any
Quoted 1 line
architecture.
You still have to make a choice about what you think
TARGET_WORDS_BIGENDIANshould be, and it's still going to be wrong half the time and horribly confusing. I just think this is completely the wrong solution to the problem.
Quoted 5 lines
Theoretically the xenpv-softmmu machine shouldn't need any code that depends on
TARGET_WORDS_BIGENDIAN.If we changed every #ifdef
TARGET_WORDS_BIGENDIANtoif(), we could compile it with "#defineTARGET_WORDS_BIGENDIANabort()".
Right. All our PV protocols are little endian by definition.
Besides I don't know how to state this more clearly but there are no big endian Xen guests. There have never been any big endian Xen guests. There are no big endian Xen guests on the roadmap.
Quoted 16 lines · Paolo Bonzini
Il 24/01/2014 15:35, Peter Maydell ha scritto:
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
(1) decide that the Xen ring buffers are little-endian even on
big-endian
Quoted 3 lines
CPUs
(2) communicate the endianness of the Xen ring buffers via Xenstore,
just
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
like we do for sizeof(long), and let the guest use either endianness on
any
Quoted 1 line
architecture.
You still have to make a choice about what you think
TARGET_WORDS_BIGENDIANshould be, and it's still going to be wrong half the time and horribly confusing. I just think this is completely the wrong solution to the problem.
Quoted 5 lines
Theoretically the xenpv-softmmu machine shouldn't need any code that depends on
TARGET_WORDS_BIGENDIAN.If we changed every #ifdef
TARGET_WORDS_BIGENDIANtoif(), we could compile it with "#defineTARGET_WORDS_BIGENDIANabort()".
Right. All our PV protocols are little endian by definition.
Besides I don't know how to state this more clearly but there are no big endian Xen guests. There have never been any big endian Xen guests. There are no big endian Xen guests on the roadmap.
Quoted 3 lines · Stefano Stabellini
Besides I don't know how to state this more clearly but there are no big endian Xen guests. There have never been any big endian Xen guests. There are no big endian Xen guests on the roadmap.
That is perhaps a bit strong, but what is 100% true is that none of the defined Xen PV protocols (listed at [0]) is big endian.
If someone were to build e.g. an armbe guest then they would either have to do the swapping in the frontend (and continue to claim to be the l.e. XEN_IO_PROTO_ABI_ARM) or they would have to define XEN_IO_PROTO_ABI_ARMBE and arrange for the front and backend to negotiate as appropriate, and that would be the appropriate point in time for the backends to be taught about non-native endianess IMHO.
[0] http://xenbits.xen.org/docs/unstable-staging/hypercall/x86_64/include,public,io,protocols.h.html
Ian.
Quoted 3 lines · Stefano Stabellini
Besides I don't know how to state this more clearly but there are no big endian Xen guests. There have never been any big endian Xen guests. There are no big endian Xen guests on the roadmap.
That is perhaps a bit strong, but what is 100% true is that none of the defined Xen PV protocols (listed at [0]) is big endian.
If someone were to build e.g. an armbe guest then they would either have to do the swapping in the frontend (and continue to claim to be the l.e. XEN_IO_PROTO_ABI_ARM) or they would have to define XEN_IO_PROTO_ABI_ARMBE and arrange for the front and backend to negotiate as appropriate, and that would be the appropriate point in time for the backends to be taught about non-native endianess IMHO.
[0] http://xenbits.xen.org/docs/unstable-staging/hypercall/x86_64/include,public,io,protocols.h.html
Ian.
Il 23/01/2014 23:16, Wei Liu ha scritto:
Quoted 63 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
The first 3 patches refactor some code to disentangle Xen PV and HVM guest. The 4th patch has the real meat. It introduces Xen PV target, which contains basically a dummy CPU, then hooks up this Xen PV CPU to QEMU internal structures.
The last patch introduces xenpv-softmmu, which contains *no* emulation code. I know that in previous discussion people said that every device emulation should be included if the target architecture is called null. But since this target CPU is now called xenpv I don't feel obliged to include any device emulation in this prototype anymore. :-)
Please note that the existing Xen QEMU build is not affected at all. You can still use "--disable-tcg --enable-xen --target-list=i386-softmmu" (or x86_64-softmmu") to build qemu-system-{i386,x86_64} and use it for both HVM and PV guest. This series adds another option to build QEMU with "--disable-tcg --enable-xen --target-list=xenpv-softmmu" and get a QEMU binary tailored for Xen PV guest. The effect is that we reduce the binary size from 14MB to 7.3MB.
What do you think of this idea? I'm all ears.
Wei.
Wei Liu (5):
xen: move Xen PV machine files to hw/xenpv
xen: factor out common functions
exec: guard Xen HVM hooks withCONFIG_XEN_I386
xen: implement Xen PV target
xen: introduce xenpv-softmmu.makMakefile.target | 3 +- arch_init.c | 2 + configure | 12 ++- cpu-exec.c | 2 + default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - default-configs/xenpv-softmmu.mak | 2 + exec.c | 16 ++++ hw/i386/Makefile.objs | 2 +- hw/xenpv/Makefile.objs | 2 + hw/{i386 => xenpv}/xen_domainbuild.c | 0 hw/{i386 => xenpv}/xen_domainbuild.h | 0 hw/{i386 => xenpv}/xen_machine_pv.c | 0 include/exec/memory-internal.h | 2 + include/sysemu/arch_init.h | 1 + target-xenpv/Makefile.objs | 1 + target-xenpv/cpu-qom.h | 64 ++++++++++++++++ target-xenpv/cpu.h | 66 ++++++++++++++++ target-xenpv/helper.c | 32 ++++++++ target-xenpv/translate.c | 27 +++++++ xen-common.c | 137 ++++++++++++++++++++++++++++++++++ xen-all.c => xen-hvm.c | 112 +-------------------------- xen-stub.c | 4 - 23 files changed, 368 insertions(+), 121 deletions(-) create mode 100644 default-configs/xenpv-softmmu.mak create mode 100644 hw/xenpv/Makefile.objs rename hw/{i386 => xenpv}/xen_domainbuild.c (100%) rename hw/{i386 => xenpv}/xen_domainbuild.h (100%) rename hw/{i386 => xenpv}/xen_machine_pv.c (100%)
Quoted 9 lines
create mode 100644 target-xenpv/Makefile.objs create mode 100644 target-xenpv/cpu-qom.h create mode 100644 target-xenpv/cpu.h create mode 100644 target-xenpv/helper.c create mode 100644 target-xenpv/helper.h create mode 100644 target-xenpv/translate.c create mode 100644 xen-common.c rename xen-all.c => xen-hvm.c (92%)
Mostly looks good!
Feel free to take any initial patches you need from my branch, and post them for inclusion together with this series!
Paolo
Il 23/01/2014 23:16, Wei Liu ha scritto:
Quoted 63 lines
As promised I hacked a prototype based on Paolo's disable TCG series. However I coded some stubs for TCG anyway. So this series in principle should work with / without Paolo's series.
The first 3 patches refactor some code to disentangle Xen PV and HVM guest. The 4th patch has the real meat. It introduces Xen PV target, which contains basically a dummy CPU, then hooks up this Xen PV CPU to QEMU internal structures.
The last patch introduces xenpv-softmmu, which contains *no* emulation code. I know that in previous discussion people said that every device emulation should be included if the target architecture is called null. But since this target CPU is now called xenpv I don't feel obliged to include any device emulation in this prototype anymore. :-)
Please note that the existing Xen QEMU build is not affected at all. You can still use "--disable-tcg --enable-xen --target-list=i386-softmmu" (or x86_64-softmmu") to build qemu-system-{i386,x86_64} and use it for both HVM and PV guest. This series adds another option to build QEMU with "--disable-tcg --enable-xen --target-list=xenpv-softmmu" and get a QEMU binary tailored for Xen PV guest. The effect is that we reduce the binary size from 14MB to 7.3MB.
What do you think of this idea? I'm all ears.
Wei.
Wei Liu (5):
xen: move Xen PV machine files to hw/xenpv
xen: factor out common functions
exec: guard Xen HVM hooks withCONFIG_XEN_I386
xen: implement Xen PV target
xen: introduce xenpv-softmmu.makMakefile.target | 3 +- arch_init.c | 2 + configure | 12 ++- cpu-exec.c | 2 + default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - default-configs/xenpv-softmmu.mak | 2 + exec.c | 16 ++++ hw/i386/Makefile.objs | 2 +- hw/xenpv/Makefile.objs | 2 + hw/{i386 => xenpv}/xen_domainbuild.c | 0 hw/{i386 => xenpv}/xen_domainbuild.h | 0 hw/{i386 => xenpv}/xen_machine_pv.c | 0 include/exec/memory-internal.h | 2 + include/sysemu/arch_init.h | 1 + target-xenpv/Makefile.objs | 1 + target-xenpv/cpu-qom.h | 64 ++++++++++++++++ target-xenpv/cpu.h | 66 ++++++++++++++++ target-xenpv/helper.c | 32 ++++++++ target-xenpv/translate.c | 27 +++++++ xen-common.c | 137 ++++++++++++++++++++++++++++++++++ xen-all.c => xen-hvm.c | 112 +-------------------------- xen-stub.c | 4 - 23 files changed, 368 insertions(+), 121 deletions(-) create mode 100644 default-configs/xenpv-softmmu.mak create mode 100644 hw/xenpv/Makefile.objs rename hw/{i386 => xenpv}/xen_domainbuild.c (100%) rename hw/{i386 => xenpv}/xen_domainbuild.h (100%) rename hw/{i386 => xenpv}/xen_machine_pv.c (100%)
Quoted 9 lines
create mode 100644 target-xenpv/Makefile.objs create mode 100644 target-xenpv/cpu-qom.h create mode 100644 target-xenpv/cpu.h create mode 100644 target-xenpv/helper.c create mode 100644 target-xenpv/helper.h create mode 100644 target-xenpv/translate.c create mode 100644 xen-common.c rename xen-all.c => xen-hvm.c (92%)
Mostly looks good!
Feel free to take any initial patches you need from my branch, and post them for inclusion together with this series!
Paolo