From patchwork Thu Oct 19 20:56:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10018311 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 4E22C60224 for ; Thu, 19 Oct 2017 20:58:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4172728D9F for ; Thu, 19 Oct 2017 20:58:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34FD728E5B; Thu, 19 Oct 2017 20:58:02 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 B0C5628D9F for ; Thu, 19 Oct 2017 20:58:01 +0000 (UTC) Received: from localhost ([::1]:51210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5HtA-0000H5-LE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Oct 2017 16:58:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5HsL-0000FW-Tv for qemu-devel@nongnu.org; Thu, 19 Oct 2017 16:57:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5HsK-00081f-VL for qemu-devel@nongnu.org; Thu, 19 Oct 2017 16:57:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:40854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5HsG-0007va-9x; Thu, 19 Oct 2017 16:57:04 -0400 Received: from [10.149.184.130] (162-198-228-33.lightspeed.wlfrct.sbcglobal.net [162.198.228.33]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 034402191C; Thu, 19 Oct 2017 20:57:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 034402191C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sstabellini@kernel.org Date: Thu, 19 Oct 2017 13:56:58 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: Peter Maydell In-Reply-To: Message-ID: References: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 198.145.29.99 Subject: Re: [Qemu-devel] [PATCH] fix WFI/WFE length in syndrome register 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: Stefano Stabellini , Julien Grall , QEMU Developers , qemu-arm Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 19 Oct 2017, Peter Maydell wrote: > On 18 October 2017 at 23:03, Stefano Stabellini wrote: > > WFI/E are 4 bytes long: set ARM_EL_IL_SHIFT in the syndrome. > > > > Signed-off-by: Stefano Stabellini > > > > diff --git a/target/arm/internals.h b/target/arm/internals.h > > index 1f6efef..cf8c966 100644 > > --- a/target/arm/internals.h > > +++ b/target/arm/internals.h > > @@ -398,6 +398,7 @@ static inline uint32_t syn_breakpoint(int same_el) > > static inline uint32_t syn_wfx(int cv, int cond, int ti) > > { > > return (EC_WFX_TRAP << ARM_EL_EC_SHIFT) | > > + (1 << ARM_EL_IL_SHIFT) | > > (cv << 24) | (cond << 20) | ti; > > } > > Hmm. What we do now is definitely wrong, but WFI and WFE can be 2 bytes: > there is a T1 Thumb encoding that is 2 bytes. > > HELPER(wfi) doesn't get that right, though: > if (target_el) { > env->pc -= 4; > raise_exception(env, EXCP_UDEF, syn_wfx(1, 0xe, 0), target_el); > } > > So I think that HELPER(wfi) needs to be passed an extra > parameter is_16bit, which it can then use both in its adjustment > of env->pc and to pass as an extra parameter to syn_wfx(), > which is then syn_wfx(int cv, int cond, int ti, bool is_16bit). > > (In theory HELPER(wfe) should also be passed is_16bit, but > since it doesn't currently ever raise an exception it > doesn't matter.) Wouldn't it be better to just check on env->thumb like HELPER(cpsr_write_eret) for example? diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 670c07a..a451763 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c diff --git a/target/arm/internals.h b/target/arm/internals.h index 43106a2..55c70b4 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -428,9 +428,10 @@ static inline uint32_t syn_breakpoint(int same_el) | ARM_EL_IL | 0x22; } -static inline uint32_t syn_wfx(int cv, int cond, int ti) +static inline uint32_t syn_wfx(int cv, int cond, int ti, bool is_16bit) { return (EC_WFX_TRAP << ARM_EL_EC_SHIFT) | + (is_16bit ? 0 : (1 << ARM_EL_IL_SHIFT)) | (cv << 24) | (cond << 20) | ti; } diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 3914145..ea16c9a 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -476,8 +476,8 @@ void HELPER(wfi)(CPUARMState *env) } if (target_el) { - env->pc -= 4; - raise_exception(env, EXCP_UDEF, syn_wfx(1, 0xe, 0), target_el); + env->pc -= env->thumb ? 2 : 4; + raise_exception(env, EXCP_UDEF, syn_wfx(1, 0xe, 0, env->thumb), target_el); } cs->exception_index = EXCP_HLT;