From patchwork Sun Sep 9 21:05:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 182658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 46EAA2C0097 for ; Mon, 10 Sep 2012 07:12:54 +1000 (EST) Received: from localhost ([::1]:40320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAooG-0000Z4-8a for incoming@patchwork.ozlabs.org; Sun, 09 Sep 2012 17:12:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAojO-00009m-IM for qemu-devel@nongnu.org; Sun, 09 Sep 2012 17:07:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAojN-0006F3-78 for qemu-devel@nongnu.org; Sun, 09 Sep 2012 17:07:50 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:63059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAojN-0005pO-0x for qemu-devel@nongnu.org; Sun, 09 Sep 2012 17:07:49 -0400 Received: by mail-pz0-f45.google.com with SMTP id n15so968311dad.4 for ; Sun, 09 Sep 2012 14:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=pt/xELCWoywm4Afb94bsjke5CPn3zKAhebRJc+EhyQM=; b=hJPiFZMHbNw9PyZBWrQ9YI3xDoY9FvBZPSkU4jCQ4clxLSlx5WbOZ7VG9h383CDoEV u9kdN+ORygmNFTgVKqft7JCzeepmwdnbpQtPFnA6Rn20Czvk4POto6Taqwd/WazIjCf3 qm+Uturo/5fd2/+S6llDULA3aoEuKYWz75cRwCgWcid52ZJPlTLOHWnVrK6+1auwhTED hJQ2PDTY/cLebvKkwDY3/vLeNAaiIvbg7BR7M0OVpPM2Cht0Ek+dYSqtD8Af6IBsQvPe +F50yzCkmd+Hz7k+E7ij72vCKVn0Akl7qq5Zg4FS6Ew8ET6ENj51oR0qfjrHptT1mq+l to4Q== Received: by 10.66.76.130 with SMTP id k2mr18184073paw.19.1347224868746; Sun, 09 Sep 2012 14:07:48 -0700 (PDT) Received: from anchor.twiddle.home ([173.160.232.49]) by mx.google.com with ESMTPS id tw5sm662053pbc.48.2012.09.09.14.07.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 14:07:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 9 Sep 2012 14:05:45 -0700 Message-Id: <1347224784-19472-88-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1347224784-19472-1-git-send-email-rth@twiddle.net> References: <1347224784-19472-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 087/126] target-s390: Convert SRST X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- target-s390x/helper.h | 2 +- target-s390x/insn-data.def | 3 +++ target-s390x/mem_helper.c | 38 +++++++++++++++++++++++++------------- target-s390x/translate.c | 31 ++++++++++++++----------------- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/target-s390x/helper.h b/target-s390x/helper.h index 473e776..281ec42 100644 --- a/target-s390x/helper.h +++ b/target-s390x/helper.h @@ -24,7 +24,7 @@ DEF_HELPER_FLAGS_3(set_cc_sub64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64, s64, s6 DEF_HELPER_FLAGS_3(set_cc_subu64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i64, i64) DEF_HELPER_FLAGS_3(set_cc_sub32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32, s32, s32) DEF_HELPER_FLAGS_3(set_cc_subu32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32, i32) -DEF_HELPER_4(srst, i32, env, i32, i32, i32) +DEF_HELPER_4(srst, i64, env, i64, i64, i64) DEF_HELPER_4(clst, i64, env, i64, i64, i64) DEF_HELPER_4(mvpg, void, env, i64, i64, i64) DEF_HELPER_4(mvst, i64, env, i64, i64, i64) diff --git a/target-s390x/insn-data.def b/target-s390x/insn-data.def index 501d02e..06cb96e 100644 --- a/target-s390x/insn-data.def +++ b/target-s390x/insn-data.def @@ -471,6 +471,9 @@ C(0xeb1d, RLL, RSY_a, Z, r3_o, sh32, new, r1_32, rll32, 0) C(0xeb1c, RLLG, RSY_a, Z, r3_o, sh64, r1, 0, rll64, 0) +/* SEARCH STRING */ + C(0xb25e, SRST, RRE, Z, r1_o, r2_o, 0, 0, srst, 0) + /* SET ACCESS */ C(0xb24e, SAR, RRE, Z, 0, r2_o, 0, 0, sar, 0) /* SET FPC */ diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index 8cc4625..a700bb0 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -337,25 +337,37 @@ static inline uint64_t get_address_31fix(CPUS390XState *env, int reg) } /* search string (c is byte to search, r2 is string, r1 end of string) */ -uint32_t HELPER(srst)(CPUS390XState *env, uint32_t c, uint32_t r1, uint32_t r2) +uint64_t HELPER(srst)(CPUS390XState *env, uint64_t c, uint64_t end, + uint64_t str) { - uint64_t i; - uint32_t cc = 2; - uint64_t str = get_address_31fix(env, r2); - uint64_t end = get_address_31fix(env, r1); + uint32_t len; - HELPER_LOG("%s: c %d *r1 0x%" PRIx64 " *r2 0x%" PRIx64 "\n", __func__, - c, env->regs[r1], env->regs[r2]); + c = c & 0xff; + str = fix_address(env, str); + end = fix_address(env, end); - for (i = str; i != end; i++) { - if (cpu_ldub_data(env, i) == c) { - env->regs[r1] = i; - cc = 1; - break; + /* Assume for now that R2 is unmodified. */ + env->retxl = str; + + /* Lest we fail to service interrupts in a timely manner, limit the + amount of work we're willing to do. For now, lets cap at 8k. */ + for (len = 0; len < 0x2000; ++len) { + uint8_t v = cpu_ldub_data(env, str + len); + if (v == c) { + /* Character found. Set R1 to the found location. */ + env->cc_op = 1; + return str + len; + } else if (str + len == end) { + /* Character not found. R1 is unmodified. */ + env->cc_op = 2; + return end; } } - return cc; + /* CPU-determined bytes processed. Advance R2 to next byte to process. */ + env->retxl = str + len; + env->cc_op = 3; + return end; } /* unsigned string compare (c is string terminator) */ diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 49f419a..018ddfc 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -1018,12 +1018,11 @@ static void free_compare(DisasCompare *c) static void disas_b2(DisasContext *s, int op, uint32_t insn) { +#ifndef CONFIG_USER_ONLY TCGv_i64 tmp, tmp2, tmp3; - TCGv_i32 tmp32_1, tmp32_2, tmp32_3; + TCGv_i32 tmp32_1, tmp32_2; int r1, r2; -#ifndef CONFIG_USER_ONLY int r3, d2, b2; -#endif r1 = (insn >> 4) & 0xf; r2 = insn & 0xf; @@ -1031,19 +1030,6 @@ static void disas_b2(DisasContext *s, int op, uint32_t insn) LOG_DISAS("disas_b2: op 0x%x r1 %d r2 %d\n", op, r1, r2); switch (op) { - case 0x5e: /* SRST R1,R2 [RRE] */ - tmp32_1 = load_reg32(0); - tmp32_2 = tcg_const_i32(r1); - tmp32_3 = tcg_const_i32(r2); - potential_page_fault(s); - gen_helper_srst(cc_op, cpu_env, tmp32_1, tmp32_2, tmp32_3); - set_cc_static(s); - tcg_temp_free_i32(tmp32_1); - tcg_temp_free_i32(tmp32_2); - tcg_temp_free_i32(tmp32_3); - break; - -#ifndef CONFIG_USER_ONLY case 0x02: /* STIDP D2(B2) [S] */ /* Store CPU ID */ check_privileged(s); @@ -1311,12 +1297,14 @@ static void disas_b2(DisasContext *s, int op, uint32_t insn) tcg_temp_free_i32(tmp32_1); tcg_temp_free_i64(tmp); break; -#endif default: +#endif LOG_DISAS("illegal b2 operation 0x%x\n", op); gen_illegal_opcode(s); +#ifndef CONFIG_USER_ONLY break; } +#endif } static void disas_s390_insn(DisasContext *s) @@ -3060,6 +3048,15 @@ static ExitStatus op_stmh(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_srst(DisasContext *s, DisasOps *o) +{ + potential_page_fault(s); + gen_helper_srst(o->in1, cpu_env, regs[0], o->in1, o->in2); + set_cc_static(s); + return_low128(o->in2); + return NO_EXIT; +} + static ExitStatus op_sub(DisasContext *s, DisasOps *o) { tcg_gen_sub_i64(o->out, o->in1, o->in2);