From patchwork Mon Jan 9 06:24:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9503835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78D8460757 for ; Mon, 9 Jan 2017 06:28:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FAE280D0 for ; Mon, 9 Jan 2017 06:28:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E6712811C; Mon, 9 Jan 2017 06:28:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4DCA2815E for ; Mon, 9 Jan 2017 06:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940097AbdAIG1M (ORCPT ); Mon, 9 Jan 2017 01:27:12 -0500 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]:52090 "EHLO outprodmail02.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939689AbdAIG0I (ORCPT ); Mon, 9 Jan 2017 01:26:08 -0500 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096PXCd005328 for ; Mon, 9 Jan 2017 01:26:05 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id DEDF980 for ; Mon, 9 Jan 2017 01:26:05 -0500 (EST) Received: from sendprodmail02.cc.columbia.edu (sendprodmail02.cc.columbia.edu [128.59.72.14]) by hazelnut (Postfix) with ESMTP id ED15E96 for ; Mon, 9 Jan 2017 01:26:04 -0500 (EST) Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by sendprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q4gT042325 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:04 -0500 Received: by mail-qk0-f198.google.com with SMTP id t84so100993917qke.7 for ; Sun, 08 Jan 2017 22:26:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z0+E5iGsb4QfhFl6mf5oMN70Y4Pe8e/EJMKhhTRekEc=; b=iVEDaq1WeHanbvMm3vrc/u3iAFvIDV/PW0WH6G1FDqqJSazyY+hrgULPC4WvsZNaKy RY0YqwkV93oyc7eiFle9HqWBA5GQgYz6XNWmeDHnfgok/aaZLiiMH1nzqK88cCcu9Vn/ zYzFVlpwqtxD/RVD9qiLv9ozHgu/dkHMn8JyYIyBILIEOjQkedYrn3vRXEW05GeRGilk be8sm6Jn14bgxZuA9UgC04Jvf6CeJBXjaNKXyAuxJDUcd+DIUDHShSBM+HXg6uTeOxTy Dw9GlrUJCZvUhVHVTIHRs1bZ0e8rY4uGYxFfBiQ2kFaW6qyQxf2+PKGXAHgCE7YuPd6z RYsA== X-Gm-Message-State: AIkVDXJmY8WSkCydwiR29VznkurOJjxVEYjvM/1BfsGON/e5W2sjCuRyyxJX93nyhF3JyJ6W3v3RXYe2KP+YSOjbLhrpSuE0XuhZqeTnj16DfsfpSGOhqdvsrCIHwfFcU1klThMcA6xatsU= X-Received: by 10.55.197.148 with SMTP id k20mr81528078qkl.34.1483943164539; Sun, 08 Jan 2017 22:26:04 -0800 (PST) X-Received: by 10.55.197.148 with SMTP id k20mr81528068qkl.34.1483943164394; Sun, 08 Jan 2017 22:26:04 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id h3sm8623257qtc.6.2017.01.08.22.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:26:03 -0800 (PST) From: Jintack Lim To: christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jintack@cs.columbia.edu Subject: [RFC 25/55] KVM: arm/arm64: Let vcpu thread modify its own active state Date: Mon, 9 Jan 2017 01:24:21 -0500 Message-Id: <1483943091-1364-26-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> References: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.14 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, if a vcpu thread tries to change its own active state when the irq is already in AP list, it'll loop forever. Since the VCPU thread has already synced back LR state to the struct vgic_irq, let it modify its own state safely. Signed-off-by: Jintack Lim --- virt/kvm/arm/vgic/vgic-mmio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c index ebe1b9f..049c570 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.c +++ b/virt/kvm/arm/vgic/vgic-mmio.c @@ -192,9 +192,9 @@ static void vgic_mmio_change_active(struct kvm_vcpu *vcpu, struct vgic_irq *irq, * If this virtual IRQ was written into a list register, we * have to make sure the CPU that runs the VCPU thread has * synced back LR state to the struct vgic_irq. We can only - * know this for sure, when either this irq is not assigned to + * know this for sure, when this irq is not assigned to * anyone's AP list anymore, or the VCPU thread is not - * running on any CPUs. + * running on any CPUs, or current thread is the VCPU thread. * * In the opposite case, we know the VCPU thread may be on its * way back from the guest and still has to sync back this @@ -202,6 +202,7 @@ static void vgic_mmio_change_active(struct kvm_vcpu *vcpu, struct vgic_irq *irq, * other thread sync back the IRQ. */ while (irq->vcpu && /* IRQ may have state in an LR somewhere */ + irq->vcpu != vcpu && /* Current thread is not the VCPU thread */ irq->vcpu->cpu != -1) /* VCPU thread is running */ cond_resched_lock(&irq->irq_lock);