From patchwork Thu Sep 25 17:49:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 37930 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 15ADD20560 for ; Thu, 25 Sep 2014 17:50:33 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id p10sf4133250wes.4 for ; Thu, 25 Sep 2014 10:50:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=BKSf0fiSQhqe+RPsvvIFPVN/f7hEKwi3CBppgRpuzd8=; b=VXRE91YzU+Tjf23N2GVE3qeFbFfVEc9RbuikMr9+eluB5Xd1EFdZuJ4nsYg+/8Bwou Hp9pizew/eU5YvJKfAT7MeQmj+hGtpoDFj56rIA4Kte7aOHGGecg79kWJMhoKxcHcLk6 sR3z8F9TDxElCCTT6xIhp38CyYt0EUyyuCyPdxNvOjdKm2RssM9YtAyvVx5+5YVyMLEG I7dsL/DqSINtEYTywTPrWQdNkewqY1CMI+VJEzzFYyRWEclJR9a5Zgy8EsbwkgFushd4 uqap/l0RsVlT0b+tWF5Wl8ePfdFxu9ptU7Nxb53dhcE4AAggzeuHYn1DfWuacLXMuPs1 HIWA== X-Gm-Message-State: ALoCoQlVR4T+8tVWxfpG0Vu3gmdUgE5b+e9rrEDiKQoPQNY3cbAxTx2p2TtwDO2k+bGm0RodunYw X-Received: by 10.152.2.97 with SMTP id 1mr1035229lat.6.1411667433150; Thu, 25 Sep 2014 10:50:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.130 with SMTP id m2ls335783laf.89.gmail; Thu, 25 Sep 2014 10:50:33 -0700 (PDT) X-Received: by 10.152.18.130 with SMTP id w2mr5255193lad.89.1411667432993; Thu, 25 Sep 2014 10:50:32 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by mx.google.com with ESMTPS id tw9si4131420lbb.0.2014.09.25.10.50.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Sep 2014 10:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id l4so13071795lbv.19 for ; Thu, 25 Sep 2014 10:50:32 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr14179097lbs.34.1411667432828; Thu, 25 Sep 2014 10:50:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp797158lbb; Thu, 25 Sep 2014 10:50:32 -0700 (PDT) X-Received: by 10.68.201.67 with SMTP id jy3mr21706853pbc.81.1411667431006; Thu, 25 Sep 2014 10:50:31 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gs9si5075488pbc.83.2014.09.25.10.50.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Sep 2014 10:50:30 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XXDA9-0004fQ-GA; Thu, 25 Sep 2014 17:49:05 +0000 Received: from mail-lb0-f174.google.com ([209.85.217.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XXDA7-0004Z5-0G for linux-arm-kernel@lists.infradead.org; Thu, 25 Sep 2014 17:49:03 +0000 Received: by mail-lb0-f174.google.com with SMTP id l4so13220550lbv.33 for ; Thu, 25 Sep 2014 10:48:40 -0700 (PDT) X-Received: by 10.112.34.239 with SMTP id c15mr14188815lbj.64.1411667320224; Thu, 25 Sep 2014 10:48:40 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id ai1sm1039676lbd.12.2014.09.25.10.48.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Sep 2014 10:48:39 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm/arm64: KVM: Fix set_clear_sgi_pend_reg offset Date: Thu, 25 Sep 2014 19:49:07 +0200 Message-Id: <1411667347-2989-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140925_104903_225343_AD5C3DE6 X-CRM114-Status: GOOD ( 10.69 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.174 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.217.174 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Christoffer Dall , kvm@vger.kernel.org, zhaoshenglong@huawei.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The sgi values calculated in read_set_clear_sgi_pend_reg() and write_set_clear_sgi_pend_reg() were horribly incorrectly multiplied by 4 with catastrophic results in that subfunctions ended up overwriting memory not allocated for the expected purpose. This showed up as bugs in kfree() and the kernel complaining a lot of you turn on memory debugging. This addresses: http://marc.info/?l=kvm&m=141164910007868&w=2 Reported-by: Shannon Zhao Signed-off-by: Christoffer Dall Tested-by: Shannon Zhao --- virt/kvm/arm/vgic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index b6fab0f..8629678 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -816,7 +816,7 @@ static bool read_set_clear_sgi_pend_reg(struct kvm_vcpu *vcpu, { struct vgic_dist *dist = &vcpu->kvm->arch.vgic; int sgi; - int min_sgi = (offset & ~0x3) * 4; + int min_sgi = (offset & ~0x3); int max_sgi = min_sgi + 3; int vcpu_id = vcpu->vcpu_id; u32 reg = 0; @@ -837,7 +837,7 @@ static bool write_set_clear_sgi_pend_reg(struct kvm_vcpu *vcpu, { struct vgic_dist *dist = &vcpu->kvm->arch.vgic; int sgi; - int min_sgi = (offset & ~0x3) * 4; + int min_sgi = (offset & ~0x3); int max_sgi = min_sgi + 3; int vcpu_id = vcpu->vcpu_id; u32 reg;