From patchwork Mon Nov 13 09:17: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: 10055403 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 DB3E260586 for ; Mon, 13 Nov 2017 09:28:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C6A29333 for ; Mon, 13 Nov 2017 09:28:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAB2C2933C; Mon, 13 Nov 2017 09:28:14 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable 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 471B429333 for ; Mon, 13 Nov 2017 09:28:14 +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:References: In-Reply-To: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:List-Owner; bh=z+/Mx/gMoWgfJal+9Mr5kNeQD5HP72kjEhanrbtXPnU=; b=jLEmVuysJDqgdpPsMe186UAHY2 VP9FoRWW81WiMeuiSx9anMl8LJUj9+NoKe52fCrJLHrc3ayP61Rkn3RQuz1ScEXoRTpFznaKwigtz YKceib8cTPs3DuUttiFXKmNRePws+MHAH3Mhgk0utoSDNR+3LdRXbK7Zx3MfT96tkmneEz98soE7c 97u5D20OqCVyKDHyLZiDIBWDrdlGaqjB69/gWujYrt0h75SE9azuKRgy0OPq0ystkaBVpAh7zd525 D6c/QBpgrWmZ2J2ZIBxQOJKD0MWDKtklxhub/G+pr4SRxR+hRtt7wrdFUBci/FtZtgGEumN2JxFU3 rSNTyMew==; 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 1eEB2L-0004Qz-EV; Mon, 13 Nov 2017 09:28:13 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEAtA-0002eZ-TD for linux-arm-kernel@bombadil.infradead.org; Mon, 13 Nov 2017 09:18:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eJ/AMOSjLwHX59NMN5aTv8bjnrkhEOcOn39bpRXyUww=; b=AAde7rvouHOpVPDdffHMXrexK iBWkuLngszM9mDTH98KbuxcSSMCSI6C7HAdppEjCTptOLd13qM/rLnpmhkJIy8xW9U8pETnYm8Q0b XoXa85k3Mpr+c97tYaUL4dpZ0BYkMl4PijWIfvtW9QJlHrzUQY3GcNyrHN60iszm65DJvYPKlB8FX Le7EiA1Tg2a/8qZAEUAYTC7EVhCkDuaKsGY73rlHxPpE8t0REQymFjZBw4jFQNpZMeuEuO/mlysvD CNOaWnYxD0inE5lIgSWQjIL6klD0+jjK+4Hmb2Vba3qVjheFuAHBLsitI4K2rveJsAzRDWlh42aag H1qQbTJDA==; Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEAt7-0005WE-3L for linux-arm-kernel@lists.infradead.org; Mon, 13 Nov 2017 09:18:42 +0000 Received: by mail-wm0-x243.google.com with SMTP id y80so13214784wmd.0 for ; Mon, 13 Nov 2017 01:18:15 -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:in-reply-to:references; bh=eJ/AMOSjLwHX59NMN5aTv8bjnrkhEOcOn39bpRXyUww=; b=PZeH4/vSmG0OFoWW269y0322ZR5wmIBVmUdbD9M+RSOlbPrOxXXRNZDYQWKTGEH3mi VJy5JMAPeTFAGxU0lIQr/6pWAv49ARnuKngmNVchql8ZQEXFdqGwUzkoHKjRG0Q3ZCag 4T45O4NGfqJsndSsaEM10Sipm05TzUek+91f8= 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=eJ/AMOSjLwHX59NMN5aTv8bjnrkhEOcOn39bpRXyUww=; b=I7MKQ+gOYI0X1aN8F4viSf4BWreEbwy1jsenhtW6fAsM9nkBJAfEMvBfC0cDVmxhxw OvdxwgjO+UjlxnBprMn619cwSTmPqohXkz9V6sgOj1+E66pySj4Du5STkdnvLgjIxmcw w4K/SXkFDfet9OVSv4d9ocYLHZnVIwP3OB/dgLS6yLzo+YNFT6lxm5OdxpxV4FGIFAhf hdRwP37rUTao5RBOHtPZC2Jd/4O76Mjzy/utbod/QOxsytl6aUQvcsSidGrtOu8vYsxH ITZ8LEqKMtxa4NEfDerKA56NuRL0XEcEqXPRZmkRPe213KNQUJ2BrUKDZbYl+n38x6Gl gegg== X-Gm-Message-State: AJaThX4xENtD7tRhYRQIrr9Nk6RUZr5DAxvlf+XimV95W1u2LFeXPqP+ RPvUE8wO/QZaI+yW9+cYmDDHrg== X-Google-Smtp-Source: AGs4zMZc8Tw5w+J/+xHr2QG8Hg6nl+a1rHUohVm6Dg/u9AXAQmgLmNtS8GO29OINm9sMTf7JT0DEcw== X-Received: by 10.28.70.131 with SMTP id t125mr2240180wma.92.1510564694099; Mon, 13 Nov 2017 01:18:14 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id x63sm9651399wma.39.2017.11.13.01.18.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Nov 2017 01:18:13 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 14/27] KVM: arm/arm64: GICv4: Handle MOVALL applied to a vPE Date: Mon, 13 Nov 2017 10:17:39 +0100 Message-Id: <20171113091752.10663-15-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171113091752.10663-1-christoffer.dall@linaro.org> References: <20171113091752.10663-1-christoffer.dall@linaro.org> 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 , Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org 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: Marc Zyngier The current implementation of MOVALL doesn't allow us to call into the core ITS code as we hold a number of spinlocks. Let's try a method used in other parts of the code, were we copy the intids of the candicate interrupts, and then do whatever we need to do with them outside of the critical section. This allows us to move the interrupts one by one, at the expense of a bit of CPU time. Who cares? MOVALL is such a stupid command anyway... Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 15e79285380d..78d11aed1e17 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1169,11 +1169,12 @@ static int vgic_its_cmd_handle_invall(struct kvm *kvm, struct vgic_its *its, static int vgic_its_cmd_handle_movall(struct kvm *kvm, struct vgic_its *its, u64 *its_cmd) { - struct vgic_dist *dist = &kvm->arch.vgic; u32 target1_addr = its_cmd_get_target_addr(its_cmd); u32 target2_addr = its_cmd_mask_field(its_cmd, 3, 16, 32); struct kvm_vcpu *vcpu1, *vcpu2; struct vgic_irq *irq; + u32 *intids; + int irq_count, i; if (target1_addr >= atomic_read(&kvm->online_vcpus) || target2_addr >= atomic_read(&kvm->online_vcpus)) @@ -1185,19 +1186,19 @@ static int vgic_its_cmd_handle_movall(struct kvm *kvm, struct vgic_its *its, vcpu1 = kvm_get_vcpu(kvm, target1_addr); vcpu2 = kvm_get_vcpu(kvm, target2_addr); - spin_lock(&dist->lpi_list_lock); + irq_count = vgic_copy_lpi_list(vcpu1, &intids); + if (irq_count < 0) + return irq_count; - list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { - spin_lock(&irq->irq_lock); + for (i = 0; i < irq_count; i++) { + irq = vgic_get_irq(kvm, NULL, intids[i]); - if (irq->target_vcpu == vcpu1) - irq->target_vcpu = vcpu2; + update_affinity(irq, vcpu2); - spin_unlock(&irq->irq_lock); + vgic_put_irq(kvm, irq); } - spin_unlock(&dist->lpi_list_lock); - + kfree(intids); return 0; }