From nobody Sun May 5 21:38:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528963063111150.03447169813592; Thu, 14 Jun 2018 00:57:43 -0700 (PDT) Received: from localhost ([::1]:39088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTN8Y-0000Gl-Em for importer@patchew.org; Thu, 14 Jun 2018 03:57:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTL69-00021T-Bq for qemu-devel@nongnu.org; Thu, 14 Jun 2018 01:47:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTL66-0003jV-96 for qemu-devel@nongnu.org; Thu, 14 Jun 2018 01:47:05 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:45247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTL66-0003jL-2s for qemu-devel@nongnu.org; Thu, 14 Jun 2018 01:47:02 -0400 Received: by mail-pf0-x243.google.com with SMTP id a22-v6so2638589pfo.12 for ; Wed, 13 Jun 2018 22:47:01 -0700 (PDT) Received: from localhost.localdomain ([103.238.105.173]) by smtp.gmail.com with ESMTPSA id l15-v6sm8737703pfg.88.2018.06.13.22.46.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 22:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=URKAXx4UsNxiFZeMiGQ0aN9Ne9WM4TEB+gqxG9XOwx0=; b=nypbRBdnqV40aGYFl5VpJ2lpcr7OhqBbOaKToz1nnYaNgxJ+dRATS+BwQ/9FBdbvyQ PWC0BRodKpJ+3SKhnyeMsQOK3/cFtbg7zPPY5T4qQu1s11GcYPxhomTgbu8Yg7mtR0dn NeEHMLa+uhIGukQN7jGqUj2+/jNLbHHIaw9yTdF7zT2WY8ny2JdTt/7oLU0wGhCsls9j HxpV2vYcfGzatLT/GuuII1pw7Zen5RF4LSKFtw1BwsUXTdXkhowzxaOUhOi2pwDi9Hrl EgBltQQiLjeqHxWFNvRvWMZRaHk7N7YpES1W+D5FJStkTwySuQkho7JYBG6X/QlulqrB 2Gmg== 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; bh=URKAXx4UsNxiFZeMiGQ0aN9Ne9WM4TEB+gqxG9XOwx0=; b=UJKVWAyuHJ+/9VX9b7xesv2QdbYfmN0tX/xYrxfGnCs+aDsX+ZKt7eEEA5iJqv/EQH Fo5dsM9N9GcOc2VB8Ejj1VKqiXP8A1mMFbm1JhWP7iJ6He7nw9wvj/ly0PDvryQ8enxG zJ110jkM6OobvZZAOJYXbHuKx3UVgaF+rM7E25H+1eorU/aHjwGCBLLpTf3/B6hqa9qE 7US0hbIMMntZWv6+Gv6xy/YQS57KwL8Atsq8s4mb7V7MmvZMa8hQy7IyAUqD6UMpoE1D czVgpAvm2+AXUaKhQMmcZ5Kpv/79VGuX4y4n+XbwVuBFAudDXUWI1SpmcPJyRmCgsEaG 1r+A== X-Gm-Message-State: APt69E3r5lgrLBHiF0HO6w6x1sCgRRDsoekz7+LyqMD5K9xVEmjxYOFv Wt+7fROu36CtVMg5UAxn/WBDKJHs X-Google-Smtp-Source: ADUXVKLUqaQcHv43EzUi6f1h9gQ+pvRZf9J/mD1JutgkD/gi1ncBEOCDByBUaRwzDEPCJRLQIrPw2w== X-Received: by 2002:a62:1358:: with SMTP id b85-v6mr8027082pfj.238.1528955220625; Wed, 13 Jun 2018 22:47:00 -0700 (PDT) From: Amol Surati To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 11:18:57 +0530 Message-Id: <20180614054857.26248-1-suratiamol@gmail.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 X-Mailman-Approved-At: Thu, 14 Jun 2018 03:56:23 -0400 Subject: [Qemu-devel] [PATCH] hw/intc/arm_gicv3: fix an extra left-shift when reading IPRIORITYR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Amol Surati Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When either GICD_IPRIORITYR or GICR_IPRIORITYR is read as a 32-bit register, the post left-shift operator in the for loop causes an extra shift after the least significant byte has been placed. The 32-bit value actually returned is therefore the expected value shifted left by 8 bits. Signed-off-by: Amol Surati --- hw/intc/arm_gicv3_dist.c | 3 ++- hw/intc/arm_gicv3_redist.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c index 93fe936862..53c55c5729 100644 --- a/hw/intc/arm_gicv3_dist.c +++ b/hw/intc/arm_gicv3_dist.c @@ -441,7 +441,8 @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr off= set, int i, irq =3D offset - GICD_IPRIORITYR; uint32_t value =3D 0; =20 - for (i =3D irq + 3; i >=3D irq; i--, value <<=3D 8) { + for (i =3D irq + 3; i >=3D irq; i--) { + value <<=3D 8; value |=3D gicd_read_ipriorityr(s, attrs, i); } *data =3D value; diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index 8a8684d76e..3b0ba6de1a 100644 --- a/hw/intc/arm_gicv3_redist.c +++ b/hw/intc/arm_gicv3_redist.c @@ -192,7 +192,8 @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr= offset, int i, irq =3D offset - GICR_IPRIORITYR; uint32_t value =3D 0; =20 - for (i =3D irq + 3; i >=3D irq; i--, value <<=3D 8) { + for (i =3D irq + 3; i >=3D irq; i--) { + value <<=3D 8; value |=3D gicr_read_ipriorityr(cs, attrs, i); } *data =3D value; --=20 2.17.1