From patchwork Mon Aug 20 17:59:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Fennell X-Patchwork-Id: 178908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 055422C009A for ; Tue, 21 Aug 2012 04:00:30 +1000 (EST) Received: from localhost ([::1]:44826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3WH6-0004Ea-5m for incoming@patchwork.ozlabs.org; Mon, 20 Aug 2012 14:00:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3WGu-00043A-CQ for qemu-devel@nongnu.org; Mon, 20 Aug 2012 14:00:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3WGt-0003ff-4M for qemu-devel@nongnu.org; Mon, 20 Aug 2012 14:00:16 -0400 Received: from gir.skynet.ie ([193.1.99.77]:56050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3WGs-0003fJ-MK for qemu-devel@nongnu.org; Mon, 20 Aug 2012 14:00:15 -0400 Received: from skynet.skynet.ie (skynet.skynet.ie [193.1.99.74]) by gir.skynet.ie (Postfix) with ESMTP id 8D67C10202; Mon, 20 Aug 2012 19:00:12 +0100 (IST) Received: by skynet.skynet.ie (Postfix, from userid 2582) id 89AF35025F; Mon, 20 Aug 2012 19:00:07 +0100 (IST) From: Brendan Fennell To: qemu-devel@nongnu.org Date: Mon, 20 Aug 2012 18:59:54 +0100 Message-Id: <1345485594-22244-1-git-send-email-bfennell@skynet.ie> X-Mailer: git-send-email 1.6.3 To: bfennell@skynet.ie X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 193.1.99.77 Cc: peter.maydell@linaro.org, Brendan Fennell Subject: [Qemu-devel] [PATCH v3] pl190: fix read of VECTADDR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Brendan Fennell Reviewed-by: Peter Maydell --- hw/pl190.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/pl190.c b/hw/pl190.c index cb50afb..b372da8 100644 --- a/hw/pl190.c +++ b/hw/pl190.c @@ -117,12 +117,18 @@ static uint64_t pl190_read(void *opaque, target_phys_addr_t offset, return s->protected; case 12: /* VECTADDR */ /* Read vector address at the start of an ISR. Increases the - current priority level to that of the current interrupt. */ - for (i = 0; i < s->priority; i++) - { - if ((s->level | s->soft_level) & s->prio_mask[i]) - break; - } + * current priority level to that of the current interrupt. + * + * Since an enabled interrupt X at priority P causes prio_mask[Y] + * to have bit X set for all Y > P, this loop will stop with + * i == the priority of the highest priority set interrupt. + */ + for (i = 0; i < s->priority; i++) { + if ((s->level | s->soft_level) & s->prio_mask[(i + 1)]) { + break; + } + } + /* Reading this value with no pending interrupts is undefined. We return the default address. */ if (i == PL190_NUM_PRIO)