Commit bf1e15a8 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: selftests: Always run vCPU thread with blocked SIG_IPI

The main thread could start to send SIG_IPI at any time, even before signal
blocked on vcpu thread.  Therefore, start the vcpu thread with the signal
blocked.

Without this patch, on very busy cores the dirty_log_test could fail directly
on receiving a SIGUSR1 without a handler (when vcpu runs far slower than main).
Reported-by: default avatarPeter Xu <peterx@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 016ff1a4
...@@ -527,9 +527,8 @@ static void *vcpu_worker(void *data) ...@@ -527,9 +527,8 @@ static void *vcpu_worker(void *data)
*/ */
sigmask->len = 8; sigmask->len = 8;
pthread_sigmask(0, NULL, sigset); pthread_sigmask(0, NULL, sigset);
sigdelset(sigset, SIG_IPI);
vcpu_ioctl(vm, VCPU_ID, KVM_SET_SIGNAL_MASK, sigmask); vcpu_ioctl(vm, VCPU_ID, KVM_SET_SIGNAL_MASK, sigmask);
sigaddset(sigset, SIG_IPI);
pthread_sigmask(SIG_BLOCK, sigset, NULL);
sigemptyset(sigset); sigemptyset(sigset);
sigaddset(sigset, SIG_IPI); sigaddset(sigset, SIG_IPI);
...@@ -858,6 +857,7 @@ int main(int argc, char *argv[]) ...@@ -858,6 +857,7 @@ int main(int argc, char *argv[])
.interval = TEST_HOST_LOOP_INTERVAL, .interval = TEST_HOST_LOOP_INTERVAL,
}; };
int opt, i; int opt, i;
sigset_t sigset;
sem_init(&sem_vcpu_stop, 0, 0); sem_init(&sem_vcpu_stop, 0, 0);
sem_init(&sem_vcpu_cont, 0, 0); sem_init(&sem_vcpu_cont, 0, 0);
...@@ -916,6 +916,11 @@ int main(int argc, char *argv[]) ...@@ -916,6 +916,11 @@ int main(int argc, char *argv[])
srandom(time(0)); srandom(time(0));
/* Ensure that vCPU threads start with SIG_IPI blocked. */
sigemptyset(&sigset);
sigaddset(&sigset, SIG_IPI);
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
if (host_log_mode_option == LOG_MODE_ALL) { if (host_log_mode_option == LOG_MODE_ALL) {
/* Run each log mode */ /* Run each log mode */
for (i = 0; i < LOG_MODE_NUM; i++) { for (i = 0; i < LOG_MODE_NUM; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment