mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-02 18:17:50 -04:00
KVM: Let KVM_SET_SIGNAL_MASK work as advertised
KVM API says for the signal mask you set via KVM_SET_SIGNAL_MASK, that "any unblocked signal received [...] will cause KVM_RUN to return with -EINTR" and that "the signal will only be delivered if not blocked by the original signal mask". This, however, is only true, when the calling task has a signal handler registered for a signal. If not, signal evaluation is short-circuited for SIG_IGN and SIG_DFL, and the signal is either ignored without KVM_RUN returning or the whole process is terminated. Make KVM_SET_SIGNAL_MASK behave as advertised by utilizing logic similar to that in do_sigtimedwait() to avoid short-circuiting of signals. Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
b74558259c
commit
20b7035c66
@@ -615,7 +615,6 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu)
|
||||
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
||||
{
|
||||
int ret;
|
||||
sigset_t sigsaved;
|
||||
|
||||
if (unlikely(!kvm_vcpu_initialized(vcpu)))
|
||||
return -ENOEXEC;
|
||||
@@ -633,8 +632,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
||||
if (run->immediate_exit)
|
||||
return -EINTR;
|
||||
|
||||
if (vcpu->sigset_active)
|
||||
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
|
||||
kvm_sigset_activate(vcpu);
|
||||
|
||||
ret = 1;
|
||||
run->exit_reason = KVM_EXIT_UNKNOWN;
|
||||
@@ -769,8 +767,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
||||
kvm_pmu_update_run(vcpu);
|
||||
}
|
||||
|
||||
if (vcpu->sigset_active)
|
||||
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
|
||||
kvm_sigset_deactivate(vcpu);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -2065,6 +2065,29 @@ void kvm_vcpu_mark_page_dirty(struct kvm_vcpu *vcpu, gfn_t gfn)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_vcpu_mark_page_dirty);
|
||||
|
||||
void kvm_sigset_activate(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
if (!vcpu->sigset_active)
|
||||
return;
|
||||
|
||||
/*
|
||||
* This does a lockless modification of ->real_blocked, which is fine
|
||||
* because, only current can change ->real_blocked and all readers of
|
||||
* ->real_blocked don't care as long ->real_blocked is always a subset
|
||||
* of ->blocked.
|
||||
*/
|
||||
sigprocmask(SIG_SETMASK, &vcpu->sigset, ¤t->real_blocked);
|
||||
}
|
||||
|
||||
void kvm_sigset_deactivate(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
if (!vcpu->sigset_active)
|
||||
return;
|
||||
|
||||
sigprocmask(SIG_SETMASK, ¤t->real_blocked, NULL);
|
||||
sigemptyset(¤t->real_blocked);
|
||||
}
|
||||
|
||||
static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
unsigned int old, val, grow;
|
||||
|
||||
Reference in New Issue
Block a user