From patchwork Tue May 9 10:44:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9717637 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 4C52D60364 for ; Tue, 9 May 2017 11:01:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D9EC20246 for ; Tue, 9 May 2017 11:01:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30D8F27FAC; Tue, 9 May 2017 11:01:54 +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=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 B211420246 for ; Tue, 9 May 2017 11:01:53 +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=xELdaVpwFwFMAo9JHjw6YQ4n4EWxO78y4NX/5fpufFk=; b=b1/n2dTkjsWhf0VCcR2Y2J7oPR qwWSziOL+z2nvP0Bds83AHoCKHwlBpSu/eTgIg2VXD/ez5WPm0CpYSh6aBWZ932Ouq3JUMV2jq657 uaslheFVAgWAw4rDajMcqxtIaRTFSLAdFh+0rGicZzJ0WpdzXPql/Wz7uhsa+rzXVp8bolJfn8dFR 4i/AhQROQBDnoHeCkH9buO6goY9OG3fWgc3GQVaX35v5VbmLa73W0MT1fzlizxpc00CtXDM12gcBA i0jDzzMX2e0+n+ItUW8pCQcKCBiEiI+jhJQJDgZPTDRObPGs1Y41xxFOv4ieqzG4lAmi2vihw3Xcc M6sSNxMA==; 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 1d82tt-0000jH-Aa; Tue, 09 May 2017 11:01:53 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d82ti-0000Ok-0T for linux-arm-kernel@bombadil.infradead.org; Tue, 09 May 2017 11:01:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=0zic6Xb7x3ksB70Q6ivPrFsurGOP6DOlLbZIMgBdKwU=; b=PKw/Xn8ktqY4uR4AiRs4onr8W tauKjLJ3Dn7VyXgY8L+AN5w5lWP2ZaN9jfRByhq/0gjedyFfOA5hH33DM8ay2jmjldS9vnSvxpK95 fEqOEwYLyA9KwMCPAHnMi+n6EdQHArOD36l9agihmg39lnFkLzzf3Ts4CLvK8hUFF4RpMJA+yfw2Y DA9nDkWgMiZ7S2GDrwDV9c5ZWwz75goGAbsLkeuFiPLmnapN0mN+n/SG6LIrmUaZ7gLO2CrD691Kx vQm9/Wa8o9oTDJTJy0Sh4E+Vd8Nse4ljuwUlnbqcjF+X4Ad+QBTfR7h+w7vf3jCaW6vGJqgLp6xhM Qi8Jr8c9A==; Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d82eV-0004j4-C6 for linux-arm-kernel@lists.infradead.org; Tue, 09 May 2017 10:46:01 +0000 Received: by mail-qk0-x22e.google.com with SMTP id a72so58967034qkj.2 for ; Tue, 09 May 2017 03:45:37 -0700 (PDT) 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=0zic6Xb7x3ksB70Q6ivPrFsurGOP6DOlLbZIMgBdKwU=; b=iTao+v1OG/7jWmCx+OsOnMEoLQdy15m5KprB7BWFHdw6FFHID1/O0+X9ZBn7u/kKqu +SOPBS/oMPOGaMAqPefUiRhAThu4KziRlD3XQgB6HIRdsBTk+G+w0qwPgTthpRRSryyE pBnAP5hEUoaekQlMIWviJaTbnNxFUo91F3G0c= 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=0zic6Xb7x3ksB70Q6ivPrFsurGOP6DOlLbZIMgBdKwU=; b=ULd8EiPj1sWt5f1Y0anDlQxQ5EqNU006YcRzpR6Ibw5SLCyX2/iAgZC5ndo77vTaQx j9tzGFku4MAPd7QduImCXUeKzK/Ca74Ojxb6HcuIJ61jws/1yHEfcQerJ//UuiaFia5T Vj2r+BhYv24UB9bsPzKLs21fMw+XavOJszUA0SEvdQgffVAyMDcUjXuXRsh/RcLSH36q 0eHO7FQOEbhkaRLO3Cv95dsnZeos9DTXEm1Ly8WU/QxdHQ0EdaURqHWupMYhkbXPBqRL PgFmdgJ6i1UE1TvQlv4f33fgB5W25iOct4EQCGCfh/9AKA4Wdyxxf+hXiEZTm0kqp2Gn d7vw== X-Gm-Message-State: AN3rC/522KwuSrOeBp6b1OFiWFl1tphhonkiby6WM/vB9yXRUcaX3Nil S9zZHRZw5ndzVTKp X-Received: by 10.80.177.148 with SMTP id m20mr45482569edd.173.1494326736312; Tue, 09 May 2017 03:45:36 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id o30sm2331510edc.42.2017.05.09.03.45.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 03:45:35 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 25/37] KVM: arm64: vgic-its: Fix pending table sync Date: Tue, 9 May 2017 12:44:54 +0200 Message-Id: <20170509104506.30929-26-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170509104506.30929-1-cdall@linaro.org> References: <20170509104506.30929-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170509_114559_520332_501218DC X-CRM114-Status: GOOD ( 19.34 ) 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 , Eric Auger , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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: Eric Auger In its_sync_lpi_pending_table() we currently ignore the target_vcpu of the LPIs. We sync the pending bit found in the vcpu pending table even if the LPI is not targeting it. Also in vgic_its_cmd_handle_invall() we are supposed to read the config table data for the LPIs associated to the collection ID. At the moment we refresh all LPI config information. This patch passes a vpcu to vgic_copy_lpi_list() so that this latter returns a snapshot of the LPIs targeting this CPU and only those. Signed-off-by: Eric Auger Reviewed-by: Christoffer Dall Acked-by: Marc Zyngier --- virt/kvm/arm/vgic/vgic-its.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index adb3d9e..9f7105c 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -301,13 +301,13 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, } /* - * Create a snapshot of the current LPI list, so that we can enumerate all - * LPIs without holding any lock. - * Returns the array length and puts the kmalloc'ed array into intid_ptr. + * Create a snapshot of the current LPIs targeting @vcpu, so that we can + * enumerate those LPIs without holding any lock. + * Returns their number and puts the kmalloc'ed array into intid_ptr. */ -static int vgic_copy_lpi_list(struct kvm *kvm, u32 **intid_ptr) +static int vgic_copy_lpi_list(struct kvm_vcpu *vcpu, u32 **intid_ptr) { - struct vgic_dist *dist = &kvm->arch.vgic; + struct vgic_dist *dist = &vcpu->kvm->arch.vgic; struct vgic_irq *irq; u32 *intids; int irq_count = dist->lpi_list_count, i = 0; @@ -326,14 +326,14 @@ static int vgic_copy_lpi_list(struct kvm *kvm, u32 **intid_ptr) spin_lock(&dist->lpi_list_lock); list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { /* We don't need to "get" the IRQ, as we hold the list lock. */ - intids[i] = irq->intid; - if (++i == irq_count) - break; + if (irq->target_vcpu != vcpu) + continue; + intids[i++] = irq->intid; } spin_unlock(&dist->lpi_list_lock); *intid_ptr = intids; - return irq_count; + return i; } /* @@ -382,7 +382,7 @@ static u32 max_lpis_propbaser(u64 propbaser) } /* - * Scan the whole LPI pending table and sync the pending bit in there + * Sync the pending table pending bit of LPIs targeting @vcpu * with our own data structures. This relies on the LPI being * mapped before. */ @@ -395,7 +395,7 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu) u32 *intids; int nr_irqs, i; - nr_irqs = vgic_copy_lpi_list(vcpu->kvm, &intids); + nr_irqs = vgic_copy_lpi_list(vcpu, &intids); if (nr_irqs < 0) return nr_irqs; @@ -1081,7 +1081,7 @@ static int vgic_its_cmd_handle_invall(struct kvm *kvm, struct vgic_its *its, vcpu = kvm_get_vcpu(kvm, collection->target_addr); - irq_count = vgic_copy_lpi_list(kvm, &intids); + irq_count = vgic_copy_lpi_list(vcpu, &intids); if (irq_count < 0) return irq_count;