Merge remote-tracking branch 'unicorn-engine/master' into msvc_native

This commit is contained in:
xorstream
2017-01-20 22:37:51 +11:00
32 changed files with 7 additions and 1189 deletions

View File

@@ -169,8 +169,6 @@ struct TranslationBlock {
uint32_t icount;
};
#include "exec/spinlock.h"
typedef struct TBContext TBContext;
struct TBContext {
@@ -178,8 +176,6 @@ struct TBContext {
TranslationBlock *tbs;
TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE];
int nb_tbs;
/* any access to the tbs or the page table must use this lock */
spinlock_t tb_lock;
/* statistics */
int tb_flush_count;

View File

@@ -16,10 +16,8 @@
#ifndef CONFIG_USER_ONLY
#define DIRTY_MEMORY_VGA 0
#define DIRTY_MEMORY_CODE 1
#define DIRTY_MEMORY_MIGRATION 2
#define DIRTY_MEMORY_NUM 3 /* num of dirty bits */
#define DIRTY_MEMORY_CODE 0
#define DIRTY_MEMORY_NUM 1 /* num of dirty bits */
#include "platform.h"
#include "qemu-common.h"
@@ -29,7 +27,6 @@
#endif
#include "qemu/queue.h"
#include "qemu/int128.h"
#include "qemu/notify.h"
#include "qapi/error.h"
#include "qom/object.h"
@@ -167,7 +164,6 @@ struct MemoryRegion {
uint8_t dirty_log_mask;
unsigned ioeventfd_nb;
MemoryRegionIoeventfd *ioeventfds;
NotifierList iommu_notify;
struct uc_struct *uc;
uint32_t perms; //all perms, partially redundant with readonly
uint64_t end;
@@ -498,25 +494,6 @@ bool memory_region_is_iommu(MemoryRegion *mr);
void memory_region_notify_iommu(MemoryRegion *mr,
IOMMUTLBEntry entry);
/**
* memory_region_register_iommu_notifier: register a notifier for changes to
* IOMMU translation entries.
*
* @mr: the memory region to observe
* @n: the notifier to be added; the notifier receives a pointer to an
* #IOMMUTLBEntry as the opaque value; the pointer ceases to be
* valid on exit from the notifier.
*/
void memory_region_register_iommu_notifier(MemoryRegion *mr, Notifier *n);
/**
* memory_region_unregister_iommu_notifier: unregister a notifier for
* changes to IOMMU translation entries.
*
* @n: the notifier to be removed.
*/
void memory_region_unregister_iommu_notifier(Notifier *n);
/**
* memory_region_name: get a memory region's name
*

View File

@@ -70,21 +70,13 @@ static inline bool cpu_physical_memory_get_dirty_flag(struct uc_struct *uc, ram_
static inline bool cpu_physical_memory_is_clean(struct uc_struct *uc, ram_addr_t addr)
{
bool vga = cpu_physical_memory_get_dirty_flag(uc, addr, DIRTY_MEMORY_VGA);
bool code = cpu_physical_memory_get_dirty_flag(uc, addr, DIRTY_MEMORY_CODE);
bool migration =
cpu_physical_memory_get_dirty_flag(uc, addr, DIRTY_MEMORY_MIGRATION);
return !(vga && code && migration);
return !cpu_physical_memory_get_dirty_flag(uc, addr, DIRTY_MEMORY_CODE);
}
static inline bool cpu_physical_memory_range_includes_clean(struct uc_struct *uc, ram_addr_t start,
ram_addr_t length)
{
bool vga = cpu_physical_memory_get_clean(uc, start, length, DIRTY_MEMORY_VGA);
bool code = cpu_physical_memory_get_clean(uc, start, length, DIRTY_MEMORY_CODE);
bool migration =
cpu_physical_memory_get_clean(uc, start, length, DIRTY_MEMORY_MIGRATION);
return vga || code || migration;
return cpu_physical_memory_get_clean(uc, start, length, DIRTY_MEMORY_CODE);
}
static inline void cpu_physical_memory_set_dirty_flag(struct uc_struct *uc, ram_addr_t addr,
@@ -94,17 +86,6 @@ static inline void cpu_physical_memory_set_dirty_flag(struct uc_struct *uc, ram_
set_bit(addr >> TARGET_PAGE_BITS, uc->ram_list.dirty_memory[client]);
}
static inline void cpu_physical_memory_set_dirty_range_nocode(struct uc_struct *uc, 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(uc->ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
bitmap_set(uc->ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
}
static inline void cpu_physical_memory_set_dirty_range(struct uc_struct *uc, ram_addr_t start,
ram_addr_t length)
{
@@ -112,8 +93,6 @@ static inline void cpu_physical_memory_set_dirty_range(struct uc_struct *uc, ram
end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
page = start >> TARGET_PAGE_BITS;
bitmap_set(uc->ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
bitmap_set(uc->ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
bitmap_set(uc->ram_list.dirty_memory[DIRTY_MEMORY_CODE], page, end - page);
}
@@ -139,9 +118,6 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(struct uc_struct *uc,
for (k = 0; k < nr; k++) {
if (bitmap[k]) {
unsigned long temp = leul_to_cpu(bitmap[k]);
uc->ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION][page + k] |= temp;
uc->ram_list.dirty_memory[DIRTY_MEMORY_VGA][page + k] |= temp;
uc->ram_list.dirty_memory[DIRTY_MEMORY_CODE][page + k] |= temp;
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright (c) 2003 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>
*/
/* configure guarantees us that we have pthreads on any host except
* mingw32, which doesn't support any of the user-only targets.
* So we can simply assume we have pthread mutexes here.
*/
#ifndef QEMU_EXEC_SPINLOCK_H
#define QEMU_EXEC_SPINLOCK_H
#if defined(CONFIG_USER_ONLY)
#include <pthread.h>
#define spin_lock pthread_mutex_lock
#define spin_unlock pthread_mutex_unlock
#define spinlock_t pthread_mutex_t
#define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER
#else
/* Empty implementations, on the theory that system mode emulation
* is single-threaded. This means that these functions should only
* be used from code run in the TCG cpu thread, and cannot protect
* data structures which might also be accessed from the IO thread
* or from signal handlers.
*/
typedef int spinlock_t;
#define SPIN_LOCK_UNLOCKED 0
static inline void spin_lock(spinlock_t *lock)
{
}
static inline void spin_unlock(spinlock_t *lock)
{
}
#endif
#endif

View File

@@ -1,72 +0,0 @@
/*
* Notifier lists
*
* Copyright IBM, Corp. 2010
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/
#ifndef QEMU_NOTIFY_H
#define QEMU_NOTIFY_H
#include "qemu/queue.h"
typedef struct Notifier Notifier;
struct Notifier
{
void (*notify)(Notifier *notifier, void *data);
QLIST_ENTRY(Notifier) node;
};
typedef struct NotifierList
{
QLIST_HEAD(, Notifier) notifiers;
} NotifierList;
#define NOTIFIER_LIST_INITIALIZER(head) \
{ QLIST_HEAD_INITIALIZER((head).notifiers) }
void notifier_list_init(NotifierList *list);
void notifier_list_add(NotifierList *list, Notifier *notifier);
void notifier_remove(Notifier *notifier);
void notifier_list_notify(NotifierList *list, void *data);
/* Same as Notifier but allows .notify() to return errors */
typedef struct NotifierWithReturn NotifierWithReturn;
struct NotifierWithReturn {
/**
* Return 0 on success (next notifier will be invoked), otherwise
* notifier_with_return_list_notify() will stop and return the value.
*/
int (*notify)(NotifierWithReturn *notifier, void *data);
QLIST_ENTRY(NotifierWithReturn) node;
};
typedef struct NotifierWithReturnList {
QLIST_HEAD(, NotifierWithReturn) notifiers;
} NotifierWithReturnList;
#define NOTIFIER_WITH_RETURN_LIST_INITIALIZER(head) \
{ QLIST_HEAD_INITIALIZER((head).notifiers) }
void notifier_with_return_list_init(NotifierWithReturnList *list);
void notifier_with_return_list_add(NotifierWithReturnList *list,
NotifierWithReturn *notifier);
void notifier_with_return_remove(NotifierWithReturn *notifier);
int notifier_with_return_list_notify(NotifierWithReturnList *list,
void *data);
#endif

View File

@@ -3,10 +3,6 @@
#include "pthread.h"
#include <semaphore.h>
struct QemuMutex {
pthread_mutex_t lock;
};
struct QemuThread {
pthread_t thread;
};

View File

@@ -2,11 +2,6 @@
#define __QEMU_THREAD_WIN32_H 1
#include "windows.h"
struct QemuMutex {
CRITICAL_SECTION lock;
LONG owner;
};
typedef struct QemuThreadData QemuThreadData;
struct QemuThread {
QemuThreadData *data;

View File

@@ -3,7 +3,6 @@
#include "platform.h"
typedef struct QemuMutex QemuMutex;
typedef struct QemuThread QemuThread;
#ifdef _WIN32
@@ -15,11 +14,6 @@ typedef struct QemuThread QemuThread;
#define QEMU_THREAD_JOINABLE 0
#define QEMU_THREAD_DETACHED 1
void qemu_mutex_init(QemuMutex *mutex);
void qemu_mutex_destroy(QemuMutex *mutex);
void qemu_mutex_lock(QemuMutex *mutex);
void qemu_mutex_unlock(QemuMutex *mutex);
struct uc_struct;
// return -1 on error, 0 on success
int qemu_thread_create(struct uc_struct *uc, QemuThread *thread, const char *name,

View File

@@ -3,7 +3,6 @@
#include "qemu/typedefs.h"
#include "qemu-common.h"
#include "qemu/notify.h"
/* timers */
@@ -106,322 +105,6 @@ static inline int64_t qemu_clock_get_us(QEMUClockType type)
return qemu_clock_get_ns(type) / SCALE_US;
}
/*
* QEMUTimerList
*/
/**
* timerlist_new:
* @type: the clock type to associate with the timerlist
* @cb: the callback to call on notification
* @opaque: the opaque pointer to pass to the callback
*
* Create a new timerlist associated with the clock of
* type @type.
*
* Returns: a pointer to the QEMUTimerList created
*/
QEMUTimerList *timerlist_new(QEMUClockType type,
QEMUTimerListNotifyCB *cb, void *opaque);
/**
* timerlist_free:
* @timer_list: the timer list to free
*
* Frees a timer_list. It must have no active timers.
*/
void timerlist_free(QEMUTimerList *timer_list);
/**
* timerlist_has_timers:
* @timer_list: the timer list to operate on
*
* Determine whether a timer list has active timers
*
* Note that this function should not be used when other threads also access
* the timer list. The return value may be outdated by the time it is acted
* upon.
*
* Returns: true if the timer list has timers.
*/
bool timerlist_has_timers(QEMUTimerList *timer_list);
/**
* timerlist_expired:
* @timer_list: the timer list to operate on
*
* Determine whether a timer list has any timers which
* are expired.
*
* Returns: true if the timer list has timers which
* have expired.
*/
bool timerlist_expired(QEMUTimerList *timer_list);
/**
* timerlist_deadline_ns:
* @timer_list: the timer list to operate on
*
* Determine the deadline for a timer_list, i.e.
* the number of nanoseconds until the first timer
* expires. Return -1 if there are no timers.
*
* Returns: the number of nanoseconds until the earliest
* timer expires -1 if none
*/
int64_t timerlist_deadline_ns(QEMUTimerList *timer_list);
/**
* timerlist_get_clock:
* @timer_list: the timer list to operate on
*
* Determine the clock type associated with a timer list.
*
* Returns: the clock type associated with the
* timer list.
*/
QEMUClockType timerlist_get_clock(QEMUTimerList *timer_list);
/**
* timerlist_run_timers:
* @timer_list: the timer list to use
*
* Call all expired timers associated with the timer list.
*
* Returns: true if any timer expired
*/
bool timerlist_run_timers(QEMUTimerList *timer_list);
/**
* timerlist_notify:
* @timer_list: the timer list to use
*
* call the notifier callback associated with the timer list.
*/
void timerlist_notify(QEMUTimerList *timer_list);
/*
* QEMUTimerListGroup
*/
/**
* timerlistgroup_init:
* @tlg: the timer list group
* @cb: the callback to call when a notify is required
* @opaque: the opaque pointer to be passed to the callback.
*
* Initialise a timer list group. This must already be
* allocated in memory and zeroed. The notifier callback is
* called whenever a clock in the timer list group is
* reenabled or whenever a timer associated with any timer
* list is modified. If @cb is specified as null, qemu_notify()
* is used instead.
*/
void timerlistgroup_init(QEMUTimerListGroup *tlg,
QEMUTimerListNotifyCB *cb, void *opaque);
/**
* timerlistgroup_deinit:
* @tlg: the timer list group
*
* Deinitialise a timer list group. This must already be
* initialised. Note the memory is not freed.
*/
void timerlistgroup_deinit(QEMUTimerListGroup *tlg);
/**
* timerlistgroup_run_timers:
* @tlg: the timer list group
*
* Run the timers associated with a timer list group.
* This will run timers on multiple clocks.
*
* Returns: true if any timer callback ran
*/
bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg);
/**
* timerlistgroup_deadline_ns:
* @tlg: the timer list group
*
* Determine the deadline of the soonest timer to
* expire associated with any timer list linked to
* the timer list group. Only clocks suitable for
* deadline calculation are included.
*
* Returns: the deadline in nanoseconds or -1 if no
* timers are to expire.
*/
int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg);
/*
* QEMUTimer
*/
/**
* timer_init:
* @ts: the timer to be initialised
* @timer_list: the timer list to attach the timer to
* @scale: the scale value for the timer
* @cb: the callback to be called when the timer expires
* @opaque: the opaque pointer to be passed to the callback
*
* Initialise a new timer and associate it with @timer_list.
* The caller is responsible for allocating the memory.
*
* You need not call an explicit deinit call. Simply make
* sure it is not on a list with timer_del.
*/
void timer_init(QEMUTimer *ts,
QEMUTimerList *timer_list, int scale,
QEMUTimerCB *cb, void *opaque);
/**
* timer_new_tl:
* @timer_list: the timer list to attach the timer to
* @scale: the scale value for the timer
* @cb: the callback to be called when the timer expires
* @opaque: the opaque pointer to be passed to the callback
*
* Creeate a new timer and associate it with @timer_list.
* The memory is allocated by the function.
*
* This is not the preferred interface unless you know you
* are going to call timer_free. Use timer_init instead.
*
* Returns: a pointer to the timer
*/
static inline QEMUTimer *timer_new_tl(QEMUTimerList *timer_list,
int scale,
QEMUTimerCB *cb,
void *opaque)
{
QEMUTimer *ts = g_malloc0(sizeof(QEMUTimer));
timer_init(ts, timer_list, scale, cb, opaque);
return ts;
}
/**
* timer_free:
* @ts: the timer
*
* Free a timer (it must not be on the active list)
*/
void timer_free(QEMUTimer *ts);
/**
* timer_del:
* @ts: the timer
*
* Delete a timer from the active list.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_del(QEMUTimer *ts);
/**
* timer_mod_ns:
* @ts: the timer
* @expire_time: the expiry time in nanoseconds
*
* Modify a timer to expire at @expire_time
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod_ns(QEMUTimer *ts, int64_t expire_time);
/**
* timer_mod_anticipate_ns:
* @ts: the timer
* @expire_time: the expiry time in nanoseconds
*
* Modify a timer to expire at @expire_time or the current time,
* whichever comes earlier.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod_anticipate_ns(QEMUTimer *ts, int64_t expire_time);
/**
* timer_mod:
* @ts: the timer
* @expire_time: the expire time in the units associated with the timer
*
* Modify a timer to expiry at @expire_time, taking into
* account the scale associated with the timer.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod(QEMUTimer *ts, int64_t expire_timer);
/**
* timer_mod_anticipate:
* @ts: the timer
* @expire_time: the expiry time in nanoseconds
*
* Modify a timer to expire at @expire_time or the current time, whichever
* comes earlier, taking into account the scale associated with the timer.
*
* This function is thread-safe but the timer and its timer list must not be
* freed while this function is running.
*/
void timer_mod_anticipate(QEMUTimer *ts, int64_t expire_time);
/**
* timer_pending:
* @ts: the timer
*
* Determines whether a timer is pending (i.e. is on the
* active list of timers, whether or not it has not yet expired).
*
* Returns: true if the timer is pending
*/
bool timer_pending(QEMUTimer *ts);
/**
* timer_expired:
* @ts: the timer
*
* Determines whether a timer has expired.
*
* Returns: true if the timer has expired
*/
bool timer_expired(QEMUTimer *timer_head, int64_t current_time);
/**
* timer_expire_time_ns:
* @ts: the timer
*
* Determine the expiry time of a timer
*
* Returns: the expiry time in nanoseconds
*/
uint64_t timer_expire_time_ns(QEMUTimer *ts);
/**
* timer_get:
* @f: the file
* @ts: the timer
*
* Read a timer @ts from a file @f
*/
void timer_get(QEMUFile *f, QEMUTimer *ts);
/**
* timer_put:
* @f: the file
* @ts: the timer
*/
void timer_put(QEMUFile *f, QEMUTimer *ts);
/*
* General utility functions
*/
/**
* qemu_timeout_ns_to_ms:
* @ns: nanosecond timeout value