From patchwork Wed Jun 7 00:31:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wj9Vq2zDmz9s5L for ; Wed, 7 Jun 2017 11:11:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ouFhDX/g"; dkim-atps=neutral Received: from localhost ([::1]:40736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIPVQ-0006cX-Ue for incoming@patchwork.ozlabs.org; Tue, 06 Jun 2017 21:11:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIOtn-0003TW-DU for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIOtm-0002FA-9F for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:35 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:36564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIOtm-0002Ex-5N for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:34 -0400 Received: by mail-qk0-x244.google.com with SMTP id y201so11029518qka.3 for ; Tue, 06 Jun 2017 17:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=e4qORPrxyE468YUchgT6oJlY09q09Ume8N+c34OkwZY=; b=ouFhDX/gK95ZobXE85WQ0rECq7h3WkSI9b5yGhwwHDI5kRAGPxXP6vUVnSLb1jcks6 4gedkkj8EAAtTBQxUX/k5krVWZhaYs+ykem9h8jKrlBcQXuoeZ/4Rdlt3Z+hcz6z8dw9 0EmTv2XG/Ud6qqel33cPzFv+eaTJByKzs0MbIC9KrYV517Jr9/F2uXYSPac7f89lgJcy rZmzu9SLXQMOKB5LRvBVugDiY0RB1LlR1p8ye0lC+R8OHsE9fsKHNgxdzZ+UQPihdnse sxWi5uswwhcjZ3tUUOJicblasZGF/1Q2H8FwdnVre7nXWZ5DK2PFehic/bFVB3krC0lq 8Wqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=e4qORPrxyE468YUchgT6oJlY09q09Ume8N+c34OkwZY=; b=dGlVQh2G5Czm4yfOreanqTGosDh5Z5lMfE/+E8yHNQIct9symXvB4v96he6w30L8Be WuCPMxREEmvaD2u5L+bbjdg8uCMaU7AePpGkNRANat0x3irJ+5bxn3s5i6+yOb7if7HH FVk7VVWTZiL2My1FSs6u/hgY6wFr0ux7mzDeW0VDRv2g+mBmzquBP1AebhH2QKCnYC6f uIRfmiS7ZDD4QgqhrWAcFgB7twRU9mVTCbwpN+EC1dw+qspLzAX8UhOOQffVQI9z0rjP TdO2zrtjf9v5qcj3Y2R/6NcRM/FTcKbaDwZN8+tenwORfNiI+iRcvr8nyZBnTW6+6R1o JEog== X-Gm-Message-State: AODbwcDPDasAx3h3wMNBS627eyJwiI3iwA8cPNLovJT5fxdQ0X8Po6/K 0D+69ZTJN0CahWpaN2Q= X-Received: by 10.55.43.93 with SMTP id r90mr32220226qkh.196.1496795553428; Tue, 06 Jun 2017 17:32:33 -0700 (PDT) Received: from bigtime.twiddle.net.com (71-217-91-69.tukw.qwest.net. [71.217.91.69]) by smtp.gmail.com with ESMTPSA id m47sm29286qtc.36.2017.06.06.17.32.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 17:32:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 17:31:02 -0700 Message-Id: <20170607003119.14778-54-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607003119.14778-1-rth@twiddle.net> References: <20170607003119.14778-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PULL v2 53/70] target/s390x: improve 24-bit and 31-bit lengths read/write 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: peter.maydell@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Aurelien Jarno Reviewed-by: Richard Henderson Signed-off-by: Aurelien Jarno Message-Id: <20170531220129.27724-17-aurelien@aurel32.net> Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 5f11e1e..83c32c4 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -407,6 +407,31 @@ static inline void set_address(CPUS390XState *env, int reg, uint64_t address) } } +static inline uint64_t wrap_length(CPUS390XState *env, uint64_t length) +{ + if (!(env->psw.mask & PSW_MASK_64)) { + /* 24-Bit and 31-Bit mode */ + length &= 0x7fffffff; + } + return length; +} + +static inline uint64_t get_length(CPUS390XState *env, int reg) +{ + return wrap_length(env, env->regs[reg]); +} + +static inline void set_length(CPUS390XState *env, int reg, uint64_t length) +{ + if (env->psw.mask & PSW_MASK_64) { + /* 64-Bit mode */ + env->regs[reg] = length; + } else { + /* 24-Bit and 31-Bit mode */ + env->regs[reg] = deposit64(env->regs[reg], 0, 32, length); + } +} + /* search string (c is byte to search, r2 is string, r1 end of string) */ uint64_t HELPER(srst)(CPUS390XState *env, uint64_t r0, uint64_t end, uint64_t str) @@ -598,19 +623,14 @@ uint32_t HELPER(mvcle)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3) { uintptr_t ra = GETPC(); - uint64_t destlen = env->regs[r1 + 1]; + uint64_t destlen = get_length(env, r1 + 1); uint64_t dest = get_address(env, r1); - uint64_t srclen = env->regs[r3 + 1]; + uint64_t srclen = get_length(env, r3 + 1); uint64_t src = get_address(env, r3); uint8_t pad = a2 & 0xff; uint8_t v; uint32_t cc; - if (!(env->psw.mask & PSW_MASK_64)) { - destlen = (uint32_t)destlen; - srclen = (uint32_t)srclen; - } - if (destlen == srclen) { cc = 0; } else if (destlen < srclen) { @@ -632,10 +652,9 @@ uint32_t HELPER(mvcle)(CPUS390XState *env, uint32_t r1, uint64_t a2, cpu_stb_data_ra(env, dest, pad, ra); } - env->regs[r1 + 1] = destlen; + set_length(env, r1 + 1 , destlen); /* can't use srclen here, we trunc'ed it */ - /* FIXME: 31-bit mode! */ - env->regs[r3 + 1] -= src - env->regs[r3]; + set_length(env, r3 + 1, env->regs[r3 + 1] - src - env->regs[r3]); set_address(env, r1, dest); set_address(env, r3, src); @@ -647,9 +666,9 @@ uint32_t HELPER(clcle)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3) { uintptr_t ra = GETPC(); - uint64_t destlen = env->regs[r1 + 1]; + uint64_t destlen = get_length(env, r1 + 1); uint64_t dest = get_address(env, r1); - uint64_t srclen = env->regs[r3 + 1]; + uint64_t srclen = get_length(env, r3 + 1); uint64_t src = get_address(env, r3); uint8_t pad = a2 & 0xff; uint32_t cc = 0; @@ -671,9 +690,9 @@ uint32_t HELPER(clcle)(CPUS390XState *env, uint32_t r1, uint64_t a2, } } - env->regs[r1 + 1] = destlen; + set_length(env, r1 + 1, destlen); /* can't use srclen here, we trunc'ed it */ - env->regs[r3 + 1] -= src - env->regs[r3]; + set_length(env, r3 + 1, env->regs[r3 + 1] - src - env->regs[r3]); set_address(env, r1, dest); set_address(env, r3, src);