From patchwork Fri Aug 10 03:01:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Zbitskiy X-Patchwork-Id: 955923 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="MIqsfocI"; 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 41mqlj3NcPz9s2P for ; Fri, 10 Aug 2018 13:06:41 +1000 (AEST) Received: from localhost ([::1]:54012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxl8-0000qt-Vy for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2018 23:06:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnxiL-00064e-QS for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnxiK-0003zE-QZ for qemu-devel@nongnu.org; Thu, 09 Aug 2018 23:03:45 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:35786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnxiK-0003xP-Ld; Thu, 09 Aug 2018 23:03:44 -0400 Received: by mail-qk0-x244.google.com with SMTP id u21-v6so5521782qku.2; Thu, 09 Aug 2018 20:03:44 -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=F03cFq8cikBW6PLTuESXSPCnXy9C7RX3u1qiuPP0f6s=; b=MIqsfocIVkE9wDLcjLLc6wAXfjnO0Tx2FTvORwLs9GrKrH58VlrwAnU5P+yZInHunZ uzTei79n9F79jUKmSWMUH14+HEgWl+sDuNvmjudXsWdX/HIayuBmGZPRTUPdwFSAcBHt WSYVMSuFMiDZEcCY9EsnWvHCVh/zH/c/826YDwmHE6jiFrofIBnp/cldQ3wX+1hjyBqG 4zquQTulHqx7aUtur6zvPD4+ZBZfk8cc+M0ui+uaND/MdDBUlDQkfzg+M5JWoQmx2IeH SdOG0CqoTpOMrrPJNz83K0N5dRcWJolX6/WuvhU2UEKkFJ8UbWPg9MLzGQ2WfBXVz1+K N23A== 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=F03cFq8cikBW6PLTuESXSPCnXy9C7RX3u1qiuPP0f6s=; b=MXTSLyUBrU7XMaCKK3qwD2WiD5Q0u8I5tJVgDSCHImughvjk9zYsu/VXDQamG914hF V4Yb4vny0nds3YdwsOCVZemulpvutN/S6L1pkVW8WSTnJ4hpu5bF5o2L5lQYUJWHZVAH R7j4loTCKVy6nFubNcnEW4eC6PBoAPOkZExGzE0xW6OlNZ3fRdBuz7V4GJ8vGi6iqlnR k59Q7rurx+uVgGr74jgHnZjO55hCyyJzU8vZS0OV8FdiW7yR9IhVMd0moF+/8cWCuqQK 4I5mBz6L79if1PhHgTHzP94SBEfm1HONJUlg/jY86Vg2B6DFWceqoFEoMR2ORrjmQgN7 JgBQ== X-Gm-Message-State: AOUpUlGrUr6Rmfjij2Z6TsnteGZVhM5qL9eTz41XTQvAA/s83Dp168Gu Na4g3EfmJLRdERLEpDloR1dq3rpaidk= X-Google-Smtp-Source: AA+uWPxDrplb35uaubhPYxWhx/DAZ+0ue3I9mGxShdHUD/EACp90QMMf3oN5aMI7aYJ6ddYO0jy4Mw== X-Received: by 2002:a37:c887:: with SMTP id t7-v6mr4330116qkl.300.1533870223746; Thu, 09 Aug 2018 20:03:43 -0700 (PDT) Received: from WAL-L-PZ01.rocketsoftware.com ([2620:117:0:a::c]) by smtp.gmail.com with ESMTPSA id i1-v6sm4457425qtj.65.2018.08.09.20.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:03:43 -0700 (PDT) From: Pavel Zbitskiy To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 23:01:35 -0400 Message-Id: <20180810030139.25916-4-pavel.zbitskiy@gmail.com> In-Reply-To: <20180810030139.25916-1-pavel.zbitskiy@gmail.com> References: <20180810030139.25916-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::244 Subject: [Qemu-devel] [PATCH 3/7] target/s390x: fix CSST decoding and runtime alignment check 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" CSST is defined as: C(0xc802, CSST, SSF, CASS, la1, a2, 0, 0, csst, 0) It means that the first parameter is handled by in1_la1(). in1_la1() fills addr1 field, and not in1. Furthermore, when extract32() is used for the alignment check, the third parameter should specify the number of trailing bits that must be 0. For FC these numbers are: FC=0 (word, 4 bytes): 2 FC=1 (double word, 8 bytes): 3 FC=2 (quad word, 16 bytes): 4 For SC these numbers correspond to the size: SC=0: 0 SC=1: 1 SC=2: 2 SC=3: 3 SC=4: 4 Signed-off-by: Pavel Zbitskiy Reviewed-by: David Hildenbrand --- target/s390x/mem_helper.c | 2 +- target/s390x/translate.c | 4 +-- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/csst.c | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/s390x/csst.c diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index e21a47fb4d..c94dbf3fcb 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1442,7 +1442,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, } /* Sanity check the alignments. */ - if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { + if (extract32(a1, 0, fc + 2) || extract32(a2, 0, sc)) { goto spec_exception; } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 316ff79250..d0d2c3412f 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2051,9 +2051,9 @@ static DisasJumpType op_csst(DisasContext *s, DisasOps *o) TCGv_i32 t_r3 = tcg_const_i32(r3); if (tb_cflags(s->base.tb) & CF_PARALLEL) { - gen_helper_csst_parallel(cc_op, cpu_env, t_r3, o->in1, o->in2); + gen_helper_csst_parallel(cc_op, cpu_env, t_r3, o->addr1, o->in2); } else { - gen_helper_csst(cc_op, cpu_env, t_r3, o->in1, o->in2); + gen_helper_csst(cc_op, cpu_env, t_r3, o->addr1, o->in2); } tcg_temp_free_i32(t_r3); diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 9f4076901f..f62f950d8e 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -1,3 +1,4 @@ VPATH+=$(SRC_PATH)/tests/tcg/s390x CFLAGS+=-march=zEC12 -m64 TESTS+=hello-s390x +TESTS+=csst diff --git a/tests/tcg/s390x/csst.c b/tests/tcg/s390x/csst.c new file mode 100644 index 0000000000..1dae9071fb --- /dev/null +++ b/tests/tcg/s390x/csst.c @@ -0,0 +1,43 @@ +#include +#include + +int main(void) +{ + uint64_t parmlist[] = { + 0xfedcba9876543210ull, + 0, + 0x7777777777777777ull, + 0, + }; + uint64_t op1 = 0x0123456789abcdefull; + uint64_t op2 = 0; + uint64_t op3 = op1; + uint64_t cc; + + asm volatile( + " lghi %%r0,%[flags]\n" + " la %%r1,%[parmlist]\n" + " csst %[op1],%[op2],%[op3]\n" + " ipm %[cc]\n" + : [op1] "+m" (op1), + [op2] "+m" (op2), + [op3] "+r" (op3), + [cc] "=r" (cc) + : [flags] "K" (0x0301), + [parmlist] "m" (parmlist) + : "r0", "r1", "cc", "memory"); + cc = (cc >> 28) & 3; + if (cc) { + write(1, "bad cc\n", 7); + return 1; + } + if (op1 != parmlist[0]) { + write(1, "bad op1\n", 8); + return 1; + } + if (op2 != parmlist[2]) { + write(1, "bad op2\n", 8); + return 1; + } + return 0; +}