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: 10090331 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 B2B7860580 for ; Mon, 4 Dec 2017 14:03:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56FBB28A6E for ; Mon, 4 Dec 2017 14:03:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BB1228D48; Mon, 4 Dec 2017 14:03:59 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_DBL_ABUSE_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 E22A328A6E for ; Mon, 4 Dec 2017 14:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754376AbdLDOD5 (ORCPT ); Mon, 4 Dec 2017 09:03:57 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:44805 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754164AbdLDODy (ORCPT ); Mon, 4 Dec 2017 09:03:54 -0500 Received: by mail-wm0-f66.google.com with SMTP id t8so6000048wmc.3 for ; Mon, 04 Dec 2017 06:03:53 -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=Scqx1n2fCZ3ts5fsFaA5btdXxK/5RQCrFFNtNK7J/0eKcJodm0vVOqLMlwldSln8ht v+FSvb2Owd262qhRNZL2G5Jz1N7a1uJpp9Oo9tI8khiExEsnN4s2LQn6mVakMq/DwDcG RzExytyn1ztWqPfHtiu6WHyuzyzb7mFqLwWrTfXMAShLeglFC2tEtgR5G51E1vHWcx9O iiXXfEC1o/RelaDiK/yO8VhNsD8mUAU/Ya2M0wsaCcHuEraMlgSI2yB6p2HaBUEdzVUv Dk7IV1KZpp9U380NdEqWX2vFhOyxX01YD1TkglsZODhNK6/5w3s5dMhXrGGyFIiAaXdG y6GA== X-Gm-Message-State: AKGB3mLBoGTBepffVj9vrOOLaTLzbXfzltT9P25xSKG3OS9Jk8UeuUXy B9xzqeVEZvvzl7k/yfNpx12u5A== 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?= Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , stable@vger.kernel.org, Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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)