Xen cleanups
v2 cover Xen cleanups
Changes to v1:
- rebase over xen-next which includes
- dropping of xen_unmap_block uninlining (as it's gone)
PS: Alex, there must be some patch(es) with style issues in your queue. Please avoid accepting anything that fails checkpatch unless for valid exceptions.
Jan Kiszka (3):
xen: Clean up build system
xen: Clean up map cache API naming
xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN
Makefile.objs | 4 ++-- Makefile.target | 14 ++------------ configure | 5 +---- exec.c | 34 ++++++++++++++++++---------------- hw/xen.h | 9 --------- trace-events | 6 +++--- xen-all.c | 4 ++-- xen-mapcache-stub.c | 36 ------------------------------------ xen-mapcache.c | 41 +++++++++++++++++++++++------------------ xen-mapcache.h | 14 ++++++-------- xen-stub.c | 16 ++++++++++++++++ 11 files changed, 73 insertions(+), 110 deletions(-) delete mode 100644 xen-mapcache-stub.c
PATCH v2 1/3 xen: Clean up build system
From: Jan Kiszka <[email protected]>
Introduce CONFIG_XEN_BACKEND so that this new config solely controls the target-independent backend build and CONFIG_XEN can focus on per-target building.
--- Makefile.objs | 4 ++-- Makefile.target | 13 +++---------- configure | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-)
Makefile.objs +2 -2
@@ -155,8 +155,8 @@ slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o common-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y)) # xen backend driver support -common-obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o -common-obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o +common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o +common-obj-$(CONFIG_XEN_BACKEND) += xen_console.o xenfb.o xen_disk.o xen_nic.o ###################################################################### # libuser
Makefile.target +3 -10
@@ -3,6 +3,8 @@ GENERATED_HEADERS = config-target.h CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y) CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y) +CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y) +CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y) include ../config-host.mak include config-devices.mak
@@ -203,17 +205,8 @@ QEMU_CFLAGS += $(VNC_SASL_CFLAGS) QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) QEMU_CFLAGS += $(VNC_PNG_CFLAGS) -# xen backend driver support -obj-i386-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o - -ifeq ($(TARGET_BASE_ARCH), i386) - CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y) -else - CONFIG_NO_XEN = y -endif # xen support -CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y) -obj-i386-$(CONFIG_XEN) += xen-all.o +obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o obj-$(CONFIG_NO_XEN) += xen-stub.o obj-i386-$(CONFIG_XEN_MAPCACHE) += xen-mapcache.o obj-$(CONFIG_NO_XEN_MAPCACHE) += xen-mapcache-stub.o
configure +1 -1
@@ -2971,7 +2971,7 @@ if test "$bluez" = "yes" ; then echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak fi if test "$xen" = "yes" ; then - echo "CONFIG_XEN=y" >> $config_host_mak + echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak fi if test "$io_thread" = "yes" ; then
Signature · 1 line
1.7.1
PATCH v2 2/3 xen: Clean up map cache API naming
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
The map cache is a Xen thing, so its API should make this clear.
--- exec.c | 18 ++++++++++-------- trace-events | 6 +++--- xen-all.c | 4 ++-- xen-mapcache-stub.c | 11 ++++++----- xen-mapcache.c | 41 +++++++++++++++++++++++------------------ xen-mapcache.h | 14 ++++++-------- 6 files changed, 50 insertions(+), 44 deletions(-)
exec.c +10 -8
@@ -2990,7 +2990,7 @@ void qemu_ram_free(ram_addr_t addr)munmap (block->host, block->length);#else if (xen_mapcache_enabled ()) { -qemu_invalidate_entry (block->host); +xen_invalidate_map_cache_entry (block->host); }else {qemu_vfree (block->host); }
@@ -3088,9 +3088,10 @@ void *qemu_get_ram_ptr(ram_addr_t addr)* In that case just map until the end of the page. */ if (block->offset ==0 ) { -return qemu_map_cache (addr,0 ,0 ); +return xen_map_cache (addr,0 ,0 ); }else if (block->host ==NULL ) { - block->host =qemu_map_cache (block->offset, block->length,1 ); + block->host = +xen_map_cache (block->offset, block->length,1 ); } }return block->host + (addr - block->offset);
@@ -3118,9 +3119,10 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)* In that case just map until the end of the page. */ if (block->offset ==0 ) { -return qemu_map_cache (addr,0 ,0 ); +return xen_map_cache (addr,0 ,0 ); }else if (block->host ==NULL ) { - block->host =qemu_map_cache (block->offset, block->length,1 ); + block->host = +xen_map_cache (block->offset, block->length,1 ); } }return block->host + (addr - block->offset);
@@ -3138,7 +3140,7 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)void *qemu_ram_ptr_length (target_phys_addr_t addr,target_phys_addr_t *size) {if (xen_mapcache_enabled ()) -return qemu_map_cache (addr, *size,1 ); +return xen_map_cache (addr, *size,1 );else {RAMBlock *block;
@@ -3169,7 +3171,7 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)uint8_t *host = ptr;if (xen_mapcache_enabled ()) { - *ram_addr =qemu_ram_addr_from_mapcache (ptr); + *ram_addr =xen_ram_addr_from_mapcache (ptr);return 0 ; }
@@ -4084,7 +4086,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, } }if (xen_mapcache_enabled ()) { -qemu_invalidate_entry (buffer); +xen_invalidate_map_cache_entry (buffer); }return ; }
trace-events +3 -3
@@ -399,9 +399,9 @@ disable xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: %# disable xen_client_set_memory(uint64_t start_addr, unsigned long size, unsigned long phys_offset, bool log_dirty) "%#"PRIx64" size %#lx, offset %#lx, log_dirty %i" # xen-mapcache.c -disable qemu_map_cache(uint64_t phys_addr) "want %#"PRIx64"" -disable qemu_remap_bucket(uint64_t index) "index %#"PRIx64"" -disable qemu_map_cache_return(void* ptr) "%p" +disable xen_map_cache(uint64_t phys_addr) "want %#"PRIx64"" +disable xen_remap_bucket(uint64_t index) "index %#"PRIx64"" +disable xen_map_cache_return(void* ptr) "%p" disable xen_map_block(uint64_t phys_addr, uint64_t size) "%#"PRIx64", size %#"PRIx64"" disable xen_unmap_block(void* addr, unsigned long size) "%p, size %#lx"
xen-all.c +2 -2
@@ -644,7 +644,7 @@ static void handle_ioreq(ioreq_t *req)case IOREQ_TYPE_TIMEOFFSET :break ;case IOREQ_TYPE_INVALIDATE : -qemu_invalidate_map_cache (); +xen_invalidate_map_cache ();break ;default :hw_error ("Invalid ioreq type 0x%x\n" , req->type);
@@ -852,7 +852,7 @@ int xen_hvm_init(void) }/* Init RAM management */ -qemu_map_cache_init (); +xen_map_cache_init ();xen_ram_init (ram_size);qemu_add_vm_change_state_handler (xen_vm_change_state_handler, state);
xen-mapcache-stub.c +6 -5
@@ -13,24 +13,25 @@#include "cpu-common.h" #include "xen-mapcache.h" -void qemu_map_cache_init (void ) +void xen_map_cache_init (void ) { } -uint8_t *qemu_map_cache (target_phys_addr_t phys_addr,target_phys_addr_t size,uint8_t lock) +uint8_t *xen_map_cache (target_phys_addr_t phys_addr,target_phys_addr_t size, +uint8_t lock) {return qemu_get_ram_ptr (phys_addr); } -ram_addr_t qemu_ram_addr_from_mapcache (void *ptr) +ram_addr_t xen_ram_addr_from_mapcache (void *ptr) {return -1 ; } -void qemu_invalidate_map_cache (void ) +void xen_invalidate_map_cache (void ) { } -void qemu_invalidate_entry (uint8_t *buffer) +void xen_invalidate_map_cache_entry (uint8_t *buffer) { }
xen-mapcache.c +23 -18
132 lines not on this page · raw message
xen-mapcache.h +6 -8
@@ -9,13 +9,11 @@#ifndef XEN_MAPCACHE_H #define XEN_MAPCACHE_H -void qemu_map_cache_init (void ); -uint8_t *qemu_map_cache (target_phys_addr_t phys_addr,target_phys_addr_t size,uint8_t lock); -ram_addr_t qemu_ram_addr_from_mapcache (void *ptr); -void qemu_invalidate_entry (uint8_t *buffer); -void qemu_invalidate_map_cache (void ); - -#define mapcache_lock () ((void)0) -#define mapcache_unlock () ((void)0) +void xen_map_cache_init (void ); +uint8_t *xen_map_cache (target_phys_addr_t phys_addr,target_phys_addr_t size, +uint8_t lock); +ram_addr_t xen_ram_addr_from_mapcache (void *ptr); +void xen_invalidate_map_cache_entry (uint8_t *buffer); +void xen_invalidate_map_cache (void );#endif /* !XEN_MAPCACHE_H */
Signature · 1 line
1.7.1
PATCH v2 3/3 xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Xen won't be enabled if there is no backend support available for the host. And that also means the map cache will work. So drop the separate config switch and move the required stubs over to xen-stub.c.
--- Makefile.target | 5 +---- configure | 3 --- exec.c | 16 ++++++++-------- hw/xen.h | 9 --------- xen-mapcache-stub.c | 37 ------------------------------------- xen-stub.c | 16 ++++++++++++++++ 6 files changed, 25 insertions(+), 61 deletions(-) delete mode 100644 xen-mapcache-stub.c
Makefile.target +1 -4
@@ -4,7 +4,6 @@ GENERATED_HEADERS = config-target.h CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y) CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y) CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y) -CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y) include ../config-host.mak include config-devices.mak
@@ -206,10 +205,8 @@ QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) QEMU_CFLAGS += $(VNC_PNG_CFLAGS) # xen support -obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o +obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o xen-mapcache.o obj-$(CONFIG_NO_XEN) += xen-stub.o -obj-i386-$(CONFIG_XEN_MAPCACHE) += xen-mapcache.o -obj-$(CONFIG_NO_XEN_MAPCACHE) += xen-mapcache-stub.o obj-i386-$(CONFIG_XEN) += xen_platform.o
configure +0 -3
@@ -3356,9 +3356,6 @@ case "$target_arch2" in if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then target_phys_bits=64 echo "CONFIG_XEN=y" >> $config_target_mak - if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then - echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak - fi fi esac case "$target_arch2" in
exec.c +8 -8
@@ -2923,7 +2923,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, abort(); }#else -if (xen_mapcache_enabled ()) { +if (xen_enabled ()) {xen_ram_alloc (new_block->offset, size); }else { new_block->host =qemu_vmalloc (size);
@@ -2989,7 +2989,7 @@ void qemu_ram_free(ram_addr_t addr)#if defined(TARGET_S390X ) && defined(CONFIG_KVM )munmap (block->host, block->length);#else -if (xen_mapcache_enabled ()) { +if (xen_enabled ()) {xen_invalidate_map_cache_entry (block->host); }else {qemu_vfree (block->host);
@@ -3082,7 +3082,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)QLIST_REMOVE (block, next);QLIST_INSERT_HEAD (&ram_list.blocks, block, next); } -if (xen_mapcache_enabled ()) { +if (xen_enabled ()) {/* 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.
@@ -3113,7 +3113,7 @@ void *qemu_safe_ram_ptr(ram_addr_t addr) QLIST_FOREACH(block, &ram_list.blocks, next) {if (addr - block->offset < block->length) { -if (xen_mapcache_enabled ()) { +if (xen_enabled ()) {/* 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.
@@ -3139,9 +3139,9 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)* but takes a size argument */ void *qemu_ram_ptr_length (target_phys_addr_t addr,target_phys_addr_t *size) { -if (xen_mapcache_enabled ()) +if (xen_enabled ()) {return xen_map_cache (addr, *size,1 ); -else { + }else {RAMBlock *block; QLIST_FOREACH(block, &ram_list.blocks, next) {
@@ -3170,7 +3170,7 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)RAMBlock *block;uint8_t *host = ptr; -if (xen_mapcache_enabled ()) { +if (xen_enabled ()) { *ram_addr =xen_ram_addr_from_mapcache (ptr);return 0 ; }
@@ -4085,7 +4085,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, access_len -= l; } } -if (xen_mapcache_enabled ()) { +if (xen_enabled ()) {xen_invalidate_map_cache_entry (buffer); }return ;
hw/xen.h +0 -9
@@ -31,15 +31,6 @@ static inline int xen_enabled(void)#endif } -static inline int xen_mapcache_enabled (void ) -{ -#ifdef CONFIG_XEN_MAPCACHE -return xen_enabled (); -#else -return 0 ; -#endif -} -int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len);
xen-mapcache-stub.c deleted +0 -37
@@ -1,37 +0,0 @@ -/* -* Copyright (C) 2011 Citrix Ltd. -* -* This work is licensed under the terms of the GNU GPL, version 2. See -* the COPYING file in the top-level directory. -* -*/ - -#include "config.h" - -#include "exec-all.h" -#include "qemu-common.h" -#include "cpu-common.h" -#include "xen-mapcache.h" - -void xen_map_cache_init (void ) -{ -} - -uint8_t *xen_map_cache (target_phys_addr_t phys_addr,target_phys_addr_t size, -uint8_t lock) -{ -return qemu_get_ram_ptr (phys_addr); -} - -ram_addr_t xen_ram_addr_from_mapcache (void *ptr) -{ -return -1 ; -} - -void xen_invalidate_map_cache (void ) -{ -} - -void xen_invalidate_map_cache_entry (uint8_t *buffer) -{ -}
xen-stub.c +16 -0
@@ -8,6 +8,7 @@#include "qemu-common.h" #include "hw/xen.h" +#include "xen-mapcache.h" int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num) {
@@ -39,3 +40,18 @@ int xen_init(void) {return -ENOSYS ; } + +uint8_t *xen_map_cache (target_phys_addr_t phys_addr,target_phys_addr_t size, +uint8_t lock) +{ +return NULL ; +} + +ram_addr_t xen_ram_addr_from_mapcache (void *ptr) +{ +return -1 ; +} + +void xen_invalidate_map_cache_entry (uint8_t *buffer) +{ +}
Signature · 1 line
1.7.1
Alexander Graf
AppliedQuoted 4 lines · Jan Kiszka
Changes to v1:
- rebase over xen-next which includes
- dropping ofxen_unmap_blockuninlining (as it's gone)
Thanks, applied to the xen-next branch.
Quoted 3 lines
PS: Alex, there must be some patch(es) with style issues in your queue. Please avoid accepting anything that fails checkpatch unless for valid exceptions.
Hrm. Will try to do so.
Alex