From patchwork Mon Jul 2 15:10:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 938004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B2GNV4py"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KBBP6jS8z9s29 for ; Tue, 3 Jul 2018 01:34:21 +1000 (AEST) Received: from localhost ([::1]:33572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0qJ-0005M3-Dk for incoming@patchwork.ozlabs.org; Mon, 02 Jul 2018 11:34:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UO-0004dV-Vg for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0UM-0008Oa-Nd for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:40 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:44779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0UM-0008NY-HC for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:38 -0400 Received: by mail-pg0-x244.google.com with SMTP id r1-v6so1582546pgp.11 for ; Mon, 02 Jul 2018 08:11:38 -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:in-reply-to:references; bh=efDCn0n+AeRfqOb3vCf/lumK4UA9AxiW92CgAjMjKNo=; b=B2GNV4pyGuHnLDouV+SLQorWp2xWycCZmbt9Eehw0fnHlI0oU/lUO9eqPxBdXH33Bz flxOstnHXUiVzjb18aKCM/+PCjBMQoIx000oEKA5ybWlLsqtJZ89KvlstuZyj0X+JSee U9AMbK6vjw0LB3NCbtr/vHJiph+VO5vy5brgWkhYrKnfmjlX0y88tMUB54uv4XxerVsD Alg3YA3ooduvJCxAz0n+BH/WyaGrUkNrXiN/6eYAefrmtzaG43jp5ayvBV4w7NWWU0fn mXCPETMpZ3E+IgjTICY+VYXpZSxcQohacI0I3GZm5kJuWeG6k49/CoRnHvm/D/GHWKwZ 8Vjw== 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:in-reply-to :references; bh=efDCn0n+AeRfqOb3vCf/lumK4UA9AxiW92CgAjMjKNo=; b=UetWFpGcrAjZK1yxydtLR+vBt4s9DkuC6Waz91qQZ2wBRPLEOK1dTlHC+fTmAxjSUF 6aGwu+wl5if7fSpKorR69VSOUbgrwll380mgZxQVqPGM+Wmea2H1boKd56jQGgn2EtKM CeZolAbjm+p8qoswyc15I1anunTr423K7DZhkIXXAu43Hldsf/Wg/Sx4hm4rNgu3ZiOn KljG2JyXwMWwCM5ZxuylZ+GFyUE2yAcDmbeZSvhlpd58kAInmF4DCX5kEMA3dAj+AkWi k6A+Cm81ChMuqbtkBvre+R1yvoo9W9N5F2Eccx+YHOcCnDjpVxXUFjYrFph4glvUAf3f pa8w== X-Gm-Message-State: APt69E2E3TnInWVZxO7SlmE+K0GbxJsVHKNLv+pqtswyyUpbvjScvJ2U 1mHr+tKooyVPnXHbb1rXv+4= X-Google-Smtp-Source: ADUXVKITKQ7ATSeWS6fDqSSstZwoPvSNCJokosK+D6cKHkNQEYzE5rM2oRZHBQ236Gx7jy63VsO2Ug== X-Received: by 2002:a65:5c4b:: with SMTP id v11-v6mr22419761pgr.445.1530544297767; Mon, 02 Jul 2018 08:11:37 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id e17-v6sm23556897pgo.70.2018.07.02.08.11.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:37 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:22 +0900 Message-Id: <20180702151023.24532-25-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PULL v2 24/25] 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 , QEMU Development Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. Reviewed-by: Richard Henderson Signed-off-by: Stafford Horne --- 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",