From b2a8658ef5dc57ea9e7a45091724a719dd4bdcd3 Mon Sep 17 00:00:00 2001 From: Umesh Deshpande Date: Wed, 17 Aug 2011 00:01:33 -0700 Subject: protect the ramlist with a separate mutex Add the new mutex that protects shared state between ram_save_live and the iothread. If the iothread mutex has to be taken together with the ramlist mutex, the iothread shall always be _outside_. Signed-off-by: Paolo Bonzini Signed-off-by: Umesh Deshpande Signed-off-by: Juan Quintela Reviewed-by: Orit Wasserman --- include/exec/cpu-all.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/exec') diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index f052b38..439e88d 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -22,6 +22,7 @@ #include "qemu-common.h" #include "qemu/tls.h" #include "exec/cpu-common.h" +#include "qemu/thread.h" /* some important defines: * @@ -487,6 +488,9 @@ typedef struct RAMBlock { ram_addr_t length; uint32_t flags; char idstr[256]; + /* Reads can take either the iothread or the ramlist lock. + * Writes must take both locks. + */ QTAILQ_ENTRY(RAMBlock) next; #if defined(__linux__) && !defined(TARGET_S390X) int fd; @@ -494,8 +498,11 @@ typedef struct RAMBlock { } RAMBlock; typedef struct RAMList { + QemuMutex mutex; + /* Protected by the iothread lock. */ uint8_t *phys_dirty; RAMBlock *mru_block; + /* Protected by the ramlist lock. */ QTAILQ_HEAD(, RAMBlock) blocks; uint32_t version; } RAMList; @@ -516,6 +523,8 @@ extern int mem_prealloc; void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); ram_addr_t last_ram_offset(void); +void qemu_mutex_lock_ramlist(void); +void qemu_mutex_unlock_ramlist(void); #endif /* !CONFIG_USER_ONLY */ int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, -- cgit v1.1