* [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). @ 2008-10-20 5:58 Zhang, Xiantao 2008-10-20 7:23 ` Avi Kivity 0 siblings, 1 reply; 9+ messages in thread From: Zhang, Xiantao @ 2008-10-20 5:58 UTC (permalink / raw) To: Avi Kivity, kvm-ia64; +Cc: kvm [-- Attachment #1: Type: text/plain, Size: 1578 bytes --] Hi, Avi This is a fix for upcoming 2.6.28-rc1. Please help to queue it for 2.6.28. Thanks Xiantao >From 87105e68273b3791add17378da01abc94035e5c6 Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Mon, 20 Oct 2008 12:36:03 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..da67884 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -673,6 +673,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) return -EAGAIN; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); -- 1.5.1 [-- Attachment #2: 0001-kvm-ia64-Ensure-SIGINT-delivered-to-main-thread-vc.patch --] [-- Type: application/octet-stream, Size: 1429 bytes --] From 87105e68273b3791add17378da01abc94035e5c6 Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Mon, 20 Oct 2008 12:36:03 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..da67884 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -673,6 +673,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) return -EAGAIN; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); -- 1.5.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-20 5:58 [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Zhang, Xiantao @ 2008-10-20 7:23 ` Avi Kivity 2008-10-20 8:08 ` Zhang, Xiantao 0 siblings, 1 reply; 9+ messages in thread From: Avi Kivity @ 2008-10-20 7:23 UTC (permalink / raw) To: Zhang, Xiantao; +Cc: kvm-ia64, kvm Zhang, Xiantao wrote: > Before Aps going to block status, it should make sure SIGINT is > masked, otherwise, it may eat SIGINT from user killing the guest, and > results in Qemu hanging there, becasue main thread can't get it to free > guest's resource. > > vcpu_load(vcpu); > > + if (vcpu->sigset_active) > + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); > + > if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) > { > kvm_vcpu_block(vcpu); > clear_bit(KVM_REQ_UNHALT, &vcpu->requests); > @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, > struct kvm_run *kvm_run) > return -EAGAIN; > The 'return' here means you are returning with the wrong signal mask. > } > > - if (vcpu->sigset_active) > - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); > - > if (vcpu->mmio_needed) { > memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); > kvm_set_mmio_data(vcpu); > -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-20 7:23 ` Avi Kivity @ 2008-10-20 8:08 ` Zhang, Xiantao 2008-10-20 8:43 ` Avi Kivity 0 siblings, 1 reply; 9+ messages in thread From: Zhang, Xiantao @ 2008-10-20 8:08 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-ia64, kvm Avi Kivity wrote: > Zhang, Xiantao wrote: >> Before Aps going to block status, it should make sure SIGINT is >> masked, otherwise, it may eat SIGINT from user killing the guest, and >> results in Qemu hanging there, becasue main thread can't get it to >> free guest's resource. >> > >> vcpu_load(vcpu); >> >> + if (vcpu->sigset_active) >> + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + >> if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { >> kvm_vcpu_block(vcpu); >> clear_bit(KVM_REQ_UNHALT, &vcpu->requests); >> @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >> *vcpu, struct kvm_run *kvm_run) return -EAGAIN; >> > > The 'return' here means you are returning with the wrong signal mask. Yes, but the signal is eaten by the thread, and can't be delivered to main thread when returing to usespace. So in order to ensure the main thread receive the signal SIGINT we should mask this signal on Aps going into halt, and only main thread can receive such signals. >> } >> >> - if (vcpu->sigset_active) >> - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - >> if (vcpu->mmio_needed) { >> memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); >> kvm_set_mmio_data(vcpu); ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-20 8:08 ` Zhang, Xiantao @ 2008-10-20 8:43 ` Avi Kivity 2008-10-20 9:03 ` Zhang, Xiantao 2008-10-22 3:13 ` Zhang, Xiantao 0 siblings, 2 replies; 9+ messages in thread From: Avi Kivity @ 2008-10-20 8:43 UTC (permalink / raw) To: Zhang, Xiantao; +Cc: kvm-ia64, kvm Zhang, Xiantao wrote: > Avi Kivity wrote: > >> Zhang, Xiantao wrote: >> >>> Before Aps going to block status, it should make sure SIGINT is >>> masked, otherwise, it may eat SIGINT from user killing the guest, and >>> results in Qemu hanging there, becasue main thread can't get it to >>> free guest's resource. >>> >>> >>> vcpu_load(vcpu); >>> >>> + if (vcpu->sigset_active) >>> + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + >>> if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) >>> > { > >>> kvm_vcpu_block(vcpu); >>> clear_bit(KVM_REQ_UNHALT, &vcpu->requests); >>> @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >>> *vcpu, struct kvm_run *kvm_run) return -EAGAIN; >>> >>> >> The 'return' here means you are returning with the wrong signal mask. >> > > Yes, but the signal is eaten by the thread, and can't be delivered to > main thread when returing to usespace. So in order to ensure the main > thread receive the signal SIGINT we should mask this signal on Aps going > into halt, and only main thread can receive such signals. > > Then you should block SIGINT in the vcpu thread in userspace. This patch is correct, except that it leaks the signal mask. You need to restore it when you return -EAGAIN. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-20 8:43 ` Avi Kivity @ 2008-10-20 9:03 ` Zhang, Xiantao 2008-10-22 3:13 ` Zhang, Xiantao 1 sibling, 0 replies; 9+ messages in thread From: Zhang, Xiantao @ 2008-10-20 9:03 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-ia64, kvm [-- Attachment #1: Type: text/plain, Size: 3228 bytes --] Avi Kivity wrote: > Zhang, Xiantao wrote: >> Avi Kivity wrote: >> >>> Zhang, Xiantao wrote: >>> >>>> Before Aps going to block status, it should make sure SIGINT is >>>> masked, otherwise, it may eat SIGINT from user killing the guest, >>>> and results in Qemu hanging there, becasue main thread can't get >>>> it to free guest's resource. >>>> >>>> >>>> vcpu_load(vcpu); >>>> >>>> + if (vcpu->sigset_active) >>>> + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + >>>> if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) >>>> >> { >> >>>> kvm_vcpu_block(vcpu); >>>> clear_bit(KVM_REQ_UNHALT, &vcpu->requests); >>>> @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >>>> *vcpu, struct kvm_run *kvm_run) return -EAGAIN; >>>> >>>> >>> The 'return' here means you are returning with the wrong signal >>> mask. >>> >> >> Yes, but the signal is eaten by the thread, and can't be delivered to >> main thread when returing to usespace. So in order to ensure the main >> thread receive the signal SIGINT we should mask this signal on Aps >> going into halt, and only main thread can receive such signals. >> >> > > Then you should block SIGINT in the vcpu thread in userspace. > > This patch is correct, except that it leaks the signal mask. You need > to restore it when you return -EAGAIN. Hi, Avi Thank you for pointing out this. Yes, we need to restore the singal mask before returning to userspace. Updated the patch. Xiantao >From 5434384ea573f8430b258163c1c07c695a0de5cc Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Mon, 20 Oct 2008 15:36:42 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..502b6fc 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -673,16 +673,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - vcpu_put(vcpu); - return -EAGAIN; + r = -EAGAIN; + goto out; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); @@ -690,7 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->mmio_needed = 0; } r = __vcpu_run(vcpu, kvm_run); - +out: if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); -- 1.5.1 [-- Attachment #2: 0001-kvm-ia64-Ensure-SIGINT-delivered-to-main-thread-vc.patch --] [-- Type: application/octet-stream, Size: 1631 bytes --] From 5434384ea573f8430b258163c1c07c695a0de5cc Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Mon, 20 Oct 2008 15:36:42 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..502b6fc 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -673,16 +673,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - vcpu_put(vcpu); - return -EAGAIN; + r = -EAGAIN; + goto out; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); @@ -690,7 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->mmio_needed = 0; } r = __vcpu_run(vcpu, kvm_run); - +out: if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); -- 1.5.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-20 8:43 ` Avi Kivity 2008-10-20 9:03 ` Zhang, Xiantao @ 2008-10-22 3:13 ` Zhang, Xiantao 2008-10-22 10:47 ` Avi Kivity 1 sibling, 1 reply; 9+ messages in thread From: Zhang, Xiantao @ 2008-10-22 3:13 UTC (permalink / raw) To: Zhang, Xiantao, Avi Kivity; +Cc: kvm-ia64, kvm [-- Attachment #1: Type: text/plain, Size: 5826 bytes --] Hi, Avi Could you help to pickup the patch, and queue it for 2.6.28-rc1 ? Thanks Xiantao >From 311134e0176d0a61cecae4bea753d28b85cdc152 Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Wed, 22 Oct 2008 09:50:21 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..9929c6f 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -439,7 +439,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) expires = div64_u64(itc_diff, cyc_per_usec); kt = ktime_set(0, 1000 * expires); - down_read(&vcpu->kvm->slots_lock); vcpu->arch.ht_active = 1; hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); @@ -452,7 +451,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; - up_read(&vcpu->kvm->slots_lock); if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE) return -EINTR; @@ -673,16 +671,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - vcpu_put(vcpu); - return -EAGAIN; + r = -EAGAIN; + goto out; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); @@ -690,7 +688,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->mmio_needed = 0; } r = __vcpu_run(vcpu, kvm_run); - +out: if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); -- 1.5.1 -----Original Message----- From: Zhang, Xiantao Sent: Monday, October 20, 2008 5:03 PM To: 'Avi Kivity' Cc: kvm-ia64@vger.kernel.org; kvm@vger.kernel.org Subject: RE: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Avi Kivity wrote: > Zhang, Xiantao wrote: >> Avi Kivity wrote: >> >>> Zhang, Xiantao wrote: >>> >>>> Before Aps going to block status, it should make sure SIGINT is >>>> masked, otherwise, it may eat SIGINT from user killing the guest, >>>> and results in Qemu hanging there, becasue main thread can't get >>>> it to free guest's resource. >>>> >>>> >>>> vcpu_load(vcpu); >>>> >>>> + if (vcpu->sigset_active) >>>> + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + >>>> if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) >>>> >> { >> >>>> kvm_vcpu_block(vcpu); >>>> clear_bit(KVM_REQ_UNHALT, &vcpu->requests); >>>> @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >>>> *vcpu, struct kvm_run *kvm_run) return -EAGAIN; >>>> >>>> >>> The 'return' here means you are returning with the wrong signal >>> mask. >>> >> >> Yes, but the signal is eaten by the thread, and can't be delivered to >> main thread when returing to usespace. So in order to ensure the main >> thread receive the signal SIGINT we should mask this signal on Aps >> going into halt, and only main thread can receive such signals. >> >> > > Then you should block SIGINT in the vcpu thread in userspace. > > This patch is correct, except that it leaks the signal mask. You need > to restore it when you return -EAGAIN. Hi, Avi Thank you for pointing out this. Yes, we need to restore the singal mask before returning to userspace. Updated the patch. Xiantao >From 5434384ea573f8430b258163c1c07c695a0de5cc Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Mon, 20 Oct 2008 15:36:42 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..502b6fc 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -673,16 +673,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - vcpu_put(vcpu); - return -EAGAIN; + r = -EAGAIN; + goto out; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); @@ -690,7 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->mmio_needed = 0; } r = __vcpu_run(vcpu, kvm_run); - +out: if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); -- 1.5.1 [-- Attachment #2: 0001-kvm-ia64-Ensure-SIGINT-delivered-to-main-thread-vc.patch --] [-- Type: application/octet-stream, Size: 2183 bytes --] From 311134e0176d0a61cecae4bea753d28b85cdc152 Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@intel.com> Date: Wed, 22 Oct 2008 09:50:21 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> --- arch/ia64/kvm/kvm-ia64.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..9929c6f 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -439,7 +439,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) expires = div64_u64(itc_diff, cyc_per_usec); kt = ktime_set(0, 1000 * expires); - down_read(&vcpu->kvm->slots_lock); vcpu->arch.ht_active = 1; hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); @@ -452,7 +451,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; - up_read(&vcpu->kvm->slots_lock); if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE) return -EINTR; @@ -673,16 +671,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - vcpu_put(vcpu); - return -EAGAIN; + r = -EAGAIN; + goto out; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); @@ -690,7 +688,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->mmio_needed = 0; } r = __vcpu_run(vcpu, kvm_run); - +out: if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); -- 1.5.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-22 3:13 ` Zhang, Xiantao @ 2008-10-22 10:47 ` Avi Kivity 2008-10-23 2:00 ` Zhang, Xiantao 0 siblings, 1 reply; 9+ messages in thread From: Avi Kivity @ 2008-10-22 10:47 UTC (permalink / raw) To: Zhang, Xiantao; +Cc: kvm-ia64, kvm Zhang, Xiantao wrote: > Before Aps going to block status, it should make sure SIGINT is > masked, otherwise, it may eat SIGINT from user killing the guest, and > results in Qemu hanging there, becasue main thread can't get it to free > guest's resource. > > > diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c > index a40223f..9929c6f 100644 > --- a/arch/ia64/kvm/kvm-ia64.c > +++ b/arch/ia64/kvm/kvm-ia64.c > @@ -439,7 +439,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) > expires = div64_u64(itc_diff, cyc_per_usec); > kt = ktime_set(0, 1000 * expires); > > - down_read(&vcpu->kvm->slots_lock); > vcpu->arch.ht_active = 1; > hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); > > @@ -452,7 +451,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) > if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) > vcpu->arch.mp_state = > KVM_MP_STATE_RUNNABLE; > - up_read(&vcpu->kvm->slots_lock); > > if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE) > return -EINTR; > These bits appear unrelated? The rest of the patch is fine. -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-22 10:47 ` Avi Kivity @ 2008-10-23 2:00 ` Zhang, Xiantao 2008-10-23 4:31 ` Avi Kivity 0 siblings, 1 reply; 9+ messages in thread From: Zhang, Xiantao @ 2008-10-23 2:00 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm-ia64@vger.kernel.org, kvm@vger.kernel.org Avi Kivity wrote: > Zhang, Xiantao wrote: >> Before Aps going to block status, it should make sure SIGINT is >> masked, otherwise, it may eat SIGINT from user killing the guest, and >> results in Qemu hanging there, becasue main thread can't get it to >> free guest's resource. >> >> >> diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c >> index a40223f..9929c6f 100644 >> --- a/arch/ia64/kvm/kvm-ia64.c >> +++ b/arch/ia64/kvm/kvm-ia64.c >> @@ -439,7 +439,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) >> expires = div64_u64(itc_diff, cyc_per_usec); >> kt = ktime_set(0, 1000 * expires); >> >> - down_read(&vcpu->kvm->slots_lock); >> vcpu->arch.ht_active = 1; >> hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); >> >> @@ -452,7 +451,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) >> if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) >> vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; >> - up_read(&vcpu->kvm->slots_lock); >> >> if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE) return >> -EINTR; >> > > These bits appear unrelated? There is nothing to be proteced by this lock here. If the vcpus go to halt with taking this lock, once other ones want to acquire write lock, they have to wait until all halted vcpus are waken up. Xiantao ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). 2008-10-23 2:00 ` Zhang, Xiantao @ 2008-10-23 4:31 ` Avi Kivity 0 siblings, 0 replies; 9+ messages in thread From: Avi Kivity @ 2008-10-23 4:31 UTC (permalink / raw) To: Zhang, Xiantao; +Cc: kvm-ia64@vger.kernel.org, kvm@vger.kernel.org Zhang, Xiantao wrote: > Avi Kivity wrote: > >> Zhang, Xiantao wrote: >> >>> Before Aps going to block status, it should make sure SIGINT is >>> masked, otherwise, it may eat SIGINT from user killing the guest, and >>> results in Qemu hanging there, becasue main thread can't get it to >>> free guest's resource. >>> >>> >>> diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c >>> index a40223f..9929c6f 100644 >>> --- a/arch/ia64/kvm/kvm-ia64.c >>> +++ b/arch/ia64/kvm/kvm-ia64.c >>> @@ -439,7 +439,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) >>> expires = div64_u64(itc_diff, cyc_per_usec); >>> kt = ktime_set(0, 1000 * expires); >>> >>> - down_read(&vcpu->kvm->slots_lock); >>> vcpu->arch.ht_active = 1; >>> hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); >>> >>> @@ -452,7 +451,6 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu) >>> if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) >>> vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; >>> - up_read(&vcpu->kvm->slots_lock); >>> >>> if (vcpu->arch.mp_state != KVM_MP_STATE_RUNNABLE) return >>> -EINTR; >>> >>> >> These bits appear unrelated? >> > There is nothing to be proteced by this lock here. If the vcpus go to halt with taking this lock, once other ones want to acquire write lock, they have to wait until all halted vcpus are waken up. > Very well; please send this as a separate patch. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-10-23 4:31 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-20 5:58 [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Zhang, Xiantao 2008-10-20 7:23 ` Avi Kivity 2008-10-20 8:08 ` Zhang, Xiantao 2008-10-20 8:43 ` Avi Kivity 2008-10-20 9:03 ` Zhang, Xiantao 2008-10-22 3:13 ` Zhang, Xiantao 2008-10-22 10:47 ` Avi Kivity 2008-10-23 2:00 ` Zhang, Xiantao 2008-10-23 4:31 ` Avi Kivity
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).