From patchwork Mon Mar 6 09:56:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9605595 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 9A6996046A for ; Mon, 6 Mar 2017 09:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8508C27F90 for ; Mon, 6 Mar 2017 09:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77A0D2833C; Mon, 6 Mar 2017 09:58:37 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DFDC727F90 for ; Mon, 6 Mar 2017 09:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=nmk1swV6+HcsLhTN7hvRy/j8Hc/LNBdvylEn8y3M+0k=; b=G/D 2RViBEBLie4Nf+/8Ee3hvOiwkcKpyvfndjLc1qdHic+OhEDRpeBpCYwDwngEaUvz91R1JQ2zWLeCC 1DnlDmJJ1zJy1HHRAfHKFnHPqjVNdfOL6/emmmfezUJKLVof/O9z6ccB6oDsjTNrusjtKJgqCf7+S +HvycKYGG/w8TQpu8SmQzxB1x1QRsc7kqpmiMsDx98sWasIzLsM3v9kojVomKRh3/cnIh6IDpyEIV VbwOpnPGWjKJ6Kt2wq9+ERjUC1Q8p1UYyXDNZNNDrso+gPNZ11vOGnVSMIxob0NEUOqgCpwBLqsBd 2wZuR4/d2XxkPisLk+a4sY+WDeIShfg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ckpPV-0005pP-Rc; Mon, 06 Mar 2017 09:58:33 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ckpPN-0005dt-86 for linux-arm-kernel@bombadil.infradead.org; Mon, 06 Mar 2017 09:58:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MJDd13ufDACMmarrDch2FTMH2Pc9sDrWQyPTGEBSMkg=; b=syOrfRCkwfXIXUkzDwLBh7s1L VVSgPixJ6nYW7WkO+3uFH760rjC0hRTfllIHiju0dTdvxlM7j7J/OgLWZ6zei2hHm7a0145p5+p4z J4YLXEDjf+0B/5ly6rdddf/lkeBUCZ0G4CPFmkCUL/TVPF4iH2tc/m2zBCAc9Ba2EnK3yn7oLYyvK dB+ll50hH/b/KWxaCKcbnvQqIQKg8XWOG+LP3lVYU1qKo/dcTli/3XsZLnHYzkK5AaHf3rkai2TO3 w2f68HV7GLmQbn53zqFomv456+wFck4jtpJVoYNWUoD3vdLMo7gLJ+vBZuuVxXUdx7FvRVytkK4tg Togl45t9g==; Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ckpO3-0007Fp-RW for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2017 09:57:06 +0000 Received: by mail-wr0-x22f.google.com with SMTP id g10so112405442wrg.2 for ; Mon, 06 Mar 2017 01:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=MJDd13ufDACMmarrDch2FTMH2Pc9sDrWQyPTGEBSMkg=; b=EMMFYXwpLvWXeME9/pQMdJNRmuv4J3heOqO57VHxpZhy+auPUUuVmZiwc0SUprJzJO 6FYxeY/6ojtaMRmXtukrH6UJtJwBI3A+qzcg7smQ9WzHgXgp/HfKrYPQBuQiXCigtBfY iKtLu2GC+hE4uqo4NXzq30SPATeR4HWyOkJ+c= 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; bh=MJDd13ufDACMmarrDch2FTMH2Pc9sDrWQyPTGEBSMkg=; b=LdBmW78rtaHRDToJDYnFc7YnisI74rvCuUJGRCmk3xnFX+dZpdRVzKJVQM1Eq/o3Nt qqOOC6aypfg+5JJ5kJKYw3qcWarDQcxL3BqvMOUOnzf++XEjObsEXAApim21czE82iAd /cu55BUE33HnH0j213Rxhl0mqYj4PICHbmaoq+yQn+JRwU2Btsk08X30RtgDWr/nXxbi jhLM9lPD4wjklDVb/Py19sMyWaIjLeO5+ePgqFMMavNt+kjpNG1YLZtisKLJI9bYcVsl 5PIokQKnJHmGKi4zrk+m/HEQQl2sEyKzkd0s07nR6kzngcEJx0vPQu8NqpQXPkM8dXmS NiRw== X-Gm-Message-State: AMke39ntpRufbhZDHDIkKBFodz8oGlYB/0s229O0hl7JdnQyuY0XH9qZTfYHJrnP+PnPFCWx X-Received: by 10.223.134.149 with SMTP id 21mr14731403wrx.1.1488794201990; Mon, 06 Mar 2017 01:56:41 -0800 (PST) Received: from localhost.localdomain ([109.74.56.122]) by smtp.gmail.com with ESMTPSA id 61sm26236286wrs.29.2017.03.06.01.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Mar 2017 01:56:41 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH] KVM: arm/arm64: Let vcpu thread modify its own active state Date: Mon, 6 Mar 2017 01:56:39 -0800 Message-Id: <1488794199-22397-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.5.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170306_095704_006895_9674CB9B X-CRM114-Status: GOOD ( 15.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Andre Przywara , Jintack Lim , kvm@vger.kernel.org, Eric Auger MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jintack Lim 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 3654b4c..29101ab 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.c +++ b/virt/kvm/arm/vgic/vgic-mmio.c @@ -185,9 +185,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 @@ -195,6 +195,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);