Received: from eggs.gnu.org ([2001:4830:134:3::10]:58066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNMs1-0005ZN-La for qemu-devel@nongnu.org; Sun, 24 Jan 2016 10:46:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNMs0-0007pe-JC for qemu-devel@nongnu.org; Sun, 24 Jan 2016 10:46:29 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNMs0-0007pW-CQ for qemu-devel@nongnu.org; Sun, 24 Jan 2016 10:46:28 -0500 Received: by mail-wm0-x241.google.com with SMTP id l65so6841049wmf.3 for ; Sun, 24 Jan 2016 07:46:28 -0800 (PST) From: James Clarke Date: Sun, 24 Jan 2016 15:41:26 +0000 Message-Id: <1453650086-92705-3-git-send-email-jrtc27@jrtc27.com> In-Reply-To: <1453650086-92705-1-git-send-email-jrtc27@jrtc27.com> References: <1453650086-92705-1-git-send-email-jrtc27@jrtc27.com> Subject: [Qemu-devel] [PATCH 2/2] target-ppc: mcrfs should always update FEX/VX and only clear exception bits List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: James Clarke , qemu-ppc@nongnu.org, Alexander Graf Signed-off-by: James Clarke --- target-ppc/cpu.h | 6 ++++++ target-ppc/translate.c | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 3a967b7..d811bc9 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -718,6 +718,12 @@ enum { #define FP_RN1 (1ull << FPSCR_RN1) #define FP_RN (1ull << FPSCR_RN) +/* the exception bits which can be cleared by mcrfs - includes FX */ +#define FP_EX_CLEAR_BITS (FP_FX | FP_OX | FP_UX | FP_ZX | \ + FP_XX | FP_VXSNAN | FP_VXISI | FP_VXIDI | \ + FP_VXZDZ | FP_VXIMZ | FP_VXVC | FP_VXSOFT | \ + FP_VXSQRT | FP_VXCVI) + /*****************************************************************************/ /* Vector status and control register */ #define VSCR_NJ 16 /* Vector non-java */ diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 4be7eaa..989f683 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -2501,17 +2501,24 @@ static void gen_mcrfs(DisasContext *ctx) { TCGv tmp = tcg_temp_new(); int bfa; + int nibble; + int shift; if (unlikely(!ctx->fpu_enabled)) { gen_exception(ctx, POWERPC_EXCP_FPU); return; } - bfa = 4 * (7 - crfS(ctx->opcode)); - tcg_gen_shri_tl(tmp, cpu_fpscr, bfa); + bfa = crfS(ctx->opcode); + nibble = 7 - bfa; + shift = 4 * nibble; + tcg_gen_shri_tl(tmp, cpu_fpscr, shift); tcg_gen_trunc_tl_i32(cpu_crf[crfD(ctx->opcode)], tmp); - tcg_temp_free(tmp); tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], 0xf); - tcg_gen_andi_tl(cpu_fpscr, cpu_fpscr, ~(0xF << bfa)); + /* Only the exception bits (including FX) should be cleared if read */ + tcg_gen_andi_tl(tmp, cpu_fpscr, ~((0xF << shift) & FP_EX_CLEAR_BITS)); + /* FEX and VX need to be updated, so don't set fpscr directly */ + gen_helper_store_fpscr(cpu_env, tmp, 1 << nibble); + tcg_temp_free(tmp); } /* mffs */ -- 2.7.0