From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v2 3/8] KVM: x86: set/get_events ioctl should consider only injected exceptions Date: Wed, 22 Nov 2017 21:25:04 +0100 Message-ID: <20171122202503.GB21279@flask> References: <1511278211-12257-1-git-send-email-liran.alon@oracle.com> <1511278211-12257-4-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]:58222 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbdKVUZI (ORCPT ); Wed, 22 Nov 2017 15:25:08 -0500 Content-Disposition: inline In-Reply-To: <1511278211-12257-4-git-send-email-liran.alon@oracle.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-11-21 17:30+0200, Liran Alon: > Do not consider pending exception when return injected exception > to user-mode. A "pending" exception means it's side-effect have not > been applied yet. In contrast, an "injected" exception means it's > side-effect have been already applied. > Therefore, we only need to report of injected exceptions to user-mode. > This is aligned with how interrupts are reported in same ioctl. Pending interrupts are stored in IRR, but we don't have anything for exceptions -- we would lose a trap exception that was made pending after handling inject_pending_event() if the VCPU got a userspace signal and save+restored before starting the next vcpu_enter_guest() cycle. (Non-trap exceptions should be generated again when re-executing, so losing them isn't that bad.) I think we should add state for pending exceptions in kvm_vcpu_events, like the FIXME says. Pending and injected are actually exclusive (for now?), so maybe we can use only one bit for that, thanks. An alternative, probably unattainable, would be to process the side-effects as we hit the exception. Using IRR to store pending interrupts also seems possible, but I'd expect more problems down the road.