From patchwork Mon Dec 4 14:03:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10090355 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 AB05C60329 for ; Mon, 4 Dec 2017 14:04:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92D9F2899A for ; Mon, 4 Dec 2017 14:04:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87A0528D48; Mon, 4 Dec 2017 14:04: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=-2.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, URIBL_DBL_ABUSE_SPAM 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 F15BF2899A for ; Mon, 4 Dec 2017 14:04: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: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=1UUqj6qDRYPvopyBzjhO81tGpts7fkABj4v8NKn5Zy8=; b=ZPeLCTCIi2TxC8kyAYbryq/K9Q F9tfdIdW40sjzGbZvg6ySj38Eh1mSQ83VbG5ePDtEDEQxavbvsNRxAlKhz3Cvjxg/qe1igmL/iM5d SEOQ3h1j/K3pD+2cOOxZQZrLzSXTE6rWJGmE8VeTXxVsH+WuQuI0Iz5rwLY2ndIdyR1R28QLtnJeO HCaC6z0RCoJflJXV3unIEphS4VjrEAKyc+Hx31eW6Eihll7nnBaXU1g3s7qZ9do/+v0SL0ZxroPgE gR8i6QGTI6MwF6IsolDDJCjAB27LbdoyUfILonT60dWeF7oE73uGmFG3Nzr8e46KQwScifsr1bSSx TIzl5aeQ==; 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 1eLrMK-0002qU-7L; Mon, 04 Dec 2017 14:04:36 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLrLy-0002Nj-R2 for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 14:04:16 +0000 Received: by mail-wm0-x244.google.com with SMTP id i11so14461475wmf.4 for ; Mon, 04 Dec 2017 06:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=TmaNMu0M7k204C0NDi+s40IgEK6nif15+A5iZT2a8Jc=; b=gqo/phH77XEQ6AxcaOPptrlizc0DPPBJZs1/QRrK5d/7p++f/MNZl35eyEG+Uy5k+2 thkRZFXjoakJgXq14hhIbNHGv5465Jkypvanpvm4sC5Ul/cSS92XryoW9Qlt7IErAicv sQsYe9SwJbs+3UDhE03njBVDHf2GXu7x/d7fZjO63jmUFG8EbaHJ/hKbpLoLkQyGtaRx HlSqtupbOmTXpQkuWq++kN8j7hnlmooJ3G8tbUkhqGOjxX+kOxxM0at2qe73bwsSHzge xcL0eG/dDodaMCZdObyJrc7L84tWJ8ttE+uvvAjBVNuPAzoW17akR8/NmhzVMjCd+o4r Vsjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=TmaNMu0M7k204C0NDi+s40IgEK6nif15+A5iZT2a8Jc=; b=g22SgAu8buvRa7ATcqkOuVvttW/eKm0trXX7b1AWG7lXvsXmkiSxqeu/skDNmLvtjC EypEy+k8dQSgqCZj0ui+l9pvSN1CFD/Ae76c/kvyUFN5LSjqOH06Ot7PWoy6aq9Sbef0 gu+xnDzYYLRSmQIjMsyWgrDUpulYtMibhhlru72JvfV7nPFilZ/0IOS/w96CU0rfgRM9 9oYfglcY15nE1kuKkLL5Ot6pPMKXpph1jGK6BkJPAALIvN6He3tUScwjmrFXRAf6z2cM iJCSVY52RJSn4cudg+K1j/gpCBxqrkIymdpAopsxqU0ZfSYVKLRSsIMBar3/O+MY0vmV 3hqw== X-Gm-Message-State: AKGB3mKbMiVGjRdcIOqQlWM/CE0ND1qvJAqRZWwgqTXijINYQt33S97F y0Eaq/M7RA+0V+rj7CIqlR+zRQ== X-Google-Smtp-Source: AGs4zMZSaG6ubXbOzABAZjj/fDm7SMtFt5pGnrr94JOE71CdNBFTe3FP0H9O5UKYYLC3RAqUWXNIJg== X-Received: by 10.28.66.148 with SMTP id k20mr3507437wmi.40.1512396233015; Mon, 04 Dec 2017 06:03:53 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id g7sm22794279wra.38.2017.12.04.06.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:52 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 04/19] KVM: arm/arm64: vgic: Preserve the revious read from the pending table Date: Mon, 4 Dec 2017 15:03:33 +0100 Message-Id: <20171204140348.21965-2-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204135637.21620-1-cdall@kernel.org> References: <20171204135637.21620-1-cdall@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171204_060415_034935_BC8329B8 X-CRM114-Status: GOOD ( 10.22 ) 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 , stable@vger.kernel.org, Christoffer Dall , 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: Marc Zyngier The current pending table parsing code assumes that we keep the previous read of the pending bits, but keep that variable in the current block, making sure it is discarded on each loop. We end-up using whatever is on the stack. Who knows, it might just be the right thing... Fixes: 280771252c1ba ("KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES") Cc: # 4.12 Reported-by: AKASHI Takahiro Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index 2f05f732d3fd..f47e8481fa45 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -327,13 +327,13 @@ int vgic_v3_save_pending_tables(struct kvm *kvm) int last_byte_offset = -1; struct vgic_irq *irq; int ret; + u8 val; list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { int byte_offset, bit_nr; struct kvm_vcpu *vcpu; gpa_t pendbase, ptr; bool stored; - u8 val; vcpu = irq->target_vcpu; if (!vcpu)