From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226196; cv=none; d=zoho.com; s=zohoarc; b=jSmkwxVNeKUgr0aXhkj0vpN0THXudZjTexNkgmMFOxD6+FiGLPaLVzAEoHnJPsmXF3VKmbMiLJ/JUi+IhseVnOGVOMYeVJ7kQq+Rbq575UU9AxmhXxyGoFz08lmBXmozh65PBYwCay4jlVrFdxDdi2fYdeOyxZzop6SmOy744og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226196; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9WFGLjaUgnGtsGiAsj0XdT2wV99CQBjwNF4p4XNU2hc=; b=XAdoGBSKZaI8Y4Ev4Z1RbxrKbONSpXK1bE29I0p/MamK5GtwDBPRzilSdoNiiF2MQIj8Zyym2lVrvOn4dkGhhsfTV2CzvfgXupjQ/B5vcHABrfGJI3D8StUnI/elVQNARNSQHcsR7srGnkVgpQSGYFLr+xMILCWtnOCeOPJuav0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226196701156.51604223503114; Mon, 23 Sep 2019 01:09:56 -0700 (PDT) Received: from localhost ([::1]:53406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJPv-0003T4-LT for importer@patchew.org; Mon, 23 Sep 2019 04:09:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNQ-0001TG-RP for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNP-0003uY-RV for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43522) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNP-0003uF-Jf; Mon, 23 Sep 2019 04:07:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3327307D8BE; Mon, 23 Sep 2019 08:07:18 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 401CB19C78; Mon, 23 Sep 2019 08:07:17 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 01/30] s390x/tcg: Reset exception_index to -1 instead of 0 Date: Mon, 23 Sep 2019 10:06:43 +0200 Message-Id: <20190923080712.23951-2-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 23 Sep 2019 08:07:18 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We use the marker "-1" for "no exception". s390_cpu_do_interrupt() might get confused by that. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 29fcce426e..39ee9b3175 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1747,7 +1747,7 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a= 1, uint64_t a2) =20 if (env->int_pgm_code =3D=3D PGM_PROTECTION) { /* retry if reading is possible */ - cs->exception_index =3D 0; + cs->exception_index =3D -1; if (!s390_cpu_virt_mem_check_read(cpu, a1, 0, 1)) { /* Fetching permitted; storing not permitted */ return 1; @@ -1757,7 +1757,7 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a= 1, uint64_t a2) switch (env->int_pgm_code) { case PGM_PROTECTION: /* Fetching not permitted; storing not permitted */ - cs->exception_index =3D 0; + cs->exception_index =3D -1; return 2; case PGM_ADDRESSING: case PGM_TRANS_SPEC: @@ -1767,7 +1767,7 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a= 1, uint64_t a2) } =20 /* Translation not available */ - cs->exception_index =3D 0; + cs->exception_index =3D -1; return 3; } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226520; cv=none; d=zoho.com; s=zohoarc; b=TtYNUktHF6gVkl0KW04qJpcJn7Vpy4axiISc1uQzUFlKuldrNm7a76oxZIJZxy760PQquc9T6PPt2REyd/HJcHHpqYX48yHVZFc4FzoP/oePi92US+ie1ViTTepRjjroxEQZCjdmPyTFpKAn/1gHS+r4/A1UlaRI4huaJRsmnxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226520; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PgBP7K/RQw2WKgTnFtSs3LLLtu45PUfnmJP74rJAAmY=; b=avXWu+tIvsIpg3j+uXNzYwviw60fGSfyDTPPmJSiarGFNZX+++rzIisXX5pUZaI0KgV4mgbLrd/OT7Mit/ZPTxpSEiMj+tAT2R9hM3om+6RDMc9v2SB7A/X5lcjb18DKIRUHbjeQ+Jzth34L2A+VWO43U6bKNKRHjAW+oB6MOTU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226520273568.835828221602; Mon, 23 Sep 2019 01:15:20 -0700 (PDT) Received: from localhost ([::1]:53444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJV8-0000Nl-7s for importer@patchew.org; Mon, 23 Sep 2019 04:15:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNS-0001Ut-Qy for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNR-0003vH-OK for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNR-0003uz-JC; Mon, 23 Sep 2019 04:07:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5F7C315C02A; Mon, 23 Sep 2019 08:07:20 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37BFE19C78; Mon, 23 Sep 2019 08:07:19 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 02/30] s390x/tcg: MVCL: Zero out unused bits of address Date: Mon, 23 Sep 2019 10:06:44 +0200 Message-Id: <20190923080712.23951-3-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 23 Sep 2019 08:07:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have to zero out unused bits in 24 and 31-bit addressing mode. Provide a new helper. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 39ee9b3175..b02ad148e5 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -469,6 +469,25 @@ static inline uint64_t get_address(CPUS390XState *env,= int reg) return wrap_address(env, env->regs[reg]); } =20 +/* + * Store the address to the given register, zeroing out unused leftmost + * bits in bit positions 32-63 (24-bit and 31-bit mode only). + */ +static inline void set_address_zero(CPUS390XState *env, int reg, + uint64_t address) +{ + if (env->psw.mask & PSW_MASK_64) { + env->regs[reg] =3D address; + } else { + if (!(env->psw.mask & PSW_MASK_32)) { + address &=3D 0x00ffffff; + } else { + address &=3D 0x7fffffff; + } + env->regs[reg] =3D deposit64(env->regs[reg], 0, 32, address); + } +} + static inline void set_address(CPUS390XState *env, int reg, uint64_t addre= ss) { if (env->psw.mask & PSW_MASK_64) { @@ -772,8 +791,8 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) =20 env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srclen); - set_address(env, r1, dest); - set_address(env, r2, src); + set_address_zero(env, r1, dest); + set_address_zero(env, r2, src); =20 return cc; } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226823; cv=none; d=zoho.com; s=zohoarc; b=WXCLfcPYZ7Rn6jln6H7WkLvrAg0v7uMbBIU3l2rxEeVUC5+BzaTauh/yWIkaxmbLT0uKcqY3WC8anVvUmkRchNl+/qRKg3ZIMPR40ceaDijPhxcnWF3jq3PbiSYWRSz3AEMcgRvX+zNKMPEh3H58/1BiETQDT5M9HUDIwteNJp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226823; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CJQj4LsDFZho4+24S4iIYhD3ecei7Cg6vUJI/TYSgM4=; b=YRGN8Qt+8v3PD7uG1HyrP9jC7E6UiNP+7n10XqOIFT7HS60HlqAjw50f5VecT1Lkz/vXJ/cfz4ROXV3sOwN6o/KBdQZ2GxFDusAxBG3PwLBhNfwO1/1c6TqZOZSJr43yapROfi/YxGsnvw72GFcmXDhsQ4j7TpM8kvgOW9rZSps= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226823039315.44188376868465; Mon, 23 Sep 2019 01:20:23 -0700 (PDT) Received: from localhost ([::1]:53480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJa1-0004Hq-7m for importer@patchew.org; Mon, 23 Sep 2019 04:20:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42603) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNU-0001XA-QH for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNT-0003wE-Kt for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNT-0003w1-Fi; Mon, 23 Sep 2019 04:07:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C938783F40; Mon, 23 Sep 2019 08:07:22 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A11419C78; Mon, 23 Sep 2019 08:07:21 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 03/30] s390x/tcg: MVCL: Detect destructive overlaps Date: Mon, 23 Sep 2019 10:06:45 +0200 Message-Id: <20190923080712.23951-4-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 23 Sep 2019 08:07:22 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We'll have to zero-out unused bit positions, so make sure to write the addresses back. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b02ad148e5..223312a4b1 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -52,6 +52,19 @@ static inline bool psw_key_valid(CPUS390XState *env, uin= t8_t psw_key) return true; } =20 +static bool is_destructive_overlap(CPUS390XState *env, uint64_t dest, + uint64_t src, uint32_t len) +{ + if (!len || src =3D=3D dest) { + return false; + } + /* Take care of wrapping at the end of address space. */ + if (unlikely(wrap_address(env, src + len - 1) < src)) { + return dest > src || dest <=3D wrap_address(env, src + len - 1); + } + return dest > src && dest <=3D src + len - 1; +} + /* Reduce the length so that addr + len doesn't cross a page boundary. */ static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr) { @@ -787,7 +800,11 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1,= uint32_t r2) uint8_t pad =3D env->regs[r2 + 1] >> 24; uint32_t cc; =20 - cc =3D do_mvcl(env, &dest, &destlen, &src, &srclen, pad, 1, ra); + if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { + cc =3D 3; + } else { + cc =3D do_mvcl(env, &dest, &destlen, &src, &srclen, pad, 1, ra); + } =20 env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srclen); --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226488; cv=none; d=zoho.com; s=zohoarc; b=B20ap9gCd71XPE40aX2W2sT0nE7DYe+OvknQqRO8u0p7OdbwQWaGd/yL+J7EJMUWYV4CYfdW8dbymjAV9MgXkEFXo6sqzbCHHkr4nhqmgcr4fF87xxQfC1jbwKi3CiamN4/uohNFiTNquk9dpYSkAAPiUd0yO29rHNyTw1eujio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226488; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8mCugWdYoSLThXhLcrTT9eRn+ab2/7dWsEP8VIR8atE=; b=WxehnUA6jE02xN8kVxnhacEItwMqY2/UayZpS2XnZpFq28TqNi8hNALrrAFAjx64tGBmZnBJd0UWlRALzGKiuecxdVEPIL365Lx+ydsoWalJET+YAQUKhZcJgByT6qFFTvvkVXj+4wFlpsIkb7PwghRErie4Db7+qdLjikUHkT4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226488458334.8918342261485; Mon, 23 Sep 2019 01:14:48 -0700 (PDT) Received: from localhost ([::1]:53442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJUc-0008CQ-LP for importer@patchew.org; Mon, 23 Sep 2019 04:14:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42627) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNX-0001c9-0i for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNV-0003y5-O2 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNV-0003x9-G7; Mon, 23 Sep 2019 04:07:25 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1C5D308FF32; Mon, 23 Sep 2019 08:07:24 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ED1219C78; Mon, 23 Sep 2019 08:07:22 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 04/30] s390x/tcg: MVCL: Process max 4k bytes at a time Date: Mon, 23 Sep 2019 10:06:46 +0200 Message-Id: <20190923080712.23951-5-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 23 Sep 2019 08:07:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Process max 4k bytes at a time, writing back registers between the accesses. The instruction is interruptible. "For operands longer than 2K bytes, access exceptions are not recognized for locations more than 2K bytes beyond the current location being processed." Note that on z/Architecture, 2k vs. 4k access cannot get differentiated as long as pages are not crossed. This seems to be a leftover from ESA/390. Simply stay within single pages. MVCL handling is quite different than MVCLE/MVCLU handling, so split up the handlers. Defer interrupt handling, as that will require more thought, add a TODO for that. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 44 +++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 223312a4b1..58ab2e48e3 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -798,19 +798,51 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1= , uint32_t r2) uint64_t srclen =3D env->regs[r2 + 1] & 0xffffff; uint64_t src =3D get_address(env, r2); uint8_t pad =3D env->regs[r2 + 1] >> 24; - uint32_t cc; + uint32_t cc, cur_len; =20 if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { cc =3D 3; + } else if (srclen =3D=3D destlen) { + cc =3D 0; + } else if (destlen < srclen) { + cc =3D 1; } else { - cc =3D do_mvcl(env, &dest, &destlen, &src, &srclen, pad, 1, ra); + cc =3D 2; } =20 - env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); - env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srclen); - set_address_zero(env, r1, dest); - set_address_zero(env, r2, src); + /* We might have to zero-out some bits even if there was no action. */ + if (unlikely(!destlen || cc =3D=3D 3)) { + set_address_zero(env, r2, src); + set_address_zero(env, r1, dest); + return cc; + } else if (!srclen) { + set_address_zero(env, r2, src); + } =20 + /* + * Only perform one type of type of operation (move/pad) in one step. + * Stay within single pages. + */ + while (destlen) { + cur_len =3D MIN(destlen, -(dest | TARGET_PAGE_MASK)); + if (!srclen) { + fast_memset(env, dest, pad, cur_len, ra); + } else { + cur_len =3D MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_le= n); + + fast_memmove(env, dest, src, cur_len, ra); + src =3D wrap_address(env, src + cur_len); + srclen -=3D cur_len; + env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srcl= en); + set_address_zero(env, r2, src); + } + dest =3D wrap_address(env, dest + cur_len); + destlen -=3D cur_len; + env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); + set_address_zero(env, r1, dest); + + /* TODO: Deliver interrupts. */ + } return cc; } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226211; cv=none; d=zoho.com; s=zohoarc; b=XLUCv1GB0B/VhLI5Z9amXm6oCgmed4v5T2t4B5Hi5o3cjkF82cE9UzKTh3U2GTQRh8AwAc/HyKnyQfgkLjravK71YfwggvsRtavphBirUjhvxCnkEl/rZMFeFmh5Kur9fCdHW935qVrxE95L9PPGAI+AajsCg7uBWiyLbiN3AFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226211; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Av0Dq9BYaqcD+LLNtTXDkCb04cn2AKYdyJxoE+r7pYs=; b=FNY63cRW7G5ylvFcY6McY64nENAP/bdkmTgohjWo+uDSGftIS0b3UMg4c3MFdWrxbnVCcX4F2ctUBw+f45dtCoxN0ZiQ4WXfsrO6dtvIS/iAlmOB3RY1FbmnjXxPKGqGkEjEPPETFuirGjxO93eziY6HgSiAY5t+ZHSWEMUHuL8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226211838282.07199985035106; Mon, 23 Sep 2019 01:10:11 -0700 (PDT) Received: from localhost ([::1]:53408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJQA-0003gh-Cz for importer@patchew.org; Mon, 23 Sep 2019 04:10:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42647) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNZ-0001ei-NZ for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNX-0003yy-Ig for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNX-0003yk-DZ; Mon, 23 Sep 2019 04:07:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B40C510F2E82; Mon, 23 Sep 2019 08:07:26 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1322F19C78; Mon, 23 Sep 2019 08:07:24 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 05/30] s390x/tcg: MVC: Increment the length once Date: Mon, 23 Sep 2019 10:06:47 +0200 Message-Id: <20190923080712.23951-6-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Mon, 23 Sep 2019 08:07:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's increment the length once. While at it, cleanup the comment. The memset() example is given as a programming note in the PoP, so drop the description. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 58ab2e48e3..013e8d6045 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -320,16 +320,20 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uin= t32_t l, uint64_t dest, HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - /* mvc and memmove do not behave the same when areas overlap! */ - /* mvc with source pointing to the byte after the destination is the - same as memset with the first source byte */ + /* MVC always copies one more byte than specified - maximum is 256 */ + l++; + + /* + * "When the operands overlap, the result is obtained as if the operan= ds + * were processed one byte at a time". Only non-destructive overlaps + * behave like memmove(). + */ if (dest =3D=3D src + 1) { - fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l + 1, ra); - } else if (dest < src || src + l < dest) { - fast_memmove(env, dest, src, l + 1, ra); + fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); + } else if (dest < src || src + l <=3D dest) { + fast_memmove(env, dest, src, l, ra); } else { - /* slow version with byte accesses which always work */ - for (i =3D 0; i <=3D l; i++) { + for (i =3D 0; i < l; i++) { uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); cpu_stb_data_ra(env, dest + i, x, ra); } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226224; cv=none; d=zoho.com; s=zohoarc; b=hfX/d6WDWYBc0UQyi+xqyVbLG6dGSXV5h5d4kLlNZWfI9mYYDodQl/g/2ao5TuNOS0ODxR3X3yNFu6KoZ6w1x2IurkP98WrefoaNGOj4uU4NNYy07XA6VKh/7DhXmwnb0i4SRuZ14+00qFEgR6aZocKFbdPWTJqV51CsKHZwHZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226224; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3vbtQ/lB62vbeTp8UpH/tHmVVZImEv2SZ9fmQDRT3ME=; b=INCMYCO1+zMwd9RBeeoF8DP7w63m97SvfyOF+Vy6JsnHwAFD63fbkQgBfLh9HgA0vg+DgyDfxoaKlsg8KNglokn/J6D7Z1iphkBFbvogNgbubKDF+136/Ixx6LUdedByVSKumUrkT+2f+6yMsgfXy9tczsmOU+gPdyNq7mS8ZYQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226224106291.6487745407113; Mon, 23 Sep 2019 01:10:24 -0700 (PDT) Received: from localhost ([::1]:53410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJQM-0003m4-JG for importer@patchew.org; Mon, 23 Sep 2019 04:10:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42660) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNa-0001fp-IF for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNZ-0003zb-Ht for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48662) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNZ-0003zG-Ce; Mon, 23 Sep 2019 04:07:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A941A3B71F; Mon, 23 Sep 2019 08:07:28 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 073FF19C78; Mon, 23 Sep 2019 08:07:26 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 06/30] s390x/tcg: MVC: Use is_destructive_overlap() Date: Mon, 23 Sep 2019 10:06:48 +0200 Message-Id: <20190923080712.23951-7-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 23 Sep 2019 08:07:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's use the new helper, that also detects destructive overlaps when wrapping. We'll make the remaining code (e.g., fast_memmove()) aware of wrapping later. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 013e8d6045..c31cf49593 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -330,7 +330,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, */ if (dest =3D=3D src + 1) { fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); - } else if (dest < src || src + l <=3D dest) { + } else if (!is_destructive_overlap(env, dest, src, l)) { fast_memmove(env, dest, src, l, ra); } else { for (i =3D 0; i < l; i++) { --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226469; cv=none; d=zoho.com; s=zohoarc; b=He09ND2WRn/nqufhaYI7sYRczFFffXdn4+fe3cdyJg6PTsMXCZRedlGSAebtuisbWBj+fVvs4RGQIltVbwuN/IIlwbchPje1olm7wojidDnrP/NfSTJWXn2A/KQhYSI1AIDRQ/wBRJUTClJX+WtqzNoQp/xeO3yLG2vnvmvwIac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226469; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GJ7szFietHKW/p9EIhgvaGaLDjVUCVRufBOpfdpg66w=; b=SjIyDHwqvkcQE1NypUmjbaU+M0g10zODGw/yqXeP3UIG9DU28IZTG0zNg3yhf4vnSaxWV6v/1eW0mZBc7kc0TUx1bWXRPi06pvzcGYmgbzf6ti8XjIIfAdkTUQ3O6sii7Yd0ycqF29bSILHjkc6C28Uz1pvOT9Ul7jdhLWBZFKw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226469184832.5383855614906; Mon, 23 Sep 2019 01:14:29 -0700 (PDT) Received: from localhost ([::1]:53438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJU7-0007cW-31 for importer@patchew.org; Mon, 23 Sep 2019 04:14:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42692) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNc-0001iJ-LD for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNb-00040R-IR for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35322) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNb-000407-BY; Mon, 23 Sep 2019 04:07:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DBDC3084031; Mon, 23 Sep 2019 08:07:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0D9819C78; Mon, 23 Sep 2019 08:07:28 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 07/30] s390x/tcg: MVPG: Check for specification exceptions Date: Mon, 23 Sep 2019 10:06:49 +0200 Message-Id: <20190923080712.23951-8-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 23 Sep 2019 08:07:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Perform the checks documented in the PoP. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index c31cf49593..7dfa848744 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -672,6 +672,13 @@ uint64_t HELPER(clst)(CPUS390XState *env, uint64_t c, = uint64_t s1, uint64_t s2) /* move page */ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64= _t r2) { + const bool f =3D extract64(r0, 11, 1); + const bool s =3D extract64(r0, 10, 1); + + if ((f && s) || extract64(r0, 12, 4)) { + s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC()); + } + /* ??? missing r0 handling, which includes access keys, but more importantly optional suppression of the exception! */ fast_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226737; cv=none; d=zoho.com; s=zohoarc; b=UBtJYEx0MR+2eWRcq8Z3Qmn2H4CI+DVF25IlRDnfl+QPrD2Se1ksVETkkpXfubO5XidyGrewN61uwudMORXw6/Kmc97FWjjq/PnyCrpoZmRV2J1d3VcWlQ9SaxPay+jWXA7/0sxpvjGokdrPTfdM9UUIS4utm2xa+a+ToBIqPe0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226737; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4eJVTKFHX9x+VPPIp429Ro5Wu2P++xQJz+haeHTaJr8=; b=HYham0Exz9yEKsLJQvHIQX/cmVXollH5oAyke+Ps6D83PNGNQc12TIGtN2PZa/7+LPqAYw5Lotm4U8Fn0wzUK6G4E/qtd0b3yzEVyagY/wvjPSLxJxLoFfCwVaCfCroVMx6skVlQQ2N4tN+GMCYAA8L5t2V/eoEjmALxBqM1H7A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226737611369.2163706789154; Mon, 23 Sep 2019 01:18:57 -0700 (PDT) Received: from localhost ([::1]:53476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJYb-000379-No for importer@patchew.org; Mon, 23 Sep 2019 04:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42727) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNj-0001qY-Cg for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNi-00042o-Au for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNi-00042c-5h; Mon, 23 Sep 2019 04:07:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71E11308FBA6; Mon, 23 Sep 2019 08:07:37 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id E725F19C78; Mon, 23 Sep 2019 08:07:30 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 08/30] s390x/tcg: MVPG: Properly wrap the addresses Date: Mon, 23 Sep 2019 10:06:50 +0200 Message-Id: <20190923080712.23951-9-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 23 Sep 2019 08:07:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have to mask of any unused bits. While at it, document what exactly is missing. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 7dfa848744..746f647303 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -679,8 +679,15 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0,= uint64_t r1, uint64_t r2) s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC()); } =20 - /* ??? missing r0 handling, which includes access keys, but more - importantly optional suppression of the exception! */ + r1 =3D wrap_address(env, r1 & TARGET_PAGE_MASK); + r2 =3D wrap_address(env, r2 & TARGET_PAGE_MASK); + + /* + * TODO: + * - Access key handling + * - CC-option with surpression of page-translation exceptions + * - Store r1/r2 register identifiers at real location 162 + */ fast_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); return 0; /* data moved */ } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226466; cv=none; d=zoho.com; s=zohoarc; b=f308yacue/i3P75UFywnmRS32P1Zs+e1Z90c1jXrY1CBGj5QFpArVTmgM4Ws80IArw0kJ3s9XHmliMoROg3tSzeUIL7lk5vBNakmEgT5VXctdtVJ7FKXUUpNgToKVF0QcJH80rtqIMIyHBzLJ2b1/dY5wa6SYck74GBmV8VJ7F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226466; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PQcKp6HOn3St9MZkXioQCqVSwAE6SiOG+3lwRjCZpv0=; b=FuBFHYFg1Zc9zG45oNlz45L+Lg72Ogb2F7DRaJLBXXYhiFgbf2H9HQLBsoWfHcdNLKJvzZpf2DlQa22YMo393ndvuIFxU3nNIXbPIPF9ezIC723Z4sa93ENzc5NkghEIWs9MswyM8JWyzC1AOtGRBsaV4eLgehshZiOqeiTWAjQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226466105613.8790126667527; Mon, 23 Sep 2019 01:14:26 -0700 (PDT) Received: from localhost ([::1]:53440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJUB-0007gs-Vx for importer@patchew.org; Mon, 23 Sep 2019 04:14:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42754) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNl-0001t5-PP for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNk-00043k-DO for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNk-00043I-4w; Mon, 23 Sep 2019 04:07:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DDB38342DF; Mon, 23 Sep 2019 08:07:39 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id B799119C78; Mon, 23 Sep 2019 08:07:37 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 09/30] s390x/tcg: MVCLU/MVCLE: Process max 4k bytes at a time Date: Mon, 23 Sep 2019 10:06:51 +0200 Message-Id: <20190923080712.23951-10-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 23 Sep 2019 08:07:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's stay within single pages. ... and indicate cc=3D3 in case there is work remaining. Keep unicode padding simple. While reworking, properly wrap the addresses. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 54 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 746f647303..86238e0163 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -768,8 +768,8 @@ static inline uint32_t do_mvcl(CPUS390XState *env, uint64_t *src, uint64_t *srclen, uint16_t pad, int wordsize, uintptr_t ra) { - uint64_t len =3D MIN(*srclen, *destlen); - uint32_t cc; + int len =3D MIN(*destlen, -(*dest | TARGET_PAGE_MASK)); + int i, cc; =20 if (*destlen =3D=3D *srclen) { cc =3D 0; @@ -779,32 +779,40 @@ static inline uint32_t do_mvcl(CPUS390XState *env, cc =3D 2; } =20 - /* Copy the src array */ - fast_memmove(env, *dest, *src, len, ra); - *src +=3D len; - *srclen -=3D len; - *dest +=3D len; - *destlen -=3D len; + if (!*destlen) { + return cc; + } =20 - /* Pad the remaining area */ - if (wordsize =3D=3D 1) { - fast_memset(env, *dest, pad, *destlen, ra); - *dest +=3D *destlen; - *destlen =3D 0; + /* + * Only perform one type of type of operation (move/pad) at a time. + * Stay within single pages. + */ + if (*srclen) { + /* Copy the src array */ + len =3D MIN(MIN(*srclen, -(*src | TARGET_PAGE_MASK)), len); + *destlen -=3D len; + *srclen -=3D len; + fast_memmove(env, *dest, *src, len, ra); + *src =3D wrap_address(env, *src + len); + *dest =3D wrap_address(env, *dest + len); + } else if (wordsize =3D=3D 1) { + /* Pad the remaining area */ + *destlen -=3D len; + fast_memset(env, *dest, pad, len, ra); + *dest =3D wrap_address(env, *dest + len); } else { - /* If remaining length is odd, pad with odd byte first. */ - if (*destlen & 1) { - cpu_stb_data_ra(env, *dest, pad & 0xff, ra); - *dest +=3D 1; - *destlen -=3D 1; - } - /* The remaining length is even, pad using words. */ - for (; *destlen; *dest +=3D 2, *destlen -=3D 2) { - cpu_stw_data_ra(env, *dest, pad, ra); + /* The remaining length selects the padding byte. */ + for (i =3D 0; i < len; (*destlen)--, i++) { + if (*destlen & 1) { + cpu_stb_data_ra(env, *dest, pad, ra); + } else { + cpu_stb_data_ra(env, *dest, pad >> 8, ra); + } + *dest =3D wrap_address(env, *dest + 1); } } =20 - return cc; + return *destlen ? 3 : cc; } =20 /* move long */ --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227043; cv=none; d=zoho.com; s=zohoarc; b=DN2e37SEvqPfjwsr6TX3DPus+y9NFsVqB8ebSWtuzt8aLFbknu4a10vHJlCYtMlYez13zrpMMDz4BNdAzpGzqAIre6JgkMs1WwRug4Qu55hqH4s/q70KPSEgOfBROsQwAuombGKGbQZ6XtpfCUl5ZNofJj7nKuz+/Ln7B0eEuXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227043; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ta3xDJdf1twB/P0yHinG5Y8t4yBSTsGgY9arihUNrM4=; b=OLe6GEa+QUZOfyL/uO1zs5rAmDi7IHcl//Vxnk73XJiWrqDEBgOBLOOxQyfU/4al0+BGrNKx8Dz7nl0vSptphJ7G6X+INWwWbDlYyUR2TX+ANlMy4jAw6qEGteGWba8Z2LFVe2W3AxIWgFqE09bfwyMIGe6UI83giNh6nMkGQYY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227043208666.5207203530505; Mon, 23 Sep 2019 01:24:03 -0700 (PDT) Received: from localhost ([::1]:53525 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJdZ-0007xV-95 for importer@patchew.org; Mon, 23 Sep 2019 04:24:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42774) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNn-0001vC-Km for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNm-00044d-Cq for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNm-00044L-5y; Mon, 23 Sep 2019 04:07:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66C5D10CC1E1; Mon, 23 Sep 2019 08:07:41 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id B633119C78; Mon, 23 Sep 2019 08:07:39 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 10/30] s390x/tcg: MVCS/MVCP: Check for special operation exceptions Date: Mon, 23 Sep 2019 10:06:52 +0200 Message-Id: <20190923080712.23951-11-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Mon, 23 Sep 2019 08:07:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's perform the documented checks. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 86238e0163..20e1ac0ea9 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1960,12 +1960,18 @@ uint32_t HELPER(rrbe)(CPUS390XState *env, uint64_t = r2) =20 uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { + const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; uintptr_t ra =3D GETPC(); int cc =3D 0, i; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); =20 + if (!(env->psw.mask & PSW_MASK_DAT) || !(env->cregs[0] & CR0_SECONDARY= ) || + psw_as =3D=3D AS_HOME || psw_as =3D=3D AS_ACCREG) { + s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); + } + if (l > 256) { /* max 256 */ l =3D 256; @@ -1983,12 +1989,18 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) =20 uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { + const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; uintptr_t ra =3D GETPC(); int cc =3D 0, i; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); =20 + if (!(env->psw.mask & PSW_MASK_DAT) || !(env->cregs[0] & CR0_SECONDARY= ) || + psw_as =3D=3D AS_HOME || psw_as =3D=3D AS_ACCREG) { + s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); + } + if (l > 256) { /* max 256 */ l =3D 256; --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226734; cv=none; d=zoho.com; s=zohoarc; b=Aj/EXa40OZdcK0nB02xP9FOoRpLUe40O63Zw/hm25Opg1M2mznp4S/eTM6Jk57lO0frz/fuuOzOh3cXXOd8Vb98ZuPZ79cTUMng3ecLZtxQyHU3PYJ4KC2mviCc0QDGnj6GDeQWJI3lM+ufjc6CAOiznZ132Cyy5S322d7cskvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226734; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QYDWtBeDEcq080AUvz+Fe9NHCB4RgHKthwMLQO93XW0=; b=X091NTxl5DjwH1T1jQObLGJ86nU+N9/jnqzDq0sRGPh6nmW19c5fqbxJhO6Nv1EA6Swiq6pCmP3qU0xn/7fEw64IMuiPMXiA17w5ppnZst6MNmLnRnbVBCZJJ/Lncx6o9eqWpS4HfYWwnb63q3WeBToVbvDqqwx7T1T9m2oRVoo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226734279150.49881447723772; Mon, 23 Sep 2019 01:18:54 -0700 (PDT) Received: from localhost ([::1]:53474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJYX-000347-Ps for importer@patchew.org; Mon, 23 Sep 2019 04:18:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42803) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNp-0001yK-ST for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNo-00045m-Oc for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2454) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNo-00045M-IS; Mon, 23 Sep 2019 04:07:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7704309BDF2; Mon, 23 Sep 2019 08:07:43 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE26819C78; Mon, 23 Sep 2019 08:07:41 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 11/30] s390x/tcg: MVCOS: Lengths are 32 bit in 24/31-bit mode Date: Mon, 23 Sep 2019 10:06:53 +0200 Message-Id: <20190923080712.23951-12-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 23 Sep 2019 08:07:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Triggered by a review comment from Richard, also MVCOS has a 32-bit length in 24/31-bit addressing mode. Add a new helper. Rename wrap_length() to wrap_length31(). Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 20e1ac0ea9..320e9ee65c 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -528,7 +528,15 @@ static inline void set_address(CPUS390XState *env, int= reg, uint64_t address) } } =20 -static inline uint64_t wrap_length(CPUS390XState *env, uint64_t length) +static inline uint64_t wrap_length32(CPUS390XState *env, uint64_t length) +{ + if (!(env->psw.mask & PSW_MASK_64)) { + return (uint32_t)length; + } + return length; +} + +static inline uint64_t wrap_length31(CPUS390XState *env, uint64_t length) { if (!(env->psw.mask & PSW_MASK_64)) { /* 24-Bit and 31-Bit mode */ @@ -539,7 +547,7 @@ static inline uint64_t wrap_length(CPUS390XState *env, = uint64_t length) =20 static inline uint64_t get_length(CPUS390XState *env, int reg) { - return wrap_length(env, env->regs[reg]); + return wrap_length31(env, env->regs[reg]); } =20 static inline void set_length(CPUS390XState *env, int reg, uint64_t length) @@ -2378,7 +2386,7 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t d= est, uint64_t src, s390_program_interrupt(env, PGM_PRIVILEGED, 6, ra); } =20 - len =3D wrap_length(env, len); + len =3D wrap_length32(env, len); if (len > 4096) { cc =3D 3; len =3D 4096; --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226789; cv=none; d=zoho.com; s=zohoarc; b=l+T1MU4J1ViwgrzWcr/5bD7FQiFV9UVRqCH9rIyuuXK9ffqrb/KtSDzvAP1BwDbS6k+UOkvSOZgY8HpVP4wq+CaR1YfKg6O14zTMjhr3z8UmKeFEEIx1MZKLo52PZMXU0MI7iyhF5ak0nUS0yLaK+IsNOkjD0GQujTnif/ZQwp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226789; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PhtO3a3QpyY0ZLhN9leeXZ7DGvQyukeX9hfZEyx1Urc=; b=OTWTCKECibEvxLLTy58tQ/U13o0oC2DNeVF1EfSZs1AayRundJjiByREyaXjQaT2SdbSOFm4ywzLmXH88TRj1HWKfGQe9j5tZ/iz9kNIZZyZgG+GSC9E/YaVgK9xyzrERNj6vwPrp/Ex9O1vl3g/1hnBD04hQvFADkmi7mrMVhc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156922678991929.30760065559366; Mon, 23 Sep 2019 01:19:49 -0700 (PDT) Received: from localhost ([::1]:53478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJZQ-0003kN-4F for importer@patchew.org; Mon, 23 Sep 2019 04:19:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42830) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNr-00020Z-PW for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNq-00046g-NL for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNq-00046U-Hu; Mon, 23 Sep 2019 04:07:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3005A2668A; Mon, 23 Sep 2019 08:07:45 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CDEC19C78; Mon, 23 Sep 2019 08:07:44 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 12/30] s390x/tcg: MVCS/MVCP: Properly wrap the length Date: Mon, 23 Sep 2019 10:06:54 +0200 Message-Id: <20190923080712.23951-13-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 23 Sep 2019 08:07:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" ... and don't perform any move in case the length is zero. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 320e9ee65c..41d7336a1a 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1980,10 +1980,13 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); } =20 + l =3D wrap_length32(env, l); if (l > 256) { /* max 256 */ l =3D 256; cc =3D 3; + } else if (!l) { + return cc; } =20 /* XXX replace w/ memcpy */ @@ -2009,10 +2012,13 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); } =20 + l =3D wrap_length32(env, l); if (l > 256) { /* max 256 */ l =3D 256; cc =3D 3; + } else if (!l) { + return cc; } =20 /* XXX replace w/ memcpy */ --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227254; cv=none; d=zoho.com; s=zohoarc; b=VO+tH/Rq8e9AVyoYGxm0sGpNZP9ZZh4r8vRKju1ApMvJJaPkjW9NVVKaap4qMuDS1yqJ929RmvY9Hz+uWmoioUvpLkaxi0RRN7QiFtzd+HylPSfVXGTl5qq9CG34gZc8ggmdLobSQ1bXgrIN2vWOfHjt+cFfMShZTf+Rtm8rOlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227254; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JWb5mB8OScsytaBd+Q7VG884iKwWMaCTRQQkRFYpscg=; b=KrJrrQsqm7cKEjnyYLCrd69Qk09qy1jrSw6Zq4vFpOSseM7FF1YoKIabJJWv1oXM+APnyvD7evdIg/cxUki9fLkjEF785snz9/JV47ap7O16HAvCuwfdjmaCf2azLLCgxVpBZ/IX/QNkuRL45iknaM2kMzgYGwSwmnEqVJWz9k0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227254435116.56599951847659; Mon, 23 Sep 2019 01:27:34 -0700 (PDT) Received: from localhost ([::1]:53572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJgv-0003Ca-Po for importer@patchew.org; Mon, 23 Sep 2019 04:27:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42858) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNt-00022p-Py for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNs-00047k-N4 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNs-00047N-Hn; Mon, 23 Sep 2019 04:07:48 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB47273A63; Mon, 23 Sep 2019 08:07:47 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 274AA19C78; Mon, 23 Sep 2019 08:07:45 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 13/30] s390x/tcg: MVST: Check for specification exceptions Date: Mon, 23 Sep 2019 10:06:55 +0200 Message-Id: <20190923080712.23951-14-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 23 Sep 2019 08:07:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Bit position 32-55 of general register 0 must be zero. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 41d7336a1a..ec27be174b 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -706,6 +706,9 @@ uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c, u= int64_t d, uint64_t s) uintptr_t ra =3D GETPC(); uint32_t len; =20 + if (c & 0xffffff00ull) { + s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); + } c =3D c & 0xff; d =3D wrap_address(env, d); s =3D wrap_address(env, s); --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227426; cv=none; d=zoho.com; s=zohoarc; b=VMbJn1JStFQ/2SVbgEXazNGbJ47pDb2rsrSTCLiGmmrDaNe8ONp1Ag2qGYSFcxhcHTZzybBfLKeANCKcCPtwIgpCXzaYktj6raNMLe+b+Yfn3oQKuxc/5ZZJPxEAEy+T1AzFr6VN/TD73xlSXX/Up4SI67LlRbDEnFeSSQLqg7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227426; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iLlW5P7me8TjkWL2oZqeYBVEcd5QQeRvp/6cNT6xXf4=; b=EjWlv4Hyds59i+gFWbjQpQ+1s7zcgs4lrheIYQSm1GnjwwVWycB/mrSaNbvPVwvADoC4RNYMdkxj3YvAYPnz4EDRlAkFN3qQliVl5nlitalz9LJzPI500jy3nTUSXBaPod+FSPc0rWhM2j16y6P/8ElUulM11sIDoPejNwEgSCw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227426075351.18292412413916; Mon, 23 Sep 2019 01:30:26 -0700 (PDT) Received: from localhost ([::1]:53602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJjk-0006IA-Kn for importer@patchew.org; Mon, 23 Sep 2019 04:30:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42877) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJNw-000265-8o for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJNu-00048b-Qe for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41860) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJNu-00048N-FR; Mon, 23 Sep 2019 04:07:50 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C202F30833C1; Mon, 23 Sep 2019 08:07:49 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FE2319D70; Mon, 23 Sep 2019 08:07:47 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 14/30] s390x/tcg: MVST: Fix storing back the addresses to registers Date: Mon, 23 Sep 2019 10:06:56 +0200 Message-Id: <20190923080712.23951-15-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 23 Sep 2019 08:07:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 24 and 31-bit address space handling is wrong when it comes to storing back the addresses to the register. While at it, read gprs 0 implicitly. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/helper.h | 2 +- target/s390x/insn-data.def | 2 +- target/s390x/mem_helper.c | 26 +++++++++++--------------- target/s390x/translate.c | 8 ++++++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index e9aff83b05..56e8149866 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -20,7 +20,7 @@ DEF_HELPER_FLAGS_4(mvn, TCG_CALL_NO_WG, void, env, i32, i= 64, i64) DEF_HELPER_FLAGS_4(mvo, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(mvpg, TCG_CALL_NO_WG, i32, env, i64, i64, i64) DEF_HELPER_FLAGS_4(mvz, TCG_CALL_NO_WG, void, env, i32, i64, i64) -DEF_HELPER_4(mvst, i64, env, i64, i64, i64) +DEF_HELPER_3(mvst, i32, env, i32, i32) DEF_HELPER_4(ex, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(stam, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index f421184fcd..449eee1662 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -637,7 +637,7 @@ /* MOVE PAGE */ C(0xb254, MVPG, RRE, Z, r1_o, r2_o, 0, 0, mvpg, 0) /* MOVE STRING */ - C(0xb255, MVST, RRE, Z, r1_o, r2_o, 0, 0, mvst, 0) + C(0xb255, MVST, RRE, Z, 0, 0, 0, 0, mvst, 0) /* MOVE WITH OPTIONAL SPECIFICATION */ C(0xc800, MVCOS, SSF, MVCOS, la1, a2, 0, 0, mvcos, 0) /* MOVE WITH OFFSET */ diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index ec27be174b..a24506676b 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -700,18 +700,18 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0= , uint64_t r1, uint64_t r2) return 0; /* data moved */ } =20 -/* string copy (c is string terminator) */ -uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c, uint64_t d, uint64_t= s) +/* string copy */ +uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2) { + const uint64_t d =3D get_address(env, r1); + const uint64_t s =3D get_address(env, r2); + const uint8_t c =3D env->regs[0]; uintptr_t ra =3D GETPC(); uint32_t len; =20 - if (c & 0xffffff00ull) { + if (env->regs[0] & 0xffffff00ull) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); } - c =3D c & 0xff; - d =3D wrap_address(env, d); - s =3D wrap_address(env, s); =20 /* Lest we fail to service interrupts in a timely manner, limit the amount of work we're willing to do. For now, let's cap at 8k. */ @@ -719,17 +719,13 @@ uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c,= uint64_t d, uint64_t s) uint8_t v =3D cpu_ldub_data_ra(env, s + len, ra); cpu_stb_data_ra(env, d + len, v, ra); if (v =3D=3D c) { - /* Complete. Set CC=3D1 and advance R1. */ - env->cc_op =3D 1; - env->retxl =3D s; - return d + len; + set_address_zero(env, r1, d + len); + return 1; } } - - /* Incomplete. Set CC=3D3 and signal to advance R1 and R2. */ - env->cc_op =3D 3; - env->retxl =3D s + len; - return d + len; + set_address_zero(env, r1, d + len); + set_address_zero(env, r2, s + len); + return 3; } =20 /* load access registers r1 to r3 from memory at a2 */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 2927247c82..b0a2500e5f 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3488,9 +3488,13 @@ static DisasJumpType op_mvpg(DisasContext *s, DisasO= ps *o) =20 static DisasJumpType op_mvst(DisasContext *s, DisasOps *o) { - gen_helper_mvst(o->in1, cpu_env, regs[0], o->in1, o->in2); + TCGv_i32 t1 =3D tcg_const_i32(get_field(s->fields, r1)); + TCGv_i32 t2 =3D tcg_const_i32(get_field(s->fields, r2)); + + gen_helper_mvst(cc_op, cpu_env, t1, t2); + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t2); set_cc_static(s); - return_low128(o->in2); return DISAS_NEXT; } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227628; cv=none; d=zoho.com; s=zohoarc; b=QhfxZHXiOsPGXeKWSWyVgvSNTAjIYrbhrmxXkUFyxbKguQo0qiEvaBXLXH0Osje7VbvxVbTd0LisZgR/15HRcrcqQruB8UXKgTc5231uGWYZrRHJ6Bl3X1+KOrnuMtpL4hWfe+nfUSKMHYuVyXLMuIfKpNholQyToCat5pHqIas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227628; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=B6D3H4fq/SqAp0OP3zYKoJh4PFgIUQ8xc0jce1MtqyY=; b=iNldnzCY60joWwquR6gL3CyGanrnmVe95T4A67vtGh+ywSHNQ05lTN8QKenvLDN4f0I8OgGb8ss6n1WBuBbYZn1PPP8qzZ/8DogKtt+L/JwjqXuMltfB5sKXDEaFLGhXWrX7IoIupZ36KASca/Q43wsI0ufLLbO784mwRAHZfCE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227628315517.6089535181704; Mon, 23 Sep 2019 01:33:48 -0700 (PDT) Received: from localhost ([::1]:53638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJn0-0000fn-0z for importer@patchew.org; Mon, 23 Sep 2019 04:33:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJO1-0002C1-GE for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJO0-0004BF-D7 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:07:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJO0-0004Ax-85; Mon, 23 Sep 2019 04:07:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8138989810B; Mon, 23 Sep 2019 08:07:55 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 174A019C78; Mon, 23 Sep 2019 08:07:49 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 15/30] s390x/tcg: Always use MMU_USER_IDX for CONFIG_USER_ONLY Date: Mon, 23 Sep 2019 10:06:57 +0200 Message-Id: <20190923080712.23951-16-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Mon, 23 Sep 2019 08:07:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Although we basically ignore the index all the time for CONFIG_USER_ONLY, let's simply skip all the checks and always return MMU_USER_IDX in cpu_mmu_index() and get_mem_index(). Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 4 ++++ target/s390x/translate.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 79202c0980..163dae13d7 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -328,6 +328,9 @@ extern const VMStateDescription vmstate_s390_cpu; =20 static inline int cpu_mmu_index(CPUS390XState *env, bool ifetch) { +#ifdef CONFIG_USER_ONLY + return MMU_USER_IDX; +#else if (!(env->psw.mask & PSW_MASK_DAT)) { return MMU_REAL_IDX; } @@ -351,6 +354,7 @@ static inline int cpu_mmu_index(CPUS390XState *env, boo= l ifetch) default: abort(); } +#endif } =20 static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *= pc, diff --git a/target/s390x/translate.c b/target/s390x/translate.c index b0a2500e5f..a3e43ff9ec 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -318,6 +318,9 @@ static inline uint64_t ld_code4(CPUS390XState *env, uin= t64_t pc) =20 static int get_mem_index(DisasContext *s) { +#ifdef CONFIG_USER_ONLY + return MMU_USER_IDX; +#else if (!(s->base.tb->flags & FLAG_MASK_DAT)) { return MMU_REAL_IDX; } @@ -333,6 +336,7 @@ static int get_mem_index(DisasContext *s) tcg_abort(); break; } +#endif } =20 static void gen_exception(int excp) --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227790; cv=none; d=zoho.com; s=zohoarc; b=caaAZtY8X+gF2QPWWUZurGIx06BKEFfqWrzIJKCtckbUe2sy6zjve2JSEvLh2RmySuZGOJ+dqmXwJE+Bp3GCblJVCXY+06mLULI1qsGCuNXGmfu7XnMJbCFRYRBN1141cesExu4zxKqzdSWR1pMma2rG/Fz2U3XpXy0s1OnzTMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227790; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3/5u6E28FmxNGeeoAFmS+8BbZJvEEoNo+c62AbfRCEo=; b=BqME3efqgJOWn0LFXA6o/JCEIFkB/wfF6Gbrtcy1Zer5r/I6vt0RmrjN0xnnK4fsJuNpHVT0u/B1H24ES81/FdrU8Ss0Y8HQJsBWmKVC5dNIYpOPa/B7ycln9wKLEb86KunVuvHBQr74VyRPVTN7hP3VWYzFSCiwblPgxd9uP+U= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227790404543.6210433689429; Mon, 23 Sep 2019 01:36:30 -0700 (PDT) Received: from localhost ([::1]:53668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJpc-0003Ym-UZ for importer@patchew.org; Mon, 23 Sep 2019 04:36:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42932) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJO4-0002Fq-PR for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJO2-0004C8-R8 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJO2-0004Bp-JE; Mon, 23 Sep 2019 04:07:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D96FC18C427C; Mon, 23 Sep 2019 08:07:57 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8997196AE; Mon, 23 Sep 2019 08:07:55 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 16/30] s390x/tcg: Fault-safe memset Date: Mon, 23 Sep 2019 10:06:58 +0200 Message-Id: <20190923080712.23951-17-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Mon, 23 Sep 2019 08:07:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Replace fast_memset() by access_memset(), that first tries to probe access to all affected pages (maximum is two). We'll use the same mechanism for other types of accesses soon. Only in very rare cases (especially TLB_NOTDIRTY), we'll have to fallback to ld/st helpers. Try to speed up that case as suggested by Richard. We'll rework most involved handlers soon to do all accesses via new fault-safe helpers, especially MVC. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 123 +++++++++++++++++++++++++++++++------- 1 file changed, 103 insertions(+), 20 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index a24506676b..dd5da70746 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -117,27 +117,95 @@ static inline void cpu_stsize_data_ra(CPUS390XState *= env, uint64_t addr, } } =20 -static void fast_memset(CPUS390XState *env, uint64_t dest, uint8_t byte, - uint32_t l, uintptr_t ra) +/* An access covers at most 4096 bytes and therefore at most two pages. */ +typedef struct S390Access { + target_ulong vaddr1; + target_ulong vaddr2; + char *haddr1; + char *haddr2; + uint16_t size1; + uint16_t size2; + /* + * If we can't access the host page directly, we'll have to do I/O acc= ess + * via ld/st helpers. These are internal details, so we store the + * mmu idx to do the access here instead of passing it around in the + * helpers. Maybe, one day we can get rid of ld/st access - once we can + * handle TLB_NOTDIRTY differently. We don't expect these special acce= sses + * to trigger exceptions - only if we would have TLB_NOTDIRTY on LAP + * pages, we might trigger a new MMU translation - very unlikely that + * the mapping changes in between and we would trigger a fault. + */ + int mmu_idx; +} S390Access; + +static S390Access access_prepare(CPUS390XState *env, vaddr vaddr, int size, + MMUAccessType access_type, int mmu_idx, + uintptr_t ra) { - int mmu_idx =3D cpu_mmu_index(env, false); + S390Access access =3D { + .vaddr1 =3D vaddr, + .size1 =3D MIN(size, -(vaddr | TARGET_PAGE_MASK)), + .mmu_idx =3D mmu_idx, + }; =20 - while (l > 0) { - void *p =3D tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_idx); - if (p) { - /* Access to the whole page in write mode granted. */ - uint32_t l_adj =3D adj_len_to_page(l, dest); - memset(p, byte, l_adj); - dest +=3D l_adj; - l -=3D l_adj; + g_assert(size > 0 && size <=3D 4096); + access.haddr1 =3D probe_access(env, access.vaddr1, access.size1, acces= s_type, + mmu_idx, ra); + + if (unlikely(access.size1 !=3D size)) { + /* The access crosses page boundaries. */ + access.vaddr2 =3D wrap_address(env, vaddr + access.size1); + access.size2 =3D size - access.size1; + access.haddr2 =3D probe_access(env, access.vaddr2, access.size2, + access_type, mmu_idx, ra); + } + return access; +} + +/* Helper to handle memset on a single page. */ +static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr, + uint8_t byte, uint16_t size, int mmu_idx, + uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + g_assert(haddr); + memset(haddr, byte, size); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + int i; + + if (likely(haddr)) { + memset(haddr, byte, size); + } else { + /* + * Do a single access and test if we can then get access to the + * page. This is especially relevant to speed up TLB_NOTDIRTY. + */ + g_assert(size > 0); + helper_ret_stb_mmu(env, vaddr, byte, oi, ra); + haddr =3D tlb_vaddr_to_host(env, vaddr, MMU_DATA_STORE, mmu_idx); + if (likely(haddr)) { + memset(haddr + 1, byte, size - 1); } else { - /* We failed to get access to the whole page. The next write - access will likely fill the QEMU TLB for the next iteration= . */ - cpu_stb_data_ra(env, dest, byte, ra); - dest++; - l--; + for (i =3D 1; i < size; i++) { + helper_ret_stb_mmu(env, vaddr + i, byte, oi, ra); + } } } +#endif +} + +static void access_memset(CPUS390XState *env, S390Access *desta, + uint8_t byte, uintptr_t ra) +{ + + do_access_memset(env, desta->vaddr1, desta->haddr1, byte, desta->size1, + desta->mmu_idx, ra); + if (likely(!desta->size2)) { + return; + } + do_access_memset(env, desta->vaddr2, desta->haddr2, byte, desta->size2, + desta->mmu_idx, ra); } =20 #ifndef CONFIG_USER_ONLY @@ -259,15 +327,19 @@ uint32_t HELPER(nc)(CPUS390XState *env, uint32_t l, u= int64_t dest, static uint32_t do_helper_xc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 + desta =3D access_prepare(env, dest, l + 1, MMU_DATA_STORE, mmu_idx, ra= ); + /* xor with itself is the same as memset(0) */ if (src =3D=3D dest) { - fast_memset(env, dest, 0, l + 1, ra); + access_memset(env, &desta, 0, ra); return 0; } =20 @@ -315,6 +387,8 @@ uint32_t HELPER(oc)(CPUS390XState *env, uint32_t l, uin= t64_t dest, static uint32_t do_helper_mvc(CPUS390XState *env, uint32_t l, uint64_t des= t, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access desta; uint32_t i; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", @@ -323,13 +397,15 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uin= t32_t l, uint64_t dest, /* MVC always copies one more byte than specified - maximum is 256 */ l++; =20 + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + /* * "When the operands overlap, the result is obtained as if the operan= ds * were processed one byte at a time". Only non-destructive overlaps * behave like memmove(). */ if (dest =3D=3D src + 1) { - fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); + access_memset(env, &desta, cpu_ldub_data_ra(env, src, ra), ra); } else if (!is_destructive_overlap(env, dest, src, l)) { fast_memmove(env, dest, src, l, ra); } else { @@ -775,7 +851,9 @@ static inline uint32_t do_mvcl(CPUS390XState *env, uint64_t *src, uint64_t *srclen, uint16_t pad, int wordsize, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); int len =3D MIN(*destlen, -(*dest | TARGET_PAGE_MASK)); + S390Access desta; int i, cc; =20 if (*destlen =3D=3D *srclen) { @@ -805,7 +883,8 @@ static inline uint32_t do_mvcl(CPUS390XState *env, } else if (wordsize =3D=3D 1) { /* Pad the remaining area */ *destlen -=3D len; - fast_memset(env, *dest, pad, len, ra); + desta =3D access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx,= ra); + access_memset(env, &desta, pad, ra); *dest =3D wrap_address(env, *dest + len); } else { /* The remaining length selects the padding byte. */ @@ -825,6 +904,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, /* move long */ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, uint32_t r2) { + const int mmu_idx =3D cpu_mmu_index(env, false); uintptr_t ra =3D GETPC(); uint64_t destlen =3D env->regs[r1 + 1] & 0xffffff; uint64_t dest =3D get_address(env, r1); @@ -832,6 +912,7 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) uint64_t src =3D get_address(env, r2); uint8_t pad =3D env->regs[r2 + 1] >> 24; uint32_t cc, cur_len; + S390Access desta; =20 if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { cc =3D 3; @@ -859,7 +940,9 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) while (destlen) { cur_len =3D MIN(destlen, -(dest | TARGET_PAGE_MASK)); if (!srclen) { - fast_memset(env, dest, pad, cur_len, ra); + desta =3D access_prepare(env, dest, cur_len, MMU_DATA_STORE, m= mu_idx, + ra); + access_memset(env, &desta, pad, ra); } else { cur_len =3D MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_le= n); =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227952; cv=none; d=zoho.com; s=zohoarc; b=WoxxPvAbMylUSMkioDQLgIGU0i+P0yu2RQAd8NWfTd3b2LbsAr17/cH7HSfHZ7Um5WFzgYk8eALP8rnunKQ+Q4/QdgOhCsKCU44SwQVokW3hQNtkVLbyowoaH/bw3CHMtj/m9Dst48P3D2TvWDoL7IzW045VLmJcNMh8uPs4v2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227952; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iPKlA2+zKQrZyd3D8+C2hqYk0LUG3vCg/lBfs8mRoGg=; b=LdNVuvxRnQ6BYXRoMP77sISprTHDh2eP9+lAN9QLveezdWuImHLtv8c+csmnpMyczQGDh+No6TwRSPxLDAtUNiAb1UxY8lqMqzld+fCccF5mikI4vI5oPr81Qs4UL92KgK4v2tdQI/rub51WSaG6Hs+BvE+6ZtnxoRb0KoA8/tY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227952106555.882788629458; Mon, 23 Sep 2019 01:39:12 -0700 (PDT) Received: from localhost ([::1]:53694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJsE-0006NT-NF for importer@patchew.org; Mon, 23 Sep 2019 04:39:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42944) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJO6-0002IF-Ud for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJO4-0004Ct-P0 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJO4-0004CX-H5; Mon, 23 Sep 2019 04:08:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9E13300DA6E; Mon, 23 Sep 2019 08:07:59 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CF0419C78; Mon, 23 Sep 2019 08:07:58 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 17/30] s390x/tcg: Fault-safe memmove Date: Mon, 23 Sep 2019 10:06:59 +0200 Message-Id: <20190923080712.23951-18-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 23 Sep 2019 08:07:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Replace fast_memmove() variants by access_memmove() variants, that first try to probe access to all affected pages (maximum is two pages). Introduce access_get_byte()/access_set_byte(). We might be able to speed up memmove in special cases even further (do single-byte access, use memmove() for remaining bytes in page), however, we'll skip that for now. In MVCOS, simply always call access_memmove_as() and drop the TODO about LAP. LAP is already handled in the MMU. Get rid of adj_len_to_page(), which is now unused. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 238 ++++++++++++++++++++++---------------- 1 file changed, 139 insertions(+), 99 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index dd5da70746..12ffe72c88 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -65,17 +65,6 @@ static bool is_destructive_overlap(CPUS390XState *env, u= int64_t dest, return dest > src && dest <=3D src + len - 1; } =20 -/* Reduce the length so that addr + len doesn't cross a page boundary. */ -static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr) -{ -#ifndef CONFIG_USER_ONLY - if ((addr & ~TARGET_PAGE_MASK) + len - 1 >=3D TARGET_PAGE_SIZE) { - return -(addr | TARGET_PAGE_MASK); - } -#endif - return len; -} - /* Trigger a SPECIFICATION exception if an address or a length is not naturally aligned. */ static inline void check_alignment(CPUS390XState *env, uint64_t v, @@ -208,39 +197,116 @@ static void access_memset(CPUS390XState *env, S390Ac= cess *desta, desta->mmu_idx, ra); } =20 -#ifndef CONFIG_USER_ONLY -static void fast_memmove_idx(CPUS390XState *env, uint64_t dest, uint64_t s= rc, - uint32_t len, int dest_idx, int src_idx, - uintptr_t ra) +static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, char **= haddr, + int offset, int mmu_idx, uintptr_t ra) { - TCGMemOpIdx oi_dest =3D make_memop_idx(MO_UB, dest_idx); - TCGMemOpIdx oi_src =3D make_memop_idx(MO_UB, src_idx); - uint32_t len_adj; - void *src_p; - void *dest_p; - uint8_t x; - - while (len > 0) { - src =3D wrap_address(env, src); - dest =3D wrap_address(env, dest); - src_p =3D tlb_vaddr_to_host(env, src, MMU_DATA_LOAD, src_idx); - dest_p =3D tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, dest_idx); - - if (src_p && dest_p) { - /* Access to both whole pages granted. */ - len_adj =3D adj_len_to_page(adj_len_to_page(len, src), dest); - memmove(dest_p, src_p, len_adj); - } else { - /* We failed to get access to one or both whole pages. The next - read or write access will likely fill the QEMU TLB for the - next iteration. */ - len_adj =3D 1; - x =3D helper_ret_ldub_mmu(env, src, oi_src, ra); - helper_ret_stb_mmu(env, dest, x, oi_dest, ra); +#ifdef CONFIG_USER_ONLY + return ldub_p(*haddr + offset); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + uint8_t byte; + + if (likely(*haddr)) { + return ldub_p(*haddr + offset); + } + /* + * Do a single access and test if we can then get access to the + * page. This is especially relevant to speed up TLB_NOTDIRTY. + */ + byte =3D helper_ret_ldub_mmu(env, vaddr + offset, oi, ra); + *haddr =3D tlb_vaddr_to_host(env, vaddr, MMU_DATA_LOAD, mmu_idx); + return byte; +#endif +} + +static uint8_t access_get_byte(CPUS390XState *env, S390Access *access, + int offset, uintptr_t ra) +{ + if (offset < access->size1) { + return do_access_get_byte(env, access->vaddr1, &access->haddr1, + offset, access->mmu_idx, ra); + } + return do_access_get_byte(env, access->vaddr2, &access->haddr2, + offset - access->size1, access->mmu_idx, ra); +} + +static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, char **had= dr, + int offset, uint8_t byte, int mmu_idx, + uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + stb_p(*haddr + offset, byte); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + + if (likely(*haddr)) { + stb_p(*haddr + offset, byte); + return; + } + /* + * Do a single access and test if we can then get access to the + * page. This is especially relevant to speed up TLB_NOTDIRTY. + */ + helper_ret_stb_mmu(env, vaddr + offset, byte, oi, ra); + *haddr =3D tlb_vaddr_to_host(env, vaddr, MMU_DATA_STORE, mmu_idx); +#endif +} + +static void access_set_byte(CPUS390XState *env, S390Access *access, + int offset, uint8_t byte, uintptr_t ra) +{ + if (offset < access->size1) { + do_access_set_byte(env, access->vaddr1, &access->haddr1, offset, b= yte, + access->mmu_idx, ra); + } else { + do_access_set_byte(env, access->vaddr2, &access->haddr2, + offset - access->size1, byte, access->mmu_idx, = ra); + } +} + +/* + * Move data with the same semantics as memmove() in case ranges don't ove= rlap + * or src > dest. Undefined behavior on destructive overlaps. + */ +static void access_memmove(CPUS390XState *env, S390Access *desta, + S390Access *srca, uintptr_t ra) +{ + int diff; + + g_assert(desta->size1 + desta->size2 =3D=3D srca->size1 + srca->size2); + + /* Fallback to slow access in case we don't have access to all host pa= ges */ + if (unlikely(!desta->haddr1 || (desta->size2 && !desta->haddr2) || + !srca->haddr1 || (srca->size2 && !srca->haddr2))) { + int i; + + for (i =3D 0; i < desta->size1 + desta->size2; i++) { + uint8_t byte =3D access_get_byte(env, srca, i, ra); + + access_set_byte(env, desta, i, byte, ra); + } + return; + } + + if (srca->size1 =3D=3D desta->size1) { + memmove(desta->haddr1, srca->haddr1, srca->size1); + if (unlikely(srca->size2)) { + memmove(desta->haddr2, srca->haddr2, srca->size2); + } + } else if (srca->size1 < desta->size1) { + diff =3D desta->size1 - srca->size1; + memmove(desta->haddr1, srca->haddr1, srca->size1); + memmove(desta->haddr1 + srca->size1, srca->haddr2, diff); + if (likely(desta->size2)) { + memmove(desta->haddr2, srca->haddr2 + diff, desta->size2); + } + } else { + diff =3D srca->size1 - desta->size1; + memmove(desta->haddr1, srca->haddr1, desta->size1); + memmove(desta->haddr2, srca->haddr1 + desta->size1, diff); + if (likely(srca->size2)) { + memmove(desta->haddr2 + diff, srca->haddr2, srca->size2); } - src +=3D len_adj; - dest +=3D len_adj; - len -=3D len_adj; } } =20 @@ -259,45 +325,6 @@ static int mmu_idx_from_as(uint8_t as) } } =20 -static void fast_memmove_as(CPUS390XState *env, uint64_t dest, uint64_t sr= c, - uint32_t len, uint8_t dest_as, uint8_t src_as, - uintptr_t ra) -{ - int src_idx =3D mmu_idx_from_as(src_as); - int dest_idx =3D mmu_idx_from_as(dest_as); - - fast_memmove_idx(env, dest, src, len, dest_idx, src_idx, ra); -} -#endif - -static void fast_memmove(CPUS390XState *env, uint64_t dest, uint64_t src, - uint32_t l, uintptr_t ra) -{ - int mmu_idx =3D cpu_mmu_index(env, false); - - while (l > 0) { - void *src_p =3D tlb_vaddr_to_host(env, src, MMU_DATA_LOAD, mmu_idx= ); - void *dest_p =3D tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_= idx); - if (src_p && dest_p) { - /* Access to both whole pages granted. */ - uint32_t l_adj =3D adj_len_to_page(l, src); - l_adj =3D adj_len_to_page(l_adj, dest); - memmove(dest_p, src_p, l_adj); - src +=3D l_adj; - dest +=3D l_adj; - l -=3D l_adj; - } else { - /* We failed to get access to one or both whole pages. The next - read or write access will likely fill the QEMU TLB for the - next iteration. */ - cpu_stb_data_ra(env, dest, cpu_ldub_data_ra(env, src, ra), ra); - src++; - dest++; - l--; - } - } -} - /* and on array */ static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) @@ -388,7 +415,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, uint64_t src, uintptr_t ra) { const int mmu_idx =3D cpu_mmu_index(env, false); - S390Access desta; + S390Access srca, desta; uint32_t i; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", @@ -397,6 +424,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, /* MVC always copies one more byte than specified - maximum is 256 */ l++; =20 + srca =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); =20 /* @@ -405,9 +433,9 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, * behave like memmove(). */ if (dest =3D=3D src + 1) { - access_memset(env, &desta, cpu_ldub_data_ra(env, src, ra), ra); + access_memset(env, &desta, access_get_byte(env, &srca, 0, ra), ra); } else if (!is_destructive_overlap(env, dest, src, l)) { - fast_memmove(env, dest, src, l, ra); + access_memmove(env, &desta, &srca, ra); } else { for (i =3D 0; i < l; i++) { uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); @@ -756,8 +784,11 @@ uint64_t HELPER(clst)(CPUS390XState *env, uint64_t c, = uint64_t s1, uint64_t s2) /* move page */ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64= _t r2) { + const int mmu_idx =3D cpu_mmu_index(env, false); const bool f =3D extract64(r0, 11, 1); const bool s =3D extract64(r0, 10, 1); + uintptr_t ra =3D GETPC(); + S390Access srca, desta; =20 if ((f && s) || extract64(r0, 12, 4)) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC()); @@ -772,7 +803,11 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0,= uint64_t r1, uint64_t r2) * - CC-option with surpression of page-translation exceptions * - Store r1/r2 register identifiers at real location 162 */ - fast_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); + srca =3D access_prepare(env, r2, TARGET_PAGE_SIZE, MMU_DATA_LOAD, mmu_= idx, + ra); + desta =3D access_prepare(env, r1, TARGET_PAGE_SIZE, MMU_DATA_STORE, mm= u_idx, + ra); + access_memmove(env, &desta, &srca, ra); return 0; /* data moved */ } =20 @@ -853,7 +888,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, { const int mmu_idx =3D cpu_mmu_index(env, false); int len =3D MIN(*destlen, -(*dest | TARGET_PAGE_MASK)); - S390Access desta; + S390Access srca, desta; int i, cc; =20 if (*destlen =3D=3D *srclen) { @@ -877,7 +912,9 @@ static inline uint32_t do_mvcl(CPUS390XState *env, len =3D MIN(MIN(*srclen, -(*src | TARGET_PAGE_MASK)), len); *destlen -=3D len; *srclen -=3D len; - fast_memmove(env, *dest, *src, len, ra); + srca =3D access_prepare(env, *src, len, MMU_DATA_LOAD, mmu_idx, ra= ); + desta =3D access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx,= ra); + access_memmove(env, &desta, &srca, ra); *src =3D wrap_address(env, *src + len); *dest =3D wrap_address(env, *dest + len); } else if (wordsize =3D=3D 1) { @@ -911,8 +948,8 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) uint64_t srclen =3D env->regs[r2 + 1] & 0xffffff; uint64_t src =3D get_address(env, r2); uint8_t pad =3D env->regs[r2 + 1] >> 24; + S390Access srca, desta; uint32_t cc, cur_len; - S390Access desta; =20 if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { cc =3D 3; @@ -946,7 +983,11 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1,= uint32_t r2) } else { cur_len =3D MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_le= n); =20 - fast_memmove(env, dest, src, cur_len, ra); + srca =3D access_prepare(env, src, cur_len, MMU_DATA_LOAD, mmu_= idx, + ra); + desta =3D access_prepare(env, dest, cur_len, MMU_DATA_STORE, m= mu_idx, + ra); + access_memmove(env, &desta, &srca, ra); src =3D wrap_address(env, src + cur_len); srclen -=3D cur_len; env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srcl= en); @@ -2488,16 +2529,15 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t= dest, uint64_t src, s390_program_interrupt(env, PGM_ADDRESSING, 6, ra); } =20 - /* FIXME: a) LAP - * b) Access using correct keys - * c) AR-mode - */ -#ifdef CONFIG_USER_ONLY - /* psw keys are never valid in user mode, we will never reach this */ - g_assert_not_reached(); -#else - fast_memmove_as(env, dest, src, len, dest_as, src_as, ra); -#endif + /* FIXME: Access using correct keys and AR-mode */ + if (len) { + S390Access srca =3D access_prepare(env, src, len, MMU_DATA_LOAD, + mmu_idx_from_as(src_as), ra); + S390Access desta =3D access_prepare(env, dest, len, MMU_DATA_STORE, + mmu_idx_from_as(dest_as), ra); + + access_memmove(env, &desta, &srca, ra); + } =20 return cc; } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226971; cv=none; d=zoho.com; s=zohoarc; b=cOCJ/TRHVCBl29amfj5B+L5k4V9kG1z7MsEN0nvOoSA05wisp6+vlsLln4RIoCSSZM5Iz2cHjx8UWr4jrpAeXVjdJoGcHCPjwCLvRDEhEeA8o/bpR3zyXX0ErQYa3SBQ6W+USWyZB3DY/SK2iZzV6yQXTXlqkqK3JfJyvpmvV7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226971; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Y9gPKArGOD8hkfc6yaVydyaSTM1EK8DSwQvrbTOLw0k=; b=mXmhd9QetkfIbUhxyFCo3cjbFjsLtgv0tN23Ob+eN3zbWMj+XHQMjdUUbTLc5v2FPf+g6n9KfBjP1qj9XYxrqyvHJpCTOdldM6JNGkV5Q6XxBOtChDgm+zNtUkwxZrvszIOvoCxJ+RFMqH5tnirnhCj0sVmukeBz/XXIY44U+2c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226971971517.3731791708459; Mon, 23 Sep 2019 01:22:51 -0700 (PDT) Received: from localhost ([::1]:53516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJcQ-0006vL-Ix for importer@patchew.org; Mon, 23 Sep 2019 04:22:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42969) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJO9-0002LP-Oc for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJO8-0004E8-1m for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47446) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJO7-0004Dl-Q2; Mon, 23 Sep 2019 04:08:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10A9BA2668E; Mon, 23 Sep 2019 08:08:03 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DB7119C78; Mon, 23 Sep 2019 08:07:59 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 18/30] s390x/tcg: MVCS/MVCP: Use access_memmove() Date: Mon, 23 Sep 2019 10:07:00 +0200 Message-Id: <20190923080712.23951-19-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 23 Sep 2019 08:08:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As we are moving between address spaces, we can use access_memmove() without checking for destructive overlaps (especially of real storage locations): "Each storage operand is processed left to right. The storage-operand-consistency rules are the same as for MOVE (MVC), except that when the operands overlap in real storage, the use of the common real- storage locations is not necessarily recognized." Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 12ffe72c88..04c4228f13 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2092,8 +2092,9 @@ uint32_t HELPER(rrbe)(CPUS390XState *env, uint64_t r2) uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; + S390Access srca, desta; uintptr_t ra =3D GETPC(); - int cc =3D 0, i; + int cc =3D 0; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); @@ -2112,20 +2113,19 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) return cc; } =20 - /* XXX replace w/ memcpy */ - for (i =3D 0; i < l; i++) { - uint8_t x =3D cpu_ldub_primary_ra(env, a2 + i, ra); - cpu_stb_secondary_ra(env, a1 + i, x, ra); - } - + /* TODO: Access key handling */ + srca =3D access_prepare(env, a2, l, MMU_DATA_LOAD, MMU_PRIMARY_IDX, ra= ); + desta =3D access_prepare(env, a1, l, MMU_DATA_STORE, MMU_SECONDARY_IDX= , ra); + access_memmove(env, &desta, &srca, ra); return cc; } =20 uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; + S390Access srca, desta; uintptr_t ra =3D GETPC(); - int cc =3D 0, i; + int cc =3D 0; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); @@ -2144,12 +2144,10 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) return cc; } =20 - /* XXX replace w/ memcpy */ - for (i =3D 0; i < l; i++) { - uint8_t x =3D cpu_ldub_secondary_ra(env, a2 + i, ra); - cpu_stb_primary_ra(env, a1 + i, x, ra); - } - + /* TODO: Access key handling */ + srca =3D access_prepare(env, a2, l, MMU_DATA_LOAD, MMU_SECONDARY_IDX, = ra); + desta =3D access_prepare(env, a1, l, MMU_DATA_STORE, MMU_PRIMARY_IDX, = ra); + access_memmove(env, &desta, &srca, ra); return cc; } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569228087; cv=none; d=zoho.com; s=zohoarc; b=QiCvE6x+MI2AohWCNEjlAs6cJVHukf6zeAq2VRsn+Awt9+0n8wb99ASdoL6/siTDNwxfJTD0TYzsQz7zTllR5OOI+6I75jGvGrRNtrUyZjet70w9liv/YH1Ig1iVDxn7lOpJ4mNSgqe0+6KWcaH3lwsHqIUH6rifQp2IucdUtCs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569228087; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=heoJo+mXVp4ND9xdKeJEYmEFI09ALsA7uSy7RKig1OI=; b=BVNKrBkHj4vsfv9GXuoWsT4xnT04Fj6By/QpRCt+crniHxel3oxbF0nPEInTshedGTNBeJe0MOBWUU5e0Mfi/vh+/HkchWdgKU8y2MH0C2xnS5dohgoDGkwFxYMuuJ1zxHbWuhffvgEZdNIkZocZwLYXEVLM/IQGfzFht2MeCLA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156922808708157.56743585694824; Mon, 23 Sep 2019 01:41:27 -0700 (PDT) Received: from localhost ([::1]:53718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJuP-0000jp-Qo for importer@patchew.org; Mon, 23 Sep 2019 04:41:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43010) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOC-0002Pf-TQ for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOB-0004Fy-PT for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOB-0004Fh-KU; Mon, 23 Sep 2019 04:08:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E89DB30860D3; Mon, 23 Sep 2019 08:08:06 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53BEE19C78; Mon, 23 Sep 2019 08:08:03 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 19/30] s390x/tcg: MVC: Fault-safe handling on destructive overlaps Date: Mon, 23 Sep 2019 10:07:01 +0200 Message-Id: <20190923080712.23951-20-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 23 Sep 2019 08:08:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The last remaining bit for MVC is handling destructive overlaps in a fault-safe way. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 04c4228f13..aed53a37da 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -438,8 +438,9 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, access_memmove(env, &desta, &srca, ra); } else { for (i =3D 0; i < l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - cpu_stb_data_ra(env, dest + i, x, ra); + uint8_t byte =3D access_get_byte(env, &srca, i, ra); + + access_set_byte(env, &desta, i, byte, ra); } } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227008; cv=none; d=zoho.com; s=zohoarc; b=MJhnflLhu6d2yP4rFn14fX26KLlP1PC8IMVk9fQN3Ckg1NEW5oeCAJZEweKMFeUg0Wd9n8safF42lHzuKuNk7gRMRg8u8zGLSX3hlxoGqEkzYbaGl08cpnF7aC+eDGL++Ou/vge4Ved9UM8twWPwn91cH8fSF6x4LgG4e/q7AKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227008; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=n9z+zcLVR58pX9VUrrgoK+uQC+tIF+adqe7QKQK6Hhk=; b=Ov3oZpSWhhfoSYE3kjVweY7y+C7IpjgNm7n/xO3DbaNvXSRKhui14Sm40ZRRxje321OD05zOuhiAaXYhDEXeP4hnEwxGwg+6OeDomuNZUkWk4QGOgomBsYuWInfnVgySk57hKZ/LRl7TUjEzSzArjJXYIaELKO0zCMk/n/T8kvY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227008455307.5537227845774; Mon, 23 Sep 2019 01:23:28 -0700 (PDT) Received: from localhost ([::1]:53520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJd0-0007Op-Lo for importer@patchew.org; Mon, 23 Sep 2019 04:23:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43040) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOJ-0002Xl-S3 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOI-0004Jc-LY for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOI-0004JM-GW; Mon, 23 Sep 2019 04:08:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA7A2308A9E2; Mon, 23 Sep 2019 08:08:13 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DF3019C78; Mon, 23 Sep 2019 08:08:07 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 20/30] s390x/tcg: MVCLU: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:02 +0200 Message-Id: <20190923080712.23951-21-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 23 Sep 2019 08:08:13 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The last remaining bit is padding with two bytes. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index aed53a37da..271b1db664 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -925,15 +925,17 @@ static inline uint32_t do_mvcl(CPUS390XState *env, access_memset(env, &desta, pad, ra); *dest =3D wrap_address(env, *dest + len); } else { + desta =3D access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx,= ra); + /* The remaining length selects the padding byte. */ for (i =3D 0; i < len; (*destlen)--, i++) { if (*destlen & 1) { - cpu_stb_data_ra(env, *dest, pad, ra); + access_set_byte(env, &desta, i, pad, ra); } else { - cpu_stb_data_ra(env, *dest, pad >> 8, ra); + access_set_byte(env, &desta, i, pad >> 8, ra); } - *dest =3D wrap_address(env, *dest + 1); } + *dest =3D wrap_address(env, *dest + len); } =20 return *destlen ? 3 : cc; --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227234; cv=none; d=zoho.com; s=zohoarc; b=MiWqjzNfust+m7Xo2bAa+qmysrgRm+SWNK3adean0AVPlet9eCwTnAlWeJ4Q1sFBMnZrM6wv/E2784GDNHz1wYnM1b8MqWKqk6kJuedZpoDRcRaTYswkz2UG098GJ36kImVupOfpM6ieP0VUD+jVIk0RkaMrEHUqzsxYWOKMxcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227234; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gB0zvcFb5qHg9l2u3/MF5lZGwTCBBqf20RhMB4JqZeE=; b=Jhl5vK9l/ialnrrfWVc5OdNmbJlGQapbeLxlbf0CMj5VNHCtZ1iLzonhNFeSznuj6/LBakwQRCA5L15i8vdvCsKJfVVzlNv5voKYi7dyrowjcqxD2tTCNRD6ZuxCZFi7fqeweWoVW84KmxjdLjsJYqwqYuPGj3FTMT5it9qbeKQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227234807514.321044776657; Mon, 23 Sep 2019 01:27:14 -0700 (PDT) Received: from localhost ([::1]:53569 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJgc-0002nn-KR for importer@patchew.org; Mon, 23 Sep 2019 04:27:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43061) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOL-0002a6-NT for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOK-0004KP-Kr for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48858) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOK-0004K7-FS; Mon, 23 Sep 2019 04:08:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF1CD356DC; Mon, 23 Sep 2019 08:08:15 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DDBD19C78; Mon, 23 Sep 2019 08:08:13 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 21/30] s390x/tcg: OC: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:03 +0200 Message-Id: <20190923080712.23951-22-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 23 Sep 2019 08:08:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 271b1db664..570e995b77 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -389,17 +389,26 @@ uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, u= int64_t dest, static uint32_t do_helper_oc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - x |=3D cpu_ldub_data_ra(env, dest + i, ra); + /* OC always processes one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca1, i, ra) | + access_get_byte(env, &srca2, i, ra); + c |=3D x; - cpu_stb_data_ra(env, dest + i, x, ra); + access_set_byte(env, &desta, i, x, ra); } return c !=3D 0; } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227413; cv=none; d=zoho.com; s=zohoarc; b=Z1SFkxyyPxDa4RRnVnBnWGu2PyiZ65itAimf7g1RwJHw5ZDN9nRLveCV+wnsrqruUfOni37gbob30Ae1ZuW2CeejqsyA8NRzppfNyrs9EgoIFmYP9rotcPVBV8z8IO/xV0RexvKOPQwXjG3Q/TNReRT9dIO+tc6VLaqfqXpDS1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227413; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zK6pFN4Tdhs0NaUOqAzazyKwuqhFhdsAmoDNP0WeCtc=; b=lIEI78Tu0ggJ2IIZCyktPVmUH6gidoUwh9mWAsudbWtrzlI3KLI8//CinCnXLVlk/ojPpLH1jHZ0iQv1R49jIyjarPGwcupNUEuBKM7f8Hb4iiHlQaM0O7irtB3e9cWGaTVJadaVb5hffdI0x2Ojcu/xy9zc1aFpfDX3Bkb1a9s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227413226910.2820737072251; Mon, 23 Sep 2019 01:30:13 -0700 (PDT) Received: from localhost ([::1]:53594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJjQ-0005yv-Ge for importer@patchew.org; Mon, 23 Sep 2019 04:30:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43097) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJON-0002cn-Ot for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOM-0004Lr-Jn for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOM-0004LE-EL; Mon, 23 Sep 2019 04:08:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7BB72A09DD; Mon, 23 Sep 2019 08:08:17 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1448219D70; Mon, 23 Sep 2019 08:08:15 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 22/30] s390x/tcg: XC: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:04 +0200 Message-Id: <20190923080712.23951-23-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 23 Sep 2019 08:08:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. While at it, increment the length once. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 570e995b77..0d4e0bc45a 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -355,14 +355,19 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint= 32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { const int mmu_idx =3D cpu_mmu_index(env, false); - S390Access desta; + S390Access srca1, srca2, desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - desta =3D access_prepare(env, dest, l + 1, MMU_DATA_STORE, mmu_idx, ra= ); + /* XC always processes one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); =20 /* xor with itself is the same as memset(0) */ if (src =3D=3D dest) { @@ -370,11 +375,12 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint= 32_t l, uint64_t dest, return 0; } =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - x ^=3D cpu_ldub_data_ra(env, dest + i, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca1, i, ra) ^ + access_get_byte(env, &srca2, i, ra); + c |=3D x; - cpu_stb_data_ra(env, dest + i, x, ra); + access_set_byte(env, &desta, i, x, ra); } return c !=3D 0; } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227590; cv=none; d=zoho.com; s=zohoarc; b=bEZvVMCF4C06EciqV95nMiOfoHL3zs8Q7jn5O9QD/It2ox6IaWIgeZGeZBj0JZZ5ZHTCvdg9HUGI+2bwPUkymjjyg0APiUSbXgMEeVIK1c01+MTeENOYaffVpKPa3rQiTN/vEQnggIO/jndtnAa54Og/OHg8BgvxJBKyVz0KG34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227590; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=M68U40wxxIijfRH7D+0KXRCBlUhJ4+Zyd9c7yOs3MWg=; b=PFQJXW1b0Q0Xv0G/2cP3yQRC+24CB80pvCt8/RZOABLuqcaHv7jdiZkPbCsFCtoLxS/WBLnJBOQlbd9rnbGnu59lqtkXlQjhNZ/zk57ojX0h2/58gyhjZ9wU/2D5PSK/XOCenUmcxa7u7XuI+N/aNfHQ2SEVsMgpLDsW2FL9gYw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227590182982.1675404363114; Mon, 23 Sep 2019 01:33:10 -0700 (PDT) Received: from localhost ([::1]:53634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJmL-0000QS-D4 for importer@patchew.org; Mon, 23 Sep 2019 04:33:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43134) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOP-0002f8-P7 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOO-0004Nw-Le for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOO-0004NI-G6; Mon, 23 Sep 2019 04:08:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADDED10CC1F0; Mon, 23 Sep 2019 08:08:19 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0989B19D70; Mon, 23 Sep 2019 08:08:17 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 23/30] s390x/tcg: NC: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:05 +0200 Message-Id: <20190923080712.23951-24-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Mon, 23 Sep 2019 08:08:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 0d4e0bc45a..a97e4aa535 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -329,17 +329,26 @@ static int mmu_idx_from_as(uint8_t as) static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - x &=3D cpu_ldub_data_ra(env, dest + i, ra); + /* NC always processes one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca1, i, ra) & + access_get_byte(env, &srca2, i, ra); + c |=3D x; - cpu_stb_data_ra(env, dest + i, x, ra); + access_set_byte(env, &desta, i, x, ra); } return c !=3D 0; } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227774; cv=none; d=zoho.com; s=zohoarc; b=QDYqxL9ZtQotPWisOgnbO/U7CM6bOW7AJSKwXQBRQpc1bT8BIgV+sHtWtRW+XBy8b1FpfBtti1+C+x99fcVIXrO3hv3MtpWhQyPADkJ5T3PW7CCsqwWnQX6ZLtF4ot/MVcYVESDH4yYGEMd5yYAjNV00zVZcM8E0cyqCUseSFrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227774; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PbUBjBX4+7VL/iDpLkMrcoOwcxxUm7y2P6nhOyu/MoA=; b=kOCNe98YtV9xjhTFzroDCg/Re7QfY+J3fxihuOHS2KXH1jCJkWs0MCVsrnIvUqACUkUxKn1JegDh1sPgykGdfkj+bQ63JQwcJRGbqIT3+khf455H44TwJoITmymC6CMbfcUkOWGetC2RM9DZe3bzk2y/1XzvztxZpeRQteipgr0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156922777451914.737595994186677; Mon, 23 Sep 2019 01:36:14 -0700 (PDT) Received: from localhost ([::1]:53666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJpM-0003Gx-Vh for importer@patchew.org; Mon, 23 Sep 2019 04:36:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43169) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOR-0002he-Ve for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOQ-0004Pm-Hj for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOQ-0004P7-C7; Mon, 23 Sep 2019 04:08:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4272300C76A; Mon, 23 Sep 2019 08:08:21 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0280819C78; Mon, 23 Sep 2019 08:08:19 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 24/30] s390x/tcg: MVCIN: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:06 +0200 Message-Id: <20190923080712.23951-25-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 23 Sep 2019 08:08:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Calculate the accessed range upfront - src is accessed right-to-left. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index a97e4aa535..eeb2552979 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -479,12 +479,21 @@ void HELPER(mvc)(CPUS390XState *env, uint32_t l, uint= 64_t dest, uint64_t src) /* move inverse */ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t= src) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca, desta; uintptr_t ra =3D GETPC(); int i; =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t v =3D cpu_ldub_data_ra(env, src - i, ra); - cpu_stb_data_ra(env, dest + i, v, ra); + /* MVCIN always copies one more byte than specified - maximum is 256 */ + l++; + + src =3D wrap_address(env, src - l + 1); + srca =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca, l - i - 1, ra); + + access_set_byte(env, &desta, i, x, ra); } } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569226979; cv=none; d=zoho.com; s=zohoarc; b=cnMXpjRoLhM3bztIuKlWDAi8ovL/5nR5o6roO0gkL1FE/KG4wTnWryL5pxwUxQ7MdceF2dNGMxRC0LXKV7NoVmh+tR94BTaD+zv8oKPNf+dUgfWosKvpe74xmy/MeyN78ydiYCn/GIzzIGyiP0mRzvDYXUCAN1fQGDNfJk0rWcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569226979; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5eILwePa4NCiGk3hr8tCFO8iFjoGL8a1czVPCLxVlNU=; b=cCs5ZFdT/QQHcdZ3o8Xd1O/RN9YWeXJFh9AcpDgrG6wsOHU1BpmyTRAfwPl4FfTGjTPlI30rCjyEZYb7Mqux83XQyblllnZH+rSokqHnG3KFynBgLEZFSHAFMr6U6iLdmxH+pXzoQd+U7IhCHxCmhqcAf9dsbt6jNTPGJPRe1SA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569226979673317.07214450421304; Mon, 23 Sep 2019 01:22:59 -0700 (PDT) Received: from localhost ([::1]:53518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJcY-0006yC-EU for importer@patchew.org; Mon, 23 Sep 2019 04:22:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43193) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOT-0002js-PL for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOS-0004Rr-Iy for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOS-0004RG-Dk; Mon, 23 Sep 2019 04:08:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D4043084029; Mon, 23 Sep 2019 08:08:23 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB8CF19C78; Mon, 23 Sep 2019 08:08:21 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 25/30] s390x/tcg: MVN: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:07 +0200 Message-Id: <20190923080712.23951-26-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 23 Sep 2019 08:08:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index eeb2552979..7c981f7902 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -500,13 +500,22 @@ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, ui= nt64_t dest, uint64_t src) /* move numerics */ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t s= rc) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uintptr_t ra =3D GETPC(); int i; =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t v =3D cpu_ldub_data_ra(env, dest + i, ra) & 0xf0; - v |=3D cpu_ldub_data_ra(env, src + i, ra) & 0x0f; - cpu_stb_data_ra(env, dest + i, v, ra); + /* MVN always copies one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D (access_get_byte(env, &srca1, i, ra) & 0x0f) | + (access_get_byte(env, &srca2, i, ra) & 0xf0); + + access_set_byte(env, &desta, i, x, ra); } } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569228469; cv=none; d=zoho.com; s=zohoarc; b=GEQHF7Kac9Y0wr/sYvkFaRR+sG5UeCvOgkDwxl+S9LmWrGq3OQE80gE3l06JODpJYTKr+V8yK5ZZbwDWdjLPw9UpAflU84ur+fgCXbfCZXkZs0z2J7kFJVGo493TsJCiT9LS+K27hmJYGGaEEDAbd9WkufLT2rTs18+SB+GAv7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569228469; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lccahSsgIaHiEexQwH280iQQdHJZetN0Lv06aolGsP8=; b=kmEzI3Y9VXMBpMhhizeb9CITpmGG18QkzAthRt25645plWk23+ZSAzE1JgEqQvNb2YJh+t2/7qRDcIX5P+lan1HhVo6Db2jmX5ynB6DBbNcmUe6iV0nqrbW7SlGjPIvsGJjmYJpxVw0n/2Sbrz2MC/JM/3xgy6/Jxy1oU++h9KY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156922846962198.01998288843401; Mon, 23 Sep 2019 01:47:49 -0700 (PDT) Received: from localhost ([::1]:53792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCK0W-000676-CK for importer@patchew.org; Mon, 23 Sep 2019 04:47:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43219) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOV-0002oP-Jh for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOU-0004TE-EX for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53742) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOU-0004Ss-9M; Mon, 23 Sep 2019 04:08:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 911B310C092E; Mon, 23 Sep 2019 08:08:25 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id E46D519C78; Mon, 23 Sep 2019 08:08:23 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 26/30] s390x/tcg: MVZ: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:08 +0200 Message-Id: <20190923080712.23951-27-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Mon, 23 Sep 2019 08:08:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 7c981f7902..b781362e16 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -553,13 +553,22 @@ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint= 64_t dest, uint64_t src) /* move zones */ void HELPER(mvz)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t s= rc) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uintptr_t ra =3D GETPC(); int i; =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t b =3D cpu_ldub_data_ra(env, dest + i, ra) & 0x0f; - b |=3D cpu_ldub_data_ra(env, src + i, ra) & 0xf0; - cpu_stb_data_ra(env, dest + i, b, ra); + /* MVZ always copies one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D (access_get_byte(env, &srca1, i, ra) & 0xf0) | + (access_get_byte(env, &srca2, i, ra) & 0x0f); + + access_set_byte(env, &desta, i, x, ra); } } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227936; cv=none; d=zoho.com; s=zohoarc; b=nYBv8v5qd0ncIovhw0xdlzSAkUNXygtQ7tGXsQ3v7jXy+YbzEfj6KxDgyMQD+6ex6uArhz1lFkKiH91QGbya4R4UoQvIfcU6ZVBvNjcmdnfAttOa4a3cm/08UapEKIH4NOi8eoFRQT5YdniE++cLa/rQBcL6nHZqHpF4QTM55LM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227936; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yI56hFiJf6LO9TAJQNZL1hm1ME70qCh4joadyUqqejM=; b=oERVUn7Kfb1LQJmlkP5JXx2VS88Oe8fRCZLKnQD6vcQg53zUYHNKxgo3x8TJu3pbqNsuC0l7VwdhGJzUi4mqo8wHR8fo2cLuWZxa3nTSwN6qtA3+zTvL8+NGAj4ZJhZEYxCaUYqXFcczMnIK42iUwOcxHEg5FiB8/c+bUUvA5vg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15692279361401015.3628744926569; Mon, 23 Sep 2019 01:38:56 -0700 (PDT) Received: from localhost ([::1]:53692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJrw-00060G-PB for importer@patchew.org; Mon, 23 Sep 2019 04:38:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43243) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOX-0002qr-Hg for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOW-0004UA-E4 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOW-0004Tr-8Y; Mon, 23 Sep 2019 04:08:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 895A718C8921; Mon, 23 Sep 2019 08:08:27 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB92119C78; Mon, 23 Sep 2019 08:08:25 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 27/30] s390x/tcg: MVST: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:09 +0200 Message-Id: <20190923080712.23951-28-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Mon, 23 Sep 2019 08:08:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Access at most single pages and document why. Using the access helpers might over-indicate watchpoints within the same page, I guess we can live with that. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b781362e16..4a4b4ea0b7 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -866,23 +866,33 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0= , uint64_t r1, uint64_t r2) /* string copy */ uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2) { + const int mmu_idx =3D cpu_mmu_index(env, false); const uint64_t d =3D get_address(env, r1); const uint64_t s =3D get_address(env, r2); const uint8_t c =3D env->regs[0]; + const int len =3D MIN(-(d | TARGET_PAGE_MASK), -(s | TARGET_PAGE_MASK)= ); + S390Access srca, desta; uintptr_t ra =3D GETPC(); - uint32_t len; + int i; =20 if (env->regs[0] & 0xffffff00ull) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); } =20 - /* Lest we fail to service interrupts in a timely manner, limit the - amount of work we're willing to do. For now, let's cap at 8k. */ - for (len =3D 0; len < 0x2000; ++len) { - uint8_t v =3D cpu_ldub_data_ra(env, s + len, ra); - cpu_stb_data_ra(env, d + len, v, ra); + /* + * Our access should not exceed single pages, as we must not report ac= cess + * exceptions exceeding the actually copied range (which we don't know= at + * this point). We might over-indicate watchpoints within the pages + * (if we ever care, we have to limit processing to a single byte). + */ + srca =3D access_prepare(env, s, len, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, d, len, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < len; i++) { + const uint8_t v =3D access_get_byte(env, &srca, i, ra); + + access_set_byte(env, &desta, i, v, ra); if (v =3D=3D c) { - set_address_zero(env, r1, d + len); + set_address_zero(env, r1, d + i); return 1; } } --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569228070; cv=none; d=zoho.com; s=zohoarc; b=PupERkmFdklTdcjzaX+uCuGW5RjKRrB/o4jws6eJ+C5FLhItKFmLj/Nw8uECsrUQlQUYt1OACHRRjzcnaMRAmwbdtRbmfUBIvNCRj05VyO/7oOFZDq/02IoZRl4SqUqiI5qp7DTKj2VW4MU797FLHhPiobka+cjlQ8DoJVOKsM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569228070; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iHuM692jaigi6OS57463DeQCglYcOl5ctl1dnzG4lgk=; b=g/Y/wsbAeqeLYPAeDMMR1V1RSd2U6Tpq7JD6tyJpkke1nDehyUzPdWR/xptgsZmnenGzNvqwm8jeP3vXeoRL9hcz59VOVh+uW4Y02hhv7NdhWU0sbut6IkqnaBwrCUhJHlILYpUWIaQ7et8ykDTUHAIR8VrBpwZ27Ji97OKpHy4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569228070908145.31290824020653; Mon, 23 Sep 2019 01:41:10 -0700 (PDT) Received: from localhost ([::1]:53714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJu9-0000Id-PB for importer@patchew.org; Mon, 23 Sep 2019 04:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43265) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOa-0002uT-P0 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOZ-0004VE-DN for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOZ-0004Uh-87; Mon, 23 Sep 2019 04:08:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85A062A09BA; Mon, 23 Sep 2019 08:08:29 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1AB019C78; Mon, 23 Sep 2019 08:08:27 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 28/30] s390x/tcg: MVO: Fault-safe handling Date: Mon, 23 Sep 2019 10:07:10 +0200 Message-Id: <20190923080712.23951-29-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 23 Sep 2019 08:08:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Each operand can have a maximum length of 16. Make sure to prepare all reads/writes before writing. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 4a4b4ea0b7..44e535856d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -522,31 +522,34 @@ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint= 64_t dest, uint64_t src) /* move with offset */ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t s= rc) { + const int mmu_idx =3D cpu_mmu_index(env, false); + /* MVO always processes one more byte than specified - maximum is 16 */ + const int len_dest =3D (l >> 4) + 1; + const int len_src =3D (l & 0xf) + 1; uintptr_t ra =3D GETPC(); - int len_dest =3D l >> 4; - int len_src =3D l & 0xf; uint8_t byte_dest, byte_src; - int i; + S390Access srca, desta; + int i, j; =20 - src +=3D len_src; - dest +=3D len_dest; + srca =3D access_prepare(env, src, len_src, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, len_dest, MMU_DATA_STORE, mmu_idx,= ra); =20 /* Handle rightmost byte */ - byte_src =3D cpu_ldub_data_ra(env, src, ra); - byte_dest =3D cpu_ldub_data_ra(env, dest, ra); + byte_dest =3D cpu_ldub_data_ra(env, dest + len_dest - 1, ra); + byte_src =3D access_get_byte(env, &srca, len_src - 1, ra); byte_dest =3D (byte_dest & 0x0f) | (byte_src << 4); - cpu_stb_data_ra(env, dest, byte_dest, ra); + access_set_byte(env, &desta, len_dest - 1, byte_dest, ra); =20 /* Process remaining bytes from right to left */ - for (i =3D 1; i <=3D len_dest; i++) { + for (i =3D len_dest - 2, j =3D len_src - 2; i >=3D 0; i--, j--) { byte_dest =3D byte_src >> 4; - if (len_src - i >=3D 0) { - byte_src =3D cpu_ldub_data_ra(env, src - i, ra); + if (j >=3D 0) { + byte_src =3D access_get_byte(env, &srca, j, ra); } else { byte_src =3D 0; } byte_dest |=3D byte_src << 4; - cpu_stb_data_ra(env, dest - i, byte_dest, ra); + access_set_byte(env, &desta, i, byte_dest, ra); } } =20 --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569228189; cv=none; d=zoho.com; s=zohoarc; b=ip1eB3EKxCDthecqxzdqKNbn5Kq9Txjahlx28Gny0ekJT7d/0hDHuxUYFGPMApN3dP7ZHfY/h4xUJK7r++KxysVf1+IPYEl3WOcNDjz79xMQuAN01/LqGGYlGBaqxZFB8mY9R+8VlCi24oA9Lk1trsRVfKJhEdWeNlSLsMv829M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569228189; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XAN/VzT+VivUDatw02nm27pcStCXBbcXAHRcdQgLlC8=; b=Ovw0iOnfiyRyFDB1WWlPg4WEvgDQFfPYAHuIBqimGXQZCFWc5Yf6Hluh/Lg+ojn6D3auV7rtoCX9Oi45f9fmO1zy3/pDLVQ3pnGBsARYmWorVo+7UEfc+G7tAh2T8js+FmBv+Guc3DCP5fu3pM7GgZN/Q1fNSBHtXnposaCbsUA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15692281890701001.9785524230156; Mon, 23 Sep 2019 01:43:09 -0700 (PDT) Received: from localhost ([::1]:53742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJw3-0002k1-L8 for importer@patchew.org; Mon, 23 Sep 2019 04:43:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43305) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOe-0002yu-I1 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOd-0004Wk-7X for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOd-0004WM-2L; Mon, 23 Sep 2019 04:08:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55995C0546FB; Mon, 23 Sep 2019 08:08:34 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE9C719C78; Mon, 23 Sep 2019 08:08:29 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 29/30] tests/tcg: target/s390x: Test MVO Date: Mon, 23 Sep 2019 10:07:11 +0200 Message-Id: <20190923080712.23951-30-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 23 Sep 2019 08:08:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's add the simple test based on the example from the PoP. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: David Hildenbrand --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/mvo.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/tcg/s390x/mvo.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 151dc075aa..6a3bfa8b29 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -6,3 +6,4 @@ TESTS+=3Dipm TESTS+=3Dexrl-trt TESTS+=3Dexrl-trtr TESTS+=3Dpack +TESTS+=3Dmvo diff --git a/tests/tcg/s390x/mvo.c b/tests/tcg/s390x/mvo.c new file mode 100644 index 0000000000..5546fe2a97 --- /dev/null +++ b/tests/tcg/s390x/mvo.c @@ -0,0 +1,25 @@ +#include +#include + +int main(void) +{ + uint8_t dest[6] =3D {0xff, 0x77, 0x88, 0x99, 0x0c, 0xff}; + uint8_t src[5] =3D {0xee, 0x12, 0x34, 0x56, 0xee}; + uint8_t expected[6] =3D {0xff, 0x01, 0x23, 0x45, 0x6c, 0xff}; + int i; + + asm volatile ( + " mvo 0(4,%[dest]),0(3,%[src])\n" + : + : [dest] "d" (dest + 1), + [src] "d" (src + 1) + : "memory"); + + for (i =3D 0; i < sizeof(expected); i++) { + if (dest[i] !=3D expected[i]) { + fprintf(stderr, "bad data\n"); + return 1; + } + } + return 0; +} --=20 2.21.0 From nobody Sat May 4 03:38:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569227283; cv=none; d=zoho.com; s=zohoarc; b=l4mcNtRyYW3ucV3KhqIb4vZfpP0k7GlSETFiBPOqpGHYaA2MS0K0Pplw2NHVZ65IVC6CpqrD5epEb7gIK/C3ep/k8RXT5TEhV/S0T9v1klpKTyFvWWaffuTdcmdufk7hHQSX1EIVBmXp9kf0GS1ljAESo4h3COWjy9O6Q+fA/i8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569227283; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VbgNLxXziD9k87Kx1FPNgL0tiWRxvOk51VxjQ39AGao=; b=Bsoyk45VmvmlLn2vpj1GociBcD9uqJrM+6UuA7u4bbZzRM+MBuQvw+L+Uj+FzEAsseVL4L+QI25/dtInLGyEG7igzGuAclvISYesxifRHW5cJxTOTZs2MSBPOFUnFYUGPL2Y4Jy2zA3+DjCQ6jQTQc/yIWr5VSHmvxkRjAKk6Ms= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569227283332270.3114934829292; Mon, 23 Sep 2019 01:28:03 -0700 (PDT) Received: from localhost ([::1]:53576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJhR-0003nS-Dm for importer@patchew.org; Mon, 23 Sep 2019 04:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43322) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJOg-00031i-Qd for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJOf-0004Xi-DU for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:08:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCJOf-0004XR-5l; Mon, 23 Sep 2019 04:08:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7881D300C76A; Mon, 23 Sep 2019 08:08:36 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DBFA196B2; Mon, 23 Sep 2019 08:08:34 +0000 (UTC) From: David Hildenbrand To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 30/30] tests/tcg: target/s390x: Test MVC Date: Mon, 23 Sep 2019 10:07:12 +0200 Message-Id: <20190923080712.23951-31-david@redhat.com> In-Reply-To: <20190923080712.23951-1-david@redhat.com> References: <20190923080712.23951-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 23 Sep 2019 08:08:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's add a test that especially verifies that no data will be touched in case we cross page boundaries and one page access triggers a fault. Before the fault-safe handling fixes, the test failes with: TEST mvc on s390x data modified during a fault make[2]: *** [../Makefile.target:116: run-mvc] Error 1 Acked-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/mvc.c | 109 ++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 tests/tcg/s390x/mvc.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 6a3bfa8b29..241ef28f61 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -7,3 +7,4 @@ TESTS+=3Dexrl-trt TESTS+=3Dexrl-trtr TESTS+=3Dpack TESTS+=3Dmvo +TESTS+=3Dmvc diff --git a/tests/tcg/s390x/mvc.c b/tests/tcg/s390x/mvc.c new file mode 100644 index 0000000000..aa552d52e5 --- /dev/null +++ b/tests/tcg/s390x/mvc.c @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include +#include +#include + +jmp_buf jmp_env; + +static void handle_sigsegv(int sig) +{ + siglongjmp(jmp_env, 1); +} + +#define ALLOC_SIZE (2 * 4096) + +static inline void mvc_256(const char *dst, const char *src) +{ + asm volatile ( + " mvc 0(256,%[dst]),0(%[src])\n" + : + : [dst] "d" (dst), + [src] "d" (src) + : "memory"); +} + +int main(void) +{ + char *src, *dst; + int i; + + /* register the SIGSEGV handler */ + if (signal(SIGSEGV, handle_sigsegv) =3D=3D SIG_ERR) { + fprintf(stderr, "SIGSEGV not registered\n"); + return 1; + } + + /* prepare the buffers - two consecutive pages */ + src =3D valloc(ALLOC_SIZE); + dst =3D valloc(ALLOC_SIZE); + memset(src, 0xff, ALLOC_SIZE); + memset(dst, 0x0, ALLOC_SIZE); + + /* protect the second pages */ + if (mprotect(src + 4096, 4096, PROT_NONE) || + mprotect(dst + 4096, 4096, PROT_NONE)) { + fprintf(stderr, "mprotect failed\n"); + return 1; + } + + /* fault on second destination page */ + if (sigsetjmp(jmp_env, 1) =3D=3D 0) { + mvc_256(dst + 4096 - 128, src); + fprintf(stderr, "fault not triggered\n"); + return 1; + } + + /* fault on second source page */ + if (sigsetjmp(jmp_env, 1) =3D=3D 0) { + mvc_256(dst, src + 4096 - 128); + fprintf(stderr, "fault not triggered\n"); + return 1; + } + + /* fault on second source and second destination page */ + if (sigsetjmp(jmp_env, 1) =3D=3D 0) { + mvc_256(dst + 4096 - 128, src + 4096 - 128); + fprintf(stderr, "fault not triggered\n"); + return 1; + } + + /* restore permissions */ + if (mprotect(src + 4096, 4096, PROT_READ | PROT_WRITE) || + mprotect(dst + 4096, 4096, PROT_READ | PROT_WRITE)) { + fprintf(stderr, "mprotect failed\n"); + return 1; + } + + /* no data must be touched during the faults */ + for (i =3D 0; i < ALLOC_SIZE; i++) { + if (src[i] !=3D 0xff || dst[i]) { + fprintf(stderr, "data modified during a fault\n"); + return 1; + } + } + + /* test if MVC works now correctly accross page boundaries */ + mvc_256(dst + 4096 - 128, src + 4096 - 128); + for (i =3D 0; i < ALLOC_SIZE; i++) { + if (src[i] !=3D 0xff) { + fprintf(stderr, "src modified\n"); + return 1; + } + if (i < 4096 - 128 || i >=3D 4096 + 128) { + if (dst[i]) { + fprintf(stderr, "wrong dst modified\n"); + return 1; + } + } else { + if (dst[i] !=3D 0xff) { + fprintf(stderr, "wrong data moved\n"); + return 1; + } + } + } + + return 0; +} --=20 2.21.0