Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755241AbcDKUwK (ORCPT ); Mon, 11 Apr 2016 16:52:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45298 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753672AbcDKUwJ (ORCPT ); Mon, 11 Apr 2016 16:52:09 -0400 Date: Mon, 11 Apr 2016 22:52:04 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Suravee Suthikulpanit Cc: pbonzini@redhat.com, joro@8bytes.org, bp@alien8.de, gleb@kernel.org, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wei@redhat.com, sherry.hurwitz@amd.com Subject: Re: [PART1 RFC v4 07/11] svm: Add interrupt injection via AVIC Message-ID: <20160411205204.GA9442@potion.brq.redhat.com> References: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1460017232-17429-8-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460017232-17429-8-git-send-email-Suravee.Suthikulpanit@amd.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1721 Lines: 47 2016-04-07 03:20-0500, Suravee Suthikulpanit: > This patch introduces a new mechanism to inject interrupt using AVIC. > Since VINTR is not supported when enable AVIC, we need to inject > interrupt via APIC backing page instead. > > This patch also adds support for AVIC doorbell, which is used by > KVM to signal a running vcpu to check IRR for injected interrupts. > > Signed-off-by: Suravee Suthikulpanit > --- > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > @@ -216,6 +218,8 @@ static bool npt_enabled = true; > +static struct kvm_x86_ops svm_x86_ops; > @@ -963,6 +979,8 @@ static __init int svm_hardware_setup(void) > > if (avic) { > printk(KERN_INFO "kvm: AVIC enabled\n"); > + } else { > + svm_x86_ops.deliver_posted_interrupt = NULL; (No need to NULL this. deliver_posted_interrupt cannot be used to determine whether avic is should be used, so we can keep it !NULL. Declaration of svm_x86_ops can be omitted then.) > @@ -2883,8 +2901,10 @@ static int clgi_interception(struct vcpu_svm *svm) > disable_gif(svm); > > /* After a CLGI no interrupts should come */ > - svm_clear_vintr(svm); > - svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; > + if (!svm_vcpu_avic_enabled(svm)) { > + svm_clear_vintr(svm); > + svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; > + } > > mark_dirty(svm->vmcb, VMCB_INTR); mark_dirty also belongs to the if, because avic doesn't touch vmcb. > @@ -3854,6 +3875,20 @@ static void svm_sync_pir_to_irr(struct kvm_vcpu *vcpu) > +static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec) > +{ > + struct vcpu_svm *svm = to_svm(vcpu); > + > + kvm_lapic_set_irr(vec, svm->vcpu.arch.apic); (vcpu->arch.apic would work too. ;])