From patchwork Wed Aug 22 14:40:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Zbitskiy X-Patchwork-Id: 960991 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="eTkK3wYf"; 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 41wVc85tPMz9s3x for ; Thu, 23 Aug 2018 00:41:44 +1000 (AEST) Received: from localhost ([::1]:59369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsUKM-0005Rn-Ct for incoming@patchwork.ozlabs.org; Wed, 22 Aug 2018 10:41:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsUJh-0005Of-C0 for qemu-devel@nongnu.org; Wed, 22 Aug 2018 10:41:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsUJf-0000AW-Bw for qemu-devel@nongnu.org; Wed, 22 Aug 2018 10:41:01 -0400 Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]:40970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsUJf-00009S-50; Wed, 22 Aug 2018 10:40:59 -0400 Received: by mail-qt0-x231.google.com with SMTP id t39-v6so1534076qtc.8; Wed, 22 Aug 2018 07:40:58 -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 :mime-version:content-transfer-encoding; bh=A8ISTKveCq0TG8f0jH20mnKsOIPZK0x3QFO2qjy7wjk=; b=eTkK3wYfZwqohgnKGETRZBt+/VG++ymm8B3zO6meK9kqAoOuw9nbkIvujK0Mc4DOP4 ZbQTd89aFuhW60NGkYuW7NhAWWgRyjRnYcWkupMJsGnYpYt+62+1XrecUBl5N6+Rnhnx e/L1q5n4/v2eIRInujlDL5H5V4uFAYSEuDO0rRkUpJI9ncLkGhdpx3DLA6CqFCEA2Pf9 ADeZ2QBLlx2NZs61DrCZpIDzNMXtBWxbj/hBECuTbogIDIebrMHM10byIApA0d5+vb3t HbVYF1+o7uLXyPiCWB9PLaPrTenbaZkWjMK4CcsAWGymMZfQTBKOgcYuM167FInJSU4O uy7Q== 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:mime-version:content-transfer-encoding; bh=A8ISTKveCq0TG8f0jH20mnKsOIPZK0x3QFO2qjy7wjk=; b=T0NMLx9GqfBsQUEQvWcTxiuGRlhC+vhX9uAQUNW+LcHPVxwtM6w9XSvn2JUW6L4mqK IeeaKOp4jR7nagjsqhEVy0rva0KwaBm/fPWDETv8YH2ai2d8a7CGyRXjGHiIozzXB2cP 7IcnHQXgViYSvI7JwOg4T3SwWxYt1L5U3kRsGQVO2SYW45uicGuJsjn+Be2/OykZVMeu xTeXnpiCTdbDmsrNhzzh4F+1y6dPm32UoyvVfNORENbiiV8poFvxm2kLfTA6ySYU4Ews B9cjBM5FlWZS5raBD8ObmOIe3t9oDpGJiBMJQar1FpEhLt6Y0LI6UZJO6gqJYoPN4SKX 3+Vw== X-Gm-Message-State: APzg51BQi3Z0cTqFdissdvQ6VPrgn70QTYSEl2zm8qSDc9+MGmtBSmbD sU1Qk/LxZdp9EDdmaSI+zKdxbkSUj74= X-Google-Smtp-Source: ANB0VdZhYgomzpkSHFqkfQrBtPJtpywiDGQFBsRQ/eaZ/YuRzer21KUkkvjM40NGA+8LrdmiS19kSQ== X-Received: by 2002:ac8:2a58:: with SMTP id l24-v6mr4163226qtl.154.1534948857871; Wed, 22 Aug 2018 07:40:57 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id 62-v6sm1217660qkx.66.2018.08.22.07.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 07:40:57 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Wed, 22 Aug 2018 10:40:37 -0400 Message-Id: <20180822144039.5796-2-pavel.zbitskiy@gmail.com> In-Reply-To: <20180822144039.5796-1-pavel.zbitskiy@gmail.com> References: <20180822144039.5796-1-pavel.zbitskiy@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::231 Subject: [Qemu-devel] [PATCH v4 1/3] target/s390x: use regular spaces in translate.c 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In a few places translate.c contains non-breaking spaces (0xc2 0xa0) instead of regular ones (0x20): 7c 7c c2 a0 63 63 7c 7c 20 63 63 | | c c This confuses some text editors. Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- target/s390x/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 40e12ca2c4..7363aabf3a 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -842,7 +842,7 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) cond = TCG_COND_NE; c->u.s32.b = tcg_const_i32(1); break; - case 0x8 | 0x2: /* cc == 0 || cc == 2 => (cc & 1) == 0 */ + case 0x8 | 0x2: /* cc == 0 || cc == 2 => (cc & 1) == 0 */ cond = TCG_COND_EQ; c->g1 = false; c->u.s32.a = tcg_temp_new_i32(); @@ -861,7 +861,7 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) cond = TCG_COND_NE; c->u.s32.b = tcg_const_i32(0); break; - case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ + case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ cond = TCG_COND_NE; c->g1 = false; c->u.s32.a = tcg_temp_new_i32(); From patchwork Wed Aug 22 14:40:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Zbitskiy X-Patchwork-Id: 960992 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="GuO3DVmp"; 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 41wVcJ4T6Pz9s47 for ; Thu, 23 Aug 2018 00:41:52 +1000 (AEST) Received: from localhost ([::1]:59370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsUKU-0005Yh-7U for incoming@patchwork.ozlabs.org; Wed, 22 Aug 2018 10:41:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsUJl-0005VH-8K for qemu-devel@nongnu.org; Wed, 22 Aug 2018 10:41:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsUJh-0000Bk-Jl for qemu-devel@nongnu.org; Wed, 22 Aug 2018 10:41:03 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:46903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsUJh-0000Ac-79; Wed, 22 Aug 2018 10:41:01 -0400 Received: by mail-qt0-x242.google.com with SMTP id d4-v6so2276803qtn.13; Wed, 22 Aug 2018 07:40:59 -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=DHL3Zcwss0piFlDFYYhvTKui+H42kSvp+qfuGFaFUFo=; b=GuO3DVmpTodR5MQPVfoHdkeUY1ojlvOIJnx3W/63Zhrl1anssReddBrxouJTTolou/ XX1Vk+0LJ3EowaMV/xLxTQj7y9vjyvJ3DF5dn/wOPy9/46804OZtgiS8P5XnGI9P0Rds SP6Y3U8hmDURQSzhMP0g02gqK737gNAy6yhAHV6IeWNgGr8ri9/AESBHHcAKwpPvr6jD a6uuKiNcrThxk0myZK5rY+TmmHLYH+UmufE9lAu0ipressOE6UwwTiQtapfXb198mAnG RmmwtAEUC7xIZU8QhafxipHk6/dm+8ChK7R7L5ViLOTzblNdeVcR69DWFN6g6/TnOodA 0yhw== 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=DHL3Zcwss0piFlDFYYhvTKui+H42kSvp+qfuGFaFUFo=; b=VgOI3ZoxVzViUplwdlbw0TdhHgi+kftnffgsAx8xjwNP2wxP3xu1My/SRuQPX/Fh+s V/rXcz55+9HzXrgZNJ51G8051YCGsMbycuC9SjlPN8+brJq+6dnYq5ytF+1hOSEMXhZt QhhOnpfjiSnSCyRdV1il3keBNsMISRNpQhG1NsjzA84ValVyXIBt85i1RXxHWw2iVQNk OWUjmS15+/Hbadmqt9I/83F/5InntincEG7Wv0151oumzJq+ZPmdkWi8EfF2oFLHAALl clcP9k2DROET55xW69FcXfSDaAVwoeThfd7gTD4Phb4ks/T4G9VHienEA4wmmQcZh//n Jvwg== X-Gm-Message-State: AOUpUlGzNeRMU6G6naOP47AAhLnUxytQO+DfrNdoPwH/Ar03sQNuiUU0 J73H4lNminxTxrhHzDnbBJbrNlk1foY= X-Google-Smtp-Source: AA+uWPyf99tMiMVuW0SZV0dJATBQcHu9TWp341GKTSlhDJm4KgOLyDqh5HrrE4fLpe/LchWAAD2cuA== X-Received: by 2002:a0c:b65a:: with SMTP id q26-v6mr51653409qvf.43.1534948859220; Wed, 22 Aug 2018 07:40:59 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id 62-v6sm1217660qkx.66.2018.08.22.07.40.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 07:40:58 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Wed, 22 Aug 2018 10:40:38 -0400 Message-Id: <20180822144039.5796-3-pavel.zbitskiy@gmail.com> In-Reply-To: <20180822144039.5796-1-pavel.zbitskiy@gmail.com> References: <20180822144039.5796-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v4 2/3] target/s390x: exception on non-aligned LPSW(E) 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Both LPSW and LPSWE should raise a specification exception when their operand is not doubleword aligned. This could've been done without a helper, but this would introduce a new basic block, which would require making o->in2 local. This could've also been done in load_psw helper, but this is too late - specification exception should be recognized before memory accesses take place. Signed-off-by: Pavel Zbitskiy --- target/s390x/helper.h | 1 + target/s390x/mem_helper.c | 19 ++++++++++++------- target/s390x/translate.c | 8 ++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 97c60ca7bc..b0df3267e5 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -120,6 +120,7 @@ DEF_HELPER_4(cu41, i32, env, i32, i32, i32) DEF_HELPER_4(cu42, i32, env, i32, i32, i32) DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32) DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env) +DEF_HELPER_FLAGS_3(check_alignment, TCG_CALL_NO_RWG, void, env, i64, i32) #ifndef CONFIG_USER_ONLY DEF_HELPER_3(servc, i32, env, i64, i64) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index bacae4f503..75ca1997ad 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -81,13 +81,18 @@ static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr) /* Trigger a SPECIFICATION exception if an address or a length is not naturally aligned. */ static inline void check_alignment(CPUS390XState *env, uint64_t v, - int wordsize, uintptr_t ra) + uint32_t wordsize, int ilen, uintptr_t ra) { if (v % wordsize) { - s390_program_interrupt(env, PGM_SPECIFICATION, 6, ra); + s390_program_interrupt(env, PGM_SPECIFICATION, ilen, ra); } } +void HELPER(check_alignment)(CPUS390XState *env, uint64_t v, uint32_t wordsize) +{ + check_alignment(env, v, wordsize, ILEN_AUTO, GETPC()); +} + /* Load a value from memory according to its size. */ static inline uint64_t cpu_ldusize_data_ra(CPUS390XState *env, uint64_t addr, int wordsize, uintptr_t ra) @@ -847,7 +852,7 @@ static inline uint32_t do_clcl(CPUS390XState *env, uint64_t len = MAX(*src1len, *src3len); uint32_t cc = 0; - check_alignment(env, *src1len | *src3len, wordsize, ra); + check_alignment(env, *src1len | *src3len, wordsize, 6, ra); if (!len) { return cc; @@ -1348,7 +1353,7 @@ uint32_t HELPER(trXX)(CPUS390XState *env, uint32_t r1, uint32_t r2, tbl &= -8; } - check_alignment(env, len, ssize, ra); + check_alignment(env, len, ssize, 6, ra); /* Lest we fail to service interrupts in a timely manner, */ /* limit the amount of work we're willing to do. */ @@ -1400,7 +1405,7 @@ static void do_cdsg(CPUS390XState *env, uint64_t addr, } else { uint64_t oldh, oldl; - check_alignment(env, addr, 16, ra); + check_alignment(env, addr, 16, 6, ra); oldh = cpu_ldq_data_ra(env, addr + 0, ra); oldl = cpu_ldq_data_ra(env, addr + 8, ra); @@ -2116,7 +2121,7 @@ static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) lo = int128_getlo(v); #endif } else { - check_alignment(env, addr, 16, ra); + check_alignment(env, addr, 16, 6, ra); hi = cpu_ldq_data_ra(env, addr + 0, ra); lo = cpu_ldq_data_ra(env, addr + 8, ra); @@ -2153,7 +2158,7 @@ static void do_stpq(CPUS390XState *env, uint64_t addr, helper_atomic_sto_be_mmu(env, addr, v, oi, ra); #endif } else { - check_alignment(env, addr, 16, ra); + check_alignment(env, addr, 16, 6, ra); cpu_stq_data_ra(env, addr + 0, high, ra); cpu_stq_data_ra(env, addr + 8, low, ra); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 7363aabf3a..4161bd0b1f 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2828,9 +2828,13 @@ static DisasJumpType op_lpp(DisasContext *s, DisasOps *o) static DisasJumpType op_lpsw(DisasContext *s, DisasOps *o) { + TCGv_i32 t0; TCGv_i64 t1, t2; check_privileged(s); + t0 = tcg_const_i32(8); + gen_helper_check_alignment(cpu_env, o->in2, t0); + tcg_temp_free_i32(t0); per_breaking_event(s); t1 = tcg_temp_new_i64(); @@ -2848,9 +2852,13 @@ static DisasJumpType op_lpsw(DisasContext *s, DisasOps *o) static DisasJumpType op_lpswe(DisasContext *s, DisasOps *o) { + TCGv_i32 t0; TCGv_i64 t1, t2; check_privileged(s); + t0 = tcg_const_i32(8); + gen_helper_check_alignment(cpu_env, o->in2, t0); + tcg_temp_free_i32(t0); per_breaking_event(s); t1 = tcg_temp_new_i64(); From patchwork Wed Aug 22 14:40:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Zbitskiy X-Patchwork-Id: 960995 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="tdU+VAAl"; 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 41wVfs4R9yz9s47 for ; Thu, 23 Aug 2018 00:44:05 +1000 (AEST) Received: from localhost ([::1]:59383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsUMd-0008BV-A0 for incoming@patchwork.ozlabs.org; Wed, 22 Aug 2018 10:44:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsUJn-0005XR-14 for qemu-devel@nongnu.org; Wed, 22 Aug 2018 10:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsUJl-0000EU-AG for qemu-devel@nongnu.org; Wed, 22 Aug 2018 10:41:06 -0400 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:40613) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsUJi-0000Bc-PO; Wed, 22 Aug 2018 10:41:03 -0400 Received: by mail-qk0-x232.google.com with SMTP id c126-v6so1342359qkd.7; Wed, 22 Aug 2018 07:41:01 -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=n4o66lilJW9Nu3Mai/5OTz9YCD0fBEl0uUjN4dnUJsA=; b=tdU+VAAlzc3Fm+z0kYbPelvpw7liRFGl9pPMGuK7o0Jmg5TMMOuISV0Q9GK97a26ja mANN+u0HOAK8frU5rINlCWxnp4SK6YpvBdHrcWK2IbdsDi0IZ7KHLHcHY8TU5jUbqtpI wqEAeWeZYfAoVx4BFiiczRFrELioHNQ7FAP1zJVhATEBk1yhI8xhQOacRBYIFhC9WWSe 1D6DHoKRGDGnDRBn3rlLkj3HgQafH3S6JOdLLJMtPILU5mAEVh3TbiFjIlQineRb1ogC vR1IbtgsyNegmibR9rMD6Z4himGSTGG9MulVNQTh+ktZfsYtTjRKbXx5drUqnJOG4mJl nhAA== 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=n4o66lilJW9Nu3Mai/5OTz9YCD0fBEl0uUjN4dnUJsA=; b=BQB9PQ2VSaEshclmkVJEGT0kmZpK2rKtohpxKuyiSfkAnivmtoSaawze8Jx77tn8rD BdujZq9cxkcfMArkxUzAYP2isPUgqFf4UdYAY4IUmvPN2D30PLIeHvpBj+d495Y7uwAR vGwMAoTMcQHc4SjiEPOjYALb+f3ZDPYBwtzxks1b0eJn5XH2dcO4F9AlCtk1QbRUZ32c 3iTPqZQQO/5GJSroEBED+GI8XxP64aZc+5fhz0MCZ5JlMytWOgb5qro2UcN3Yyy5axKl FMsU+ENWCtPUHql1ONOB8xtaVWYE6Y2i/Of1+hLOtW1rdaglzX+QH4H9KTypsztpws5k yfyg== X-Gm-Message-State: APzg51BdWp54eygci7ibKCrRvhND8dgUBsmLpQkTIAGwG7hiWe3neHyG HrIz8deqKS2s4RMbLtw8eP9fvyKzvRI= X-Google-Smtp-Source: ANB0VdaSPQ9qQBkalkVJEcxJj5+XNEeNdDwKCTO7OUJJ9fhoHwTOOMvkKB6eZkZX0W9MASr53BnZkg== X-Received: by 2002:a37:c5d4:: with SMTP id k81-v6mr13428014qkl.66.1534948861076; Wed, 22 Aug 2018 07:41:01 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com (inet-64-112-177-9.bos.netblazr.com. [64.112.177.9]) by smtp.gmail.com with ESMTPSA id 62-v6sm1217660qkx.66.2018.08.22.07.41.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 07:41:00 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Wed, 22 Aug 2018 10:40:39 -0400 Message-Id: <20180822144039.5796-4-pavel.zbitskiy@gmail.com> In-Reply-To: <20180822144039.5796-1-pavel.zbitskiy@gmail.com> References: <20180822144039.5796-1-pavel.zbitskiy@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::232 Subject: [Qemu-devel] [PATCH v4 3/3] target/s390x: implement CVB, CVBY and CVBG 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: Pavel Zbitskiy , david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, Alexander Graf , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Convert to Binary - counterparts of the already implemented Convert to Decimal (CVD*) instructions. Example from the Principles of Operation: 25594C becomes 63FA. Signed-off-by: Pavel Zbitskiy --- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 +++ target/s390x/int_helper.c | 52 +++++++++++++++++++++++++++++++++ target/s390x/translate.c | 11 +++++++ tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvb.c | 18 ++++++++++++ 6 files changed, 87 insertions(+) create mode 100644 tests/tcg/s390x/cvb.c diff --git a/target/s390x/helper.h b/target/s390x/helper.h index b0df3267e5..2a9e9240df 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -88,6 +88,7 @@ DEF_HELPER_FLAGS_4(tcxb, TCG_CALL_NO_RWG_SE, i32, env, i64, i64, i64) DEF_HELPER_FLAGS_2(sqeb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(sqdb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_3(sqxb, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(cvb, TCG_CALL_NO_WG, i64, env, i64, i32) DEF_HELPER_FLAGS_1(cvd, TCG_CALL_NO_RWG_SE, i64, s32) DEF_HELPER_FLAGS_4(pack, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(pka, TCG_CALL_NO_WG, void, env, i64, i64, i32) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 9c7b434fca..0911180ca6 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -284,6 +284,10 @@ D(0xec73, CLFIT, RIE_a, GIE, r1_32u, i2_32u, 0, 0, ct, 0, 1) D(0xec71, CLGIT, RIE_a, GIE, r1_o, i2_32u, 0, 0, ct, 0, 1) +/* CONVERT TO BINARY */ + C(0x4f00, CVB, RX_a, Z, la2, 0, new, r1_32, cvb, 0) + C(0xe306, CVBY, RXY_a, LD, la2, 0, new, r1_32, cvb, 0) + C(0xe30e, CVBG, RXY_a, Z, la2, 0, r1, 0, cvb, 0) /* CONVERT TO DECIMAL */ C(0x4e00, CVD, RX_a, Z, r1_o, a2, 0, 0, cvd, 0) C(0xe326, CVDY, RXY_a, LD, r1_o, a2, 0, 0, cvd, 0) diff --git a/target/s390x/int_helper.c b/target/s390x/int_helper.c index abf77a94e6..3b12c11cee 100644 --- a/target/s390x/int_helper.c +++ b/target/s390x/int_helper.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" +#include "exec/cpu_ldst.h" /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER @@ -118,6 +119,57 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al, return ret; } +static void general_operand_exception(CPUS390XState *env, uintptr_t ra) +{ +#ifndef CONFIG_USER_ONLY + LowCore *lowcore; + + lowcore = cpu_map_lowcore(env); + lowcore->data_exc_code = 0; + cpu_unmap_lowcore(lowcore); +#endif + s390_program_interrupt(env, PGM_DATA, ILEN_AUTO, ra); +} + +uint64_t HELPER(cvb)(CPUS390XState *env, uint64_t src, uint32_t n) +{ + int i, j; + uint64_t tmpsrc; + const uintptr_t ra = GETPC(); + int64_t dec, sign = 0, digit, val = 0, pow10 = 0; + + for (i = 0; i < n; i++) { + tmpsrc = wrap_address(env, src + (n - i - 1) * 8); + dec = cpu_ldq_data_ra(env, tmpsrc, ra); + for (j = 0; j < 16; j++, dec >>= 4) { + if (i == 0 && j == 0) { + sign = dec & 0xf; + if (sign < 0xa) { + general_operand_exception(env, ra); + } + continue; + } + digit = dec & 0xf; + if (digit > 0x9) { + general_operand_exception(env, ra); + } + if (i == 0 && j == 1) { + if (sign == 0xb || sign == 0xd) { + val = -digit; + pow10 = -10; + } else { + val = digit; + pow10 = 10; + } + } else { + val += digit * pow10; + pow10 *= 10; + } + } + } + return val; +} + uint64_t HELPER(cvd)(int32_t reg) { /* positive 0 */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 4161bd0b1f..ff36dbe362 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2114,6 +2114,17 @@ static DisasJumpType op_csp(DisasContext *s, DisasOps *o) } #endif +static DisasJumpType op_cvb(DisasContext *s, DisasOps *o) +{ + bool g = (s->fields->op == 0xE3) && (s->fields->op2 == 0x0E); + int32_t n = g ? 2 /* CVBG */ : 1 /* CVB, CVBY */; + TCGv_i32 tmp = tcg_const_i32(n); + + gen_helper_cvb(o->out, cpu_env, o->addr1, tmp); + tcg_temp_free_i32(tmp); + return DISAS_NEXT; +} + static DisasJumpType op_cvd(DisasContext *s, DisasOps *o) { TCGv_i64 t1 = tcg_temp_new_i64(); diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 151dc075aa..990dfb26ff 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -6,3 +6,4 @@ TESTS+=ipm TESTS+=exrl-trt TESTS+=exrl-trtr TESTS+=pack +TESTS+=cvb diff --git a/tests/tcg/s390x/cvb.c b/tests/tcg/s390x/cvb.c new file mode 100644 index 0000000000..3a72e132aa --- /dev/null +++ b/tests/tcg/s390x/cvb.c @@ -0,0 +1,18 @@ +#include +#include + +int main(void) +{ + uint64_t data = 0x000000000025594cull; + uint64_t result = 0; + + asm volatile( + " cvb %[result],%[data]\n" + : [result] "+r" (result) + : [data] "m" (data)); + if (result != 0x63fa) { + write(1, "bad result\n", 11); + return 1; + } + return 0; +}