KVM, dirty bitmap, build system, SMM, icount changes for 2015-06-05
Subsystems (3)
The following changes since commit 00967f4e0bab246679d0ddc32fd31a7179345baf:
Merge remote-tracking branch 'remotes/agraf/tags/signed-s390-for-upstream' into staging (2015-06-05 12:04:42 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 4f4edb40f55b130b00960abc826a588b31bd3308:
update Linux headers from kvm/next (2015-06-05 17:10:02 +0200)
Apologies for the very large pull request, mostly due to the two main topics (dirty bitmap + SMM) being reviewed more or less at the same time.
----------------------------------------------------------------
* KVM error improvement from Laurent
* CONFIG_PARALLEL fix from Mirek
* Atomic/optimized dirty bitmap access from myself and Stefan
* BUILD_DIR convenience/bugfix from Peter C
* Memory leak fix from Shannon
* SMM improvements (though still TCG only) from myself and Gerd, acked by mst
----------------------------------------------------------------
Fam Zheng (1):
qemu-nbd: Switch to qemu_set_fd_handler
Gerd Hoffmann (6):
q35: fix ESMRAMC default
q35: add config space wmask for SMRAM and ESMRAMC
q35: implement SMRAM.D_LCK
q35: add test for SMRAM.D_LCK
q35: implement TSEG
ich9: implement SMI_LOCK
Laurent Vivier (1):
ppc: add helpful message when KVM fails to start VCPU
Miroslav Rezanina (1):
Move parallel_hds_isa_init to hw/isa/isa-bus.c
Paolo Bonzini (43):
exec: optimize phys_page_set_level
memory: the only dirty memory flag for users is DIRTY_MEMORY_VGA
g364fb: remove pointless call to memory_region_set_coalescing
display: enable DIRTY_MEMORY_VGA tracking explicitly
display: add memory_region_sync_dirty_bitmap calls
memory: differentiate memory_region_is_logging and memory_region_get_dirty_log_mask
memory: prepare for multiple bits in the dirty log mask
framebuffer: check memory_region_is_logging
ui/console: remove dpy_gfx_update_dirty
memory: track DIRTY_MEMORY_CODE in mr->dirty_log_mask
kvm: accept non-mapped memory in kvm_dirty_pages_log_change
memory: include DIRTY_MEMORY_MIGRATION in the dirty log mask
kvm: remove special handling of DIRTY_MEMORY_MIGRATION in the dirty log mask
ram_addr: tweaks to xen_modified_memory
exec: use memory_region_get_dirty_log_mask to optimize dirty tracking
exec: move functions to translate-all.h
translate-all: remove unnecessary argument to tb_invalidate_phys_range
cputlb: remove useless arguments to tlb_unprotect_code_phys, rename
translate-all: make less of tb_invalidate_phys_page_range depend on is_cpu_write_access
exec: pass client mask to cpu_physical_memory_set_dirty_range
exec: invert return value of cpu_physical_memory_get_clean, rename
exec: only check relevant bitmaps for cleanliness
memory: do not touch code dirty bitmap unless TCG is enabled
memory: use mr->ram_addr in "is this RAM?" assertions
target-i386: introduce cpu_get_mem_attrs
target-i386: Use correct memory attributes for memory accesses
target-i386: Use correct memory attributes for ioport accesses
target-i386: mask NMIs on entry to SMM
target-i386: set G=1 in SMM big real mode selectors
target-i386: wake up processors that receive an SMI
pflash_cfi01: change big-endian property to BIT type
pflash_cfi01: change to new-style MMIO accessors
pflash_cfi01: add secure property
vl: allow full-blown QemuOpts syntax for -global
qom: add object_property_add_const_link
vl: run "late" notifiers immediately
target-i386: create a separate AddressSpace for each CPU
hw/i386: add a separate region that tracks the SMRAME bit
target-i386: use memory API to implement SMRAM
hw/i386: remove smram_update
q35: implement high SMRAM
atomics: add explicit compiler fence in __atomic memory barriers
update Linux headers from kvm/next
Peter Crosthwaite (1):
Makefile.target: set master BUILD_DIR
Stefan Hajnoczi (6):
bitmap: add atomic set functions
bitmap: add atomic test and clear
memory: use atomic ops for setting dirty memory bits
migration: move dirty bitmap sync to ram_addr.h
memory: replace cpu_physical_memory_reset_dirty() with test-and-clear
memory: make cpu_physical_memory_sync_dirty_bitmap() fully atomic
Victor CLEMENT (3):
icount: implement a new icount_sleep mode toggleing real-time cpu sleep
icount: add sleep parameter to the icount option to set icount_sleep mode
icount: print a warning if there is no more deadline in sleep=no mode
Makefile.target | 2 + arch_init.c | 46 +--- bsd-user/main.c | 4 - cpus.c | 84 ++++--- cputlb.c | 7 +- exec.c | 123 +++++----- hw/acpi/ich9.c | 4 +- hw/block/pflash_cfi01.c | 204 +++++++--------- hw/char/parallel.c | 25 -- hw/display/cg3.c | 2 + hw/display/exynos4210_fimd.c | 20 +- hw/display/framebuffer.c | 4 + hw/display/g364fb.c | 3 +- hw/display/sm501.c | 2 + hw/display/tcx.c | 3 + hw/display/vmware_vga.c | 2 +- hw/i386/pc.c | 21 -- hw/isa/isa-bus.c | 26 +++ hw/isa/lpc_ich9.c | 19 ++ hw/pci-host/pam.c | 20 -- hw/pci-host/piix.c | 44 ++-- hw/pci-host/q35.c | 142 ++++++++++-- hw/virtio/dataplane/vring.c | 2 +- hw/virtio/vhost.c | 9 +- include/exec/cputlb.h | 3 +- include/exec/exec-all.h | 6 +- include/exec/memattrs.h | 4 +- include/exec/memory.h | 25 +- include/exec/ram_addr.h | 138 +++++++---- include/hw/acpi/ich9.h | 1 + include/hw/i386/ich9.h | 6 + include/hw/i386/pc.h | 1 - include/hw/pci-host/pam.h | 4 - include/hw/pci-host/q35.h | 36 ++- include/qemu/atomic.h | 12 +- include/qemu/bitmap.h | 4 + include/qemu/bitops.h | 14 ++ include/qom/object.h | 18 ++ include/standard-headers/linux/virtio_ring.h | 2 +- include/ui/console.h | 4 - kvm-all.c | 85 ++----- linux-headers/asm-x86/kvm.h | 14 +- linux-headers/linux/kvm.h | 7 +- linux-user/main.c | 4 - linux-user/mmap.c | 7 +- memory.c | 81 +++++-- qdev-monitor.c | 18 +- qemu-nbd.c | 21 +- qemu-options.hx | 19 +- qom/object.c | 16 ++ target-i386/Makefile.objs | 2 - target-i386/cpu-qom.h | 3 + target-i386/cpu.c | 47 +++- target-i386/cpu.h | 40 +++- target-i386/helper.c | 135 +++++++++-- target-i386/helper.h | 12 +- target-i386/ioport-user.c | 60 ----- target-i386/kvm.c | 2 +- target-i386/machine.c | 3 + target-i386/misc_helper.c | 59 +++-- target-i386/seg_helper.c | 12 +- target-i386/smm_helper.c | 333 ++++++++++++++------------- target-i386/svm_helper.c | 230 +++++++++--------- target-i386/translate.c | 12 +- tests/Makefile | 3 + tests/q35-test.c | 91 ++++++++ translate-all.c | 20 +- translate-all.h | 7 + ui/console.c | 61 ----- user-exec.c | 1 + util/bitmap.c | 83 +++++++ vl.c | 9 + xen-hvm.c | 22 +- 73 files changed, 1560 insertions(+), 1055 deletions(-) delete mode 100644 target-i386/ioport-user.c create mode 100644 tests/q35-test.c
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 01/62] Move parallel_hds_isa_init to hw/isa/isa-bus.c
From: Miroslav Rezanina <[email protected]>
Disabling CONFIG_PARALLEL cause removing parallel_hds_isa_init defined in parallel.c. This function is called during initialization of some boards so disabling CONFIG_PARALLEL cause build failure.
This patch moves parallel_hds_isa_init to hw/isa/isa-bus.c so it is included in case of disabled CONFIG_PARALLEL. Build is successful but qemu will abort with "Unknown device" error when function is called.
Message-Id: <[email protected]>
--- hw/char/parallel.c | 25 ------------------------- hw/isa/isa-bus.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-)
hw/char/parallel.c +0 -25
@@ -641,28 +641,3 @@ static void parallel_register_types(void) }type_init (parallel_register_types) - -static void parallel_init(ISABus *bus, int index, CharDriverState *chr) -{ -DeviceState *dev; -ISADevice *isadev; - - isadev =isa_create (bus,"isa-parallel" ); - dev =DEVICE (isadev); -qdev_prop_set_uint32 (dev,"index" , index); -qdev_prop_set_chr (dev,"chardev" , chr); -qdev_init_nofail (dev); -} - -void parallel_hds_isa_init (ISABus *bus,int n) -{ -int i; - -assert (n <=MAX_PARALLEL_PORTS ); - -for (i =0 ; i < n; i++) { -if (parallel_hds[i]) { -parallel_init (bus, i, parallel_hds[i]); - } - } -}
hw/isa/isa-bus.c +26 -0
@@ -21,6 +21,7 @@#include "hw/sysbus.h" #include "sysemu/sysemu.h" #include "hw/isa/isa.h" +#include "hw/i386/pc.h" static ISABus *isabus;
@@ -267,3 +268,28 @@ MemoryRegion *isa_address_space_io(ISADevice *dev) }type_init (isabus_register_types) + +static void parallel_init(ISABus *bus, int index, CharDriverState *chr) +{ +DeviceState *dev; +ISADevice *isadev; + + isadev =isa_create (bus,"isa-parallel" ); + dev =DEVICE (isadev); +qdev_prop_set_uint32 (dev,"index" , index); +qdev_prop_set_chr (dev,"chardev" , chr); +qdev_init_nofail (dev); +} + +void parallel_hds_isa_init (ISABus *bus,int n) +{ +int i; + +assert (n <=MAX_PARALLEL_PORTS ); + +for (i =0 ; i < n; i++) { +if (parallel_hds[i]) { +parallel_init (bus, i, parallel_hds[i]); + } + } +}
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 02/62] ppc: add helpful message when KVM fails to start VCPU
In reply to Paolo BonziniFrom: Laurent Vivier <[email protected]>
On POWER8 systems, KVM checks if VCPU is running on primary threads, and that secondary threads are offline. If this is not the case, ioctl() fails with errno set to EBUSY.
QEMU aborts with a non explicit error message:
$ ./qemu-system-ppc64 --nographic -machine pseries,accel=kvm error: kvm run failed Device or resource busy
To help user to diagnose the problem, this patch adds an informative error message.
There is no easy way to check if SMT is enabled before starting the VCPU, and as this case is the only one setting errno to EBUSY, we just check the errno value to display a message.
Message-Id: <[email protected]>
--- kvm-all.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kvm-all.c +8 -0
@@ -1828,6 +1828,14 @@ int kvm_cpu_exec(CPUState *cpu) }fprintf (stderr,"error: kvm run failed %s\n" ,strerror (-run_ret)); +#ifdef TARGET_PPC +if (run_ret == -EBUSY ) { +fprintf (stderr, +"This is probably because your SMT is enabled.\n" +"VCPU can only run on primary threads with all " +"secondary threads offline.\n" ); + } +#endif ret =-1 ;break ; }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 04/62] exec: optimize phys_page_set_level
In reply to Paolo Bonziniphys_page_set_level is writing zeroes to a struct that has just been filled in by phys_map_node_alloc. Instead, tell phys_map_node_alloc whether to fill in the page "as a leaf" or "as a non-leaf".
memcpy is faster than struct assignment, which copies each bitfield individually. A compiler bug (https://gcc.gnu.org/PR66391), and small memcpys like this one are special-cased anyway, and optimized to a register move, so just use the memcpy.
This cuts the cost of phys_page_set_level from 25% to 5% when booting qboot.
--- exec.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
exec.c +10 -14
@@ -173,17 +173,22 @@ static void phys_map_node_reserve(PhysPageMap *map, unsigned nodes) } } -static uint32_t phys_map_node_alloc (PhysPageMap *map) +static uint32_t phys_map_node_alloc (PhysPageMap *map,bool leaf) {unsigned i;uint32_t ret; +PhysPageEntry e; +PhysPageEntry *p; ret = map->nodes_nb++; + p = map->nodes[ret];assert (ret !=PHYS_MAP_NODE_NIL );assert (ret != map->nodes_nb_alloc); + + e.skip = leaf ?0 :1 ; + e.ptr = leaf ?PHYS_SECTION_UNASSIGNED :PHYS_MAP_NODE_NIL ;for (i =0 ; i <P_L2_SIZE ; ++i) { - map->nodes[ret][i].skip =1 ; - map->nodes[ret][i].ptr =PHYS_MAP_NODE_NIL ; +memcpy (&p[i], &e,sizeof (e)); }return ret; }
@@ -193,21 +198,12 @@ static void phys_page_set_level(PhysPageMap *map, PhysPageEntry *lp, int level) {PhysPageEntry *p; -int i;hwaddr step = (hwaddr )1 << (level *P_L2_BITS );if (lp->skip && lp->ptr ==PHYS_MAP_NODE_NIL ) { - lp->ptr =phys_map_node_alloc (map); - p = map->nodes[lp->ptr]; -if (level ==0 ) { -for (i =0 ; i <P_L2_SIZE ; i++) { - p[i].skip =0 ; - p[i].ptr =PHYS_SECTION_UNASSIGNED ; - } - } - }else { - p = map->nodes[lp->ptr]; + lp->ptr =phys_map_node_alloc (map, level ==0 ); } + p = map->nodes[lp->ptr]; lp = &p[(*index >> (level *P_L2_BITS )) & (P_L2_SIZE -1 )];while (*nb && lp < &p[P_L2_SIZE ]) {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 03/62] qemu-nbd: Switch to qemu_set_fd_handler
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Achieved by:
- Remembering the server fd with a global variable, in order to access it from nbd_client_closed.
- Checking nbd_can_accept() and updating server_fd handler whenever client connects or disconnects.
Message-Id: <[email protected]>
--- qemu-nbd.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
qemu-nbd.c +17 -4
@@ -53,6 +53,7 @@ static int persistent = 0;static enum {RUNNING ,TERMINATE ,TERMINATING ,TERMINATED } state;static int shared =1 ;static int nb_fds; +static int server_fd;static void usage (const char *name) {
@@ -340,7 +341,7 @@ out:return (void *)EXIT_FAILURE ; } -static int nbd_can_accept (void *opaque) +static int nbd_can_accept (void ) {return nb_fds < shared; }
@@ -351,19 +352,21 @@ static void nbd_export_closed(NBDExport *exp) state =TERMINATED ; } +static void nbd_update_server_fd_handler (int fd); +static void nbd_client_closed (NBDClient *client) { nb_fds--;if (nb_fds ==0 && !persistent && state ==RUNNING ) { state =TERMINATE ; } +nbd_update_server_fd_handler (server_fd);qemu_notify_event ();nbd_client_put (client); }static void nbd_accept (void *opaque) { -int server_fd = (uintptr_t ) opaque;struct sockaddr_in addr;socklen_t addr_len =sizeof (addr);
@@ -380,12 +383,22 @@ static void nbd_accept(void *opaque)if (nbd_client_new (exp, fd, nbd_client_closed)) { nb_fds++; +nbd_update_server_fd_handler (server_fd); }else {shutdown (fd,2 );close (fd); } } +static void nbd_update_server_fd_handler (int fd) +{ +if (nbd_can_accept ()) { +qemu_set_fd_handler (fd, nbd_accept,NULL , (void *)(uintptr_t )fd); + }else { +qemu_set_fd_handler (fd,NULL ,NULL ,NULL ); + } +} +int main (int argc,char **argv) {BlockBackend *blk;
@@ -761,8 +774,8 @@ int main(int argc, char **argv)memset (&client_thread,0 ,sizeof (client_thread)); } -qemu_set_fd_handler2 (fd, nbd_can_accept, nbd_accept,NULL , - (void *)(uintptr_t )fd); + server_fd = fd; +nbd_update_server_fd_handler (fd);/* now when the initialization is (almost) complete, chdir("/") * to free any busy filesystems */
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 06/62] memory: the only dirty memory flag for users is DIRTY_MEMORY_VGA
In reply to Paolo BonziniDIRTY_MEMORY_MIGRATION is triggered by memory_global_dirty_log_start and memory_global_dirty_log_stop, so it cannot be used with memory_region_set_log.
Specify this in the documentation and assert it.
--- include/exec/memory.h | 3 +-- memory.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
include/exec/memory.h +1 -2
@@ -647,8 +647,7 @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize,* * @mr: the memory region being updated. * @log: whether dirty logging is to be enabled or disabled. -* @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or -* %DIRTY_MEMORY_VGA. +* @client: the user of the logging information; %DIRTY_MEMORY_VGA only. */ void memory_region_set_log (MemoryRegion *mr,bool log,unsigned client);
memory.c +1 -0
@@ -1425,6 +1425,7 @@ void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client) {uint8_t mask =1 << client; +assert (client ==DIRTY_MEMORY_VGA );memory_region_transaction_begin (); mr->dirty_log_mask = (mr->dirty_log_mask & ~mask) | (log * mask); memory_region_update_pending |= mr->enabled;
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 05/62] Makefile.target: set master BUILD_DIR
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
make can be invoked in the individual build dirs to build an individual target or just a single file of a target. e.g.
touch translate-all.c
make -C microblazeel-softmmu translate-all.o
There is however a small bug when using the pixman submodule. config-host.mak will ref BUILD_DIR for the pixman -I CFLAGS:
grep BUILD_DIR config-host.mak QEMU_CFLAGS=-I$(SRC_PATH)/pixman/pixman -I$(BUILD_DIR)/pixman/pixman ...
This causes a build failure as -I/pixman/pixman (BUILD_DIR=="") will not be found.
BUILD_DIR is usually set by the top level Makefile. Just lazy-set it in Makefile.target to the parent directory.
Granted, this will not work if the pixman submodule is not prebuilt, but it at least means you can do incremental partial builds once you have done your initial full build (or attempt) from the top level.
The next step would be refactor make infrastructure to rebuild pixman on a submake like the one above.
Message-Id: <[email protected]>
--- Makefile.target | 2 ++ 1 file changed, 2 insertions(+)
Makefile.target +2 -0
@@ -1,5 +1,7 @@ # -*- Mode: makefile -*- +BUILD_DIR?=$(CURDIR)/.. + include ../config-host.mak include config-target.mak include config-devices.mak
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 07/62] g364fb: remove pointless call to memory_region_set_coalescing
In reply to Paolo BonziniCoalescing work on MMIO, not RAM, thus this call has no effect.
--- hw/display/g364fb.c | 1 - 1 file changed, 1 deletion(-)
hw/display/g364fb.c +0 -1
@@ -489,7 +489,6 @@ static void g364fb_init(DeviceState *dev, G364State *s)memory_region_init_ram_ptr (&s->mem_vram,NULL ,"vram" , s->vram_size, s->vram);vmstate_register_ram (&s->mem_vram, dev); -memory_region_set_coalescing (&s->mem_vram); }#define TYPE_G364 "sysbus-g364"
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 08/62] display: enable DIRTY_MEMORY_VGA tracking explicitly
In reply to Paolo BonziniThis will be required soon by the memory core.
--- hw/display/cg3.c | 1 + hw/display/exynos4210_fimd.c | 20 +++++++++++++------- hw/display/g364fb.c | 1 + hw/display/sm501.c | 1 + hw/display/tcx.c | 1 + 5 files changed, 17 insertions(+), 7 deletions(-)
hw/display/cg3.c +1 -0
@@ -309,6 +309,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)memory_region_init_ram (&s->vram_mem,NULL ,"cg3.vram" , s->vram_size, &error_abort); +memory_region_set_log (&s->vram_mem, true,DIRTY_MEMORY_VGA );vmstate_register_ram_global (&s->vram_mem);sysbus_init_mmio (sbd, &s->vram_mem);
hw/display/exynos4210_fimd.c +13 -7
@@ -1109,6 +1109,12 @@ static inline int fimd_get_buffer_id(Exynos4210fimdWindow *w) } } +static void exynos4210_fimd_invalidate (void *opaque) +{ +Exynos4210fimdState *s = (Exynos4210fimdState *)opaque; + s->invalidate = true; +} +/* Updates specified window's MemorySection based on values of WINCON, * VIDOSDA, VIDOSDB, VIDWADDx and SHADOWCON registers */ static void fimd_update_memory_section (Exynos4210fimdState *s,unsigned win)
@@ -1136,7 +1142,11 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)/* TODO: add .exit and unref the region there. Not needed yet since sysbus * does not support hot-unplug. */ -memory_region_unref (w->mem_section.mr); +if (w->mem_section.mr) { +memory_region_set_log (w->mem_section.mr, false,DIRTY_MEMORY_VGA ); +memory_region_unref (w->mem_section.mr); + } + w->mem_section =memory_region_find (sysbus_address_space (sbd), fb_start_addr, w->fb_len);assert (w->mem_section.mr);
@@ -1162,6 +1172,8 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)cpu_physical_memory_unmap (w->host_fb_addr, fb_mapped_len,0 ,0 ); goto error_return; } +memory_region_set_log (w->mem_section.mr, true,DIRTY_MEMORY_VGA ); +exynos4210_fimd_invalidate (s);return ; error_return:
@@ -1224,12 +1236,6 @@ static void exynos4210_fimd_update_irq(Exynos4210fimdState *s) } } -static void exynos4210_fimd_invalidate (void *opaque) -{ -Exynos4210fimdState *s = (Exynos4210fimdState *)opaque; - s->invalidate = true; -} -static void exynos4210_update_resolution (Exynos4210fimdState *s) {DisplaySurface *surface =qemu_console_surface (s->console);
hw/display/g364fb.c +1 -0
@@ -489,6 +489,7 @@ static void g364fb_init(DeviceState *dev, G364State *s)memory_region_init_ram_ptr (&s->mem_vram,NULL ,"vram" , s->vram_size, s->vram);vmstate_register_ram (&s->mem_vram, dev); +memory_region_set_log (&s->mem_vram, true,DIRTY_MEMORY_VGA ); }#define TYPE_G364 "sysbus-g364"
hw/display/sm501.c +1 -0
@@ -1412,6 +1412,7 @@ void sm501_init(MemoryRegion *address_space_mem, uint32_t base,memory_region_init_ram (&s->local_mem_region,NULL ,"sm501.local" , local_mem_bytes, &error_abort);vmstate_register_ram_global (&s->local_mem_region); +memory_region_set_log (&s->local_mem_region, true,DIRTY_MEMORY_VGA ); s->local_mem =memory_region_get_ram_ptr (&s->local_mem_region);memory_region_add_subregion (address_space_mem, base, &s->local_mem_region);
hw/display/tcx.c +1 -0
@@ -1006,6 +1006,7 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)memory_region_init_ram (&s->vram_mem,OBJECT (s),"tcx.vram" , s->vram_size * (1 +4 +4 ), &error_abort);vmstate_register_ram_global (&s->vram_mem); +memory_region_set_log (&s->vram_mem, true,DIRTY_MEMORY_VGA ); vram_base =memory_region_get_ram_ptr (&s->vram_mem);/* 10/ROM : FCode ROM */
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 09/62] display: add memory_region_sync_dirty_bitmap calls
In reply to Paolo BonziniThese are strictly speaking only needed for KVM and Xen, but it's still nice to be consistent.
--- hw/display/cg3.c | 1 + hw/display/g364fb.c | 1 + hw/display/sm501.c | 1 + hw/display/tcx.c | 2 ++ 4 files changed, 5 insertions(+)
hw/display/cg3.c +1 -0
@@ -106,6 +106,7 @@ static void cg3_update_display(void *opaque) pix =memory_region_get_ram_ptr (&s->vram_mem); data = (uint32_t *)surface_data (surface); +memory_region_sync_dirty_bitmap (&s->vram_mem);for (y =0 ; y < height; y++) {int update = s->full_update;
hw/display/g364fb.c +1 -0
@@ -260,6 +260,7 @@ static void g364fb_update_display(void *opaque)qemu_console_resize (s->con, s->width, s->height); } +memory_region_sync_dirty_bitmap (&s->mem_vram);if (s->ctla &CTLA_FORCE_BLANK ) {g364fb_draw_blank (s); }else if (s->depth ==8 ) {
hw/display/sm501.c +1 -0
@@ -1322,6 +1322,7 @@ static void sm501_draw_crt(SM501State * s) }/* draw each line according to conditions */ +memory_region_sync_dirty_bitmap (&s->local_mem_region);for (y =0 ; y < height; y++) {int update_hwc = draw_hwc_line ?within_hwc_y_range (s, y,1 ) :0 ;int update = full_update || update_hwc;
hw/display/tcx.c +2 -0
@@ -353,6 +353,7 @@ static void tcx_update_display(void *opaque)return ; } +memory_region_sync_dirty_bitmap (&ts->vram_mem);for (y =0 ; y < ts->height; page +=TARGET_PAGE_SIZE ) {if (memory_region_get_dirty (&ts->vram_mem, page,TARGET_PAGE_SIZE ,DIRTY_MEMORY_VGA )) {
@@ -446,6 +447,7 @@ static void tcx24_update_display(void *opaque) dd =surface_stride (surface); ds =1024 ; +memory_region_sync_dirty_bitmap (&ts->vram_mem);for (y =0 ; y < ts->height; page +=TARGET_PAGE_SIZE , page24 +=TARGET_PAGE_SIZE , cpage +=TARGET_PAGE_SIZE ) {if (tcx24_check_dirty (ts, page, page24, cpage)) {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 10/62] memory: differentiate memory_region_is_logging and memory_region_get_dirty_log_mask
In reply to Paolo BonziniFor now memory regions only track DIRTY_MEMORY_VGA individually, but this will change soon. To support this, split memory_region_is_logging in two functions: one that returns a given bit from dirty_log_mask, and one that returns the entire mask. memory_region_is_logging gets an extra parameter so that the compiler flags misuse.
While VGA-specific users (including the Xen listener!) will want to keep checking that bit, KVM and vhost check for "any bit except migration" (because migration is handled via the global start/stop listener callbacks).
--- hw/display/vmware_vga.c | 2 +- hw/virtio/dataplane/vring.c | 2 +- hw/virtio/vhost.c | 3 ++- include/exec/memory.h | 16 ++++++++++++++-- kvm-all.c | 3 ++- memory.c | 7 ++++++- xen-hvm.c | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-)
hw/display/vmware_vga.c +1 -1
@@ -1124,7 +1124,7 @@ static void vmsvga_update_display(void *opaque)* Is it more efficient to look at vram VGA-dirty bits or wait * for the driver to issue SVGA_CMD_UPDATE? */ -if (memory_region_is_logging (&s->vga.vram)) { +if (memory_region_is_logging (&s->vga.vram,DIRTY_MEMORY_VGA )) {vga_sync_dirty_bitmap (&s->vga); dirty = memory_region_get_dirty(&s->vga.vram, 0, surface_stride(surface) * surface_height(surface),
hw/virtio/dataplane/vring.c +1 -1
@@ -42,7 +42,7 @@ static void *vring_map(MemoryRegion **mr, hwaddr phys, hwaddr len, }/* Ignore regions with dirty logging, we cannot mark them dirty */ -if (memory_region_is_logging (section.mr)) { +if (memory_region_get_dirty_log_mask (section.mr)) { goto out; }
hw/virtio/vhost.c +2 -1
@@ -416,7 +416,8 @@ static void vhost_set_memory(MemoryListener *listener, memory_listener);hwaddr start_addr = section->offset_within_address_space;ram_addr_t size =int128_get64 (section->size); -bool log_dirty =memory_region_is_logging (section->mr); +bool log_dirty = +memory_region_get_dirty_log_mask (section->mr) & ~(1 <<DIRTY_MEMORY_MIGRATION );int s = offsetof(struct vhost_memory , regions) + (dev->mem->nregions +1 ) *sizeof dev->mem->regions[0 ];void *ram;
include/exec/memory.h +14 -2
@@ -591,11 +591,23 @@ const char *memory_region_name(const MemoryRegion *mr);/** * memory_region_is_logging: return whether a memory region is logging writes * -* Returns %true if the memory region is logging writes +* Returns %true if the memory region is logging writes for the given client * * @mr: the memory region being queried +* @client: the client being queried */ -bool memory_region_is_logging (MemoryRegion *mr); +bool memory_region_is_logging (MemoryRegion *mr,uint8_t client); + +/** +* memory_region_get_dirty_log_mask: return the clients for which a +* memory region is logging writes. +* +* Returns a bitmap of clients, which right now will be either 0 or +* (1 << DIRTY_MEMORY_VGA). +* +* @mr: the memory region being queried +*/ +uint8_t memory_region_get_dirty_log_mask (MemoryRegion *mr);/** * memory_region_is_rom: check whether a memory region is ROM
kvm-all.c +2 -1
@@ -663,7 +663,8 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add)KVMSlot *mem, old;int err;MemoryRegion *mr = section->mr; -bool log_dirty =memory_region_is_logging (mr); +bool log_dirty = +memory_region_get_dirty_log_mask (mr) & ~(1 <<DIRTY_MEMORY_MIGRATION );bool writeable = !mr->readonly && !mr->rom_device;bool readonly_flag = mr->readonly ||memory_region_is_romd (mr);hwaddr start_addr = section->offset_within_address_space;
memory.c +6 -1
@@ -1389,11 +1389,16 @@ bool memory_region_is_skip_dump(MemoryRegion *mr)return mr->skip_dump; } -bool memory_region_is_logging (MemoryRegion *mr) +uint8_t memory_region_get_dirty_log_mask (MemoryRegion *mr) {return mr->dirty_log_mask; } +bool memory_region_is_logging (MemoryRegion *mr,uint8_t client) +{ +return memory_region_get_dirty_log_mask (mr) & (1 << client); +} +bool memory_region_is_rom (MemoryRegion *mr) {return mr->ram && mr->readonly;
xen-hvm.c +1 -1
@@ -488,7 +488,7 @@ static void xen_set_memory(struct MemoryListener *listener,XenIOState *state =container_of (listener, XenIOState, memory_listener);hwaddr start_addr = section->offset_within_address_space;ram_addr_t size =int128_get64 (section->size); -bool log_dirty =memory_region_is_logging (section->mr); +bool log_dirty =memory_region_is_logging (section->mr,DIRTY_MEMORY_VGA );hvmmem_type_t mem_type;if (section->mr == &ram_memory) {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 11/62] memory: prepare for multiple bits in the dirty log mask
In reply to Paolo BonziniWhen the dirty log mask will also cover other bits than DIRTY_MEMORY_VGA, some listeners may be interested in the overall zero/non-zero value of the dirty log mask; others may be interested in the value of single bits.
For this reason, always call log_start/log_stop if bits have respectively appeared or disappeared, and pass the old and new values of the dirty log mask so that listeners can distinguish the kinds of change.
For example, KVM checks if dirty logging used to be completely disabled (in log_start) or is now completely disabled (in log_stop). On the other hand, Xen has to check manually if DIRTY_MEMORY_VGA changed, since that is the only bit it cares about.
--- hw/virtio/vhost.c | 6 ++++-- include/exec/memory.h | 6 ++++-- kvm-all.c | 14 ++++++++++++-- memory.c | 17 +++++++++++------ xen-hvm.c | 20 +++++++++++++------- 5 files changed, 44 insertions(+), 19 deletions(-)
hw/virtio/vhost.c +4 -2
@@ -676,13 +676,15 @@ static void vhost_log_global_stop(MemoryListener *listener) }static void vhost_log_start (MemoryListener *listener, -MemoryRegionSection *section) +MemoryRegionSection *section, +int old,int new) {/* FIXME: implement */ }static void vhost_log_stop (MemoryListener *listener, -MemoryRegionSection *section) +MemoryRegionSection *section, +int old,int new) {/* FIXME: implement */ }
include/exec/memory.h +4 -2
@@ -206,8 +206,10 @@ struct MemoryListener {void (*region_add)(MemoryListener *listener,MemoryRegionSection *section);void (*region_del)(MemoryListener *listener,MemoryRegionSection *section);void (*region_nop)(MemoryListener *listener,MemoryRegionSection *section); -void (*log_start)(MemoryListener *listener,MemoryRegionSection *section); -void (*log_stop)(MemoryListener *listener,MemoryRegionSection *section); +void (*log_start)(MemoryListener *listener,MemoryRegionSection *section, +int old,int new); +void (*log_stop)(MemoryListener *listener,MemoryRegionSection *section, +int old,int new);void (*log_sync)(MemoryListener *listener,MemoryRegionSection *section);void (*log_global_start)(MemoryListener *listener);void (*log_global_stop)(MemoryListener *listener);
kvm-all.c +12 -2
@@ -344,10 +344,15 @@ static int kvm_dirty_pages_log_change(hwaddr phys_addr, }static void kvm_log_start (MemoryListener *listener, -MemoryRegionSection *section) +MemoryRegionSection *section, +int old,int new) {int r; +if (old !=0 ) { +return ; + } + r =kvm_dirty_pages_log_change (section->offset_within_address_space,int128_get64 (section->size), true);if (r <0 ) {
@@ -356,10 +361,15 @@ static void kvm_log_start(MemoryListener *listener, }static void kvm_log_stop (MemoryListener *listener, -MemoryRegionSection *section) +MemoryRegionSection *section, +int old,int new) {int r; +if (new !=0 ) { +return ; + } + r =kvm_dirty_pages_log_change (section->offset_within_address_space,int128_get64 (section->size), false);if (r <0 ) {
memory.c +11 -6
@@ -152,7 +152,7 @@ static bool memory_listener_match(MemoryListener *listener, } while (0)/* No need to ref/unref .mr, the FlatRange keeps it alive. */ -#define MEMORY_LISTENER_UPDATE_REGION (fr, as, dir, callback) \ +#define MEMORY_LISTENER_UPDATE_REGION(fr, as, dir, callback, _args...) \ MEMORY_LISTENER_CALL(callback, dir, (&(MemoryRegionSection) { \ .mr = (fr)->mr, \ .address_space = (as), \
@@ -160,7 +160,7 @@ static bool memory_listener_match(MemoryListener *listener, .size = (fr)->addr.size, \ .offset_within_address_space = int128_get64((fr)->addr.start), \ .readonly = (fr)->readonly, \ - })) + }), ##_args) struct CoalescedMemoryRange { AddrRange addr;
@@ -774,10 +774,15 @@ static void address_space_update_topology_pass(AddressSpace *as,if (adding) {MEMORY_LISTENER_UPDATE_REGION (frnew, as, Forward, region_nop); -if (frold->dirty_log_mask && !frnew->dirty_log_mask) { -MEMORY_LISTENER_UPDATE_REGION (frnew, as, Reverse, log_stop); - }else if (frnew->dirty_log_mask && !frold->dirty_log_mask) { -MEMORY_LISTENER_UPDATE_REGION (frnew, as, Forward, log_start); +if (frnew->dirty_log_mask & ~frold->dirty_log_mask) { +MEMORY_LISTENER_UPDATE_REGION (frnew, as, Forward, log_start, + frold->dirty_log_mask, + frnew->dirty_log_mask); + } +if (frold->dirty_log_mask & ~frnew->dirty_log_mask) { +MEMORY_LISTENER_UPDATE_REGION (frnew, as, Reverse, log_stop, + frold->dirty_log_mask, + frnew->dirty_log_mask); } }
xen-hvm.c +13 -7
@@ -646,21 +646,27 @@ static void xen_sync_dirty_bitmap(XenIOState *state, }static void xen_log_start (MemoryListener *listener, -MemoryRegionSection *section) +MemoryRegionSection *section, +int old,int new) {XenIOState *state =container_of (listener, XenIOState, memory_listener); -xen_sync_dirty_bitmap (state, section->offset_within_address_space, -int128_get64 (section->size)); +if (new & ~old & (1 <<DIRTY_MEMORY_VGA )) { +xen_sync_dirty_bitmap (state, section->offset_within_address_space, +int128_get64 (section->size)); + } } -static void xen_log_stop (MemoryListener *listener,MemoryRegionSection *section) +static void xen_log_stop (MemoryListener *listener,MemoryRegionSection *section, +int old,int new) {XenIOState *state =container_of (listener, XenIOState, memory_listener); - state->log_for_dirtybit =NULL ; -/* Disable dirty bit tracking */ -xc_hvm_track_dirty_vram (xen_xc, xen_domid,0 ,0 ,NULL ); +if (old & ~new & (1 <<DIRTY_MEMORY_VGA )) { + state->log_for_dirtybit =NULL ; +/* Disable dirty bit tracking */ +xc_hvm_track_dirty_vram (xen_xc, xen_domid,0 ,0 ,NULL ); + } }static void xen_log_sync (MemoryListener *listener,MemoryRegionSection *section)
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
In reply to Paolo Bonziniframebuffer.c expects DIRTY_MEMORY_VGA logging to be always on, but that will not be the case soon. Because framebuffer.c computes the memory region on the fly for every update (with memory_region_find), it cannot enable/disable logging by itself.
Instead, always treat updates as invalidations if dirty logging is not enabled, assuming that the board will enable logging on the RAM region that includes the framebuffer.
--- hw/display/framebuffer.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/display/framebuffer.c +4 -0
@@ -63,6 +63,10 @@ void framebuffer_update_display(assert (mem_section.offset_within_address_space == base);memory_region_sync_dirty_bitmap (mem); +if (!memory_region_is_logging (mem,DIRTY_MEMORY_VGA )) { + invalidate = true; + } + src_base =cpu_physical_memory_map (base, &src_len,0 );/* If we can't map the framebuffer then bail. We could try harder, but it's not really worth it as dirty flag tracking will probably
Signature · 1 line
2.4.1
Re: [Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
Quoted 20 lines · Paolo Bonzini
framebuffer.cexpectsDIRTY_MEMORY_VGAlogging to be always on, but that will not be the case soon. Becauseframebuffer.ccomputes the memory region on the fly for every update (withmemory_region_find), it cannot enable/disable logging by itself.Instead, always treat updates as invalidations if dirty logging is not enabled, assuming that the board will enable logging on the RAM region that includes the framebuffer.
Reviewed-by Fam Zheng <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- hw/display/framebuffer.c | 4 ++++ 1 file changed, 4 insertions(+)hw/display/framebuffer.c +0
-0
hw/display/framebuffer.c void framebuffer_update_display( · line 72
Quoted 10 lines
hw/display/framebuffer.c +4
-0@@ -63,6 +63,10 @@ void framebuffer_update_display(assert (mem_section.offset_within_address_space == base);memory_region_sync_dirty_bitmap (mem); +if (!memory_region_is_logging (mem,DIRTY_MEMORY_VGA )) { + invalidate = true; + } + src_base =cpu_physical_memory_map (base, &src_len,0 );/* If we can't map the framebuffer then bail. We could try harder, but it's not really worth it as dirty flag tracking will probably
I've just noticed that one of my vexpress-a9 test images has regressed, and git bisect suggests this commit (d55d42078bfb50) is at fault.
Test image (512MB)
http://people.linaro.org/~peter.maydell/vexpress-3.8.tgz
Untar anywhere, and run with
~/path/to/vexpress-3.8/runme path/to/qemu-system-arm
Before this commit it boots, but afterwards it hangs just after:
[ 7.338111] clcd-pl11x 10020000.clcd: Device Tree CLCD PL111 hardware, XVGA display [ 7.437573] Console: switching to colour frame buffer device 128x48 [ 7.510028] VD10: at 1000 mV [ 7.533710] VD10_S2: at 1000 mV [ 7.552106] VD10_S3: at 1000 mV [ 7.579775] VCC1V8: at 1800 mV [ 7.606060] DDR2VTT: at 900 mV [ 7.619865] VCC3V3: at 3300 mV [ 7.649775] VIO: at 3300 mV
...eventually the guest's rcu_sched stall detector fires, so the guest isn't totally dead:
[ 51.405779] INFO: rcu_sched detected stalls on CPUs/tasks: {}
(detected by 0, t=4266 jiffies, g=4294967169, c=4294967168, q=47)
[ 51.407674] INFO: Stall ended before state dump start
[ 75.834733] INFO: rcu_sched self-detected stall on CPU { 0}(t=2437 jiffies g=4294967174 c=4294967173 q=27)
thanks
-- PMM
Re: [Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
Quoted 8 lines · Peter Maydell
I've just noticed that one of my vexpress-a9 test images has regressed, and git bisect suggests this commit (
d55d42078bfb50) is at fault.Test image (512MB)
http://people.linaro.org/~peter.maydell/vexpress-3.8.tgz
Untar anywhere, and run with
~/path/to/vexpress-3.8/runme path/to/qemu-system-arm
I can't reproduce it. I get to the root shell prompt (both on the framebuffer and on the serial console) and can poweroff successfully.
Paolo
Re: [Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
Quoted 7 lines · Paolo Bonzini
Quoted 4 lines · Peter Maydell
I've just noticed that one of my vexpress-a9 test images has regressed, and git bisect suggests this commit (
d55d42078bfb50) is at fault.
Quoted 7 lines
Quoted 4 lines
Test image (512MB)
http://people.linaro.org/~peter.maydell/vexpress-3.8.tgz
Untar anywhere, and run with
~/path/to/vexpress-3.8/runme path/to/qemu-system-armI can't reproduce it. I get to the root shell prompt (both on the framebuffer and on the serial console) and can poweroff successfully.
Odd, it was entirely consistent for me. This is with GTK and X11-over-ssh-over-slowish-ADSL, so the actual refresh of the display will be slow, but that ought not to imply anything about how fast the guest can do things, right? (I'm wondering if we somehow manage to spend all our time trying to service the GUI and no time making forward progress in the guest, though I don't have a clear idea in mind of why this would be so or why this change would make things worse, except that presumably we now do more full-screen-invalidates.)
-- PMM
Re: [Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
Quoted 4 lines · Peter Maydell
(I'm wondering if we somehow manage to spend all our time trying to service the GUI and no time making forward progress in the guest, though I don't have a clear idea in mind of why this would be so
Perhaps because Xlib calls (and hence GTK+ calls) are blocking?
Quoted 3 lines
or why this change would
make things worse, except that presumably we now do more full-screen-invalidates.)
Yes, then it makes sense for this patch to make a difference. VNC does dirty rectangles and has multithreading, but GTK+ doesn't do either.
You can just add a memory_region_set_log call for the integratorcp and versatilepb RAM regions.
Paolo
Re: [Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
Quoted 8 lines · Paolo Bonzini
Quoted 4 lines · Peter Maydell
(I'm wondering if we somehow manage to spend all our time trying to service the GUI and no time making forward progress in the guest, though I don't have a clear idea in mind of why this would be so
Quoted 8 lines
Perhaps because Xlib calls (and hence GTK+ calls) are blocking?
Quoted 3 lines
or why this change would
make things worse, except that presumably we now do more full-screen-invalidates.)Yes, then it makes sense for this patch to make a difference. VNC does dirty rectangles and has multithreading, but GTK+ doesn't do either.
Yes, that would make sense. But why do we need to do more full invalidates now?
Quoted 2 lines
You can just add a
memory_region_set_logcall for the integratorcp and versatilepb RAM regions.
It seems a bit of a shame that we basically broke previously working configs for all our boards with embedded framebuffer in RAM :-(
-- PMM
Re: [Qemu-devel] [PULL 12/62] framebuffer: check memory_region_is_logging
Quoted 2 lines · Peter Maydell
Yes, that would make sense. But why do we need to do more full invalidates now?
Because the board doesn't call memory_region_set_log.
Quoted 6 lines
Quoted 2 lines
You can just add a
memory_region_set_logcall for the integratorcp and versatilepb RAM regions.It seems a bit of a shame that we basically broke previously working configs for all our boards with embedded framebuffer in RAM :-(
They are not broken, just less efficient. But it's easy to fix; I'll prepare the patch to add memory_region_set_log.
Paolo
[Qemu-devel] [PULL 14/62] memory: track DIRTY_MEMORY_CODE in mr->dirty_log_mask
In reply to Paolo BonziniDIRTY_MEMORY_CODE is only needed for TCG. By adding it directly to mr->dirty_log_mask, we avoid testing for TCG everywhere a region is checked for the enabled/disabled state of dirty logging.
--- include/exec/memory.h | 4 ++-- memory.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)
include/exec/memory.h +2 -2
@@ -604,8 +604,8 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8_t client);* memory_region_get_dirty_log_mask: return the clients for which a * memory region is logging writes. * -* Returns a bitmap of clients, which right now will be either 0 or -* (1 << DIRTY_MEMORY_VGA). +* Returns a bitmap of clients, in which the DIRTY_MEMORY_* constants +* are the bit indices. * * @mr: the memory region being queried */
memory.c +4 -0
@@ -1212,6 +1212,7 @@ void memory_region_init_ram(MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr =qemu_ram_alloc (size, mr, errp); + mr->dirty_log_mask =tcg_enabled () ? (1 <<DIRTY_MEMORY_CODE ) :0 ; } void memory_region_init_resizeable_ram(MemoryRegion *mr,
@@ -1229,6 +1230,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr =qemu_ram_alloc_resizeable (size, max_size, resized, mr, errp); + mr->dirty_log_mask =tcg_enabled () ? (1 <<DIRTY_MEMORY_CODE ) :0 ; }#ifdef __linux__
@@ -1245,6 +1247,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr =qemu_ram_alloc_from_file (size, mr, share, path, errp); + mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; }#endif
@@ -1258,6 +1261,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr, mr->ram = true; mr->terminates = true; mr->destructor = memory_region_destructor_ram_from_ptr; + mr->dirty_log_mask =tcg_enabled () ? (1 <<DIRTY_MEMORY_CODE ) :0 ;/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */ assert (ptr !=NULL );
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 13/62] ui/console: remove dpy_gfx_update_dirty
In reply to Paolo Bonzinidpy_gfx_update_dirty expects DIRTY_MEMORY_VGA logging to be always on, but that will not be the case soon. Because it computes the memory region on the fly for every update (with memory_region_find), it cannot enable/disable logging by itself.
We could always treat updates as invalidations if dirty logging is not enabled, assuming that the board will enable logging on the RAM region that includes the framebuffer.
However, the function is unused, so just drop it.
--- include/ui/console.h | 4 ---- ui/console.c | 61 ---------------------------------------------------- 2 files changed, 65 deletions(-)
include/ui/console.h +0 -4
@@ -241,10 +241,6 @@ void dpy_text_resize(QemuConsole *con, int w, int h);void dpy_mouse_set (QemuConsole *con,int x,int y,int on);void dpy_cursor_define (QemuConsole *con,QEMUCursor *cursor);bool dpy_cursor_define_supported (QemuConsole *con); -void dpy_gfx_update_dirty (QemuConsole *con, -MemoryRegion *address_space, -uint64_t base, -bool invalidate);bool dpy_gfx_check_format (QemuConsole *con,pixman_format_code_t format);
ui/console.c +0 -61
67 lines not on this page · raw message
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 15/62] kvm: accept non-mapped memory in kvm_dirty_pages_log_change
In reply to Paolo BonziniIt is okay if memory is not mapped into the guest but has dirty logging enabled. When this happens, KVM will not do anything and only accesses from the host will be logged.
This can be triggered by iofuzz.
--- kvm-all.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kvm-all.c +3 -5
@@ -335,12 +335,10 @@ static int kvm_dirty_pages_log_change(hwaddr phys_addr,KVMSlot *mem =kvm_lookup_matching_slot (s, phys_addr, phys_addr + size);if (mem ==NULL ) { -fprintf (stderr,"BUG: %s: invalid parameters " TARGET_FMT_plx"-" - TARGET_FMT_plx"\n" , __func__, phys_addr, - (hwaddr)(phys_addr + size -1 )); -return -EINVAL ; +return 0 ; + }else { +return kvm_slot_dirty_pages_log_change (mem, log_dirty); } -return kvm_slot_dirty_pages_log_change (mem, log_dirty); } static void kvm_log_start(MemoryListener *listener,
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 16/62] memory: include DIRTY_MEMORY_MIGRATION in the dirty log mask
In reply to Paolo BonziniThe separate handling of DIRTY_MEMORY_MIGRATION, which does not call log_start/log_stop callbacks when it changes in a region's dirty logging mask, has caused several bugs.
One recent example is commit 4cc856f (kvm-all: Sync dirty-bitmap from kvm before kvm destroy the corresponding dirty_bitmap, 2015-04-02). Another performance problem is that KVM keeps tracking dirty pages after a failed live migration, which causes bad performance due to disallowing huge page mapping.
This patch removes the root cause of the problem by reporting DIRTY_MEMORY_MIGRATION changes via log_start and log_stop. Note that we now have to rebuild the FlatView when global dirty logging is enabled or disabled; this ensures that log_start and log_stop callbacks are invoked.
This will also be used to make the setting of bitmaps conditional. In general, this patch lets users of the memory API ignore the global state of dirty logging if they handle dirty logging generically per region.
--- memory.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
memory.c +18 -2
@@ -588,7 +588,7 @@ static void render_memory_region(FlatView *view, remain = clip.size; fr.mr = mr; - fr.dirty_log_mask = mr->dirty_log_mask; + fr.dirty_log_mask =memory_region_get_dirty_log_mask (mr); fr.romd_mode = mr->romd_mode; fr.readonly = readonly;
@@ -1400,7 +1400,11 @@ bool memory_region_is_skip_dump(MemoryRegion *mr)uint8_t memory_region_get_dirty_log_mask (MemoryRegion *mr) { -return mr->dirty_log_mask; +uint8_t mask = mr->dirty_log_mask; +if (global_dirty_log) { + mask |= (1 <<DIRTY_MEMORY_MIGRATION ); + } +return mask; }bool memory_region_is_logging (MemoryRegion *mr,uint8_t client)
@@ -1962,12 +1966,24 @@ void address_space_sync_dirty_bitmap(AddressSpace *as)void memory_global_dirty_log_start (void ) { global_dirty_log = true; +MEMORY_LISTENER_CALL_GLOBAL (log_global_start, Forward); + +/* Refresh DIRTY_LOG_MIGRATION bit. */ +memory_region_transaction_begin (); + memory_region_update_pending = true; +memory_region_transaction_commit (); }void memory_global_dirty_log_stop (void ) { global_dirty_log = false; + +/* Refresh DIRTY_LOG_MIGRATION bit. */ +memory_region_transaction_begin (); + memory_region_update_pending = true; +memory_region_transaction_commit (); +MEMORY_LISTENER_CALL_GLOBAL (log_global_stop, Reverse); }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 17/62] kvm: remove special handling of DIRTY_MEMORY_MIGRATION in the dirty log mask
In reply to Paolo BonziniOne recent example is commit 4cc856f (kvm-all: Sync dirty-bitmap from kvm before kvm destroy the corresponding dirty_bitmap, 2015-04-02). Another performance problem is that KVM keeps tracking dirty pages after a failed live migration, which causes bad performance due to disallowing huge page mapping.
Thanks to the previous patch, KVM can now stop hooking into log_global_start/stop. This simplifies the KVM code noticeably.
--- kvm-all.c | 56 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 54 deletions(-)
kvm-all.c +2 -54
@@ -83,7 +83,6 @@ struct KVMStatestruct kvm_coalesced_mmio_ring *coalesced_mmio_ring;bool coalesced_flush_in_progress;int broken_set_mem_region; -int migration_log;int vcpu_events;int robust_singlestep;int debugregs;
@@ -234,9 +233,6 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot) mem.guest_phys_addr = slot->start_addr; mem.userspace_addr = (unsigned long )slot->ram; mem.flags = slot->flags; -if (s->migration_log) { - mem.flags |=KVM_MEM_LOG_DIRTY_PAGES ; - }if (slot->memory_size && mem.flags &KVM_MEM_READONLY ) {/* Set the slot size to 0 before setting the slot to the desired
@@ -317,10 +313,6 @@ static int kvm_slot_dirty_pages_log_change(KVMSlot *mem, bool log_dirty) mem->flags = flags;/* If nothing changed effectively, no need to issue ioctl */ -if (s->migration_log) { - flags |=KVM_MEM_LOG_DIRTY_PAGES ; - } -if (flags == old_flags) {return 0 ; }
@@ -375,31 +367,6 @@ static void kvm_log_stop(MemoryListener *listener, } } -static int kvm_set_migration_log (bool enable) -{ -KVMState *s = kvm_state; -KVMSlot *mem; -int i, err; - - s->migration_log = enable; - -for (i =0 ; i < s->nr_slots; i++) { - mem = &s->slots[i]; - -if (!mem->memory_size) { -continue ; - } -if (!!(mem->flags &KVM_MEM_LOG_DIRTY_PAGES ) == enable) { -continue ; - } - err =kvm_set_user_memory_region (s, mem); -if (err) { -return err; - } - } -return 0 ; -} -/* get kvm's dirty pages bitmap and update qemu's */ static int kvm_get_dirty_pages_log_range (MemoryRegionSection *section,unsigned long *bitmap)
@@ -671,8 +638,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add)KVMSlot *mem, old;int err;MemoryRegion *mr = section->mr; -bool log_dirty = -memory_region_get_dirty_log_mask (mr) & ~(1 <<DIRTY_MEMORY_MIGRATION ); +bool log_dirty =memory_region_get_dirty_log_mask (mr) !=0 ;bool writeable = !mr->readonly && !mr->rom_device;bool readonly_flag = mr->readonly ||memory_region_is_romd (mr);hwaddr start_addr = section->offset_within_address_space;
@@ -724,7 +690,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add) old = *mem; -if ((mem->flags &KVM_MEM_LOG_DIRTY_PAGES ) || s->migration_log) { +if (mem->flags &KVM_MEM_LOG_DIRTY_PAGES ) {kvm_physical_sync_dirty_bitmap (section); }
@@ -853,22 +819,6 @@ static void kvm_log_sync(MemoryListener *listener, } } -static void kvm_log_global_start (struct MemoryListener *listener) -{ -int r; - - r =kvm_set_migration_log (1 ); -assert (r >=0 ); -} - -static void kvm_log_global_stop (struct MemoryListener *listener) -{ -int r; - - r =kvm_set_migration_log (0 ); -assert (r >=0 ); -} - static void kvm_mem_ioeventfd_add(MemoryListener *listener, MemoryRegionSection *section, bool match_data, uint64_t data,
@@ -944,8 +894,6 @@ static MemoryListener kvm_memory_listener = { .log_start = kvm_log_start, .log_stop = kvm_log_stop, .log_sync = kvm_log_sync, - .log_global_start = kvm_log_global_start, - .log_global_stop = kvm_log_global_stop, .eventfd_add = kvm_mem_ioeventfd_add, .eventfd_del = kvm_mem_ioeventfd_del, .coalesced_mmio_add = kvm_coalesce_mmio_region,
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 19/62] exec: use memory_region_get_dirty_log_mask to optimize dirty tracking
In reply to Paolo BonziniThe memory API can now return the exact set of bitmaps that have to be tracked. Use it instead of the in_migration variable.
In the next patches, we will also use it to set only DIRTY_MEMORY_VGA or DIRTY_MEMORY_MIGRATION if necessary. This can make a difference for dataplane, especially after the dirty bitmap is changed to use more expensive atomic operations.
Of some interest is the change to stl_phys_notdirty. When migration was introduced, stl_phys_notdirty was changed to effectively behave as stl_phys during migration. In fact, if one looks at the function as it was in the beginning (commit 8df1cd0, physical memory access functions, 2005-01-28), at the time the dirty bitmap was the equivalent of DIRTY_MEMORY_CODE nowadays; hence, the function simply should not touch the dirty code bits. This patch changes it to do the intended thing.
--- exec.c | 59 +++++++++++++++++++---------------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-)
exec.c +19 -40
@@ -59,8 +59,6 @@//#define DEBUG_SUBPAGE #if !defined(CONFIG_USER_ONLY ) -static bool in_migration; -/* ram_list is read under rcu_read_lock()/rcu_read_unlock(). Writes * are protected by the ramlist lock. */
@@ -866,11 +864,6 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length, } } -static void cpu_physical_memory_set_dirty_tracking (bool enable) -{ - in_migration = enable; -} -/* Called from RCU critical section */ hwaddr memory_region_section_get_iotlb(CPUState *cpu, MemoryRegionSection *section,
@@ -2161,22 +2154,6 @@ static void tcg_commit(MemoryListener *listener) } } -static void core_log_global_start (MemoryListener *listener) -{ -cpu_physical_memory_set_dirty_tracking (true); -} - -static void core_log_global_stop (MemoryListener *listener) -{ -cpu_physical_memory_set_dirty_tracking (false); -} - -static MemoryListener core_memory_listener = { - .log_global_start = core_log_global_start, - .log_global_stop = core_log_global_stop, - .priority =1 , -}; -void address_space_init_dispatch (AddressSpace *as) { as->dispatch =NULL ;
@@ -2216,8 +2193,6 @@ static void memory_map_init(void)memory_region_init_io (system_io,NULL , &unassigned_io_ops,NULL ,"io" ,65536 );address_space_init (&address_space_io, system_io,"I/O" ); - -memory_listener_register (&core_memory_listener, &address_space_memory); }MemoryRegion *get_system_memory (void )
@@ -2275,12 +2250,18 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,#else -static void invalidate_and_set_dirty (hwaddr addr, +static void invalidate_and_set_dirty (MemoryRegion *mr,hwaddr addr,hwaddr length) {if (cpu_physical_memory_range_includes_clean (addr, length)) { -tb_invalidate_phys_range (addr, addr + length,0 ); -cpu_physical_memory_set_dirty_range_nocode (addr, length); +uint8_t dirty_log_mask =memory_region_get_dirty_log_mask (mr); +if (dirty_log_mask & (1 <<DIRTY_MEMORY_CODE )) { +tb_invalidate_phys_range (addr, addr + length,0 ); + dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); + } +if (dirty_log_mask) { +cpu_physical_memory_set_dirty_range_nocode (addr, length); + } }else {xen_modified_memory (addr, length); }
@@ -2368,7 +2349,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,/* RAM case */ ptr =qemu_get_ram_ptr (addr1);memcpy (ptr, buf, l); -invalidate_and_set_dirty (addr1, l); +invalidate_and_set_dirty (mr, addr1, l); } }else {if (!memory_access_is_direct (mr, is_write)) {
@@ -2465,7 +2446,7 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as,switch (type) {case WRITE_DATA :memcpy (ptr, buf, l); -invalidate_and_set_dirty (addr1, l); +invalidate_and_set_dirty (mr, addr1, l);break ;case FLUSH_CACHE :flush_icache_range ((uintptr_t )ptr, (uintptr_t )ptr + l);
@@ -2690,7 +2671,7 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, mr =qemu_ram_addr_from_host (buffer, &addr1);assert (mr !=NULL );if (is_write) { -invalidate_and_set_dirty (addr1, access_len); +invalidate_and_set_dirty (mr, addr1, access_len); }if (xen_enabled ()) {xen_invalidate_map_cache_entry (buffer);
@@ -3019,6 +3000,7 @@ void address_space_stl_notdirty(AddressSpace *as, hwaddr addr, uint32_t val,hwaddr l =4 ;hwaddr addr1;MemTxResult r; +uint8_t dirty_log_mask;rcu_read_lock (); mr = address_space_translate(as, addr, &addr1, &l,
@@ -3030,13 +3012,10 @@ void address_space_stl_notdirty(AddressSpace *as, hwaddr addr, uint32_t val, ptr =qemu_get_ram_ptr (addr1);stl_p (ptr, val); -if (unlikely (in_migration)) { -if (cpu_physical_memory_is_clean (addr1)) { -/* invalidate code */ -tb_invalidate_phys_page_range (addr1, addr1 +4 ,0 ); -/* set dirty bit */ -cpu_physical_memory_set_dirty_range_nocode (addr1,4 ); - } + dirty_log_mask =memory_region_get_dirty_log_mask (mr); + dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); +if (dirty_log_mask) { +cpu_physical_memory_set_dirty_range_nocode (addr1,4 ); } r =MEMTX_OK ; }
@@ -3093,7 +3072,7 @@ static inline void address_space_stl_internal(AddressSpace *as,stl_p (ptr, val);break ; } -invalidate_and_set_dirty (addr1,4 ); +invalidate_and_set_dirty (mr, addr1,4 ); r =MEMTX_OK ; }if (result) {
@@ -3197,7 +3176,7 @@ static inline void address_space_stw_internal(AddressSpace *as,stw_p (ptr, val);break ; } -invalidate_and_set_dirty (addr1,2 ); +invalidate_and_set_dirty (mr, addr1,2 ); r =MEMTX_OK ; }if (result) {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 20/62] exec: move functions to translate-all.h
In reply to Paolo BonziniRemove them from the sundry exec-all.h header, since they are only used by the TCG runtime in exec.c and user-exec.c.
--- include/exec/exec-all.h | 6 +----- linux-user/mmap.c | 1 + translate-all.h | 8 ++++++++ user-exec.c | 1 + 4 files changed, 11 insertions(+), 5 deletions(-)
include/exec/exec-all.h +1 -5
@@ -90,11 +90,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, int cflags);void cpu_exec_init (CPUArchState *env); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); -int page_unprotect (target_ulong address,uintptr_t pc,void *puc); -void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end, -int is_cpu_write_access); -void tb_invalidate_phys_range (tb_page_addr_t start,tb_page_addr_t end, -int is_cpu_write_access); +#if !defined(CONFIG_USER_ONLY )bool qemu_in_vcpu_thread (void );void cpu_reload_memory_map (CPUState *cpu);
linux-user/mmap.c +1 -0
@@ -30,6 +30,7 @@#include "qemu.h" #include "qemu-common.h" +#include "translate-all.h" //#define DEBUG_MMAP
translate-all.h +8 -0
@@ -21,6 +21,14 @@/* translate-all.c */ void tb_invalidate_phys_page_fast (tb_page_addr_t start,int len); +void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end, +int is_cpu_write_access); +void tb_invalidate_phys_range (tb_page_addr_t start,tb_page_addr_t end, +int is_cpu_write_access);void tb_check_watchpoint (CPUState *cpu); +#ifdef CONFIG_USER_ONLY +int page_unprotect (target_ulong address,uintptr_t pc,void *puc); +#endif +#endif /* TRANSLATE_ALL_H */
user-exec.c +1 -0
@@ -22,6 +22,7 @@#include "tcg.h" #include "qemu/bitops.h" #include "exec/cpu_ldst.h" +#include "translate-all.h" #undef EAX#undef ECX
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 18/62] ram_addr: tweaks to xen_modified_memory
In reply to Paolo BonziniInvoke xen_modified_memory from cpu_physical_memory_set_dirty_range_nocode; it is akin to DIRTY_MEMORY_MIGRATION, so set it together with that bitmap. The remaining call from invalidate_and_set_dirty's "else" branch will go away soon.
Second, fix the second argument to the function in the cpu_physical_memory_set_dirty_lebitmap call site. That function is only used by KVM, but it is better to be clean anyway.
--- exec.c | 3 ++- include/exec/ram_addr.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
exec.c +2 -1
@@ -2281,8 +2281,9 @@ static void invalidate_and_set_dirty(hwaddr addr,if (cpu_physical_memory_range_includes_clean (addr, length)) {tb_invalidate_phys_range (addr, addr + length,0 );cpu_physical_memory_set_dirty_range_nocode (addr, length); + }else { +xen_modified_memory (addr, length); } -xen_modified_memory (addr, length); }static int memory_access_size (MemoryRegion *mr,unsigned l,hwaddr addr)
include/exec/ram_addr.h +2 -1
@@ -112,6 +112,7 @@ static inline void cpu_physical_memory_set_dirty_range_nocode(ram_addr_t start, page = start >>TARGET_PAGE_BITS ;bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ], page, end - page);bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_VGA ], page, end - page); +xen_modified_memory (start, length); } static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
@@ -155,7 +156,7 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, ram_list.dirty_memory[DIRTY_MEMORY_CODE ][page + k] |= temp; } } -xen_modified_memory (start, pages); +xen_modified_memory (start, pages <<TARGET_PAGE_BITS ); }else {/* * bitmap-traveling is faster than memory-traveling (for addr...)
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 21/62] translate-all: remove unnecessary argument to tb_invalidate_phys_range
In reply to Paolo BonziniThe is_cpu_write_access argument is always 0, remove it.
--- exec.c | 2 +- linux-user/mmap.c | 6 +++--- translate-all.c | 5 ++--- translate-all.h | 3 +-- 4 files changed, 7 insertions(+), 9 deletions(-)
exec.c +1 -1
@@ -2256,7 +2256,7 @@ static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr,if (cpu_physical_memory_range_includes_clean (addr, length)) {uint8_t dirty_log_mask =memory_region_get_dirty_log_mask (mr);if (dirty_log_mask & (1 <<DIRTY_MEMORY_CODE )) { -tb_invalidate_phys_range (addr, addr + length,0 ); +tb_invalidate_phys_range (addr, addr + length); dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); }if (dirty_log_mask) {
linux-user/mmap.c +3 -3
@@ -575,7 +575,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,page_dump (stdout);printf ("\n" );#endif -tb_invalidate_phys_range (start, start + len,0 ); +tb_invalidate_phys_range (start, start + len);mmap_unlock ();return start; fail:
@@ -680,7 +680,7 @@ int target_munmap(abi_ulong start, abi_ulong len)if (ret ==0 ) {page_set_flags (start, start + len,0 ); -tb_invalidate_phys_range (start, start + len,0 ); +tb_invalidate_phys_range (start, start + len); }mmap_unlock ();return ret;
@@ -759,7 +759,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,page_set_flags (old_addr, old_addr + old_size,0 );page_set_flags (new_addr, new_addr + new_size, prot |PAGE_VALID ); } -tb_invalidate_phys_range (new_addr, new_addr + new_size,0 ); +tb_invalidate_phys_range (new_addr, new_addr + new_size);mmap_unlock ();return new_addr; }
translate-all.c +2 -3
@@ -1042,11 +1042,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu,* access: the virtual CPU will exit the current TB if code is modified inside * this TB. */ -void tb_invalidate_phys_range (tb_page_addr_t start,tb_page_addr_t end, -int is_cpu_write_access) +void tb_invalidate_phys_range (tb_page_addr_t start,tb_page_addr_t end) {while (start < end) { -tb_invalidate_phys_page_range (start, end, is_cpu_write_access); +tb_invalidate_phys_page_range (start, end,0 ); start &=TARGET_PAGE_MASK ; start +=TARGET_PAGE_SIZE ; }
translate-all.h +1 -2
@@ -23,8 +23,7 @@void tb_invalidate_phys_page_fast (tb_page_addr_t start,int len);void tb_invalidate_phys_page_range (tb_page_addr_t start,tb_page_addr_t end,int is_cpu_write_access); -void tb_invalidate_phys_range (tb_page_addr_t start,tb_page_addr_t end, -int is_cpu_write_access); +void tb_invalidate_phys_range (tb_page_addr_t start,tb_page_addr_t end);void tb_check_watchpoint (CPUState *cpu);#ifdef CONFIG_USER_ONLY
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 22/62] cputlb: remove useless arguments to tlb_unprotect_code_phys, rename
In reply to Paolo BonziniThese days modification of the TLB is done in notdirty_mem_write, so the virtual address and env pointer as unnecessary.
The new name of the function, tlb_unprotect_code, is consistent with tlb_protect_code.
--- cputlb.c | 3 +-- include/exec/cputlb.h | 3 +-- translate-all.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
cputlb.c +1 -2
@@ -131,8 +131,7 @@ void tlb_protect_code(ram_addr_t ram_addr)/* update the TLB so that writes in physical page 'phys_addr' are no longer tested for self modifying code */ -void tlb_unprotect_code_phys (CPUState *cpu,ram_addr_t ram_addr, -target_ulong vaddr) +void tlb_unprotect_code (ram_addr_t ram_addr) {cpu_physical_memory_set_dirty_flag (ram_addr,DIRTY_MEMORY_CODE ); }
include/exec/cputlb.h +1 -2
@@ -22,8 +22,7 @@#if !defined(CONFIG_USER_ONLY )/* cputlb.c */ void tlb_protect_code (ram_addr_t ram_addr); -void tlb_unprotect_code_phys (CPUState *cpu,ram_addr_t ram_addr, -target_ulong vaddr); +void tlb_unprotect_code (ram_addr_t ram_addr);void tlb_reset_dirty_range (CPUTLBEntry *tlb_entry,uintptr_t start,uintptr_t length);void cpu_tlb_reset_dirty_all (ram_addr_t start1,ram_addr_t length);
translate-all.c +1 -1
@@ -1158,7 +1158,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,if (!p->first_tb) {invalidate_page_bitmap (p);if (is_cpu_write_access) { -tlb_unprotect_code_phys (cpu, start, cpu->mem_io_vaddr); +tlb_unprotect_code (start); } }#endif
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 24/62] exec: pass client mask to cpu_physical_memory_set_dirty_range
In reply to Paolo BonziniThis cuts in half the cost of bitmap operations (which will become more expensive when made atomic) during migration on non-VRAM regions.
--- exec.c | 20 +++++++++++--------- include/exec/ram_addr.h | 33 ++++++++++++++++----------------- memory.c | 3 ++- 3 files changed, 29 insertions(+), 27 deletions(-)
exec.c +11 -9
@@ -1351,7 +1351,8 @@ int qemu_ram_resize(ram_addr_t base, ram_addr_t newsize, Error **errp)cpu_physical_memory_clear_dirty_range (block->offset, block->used_length); block->used_length = newsize; -cpu_physical_memory_set_dirty_range (block->offset, block->used_length); +cpu_physical_memory_set_dirty_range (block->offset, block->used_length, +DIRTY_CLIENTS_ALL );memory_region_set_size (block->mr, newsize);if (block->resized) { block->resized (block->idstr, newsize, block->host);
@@ -1425,7 +1426,8 @@ static ram_addr_t ram_block_add(RAMBlock *new_block, Error **errp) } }cpu_physical_memory_set_dirty_range (new_block->offset, - new_block->used_length); + new_block->used_length, +DIRTY_CLIENTS_ALL );if (new_block->host) {qemu_ram_setup_dump (new_block->host, new_block->max_length);
@@ -1813,7 +1815,11 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,default :abort (); } -cpu_physical_memory_set_dirty_range_nocode (ram_addr, size); +/* Set both VGA and migration bits for simplicity and to remove +* the notdirty callback faster. +*/ +cpu_physical_memory_set_dirty_range (ram_addr, size, +DIRTY_CLIENTS_NOCODE );/* we remove the notdirty callback only if the code has been flushed */ if (!cpu_physical_memory_is_clean (ram_addr)) {
@@ -2259,9 +2265,7 @@ static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr,tb_invalidate_phys_range (addr, addr + length); dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); } -if (dirty_log_mask) { -cpu_physical_memory_set_dirty_range_nocode (addr, length); - } +cpu_physical_memory_set_dirty_range (addr, length, dirty_log_mask); }else {xen_modified_memory (addr, length); }
@@ -3014,9 +3018,7 @@ void address_space_stl_notdirty(AddressSpace *as, hwaddr addr, uint32_t val, dirty_log_mask =memory_region_get_dirty_log_mask (mr); dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); -if (dirty_log_mask) { -cpu_physical_memory_set_dirty_range_nocode (addr1,4 ); - } +cpu_physical_memory_set_dirty_range (addr1,4 , dirty_log_mask); r =MEMTX_OK ; }if (result) {
include/exec/ram_addr.h +16 -17
@@ -41,6 +41,9 @@ void qemu_ram_free_from_ptr(ram_addr_t addr);int qemu_ram_resize (ram_addr_t base,ram_addr_t newsize,Error **errp); +#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) +#define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) +static inline bool cpu_physical_memory_get_dirty (ram_addr_t start,ram_addr_t length,unsigned client)
@@ -103,28 +106,23 @@ static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,set_bit (addr >>TARGET_PAGE_BITS , ram_list.dirty_memory[client]); } -static inline void cpu_physical_memory_set_dirty_range_nocode (ram_addr_t start, -ram_addr_t length) -{ -unsigned long end, page; - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ], page, end - page); -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_VGA ], page, end - page); -xen_modified_memory (start, length); -} -static inline void cpu_physical_memory_set_dirty_range (ram_addr_t start, -ram_addr_t length) +ram_addr_t length, +uint8_t mask) {unsigned long end, page; end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; page = start >>TARGET_PAGE_BITS ; -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ], page, end - page); -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_VGA ], page, end - page); -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_CODE ], page, end - page); +if (likely (mask & (1 <<DIRTY_MEMORY_MIGRATION ))) { +bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ], page, end - page); + } +if (unlikely (mask & (1 <<DIRTY_MEMORY_VGA ))) { +bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_VGA ], page, end - page); + } +if (unlikely (mask & (1 <<DIRTY_MEMORY_CODE ))) { +bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_CODE ], page, end - page); + }xen_modified_memory (start, length); }
@@ -172,7 +170,8 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, addr = page_number *TARGET_PAGE_SIZE ; ram_addr = start + addr;cpu_physical_memory_set_dirty_range (ram_addr, -TARGET_PAGE_SIZE * hpratio); +TARGET_PAGE_SIZE * hpratio, +DIRTY_CLIENTS_ALL ); }while (c !=0 ); } }
memory.c +2 -1
@@ -1461,7 +1461,8 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size) {assert (mr->terminates); -cpu_physical_memory_set_dirty_range (mr->ram_addr + addr, size); +cpu_physical_memory_set_dirty_range (mr->ram_addr + addr, size, +memory_region_get_dirty_log_mask (mr)); } bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr,
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 23/62] translate-all: make less of tb_invalidate_phys_page_range depend on is_cpu_write_access
In reply to Paolo Bonziniis_cpu_write_access is only set if tb_invalidate_phys_page_range is called from tb_invalidate_phys_page_fast, and hence from notdirty_mem_write. However:
- the code bitmap can be built directly in tb_invalidate_phys_page_fast (unconditionally, since is_cpu_write_access would always be passed as 1);
- the virtual address is not needed to mark the page as "not containing code" (dirty code bitmap = 1), so we can also remove that use of is_cpu_write_access. For calls of tb_invalidate_phys_page_range that do not come from notdirty_mem_write, the next call to notdirty_mem_write will notice that the page does not contain code anymore, and will fix up the TLB entry.
The parameter needs to remain in order to guard accesses to cpu->mem_io_pc.
--- translate-all.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
translate-all.c +6 -9
@@ -1082,12 +1082,6 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,if (!p) {return ; } -if (!p->code_bitmap && - ++p->code_write_count >=SMC_BITMAP_USE_THRESHOLD && - is_cpu_write_access) { -/* build code bitmap */ -build_page_bitmap (p); - }#if defined(TARGET_HAS_PRECISE_SMC )if (cpu !=NULL ) { env = cpu->env_ptr;
@@ -1157,9 +1151,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,/* if no code remaining, no need to continue to use slow writes */ if (!p->first_tb) {invalidate_page_bitmap (p); -if (is_cpu_write_access) { -tlb_unprotect_code (start); - } +tlb_unprotect_code (start); }#endif #ifdef TARGET_HAS_PRECISE_SMC
@@ -1192,6 +1184,11 @@ void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len)if (!p) {return ; } +if (!p->code_bitmap && + ++p->code_write_count >=SMC_BITMAP_USE_THRESHOLD ) { +/* build code bitmap */ +build_page_bitmap (p); + }if (p->code_bitmap) {unsigned int nr;unsigned long b;
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 25/62] exec: invert return value of cpu_physical_memory_get_clean, rename
In reply to Paolo BonziniWhile it is obvious that cpu_physical_memory_get_dirty returns true even if a single page is dirty, the same is not true for cpu_physical_memory_get_clean; one would expect that it returns true only if all the pages are clean, but it actually looks for even one clean page. (By contrast, the caller of that function, cpu_physical_memory_range_includes_clean, has a good name).
To clarify, rename the function to cpu_physical_memory_all_dirty and return true if _all_ the pages are dirty. This is the opposite of the previous meaning, because "all are 1" is the same as "not (any is 0)", so we have to modify cpu_physical_memory_range_includes_clean as well.
--- include/exec/ram_addr.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
include/exec/ram_addr.h +5 -5
@@ -59,7 +59,7 @@ static inline bool cpu_physical_memory_get_dirty(ram_addr_t start,return next < end; } -static inline bool cpu_physical_memory_get_clean (ram_addr_t start, +static inline bool cpu_physical_memory_all_dirty (ram_addr_t start,ram_addr_t length,unsigned client) {
@@ -71,7 +71,7 @@ static inline bool cpu_physical_memory_get_clean(ram_addr_t start, page = start >>TARGET_PAGE_BITS ; next =find_next_zero_bit (ram_list.dirty_memory[client], end, page); -return next < end; +return next >= end; } static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
@@ -92,10 +92,10 @@ static inline bool cpu_physical_memory_is_clean(ram_addr_t addr)static inline bool cpu_physical_memory_range_includes_clean (ram_addr_t start,ram_addr_t length) { -bool vga =cpu_physical_memory_get_clean (start, length,DIRTY_MEMORY_VGA ); -bool code =cpu_physical_memory_get_clean (start, length,DIRTY_MEMORY_CODE ); +bool vga = !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA ); +bool code = !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE );bool migration = -cpu_physical_memory_get_clean (start, length,DIRTY_MEMORY_MIGRATION ); + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION );return vga || code || migration; }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 26/62] exec: only check relevant bitmaps for cleanliness
In reply to Paolo BonziniMost of the time, not all bitmaps have to be marked as dirty; do not do anything if the interesting ones are already dirty. Previously, any clean bitmap would have cause all the bitmaps to be marked dirty.
In fact, unless running TCG most of the time bitmap operations need not be done at all, because memory_region_is_logging returns zero. In this case, skip the call to cpu_physical_memory_range_includes_clean altogether as well.
With this patch, cpu_physical_memory_set_dirty_range is called unconditionally, so there need not be anymore a separate call to xen_modified_memory.
--- exec.c | 22 +++++++++++++--------- include/exec/ram_addr.h | 25 ++++++++++++++++++------- 2 files changed, 31 insertions(+), 16 deletions(-)
exec.c +13 -9
@@ -2259,16 +2259,20 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,static void invalidate_and_set_dirty (MemoryRegion *mr,hwaddr addr,hwaddr length) { -if (cpu_physical_memory_range_includes_clean (addr, length)) { -uint8_t dirty_log_mask =memory_region_get_dirty_log_mask (mr); -if (dirty_log_mask & (1 <<DIRTY_MEMORY_CODE )) { -tb_invalidate_phys_range (addr, addr + length); - dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); - } -cpu_physical_memory_set_dirty_range (addr, length, dirty_log_mask); - }else { -xen_modified_memory (addr, length); +uint8_t dirty_log_mask =memory_region_get_dirty_log_mask (mr); +/* No early return if dirty_log_mask is or becomes 0, because +* cpu_physical_memory_set_dirty_range will still call +* xen_modified_memory. +*/ +if (dirty_log_mask) { + dirty_log_mask = +cpu_physical_memory_range_includes_clean (addr, length, dirty_log_mask); + } +if (dirty_log_mask & (1 <<DIRTY_MEMORY_CODE )) { +tb_invalidate_phys_range (addr, addr + length); + dirty_log_mask &= ~(1 <<DIRTY_MEMORY_CODE ); } +cpu_physical_memory_set_dirty_range (addr, length, dirty_log_mask); }static int memory_access_size (MemoryRegion *mr,unsigned l,hwaddr addr)
include/exec/ram_addr.h +18 -7
@@ -89,14 +89,25 @@ static inline bool cpu_physical_memory_is_clean(ram_addr_t addr)return !(vga && code && migration); } -static inline bool cpu_physical_memory_range_includes_clean (ram_addr_t start, -ram_addr_t length) +static inline uint8_t cpu_physical_memory_range_includes_clean (ram_addr_t start, +ram_addr_t length, +uint8_t mask) { -bool vga = !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA ); -bool code = !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE ); -bool migration = - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION ); -return vga || code || migration; +uint8_t ret =0 ; + +if (mask & (1 <<DIRTY_MEMORY_VGA ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA )) { + ret |= (1 <<DIRTY_MEMORY_VGA ); + } +if (mask & (1 <<DIRTY_MEMORY_CODE ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE )) { + ret |= (1 <<DIRTY_MEMORY_CODE ); + } +if (mask & (1 <<DIRTY_MEMORY_MIGRATION ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION )) { + ret |= (1 <<DIRTY_MEMORY_MIGRATION ); + } +return ret; } static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 27/62] memory: do not touch code dirty bitmap unless TCG is enabled
In reply to Paolo Bonzinicpu_physical_memory_set_dirty_lebitmap unconditionally syncs the DIRTY_MEMORY_CODE bitmap. This however is unused unless TCG is enabled.
--- include/exec/ram_addr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
include/exec/ram_addr.h +5 -3
@@ -162,11 +162,14 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ][page + k] |= temp; ram_list.dirty_memory[DIRTY_MEMORY_VGA ][page + k] |= temp; - ram_list.dirty_memory[DIRTY_MEMORY_CODE ][page + k] |= temp; +if (tcg_enabled ()) { + ram_list.dirty_memory[DIRTY_MEMORY_CODE ][page + k] |= temp; + } } }xen_modified_memory (start, pages <<TARGET_PAGE_BITS ); }else { +uint8_t clients =tcg_enabled () ?DIRTY_CLIENTS_ALL :DIRTY_CLIENTS_NOCODE ;/* * bitmap-traveling is faster than memory-traveling (for addr...) * especially when most of the memory is not dirty.
@@ -181,8 +184,7 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, addr = page_number *TARGET_PAGE_SIZE ; ram_addr = start + addr;cpu_physical_memory_set_dirty_range (ram_addr, -TARGET_PAGE_SIZE * hpratio, -DIRTY_CLIENTS_ALL ); +TARGET_PAGE_SIZE * hpratio, clients); }while (c !=0 ); } }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 28/62] bitmap: add atomic set functions
In reply to Paolo BonziniFrom: Stefan Hajnoczi <[email protected]>
Use atomic_or() for atomic bitmaps where several threads may set bits at the same time. This avoids the race condition between threads loading an element, bitwise ORing, and then storing the element.
When setting all bits in a word we can avoid atomic ops and instead just use an smp_mb() at the end.
Most bitmap users don't need atomicity so introduce new functions.
Message-Id: <[email protected]> [Avoid barrier in the single word case, use full barrier instead of write.
- Paolo]
--- include/qemu/bitmap.h | 2 ++ include/qemu/bitops.h | 14 ++++++++++++++ util/bitmap.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
include/qemu/bitmap.h +2 -0
@@ -39,6 +39,7 @@* bitmap_empty(src, nbits) Are all bits zero in *src? * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_set(dst, pos, nbits) Set specified bit area +* bitmap_set_atomic(dst, pos, nbits) Set specified bit area with atomic ops * bitmap_clear(dst, pos, nbits) Clear specified bit area * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area */
@@ -226,6 +227,7 @@ static inline int bitmap_intersects(const unsigned long *src1, }void bitmap_set (unsigned long *map,long i,long len); +void bitmap_set_atomic (unsigned long *map,long i,long len);void bitmap_clear (unsigned long *map,long start,long nr); unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size,
include/qemu/bitops.h +14 -0
@@ -16,6 +16,7 @@#include <assert.h> #include "host-utils.h" +#include "atomic.h" #define BITS_PER_BYTE CHAR_BIT#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE)
@@ -39,6 +40,19 @@ static inline void set_bit(long nr, unsigned long *addr) }/** +* set_bit_atomic - Set a bit in memory atomically +* @nr: the bit to set +* @addr: the address to start counting from +*/ +static inline void set_bit_atomic (long nr,unsigned long *addr) +{ +unsigned long mask =BIT_MASK (nr); +unsigned long *p = addr +BIT_WORD (nr); + +atomic_or (p, mask); +} + +/** * clear_bit - Clears a bit in memory * @nr: Bit to clear * @addr: Address to start counting from
util/bitmap.c +38 -0
@@ -11,6 +11,7 @@#include "qemu/bitops.h" #include "qemu/bitmap.h" +#include "qemu/atomic.h" /* * bitmaps provide an array of bits, implemented using an an
@@ -177,6 +178,43 @@ void bitmap_set(unsigned long *map, long start, long nr) } } +void bitmap_set_atomic (unsigned long *map,long start,long nr) +{ +unsigned long *p = map +BIT_WORD (start); +const long size = start + nr; +int bits_to_set =BITS_PER_LONG - (start %BITS_PER_LONG ); +unsigned long mask_to_set =BITMAP_FIRST_WORD_MASK (start); + +/* First word */ +if (nr - bits_to_set >0 ) { +atomic_or (p, mask_to_set); + nr -= bits_to_set; + bits_to_set =BITS_PER_LONG ; + mask_to_set = ~0UL ; + p++; + } + +/* Full words */ +if (bits_to_set ==BITS_PER_LONG ) { +while (nr >=BITS_PER_LONG ) { + *p = ~0UL ; + nr -=BITS_PER_LONG ; + p++; + } + } + +/* Last word */ +if (nr) { + mask_to_set &=BITMAP_LAST_WORD_MASK (size); +atomic_or (p, mask_to_set); + }else { +/* If we avoided the full barrier in atomic_or(), issue a +* barrier to account for the assignments in the while loop. +*/ +smp_mb (); + } +} +void bitmap_clear (unsigned long *map,long start,long nr) {unsigned long *p = map +BIT_WORD (start);
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 29/62] bitmap: add atomic test and clear
In reply to Paolo BonziniFrom: Stefan Hajnoczi <[email protected]>
The new bitmap_test_and_clear_atomic() function clears a range and returns whether or not the bits were set.
Message-Id: <[email protected]> [Test before xchg; then a full barrier is needed at the end just like
in the previous patch. The barrier can be avoided if we did at least one xchg. - Paolo]
--- include/qemu/bitmap.h | 2 ++ util/bitmap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
include/qemu/bitmap.h +2 -0
@@ -41,6 +41,7 @@* bitmap_set(dst, pos, nbits) Set specified bit area * bitmap_set_atomic(dst, pos, nbits) Set specified bit area with atomic ops * bitmap_clear(dst, pos, nbits) Clear specified bit area +* bitmap_test_and_clear_atomic(dst, pos, nbits) Test and clear area * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area */
@@ -229,6 +230,7 @@ static inline int bitmap_intersects(const unsigned long *src1,void bitmap_set (unsigned long *map,long i,long len);void bitmap_set_atomic (unsigned long *map,long i,long len);void bitmap_clear (unsigned long *map,long start,long nr); +bool bitmap_test_and_clear_atomic (unsigned long *map,long start,long nr); unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start,
util/bitmap.c +45 -0
51 lines not on this page · raw message
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 30/62] memory: use atomic ops for setting dirty memory bits
In reply to Paolo BonziniFrom: Stefan Hajnoczi <[email protected]>
Use set_bit_atomic() and bitmap_set_atomic() so that multiple threads can dirty memory without race conditions.
Message-Id: <[email protected]>
--- include/exec/ram_addr.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
include/exec/ram_addr.h +9 -7
@@ -114,7 +114,7 @@ static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr, unsigned client) {assert (client <DIRTY_MEMORY_NUM ); -set_bit (addr >>TARGET_PAGE_BITS , ram_list.dirty_memory[client]); +set_bit_atomic (addr >>TARGET_PAGE_BITS , ram_list.dirty_memory[client]); } static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
@@ -122,17 +122,18 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, uint8_t mask) {unsigned long end, page; +unsigned long **d = ram_list.dirty_memory; end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; page = start >>TARGET_PAGE_BITS ;if (likely (mask & (1 <<DIRTY_MEMORY_MIGRATION ))) { -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ], page, end - page); +bitmap_set_atomic (d[DIRTY_MEMORY_MIGRATION ], page, end - page); }if (unlikely (mask & (1 <<DIRTY_MEMORY_VGA ))) { -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_VGA ], page, end - page); +bitmap_set_atomic (d[DIRTY_MEMORY_VGA ], page, end - page); }if (unlikely (mask & (1 <<DIRTY_MEMORY_CODE ))) { -bitmap_set (ram_list.dirty_memory[DIRTY_MEMORY_CODE ], page, end - page); +bitmap_set_atomic (d[DIRTY_MEMORY_CODE ], page, end - page); }xen_modified_memory (start, length); }
@@ -159,11 +160,12 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,for (k =0 ; k < nr; k++) {if (bitmap[k]) {unsigned long temp =leul_to_cpu (bitmap[k]); +unsigned long **d = ram_list.dirty_memory; - ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ][page + k] |= temp; - ram_list.dirty_memory[DIRTY_MEMORY_VGA ][page + k] |= temp; +atomic_or (&d[DIRTY_MEMORY_MIGRATION ][page + k], temp); +atomic_or (&d[DIRTY_MEMORY_VGA ][page + k], temp);if (tcg_enabled ()) { - ram_list.dirty_memory[DIRTY_MEMORY_CODE ][page + k] |= temp; +atomic_or (&d[DIRTY_MEMORY_CODE ][page + k], temp); } } }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 31/62] migration: move dirty bitmap sync to ram_addr.h
In reply to Paolo BonziniFrom: Stefan Hajnoczi <[email protected]>
The dirty memory bitmap is managed by ram_addr.h and copied to migration_bitmap[] periodically during live migration.
Move the code to sync the bitmap to ram_addr.h where related code lives.
Message-Id: <[email protected]>
--- arch_init.c | 46 ++-------------------------------------------- include/exec/ram_addr.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 44 deletions(-)
arch_init.c +2 -44
@@ -609,52 +609,10 @@ ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr,return (next - base) <<TARGET_PAGE_BITS ; } -static inline bool migration_bitmap_set_dirty (ram_addr_t addr) -{ -bool ret; -int nr = addr >>TARGET_PAGE_BITS ; - - ret =test_and_set_bit (nr, migration_bitmap); - -if (!ret) { - migration_dirty_pages++; - } -return ret; -} -static void migration_bitmap_sync_range (ram_addr_t start,ram_addr_t length) { -ram_addr_t addr; -unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); - -/* start address is aligned at the start of a word? */ -if (((page *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == start) { -int k; -int nr =BITS_TO_LONGS (length >>TARGET_PAGE_BITS ); -unsigned long *src = ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ]; - -for (k = page; k < page + nr; k++) { -if (src[k]) { -unsigned long new_dirty; - new_dirty = ~migration_bitmap[k]; - migration_bitmap[k] |= src[k]; - new_dirty &= src[k]; - migration_dirty_pages +=ctpopl (new_dirty); - src[k] =0 ; - } - } - }else { -for (addr =0 ; addr < length; addr +=TARGET_PAGE_SIZE ) { -if (cpu_physical_memory_get_dirty (start + addr, -TARGET_PAGE_SIZE , -DIRTY_MEMORY_MIGRATION )) { -cpu_physical_memory_reset_dirty (start + addr, -TARGET_PAGE_SIZE , -DIRTY_MEMORY_MIGRATION ); -migration_bitmap_set_dirty (start + addr); - } - } - } + migration_dirty_pages += +cpu_physical_memory_sync_dirty_bitmap (migration_bitmap, start, length); }
include/exec/ram_addr.h +44 -0
49 lines not on this page · raw message
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 33/62] memory: make cpu_physical_memory_sync_dirty_bitmap() fully atomic
In reply to Paolo BonziniFrom: Stefan Hajnoczi <[email protected]>
The fast path of cpu_physical_memory_sync_dirty_bitmap() directly manipulates the dirty bitmap. Use atomic_xchg() to make the test-and-clear atomic.
Message-Id: <[email protected]>
--- include/exec/ram_addr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/exec/ram_addr.h +3 -3
@@ -224,12 +224,12 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,for (k = page; k < page + nr; k++) {if (src[k]) { +unsigned long bits =atomic_xchg (&src[k],0 );unsigned long new_dirty; new_dirty = ~dest[k]; - dest[k] |= src[k]; - new_dirty &= src[k]; + dest[k] |= bits; + new_dirty &= bits; num_dirty +=ctpopl (new_dirty); - src[k] =0 ; } } }else {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 32/62] memory: replace cpu_physical_memory_reset_dirty() with test-and-clear
In reply to Paolo BonziniFrom: Stefan Hajnoczi <[email protected]>
The cpu_physical_memory_reset_dirty() function is sometimes used together with cpu_physical_memory_get_dirty(). This is not atomic since two separate accesses to the dirty memory bitmap are made.
Turn cpu_physical_memory_reset_dirty() and cpu_physical_memory_clear_dirty_range_type() into the atomic cpu_physical_memory_test_and_clear_dirty().
Message-Id: <[email protected]>
--- cputlb.c | 4 ++-- exec.c | 23 +++++++++++++++++------ include/exec/ram_addr.h | 33 ++++++++++----------------------- memory.c | 11 ++++------- 4 files changed, 33 insertions(+), 38 deletions(-)
cputlb.c +2 -2
@@ -125,8 +125,8 @@ void tlb_flush_page(CPUState *cpu, target_ulong addr)can be detected */ void tlb_protect_code (ram_addr_t ram_addr) { -cpu_physical_memory_reset_dirty (ram_addr,TARGET_PAGE_SIZE , -DIRTY_MEMORY_CODE ); +cpu_physical_memory_test_and_clear_dirty (ram_addr,TARGET_PAGE_SIZE , +DIRTY_MEMORY_CODE ); }/* update the TLB so that writes in physical page 'phys_addr' are no longer
exec.c +17 -6
@@ -852,16 +852,27 @@ static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length) }/* Note: start and end must be within the same ram block. */ -void cpu_physical_memory_reset_dirty (ram_addr_t start,ram_addr_t length, -unsigned client) +bool cpu_physical_memory_test_and_clear_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client) { -if (length ==0 ) -return ; -cpu_physical_memory_clear_dirty_range_type (start, length, client); +unsigned long end, page; +bool dirty; -if (tcg_enabled ()) { +if (length ==0 ) { +return false; + } + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + dirty =bitmap_test_and_clear_atomic (ram_list.dirty_memory[client], + page, end - page); + +if (dirty &&tcg_enabled ()) {tlb_reset_dirty_range_all (start, length); } + +return dirty; }/* Called from RCU critical section */
include/exec/ram_addr.h +10 -23
@@ -194,30 +194,19 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, }#endif /* not _WIN32 */ -static inline void cpu_physical_memory_clear_dirty_range_type (ram_addr_t start, -ram_addr_t length, -unsigned client) -{ -unsigned long end, page; - -assert (client <DIRTY_MEMORY_NUM ); - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; -bitmap_clear (ram_list.dirty_memory[client], page, end - page); -} +bool cpu_physical_memory_test_and_clear_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client);static inline void cpu_physical_memory_clear_dirty_range (ram_addr_t start,ram_addr_t length) { -cpu_physical_memory_clear_dirty_range_type (start, length,DIRTY_MEMORY_MIGRATION ); -cpu_physical_memory_clear_dirty_range_type (start, length,DIRTY_MEMORY_VGA ); -cpu_physical_memory_clear_dirty_range_type (start, length,DIRTY_MEMORY_CODE ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_MIGRATION ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_VGA ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_CODE ); } -void cpu_physical_memory_reset_dirty (ram_addr_t start,ram_addr_t length, -unsigned client); - static inline uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest, ram_addr_t start,
@@ -245,16 +234,14 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest, } }else {for (addr =0 ; addr < length; addr +=TARGET_PAGE_SIZE ) { -if (cpu_physical_memory_get_dirty (start + addr, -TARGET_PAGE_SIZE , -DIRTY_MEMORY_MIGRATION )) { +if (cpu_physical_memory_test_and_clear_dirty ( + start + addr, +TARGET_PAGE_SIZE , +DIRTY_MEMORY_MIGRATION )) {long k = (start + addr) >>TARGET_PAGE_BITS ;if (!test_and_set_bit (k, dest)) { num_dirty++; } -cpu_physical_memory_reset_dirty (start + addr, -TARGET_PAGE_SIZE , -DIRTY_MEMORY_MIGRATION ); } } }
memory.c +4 -7
@@ -1468,13 +1468,9 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr,bool memory_region_test_and_clear_dirty (MemoryRegion *mr,hwaddr addr,hwaddr size,unsigned client) { -bool ret;assert (mr->terminates); - ret =cpu_physical_memory_get_dirty (mr->ram_addr + addr, size, client); -if (ret) { -cpu_physical_memory_reset_dirty (mr->ram_addr + addr, size, client); - } -return ret; +return cpu_physical_memory_test_and_clear_dirty (mr->ram_addr + addr, + size, client); }
@@ -1518,7 +1514,8 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size, unsigned client) {assert (mr->terminates); -cpu_physical_memory_reset_dirty (mr->ram_addr + addr, size, client); +cpu_physical_memory_test_and_clear_dirty (mr->ram_addr + addr, size, + client); }int memory_region_get_fd (MemoryRegion *mr)
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 34/62] memory: use mr->ram_addr in "is this RAM?" assertions
In reply to Paolo Bonzinimr->terminates alone doesn't guarantee that we are looking at a RAM region. mr->ram_addr also has to be checked, in order to distinguish RAM and I/O regions.
So, do the following:
1) add a new define RAM_ADDR_INVALID, and test it in the assertions instead of mr->terminates
2) IOMMU regions were not setting mr->ram_addr to a bogus value, initialize it in the instance_init function so that the new assertions would fire for IOMMU regions as well.
--- memory.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
memory.c +10 -8
@@ -28,6 +28,8 @@//#define DEBUG_UNASSIGNED +#define RAM_ADDR_INVALID (~(ram_addr_t)0) +static unsigned memory_region_transaction_depth;static bool memory_region_update_pending;static bool ioeventfd_update_pending;
@@ -1007,6 +1009,7 @@ static void memory_region_initfn(Object *obj)ObjectProperty *op; mr->ops = &unassigned_mem_ops; + mr->ram_addr =RAM_ADDR_INVALID ; mr->enabled = true; mr->romd_mode = true; mr->destructor = memory_region_destructor_none;
@@ -1198,7 +1201,6 @@ void memory_region_init_io(MemoryRegion *mr, mr->ops = ops; mr->opaque = opaque; mr->terminates = true; - mr->ram_addr = ~(ram_addr_t )0 ; } void memory_region_init_ram(MemoryRegion *mr,
@@ -1453,14 +1455,14 @@ void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)bool memory_region_get_dirty (MemoryRegion *mr,hwaddr addr,hwaddr size,unsigned client) { -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );return cpu_physical_memory_get_dirty (mr->ram_addr + addr, size, client); }void memory_region_set_dirty (MemoryRegion *mr,hwaddr addr,hwaddr size) { -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );cpu_physical_memory_set_dirty_range (mr->ram_addr + addr, size,memory_region_get_dirty_log_mask (mr)); }
@@ -1468,7 +1470,7 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr,bool memory_region_test_and_clear_dirty (MemoryRegion *mr,hwaddr addr,hwaddr size,unsigned client) { -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );return cpu_physical_memory_test_and_clear_dirty (mr->ram_addr + addr, size, client); }
@@ -1513,7 +1515,7 @@ void memory_region_rom_device_set_romd(MemoryRegion *mr, bool romd_mode)void memory_region_reset_dirty (MemoryRegion *mr,hwaddr addr,hwaddr size,unsigned client) { -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );cpu_physical_memory_test_and_clear_dirty (mr->ram_addr + addr, size, client); }
@@ -1524,7 +1526,7 @@ int memory_region_get_fd(MemoryRegion *mr)return memory_region_get_fd (mr->alias); } -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );return qemu_get_ram_fd (mr->ram_addr &TARGET_PAGE_MASK ); }
@@ -1535,14 +1537,14 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr)return memory_region_get_ram_ptr (mr->alias) + mr->alias_offset; } -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );return qemu_get_ram_ptr (mr->ram_addr &TARGET_PAGE_MASK ); }void memory_region_ram_resize (MemoryRegion *mr,ram_addr_t newsize,Error **errp) { -assert (mr->terminates); +assert (mr->ram_addr !=RAM_ADDR_INVALID );qemu_ram_resize (mr->ram_addr, newsize, errp); }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 35/62] icount: implement a new icount_sleep mode toggleing real-time cpu sleep
In reply to Paolo BonziniFrom: Victor CLEMENT <[email protected]>
When the icount_sleep mode is disabled, the QEMU_VIRTUAL_CLOCK runs at the maximum possible speed by warping the sleep times of the virtual cpu to the soonest clock deadline. The virtual clock will be updated only according the instruction counter.
Message-Id: <[email protected]>
--- cpus.c | 70 +++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 26 deletions(-)
cpus.c +44 -26
@@ -105,6 +105,7 @@ static bool all_cpu_threads_idle(void)/* Protected by TimersState seqlock */ +static bool icount_sleep = true;static int64_t vm_clock_warp_start =-1 ;/* Conversion factor from emulated instructions to virtual clock ticks. */ static int icount_time_shift;
@@ -393,15 +394,18 @@ void qemu_clock_warp(QEMUClockType type)return ; } -/* -* If the CPUs have been sleeping, advance QEMU_CLOCK_VIRTUAL timer now. -* This ensures that the deadline for the timer is computed correctly below. -* This also makes sure that the insn counter is synchronized before the -* CPU starts running, in case the CPU is woken by an event other than -* the earliest QEMU_CLOCK_VIRTUAL timer. -*/ -icount_warp_rt (NULL ); -timer_del (icount_warp_timer); +if (icount_sleep) { +/* +* If the CPUs have been sleeping, advance QEMU_CLOCK_VIRTUAL timer now. +* This ensures that the deadline for the timer is computed correctly +* below. +* This also makes sure that the insn counter is synchronized before +* the CPU starts running, in case the CPU is woken by an event other +* than the earliest QEMU_CLOCK_VIRTUAL timer. +*/ +icount_warp_rt (NULL ); +timer_del (icount_warp_timer); + }if (!all_cpu_threads_idle ()) {return ; }
@@ -425,23 +429,35 @@ void qemu_clock_warp(QEMUClockType type)* interrupt to wake it up, but the interrupt never comes because * the vCPU isn't running any insns and thus doesn't advance the * QEMU_CLOCK_VIRTUAL. -* -* An extreme solution for this problem would be to never let VCPUs -* sleep in icount mode if there is a pending QEMU_CLOCK_VIRTUAL -* timer; rather time could just advance to the next QEMU_CLOCK_VIRTUAL -* event. Instead, we do stop VCPUs and only advance QEMU_CLOCK_VIRTUAL -* after some "real" time, (related to the time left until the next -* event) has passed. The QEMU_CLOCK_VIRTUAL_RT clock will do this. -* This avoids that the warps are visible externally; for example, -* you will not be sending network packets continuously instead of -* every 100ms. */ -seqlock_write_lock (&timers_state.vm_clock_seqlock); -if (vm_clock_warp_start ==-1 || vm_clock_warp_start > clock) { - vm_clock_warp_start = clock; +if (!icount_sleep) { +/* +* We never let VCPUs sleep in no sleep icount mode. +* If there is a pending QEMU_CLOCK_VIRTUAL timer we just advance +* to the next QEMU_CLOCK_VIRTUAL event and notify it. +* It is useful when we want a deterministic execution time, +* isolated from host latencies. +*/ +seqlock_write_lock (&timers_state.vm_clock_seqlock); + timers_state.qemu_icount_bias += deadline; +seqlock_write_unlock (&timers_state.vm_clock_seqlock); +qemu_clock_notify (QEMU_CLOCK_VIRTUAL ); + }else { +/* +* We do stop VCPUs and only advance QEMU_CLOCK_VIRTUAL after some +* "real" time, (related to the time left until the next event) has +* passed. The QEMU_CLOCK_VIRTUAL_RT clock will do this. +* This avoids that the warps are visible externally; for example, +* you will not be sending network packets continuously instead of +* every 100ms. +*/ +seqlock_write_lock (&timers_state.vm_clock_seqlock); +if (vm_clock_warp_start ==-1 || vm_clock_warp_start > clock) { + vm_clock_warp_start = clock; + } +seqlock_write_unlock (&timers_state.vm_clock_seqlock); +timer_mod_anticipate (icount_warp_timer, clock + deadline); } -seqlock_write_unlock (&timers_state.vm_clock_seqlock); -timer_mod_anticipate (icount_warp_timer, clock + deadline); }else if (deadline ==0 ) {qemu_clock_notify (QEMU_CLOCK_VIRTUAL ); }
@@ -504,9 +520,11 @@ void configure_icount(QemuOpts *opts, Error **errp) }return ; } +if (icount_sleep) { + icount_warp_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL_RT , + icount_warp_rt,NULL ); + } icount_align_option =qemu_opt_get_bool (opts,"align" , false); - icount_warp_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL_RT , - icount_warp_rt,NULL );if (strcmp (option,"auto" ) !=0 ) { errno =0 ; icount_time_shift =strtol (option, &rem_str,0 );
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 36/62] icount: add sleep parameter to the icount option to set icount_sleep mode
In reply to Paolo BonziniFrom: Victor CLEMENT <[email protected]>
The 'sleep' parameter sets the icount_sleep mode, which is enabled by default. To disable it, add the 'sleep=no' parameter (or 'nosleep') to the qemu -icount option.
Message-Id: <[email protected]>
--- cpus.c | 9 +++++++++ qemu-options.hx | 12 ++++++++++-- vl.c | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-)
cpus.c +9 -0
@@ -520,11 +520,18 @@ void configure_icount(QemuOpts *opts, Error **errp) }return ; } + + icount_sleep =qemu_opt_get_bool (opts,"sleep" , true);if (icount_sleep) { icount_warp_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL_RT , icount_warp_rt,NULL ); } + icount_align_option =qemu_opt_get_bool (opts,"align" , false); + +if (icount_align_option && !icount_sleep) { +error_setg (errp,"align=on and sleep=no are incompatible" ); + }if (strcmp (option,"auto" ) !=0 ) { errno =0 ; icount_time_shift =strtol (option, &rem_str,0 );
@@ -535,6 +542,8 @@ void configure_icount(QemuOpts *opts, Error **errp)return ; }else if (icount_align_option) {error_setg (errp,"shift=auto and align=on are incompatible" ); + }else if (!icount_sleep) { +error_setg (errp,"shift=auto and sleep=no are incompatible" ); } use_icount =2 ;
qemu-options.hx +10 -2
@@ -3100,9 +3100,10 @@ re-inject them. ETEXI DEF("icount", HAS_ARG, QEMU_OPTION_icount, \ - "-icount [shift=N|auto][,align=on|off]\n" \ + "-icount [shift=N|auto][,align=on|off][,sleep=no]\n" \ " enable virtual instruction counter with 2^N clock ticks per\n" \ - " instruction and enable aligning the host and virtual clocks\n", QEMU_ARCH_ALL) + " instruction, enable aligning the host and virtual clocks\n" \ + " or disable real time cpu sleeping\n", QEMU_ARCH_ALL) STEXI @item -icount [shift=@var{N}|auto] @findex -icount
@@ -3111,6 +3112,13 @@ instruction every 2^@var{N} ns of virtual time. If @code{auto} is specified then the virtual cpu speed will be automatically adjusted to keep virtual time within a few seconds of real time. +When the virtual cpu is sleeping, the virtual time will advance at default +speed unless @option{sleep=no} is specified. +With @option{sleep=no}, the virtual time will jump to the next timer deadline +instantly whenever the virtual cpu goes to sleep mode and will not advance +if no timer is enabled. This behavior give deterministic execution times from +the guest point of view. + Note that while this option can give deterministic behavior, it does not provide cycle accurate emulation. Modern CPUs contain superscalar out of order cores with complex cache hierarchies. The number of instructions
vl.c +3 -0
@@ -468,6 +468,9 @@ static QemuOptsList qemu_icount_opts = { }, { .name = "align", .type = QEMU_OPT_BOOL, + }, { + .name = "sleep", + .type = QEMU_OPT_BOOL, }, {/* end of list */ } },
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 37/62] icount: print a warning if there is no more deadline in sleep=no mode
In reply to Paolo BonziniFrom: Victor CLEMENT <[email protected]>
While qemu is running in sleep=no mode, a warning will be printed when no timer deadline is set.
As this mode is intended for getting deterministic virtual time, if no timer is set on the virtual clock this determinism is broken.
Message-Id: <[email protected]>
--- cpus.c | 5 +++++ 1 file changed, 5 insertions(+)
cpus.c +5 -0
@@ -419,6 +419,11 @@ void qemu_clock_warp(QEMUClockType type) clock =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL_RT ); deadline =qemu_clock_deadline_ns_all (QEMU_CLOCK_VIRTUAL );if (deadline <0 ) { +static bool notified; +if (!icount_sleep && !notified) { +error_report ("WARNING: icount sleep disabled and no active timers" ); + notified = true; + }return ; }
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 38/62] target-i386: introduce cpu_get_mem_attrs
In reply to Paolo Bonzini--- include/exec/memattrs.h | 4 +++- target-i386/cpu.h | 5 +++++ target-i386/helper.c | 3 ++- target-i386/kvm.c | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-)
include/exec/memattrs.h +3 -1
@@ -29,7 +29,9 @@ typedef struct MemTxAttrs {* "didn't specify" if necessary. */ unsigned int unspecified:1; -/* ARM/AMBA TrustZone Secure access */ +/* ARM/AMBA: TrustZone Secure access +* x86: System Management Mode access +*/ unsigned int secure:1;/* Memory access is usermode (unprivileged) */ unsigned int user:1;
target-i386/cpu.h +5 -0
@@ -1292,6 +1292,11 @@ static inline void cpu_load_efer(CPUX86State *env, uint64_t val) } } +static inline MemTxAttrs cpu_get_mem_attrs (CPUX86State *env) +{ +return ((MemTxAttrs ) { .secure = (env->hflags &HF_SMM_MASK ) !=0 }); +} +/* fpu_helper.c */ void cpu_set_mxcsr (CPUX86State *env,uint32_t val);void cpu_set_fpuc (CPUX86State *env,uint16_t val);
target-i386/helper.c +2 -1
@@ -771,7 +771,8 @@ do_check_protect_pse36: page_offset = vaddr & (page_size -1 ); paddr = pte + page_offset; -tlb_set_page (cs, vaddr, paddr, prot, mmu_idx, page_size); +tlb_set_page_with_attrs (cs, vaddr, paddr,cpu_get_mem_attrs (env), + prot, mmu_idx, page_size);return 0 ; do_fault_rsvd: error_code |=PG_ERROR_RSVD_MASK ;
target-i386/kvm.c +1 -1
@@ -2259,7 +2259,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run) }cpu_set_apic_tpr (x86_cpu->apic_state, run->cr8);cpu_set_apic_base (x86_cpu->apic_state, run->apic_base); -return MEMTXATTRS_UNSPECIFIED ; +return cpu_get_mem_attrs (env); }int kvm_arch_process_async_events (CPUState *cs)
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 40/62] target-i386: Use correct memory attributes for ioport accesses
In reply to Paolo BonziniIn order to do this, stop using the cpu_in*/out* helpers, and instead access address_space_io directly.
cpu_in* and cpu_out* remain for usage in the monitor, in qtest, and in Xen.
--- target-i386/Makefile.objs | 2 -- target-i386/helper.h | 12 +++++----- target-i386/ioport-user.c | 60 ----------------------------------------------- target-i386/misc_helper.c | 59 ++++++++++++++++++++++++++++++++++++---------- target-i386/translate.c | 12 +++++----- 5 files changed, 58 insertions(+), 87 deletions(-) delete mode 100644 target-i386/ioport-user.c
target-i386/Makefile.objs +0 -2
@@ -5,5 +5,3 @@ obj-y += gdbstub.o obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o obj-$(CONFIG_KVM) += kvm.o obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o -obj-$(CONFIG_LINUX_USER) += ioport-user.o -obj-$(CONFIG_BSD_USER) += ioport-user.o
target-i386/helper.h +6 -6
@@ -86,12 +86,12 @@ DEF_HELPER_1(wrmsr, void, env) DEF_HELPER_2(check_iob, void, env, i32) DEF_HELPER_2(check_iow, void, env, i32) DEF_HELPER_2(check_iol, void, env, i32) -DEF_HELPER_2(outb, void, i32, i32) -DEF_HELPER_1(inb, tl, i32) -DEF_HELPER_2(outw, void, i32, i32) -DEF_HELPER_1(inw, tl, i32) -DEF_HELPER_2(outl, void, i32, i32) -DEF_HELPER_1(inl, tl, i32) +DEF_HELPER_3(outb, void, env, i32, i32) +DEF_HELPER_2(inb, tl, env, i32) +DEF_HELPER_3(outw, void, env, i32, i32) +DEF_HELPER_2(inw, tl, env, i32) +DEF_HELPER_3(outl, void, env, i32, i32) +DEF_HELPER_2(inl, tl, env, i32) DEF_HELPER_3(svm_check_intercept_param, void, env, i32, i64)DEF_HELPER_3 (vmexit, void, env, i32, i64)
target-i386/ioport-user.c deleted +0 -60
60 lines not on this page · raw message
target-i386/misc_helper.c +46 -13
84 lines not on this page · raw message
target-i386/translate.c +6 -6
@@ -631,13 +631,13 @@ static void gen_helper_in_func(TCGMemOp ot, TCGv v, TCGv_i32 n) {switch (ot) {case MO_8 : -gen_helper_inb (v, n); +gen_helper_inb (v, cpu_env, n);break ;case MO_16 : -gen_helper_inw (v, n); +gen_helper_inw (v, cpu_env, n);break ;case MO_32 : -gen_helper_inl (v, n); +gen_helper_inl (v, cpu_env, n);break ;default :tcg_abort ();
@@ -648,13 +648,13 @@ static void gen_helper_out_func(TCGMemOp ot, TCGv_i32 v, TCGv_i32 n) {switch (ot) {case MO_8 : -gen_helper_outb (v, n); +gen_helper_outb (cpu_env, v, n);break ;case MO_16 : -gen_helper_outw (v, n); +gen_helper_outw (cpu_env, v, n);break ;case MO_32 : -gen_helper_outl (v, n); +gen_helper_outl (cpu_env, v, n);break ;default :tcg_abort ();
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 41/62] target-i386: mask NMIs on entry to SMM
In reply to Paolo BonziniQEMU is not blocking NMIs on entry to SMM. Implementing this has to cover a few corner cases, because:
- NMIs can then be enabled by an IRET instruction and there is no mechanism to _set_ the "NMIs masked" flag on exit from SMM:
"A special case can occur if an SMI handler nests inside an NMI handler and then another NMI occurs. [...] When the processor enters SMM while executing an NMI handler, the processor saves the SMRAM state save map but does not save the attribute to keep NMI interrupts disabled.
- However, there is some hidden state, because "If NMIs were blocked before the SMI occurred [and no IRET is executed while in SMM], they are blocked after execution of RSM." This is represented by the new HF2_SMM_INSIDE_NMI_MASK bit. If it is zero, NMIs are _unblocked_ on exit from RSM.
--- target-i386/cpu.h | 20 +++++++++++--------- target-i386/smm_helper.c | 9 +++++++++ 2 files changed, 20 insertions(+), 9 deletions(-)
target-i386/cpu.h +11 -9
@@ -180,15 +180,17 @@/* hflags2 */ -#define HF2_GIF_SHIFT 0/* if set CPU takes interrupts */ -#define HF2_HIF_SHIFT 1/* value of IF_MASK when entering SVM */ -#define HF2_NMI_SHIFT 2/* CPU serving NMI */ -#define HF2_VINTR_SHIFT 3/* value of V_INTR_MASKING bit */ - -#define HF2_GIF_MASK (1 << HF2_GIF_SHIFT) -#define HF2_HIF_MASK (1 << HF2_HIF_SHIFT) -#define HF2_NMI_MASK (1 << HF2_NMI_SHIFT) -#define HF2_VINTR_MASK (1 << HF2_VINTR_SHIFT) +#define HF2_GIF_SHIFT 0/* if set CPU takes interrupts */ +#define HF2_HIF_SHIFT 1/* value of IF_MASK when entering SVM */ +#define HF2_NMI_SHIFT 2/* CPU serving NMI */ +#define HF2_VINTR_SHIFT 3/* value of V_INTR_MASKING bit */ +#define HF2_SMM_INSIDE_NMI_SHIFT 4/* CPU serving SMI nested inside NMI */ + +#define HF2_GIF_MASK (1 << HF2_GIF_SHIFT) +#define HF2_HIF_MASK (1 << HF2_HIF_SHIFT) +#define HF2_NMI_MASK (1 << HF2_NMI_SHIFT) +#define HF2_VINTR_MASK (1 << HF2_VINTR_SHIFT) +#define HF2_SMM_INSIDE_NMI_MASK (1 << HF2_SMM_INSIDE_NMI_SHIFT)#define CR0_PE_SHIFT 0#define CR0_MP_SHIFT 1
target-i386/smm_helper.c +9 -0
@@ -52,6 +52,11 @@ void do_smm_enter(X86CPU *cpu)log_cpu_state_mask (CPU_LOG_INT ,CPU (cpu),CPU_DUMP_CCOP ); env->hflags |=HF_SMM_MASK ; +if (env->hflags2 &HF2_NMI_MASK ) { + env->hflags2 |=HF2_SMM_INSIDE_NMI_MASK ; + }else { + env->hflags2 |=HF2_NMI_MASK ; + }cpu_smm_update (env); sm_state = env->smbase +0x8000 ;
@@ -307,6 +312,10 @@ void helper_rsm(CPUX86State *env) env->smbase = x86_ldl_phys(cs, sm_state + 0x7ef8) & ~0x7fff; }#endif +if ((env->hflags2 &HF2_SMM_INSIDE_NMI_MASK ) ==0 ) { + env->hflags2 &= ~HF2_NMI_MASK ; + } + env->hflags2 &= ~HF2_SMM_INSIDE_NMI_MASK ; env->hflags &= ~HF_SMM_MASK ;cpu_smm_update (env);
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 42/62] target-i386: set G=1 in SMM big real mode selectors
In reply to Paolo BonziniBecause the limit field's bits 31:20 is 1, G should be 1. VMX actually enforces this, let's do it for completeness in QEMU as well.
--- target-i386/smm_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target-i386/smm_helper.c +6 -6
@@ -177,22 +177,22 @@ void do_smm_enter(X86CPU *cpu)cpu_x86_load_seg_cache (env,R_CS , (env->smbase >>4 ) &0xffff , env->smbase,0xffffffff ,DESC_P_MASK |DESC_S_MASK |DESC_W_MASK | -DESC_A_MASK ); +DESC_G_MASK |DESC_A_MASK );cpu_x86_load_seg_cache (env,R_DS ,0 ,0 ,0xffffffff ,DESC_P_MASK |DESC_S_MASK |DESC_W_MASK | -DESC_A_MASK ); +DESC_G_MASK |DESC_A_MASK );cpu_x86_load_seg_cache (env,R_ES ,0 ,0 ,0xffffffff ,DESC_P_MASK |DESC_S_MASK |DESC_W_MASK | -DESC_A_MASK ); +DESC_G_MASK |DESC_A_MASK );cpu_x86_load_seg_cache (env,R_SS ,0 ,0 ,0xffffffff ,DESC_P_MASK |DESC_S_MASK |DESC_W_MASK | -DESC_A_MASK ); +DESC_G_MASK |DESC_A_MASK );cpu_x86_load_seg_cache (env,R_FS ,0 ,0 ,0xffffffff ,DESC_P_MASK |DESC_S_MASK |DESC_W_MASK | -DESC_A_MASK ); +DESC_G_MASK |DESC_A_MASK );cpu_x86_load_seg_cache (env,R_GS ,0 ,0 ,0xffffffff ,DESC_P_MASK |DESC_S_MASK |DESC_W_MASK | -DESC_A_MASK ); +DESC_G_MASK |DESC_A_MASK ); }void helper_rsm (CPUX86State *env)
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 43/62] target-i386: wake up processors that receive an SMI
In reply to Paolo BonziniAn SMI should definitely wake up a processor in halted state! This lets OVMF boot with SMM on multiprocessor systems, although it halts very soon after that with a "CpuIndex != BspIndex" assertion failure.
--- target-i386/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target-i386/cpu.c +3 -1
@@ -3063,7 +3063,9 @@ static bool x86_cpu_has_work(CPUState *cs) (cs->interrupt_request & (CPU_INTERRUPT_NMI |CPU_INTERRUPT_INIT |CPU_INTERRUPT_SIPI | -CPU_INTERRUPT_MCE )); +CPU_INTERRUPT_MCE )) || + ((cs->interrupt_request &CPU_INTERRUPT_SMI ) && + !(env->hflags &HF_SMM_MASK )); }static Property x86_cpu_properties[] = {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 44/62] pflash_cfi01: change big-endian property to BIT type
In reply to Paolo BonziniMake this consistent with the secure property, added in the next patch.
--- hw/block/pflash_cfi01.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/block/pflash_cfi01.c +7 -4
@@ -64,6 +64,8 @@ do { \#define TYPE_CFI_PFLASH01 "cfi.pflash01"#define CFI_PFLASH01 (obj) OBJECT_CHECK(pflash_t, (obj), TYPE_CFI_PFLASH01) +#define PFLASH_BE 0 +struct pflash_t {/*< private >*/ SysBusDevice parent_obj;
@@ -75,7 +77,7 @@ struct pflash_t {uint8_t bank_width;uint8_t device_width;/* If 0, device width not specified. */ uint8_t max_device_width;/* max device width in bytes */ -uint8_t be; +uint32_t features;uint8_t wcycle;/* if 0, the flash is read normally */ int ro;uint8_t cmd;
@@ -773,7 +775,8 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)memory_region_init_rom_device ( &pfl->mem,OBJECT (dev), - pfl->be ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, pfl, + pfl->features & (1 <<PFLASH_BE ) ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, + pfl, pfl->name, total_len, &local_err);if (local_err) {error_propagate (errp, local_err);
@@ -925,7 +928,7 @@ static Property pflash_cfi01_properties[] = { DEFINE_PROP_UINT8("width", struct pflash_t, bank_width, 0), DEFINE_PROP_UINT8("device-width", struct pflash_t, device_width, 0), DEFINE_PROP_UINT8("max-device-width", struct pflash_t, max_device_width, 0), - DEFINE_PROP_UINT8("big-endian", struct pflash_t, be, 0), + DEFINE_PROP_BIT("big-endian", struct pflash_t, features, PFLASH_BE, 0), DEFINE_PROP_UINT16("id0", struct pflash_t, ident0, 0), DEFINE_PROP_UINT16("id1", struct pflash_t, ident1, 0), DEFINE_PROP_UINT16("id2", struct pflash_t, ident2, 0),
@@ -975,7 +978,7 @@ pflash_t *pflash_cfi01_register(hwaddr base,qdev_prop_set_uint32 (dev,"num-blocks" , nb_blocs);qdev_prop_set_uint64 (dev,"sector-length" , sector_len);qdev_prop_set_uint8 (dev,"width" , bank_width); -qdev_prop_set_uint8 (dev,"big-endian" , !!be); +qdev_prop_set_bit (dev,"big-endian" , !!be);qdev_prop_set_uint16 (dev,"id0" , id0);qdev_prop_set_uint16 (dev,"id1" , id1);qdev_prop_set_uint16 (dev,"id2" , id2);
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 45/62] pflash_cfi01: change to new-style MMIO accessors
In reply to Paolo BonziniThis is a required step to implement read_with_attrs and write_with_attrs.
--- hw/block/pflash_cfi01.c | 96 ++++++------------------------------------------- 1 file changed, 10 insertions(+), 86 deletions(-)
hw/block/pflash_cfi01.c +10 -86
@@ -650,101 +650,25 @@ static void pflash_write(pflash_t *pfl, hwaddr offset, } -static uint32_t pflash_readb_be (void *opaque,hwaddr addr) -{ -return pflash_read (opaque, addr,1 ,1 ); -} - -static uint32_t pflash_readb_le (void *opaque,hwaddr addr) -{ -return pflash_read (opaque, addr,1 ,0 ); -} - -static uint32_t pflash_readw_be (void *opaque,hwaddr addr) +static uint64_t pflash_mem_read (void *opaque,hwaddr addr,unsigned len) {pflash_t *pfl = opaque; +bool be = !!(pfl->features & (1 <<PFLASH_BE )); -return pflash_read (pfl, addr,2 ,1 ); +return pflash_read (pfl, addr, len, be); } -static uint32_t pflash_readw_le (void *opaque,hwaddr addr) +static void pflash_mem_write (void *opaque,hwaddr addr,uint64_t value,unsigned len) {pflash_t *pfl = opaque; +bool be = !!(pfl->features & (1 <<PFLASH_BE )); -return pflash_read (pfl, addr,2 ,0 ); +pflash_write (pfl, addr, value, len, be); } -static uint32_t pflash_readl_be (void *opaque,hwaddr addr) -{ -pflash_t *pfl = opaque; - -return pflash_read (pfl, addr,4 ,1 ); -} - -static uint32_t pflash_readl_le (void *opaque,hwaddr addr) -{ -pflash_t *pfl = opaque; - -return pflash_read (pfl, addr,4 ,0 ); -} - -static void pflash_writeb_be (void *opaque,hwaddr addr, -uint32_t value) -{ -pflash_write (opaque, addr, value,1 ,1 ); -} - -static void pflash_writeb_le (void *opaque,hwaddr addr, -uint32_t value) -{ -pflash_write (opaque, addr, value,1 ,0 ); -} - -static void pflash_writew_be (void *opaque,hwaddr addr, -uint32_t value) -{ -pflash_t *pfl = opaque; - -pflash_write (pfl, addr, value,2 ,1 ); -} - -static void pflash_writew_le (void *opaque,hwaddr addr, -uint32_t value) -{ -pflash_t *pfl = opaque; - -pflash_write (pfl, addr, value,2 ,0 ); -} - -static void pflash_writel_be (void *opaque,hwaddr addr, -uint32_t value) -{ -pflash_t *pfl = opaque; - -pflash_write (pfl, addr, value,4 ,1 ); -} - -static void pflash_writel_le (void *opaque,hwaddr addr, -uint32_t value) -{ -pflash_t *pfl = opaque; - -pflash_write (pfl, addr, value,4 ,0 ); -} - -static const MemoryRegionOps pflash_cfi01_ops_be = { - .old_mmio = { - .read = { pflash_readb_be, pflash_readw_be, pflash_readl_be, }, - .write = { pflash_writeb_be, pflash_writew_be, pflash_writel_be, }, - }, - .endianness =DEVICE_NATIVE_ENDIAN , -}; - -static const MemoryRegionOps pflash_cfi01_ops_le = { - .old_mmio = { - .read = { pflash_readb_le, pflash_readw_le, pflash_readl_le, }, - .write = { pflash_writeb_le, pflash_writew_le, pflash_writel_le, }, - }, +static const MemoryRegionOps pflash_cfi01_ops = { + .read = pflash_mem_read, + .write = pflash_mem_write, .endianness =DEVICE_NATIVE_ENDIAN , };
@@ -775,7 +699,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)memory_region_init_rom_device ( &pfl->mem,OBJECT (dev), - pfl->features & (1 <<PFLASH_BE ) ? &pflash_cfi01_ops_be : &pflash_cfi01_ops_le, + &pflash_cfi01_ops, pfl, pfl->name, total_len, &local_err);if (local_err) {
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 39/62] target-i386: Use correct memory attributes for memory accesses
In reply to Paolo BonziniThese include page table walks, SVM accesses and SMM state save accesses.
The bulk of the patch is obtained with
sed -i 's/\(\<[a-z_]*_phys\(_notdirty\)\?\>(cs\)->as,/x86_\1,/'
--- target-i386/cpu.h | 12 ++ target-i386/helper.c | 132 +++++++++++++++++---- target-i386/seg_helper.c | 12 +- target-i386/smm_helper.c | 298 +++++++++++++++++++++++------------------------ target-i386/svm_helper.c | 230 ++++++++++++++++++------------------ 5 files changed, 394 insertions(+), 290 deletions(-)
target-i386/cpu.h +12 -0
@@ -1105,6 +1105,18 @@ int x86_cpu_handle_mmu_fault(CPUState *cpu, vaddr addr, int is_write, int mmu_idx);void x86_cpu_set_a20 (X86CPU *cpu,int a20_state); +#ifndef CONFIG_USER_ONLY +uint8_t x86_ldub_phys (CPUState *cs,hwaddr addr); +uint32_t x86_lduw_phys (CPUState *cs,hwaddr addr); +uint32_t x86_ldl_phys (CPUState *cs,hwaddr addr); +uint64_t x86_ldq_phys (CPUState *cs,hwaddr addr); +void x86_stb_phys (CPUState *cs,hwaddr addr,uint8_t val); +void x86_stl_phys_notdirty (CPUState *cs,hwaddr addr,uint32_t val); +void x86_stw_phys (CPUState *cs,hwaddr addr,uint32_t val); +void x86_stl_phys (CPUState *cs,hwaddr addr,uint32_t val); +void x86_stq_phys (CPUState *cs,hwaddr addr,uint64_t val); +#endif +static inline bool hw_local_breakpoint_enabled (unsigned long dr7,int index) {return (dr7 >> (index *2 )) &1 ;
target-i386/helper.c +112 -20
248 lines not on this page · raw message
target-i386/seg_helper.c +6 -6
@@ -1144,7 +1144,7 @@ static void handle_even_inj(CPUX86State *env, int intno, int is_int, int error_code, int is_hw, int rm) { CPUState *cs = CPU(x86_env_get_cpu(env)); -uint32_t event_inj =ldl_phys (cs->as, env->vm_vmcb + offsetof(struct vmcb , +uint32_t event_inj =x86_ldl_phys (cs, env->vm_vmcb + offsetof(struct vmcb , control.event_inj));if (!(event_inj &SVM_EVTINJ_VALID )) {
@@ -1158,11 +1158,11 @@ static void handle_even_inj(CPUX86State *env, int intno, int is_int, event_inj = intno | type |SVM_EVTINJ_VALID ;if (!rm &&exception_has_error_code (intno)) { event_inj |=SVM_EVTINJ_VALID_ERR ; -stl_phys (cs->as, env->vm_vmcb + offsetof(struct vmcb , +x86_stl_phys (cs, env->vm_vmcb + offsetof(struct vmcb , control.event_inj_err), error_code); } -stl_phys (cs->as, +x86_stl_phys (cs, env->vm_vmcb + offsetof(struct vmcb, control.event_inj), event_inj); }
@@ -1240,11 +1240,11 @@ static void do_interrupt_all(X86CPU *cpu, int intno, int is_int,#if !defined(CONFIG_USER_ONLY )if (env->hflags &HF_SVMI_MASK ) {CPUState *cs =CPU (cpu); -uint32_t event_inj =ldl_phys (cs->as, env->vm_vmcb + +uint32_t event_inj =x86_ldl_phys (cs, env->vm_vmcb + offsetof(struct vmcb , control.event_inj)); -stl_phys (cs->as, +x86_stl_phys (cs, env->vm_vmcb + offsetof(struct vmcb, control.event_inj), event_inj & ~SVM_EVTINJ_VALID ); }
@@ -1339,7 +1339,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request)int intno;/* FIXME: this should respect TPR */ cpu_svm_check_intercept_param (env,SVM_EXIT_VINTR ,0 ); - intno =ldl_phys (cs->as, env->vm_vmcb + intno =x86_ldl_phys (cs, env->vm_vmcb + offsetof(struct vmcb, control.int_vector));qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing virtual hardware INT=0x%02x\n" , intno);
target-i386/smm_helper.c +149 -149
356 lines not on this page · raw message
target-i386/svm_helper.c +115 -115
488 lines not on this page · raw message
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 46/62] pflash_cfi01: add secure property
In reply to Paolo BonziniWhen this property is set, MMIO accesses are only allowed with the MEMTXATTRS_SECURE attribute. This is used for secure access to UEFI variables stored in flash.
--- hw/block/pflash_cfi01.c | 111 +++++++++++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 44 deletions(-)
hw/block/pflash_cfi01.c +67 -44
@@ -65,6 +65,7 @@ do { \#define CFI_PFLASH01 (obj) OBJECT_CHECK(pflash_t, (obj), TYPE_CFI_PFLASH01)#define PFLASH_BE 0 +#define PFLASH_SECURE 1struct pflash_t {/*< private >*/
@@ -237,12 +238,57 @@ static uint32_t pflash_devid_query(pflash_t *pfl, hwaddr offset)return resp; } +static uint32_t pflash_data_read (pflash_t *pfl,hwaddr offset, +int width,int be) +{ +uint8_t *p; +uint32_t ret; + + p = pfl->storage; +switch (width) { +case 1 : + ret = p[offset]; +DPRINTF ("%s: data offset " TARGET_FMT_plx" %02x\n" , + __func__, offset, ret); +break ; +case 2 : +if (be) { + ret = p[offset] <<8 ; + ret |= p[offset +1 ]; + }else { + ret = p[offset]; + ret |= p[offset +1 ] <<8 ; + } +DPRINTF ("%s: data offset " TARGET_FMT_plx" %04x\n" , + __func__, offset, ret); +break ; +case 4 : +if (be) { + ret = p[offset] <<24 ; + ret |= p[offset +1 ] <<16 ; + ret |= p[offset +2 ] <<8 ; + ret |= p[offset +3 ]; + }else { + ret = p[offset]; + ret |= p[offset +1 ] <<8 ; + ret |= p[offset +2 ] <<16 ; + ret |= p[offset +3 ] <<24 ; + } +DPRINTF ("%s: data offset " TARGET_FMT_plx" %08x\n" , + __func__, offset, ret); +break ; +default : +DPRINTF ("BUG in %s\n" , __func__); +abort (); + } +return ret; +} +static uint32_t pflash_read (pflash_t *pfl,hwaddr offset,int width,int be) {hwaddr boff;uint32_t ret; -uint8_t *p; ret =-1 ;
@@ -259,43 +305,7 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset,/* fall through to read code */ case 0x00 :/* Flash area read */ - p = pfl->storage; -switch (width) { -case 1 : - ret = p[offset]; -DPRINTF ("%s: data offset " TARGET_FMT_plx" %02x\n" , - __func__, offset, ret); -break ; -case 2 : -if (be) { - ret = p[offset] <<8 ; - ret |= p[offset +1 ]; - }else { - ret = p[offset]; - ret |= p[offset +1 ] <<8 ; - } -DPRINTF ("%s: data offset " TARGET_FMT_plx" %04x\n" , - __func__, offset, ret); -break ; -case 4 : -if (be) { - ret = p[offset] <<24 ; - ret |= p[offset +1 ] <<16 ; - ret |= p[offset +2 ] <<8 ; - ret |= p[offset +3 ]; - }else { - ret = p[offset]; - ret |= p[offset +1 ] <<8 ; - ret |= p[offset +2 ] <<16 ; - ret |= p[offset +3 ] <<24 ; - } -DPRINTF ("%s: data offset " TARGET_FMT_plx" %08x\n" , - __func__, offset, ret); -break ; -default : -DPRINTF ("BUG in %s\n" , __func__); - } - + ret =pflash_data_read (pfl, offset, width, be);break ;case 0x10 :/* Single byte program */ case 0x20 :/* Block erase */
@@ -650,25 +660,37 @@ static void pflash_write(pflash_t *pfl, hwaddr offset, } -static uint64_t pflash_mem_read (void *opaque,hwaddr addr,unsigned len) +static MemTxResult pflash_mem_read_with_attrs (void *opaque,hwaddr addr,uint64_t *value, +unsigned len,MemTxAttrs attrs) {pflash_t *pfl = opaque;bool be = !!(pfl->features & (1 <<PFLASH_BE )); -return pflash_read (pfl, addr, len, be); +if ((pfl->features & (1 <<PFLASH_SECURE )) && !attrs.secure) { + *value =pflash_data_read (opaque, addr, len, be); + }else { + *value =pflash_read (opaque, addr, len, be); + } +return MEMTX_OK ; } -static void pflash_mem_write (void *opaque,hwaddr addr,uint64_t value,unsigned len) +static MemTxResult pflash_mem_write_with_attrs (void *opaque,hwaddr addr,uint64_t value, +unsigned len,MemTxAttrs attrs) {pflash_t *pfl = opaque;bool be = !!(pfl->features & (1 <<PFLASH_BE )); -pflash_write (pfl, addr, value, len, be); +if ((pfl->features & (1 <<PFLASH_SECURE )) && !attrs.secure) { +return MEMTX_ERROR ; + }else { +pflash_write (opaque, addr, value, len, be); +return MEMTX_OK ; + } }static const MemoryRegionOps pflash_cfi01_ops = { - .read = pflash_mem_read, - .write = pflash_mem_write, + .read_with_attrs = pflash_mem_read_with_attrs, + .write_with_attrs = pflash_mem_write_with_attrs, .endianness =DEVICE_NATIVE_ENDIAN , };
@@ -853,6 +875,7 @@ static Property pflash_cfi01_properties[] = { DEFINE_PROP_UINT8("device-width", struct pflash_t, device_width, 0), DEFINE_PROP_UINT8("max-device-width", struct pflash_t, max_device_width, 0), DEFINE_PROP_BIT("big-endian", struct pflash_t, features, PFLASH_BE, 0), + DEFINE_PROP_BIT("secure", struct pflash_t, features, PFLASH_SECURE, 0), DEFINE_PROP_UINT16("id0", struct pflash_t, ident0, 0), DEFINE_PROP_UINT16("id1", struct pflash_t, ident1, 0), DEFINE_PROP_UINT16("id2", struct pflash_t, ident2, 0),
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 47/62] vl: allow full-blown QemuOpts syntax for -global
In reply to Paolo Bonzini-global does not work for drivers that have a dot in their name, such as cfi.pflash01. This is just a parsing limitation, because such globals can be declared easily inside a -readconfig file.
To allow this usage, support the full QemuOpts key/value syntax for -global too, for example "-global driver=cfi.pflash01,property=secure,value=on". The two formats do not conflict, because the key/value syntax does not have a period before the first equal sign.
--- qdev-monitor.c | 18 +++++++++++------- qemu-options.hx | 7 ++++++- 2 files changed, 17 insertions(+), 8 deletions(-)
qdev-monitor.c +11 -7
@@ -822,15 +822,19 @@ int qemu_global_option(const char *str)QemuOpts *opts;int rc, offset; - rc =sscanf (str,"%63[^.].%63[^=]%n" , driver, property, &offset); -if (rc <2 || str[offset] !='=' ) { -error_report ("can't parse: \"%s\"" , str); + rc =sscanf (str,"%63[^.=].%63[^=]%n" , driver, property, &offset); +if (rc ==2 && str[offset] =='=' ) { + opts =qemu_opts_create (&qemu_global_opts,NULL ,0 , &error_abort); +qemu_opt_set (opts,"driver" , driver, &error_abort); +qemu_opt_set (opts,"property" , property, &error_abort); +qemu_opt_set (opts,"value" , str + offset +1 , &error_abort); +return 0 ; + } + + opts =qemu_opts_parse (&qemu_global_opts, str, false); +if (!opts) {return -1 ; } - opts =qemu_opts_create (&qemu_global_opts,NULL ,0 , &error_abort); -qemu_opt_set (opts,"driver" , driver, &error_abort); -qemu_opt_set (opts,"property" , property, &error_abort); -qemu_opt_set (opts,"value" , str + offset +1 , &error_abort);return 0 ; }
qemu-options.hx +6 -1
@@ -171,11 +171,13 @@ Set parameter @var{arg} for item @var{id} of type @var{group}\n" ETEXI DEF("global", HAS_ARG, QEMU_OPTION_global, - "-global driver.prop=value\n" + "-global driver.property=value\n" + "-global driver=driver,property=property,value=value\n" " set a global default for a driver property\n", QEMU_ARCH_ALL) STEXI @item -global @var{driver}.@var{prop}=@var{value} +@itemx -global driver=@var{driver},property=@var{property},value=@var{value} @findex -global Set default value of @var{driver}'s property @var{prop} to @var{value}, e.g.:
@@ -186,6 +188,9 @@ qemu-system-i386 -global ide-drive.physical_block_size=4096 -drive file=file,if= In particular, you can use this to set driver properties for devices which are created automatically by the machine model. To create a device which is not created automatically and set properties on it, use -@option{device}. + +The two syntaxes are equivalent. The longer one works for drivers whose name +contains a dot. ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot,
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 48/62] qom: add object_property_add_const_link
In reply to Paolo Bonzini--- include/qom/object.h | 18 ++++++++++++++++++ qom/object.c | 16 ++++++++++++++++ 2 files changed, 34 insertions(+)
include/qom/object.h +18 -0
@@ -1290,6 +1290,24 @@ void object_property_add_alias(Object *obj, const char *name, Error **errp);/** +* object_property_add_const_link: +* @obj: the object to add a property to +* @name: the name of the property +* @target: the object to be referred by the link +* @errp: if an error occurs, a pointer to an area to store the error +* +* Add an unmodifiable link for a property on an object. This function will +* add a property of type link<TYPE> where TYPE is the type of @target. +* +* The caller must ensure that @target stays alive as long as +* this property exists. In the case @target is a child of @obj, +* this will be the case. Otherwise, the caller is responsible for +* taking a reference. +*/ +void object_property_add_const_link (Object *obj,const char *name, +Object *target,Error **errp); + +/** * object_property_set_description: * @obj: the object owning the property * @name: the name of the property
qom/object.c +16 -0
@@ -1266,6 +1266,22 @@ out:g_free (full_type); } +void object_property_add_const_link (Object *obj,const char *name, +Object *target,Error **errp) +{ +char *link_type; +ObjectProperty *op; + + link_type =g_strdup_printf ("link<%s>" ,object_get_typename (target)); + op =object_property_add (obj, name, link_type, + object_get_child_property,NULL , +NULL , target, errp); +if (op !=NULL ) { + op->resolve = object_resolve_child_property; + } +g_free (link_type); +} +gchar *object_get_canonical_path_component (Object *obj) {ObjectProperty *prop =NULL ;
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 49/62] vl: run "late" notifiers immediately
In reply to Paolo BonziniIf a machine_init_done notifier is added late, as part of a hot-plugged device, run it immediately.
--- vl.c | 6 ++++++ 1 file changed, 6 insertions(+)
vl.c +6 -0
@@ -2500,14 +2500,20 @@ static void qemu_run_exit_notifiers(void)notifier_list_notify (&exit_notifiers,NULL ); } +static bool machine_init_done; +void qemu_add_machine_init_done_notifier (Notifier *notify) {notifier_list_add (&machine_init_done_notifiers, notify); +if (machine_init_done) { + notify->notify (notify,NULL ); + } }static void qemu_run_machine_init_done_notifiers (void ) {notifier_list_notify (&machine_init_done_notifiers,NULL ); + machine_init_done = true; } static const QEMUOption *lookup_opt(int argc, char **argv,
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 50/62] target-i386: create a separate AddressSpace for each CPU
In reply to Paolo BonziniDifferent CPUs can be in SMM or not at the same time, thus they will see different things where the chipset places SMRAM.
--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
target-i386/cpu-qom.h +1 -0
@@ -111,6 +111,7 @@ typedef struct X86CPU {/* in order to simplify APIC support, we leave this pointer to the user */ struct DeviceState *apic_state; +struct MemoryRegion *cpu_as_root; }X86CPU ;static inline X86CPU *x86_env_get_cpu (CPUX86State *env)
target-i386/cpu.c +14 -0
@@ -44,6 +44,7 @@#include "hw/qdev-properties.h" #include "hw/cpu/icc_bus.h" #ifndef CONFIG_USER_ONLY +#include "exec/address-spaces.h" #include "hw/xen/xen.h" #include "hw/i386/apic_internal.h" #endif
@@ -2811,6 +2812,18 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)#endif mce_init (cpu); + +#ifndef CONFIG_USER_ONLY +if (tcg_enabled ()) { + cpu->cpu_as_root =g_new (MemoryRegion,1 ); + cs->as =g_new (AddressSpace,1 ); +memory_region_init_alias (cpu->cpu_as_root,OBJECT (cpu),"memory" , +get_system_memory (),0 , ~0ull ); +memory_region_set_enabled (cpu->cpu_as_root, true); +address_space_init (cs->as, cpu->cpu_as_root,"CPU" ); + } +#endif +qemu_init_vcpu (cs);/* Only Intel CPUs support hyperthreading. Even though QEMU fixes this
@@ -2834,6 +2847,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)cpu_reset (cs); xcc->parent_realize (dev, &local_err); + out:if (local_err !=NULL ) {error_propagate (errp, local_err);
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 51/62] hw/i386: add a separate region that tracks the SMRAME bit
In reply to Paolo BonziniThis region is exported at /machine/smram. It is "empty" if SMRAME=0 and points to SMRAM if SMRAME=1. The CPU will enable/disable it as it enters or exits SMRAM.
While touching nearby code, the existing memory region setup was slightly inconsistent. The smram_region is *disabled* in order to open SMRAM (because the smram_region shows the low VRAM instead of the RAM at 0xa0000). Because SMRAM is closed at startup, the smram_region must be enabled when creating the i440fx or q35 devices.
--- hw/pci-host/piix.c | 17 ++++++++++++++++- hw/pci-host/q35.c | 17 +++++++++++++++-- include/hw/pci-host/q35.h | 1 + 3 files changed, 32 insertions(+), 3 deletions(-)
hw/pci-host/piix.c +16 -1
@@ -105,6 +105,7 @@ struct PCII440FXState {MemoryRegion *ram_memory;PAMMemoryRegion pam_regions[13 ];MemoryRegion smram_region; +MemoryRegion smram, low_smram;uint8_t smm_enabled; };
@@ -139,6 +140,8 @@ static void i440fx_update_memory_mappings(PCII440FXState *d) pd->config[I440FX_PAM + ((i + 1) / 2)]); }smram_update (&d->smram_region, pd->config[I440FX_SMRAM ], d->smm_enabled); +memory_region_set_enabled (&d->smram, + pd->config[I440FX_SMRAM ] &SMRAM_G_SMRAME );memory_region_transaction_commit (); }
@@ -346,11 +349,23 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,pc_pci_as_mapping_init (OBJECT (f), f->system_memory, f->pci_address_space); +/* if *disabled* show SMRAM to all CPUs */ memory_region_init_alias (&f->smram_region,OBJECT (d),"smram-region" , f->pci_address_space,0xa0000 ,0x20000 );memory_region_add_subregion_overlap (f->system_memory,0xa0000 , &f->smram_region,1 ); -memory_region_set_enabled (&f->smram_region, false); +memory_region_set_enabled (&f->smram_region, true); + +/* smram, as seen by SMM CPUs */ +memory_region_init (&f->smram,OBJECT (d),"smram" ,1ull <<32 ); +memory_region_set_enabled (&f->smram, true); +memory_region_init_alias (&f->low_smram,OBJECT (d),"smram-low" , + f->system_memory,0xa0000 ,0x20000 ); +memory_region_set_enabled (&f->low_smram, true); +memory_region_add_subregion (&f->smram,0xa0000 , &f->low_smram); +object_property_add_const_link (qdev_get_machine (),"smram" , +OBJECT (&f->smram), &error_abort); +init_pam (dev, f->ram_memory, f->system_memory, f->pci_address_space, &f->pam_regions[0 ],PAM_BIOS_BASE ,PAM_BIOS_SIZE );for (i =0 ; i <12 ; ++i) {
hw/pci-host/q35.c +15 -2
@@ -270,6 +270,8 @@ static void mch_update_smram(MCHPCIState *mch)memory_region_transaction_begin ();smram_update (&mch->smram_region, pd->config[MCH_HOST_BRIDGE_SMRAM ], mch->smm_enabled); +memory_region_set_enabled (&mch->smram, + pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_G_SMRAME );memory_region_transaction_commit (); }
@@ -399,13 +401,24 @@ static void mch_realize(PCIDevice *d, Error **errp)pc_pci_as_mapping_init (OBJECT (mch), mch->system_memory, mch->pci_address_space); -/* smram */ +/* if *disabled* show SMRAM to all CPUs */ cpu_smm_register (&mch_set_smm, mch);memory_region_init_alias (&mch->smram_region,OBJECT (mch),"smram-region" , mch->pci_address_space,0xa0000 ,0x20000 );memory_region_add_subregion_overlap (mch->system_memory,0xa0000 , &mch->smram_region,1 ); -memory_region_set_enabled (&mch->smram_region, false); +memory_region_set_enabled (&mch->smram_region, true); + +/* smram, as seen by SMM CPUs */ +memory_region_init (&mch->smram,OBJECT (mch),"smram" ,1ull <<32 ); +memory_region_set_enabled (&mch->smram, true); +memory_region_init_alias (&mch->low_smram,OBJECT (mch),"smram-low" , + mch->system_memory,0xa0000 ,0x20000 ); +memory_region_set_enabled (&mch->low_smram, true); +memory_region_add_subregion (&mch->smram,0xa0000 , &mch->low_smram); +object_property_add_const_link (qdev_get_machine (),"smram" , +OBJECT (&mch->smram), &error_abort); +init_pam (DEVICE (mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[0 ],PAM_BIOS_BASE ,PAM_BIOS_SIZE );
include/hw/pci-host/q35.h +1 -0
@@ -53,6 +53,7 @@ typedef struct MCHPCIState {MemoryRegion *address_space_io;PAMMemoryRegion pam_regions[13 ];MemoryRegion smram_region; +MemoryRegion smram, low_smram;PcPciInfo pci_info;uint8_t smm_enabled;ram_addr_t below_4g_mem_size;
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 52/62] target-i386: use memory API to implement SMRAM
In reply to Paolo BonziniRemove cpu_smm_register and cpu_smm_update. Instead, each CPU address space gets an extra region which is an alias of /machine/smram. This extra region is enabled or disabled as the CPU enters/exits SMM.
--- bsd-user/main.c | 4 ---- hw/i386/pc.c | 21 --------------------- hw/pci-host/pam.c | 18 ++---------------- hw/pci-host/piix.c | 28 ++++++++-------------------- hw/pci-host/q35.c | 22 ++++++---------------- include/hw/i386/pc.h | 1 - include/hw/pci-host/pam.h | 5 +---- include/hw/pci-host/q35.h | 1 - linux-user/main.c | 4 ---- target-i386/cpu-qom.h | 4 +++- target-i386/cpu.c | 33 +++++++++++++++++++++++++++++++-- target-i386/cpu.h | 3 ++- target-i386/machine.c | 3 +++ target-i386/smm_helper.c | 14 ++++++++++++-- 14 files changed, 68 insertions(+), 93 deletions(-)
bsd-user/main.c +0 -4
@@ -108,10 +108,6 @@ void cpu_list_unlock(void)/***********************************************************/ /* CPUX86 core interface */ -void cpu_smm_update (CPUX86State *env) -{ -} -uint64_t cpu_get_tsc (CPUX86State *env) {return cpu_get_real_ticks ();
hw/i386/pc.c +0 -21
@@ -164,27 +164,6 @@ uint64_t cpu_get_tsc(CPUX86State *env)return cpu_get_ticks (); } -/* SMM support */ - -static cpu_set_smm_t smm_set; -static void *smm_arg; - -void cpu_smm_register (cpu_set_smm_t callback,void *arg) -{ -assert (smm_set ==NULL ); -assert (smm_arg ==NULL ); - smm_set = callback; - smm_arg = arg; -} - -void cpu_smm_update (CPUX86State *env) -{ -if (smm_set && smm_arg &&CPU (x86_env_get_cpu (env)) == first_cpu) { -smm_set (!!(env->hflags &HF_SMM_MASK ), smm_arg); - } -} - -/* IRQ handling */ int cpu_get_pic_interrupt (CPUX86State *env) {
hw/pci-host/pam.c +2 -16
@@ -31,26 +31,12 @@#include "sysemu/sysemu.h" #include "hw/pci-host/pam.h" -void smram_update (MemoryRegion *smram_region,uint8_t smram, -uint8_t smm_enabled) +void smram_update (MemoryRegion *smram_region,uint8_t smram) { -bool smram_enabled; - - smram_enabled = ((smm_enabled && (smram &SMRAM_G_SMRAME )) || - (smram &SMRAM_D_OPEN )); +bool smram_enabled = (smram &SMRAM_D_OPEN );memory_region_set_enabled (smram_region, !smram_enabled); } -void smram_set_smm (uint8_t *host_smm_enabled,int smm,uint8_t smram, -MemoryRegion *smram_region) -{ -uint8_t smm_enabled = (smm !=0 ); -if (*host_smm_enabled != smm_enabled) { - *host_smm_enabled = smm_enabled; -smram_update (smram_region, smram, *host_smm_enabled); - } -} -void init_pam (DeviceState *dev,MemoryRegion *ram_memory,MemoryRegion *system_memory,MemoryRegion *pci_address_space,PAMMemoryRegion *mem,uint32_t start,uint32_t size)
hw/pci-host/piix.c +8 -20
@@ -106,7 +106,6 @@ struct PCII440FXState {PAMMemoryRegion pam_regions[13 ];MemoryRegion smram_region;MemoryRegion smram, low_smram; -uint8_t smm_enabled; };
@@ -139,23 +138,12 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)pam_update (&d->pam_regions[i], i, pd->config[I440FX_PAM + ((i +1 ) /2 )]); } -smram_update (&d->smram_region, pd->config[I440FX_SMRAM ], d->smm_enabled); +smram_update (&d->smram_region, pd->config[I440FX_SMRAM ]);memory_region_set_enabled (&d->smram, pd->config[I440FX_SMRAM ] &SMRAM_G_SMRAME );memory_region_transaction_commit (); } -static void i440fx_set_smm (int val,void *arg) -{ -PCII440FXState *d = arg; -PCIDevice *pd =PCI_DEVICE (d); - -memory_region_transaction_begin (); -smram_set_smm (&d->smm_enabled, val, pd->config[I440FX_SMRAM ], - &d->smram_region); -memory_region_transaction_commit (); -} -static void i440fx_write_config (PCIDevice *dev,uint32_t address,uint32_t val,int len)
@@ -175,12 +163,13 @@ static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id)PCII440FXState *d = opaque;PCIDevice *pd =PCI_DEVICE (d);int ret, i; +uint8_t smm_enabled; ret =pci_device_load (pd, f);if (ret <0 )return ret;i440fx_update_memory_mappings (d); -qemu_get_8s (f, &d->smm_enabled); +qemu_get_8s (f, &smm_enabled);if (version_id ==2 ) {for (i =0 ; i <PIIX_NUM_PIRQS ; i++) {
@@ -208,7 +197,10 @@ static const VMStateDescription vmstate_i440fx = { .post_load = i440fx_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (parent_obj, PCII440FXState), -VMSTATE_UINT8 (smm_enabled, PCII440FXState), +/* Used to be smm_enabled, which was basically always zero because +* SeaBIOS hardly uses SMM. SMRAM is now handled by CPU code. +*/ +VMSTATE_UNUSED (1 ),VMSTATE_END_OF_LIST () } };
@@ -300,11 +292,7 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)static void i440fx_realize (PCIDevice *dev,Error **errp) { -PCII440FXState *d =I440FX_PCI_DEVICE (dev); - dev->config[I440FX_SMRAM ] =0x02 ; - -cpu_smm_register (&i440fx_set_smm, d); } PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
@@ -360,7 +348,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,memory_region_init (&f->smram,OBJECT (d),"smram" ,1ull <<32 );memory_region_set_enabled (&f->smram, true);memory_region_init_alias (&f->low_smram,OBJECT (d),"smram-low" , - f->system_memory,0xa0000 ,0x20000 ); + f->ram_memory,0xa0000 ,0x20000 );memory_region_set_enabled (&f->low_smram, true);memory_region_add_subregion (&f->smram,0xa0000 , &f->low_smram); object_property_add_const_link(qdev_get_machine(), "smram",
hw/pci-host/q35.c +6 -16
@@ -268,24 +268,12 @@ static void mch_update_smram(MCHPCIState *mch)PCIDevice *pd =PCI_DEVICE (mch);memory_region_transaction_begin (); -smram_update (&mch->smram_region, pd->config[MCH_HOST_BRIDGE_SMRAM ], - mch->smm_enabled); +smram_update (&mch->smram_region, pd->config[MCH_HOST_BRIDGE_SMRAM ]);memory_region_set_enabled (&mch->smram, pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_G_SMRAME );memory_region_transaction_commit (); } -static void mch_set_smm (int smm,void *arg) -{ -MCHPCIState *mch = arg; -PCIDevice *pd =PCI_DEVICE (mch); - -memory_region_transaction_begin (); -smram_set_smm (&mch->smm_enabled, smm, pd->config[MCH_HOST_BRIDGE_SMRAM ], - &mch->smram_region); -memory_region_transaction_commit (); -} -static void mch_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len) {
@@ -331,7 +319,10 @@ static const VMStateDescription vmstate_mch = { .post_load = mch_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (parent_obj, MCHPCIState), -VMSTATE_UINT8 (smm_enabled, MCHPCIState), +/* Used to be smm_enabled, which was basically always zero because +* SeaBIOS hardly uses SMM. SMRAM is now handled by CPU code. +*/ +VMSTATE_UNUSED (1 ),VMSTATE_END_OF_LIST () } };
@@ -402,7 +393,6 @@ static void mch_realize(PCIDevice *d, Error **errp) mch->pci_address_space);/* if *disabled* show SMRAM to all CPUs */ -cpu_smm_register (&mch_set_smm, mch);memory_region_init_alias (&mch->smram_region,OBJECT (mch),"smram-region" , mch->pci_address_space,0xa0000 ,0x20000 ); memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,
@@ -413,7 +403,7 @@ static void mch_realize(PCIDevice *d, Error **errp)memory_region_init (&mch->smram,OBJECT (mch),"smram" ,1ull <<32 );memory_region_set_enabled (&mch->smram, true);memory_region_init_alias (&mch->low_smram,OBJECT (mch),"smram-low" , - mch->system_memory,0xa0000 ,0x20000 ); + mch->ram_memory,0xa0000 ,0x20000 );memory_region_set_enabled (&mch->low_smram, true);memory_region_add_subregion (&mch->smram,0xa0000 , &mch->low_smram); object_property_add_const_link(qdev_get_machine(), "smram",
include/hw/i386/pc.h +0 -1
@@ -210,7 +210,6 @@ void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);void pc_pci_device_init (PCIBus *pci_bus);typedef void (*cpu_set_smm_t )(int smm,void *arg); -void cpu_smm_register (cpu_set_smm_t callback,void *arg);void ioapic_init_gsi (GSIState *gsi_state,const char *parent_name);
include/hw/pci-host/pam.h +1 -4
@@ -86,10 +86,7 @@ typedef struct PAMMemoryRegion {unsigned current; } PAMMemoryRegion; -void smram_update (MemoryRegion *smram_region,uint8_t smram, -uint8_t smm_enabled); -void smram_set_smm (uint8_t *host_smm_enabled,int smm,uint8_t smram, -MemoryRegion *smram_region); +void smram_update (MemoryRegion *smram_region,uint8_t smram);void init_pam (DeviceState *dev,MemoryRegion *ram,MemoryRegion *system,MemoryRegion *pci,PAMMemoryRegion *mem,uint32_t start,uint32_t size);void pam_update (PAMMemoryRegion *mem,int idx,uint8_t val);
include/hw/pci-host/q35.h +0 -1
@@ -55,7 +55,6 @@ typedef struct MCHPCIState {MemoryRegion smram_region;MemoryRegion smram, low_smram;PcPciInfo pci_info; -uint8_t smm_enabled;ram_addr_t below_4g_mem_size;ram_addr_t above_4g_mem_size;uint64_t pci_hole64_size;
linux-user/main.c +0 -4
@@ -215,10 +215,6 @@ void cpu_list_unlock(void)/***********************************************************/ /* CPUX86 core interface */ -void cpu_smm_update (CPUX86State *env) -{ -} -uint64_t cpu_get_tsc (CPUX86State *env) {return cpu_get_real_ticks ();
target-i386/cpu-qom.h +3 -1
@@ -23,6 +23,7 @@#include "qom/cpu.h" #include "cpu.h" #include "qapi/error.h" +#include "qemu/notify.h" #ifdef TARGET_X86_64 #define TYPE_X86_CPU "x86_64-cpu"
@@ -111,7 +112,8 @@ typedef struct X86CPU {/* in order to simplify APIC support, we leave this pointer to the user */ struct DeviceState *apic_state; -struct MemoryRegion *cpu_as_root; +struct MemoryRegion *cpu_as_root, *cpu_as_mem, *smram; +Notifier machine_done; }X86CPU ;static inline X86CPU *x86_env_get_cpu (CPUX86State *env)
target-i386/cpu.c +31 -2
@@ -2751,6 +2751,21 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)object_property_set_bool (OBJECT (cpu->apic_state), true,"realized" , errp); } + +static void x86_cpu_machine_done (Notifier *n,void *unused) +{ +X86CPU *cpu =container_of (n,X86CPU , machine_done); +MemoryRegion *smram = + (MemoryRegion *)object_resolve_path ("/machine/smram" ,NULL ); + +if (smram) { + cpu->smram =g_new (MemoryRegion,1 ); +memory_region_init_alias (cpu->smram,OBJECT (cpu),"smram" , + smram,0 ,1ull <<32 ); +memory_region_set_enabled (cpu->smram, false); +memory_region_add_subregion_overlap (cpu->cpu_as_root,0 , cpu->smram,1 ); + } +}#else static void x86_cpu_apic_realize (X86CPU *cpu,Error **errp) {
@@ -2815,12 +2830,26 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)#ifndef CONFIG_USER_ONLY if (tcg_enabled ()) { + cpu->cpu_as_mem =g_new (MemoryRegion,1 ); cpu->cpu_as_root =g_new (MemoryRegion,1 ); cs->as =g_new (AddressSpace,1 ); -memory_region_init_alias (cpu->cpu_as_root,OBJECT (cpu),"memory" , -get_system_memory (),0 , ~0ull ); + +/* Outer container... */ +memory_region_init (cpu->cpu_as_root,OBJECT (cpu),"memory" , ~0ull );memory_region_set_enabled (cpu->cpu_as_root, true); + +/* ... with two regions inside: normal system memory with low +* priority, and... +*/ +memory_region_init_alias (cpu->cpu_as_mem,OBJECT (cpu),"memory" , +get_system_memory (),0 , ~0ull ); +memory_region_add_subregion_overlap (cpu->cpu_as_root,0 , cpu->cpu_as_mem,0 ); +memory_region_set_enabled (cpu->cpu_as_mem, true);address_space_init (cs->as, cpu->cpu_as_root,"CPU" ); + +/* ... SMRAM with higher priority, linked from /machine/smram. */ + cpu->machine_done.notify = x86_cpu_machine_done; +qemu_add_machine_init_done_notifier (&cpu->machine_done); }#endif
target-i386/cpu.h +2 -1
@@ -1157,7 +1157,6 @@ void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);void cpu_x86_update_cr4 (CPUX86State *env,uint32_t new_cr4);/* hw/pc.c */ -void cpu_smm_update (CPUX86State *env);uint64_t cpu_get_tsc (CPUX86State *env);#define TARGET_PAGE_BITS 12
@@ -1323,7 +1322,9 @@ void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_1);/* seg_helper.c */ void do_interrupt_x86_hardirq (CPUX86State *env,int intno,int is_hw); +/* smm_helper.c */ void do_smm_enter (X86CPU *cpu); +void cpu_smm_update (X86CPU *cpu);void cpu_report_tpr_access (CPUX86State *env,TPRAccess access);
target-i386/machine.c +3 -0
@@ -372,6 +372,9 @@ static int cpu_post_load(void *opaque, int version_id) }tlb_flush (cs,1 ); +if (tcg_enabled ()) { +cpu_smm_update (cpu); + }return 0 ; }
target-i386/smm_helper.c +12 -2
@@ -40,6 +40,16 @@ void helper_rsm(CPUX86State *env)#define SMM_REVISION_ID 0x00020000#endif +void cpu_smm_update (X86CPU *cpu) +{ +CPUX86State *env = &cpu->env; +bool smm_enabled = (env->hflags &HF_SMM_MASK ); + +if (cpu->smram) { +memory_region_set_enabled (cpu->smram, smm_enabled); + } +} +void do_smm_enter (X86CPU *cpu) {CPUX86State *env = &cpu->env;
@@ -57,7 +67,7 @@ void do_smm_enter(X86CPU *cpu) }else { env->hflags2 |=HF2_NMI_MASK ; } -cpu_smm_update (env); +cpu_smm_update (cpu); sm_state = env->smbase +0x8000 ;
@@ -317,7 +327,7 @@ void helper_rsm(CPUX86State *env) } env->hflags2 &= ~HF2_SMM_INSIDE_NMI_MASK ; env->hflags &= ~HF_SMM_MASK ; -cpu_smm_update (env); +cpu_smm_update (cpu);qemu_log_mask (CPU_LOG_INT ,"SMM: after RSM\n" );log_cpu_state_mask (CPU_LOG_INT ,CPU (cpu),CPU_DUMP_CCOP );
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 53/62] hw/i386: remove smram_update
In reply to Paolo BonziniIt's easier to inline it now that most of its work is done by the CPU (rather than the chipset) through /machine/smram and the memory API.
--- hw/pci-host/pam.c | 6 ------ hw/pci-host/piix.c | 3 ++- hw/pci-host/q35.c | 3 ++- include/hw/pci-host/pam.h | 1 - 4 files changed, 4 insertions(+), 9 deletions(-)
hw/pci-host/pam.c +0 -6
@@ -31,12 +31,6 @@#include "sysemu/sysemu.h" #include "hw/pci-host/pam.h" -void smram_update (MemoryRegion *smram_region,uint8_t smram) -{ -bool smram_enabled = (smram &SMRAM_D_OPEN ); -memory_region_set_enabled (smram_region, !smram_enabled); -} -void init_pam (DeviceState *dev,MemoryRegion *ram_memory,MemoryRegion *system_memory,MemoryRegion *pci_address_space,PAMMemoryRegion *mem,uint32_t start,uint32_t size)
hw/pci-host/piix.c +2 -1
@@ -138,7 +138,8 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)pam_update (&d->pam_regions[i], i, pd->config[I440FX_PAM + ((i +1 ) /2 )]); } -smram_update (&d->smram_region, pd->config[I440FX_SMRAM ]); +memory_region_set_enabled (&d->smram_region, + !(pd->config[I440FX_SMRAM ] &SMRAM_D_OPEN ));memory_region_set_enabled (&d->smram, pd->config[I440FX_SMRAM ] &SMRAM_G_SMRAME );memory_region_transaction_commit ();
hw/pci-host/q35.c +2 -1
@@ -268,7 +268,8 @@ static void mch_update_smram(MCHPCIState *mch)PCIDevice *pd =PCI_DEVICE (mch);memory_region_transaction_begin (); -smram_update (&mch->smram_region, pd->config[MCH_HOST_BRIDGE_SMRAM ]); +memory_region_set_enabled (&mch->smram_region, + !(pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_D_OPEN ));memory_region_set_enabled (&mch->smram, pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_G_SMRAME );memory_region_transaction_commit ();
include/hw/pci-host/pam.h +0 -1
@@ -86,7 +86,6 @@ typedef struct PAMMemoryRegion {unsigned current; } PAMMemoryRegion; -void smram_update (MemoryRegion *smram_region,uint8_t smram);void init_pam (DeviceState *dev,MemoryRegion *ram,MemoryRegion *system,MemoryRegion *pci,PAMMemoryRegion *mem,uint32_t start,uint32_t size);void pam_update (PAMMemoryRegion *mem,int idx,uint8_t val);
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 54/62] q35: implement high SMRAM
In reply to Paolo BonziniWhen H_SMRAME is 1, low memory at 0xa0000 is left alone by SMM, and instead the chipset maps the 0xa0000-0xbffff window at 0xfeda0000-0xfedbffff. This affects both the "non-SMM" view controlled by D_OPEN and the SMM view controlled by G_SMRAME, so add two new MemoryRegions and toggle the enabled/disabled state of all four in mch_update_smram.
--- hw/pci-host/q35.c | 35 +++++++++++++++++++++++++++++++---- include/hw/pci-host/q35.h | 16 ++++++++-------- 2 files changed, 39 insertions(+), 12 deletions(-)
hw/pci-host/q35.c +31 -4
@@ -266,12 +266,29 @@ static void mch_update_pam(MCHPCIState *mch)static void mch_update_smram (MCHPCIState *mch) {PCIDevice *pd =PCI_DEVICE (mch); +bool h_smrame = (pd->config[MCH_HOST_BRIDGE_ESMRAMC ] &MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME );memory_region_transaction_begin (); -memory_region_set_enabled (&mch->smram_region, - !(pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_D_OPEN )); -memory_region_set_enabled (&mch->smram, - pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_G_SMRAME ); + +if (pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_D_OPEN ) { +/* Hide (!) low SMRAM if H_SMRAME = 1 */ +memory_region_set_enabled (&mch->smram_region, h_smrame); +/* Show high SMRAM if H_SMRAME = 1 */ +memory_region_set_enabled (&mch->open_high_smram, h_smrame); + }else { +/* Hide high SMRAM and low SMRAM */ +memory_region_set_enabled (&mch->smram_region, true); +memory_region_set_enabled (&mch->open_high_smram, false); + } + +if (pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_G_SMRAME ) { +memory_region_set_enabled (&mch->low_smram, !h_smrame); +memory_region_set_enabled (&mch->high_smram, h_smrame); + }else { +memory_region_set_enabled (&mch->low_smram, false); +memory_region_set_enabled (&mch->high_smram, false); + } +memory_region_transaction_commit (); }
@@ -400,6 +417,12 @@ static void mch_realize(PCIDevice *d, Error **errp) &mch->smram_region, 1);memory_region_set_enabled (&mch->smram_region, true); +memory_region_init_alias (&mch->open_high_smram,OBJECT (mch),"smram-open-high" , + mch->ram_memory,0xa0000 ,0x20000 ); +memory_region_add_subregion_overlap (mch->system_memory,0xfeda0000 , + &mch->open_high_smram,1 ); +memory_region_set_enabled (&mch->open_high_smram, false); +/* smram, as seen by SMM CPUs */ memory_region_init (&mch->smram,OBJECT (mch),"smram" ,1ull <<32 );memory_region_set_enabled (&mch->smram, true);
@@ -407,6 +430,10 @@ static void mch_realize(PCIDevice *d, Error **errp) mch->ram_memory, 0xa0000, 0x20000);memory_region_set_enabled (&mch->low_smram, true);memory_region_add_subregion (&mch->smram,0xa0000 , &mch->low_smram); +memory_region_init_alias (&mch->high_smram,OBJECT (mch),"smram-high" , + mch->ram_memory,0xa0000 ,0x20000 ); +memory_region_set_enabled (&mch->high_smram, true); +memory_region_add_subregion (&mch->smram,0xfeda0000 , &mch->high_smram);object_property_add_const_link (qdev_get_machine (),"smram" ,OBJECT (&mch->smram), &error_abort);
include/hw/pci-host/q35.h +8 -8
@@ -52,8 +52,8 @@ typedef struct MCHPCIState {MemoryRegion *system_memory;MemoryRegion *address_space_io;PAMMemoryRegion pam_regions[13 ]; -MemoryRegion smram_region; -MemoryRegion smram, low_smram; +MemoryRegion smram_region, open_high_smram; +MemoryRegion smram, low_smram, high_smram;PcPciInfo pci_info;ram_addr_t below_4g_mem_size;ram_addr_t above_4g_mem_size;
@@ -127,7 +127,7 @@ typedef struct Q35PCIHost {#define MCH_HOST_BRIDGE_PAM_MASK ((uint8_t)0x3)#define MCH_HOST_BRIDGE_SMRAM 0x9d -#define MCH_HOST_BRIDGE_SMRAM_SIZE 1 +#define MCH_HOST_BRIDGE_SMRAM_SIZE 2#define MCH_HOST_BRIDGE_SMRAM_DEFAULT ((uint8_t)0x2)#define MCH_HOST_BRIDGE_SMRAM_D_OPEN ((uint8_t)(1 << 6))#define MCH_HOST_BRIDGE_SMRAM_D_CLS ((uint8_t)(1 << 5))
@@ -141,11 +141,11 @@ typedef struct Q35PCIHost {#define MCH_HOST_BRIDGE_UPPER_SYSTEM_BIOS_END 0x100000#define MCH_HOST_BRIDGE_ESMRAMC 0x9e -#define MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ((uint8_t)(1 << 6)) -#define MCH_HOST_BRIDGE_ESMRAMC_E_SMERR ((uint8_t)(1 << 5)) -#define MCH_HOST_BRIDGE_ESMRAMC_SM_CACHE ((uint8_t)(1 << 4)) -#define MCH_HOST_BRIDGE_ESMRAMC_SM_L1 ((uint8_t)(1 << 3)) -#define MCH_HOST_BRIDGE_ESMRAMC_SM_L2 ((uint8_t)(1 << 2)) +#define MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ((uint8_t)(1 << 7)) +#define MCH_HOST_BRIDGE_ESMRAMC_E_SMERR ((uint8_t)(1 << 6)) +#define MCH_HOST_BRIDGE_ESMRAMC_SM_CACHE ((uint8_t)(1 << 5)) +#define MCH_HOST_BRIDGE_ESMRAMC_SM_L1 ((uint8_t)(1 << 4)) +#define MCH_HOST_BRIDGE_ESMRAMC_SM_L2 ((uint8_t)(1 << 3))#define MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK ((uint8_t)(0x3 << 1))#define MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB ((uint8_t)(0x0 << 1))#define MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_2MB ((uint8_t)(0x1 << 1))
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 55/62] q35: fix ESMRAMC default
In reply to Paolo BonziniFrom: Gerd Hoffmann <[email protected]>
The cache bits in ESMRAMC are hardcoded to 1 (=disabled) according to the q35 mch specs. Add and use a define with this default.
While being at it also update the SMRAM default to use the name (no code change, just makes things a bit more readable).
--- hw/pci-host/q35.c | 1 + include/hw/pci-host/q35.h | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
hw/pci-host/q35.c +1 -0
@@ -354,6 +354,7 @@ static void mch_reset(DeviceState *qdev) MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT); d->config[MCH_HOST_BRIDGE_SMRAM ] =MCH_HOST_BRIDGE_SMRAM_DEFAULT ; + d->config[MCH_HOST_BRIDGE_ESMRAMC ] =MCH_HOST_BRIDGE_ESMRAMC_DEFAULT ;mch_update (mch); }
include/hw/pci-host/q35.h +6 -1
@@ -128,7 +128,6 @@ typedef struct Q35PCIHost {#define MCH_HOST_BRIDGE_SMRAM 0x9d#define MCH_HOST_BRIDGE_SMRAM_SIZE 2 -#define MCH_HOST_BRIDGE_SMRAM_DEFAULT ((uint8_t)0x2)#define MCH_HOST_BRIDGE_SMRAM_D_OPEN ((uint8_t)(1 << 6))#define MCH_HOST_BRIDGE_SMRAM_D_CLS ((uint8_t)(1 << 5))#define MCH_HOST_BRIDGE_SMRAM_D_LCK ((uint8_t)(1 << 4))
@@ -139,6 +138,8 @@ typedef struct Q35PCIHost {#define MCH_HOST_BRIDGE_SMRAM_C_END 0xc0000#define MCH_HOST_BRIDGE_SMRAM_C_SIZE 0x20000#define MCH_HOST_BRIDGE_UPPER_SYSTEM_BIOS_END 0x100000 +#define MCH_HOST_BRIDGE_SMRAM_DEFAULT \ + MCH_HOST_BRIDGE_SMRAM_C_BASE_SEG#define MCH_HOST_BRIDGE_ESMRAMC 0x9e#define MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ((uint8_t)(1 << 7))
@@ -151,6 +152,10 @@ typedef struct Q35PCIHost {#define MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_2MB ((uint8_t)(0x1 << 1))#define MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_8MB ((uint8_t)(0x2 << 1))#define MCH_HOST_BRIDGE_ESMRAMC_T_EN ((uint8_t)1) +#define MCH_HOST_BRIDGE_ESMRAMC_DEFAULT \ + (MCH_HOST_BRIDGE_ESMRAMC_SM_CACHE | \ + MCH_HOST_BRIDGE_ESMRAMC_SM_L1 | \ + MCH_HOST_BRIDGE_ESMRAMC_SM_L2)/* D1:F0 PCIE* port*/ #define MCH_PCIE_DEV 1
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 56/62] q35: add config space wmask for SMRAM and ESMRAMC
In reply to Paolo BonziniFrom: Gerd Hoffmann <[email protected]>
Not all bits in SMRAM and ESMRAMC can be changed by the guest. Add wmask defines accordingly and set them in mch_reset().
--- hw/pci-host/q35.c | 2 ++ include/hw/pci-host/q35.h | 9 +++++++++ 2 files changed, 11 insertions(+)
hw/pci-host/q35.c +2 -0
@@ -355,6 +355,8 @@ static void mch_reset(DeviceState *qdev) d->config[MCH_HOST_BRIDGE_SMRAM ] =MCH_HOST_BRIDGE_SMRAM_DEFAULT ; d->config[MCH_HOST_BRIDGE_ESMRAMC ] =MCH_HOST_BRIDGE_ESMRAMC_DEFAULT ; + d->wmask[MCH_HOST_BRIDGE_SMRAM ] =MCH_HOST_BRIDGE_SMRAM_WMASK ; + d->wmask[MCH_HOST_BRIDGE_ESMRAMC ] =MCH_HOST_BRIDGE_ESMRAMC_WMASK ;mch_update (mch); }
include/hw/pci-host/q35.h +9 -0
@@ -140,6 +140,11 @@ typedef struct Q35PCIHost {#define MCH_HOST_BRIDGE_UPPER_SYSTEM_BIOS_END 0x100000#define MCH_HOST_BRIDGE_SMRAM_DEFAULT \ MCH_HOST_BRIDGE_SMRAM_C_BASE_SEG +#define MCH_HOST_BRIDGE_SMRAM_WMASK \ + (MCH_HOST_BRIDGE_SMRAM_D_OPEN | \ + MCH_HOST_BRIDGE_SMRAM_D_CLS | \ + MCH_HOST_BRIDGE_SMRAM_D_LCK | \ + MCH_HOST_BRIDGE_SMRAM_G_SMRAME)#define MCH_HOST_BRIDGE_ESMRAMC 0x9e#define MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ((uint8_t)(1 << 7))
@@ -156,6 +161,10 @@ typedef struct Q35PCIHost { (MCH_HOST_BRIDGE_ESMRAMC_SM_CACHE | \MCH_HOST_BRIDGE_ESMRAMC_SM_L1 | \ MCH_HOST_BRIDGE_ESMRAMC_SM_L2) +#define MCH_HOST_BRIDGE_ESMRAMC_WMASK \ + (MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME | \ + MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK | \ + MCH_HOST_BRIDGE_ESMRAMC_T_EN)/* D1:F0 PCIE* port*/ #define MCH_PCIE_DEV 1
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 57/62] q35: implement SMRAM.D_LCK
In reply to Paolo BonziniFrom: Gerd Hoffmann <[email protected]>
Once the SMRAM.D_LCK bit has been set by the guest several bits in SMRAM and ESMRAMC become readonly until the next machine reset. Implement this by updating the wmask accordingly when the guest sets the lock bit. As the lock it itself is locked down too we don't need to worry about the guest clearing the lock bit.
--- hw/pci-host/q35.c | 8 +++++++- include/hw/pci-host/q35.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-)
hw/pci-host/q35.c +7 -1
@@ -268,6 +268,13 @@ static void mch_update_smram(MCHPCIState *mch)PCIDevice *pd =PCI_DEVICE (mch);bool h_smrame = (pd->config[MCH_HOST_BRIDGE_ESMRAMC ] &MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ); +/* implement SMRAM.D_LCK */ +if (pd->config[MCH_HOST_BRIDGE_SMRAM ] &MCH_HOST_BRIDGE_SMRAM_D_LCK ) { + pd->config[MCH_HOST_BRIDGE_SMRAM ] &= ~MCH_HOST_BRIDGE_SMRAM_D_OPEN ; + pd->wmask[MCH_HOST_BRIDGE_SMRAM ] =MCH_HOST_BRIDGE_SMRAM_WMASK_LCK ; + pd->wmask[MCH_HOST_BRIDGE_ESMRAMC ] =MCH_HOST_BRIDGE_ESMRAMC_WMASK_LCK ; + } +memory_region_transaction_begin ();if (pd->config[MCH_HOST_BRIDGE_SMRAM ] &SMRAM_D_OPEN ) {
@@ -297,7 +304,6 @@ static void mch_write_config(PCIDevice *d, {MCHPCIState *mch =MCH_PCI_DEVICE (d); -/* XXX: implement SMRAM.D_LOCK */ pci_default_write_config (d, address, val, len); if (ranges_overlap(address, len, MCH_HOST_BRIDGE_PAM0,
include/hw/pci-host/q35.h +3 -0
@@ -145,6 +145,8 @@ typedef struct Q35PCIHost { MCH_HOST_BRIDGE_SMRAM_D_CLS | \ MCH_HOST_BRIDGE_SMRAM_D_LCK | \ MCH_HOST_BRIDGE_SMRAM_G_SMRAME) +#define MCH_HOST_BRIDGE_SMRAM_WMASK_LCK \ + MCH_HOST_BRIDGE_SMRAM_D_CLS#define MCH_HOST_BRIDGE_ESMRAMC 0x9e#define MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ((uint8_t)(1 << 7))
@@ -165,6 +167,7 @@ typedef struct Q35PCIHost { (MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME | \MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK | \ MCH_HOST_BRIDGE_ESMRAMC_T_EN) +#define MCH_HOST_BRIDGE_ESMRAMC_WMASK_LCK 0/* D1:F0 PCIE* port*/ #define MCH_PCIE_DEV 1
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 58/62] q35: add test for SMRAM.D_LCK
In reply to Paolo BonziniFrom: Gerd Hoffmann <[email protected]>
--- tests/Makefile | 3 ++ tests/q35-test.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 tests/q35-test.c
tests/Makefile +3 -0
@@ -174,6 +174,8 @@ gcov-files-i386-y += hw/usb/dev-storage.c check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF) gcov-files-i386-y += hw/usb/hcd-xhci.c check-qtest-i386-y += tests/pc-cpu-test$(EXESUF) +check-qtest-i386-y += tests/q35-test$(EXESUF) +gcov-files-i386-y += hw/pci-host/q35.c check-qtest-i386-$(CONFIG_LINUX) += tests/vhost-user-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
@@ -389,6 +391,7 @@ tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y) tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y) tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y) tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o +tests/smram-test$(EXESUF): tests/smram-test.o $(libqos-pc-obj-y) tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a
tests/q35-test.c new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 60/62] ich9: implement SMI_LOCK
In reply to Paolo BonziniFrom: Gerd Hoffmann <[email protected]>
Add write mask for the smi enable register, so we can disable write access to certain bits. Open all bits on reset. Disable write access to GBL_SMI_EN when SMI_LOCK (in ich9 lpc pci config space) is set. Write access to SMI_LOCK itself is disabled too.
--- hw/acpi/ich9.c | 4 +++- hw/isa/lpc_ich9.c | 19 +++++++++++++++++++ include/hw/acpi/ich9.h | 1 + include/hw/i386/ich9.h | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +3 -1
@@ -94,7 +94,8 @@ static void ich9_smi_writel(void *opaque, hwaddr addr, uint64_t val,ICH9LPCPMRegs *pm = opaque;switch (addr) {case 0 : - pm->smi_en = val; + pm->smi_en &= ~pm->smi_en_wmask; + pm->smi_en |= (val & pm->smi_en_wmask);break ; } }
@@ -198,6 +199,7 @@ static void pm_reset(void *opaque)* support SMM mode. */ pm->smi_en |=ICH9_PMIO_SMI_EN_APMC_EN ; } + pm->smi_en_wmask = ~0 ;acpi_update_sci (&pm->acpi_regs, pm->irq); }
hw/isa/lpc_ich9.c +19 -0
@@ -407,12 +407,28 @@ static void ich9_lpc_rcba_update(ICH9LPCState *lpc, uint32_t rbca_old) } } +/* config:GEN_PMCON* */ +static void +ich9_lpc_pmcon_update (ICH9LPCState *lpc) +{ +uint16_t gen_pmcon_1 =pci_get_word (lpc->d.config +ICH9_LPC_GEN_PMCON_1 ); +uint16_t wmask; + +if (gen_pmcon_1 &ICH9_LPC_GEN_PMCON_1_SMI_LOCK ) { + wmask =pci_get_word (lpc->d.wmask +ICH9_LPC_GEN_PMCON_1 ); + wmask &= ~ICH9_LPC_GEN_PMCON_1_SMI_LOCK ; +pci_set_word (lpc->d.wmask +ICH9_LPC_GEN_PMCON_1 , wmask); + lpc->pm.smi_en_wmask &= ~1 ; + } +} +static int ich9_lpc_post_load (void *opaque,int version_id) {ICH9LPCState *lpc = opaque;ich9_lpc_pmbase_update (lpc);ich9_lpc_rcba_update (lpc,0 /* disabled ICH9_LPC_RBCA_EN */ ); +ich9_lpc_pmcon_update (lpc);return 0 ; }
@@ -435,6 +451,9 @@ static void ich9_lpc_config_write(PCIDevice *d,if (ranges_overlap (addr, len,ICH9_LPC_PIRQE_ROUT ,4 )) {pci_bus_fire_intx_routing_notifier (lpc->d.bus); } +if (ranges_overlap (addr, len,ICH9_LPC_GEN_PMCON_1 ,8 )) { +ich9_lpc_pmcon_update (lpc); + } }static void ich9_lpc_reset (DeviceState *qdev)
include/hw/acpi/ich9.h +1 -0
@@ -39,6 +39,7 @@ typedef struct ICH9LPCPMRegs {MemoryRegion io_smi;uint32_t smi_en; +uint32_t smi_en_wmask;uint32_t smi_sts;qemu_irq irq;/* SCI */
include/hw/i386/ich9.h +6 -0
@@ -152,6 +152,12 @@ Object *ich9_lpc_find(void);#define ICH9_LPC_PIRQ_ROUT_MASK Q35_MASK(8, 3, 0)#define ICH9_LPC_PIRQ_ROUT_DEFAULT 0x80 +#define ICH9_LPC_GEN_PMCON_1 0xa0 +#define ICH9_LPC_GEN_PMCON_1_SMI_LOCK (1 << 4) +#define ICH9_LPC_GEN_PMCON_2 0xa2 +#define ICH9_LPC_GEN_PMCON_3 0xa4 +#define ICH9_LPC_GEN_PMCON_LOCK 0xa6 +#define ICH9_LPC_RCBA 0xf0#define ICH9_LPC_RCBA_BA_MASK Q35_MASK(32, 31, 14)#define ICH9_LPC_RCBA_EN 0x1
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 59/62] q35: implement TSEG
In reply to Paolo BonziniFrom: Gerd Hoffmann <[email protected]>
TSEG provides larger amounts of SMRAM than the 128 KB available with legacy SMRAM and high SMRAM.
Route access to tseg into nowhere when enabled, for both cpus and busmaster dma, and add tseg window to smram region, so cpus can access it in smm mode.
--- hw/pci-host/q35.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/pci-host/q35.h | 1 + 2 files changed, 71 insertions(+)
hw/pci-host/q35.c +70 -0
@@ -198,6 +198,28 @@ static const TypeInfo q35_host_info = {* MCH D0:F0 */ +static uint64_t tseg_blackhole_read (void *ptr,hwaddr reg,unsigned size) +{ +return 0xffffffff ; +} + +static void tseg_blackhole_write (void *opaque,hwaddr addr,uint64_t val, +unsigned width) +{ +/* nothing */ +} + +static const MemoryRegionOps tseg_blackhole_ops = { + .read = tseg_blackhole_read, + .write = tseg_blackhole_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid.min_access_size =1 , + .valid.max_access_size =4 , + .impl.min_access_size =4 , + .impl.max_access_size =4 , + .endianness =DEVICE_LITTLE_ENDIAN , +}; +/* PCIe MMCFG */ static void mch_update_pciexbar (MCHPCIState *mch) {
@@ -267,6 +289,7 @@ static void mch_update_smram(MCHPCIState *mch) {PCIDevice *pd =PCI_DEVICE (mch);bool h_smrame = (pd->config[MCH_HOST_BRIDGE_ESMRAMC ] &MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME ); +uint32_t tseg_size;/* implement SMRAM.D_LCK */ if (pd->config[MCH_HOST_BRIDGE_SMRAM ] &MCH_HOST_BRIDGE_SMRAM_D_LCK ) {
@@ -296,6 +319,39 @@ static void mch_update_smram(MCHPCIState *mch)memory_region_set_enabled (&mch->high_smram, false); } +if (pd->config[MCH_HOST_BRIDGE_ESMRAMC ] &MCH_HOST_BRIDGE_ESMRAMC_T_EN ) { +switch (pd->config[MCH_HOST_BRIDGE_ESMRAMC ] & +MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK ) { +case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB : + tseg_size =1024 *1024 ; +break ; +case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_2MB : + tseg_size =1024 *1024 *2 ; +break ; +case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_8MB : + tseg_size =1024 *1024 *8 ; +break ; +default : + tseg_size =0 ; +break ; + } + }else { + tseg_size =0 ; + } +memory_region_del_subregion (mch->system_memory, &mch->tseg_blackhole); +memory_region_set_enabled (&mch->tseg_blackhole, tseg_size); +memory_region_set_size (&mch->tseg_blackhole, tseg_size); +memory_region_add_subregion_overlap (mch->system_memory, + mch->below_4g_mem_size - tseg_size, + &mch->tseg_blackhole,1 ); + +memory_region_set_enabled (&mch->tseg_window, tseg_size); +memory_region_set_size (&mch->tseg_window, tseg_size); +memory_region_set_address (&mch->tseg_window, + mch->below_4g_mem_size - tseg_size); +memory_region_set_alias_offset (&mch->tseg_window, + mch->below_4g_mem_size - tseg_size); +memory_region_transaction_commit (); }
@@ -443,6 +499,20 @@ static void mch_realize(PCIDevice *d, Error **errp) mch->ram_memory, 0xa0000, 0x20000);memory_region_set_enabled (&mch->high_smram, true);memory_region_add_subregion (&mch->smram,0xfeda0000 , &mch->high_smram); + +memory_region_init_io (&mch->tseg_blackhole,OBJECT (mch), + &tseg_blackhole_ops,NULL , +"tseg-blackhole" ,0 ); +memory_region_set_enabled (&mch->tseg_blackhole, false); +memory_region_add_subregion_overlap (mch->system_memory, + mch->below_4g_mem_size, + &mch->tseg_blackhole,1 ); + +memory_region_init_alias (&mch->tseg_window,OBJECT (mch),"tseg-window" , + mch->ram_memory, mch->below_4g_mem_size,0 ); +memory_region_set_enabled (&mch->tseg_window, false); +memory_region_add_subregion (&mch->smram, mch->below_4g_mem_size, + &mch->tseg_window);object_property_add_const_link (qdev_get_machine (),"smram" ,OBJECT (&mch->smram), &error_abort);
include/hw/pci-host/q35.h +1 -0
@@ -54,6 +54,7 @@ typedef struct MCHPCIState {PAMMemoryRegion pam_regions[13 ];MemoryRegion smram_region, open_high_smram;MemoryRegion smram, low_smram, high_smram; +MemoryRegion tseg_blackhole, tseg_window;PcPciInfo pci_info;ram_addr_t below_4g_mem_size;ram_addr_t above_4g_mem_size;
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 61/62] atomics: add explicit compiler fence in __atomic memory barriers
In reply to Paolo Bonzini__atomic_thread_fence does not include a compiler barrier; in the C++11 memory model, fences take effect in combination with other atomic operations. GCC implements this by making __atomic_load and __atomic_store access memory as if the pointer was volatile, and leaves no trace whatsoever of acquire and release fences in the compiler's intermediate representation.
In QEMU, we want memory barriers to act on all memory, but at the same time we would like to use __atomic_thread_fence for portability reasons. Add compiler barriers manually around the __atomic_thread_fence.
Message-Id: <[email protected]>
--- include/qemu/atomic.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
include/qemu/atomic.h +9 -3
@@ -99,7 +99,13 @@#ifndef smp_wmb#ifdef __ATOMIC_RELEASE -#define smp_wmb () __atomic_thread_fence(__ATOMIC_RELEASE) +/* __atomic_thread_fence does not include a compiler barrier; instead, +* the barrier is part of __atomic_load/__atomic_store's "volatile-like" +* semantics. If smp_wmb() is a no-op, absence of the barrier means that +* the compiler is free to reorder stores on each side of the barrier. +* Add one here, and similarly in smp_rmb() and smp_read_barrier_depends(). +*/ +#define smp_wmb () ({ barrier(); __atomic_thread_fence(__ATOMIC_RELEASE); barrier(); })#else #define smp_wmb () __sync_synchronize()#endif
@@ -107,7 +113,7 @@#ifndef smp_rmb#ifdef __ATOMIC_ACQUIRE -#define smp_rmb () __atomic_thread_fence(__ATOMIC_ACQUIRE) +#define smp_rmb () ({ barrier(); __atomic_thread_fence(__ATOMIC_ACQUIRE); barrier(); })#else #define smp_rmb () __sync_synchronize()#endif
@@ -115,7 +121,7 @@#ifndef smp_read_barrier_depends#ifdef __ATOMIC_CONSUME -#define smp_read_barrier_depends () __atomic_thread_fence(__ATOMIC_CONSUME) +#define smp_read_barrier_depends () ({ barrier(); __atomic_thread_fence(__ATOMIC_CONSUME); barrier(); })#else #define smp_read_barrier_depends () barrier()#endif
Signature · 1 line
2.4.1
[Qemu-devel] [PULL 62/62] update Linux headers from kvm/next
In reply to Paolo BonziniThis is kvm.git commit 05ff30bb56c6b3d3000519d6e02ed35678ddae3b.
--- include/standard-headers/linux/virtio_ring.h | 2 +- linux-headers/asm-x86/kvm.h | 14 +++++++++++++- linux-headers/linux/kvm.h | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-)
include/standard-headers/linux/virtio_ring.h +1 -1
@@ -155,7 +155,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align) }/* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */ -/* Assuming a given event_idx value from the other size, if +/* Assuming a given event_idx value from the other side, if * we have just incremented index from old to new_idx, * should we trigger an event? */ static inline int vring_need_event (uint16_t event_idx,uint16_t new_idx,uint16_t old)
linux-headers/asm-x86/kvm.h +13 -1
@@ -106,6 +106,8 @@ struct kvm_ioapic_state {#define KVM_IRQCHIP_IOAPIC 2#define KVM_NR_IRQCHIPS 3 +#define KVM_RUN_X86_SMM (1 << 0) +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
@@ -281,6 +283,7 @@ struct kvm_reinject_control {#define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001#define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002#define KVM_VCPUEVENT_VALID_SHADOW 0x00000004 +#define KVM_VCPUEVENT_VALID_SMM 0x00000008/* Interrupt shadow states */ #define KVM_X86_SHADOW_INT_MOV_SS 0x01
@@ -309,7 +312,13 @@ struct kvm_vcpu_events { } nmi;__u32 sipi_vector;__u32 flags; -__u32 reserved[10 ]; +struct { +__u8 smm; +__u8 pending; +__u8 smm_inside_nmi; +__u8 latched_init; + } smi; +__u32 reserved[9 ]; };/* for KVM_GET/SET_DEBUGREGS */
@@ -345,4 +354,7 @@ struct kvm_xcrs {struct kvm_sync_regs { }; +#define KVM_QUIRK_LINT0_REENABLED (1 << 0) +#define KVM_QUIRK_CD_NW_CLEARED (1 << 1) +#endif /* _ASM_X86_KVM_H */
linux-headers/linux/kvm.h +6 -1
@@ -202,7 +202,7 @@ struct kvm_run {__u32 exit_reason;__u8 ready_for_interrupt_injection;__u8 if_flag; -__u8 padding2[2 ]; +__u16 flags;/* in (pre_kvm_run), out (post_kvm_run) */ __u64 cr8;
@@ -814,6 +814,9 @@ struct kvm_ppc_smmu_info {#define KVM_CAP_S390_INJECT_IRQ 113#define KVM_CAP_S390_IRQ_STATE 114#define KVM_CAP_PPC_HWRNG 115 +#define KVM_CAP_DISABLE_QUIRKS 116 +#define KVM_CAP_X86_SMM 117 +#define KVM_CAP_MULTI_ADDRESS_SPACE 118#ifdef KVM_CAP_IRQ_ROUTING
@@ -1199,6 +1202,8 @@ struct kvm_s390_ucas_mapping {/* Available with KVM_CAP_S390_IRQ_STATE */ #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)#define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) +/* Available with KVM_CAP_X86_SMM */ +#define KVM_SMI _IO(KVMIO, 0xb7)#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
Signature · 1 line
2.4.1
Quoted 170 lines · Paolo Bonzini
The following changes since commit
00967f4e0bab246679d0ddc32fd31a7179345baf:Merge remote-tracking branch 'remotes/agraf/tags/signed-s390-for-upstream' into staging (2015-06-05 12:04:42 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
4f4edb40f55b130b00960abc826a588b31bd3308:update Linux headers from kvm/next (2015-06-05 17:10:02 +0200)
Apologies for the very large pull request, mostly due to the two main topics (dirty bitmap + SMM) being reviewed more or less at the same time.
----------------------------------------------------------------
* KVM error improvement from Laurent
*CONFIG_PARALLELfix from Mirek
* Atomic/optimized dirty bitmap access from myself and Stefan
*BUILD_DIRconvenience/bugfix from Peter C
* Memory leak fix from Shannon
* SMM improvements (though still TCG only) from myself and Gerd, acked by mst----------------------------------------------------------------
Fam Zheng (1):
qemu-nbd: Switch toqemu_set_fd_handlerGerd Hoffmann (6):
q35: fix ESMRAMC default
q35: add config space wmask for SMRAM and ESMRAMC
q35: implement SMRAM.D_LCK
q35: add test for SMRAM.D_LCK
q35: implement TSEG
ich9: implementSMI_LOCKLaurent Vivier (1):
ppc: add helpful message when KVM fails to start VCPUMiroslav Rezanina (1):
Moveparallel_hds_isa_inittohw/isa/isa-bus.cPaolo Bonzini (43):
exec: optimizephys_page_set_level
memory: the only dirty memory flag for users isDIRTY_MEMORY_VGA
g364fb: remove pointless call tomemory_region_set_coalescing
display: enableDIRTY_MEMORY_VGAtracking explicitly
display: addmemory_region_sync_dirty_bitmapcalls
memory: differentiatememory_region_is_loggingandmemory_region_get_dirty_log_mask
memory: prepare for multiple bits in the dirty log mask
framebuffer: checkmemory_region_is_logging
ui/console: removedpy_gfx_update_dirty
memory: trackDIRTY_MEMORY_CODEinmr->dirty_log_mask
kvm: accept non-mapped memory inkvm_dirty_pages_log_change
memory: includeDIRTY_MEMORY_MIGRATIONin the dirty log mask
kvm: remove special handling ofDIRTY_MEMORY_MIGRATIONin the dirty log mask
ram_addr: tweaks toxen_modified_memory
exec: usememory_region_get_dirty_log_maskto optimize dirty tracking
exec: move functions totranslate-all.h
translate-all: remove unnecessary argument totb_invalidate_phys_range
cputlb: remove useless arguments totlb_unprotect_code_phys, rename
translate-all: make less oftb_invalidate_phys_page_rangedepend onis_cpu_write_access
exec: pass client mask tocpu_physical_memory_set_dirty_range
exec: invert return value ofcpu_physical_memory_get_clean, rename
exec: only check relevant bitmaps for cleanliness
memory: do not touch code dirty bitmap unless TCG is enabled
memory: usemr->ram_addrin "is this RAM?" assertions
target-i386: introducecpu_get_mem_attrs
target-i386: Use correct memory attributes for memory accesses
target-i386: Use correct memory attributes for ioport accesses
target-i386: mask NMIs on entry to SMM
target-i386: set G=1 in SMM big real mode selectors
target-i386: wake up processors that receive an SMI
pflash_cfi01: change big-endian property to BIT type
pflash_cfi01: change to new-style MMIO accessors
pflash_cfi01: add secure property
vl: allow full-blown QemuOpts syntax for -global
qom: addobject_property_add_const_link
vl: run "late" notifiers immediately
target-i386: create a separate AddressSpace for each CPU
hw/i386: add a separate region that tracks the SMRAME bit
target-i386: use memory API to implement SMRAM
hw/i386: removesmram_update
q35: implement high SMRAM
atomics: add explicit compiler fence in__atomicmemory barriers
update Linux headers from kvm/nextPeter Crosthwaite (1):
Makefile.target: set masterBUILD_DIRStefan Hajnoczi (6):
bitmap: add atomic set functions
bitmap: add atomic test and clear
memory: use atomic ops for setting dirty memory bits
migration: move dirty bitmap sync toram_addr.h
memory: replacecpu_physical_memory_reset_dirty()with test-and-clear
memory: makecpu_physical_memory_sync_dirty_bitmap()fully atomicVictor CLEMENT (3):
icount: implement a newicount_sleepmode toggleing real-time cpu sleep
icount: add sleep parameter to the icount option to seticount_sleepmode
icount: print a warning if there is no more deadline in sleep=no modeMakefile.target | 2 + arch_init.c | 46 +--- bsd-user/main.c | 4 - cpus.c | 84 ++++--- cputlb.c | 7 +- exec.c | 123 +++++----- hw/acpi/ich9.c | 4 +- hw/block/pflash_cfi01.c | 204 +++++++--------- hw/char/parallel.c | 25 -- hw/display/cg3.c | 2 + hw/display/exynos4210_fimd.c | 20 +- hw/display/framebuffer.c | 4 + hw/display/g364fb.c | 3 +- hw/display/sm501.c | 2 + hw/display/tcx.c | 3 + hw/display/vmware_vga.c | 2 +- hw/i386/pc.c | 21 -- hw/isa/isa-bus.c | 26 +++ hw/isa/lpc_ich9.c | 19 ++ hw/pci-host/pam.c | 20 -- hw/pci-host/piix.c | 44 ++-- hw/pci-host/q35.c | 142 ++++++++++-- hw/virtio/dataplane/vring.c | 2 +- hw/virtio/vhost.c | 9 +- include/exec/cputlb.h | 3 +- include/exec/exec-all.h | 6 +- include/exec/memattrs.h | 4 +- include/exec/memory.h | 25 +- include/exec/ram_addr.h | 138 +++++++---- include/hw/acpi/ich9.h | 1 + include/hw/i386/ich9.h | 6 + include/hw/i386/pc.h | 1 - include/hw/pci-host/pam.h | 4 - include/hw/pci-host/q35.h | 36 ++- include/qemu/atomic.h | 12 +- include/qemu/bitmap.h | 4 + include/qemu/bitops.h | 14 ++ include/qom/object.h | 18 ++ include/standard-headers/linux/virtio_ring.h | 2 +- include/ui/console.h | 4 - kvm-all.c | 85 ++----- linux-headers/asm-x86/kvm.h | 14 +- linux-headers/linux/kvm.h | 7 +- linux-user/main.c | 4 - linux-user/mmap.c | 7 +- memory.c | 81 +++++-- qdev-monitor.c | 18 +- qemu-nbd.c | 21 +- qemu-options.hx | 19 +- qom/object.c | 16 ++ target-i386/Makefile.objs | 2 - target-i386/cpu-qom.h | 3 + target-i386/cpu.c | 47 +++- target-i386/cpu.h | 40 +++- target-i386/helper.c | 135 +++++++++-- target-i386/helper.h | 12 +- target-i386/ioport-user.c | 60 ----- target-i386/kvm.c | 2 +- target-i386/machine.c | 3 + target-i386/misc_helper.c | 59 +++-- target-i386/seg_helper.c | 12 +- target-i386/smm_helper.c | 333 ++++++++++++++------------- target-i386/svm_helper.c | 230 +++++++++--------- target-i386/translate.c | 12 +- tests/Makefile | 3 + tests/q35-test.c | 91 ++++++++ translate-all.c | 20 +- translate-all.h | 7 +
Quoted 9 lines
ui/console.c | 61 ----- user-exec.c | 1 + util/bitmap.c | 83 +++++++ vl.c | 9 + xen-hvm.c | 22 +- 73 files changed, 1560 insertions(+), 1055 deletions(-) delete mode 100644 target-i386/ioport-user.c create mode 100644 tests/q35-test.c
The final rebase to origin/master broke qtest. Sent one patch for an existing breakage, but this pull request has to be redone as well.
Paolo