mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
replay: push replay_mutex_lock up the call tree
Now instead of using the replay_lock to guard the output of the log we now use it to protect the whole execution section. This replaces what the BQL used to do when it was held during TCG execution. We also introduce some rules for locking order - mainly that you cannot take the replay_mutex while holding the BQL. This leads to some slight sophistry during start-up and extending the replay_mutex_destroy function to unlock the mutex without checking for the BQL condition so it can be cleanly dropped in the non-replay case. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru> Tested-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru> Message-Id: <20180227095248.1060.40374.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
parent
1a423896fa
commit
d759c951f3
10 changed files with 109 additions and 76 deletions
|
@ -96,25 +96,24 @@ void *replay_event_char_read_load(void)
|
|||
|
||||
void replay_char_write_event_save(int res, int offset)
|
||||
{
|
||||
g_assert(replay_mutex_locked());
|
||||
|
||||
replay_save_instructions();
|
||||
replay_mutex_lock();
|
||||
replay_put_event(EVENT_CHAR_WRITE);
|
||||
replay_put_dword(res);
|
||||
replay_put_dword(offset);
|
||||
replay_mutex_unlock();
|
||||
}
|
||||
|
||||
void replay_char_write_event_load(int *res, int *offset)
|
||||
{
|
||||
g_assert(replay_mutex_locked());
|
||||
|
||||
replay_account_executed_instructions();
|
||||
replay_mutex_lock();
|
||||
if (replay_next_event_is(EVENT_CHAR_WRITE)) {
|
||||
*res = replay_get_dword();
|
||||
*offset = replay_get_dword();
|
||||
replay_finish_event();
|
||||
replay_mutex_unlock();
|
||||
} else {
|
||||
replay_mutex_unlock();
|
||||
error_report("Missing character write event in the replay log");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -122,23 +121,21 @@ void replay_char_write_event_load(int *res, int *offset)
|
|||
|
||||
int replay_char_read_all_load(uint8_t *buf)
|
||||
{
|
||||
replay_mutex_lock();
|
||||
g_assert(replay_mutex_locked());
|
||||
|
||||
if (replay_next_event_is(EVENT_CHAR_READ_ALL)) {
|
||||
size_t size;
|
||||
int res;
|
||||
replay_get_array(buf, &size);
|
||||
replay_finish_event();
|
||||
replay_mutex_unlock();
|
||||
res = (int)size;
|
||||
assert(res >= 0);
|
||||
return res;
|
||||
} else if (replay_next_event_is(EVENT_CHAR_READ_ALL_ERROR)) {
|
||||
int res = replay_get_dword();
|
||||
replay_finish_event();
|
||||
replay_mutex_unlock();
|
||||
return res;
|
||||
} else {
|
||||
replay_mutex_unlock();
|
||||
error_report("Missing character read all event in the replay log");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -146,19 +143,17 @@ int replay_char_read_all_load(uint8_t *buf)
|
|||
|
||||
void replay_char_read_all_save_error(int res)
|
||||
{
|
||||
g_assert(replay_mutex_locked());
|
||||
assert(res < 0);
|
||||
replay_save_instructions();
|
||||
replay_mutex_lock();
|
||||
replay_put_event(EVENT_CHAR_READ_ALL_ERROR);
|
||||
replay_put_dword(res);
|
||||
replay_mutex_unlock();
|
||||
}
|
||||
|
||||
void replay_char_read_all_save_buf(uint8_t *buf, int offset)
|
||||
{
|
||||
g_assert(replay_mutex_locked());
|
||||
replay_save_instructions();
|
||||
replay_mutex_lock();
|
||||
replay_put_event(EVENT_CHAR_READ_ALL);
|
||||
replay_put_array(buf, offset);
|
||||
replay_mutex_unlock();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue