From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v2 4/8] KVM: x86: Warn if userspace overrides existing injected exception/interrupt Date: Wed, 22 Nov 2017 21:34:44 +0100 Message-ID: <20171122203443.GA26792@flask> References: <1511278211-12257-1-git-send-email-liran.alon@oracle.com> <1511278211-12257-5-git-send-email-liran.alon@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com, kvm@vger.kernel.org, jmattson@google.com, wanpeng.li@hotmail.com, idan.brown@oracle.com, Krish Sadhukhan To: Liran Alon Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33330 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbdKVUet (ORCPT ); Wed, 22 Nov 2017 15:34:49 -0500 Content-Disposition: inline In-Reply-To: <1511278211-12257-5-git-send-email-liran.alon@oracle.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-11-21 17:30+0200, Liran Alon: > An alternative could have been done to return -EBUSY in this case. > For now, we decided to just silently override exception and warn on > such an attempt. > > Signed-off-by: Liran Alon > Reviewed-by: Nikita Leshenko > Reviewed-by: Krish Sadhukhan > Signed-off-by: Krish Sadhukhan > --- > arch/x86/kvm/x86.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1490da89de4b..c8cec7c39c1c 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -3153,12 +3153,25 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, > return -EINVAL; > > process_nmi(vcpu); > + > + /* > + * Warn if userspace is overriding existing > + * injected exception > + */ > + WARN_ON_ONCE(vcpu->arch.exception.injected && > + events->exception.injected); I think that overwriting the injected exception/interrupt is a perfectly valid operation -- userspace could have rolled back the state to a time of the previous injection. Syzkaller would complain sooner or later and I don't see it as a useful printk, so dropping this patch would be preferred, thanks.