From patchwork Sun Jul 1 05:11:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 10498507 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 6800F60325 for ; Sun, 1 Jul 2018 05:12:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5637128A4A for ; Sun, 1 Jul 2018 05:12:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4702928A52; Sun, 1 Jul 2018 05:12:49 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF63128A4A for ; Sun, 1 Jul 2018 05:12:48 +0000 (UTC) Received: from localhost ([::1]:48849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZUfF-0002UV-UR for patchwork-qemu-devel@patchwork.kernel.org; Sun, 01 Jul 2018 01:12:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZUeX-0002Bd-Bj for qemu-devel@nongnu.org; Sun, 01 Jul 2018 01:12:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZUeU-0004lC-78 for qemu-devel@nongnu.org; Sun, 01 Jul 2018 01:12:01 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35565) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZUeU-0004ir-0E for qemu-devel@nongnu.org; Sun, 01 Jul 2018 01:11:58 -0400 Received: by mail-pf0-x242.google.com with SMTP id a24-v6so2348472pfo.2 for ; Sat, 30 Jun 2018 22:11:56 -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=x0u7sEZXBlFKDd/yE84BIosftxCD9C//cQUBU8MwoRc=; b=WOJjZ4Npp3ufVG+d3Gd7tFpRLRPJUcTRjeBLIG1yrNSduXSIal/s5+MXS0yzP80/jw 7wJ6edD3Cd40FiI62TCJZPWG1TK/zZmYdjb74njxOpTkOEkj9kHP7gHqMkh6ac06ShbZ 3QAVwaVTFOiYemaklE1igHWLlWklkGPQ4fehdveSGodw88zzbzjQsNvjtsk1JCBlxJcp e+E7EiMKaXc8nq2wO14cgnYsETGJuKMNdo/R/7eAUae6EkAZuQdzmc27bah+J4jmgNU/ BY7sg5EAhQSAtdkN6mhrYVxTfNp3u7/hxW6VvhJ5tAiGxWa8PSt11lZJEpp3pMR6YhIO 9Jtg== 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=x0u7sEZXBlFKDd/yE84BIosftxCD9C//cQUBU8MwoRc=; b=t0CW0UlEK2qHIgXTiuDMA32Ow8+6TaV1gm0Rqi7UAcqoocRkweB4U+lhhKJdsnwQEz axUNWoR0d7dhX4mtHdCGn/5ritGyt9kekV/kCGA5tCLRK2bTuqxp/x24qs7tWEwESTzt pG6NgmcdsIezePWkfFm4Ls+E7cHpHyYhSjeCH49x7h/gSqzU+/AJRLBX1nfK3WVBwTVF I5kGwtHRnW1fxZsBgoTV0oUdeCJk5mQQjpPjee0+51MYojD4pgwqlMSaxCdODZ/1YIxy +ngS2jc4efpMhFrFTM1BVIEBD2MHuleHCl4BsckjBe1WapxsU3XTCx1Qif14v1sbkeK+ gYVA== X-Gm-Message-State: APt69E234GQbm2A+vUwjWyQ+s28RDYDJaIP0c0NQq1NSTOdmFD38b/GC cXOas0GeI+oQcE4DA71M8GWb8Nl1 X-Google-Smtp-Source: AAOMgpdEcg3nPC1MhKdPMsCtEQQqWdFvEICGyxcN+YIO+Nr7r4Tjsg4H8W5RgXSZ1R6PzZdn/EY+rg== X-Received: by 2002:a62:3d41:: with SMTP id k62-v6mr3249524pfa.35.1530421915283; Sat, 30 Jun 2018 22:11:55 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id 76-v6sm7566792pfx.40.2018.06.30.22.11.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Jun 2018 22:11:54 -0700 (PDT) From: Stafford Horne To: QEMU Development Date: Sun, 1 Jul 2018 14:11:47 +0900 Message-Id: <20180701051147.31649-1-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH] target/openrisc: Fix delay slot exception flag to match spec 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: Stafford Horne , Openrisc , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The delay slot exception flag is only set on the SR register during exception. Previously it was being set on both the ESR and SR this caused QEMU to differ from the spec. The was apparent as the linux kernel had a bug where it could boot on QEMU but not on real hardware. The fixed logic now matches hardware. Signed-off-by: Stafford Horne Reviewed-by: Richard Henderson --- target/openrisc/interrupt.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 138ad17f00..bbae956361 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -35,13 +35,6 @@ void openrisc_cpu_do_interrupt(CPUState *cs) int exception = cs->exception_index; env->epcr = env->pc; - if (env->dflag) { - env->dflag = 0; - env->sr |= SR_DSX; - env->epcr -= 4; - } else { - env->sr &= ~SR_DSX; - } if (exception == EXCP_SYSCALL) { env->epcr += 4; } @@ -51,7 +44,10 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->eear = env->pc; } + /* During exceptions esr is populared with the pre-exception sr. */ env->esr = cpu_get_sr(env); + /* In parallel sr is updated to disable mmu, interrupts, timers and + set the delay slot exception flag. */ env->sr &= ~SR_DME; env->sr &= ~SR_IME; env->sr |= SR_SM; @@ -61,6 +57,15 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->pmr &= ~PMR_SME; env->lock_addr = -1; + /* Set/clear dsx to indicate if we are in a delay slot exception. */ + if (env->dflag) { + env->dflag = 0; + env->sr |= SR_DSX; + env->epcr -= 4; + } else { + env->sr &= ~SR_DSX; + } + if (exception > 0 && exception < EXCP_NR) { static const char * const int_name[EXCP_NR] = { [EXCP_RESET] = "RESET",