From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751561AbcBOTWu (ORCPT ); Mon, 15 Feb 2016 14:22:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42132 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbcBOTWt (ORCPT ); Mon, 15 Feb 2016 14:22:49 -0500 Date: Mon, 15 Feb 2016 20:22:44 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: Suravee Suthikulpanit , joro@8bytes.org, alex.williamson@redhat.com, gleb@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wei@redhat.com, sherry.hurwitz@amd.com Subject: Re: [PART1 RFC 5/9] svm: Add VMEXIT handlers for AVIC Message-ID: <20160215192243.GA22531@potion.brq.redhat.com> References: <1455285574-27892-1-git-send-email-suravee.suthikulpanit@amd.com> <1455285574-27892-6-git-send-email-suravee.suthikulpanit@amd.com> <56BDFC72.7030905@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56BDFC72.7030905@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-02-12 16:38+0100, Paolo Bonzini: > On 12/02/2016 14:59, Suravee Suthikulpanit wrote: >> + case AVIC_INCMP_IPI_ERR_TARGET_NOT_RUN: >> + kvm_lapic_reg_write(apic, APIC_ICR2, icrh); >> + kvm_lapic_reg_write(apic, APIC_ICR, icrl); > > Wouldn't this cause a double injection of the IPI if the following happens: I think it will. (IRR was written to APIC pages, so hypervisor's only job is to make sure that all targeted VCPUs eventually run.) > The handling of races for IsRunning and incomplete IPIs has always been > very confusing to me whenever I read the AVIC specification. It would > be great if you could clarify this. Yeah, we bug there as well: If all target VCPUs have IsRunning set and are in the process of being scheduled out (avic_set_running false), then there is no VMEXIT on IPI and the doorbell does nothing[1]; KVM desn't re-check pending interrupts before actually scheduling out, therefore VCPUs will wake only if another interrupt comes. The hypervisor can manage the IsRunning as it wishes to, so KVM probably should set IsRunning to false before scanning IRR. --- 1: I didn't find a single mention of a situation when doorbell arrives outside of guest mode, so I presume that nothing happens. Is it right? Thanks.