From nobody Sat May 4 02:51:47 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=1567756811; cv=none; d=zoho.com; s=zohoarc; b=e/UFReIH9YwmcdZe3naLBrPbZcsERa7o5gZ1QRqTFode824QB2f9bPG6LWs+b7aUFZh5tMOqqbrCwhGSVj+o4T8Wiw32sScVzIok4v0zOxRrfT9rKDy0Qs+tCaIPWsPsfDqiJEr71bNuAOO0FutULHJCcOg6nNv64dwGZqzQVPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567756811; 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=ww2RSsoTkkASqQclaV3rN4IolRdJCxdU/MEdGPSWPdI=; b=HJrooVUFySTpcbeIqnel6JVh/XJCISwKQzHBnbQHYvxABs+EBXypXDQYibMfN+/VomfTrQIa5PWF9heHu+pwO2Yy0iUIcVkLLn1ra85bsvinJTEeXxWA5X/6BKi6I9uJVraIZWsDffsG20n/RAIoxwHvfJU9bQQWJB0H6nkFeAY= 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 1567756811123583.2673282048394; Fri, 6 Sep 2019 01:00:11 -0700 (PDT) Received: from localhost ([::1]:53170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69A3-00053G-98 for importer@patchew.org; Fri, 06 Sep 2019 04:00:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41869) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6984-0003Ji-Mj for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6983-0002av-JC for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6983-0002aG-Cp; Fri, 06 Sep 2019 03:57:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B110F3175284; Fri, 6 Sep 2019 07:57:58 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC61E1001955; Fri, 6 Sep 2019 07:57:55 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:23 +0200 Message-Id: <20190906075750.14791-2-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 06 Sep 2019 07:57:58 +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 Subject: [Qemu-devel] [PATCH v2 01/28] s390x/tcg: Reset exception_index to -1 instead of 0 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 02:51:47 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=1567757003; cv=none; d=zoho.com; s=zohoarc; b=AuKLzFTd/+dk2bj8iOBbq/wWMavPN7fgsHvA9v/9WstLg8gd++aUQwlCHrK1x9HQvPZzq9/vPSGaj1pUQL452Zndzja3ElRfbKKq+tJODEVa1NjDKn/ISZsldNoCZJLSC9OSGWZ8Ua1/1xBvLYDbnnMpalGcEyUgl55PGfqQC90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757003; 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=yvjTIkTw/vplcNd260w9IidNiTMifu3VC4KqvEUxUyQ=; b=oQsuMCgGBxJCUE3gINJRbzYD1C1KLsW9xeNFzgxOK++GTmsDhTs1Gv3KztbBLU2e0qBeZQy44VrjnCwmzMuDFIFujwsIsNaVVaXAFNzKQeXeTmlm+6ej/FFGXcq90L7VBEBO7yWX3bUKGcDlASrvq6zlAhu7LFIj7ksfpmUXv4c= 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 1567757003310415.749903075647; Fri, 6 Sep 2019 01:03:23 -0700 (PDT) Received: from localhost ([::1]:53208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69DF-0000Dp-M2 for importer@patchew.org; Fri, 06 Sep 2019 04:03:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41913) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6987-0003LJ-2g for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6986-0002dN-0R for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6985-0002cl-QI; Fri, 06 Sep 2019 03:58:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A714C3086246; Fri, 6 Sep 2019 07:58:00 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 059C81001955; Fri, 6 Sep 2019 07:57:58 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:24 +0200 Message-Id: <20190906075750.14791-3-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 06 Sep 2019 07:58:01 +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 Subject: [Qemu-devel] [PATCH v2 02/28] s390x/tcg: MVCL: Zero out unused bits of address 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 39ee9b3175..3152bdafe2 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -469,6 +469,26 @@ 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; + env->regs[reg] =3D deposit64(env->regs[reg], 0, 32, address); + } 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 +792,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 02:51:47 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=1567757000; cv=none; d=zoho.com; s=zohoarc; b=QAUG1dtFESQY8dRFcHEeiG/QU2O4KTKPlF8Kr1j2mXvdeoVo7SJWLgmbItbAcPVQPjEkbeZx4xXgBqzFphb5yAb5bg62OCnP50lCxiIygf+2IAGo9mggU9e2h7Uhvw5S/G+jQkmD0b+HPamSNmW+pr+nI/tL9a2QwDtvGdRrNOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757000; 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=B/gpWRZ1q2gou4k2hqoP6Qitdi8EWZPdUHE8mQ9X7TY=; b=GzEmsObKtFcxyOPs2HSIz2cbpoh3EYmGb/CNMW3slUWaxIoJ6EK4ZdulvGl8oHKc9LA30brvV418C8DzX6oNqQydPDMd3Jpd8E6cHtxFCWO9txT2tnyE6p2bhqFSbLfknD9x1p03/xBIWWwizcQ64Uwo6KruWU5RGNEXvZLyPpk= 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 1567757000558344.22691186551697; Fri, 6 Sep 2019 01:03:20 -0700 (PDT) Received: from localhost ([::1]:53206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69DC-000096-L7 for importer@patchew.org; Fri, 06 Sep 2019 04:03:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41940) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6988-0003Na-Tq for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6987-0002ff-Mq for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6987-0002e2-AL; Fri, 06 Sep 2019 03:58:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 995DC3082B43; Fri, 6 Sep 2019 07:58:02 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED4351001B05; Fri, 6 Sep 2019 07:58:00 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:25 +0200 Message-Id: <20190906075750.14791-4-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 06 Sep 2019 07:58:02 +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 Subject: [Qemu-devel] [PATCH v2 03/28] s390x/tcg: MVCL: Detect destructive overlaps 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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 amke sure to write the addresses back. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 3152bdafe2..2361ed6d54 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) { @@ -788,7 +801,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 02:51:47 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=1567757206; cv=none; d=zoho.com; s=zohoarc; b=M68Sz1B57v/n+h8QBKpVKJwuSY265aI9y+hApbb36ZbatV4132mxl3ZB9y45CMs0hPh0GySvYYsDJDsF6Yx9QP2yfoeE6zyLjAYep7MHQD1iZQSTa+hwoY0a2fnPnpuSV1tigOljlG/GNetdfZhFQB2TanUbvDj01pOLFjGJ0Uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757206; 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=Qnx65KDi4rKAPFeKLylT7LVbmP/Fux5hV2Cyo5DTIMo=; b=AiTLNDcq9ICVZJVtWFgjLojIE1q/mSyMuxWZcR8fuvqOMQ91D8qDbZy4D9dbx4aj/iWWKH4a9f5NH4bZhlJcmFVvD3gkrsBnSDVFmkA7zzhajnuPXCvnRypqnvpq8Ri8mA8hYlF6CnbLGdXdinPy+zVl83aFBFpGzYAL8aoQqB8= 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 1567757206667229.68815307622663; Fri, 6 Sep 2019 01:06:46 -0700 (PDT) Received: from localhost ([::1]:53238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69GM-0003t5-8o for importer@patchew.org; Fri, 06 Sep 2019 04:06:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41966) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698A-0003Qg-U1 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6989-0002k0-JT for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6989-0002hM-8d; Fri, 06 Sep 2019 03:58:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89819C05683F; Fri, 6 Sep 2019 07:58:04 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id E00E010002B8; Fri, 6 Sep 2019 07:58:02 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:26 +0200 Message-Id: <20190906075750.14791-5-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 06 Sep 2019 07:58:04 +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 Subject: [Qemu-devel] [PATCH v2 04/28] s390x/tcg: MVCL: Process max 2k bytes at a time 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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 2k 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." MVCL handling is quite different than MVCLE/MVCLU handling, so split up the handlers. We'll deal with fast_memmove() and fast_memset() not probing reads/writes properly later. Also, we'll defer interrupt handling, as that will require more thought, add a TODO for that. 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 2361ed6d54..2e22c183bd 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -799,19 +799,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. + * Process up to 2k bytes. + */ + while (destlen) { + cur_len =3D MIN(destlen, 2048); + if (!srclen) { + fast_memset(env, dest, pad, cur_len, ra); + } else { + cur_len =3D MIN(cur_len, srclen); + + 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 02:51:47 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=1567756824; cv=none; d=zoho.com; s=zohoarc; b=YfxfpOxQjdIUDQt6Wqs7qW1h3lqmT2VcMybg7/xPsAaFQbevqSoU88kVmkyJ/NapGhXPVtlgKKHfV0evBkGWsgdyD2e8PjtDrePI0IPOHZmcFn/8jr2hTb9jRKQzgPMhq9drrzxid6906XmIR3WvAwIVjkJdktLtPZ9a/8KULfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567756824; 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=Ich/ncMwKrE5NxKtBHaK3mtxr1ipTIcEzjijh09Z+mk=; b=niz0xHXglj0u0T4EneWLLJZHIGs2AQ5UFGnhm3eqh0x+QmTYMhBSoLnSykrptgvRfNOGnyMuRgzJEX5APuv56j6DuaEUfLbzALzpaoxUtNNcdTZj+eYBtTF6EejGTGD7hhiz6wYLGPREqBq5Gn/5ctNDFuVU0Jr8R2JEAlcLG1E= 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 1567756824590962.3262574639738; Fri, 6 Sep 2019 01:00:24 -0700 (PDT) Received: from localhost ([::1]:53172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69AK-0005JG-CL for importer@patchew.org; Fri, 06 Sep 2019 04:00:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41995) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698C-0003T0-Pn for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698B-0002nu-IL for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698B-0002mM-C0; Fri, 06 Sep 2019 03:58:07 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A31D6307D930; Fri, 6 Sep 2019 07:58:06 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id D26611001B00; Fri, 6 Sep 2019 07:58:04 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:27 +0200 Message-Id: <20190906075750.14791-6-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 06 Sep 2019 07:58:06 +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 Subject: [Qemu-devel] [PATCH v2 05/28] s390x/tcg: MVC: Increment the length once 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , Stefano Brivio , 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 2e22c183bd..2bc2cd09c1 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 02:51:47 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=1567757368; cv=none; d=zoho.com; s=zohoarc; b=OY65d9jL5rj2Y+y11/9tyqU3+WGkDkNFgfzdc7KFdnBEZtDQwkzAC/d+e3D9r57mqo9i5l2pQLodDNI9HYPXn7Q7Y0FmKME5u7dwQb91JOVFqVkR9Nv92co3iqz1RMvFVGelDFyOgC3CPZcTO1YX4it9RzONwPdeBYL5odb6AHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757368; 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=vOjldbX52UW0ocTVvZpqMzlQKX59dHOPQl7d6n8zO/g=; b=K4zBAF6HK91AeP+10jtkMco2uQd4ON68LOnXjpI0PIMrLW5yO99eRnvSfiC6ioQln2K1jIH+EvtoEMxnDGwGmTLJYE12+vwi4jO3d4jjYJu93zw8CIQr7OB6N+j7MVSEjpMud8etxqLozCxdD3ZNr5KHE+xo6o99x37g0DUapS0= 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 1567757368760755.9239516672118; Fri, 6 Sep 2019 01:09:28 -0700 (PDT) Received: from localhost ([::1]:53280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69J7-0007Rn-SD for importer@patchew.org; Fri, 06 Sep 2019 04:09:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698F-0003WB-1Y for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698D-0002rj-ON for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698D-0002qF-Dj; Fri, 06 Sep 2019 03:58:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96EEC315C00D; Fri, 6 Sep 2019 07:58:08 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED2221000321; Fri, 6 Sep 2019 07:58:06 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:28 +0200 Message-Id: <20190906075750.14791-7-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 06 Sep 2019 07:58:08 +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 Subject: [Qemu-devel] [PATCH v2 06/28] s390x/tcg: MVC: Use is_destructive_overlap() 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 2bc2cd09c1..3c23c403cd 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 02:51:47 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=1567757247; cv=none; d=zoho.com; s=zohoarc; b=dk+UyLGhYn+D9M7lwf5kk8HebwtuPenQPjFeMF1nb6TvTZn/WST/RLLhlPQe4m/UGjGsP9ZZa2/cS2C6BN7cTUS27EDLOqajs9ndfVFnwHTeip1+34lDasPz9rklKugdZzyucAqsKtj4w0LUdnxMClOyezBJZwjweWOrWrL/NWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757247; 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=ubd1eJHdH1Gmj+LMjykhPzGqP9RJ6sMLrRdfY0V5bUg=; b=EONcduduP7A2zzzIK2u4GePTmvnKHGkbRroKi7CEn1Xg1TjP/DyY+SCYpIM/uWWwVCWfO8F/0LrYf83ffEJjEBOSJpVI/j1taeUtbLSqrLR16o6Vi12A7Duun9zCQRrds9ioTX0RstcBGIBSA7xEctxJ8I2HbzlmKJRZT7LwNdI= 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 1567757247598651.4211249399301; Fri, 6 Sep 2019 01:07:27 -0700 (PDT) Received: from localhost ([::1]:53244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69HB-0005CG-Ub for importer@patchew.org; Fri, 06 Sep 2019 04:07:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42074) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698K-0003dp-P9 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698J-00032L-OM for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33496) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698J-00030f-Id; Fri, 06 Sep 2019 03:58:15 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DADC918C4271; Fri, 6 Sep 2019 07:58:14 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFD591001284; Fri, 6 Sep 2019 07:58:08 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:29 +0200 Message-Id: <20190906075750.14791-8-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Fri, 06 Sep 2019 07:58:14 +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 Subject: [Qemu-devel] [PATCH v2 07/28] s390x/tcg: MVPG: Check for specification exceptions 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 3c23c403cd..a763482ae0 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -673,6 +673,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 02:51:47 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=1567756842; cv=none; d=zoho.com; s=zohoarc; b=Hxr62s2S/szYnmGAISsBK1OMPpR3sIrJ/YG72rWKwL522gg6OtfB9rSNT7YBuMoAspMFpglSpAEz1tReLxkkbAoRJn+I887qVHbBRqDY0x9CEwStsANAlP1G3HNH8e2P7iPOQ9sChFv+RE4SAMHB/As5SqW4rAfXSOOBd1a4Djs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567756842; 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=CO8jbkfuxscHFbkH01SqAimBTlGM4pHiQQ1NsX2WxnA=; b=HcRmXRJjTo61b3UECBynFOjk3Zrsj+RWA+jLq14iZgr9amFWw7127dU5bQjB64rUO4Gp8hrhMRDpl3XWZmEa1Ty0/hpBe8K1WDjyOGEadz0kk2w0jSQMzktmKONhBy9ri3GpF6R2DYNYs12mpMV2ZieZWaUNMRE1WBzrppTnGX8= 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 1567756842105548.5659737373403; Fri, 6 Sep 2019 01:00:42 -0700 (PDT) Received: from localhost ([::1]:53174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Ab-0005eb-TB for importer@patchew.org; Fri, 06 Sep 2019 04:00:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42107) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698O-0003jC-GI for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698N-00039M-GI for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27743) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698N-00038D-AV; Fri, 06 Sep 2019 03:58:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A13BC308FC20; Fri, 6 Sep 2019 07:58:18 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 301021001B00; Fri, 6 Sep 2019 07:58:15 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:30 +0200 Message-Id: <20190906075750.14791-9-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 08/28] s390x/tcg: MVPG: Properly wrap the addresses 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 a763482ae0..947a4277f0 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -680,8 +680,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 02:51:47 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=1567757020; cv=none; d=zoho.com; s=zohoarc; b=mC5Ev/RRRznJjX1bFVARXR7PnbY92sgTjH8QRpZ9+/3sCk94vPrZ9zIQyvXs8X5U2r2kshQ+Cy1aMxV+zNMDQDY3bV3S0k5HSyDUzrQQ4X8kxGftTp1l7rXk0IwtwteZ8pxFmA76ZQ7pm/CpTJc01E1N3lY/oYja0sOtvWSoS3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757020; 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=NDkdgWilQqNV/dGdGf7fEaOYX1X1NLP5sHpKAf0O+H4=; b=FwE0NBBevDQnceugYw9dHswRb8YlER3YEbRjt0OQaJnn8hyFKferE+Ner+YHbEXGnMbOqElhk/CxqCwxC1Q4yDtHAOIi40GBQtu7dOE8EE3vKwIqS4aP/yS28DQ3zlNYCGORk7K7kl50krwBMptc0vs42GloBSXbhupvhocIpJg= 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 1567757020065567.5470486480204; Fri, 6 Sep 2019 01:03:40 -0700 (PDT) Received: from localhost ([::1]:53210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69DW-0000a7-FA for importer@patchew.org; Fri, 06 Sep 2019 04:03:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42129) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698Q-0003mN-TD for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698P-0003DH-KY for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33782) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698P-0003BU-8o; Fri, 06 Sep 2019 03:58:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 934C84E924; Fri, 6 Sep 2019 07:58:20 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id E91811001284; Fri, 6 Sep 2019 07:58:18 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:31 +0200 Message-Id: <20190906075750.14791-10-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 09/28] s390x/tcg: MVCLU/MVCLE: Process max 4k bytes at a time 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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 indicate cc=3D3 in case there is work remaining. Keep unicode padding simple. While reworking, properly wrap the addresses. 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 947a4277f0..6d8ebd18fa 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -769,8 +769,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, TARGET_PAGE_SIZE); + int i, cc; =20 if (*destlen =3D=3D *srclen) { cc =3D 0; @@ -780,32 +780,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. + * Process up to 4k bytes. + */ + if (*srclen) { + /* Copy the src array */ + len =3D MIN(len, *srclen); + *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 02:51:47 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=1567757033; cv=none; d=zoho.com; s=zohoarc; b=V9bWsCXW6OSbQq5MWyRUhfg9F5j8C3+KPzWylHapjPrFd+jxO/gRfuYOlC9t/QiWNvEHw6wtFRGfPD7GsS9x7j03g+CVaRmglz7kX3FVdZ5KHbGdCPVTYNSAX2GqO52RriK5i0Z41kWetlPXN9V0OAQowTJIWcQnhbvejl2Jhuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757033; 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=5yU1ytLMVPHCVJ001Se3d21mh1gT9dL6M6COoK4K5rk=; b=VmOowq+MbG1HbDHmOTWqPE/I3ENYEs9AARUFenyjot5ImEPwMiJo+C9zhkCybLI+oe7VM2dSy5ATrYh5kypcjz34/eDcew3imZunvqZqMY81s4qTeRElpU3OU0iWLRzXL3vvrC5E70/Cc4bwb0V5H6U+ML+Rs7Mh/IqSvD8pFeg= 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 1567757033525124.33081213188154; Fri, 6 Sep 2019 01:03:53 -0700 (PDT) Received: from localhost ([::1]:53212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Dj-0000pE-Bq for importer@patchew.org; Fri, 06 Sep 2019 04:03:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42157) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698T-0003qC-LV for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698S-0003HS-Dv for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698S-0003Gs-8C; Fri, 06 Sep 2019 03:58:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86FBB3084288; Fri, 6 Sep 2019 07:58:22 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC35A1001284; Fri, 6 Sep 2019 07:58:20 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:32 +0200 Message-Id: <20190906075750.14791-11-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 10/28] s390x/tcg: MVCS/MVCP: Check for special operation exceptions 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 6d8ebd18fa..041d01d63d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1961,12 +1961,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; @@ -1984,12 +1990,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 02:51:47 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=1567757214; cv=none; d=zoho.com; s=zohoarc; b=LoJaKCxi74mUhGC8A2iG1o0mn0M7E9RDj0UVAMcc6pGZGVqoiECCJaD4OroihP5wf5xQz8QKi8J+qpFYoqAGlqTcEMd5Vagumm5bKIDiJ8GhFI9nNOmzq4fBuqnbpO7zGioSuo04vgSYza1fUM5X+o1QLkiGsUg6OUASJTVtNcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757214; 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=RdIITZazrU4mDSlzRrIXrrG3vU10RpiCkR/cDwHaonM=; b=YOji8Zzg6G79bX8B6w5U0KDgnjCEyE2yIOjG8W65MZhegZvV7uc8M9QjzMH1sjarrn5R6pf5qKxwzC4/7QR8OLNZEf50Qmf1vwtBq2PKWhQ2B7PjvTkayXOK0mls/Eh33aBwTa85Hij1GczH6VM0F4awcKq62e0zC/yc3A8N2R8= 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 1567757214915896.3825631614851; Fri, 6 Sep 2019 01:06:54 -0700 (PDT) Received: from localhost ([::1]:53240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Gc-0004H7-HX for importer@patchew.org; Fri, 06 Sep 2019 04:06:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42173) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698U-0003rR-JI for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698T-0003IK-GY for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698T-0003Hc-6l; Fri, 06 Sep 2019 03:58:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A25B37E79; Fri, 6 Sep 2019 07:58:24 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id D14191001955; Fri, 6 Sep 2019 07:58:22 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:33 +0200 Message-Id: <20190906075750.14791-12-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 11/28] s390x/tcg: MVCS/MVCP: Properly wrap the length 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. 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 041d01d63d..de5e69b500 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1973,10 +1973,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_length(env, l); if (l > 256) { /* max 256 */ l =3D 256; cc =3D 3; + } else if (!l) { + return cc; } =20 /* XXX replace w/ memcpy */ @@ -2002,10 +2005,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_length(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 02:51:47 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=1567757219; cv=none; d=zoho.com; s=zohoarc; b=SNOqGqVEGIovdNPjtNPt3H5pZAwT1oWIizWcSv0F99/OAC90uTI6NKg+M2iEEY1hWeD89X+LA/HhLBBpJ39gbRH0No7vnxA5wBTb6sIPHmQm0E2mGfhMZu2tBPQj2e3tTr904Il/7NB0fZkPW7clW27DOKR+yeGRbHxQRGGogq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757219; 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=cxaz1Q3TAqfTEUByyb8anOpYAryCdEumPSZClUlxxqI=; b=iWpzSuaXCOvRUprEXATBXVoRWRa/dIUoakR94jiKTPd9EiuPISduLg+vTlLhoNOS85e63dZdLfR5OvGfW7JyEevCw9IUKbjzL81Gyf+tViT3sBK68o98HLrUetu4DrUZ7JYQATcGPh4mvx4Ep+YHamvBe1Y82moVq2qYbI7Bgvs= 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 1567757219808564.9442876004764; Fri, 6 Sep 2019 01:06:59 -0700 (PDT) Received: from localhost ([::1]:53242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Gk-0004U6-BH for importer@patchew.org; Fri, 06 Sep 2019 04:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42212) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698W-0003uS-Qh for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698V-0003Jt-IO for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60980) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698V-0003JF-8H; Fri, 06 Sep 2019 03:58:27 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F851C04B946; Fri, 6 Sep 2019 07:58:26 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id C38831001B00; Fri, 6 Sep 2019 07:58:24 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:34 +0200 Message-Id: <20190906075750.14791-13-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 12/28] s390x/tcg: MVST: Check for specification exceptions 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 de5e69b500..afcd452a00 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -699,6 +699,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 02:51:47 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=1567757382; cv=none; d=zoho.com; s=zohoarc; b=PJVgTETcpxABMqNNi0pyPDIgdTxQ6HfS+iLpp7hSLrV3QaEKMLOlf0CP+OonWAjWiAsGHCgBflP9n2xZCnRgw+ABtivlz+6ueXdmA4YbjqFPeQhObPMggjrdEAlUxRDXTytSrUTCYE2182GJTJnZwhhLtShRMU466jzdqWXUFUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757382; 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=3LE832L3PMwYntsICAJXWrs8d2LLpSCnIGbzfU2KzuQ=; b=MnSQYZXNqaqxjy4aNPamJDCdWOYmqmY8tq8Q0Qk6DevkHzH8/HMiKzTqqgSUqlfpE2ZMDUoVoxUdd5sp0tP8x72Rlvb3ncBL80wO6CRu/1z/NSo8loXs1H2CgQRtekFHo9r4K4YbxbYo3/O2qWEXgB+9sJz9PaWuRKuxco+AY44= 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 1567757382757456.0801010766618; Fri, 6 Sep 2019 01:09:42 -0700 (PDT) Received: from localhost ([::1]:53282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69JN-0007rr-5H for importer@patchew.org; Fri, 06 Sep 2019 04:09:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42248) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698a-0003zI-6v for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698X-0003MF-Tp for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698X-0003Kt-Dx; Fri, 06 Sep 2019 03:58:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6220B875220; Fri, 6 Sep 2019 07:58:28 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id B689A1001284; Fri, 6 Sep 2019 07:58:26 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:35 +0200 Message-Id: <20190906075750.14791-14-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 13/28] s390x/tcg: MVST: Fix storing back the addresses to registers 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/helper.h | 2 +- target/s390x/insn-data.def | 2 +- target/s390x/mem_helper.c | 20 ++++++++------------ target/s390x/translate.c | 8 ++++++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index e9aff83b05..b32fce22ca 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_4(mvst, i32, env, i64, 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 afcd452a00..8dd58b3ab1 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -694,8 +694,10 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0,= uint64_t r1, uint64_t r2) } =20 /* string copy (c is string terminator) */ -uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c, uint64_t d, uint64_t= s) +uint32_t HELPER(mvst)(CPUS390XState *env, uint64_t c, uint32_t r1, uint32_= t r2) { + const uint64_t d =3D get_address(env, r1); + const uint64_t s =3D get_address(env, r2); uintptr_t ra =3D GETPC(); uint32_t len; =20 @@ -703,8 +705,6 @@ uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c, u= int64_t d, uint64_t s) 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. */ @@ -712,17 +712,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..b76e10d832 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, regs[0], 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 02:51:47 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=1567757527; cv=none; d=zoho.com; s=zohoarc; b=nxqoJA34v9PNKq5UadyftaM4ooKoj2qIQX1QAHGzbepyK9+LRnb1OjoFItZVK891nFdSVvxAlwfBFNQQCeuGXBQsZP3XeNb4q5ELjyIMl829LWI/jfucIXoztZq2wvdQvc1qPm9FM3EWGOcRtdy/5XmV2xmZIk0B9NZwi/cee6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757527; 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=cDc4WK1rrXK/hX/mr5iAQa3WmpjJPM/44ya3DqnCdVU=; b=PHAD0eRd1EiJ2u+9PZ+XjUXjxr+SacRtbWNR0E8fjtZd2VemoyKe1o7SIQpAYxHZY9W6/VzNcS4H6FO66HQaofMKC3YfK6mC1v7o+LRMqg83fBketqDai8JS4zeJXMsyz9GvslSrfiHyQD+I7t8Hu6U4O9XRsxk6ByUYGKW+6OY= 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 1567757527660788.6632736133909; Fri, 6 Sep 2019 01:12:07 -0700 (PDT) Received: from localhost ([::1]:53312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69LZ-0002vk-S4 for importer@patchew.org; Fri, 06 Sep 2019 04:11:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42261) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698b-00040q-7a for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698Z-0003NL-In for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698Z-0003Mg-8l; Fri, 06 Sep 2019 03:58:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59AFB49; Fri, 6 Sep 2019 07:58:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAAE31001955; Fri, 6 Sep 2019 07:58:28 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:36 +0200 Message-Id: <20190906075750.14791-15-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 14/28] s390x/tcg: Always use MMU_USER_IDX for CONFIG_USER_ONLY 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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(). Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 b76e10d832..50124520c9 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 02:51:47 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=1567757668; cv=none; d=zoho.com; s=zohoarc; b=ekze/no0K1hdTJc4WAYB3IbJvoOMxZFrXmGBVc4tMCpuhzoJi6v1CY5shLkatwML2lPg/OcuZP+fdIP+D7VkFGvhfqSWxwxrk1dOShRZdtr9aU7J/ETfREt2xor3of0ls24AFYKk32FJdXKE2hxJIIyA/SiRfEquXUK1kAGcekg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757668; 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=1I2+WC65KexuMqfnR26h58+ceDeIa1YwUFlpJHzTuPs=; b=M7id2Io5KslucgJcrWTD7FcEoDcfFW2PWW5HXZHMWI8zKf/L3kNHl9D78snHYlLHIC0+hJyirLy+xOhVzDFWlyjbxmHyhb3zVj+xJ2vSbo6G/HKaraTQXv7f9wV72Dw65CMZC0DNq5OWWNtdUthsX1P6gg+PUPixU4aRbiAtWt0= 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 1567757668869998.2700017344958; Fri, 6 Sep 2019 01:14:28 -0700 (PDT) Received: from localhost ([::1]:53348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Nz-0006Y0-Ev for importer@patchew.org; Fri, 06 Sep 2019 04:14:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42303) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698e-00046I-Tg for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698d-0003Pc-GI for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698d-0003P4-8L; Fri, 06 Sep 2019 03:58:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EF7510F23EC; Fri, 6 Sep 2019 07:58:34 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id A33991001284; Fri, 6 Sep 2019 07:58:30 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:37 +0200 Message-Id: <20190906075750.14791-16-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 15/28] s390x/tcg: Fault-safe memset 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 99 ++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 22 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 8dd58b3ab1..8d654b24e7 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -117,27 +117,82 @@ 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) -{ - int mmu_idx =3D cpu_mmu_index(env, false); +/* + * An access covers at most 4096 bytes and therefore at most two pages. If + * we can't access the host page directly, we'll have to do I/O access + * via ld/st helpers. + */ +typedef struct S390Access { + target_ulong vaddr1; + target_ulong vaddr2; + char *haddr1; + char *haddr2; + uint16_t size1; + uint16_t size2; +} S390Access; + +static S390Access access_prepare_idx(CPUS390XState *env, vaddr vaddr, int = size, + MMUAccessType access_type, int mmu_id= x, + uintptr_t ra) +{ + S390Access access =3D { + .vaddr1 =3D vaddr, + .size1 =3D MIN(size, -(vaddr | TARGET_PAGE_MASK)), + }; + + 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; +} + +static void access_memset_idx(CPUS390XState *env, vaddr vaddr, uint8_t byt= e, + int size, int mmu_idx, uintptr_t ra) +{ + S390Access desta =3D access_prepare_idx(env, vaddr, size, MMU_DATA_STO= RE, + mmu_idx, ra); +#ifdef CONFIG_USER_ONLY + g_assert(desta.haddr1 && (desta.haddr2 || !desta.size2)); + memset(desta.haddr1, byte, desta.size1); + memset(desta.haddr2, byte, desta.size2); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + int i; =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; - } 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--; + if (likely(desta.haddr1)) { + memset(desta.haddr1, byte, desta.size1); + } else { + for (i =3D 0; i < desta.size1; i++) { + helper_ret_stb_mmu(env, desta.vaddr1 + i, byte, oi, ra); + } + } + if (likely(!desta.size2)) { + return; + } + if (likely(desta.haddr2)) { + memset(desta.haddr2, byte, desta.size2); + } else { + for (i =3D 0; i < desta.size2; i++) { + helper_ret_stb_mmu(env, desta.vaddr2 + i, byte, oi, ra); } } +#endif +} + +static void access_memset(CPUS390XState *env, vaddr vaddr, uint8_t byte, + int size, uintptr_t ra) +{ + int mmu_idx =3D cpu_mmu_index(env, false); + + access_memset_idx(env, vaddr, byte, size, mmu_idx, ra); } =20 #ifndef CONFIG_USER_ONLY @@ -267,7 +322,7 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint32= _t l, uint64_t dest, =20 /* 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, dest, 0, l + 1, ra); return 0; } =20 @@ -329,7 +384,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, * 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, dest, cpu_ldub_data_ra(env, src, ra), l, ra); } else if (!is_destructive_overlap(env, dest, src, l)) { fast_memmove(env, dest, src, l, ra); } else { @@ -798,7 +853,7 @@ 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); + access_memset(env, *dest, pad, len, ra); *dest =3D wrap_address(env, *dest + len); } else { /* The remaining length selects the padding byte. */ @@ -852,7 +907,7 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) while (destlen) { cur_len =3D MIN(destlen, 2048); if (!srclen) { - fast_memset(env, dest, pad, cur_len, ra); + access_memset(env, dest, pad, cur_len, ra); } else { cur_len =3D MIN(cur_len, srclen); =20 --=20 2.21.0 From nobody Sat May 4 02:51:47 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=1567757656; cv=none; d=zoho.com; s=zohoarc; b=O7d78JfrKIJAoQovekh8YCILf55nSTrLXOMc0tIAEheVdXP4lGHdnfxk3OLNPA8BH9cpTja7cOfb/79qoCTGLGxWeouJdfi/PRwvLd5WoZ70Z+p4gKSF7G4ZzGLsiYKWUa5wWMssuxgXx81O1Z7CoZ7VqP3Le2A/dfvjXPHXvZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757656; 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=Jx0rRcH5ldNslXIETYt4u/zivvtDKl/q8Q+zt1zwyGQ=; b=C73RMWWb7JbW3wRPZlz/+TVnLvKDaUN9O6h874+XtxhdV7yDG71FC3uy9dsOlA/LfoXjPDkYOoXBixHdCubE0YyrzCUqpNqU7HLQ9tg0IevLXSLXUOHzrb1TpRpppAlnGXxvo9RbnbUogOWwDMmIBgGDnFCr4dM0UfyTo9stJbc= 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 1567757656884338.563385695403; Fri, 6 Sep 2019 01:14:16 -0700 (PDT) Received: from localhost ([::1]:53346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Nn-0006F4-8I for importer@patchew.org; Fri, 06 Sep 2019 04:14:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42327) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698h-0004AH-W1 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698f-0003Rh-IZ for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59774) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698f-0003Qr-87; Fri, 06 Sep 2019 03:58:37 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89A2A8980E2; Fri, 6 Sep 2019 07:58:36 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8A461000321; Fri, 6 Sep 2019 07:58:34 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:38 +0200 Message-Id: <20190906075750.14791-17-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Fri, 06 Sep 2019 07:58: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 Subject: [Qemu-devel] [PATCH v2 16/28] s390x/tcg: Fault-safe memmove 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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). 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 204 +++++++++++++++++++++----------------- 1 file changed, 115 insertions(+), 89 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 8d654b24e7..db678ddf47 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, @@ -129,6 +118,7 @@ typedef struct S390Access { char *haddr2; uint16_t size1; uint16_t size2; + int mmu_idx; } S390Access; =20 static S390Access access_prepare_idx(CPUS390XState *env, vaddr vaddr, int = size, @@ -138,6 +128,7 @@ static S390Access access_prepare_idx(CPUS390XState *env= , vaddr vaddr, int size, S390Access access =3D { .vaddr1 =3D vaddr, .size1 =3D MIN(size, -(vaddr | TARGET_PAGE_MASK)), + .mmu_idx =3D mmu_idx, }; =20 g_assert(size > 0 && size <=3D 4096); @@ -195,42 +186,112 @@ static void access_memset(CPUS390XState *env, vaddr = vaddr, uint8_t byte, access_memset_idx(env, vaddr, byte, size, 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) -{ - 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); +static uint8_t access_get_byte(CPUS390XState *env, const S390Access *acces= s, + int offset, uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + if (offset < access->size1) { + return ldub_p(access->haddr1 + offset); + } else { + return ldub_p(access->haddr2 + offset - access->size1); + } +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, access->mmu_idx); + + if (offset < access->size1) { + if (likely(access->haddr1)) { + return ldub_p(access->haddr1 + offset); + } + return helper_ret_ldub_mmu(env, access->vaddr1 + offset, oi, ra); + } + if (access->haddr2) { + return ldub_p(access->haddr2 + offset - access->size1); + } + return helper_ret_ldub_mmu(env, access->vaddr2 + offset - access->size= 1, oi, + ra); +#endif +} + +static void access_set_byte(CPUS390XState *env, const S390Access *access, + int offset, uint8_t byte, uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + if (offset < access->size1) { + stb_p(access->haddr1 + offset, byte); + } else { + stb_p(access->haddr2 + offset - access->size1, byte); + } +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, access->mmu_idx); + + if (offset < access->size1) { + if (likely(access->haddr1)) { + stb_p(access->haddr1 + offset, byte); } 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); + helper_ret_stb_mmu(env, access->vaddr1 + offset, byte, oi, ra); + } + } else { + if (likely(access->haddr2)) { + stb_p(access->haddr2 + offset - access->size1, byte); + } else { + helper_ret_stb_mmu(env, access->vaddr2 + offset - access->size= 1, + byte, oi, ra); + } + } +#endif +} + +/* + * 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_idx(CPUS390XState *env, vaddr dest, vaddr src, + int size, int dest_idx, int src_idx, + uintptr_t ra) +{ + S390Access srca =3D access_prepare_idx(env, src, size, MMU_DATA_LOAD, = src_idx, + ra); + S390Access desta =3D access_prepare_idx(env, dest, size, MMU_DATA_STOR= E, + dest_idx, ra); + uint16_t diff; + + /* 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))) { + uint8_t byte; + int i; + + for (i =3D 0; i < desta.size1 + desta.size2; i++) { + byte =3D access_get_byte(env, &srca, i, ra); + access_set_byte(env, &desta, i, byte, ra); } - src +=3D len_adj; - dest +=3D len_adj; - len -=3D len_adj; + return; + } + + if (srca.size1 =3D=3D desta.size1) { + memmove(desta.haddr1, srca.haddr1, srca.size1); + 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); + 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); + memmove(desta.haddr2 + diff, srca.haddr2, srca.size2); } } =20 +static void access_memmove(CPUS390XState *env, vaddr dest, vaddr src, + int size, uintptr_t ra) +{ + int mmu_idx =3D cpu_mmu_index(env, false); + + access_memmove_idx(env, dest, src, size, mmu_idx, mmu_idx, ra); +} + static int mmu_idx_from_as(uint8_t as) { switch (as) { @@ -246,43 +307,14 @@ 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) +static void access_memmove_as(CPUS390XState *env, uint64_t dest, uint64_t = src, + uint32_t len, uint8_t dest_as, uint8_t src_a= s, + uintptr_t ra) { int src_idx =3D mmu_idx_from_as(src_as); int dest_idx =3D mmu_idx_from_as(dest_as); =20 - 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--; - } - } + access_memmove_idx(env, dest, src, len, dest_idx, src_idx, ra); } =20 /* and on array */ @@ -386,7 +418,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, if (dest =3D=3D src + 1) { access_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); } else if (!is_destructive_overlap(env, dest, src, l)) { - fast_memmove(env, dest, src, l, ra); + access_memmove(env, dest, src, l, ra); } else { for (i =3D 0; i < l; i++) { uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); @@ -744,7 +776,7 @@ 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()); + access_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); return 0; /* data moved */ } =20 @@ -847,7 +879,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, len =3D MIN(len, *srclen); *destlen -=3D len; *srclen -=3D len; - fast_memmove(env, *dest, *src, len, ra); + access_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) { @@ -911,7 +943,7 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) } else { cur_len =3D MIN(cur_len, srclen); =20 - fast_memmove(env, dest, src, cur_len, ra); + access_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); @@ -2453,16 +2485,10 @@ 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) { + access_memmove_as(env, dest, src, len, dest_as, src_as, ra); + } =20 return cc; } --=20 2.21.0 From nobody Sat May 4 02:51:47 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=1567757507; cv=none; d=zoho.com; s=zohoarc; b=h6498jVjbJfsIFT1/ZLMtQPCw2zaS2izx6SK5cnJUOnvrYc4FKpTXvBFzlbtqNwQzbJvZzp1ZuM1HpAk/VBXka9B6MjPKtV1Xp401tHL8mD6X1TMuEWxyT+za0G/cEdJ9AFLu6NEe7EKVkMzO7TtAeeIHC9HsxQPTTGtZW98yjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757507; 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=q92ctnZlbLPCI7PGbdRjLwW9NWpZzE+t/GTbEUEqyTk=; b=L+ml6Bl7Sp6qSZ1JDoS1/YZ2VlDo3SQ/su4m90Q2eYvwLDaxSYp1ZbxN7tkX5Wx8h65K9mLZqfxogGPapikYl77VmhqPlHTSA+afBiKDR6fbxLg07ePg35tyBzARs21jdbLrc0lW8GQJbvExoxnRDpiB1ggahOP8YUwNyY6hDFo= 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 1567757507566378.45253243685545; Fri, 6 Sep 2019 01:11:47 -0700 (PDT) Received: from localhost ([::1]:53306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69LN-0002cv-L1 for importer@patchew.org; Fri, 06 Sep 2019 04:11:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42339) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698i-0004BD-KA for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698h-0003T7-CU for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42128) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698h-0003SW-60; Fri, 06 Sep 2019 03:58:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7AE6E18012F2; Fri, 6 Sep 2019 07:58:38 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C6F1001955; Fri, 6 Sep 2019 07:58:36 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:39 +0200 Message-Id: <20190906075750.14791-18-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Fri, 06 Sep 2019 07:58:38 +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 Subject: [Qemu-devel] [PATCH v2 17/28] s390x/tcg: MVCS/MVCP: Use access_memmove_idx() 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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_idx() 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." Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index db678ddf47..2607dd1677 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2049,7 +2049,7 @@ 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; + int cc =3D 0; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); @@ -2068,12 +2068,8 @@ 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 */ + access_memmove_idx(env, a1, a2, l, MMU_SECONDARY_IDX, MMU_PRIMARY_IDX,= ra); return cc; } =20 @@ -2081,7 +2077,7 @@ 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; + int cc =3D 0; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); @@ -2100,12 +2096,8 @@ 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 */ + access_memmove_idx(env, a1, a2, l, MMU_PRIMARY_IDX, MMU_SECONDARY_IDX,= ra); return cc; } =20 --=20 2.21.0 From nobody Sat May 4 02:51:47 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=1567757425; cv=none; d=zoho.com; s=zohoarc; b=dMe1AjSxrq+z5HwhrtzlSk5M9moT7nfaZ7DD5Jj/QIxLeHWk7zQ/Z6JzZja8WQQkbTyfpMp7JazYJZjDlM3q7w7kxffXOjprmUe511mtSlzJUWPJCC59PFlCTPaQeoRtiGBTcbdpNfEBjsrHvPKX5truKJr1qxzGOgAhygzRW3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757425; 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=V27g+0PJG2y4+kglikthoTNX6371Wyb8KMAGBpimTLM=; b=aRlKgav7Sj+D584SAsBoYcAWYdViuz57nZ2+IyWcqFjrEwNnK5UmMM0Yp1vo295o3KcGCGa4/uVdSxBRO7EIKPSgES4YQX20EHuQlySnepm+xrEr+cIupXYAcDf8I23nzZLxX8oxUNDAR0F0aPi2hAydFl6Kzf/hZQbzcSzIAHU= 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 1567757425498917.6060945275929; Fri, 6 Sep 2019 01:10:25 -0700 (PDT) Received: from localhost ([::1]:53286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69K3-0000YM-PW for importer@patchew.org; Fri, 06 Sep 2019 04:10:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698k-0004Dt-LB for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698j-0003Ut-Ah for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698j-0003UR-5U; Fri, 06 Sep 2019 03:58:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 707DA875220; Fri, 6 Sep 2019 07:58:40 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id C449B1001955; Fri, 6 Sep 2019 07:58:38 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:40 +0200 Message-Id: <20190906075750.14791-19-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Fri, 06 Sep 2019 07:58:40 +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 Subject: [Qemu-devel] [PATCH v2 18/28] s390x/tcg: MVC: Fault-safe handling on destructive overlaps 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 2607dd1677..f636f3a011 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -145,6 +145,14 @@ static S390Access access_prepare_idx(CPUS390XState *en= v, vaddr vaddr, int size, return access; } =20 +static S390Access access_prepare(CPUS390XState *env, vaddr vaddr, int size, + MMUAccessType access_type, uintptr_t ra) +{ + int mmu_idx =3D cpu_mmu_index(env, false); + + return access_prepare_idx(env, vaddr, size, access_type, mmu_idx, ra); +} + static void access_memset_idx(CPUS390XState *env, vaddr vaddr, uint8_t byt= e, int size, int mmu_idx, uintptr_t ra) { @@ -420,9 +428,13 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint= 32_t l, uint64_t dest, } else if (!is_destructive_overlap(env, dest, src, l)) { access_memmove(env, dest, src, l, ra); } else { + S390Access srca =3D access_prepare(env, src, l, MMU_DATA_LOAD, ra); + S390Access desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, = ra); + 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 02:51:47 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=1567757577; cv=none; d=zoho.com; s=zohoarc; b=gSUjki7YPDC5TBV9vFhMn5VkiiEQairXgg9KqJcJMDXzC87wsTCgJw2T3Z9KG9deEo+53VEhbQ7FL9d4Ec9AwbGWRAskBqMJtj1mIzYTOm2o+YKrxzQEIJkBfhFH1pgXvsbajq/ddeH3KxzEW78qgb6EszZMe0WwtIqcF0iy8mY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757577; 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=0QQZ29E0IaeYqLcd9aKPKkvU9wXqVEIVRfnUjZ12Sy0=; b=eVQBvNCDeJx3hFa4opSYTlmd5q0gvCFzhqgSz1BAl9P3tuodUvVTGC0MPe3IpdiELvaARDqJAHeNQoXwReJOGQ0RsEzjytM3sO7khvuoDufo1s+x6v7szFgmT3KQ6jRndTOV1e1snlOXdy7NiRfv+w2X7XQ9ub05TYBMy1N3Vjw= 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 1567757577858300.59560704176556; Fri, 6 Sep 2019 01:12:57 -0700 (PDT) Received: from localhost ([::1]:53316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69MW-00042F-4H for importer@patchew.org; Fri, 06 Sep 2019 04:12:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42405) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698m-0004FS-Rg for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698l-0003Wq-F0 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698l-0003W6-4M; Fri, 06 Sep 2019 03:58:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64E228372F2; Fri, 6 Sep 2019 07:58:42 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9B091001955; Fri, 6 Sep 2019 07:58:40 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:41 +0200 Message-Id: <20190906075750.14791-20-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Fri, 06 Sep 2019 07:58:42 +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 Subject: [Qemu-devel] [PATCH v2 19/28] s390x/tcg: MVCLU: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 f636f3a011..0366cbc753 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -900,15 +900,17 @@ static inline uint32_t do_mvcl(CPUS390XState *env, access_memset(env, *dest, pad, len, ra); *dest =3D wrap_address(env, *dest + len); } else { + S390Access desta =3D access_prepare(env, *dest, len, MMU_DATA_STOR= E, 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 02:51:47 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=1567757960; cv=none; d=zoho.com; s=zohoarc; b=XENOFJtuBvzTY008mxjvNgxvEznhcKYrDpraWftLeyuiJnq2MWbCyV+mgSEzSPAiNMVrUQgruc2l0TYu1k8U99FKK4X/QkfGNFVvkvEH7ZoUxGKOMfBPAbihrmcW1HYhQSDEsgI4z0fEIaD1f+5CRBXf2J3O3ucRsF4fUrbi3po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757960; 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=kAGZ29z/UY6/n/AK5QtrU9dAyYQllNvo8oD2uPl7KC4=; b=aCT8esUuBOHsP5TcGBSMAXFkQRUl01UvyxFedG9ylK9tTDN5WPjFiZM2wlx3VA9q/9UhO0IVQipH0oIqap93HATJWht60K0iN9MHh9DLmHS32vE3Azf6+8NCucOEpTXfDaOVlJzvMZ2HGoauanmg21wv0sDspQg6Dw0neFN36qI= 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 1567757960064514.1888777574499; Fri, 6 Sep 2019 01:19:20 -0700 (PDT) Received: from localhost ([::1]:53382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69SZ-0001T8-C3 for importer@patchew.org; Fri, 06 Sep 2019 04:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i698w-0004Ix-1S for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698q-0003bc-Ux for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50204) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698n-0003Xh-AY; Fri, 06 Sep 2019 03:58:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B513877A6D; Fri, 6 Sep 2019 07:58:44 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEC641000321; Fri, 6 Sep 2019 07:58:42 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:42 +0200 Message-Id: <20190906075750.14791-21-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Fri, 06 Sep 2019 07:58:44 +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 Subject: [Qemu-devel] [PATCH v2 20/28] s390x/tcg: OC: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 0366cbc753..ff57fec8de 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -385,17 +385,25 @@ 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) { + 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, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, 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 02:51:47 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=1567757963; cv=none; d=zoho.com; s=zohoarc; b=nkOFwcjyK9dcqknuIakWcJap0uromznY0vWBPYxgTW6r6hd0ENb/qdJkMvLDtCou5Cb/ee+mbXlmP614/veXiBDfGYUwGx7jE+ZugVSmoIzyorri0bhq7Wv2JVU8vhOcumdZgGXeCijqHf77kzQiOUSNfysXtP8tlc5EBPH2tM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757963; 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=hxDzu/W6RY44YhO1NSJonS+x0ao+fbFnhRCLH8Kva8s=; b=HWhbpM/FmeEeCNvXv31PSoQAzuZOYH0emUpPGrXSXwcLw5wVu5Xl6iCf7sZmf1l1ZeWIDM4rgf8DgUdIpn8yromj8Z+KpFbecCyV9ftrDjpqRA018fpyqFk5AF4RV/wur14FlVxu+MsJHldcZ07TYEB6DCJj/zL+WtFebsBQm7w= 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 156775796326969.98729320956022; Fri, 6 Sep 2019 01:19:23 -0700 (PDT) Received: from localhost ([::1]:53384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Sh-0001gP-TX for importer@patchew.org; Fri, 06 Sep 2019 04:19:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6991-0004Jl-7N for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i698v-0003eP-CX for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:58:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698q-0003a4-UL; Fri, 06 Sep 2019 03:58:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 503AC308FB9A; Fri, 6 Sep 2019 07:58:46 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id A33F11001955; Fri, 6 Sep 2019 07:58:44 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:43 +0200 Message-Id: <20190906075750.14791-22-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 06 Sep 2019 07:58:46 +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 Subject: [Qemu-devel] [PATCH v2 21/28] s390x/tcg: XC: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index ff57fec8de..88ff6c21ed 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -354,23 +354,31 @@ 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) { + 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 + /* XC always processes one more byte than specified - maximum is 256 */ + l++; + /* xor with itself is the same as memset(0) */ if (src =3D=3D dest) { - access_memset(env, dest, 0, l + 1, ra); + access_memset(env, dest, 0, l, ra); 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); + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, 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 02:51:47 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=1567757806; cv=none; d=zoho.com; s=zohoarc; b=UZKvaBKE8LzRtI7mjvQh7+4xCBXlYVxm3rBRMW4PeFZiS3uejstRCkgphNqFgzIOuluWiRqhx+ZYRvDbR9UNmCOcvkfk8MaIwzGux/VLPXJYfqhST3LEaVACYJg4HN36xABEFzy2PTEBSURBjHXGRzHNVyx2U1baZzo4P9s6ykM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757806; 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=XrNLpTHXwzgVk5r3N/Uzwr2CSnRDMhKNRlFQbXXADaM=; b=IdwAZogGnxA4oiBsr2tmU1/SOkK3xDrkg2IgrwFEwkPjpBn2T982+219Wx7pcbD3pWTTa4/+pYLv/LegceZA1FCjj2s0CfLC5yn9TsDkM+M0HwXOhx1NlCdHwy2Rm0UGQ9ye82z8pGp7SlG5UWZVHjBEscjETssjfL8aJ/4rwtQ= 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 1567757806539190.1781837556499; Fri, 6 Sep 2019 01:16:46 -0700 (PDT) Received: from localhost ([::1]:53350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69QC-0007gy-8X for importer@patchew.org; Fri, 06 Sep 2019 04:16:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42508) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6992-0004LT-F4 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6990-0003h8-Ld for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698v-0003bI-Bl; Fri, 06 Sep 2019 03:58:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4298369078; Fri, 6 Sep 2019 07:58:48 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98E5E1001955; Fri, 6 Sep 2019 07:58:46 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:44 +0200 Message-Id: <20190906075750.14791-23-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 06 Sep 2019 07:58:48 +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 Subject: [Qemu-devel] [PATCH v2 22/28] s390x/tcg: NC: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 88ff6c21ed..49b4879859 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -329,17 +329,25 @@ static void access_memmove_as(CPUS390XState *env, uin= t64_t dest, uint64_t src, static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + 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, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, 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 02:51:47 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=1567757393; cv=none; d=zoho.com; s=zohoarc; b=X81Qe61sJT3gEt2djYcac7OCMJL1gHuA+TEhOT0zP1/kOhsRMmgnc09NZ5rSaajsH+xoSkZRQuYOgvyF2mGK34hf5Wi1UPGpyC3ziDciT+oVg9SwEmDyPcNcAPkOmLMS4K98vIij9ogPc9HPY2fc10f6t4BSoO78r7cNl2jnIRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757393; 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=++LJTHfXZReQUtvg6V7/7etynJ4mTVx30op+LvycB2s=; b=jMElRaa8UO/Ae5QZPChHZxtv9tNS3aue8cRuBru6MS/leZgFq/hBopAuv2+rI31IpUXKR6aTXO9Flx0baVf23HXIY+5hsn/a0uyt9CZNgw7ydMCPlPXSgPbsFjD6v162uh593a19SjFWOcVMUU6a1QpLXPwVN956RlJgAONKtlA= 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 1567757393188113.72744909376831; Fri, 6 Sep 2019 01:09:53 -0700 (PDT) Received: from localhost ([::1]:53284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69JX-0008Cq-Oc for importer@patchew.org; Fri, 06 Sep 2019 04:09:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42530) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6993-0004NK-Km for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6991-0003he-6w for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i698x-0003dl-HS; Fri, 06 Sep 2019 03:58:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5472C307CB3F; Fri, 6 Sep 2019 07:58:52 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A9801001956; Fri, 6 Sep 2019 07:58:48 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:45 +0200 Message-Id: <20190906075750.14791-24-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 06 Sep 2019 07:58:52 +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 Subject: [Qemu-devel] [PATCH v2 23/28] s390x/tcg: MVCIN: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- 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 49b4879859..ba8a657e18 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -473,12 +473,20 @@ 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) { + 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, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, 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 02:51:47 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=1567757533; cv=none; d=zoho.com; s=zohoarc; b=S1Kd77jWKgrbR5SnwU0U8gufozez9MA8Sn3vrTX0eoOCaToKUrHlpWGq1M3JD847Ozifc3wWle775Q0tYY7IxkmlkkB7+Okn0Kt2LtC203Zwgxq824+yWOaNsed50OGM+7NaCRTeW8j4yC9n/EhhH1oBICZ4IrRw6S8izSgzmeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757533; 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=zvddbMs6LL2ZS/f/rbDEs6uWAD8vhoGpEAC+n/G5aPI=; b=KZD0WotOW0KuhB9fe4r6vzJxVqCJ7suhLFCFWXOgDWDBk9Hfy/htTLV0/LvbzyFsHL8jvbMq7JV7ZWceWSpwpGzsHIOD11lmxzegqnMhIY/6W3vKQdNiGlH6Wx5gzqBd6CFfwCGrcUEkzJ/TcojSIbqXUkFvuuBWRuitpTv/Alc= 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 1567757533319522.8588591312152; Fri, 6 Sep 2019 01:12:13 -0700 (PDT) Received: from localhost ([::1]:53314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69Ll-0003GW-QO for importer@patchew.org; Fri, 06 Sep 2019 04:12:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42537) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6994-0004OJ-6v for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6991-0003iL-SC for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6991-0003fI-4N; Fri, 06 Sep 2019 03:58:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42FD31056FB8; Fri, 6 Sep 2019 07:58:54 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B0E11001284; Fri, 6 Sep 2019 07:58:52 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:46 +0200 Message-Id: <20190906075750.14791-25-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Fri, 06 Sep 2019 07:58:54 +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 Subject: [Qemu-devel] [PATCH v2 24/28] s390x/tcg: MVN: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index ba8a657e18..5e38b2c4d8 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -493,13 +493,21 @@ 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) { + 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, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, 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 02:51:47 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=1567757995; cv=none; d=zoho.com; s=zohoarc; b=bOt4GYxGNKSXnQR47W62SbQFVjcWZxdOdAM1BQk6kMLSqdMfH3fad47MygUrCIWHrBJFOtzj7VPF0CfRV+DQtqSGld2ZriEq6Qv8OQblwKQDGO0gONE2IsIOkzo/Jkkb7cyv9TDvm8UW98sr5AuiI9v089xJmDv5rUlxeZF4OOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567757995; 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=S/mV32l7wTBxvF53+IdzRiqyvUbSms6xvRqjBO/M80g=; b=WL0OwfYtQ23Ya7xZ1YQ063V8fLV0lZmm4n+vxHk6dPJRDMTHfK67XlXv0ciEkUIqkzxlQ0QsadctRsWpUiTemgOkkiwtKY2luk70D3eQsi9PFn2+tLZrmaCf4gCUz/hB9hv3Hgz0Zo6aaAzMnB5wC7wE+JXGIXG2eZYFKmnPsJE= 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 1567757995840505.5714624707201; Fri, 6 Sep 2019 01:19:55 -0700 (PDT) Received: from localhost ([::1]:53386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69TG-0002eK-Fs for importer@patchew.org; Fri, 06 Sep 2019 04:19:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42549) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6994-0004P6-Nt for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6992-0003jH-LY for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33608) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6992-0003g2-3G; Fri, 06 Sep 2019 03:59:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33FC018C4272; Fri, 6 Sep 2019 07:58:56 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B3B41001955; Fri, 6 Sep 2019 07:58:54 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:47 +0200 Message-Id: <20190906075750.14791-26-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Fri, 06 Sep 2019 07:58:56 +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 Subject: [Qemu-devel] [PATCH v2 25/28] s390x/tcg: MVZ: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 5e38b2c4d8..4c67c6f37e 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -545,13 +545,21 @@ 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) { + 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, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, 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 02:51:47 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=1567758041; cv=none; d=zoho.com; s=zohoarc; b=MZUFFAV6r2++UeftovXjz7bDEiD17If5vFqV5hT4wpjB596jMJ53zRXBopsarrxU/JwCceoIcnFGYaFxCdxk+1c+OP8dVVYmUeaWjOHbJQ77SxU8gI05xt/i3Av9vgkcdrOBxFSsfvx81c9wUVpfXDjXnJgQxDvDnyPM03gZars= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567758041; 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=U641LOqrYG40owCtlpkR0osjlkiSWxVl9GDCRep4GU8=; b=Dp/t2D1pvmWVhjD85twpZA48ArKPtmHMUFtCvoOASt9yvuLwg5z85+Js7GyBKy/x8RrasGZZxmbiNii76c6j6cMYk4Pk1JtvhuYbVA/uAJTLC3Bj4LfgqjGGIkT8H4Ghg2Jeb9oizFoLznzEzu8eW/B+LyYR5dqSlIY8Lfa+kac= 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 1567758041148706.4259685123967; Fri, 6 Sep 2019 01:20:41 -0700 (PDT) Received: from localhost ([::1]:53406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69U0-0003wF-35 for importer@patchew.org; Fri, 06 Sep 2019 04:20:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42566) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6995-0004QB-L5 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6992-0003j0-Hl for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58692) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6991-0003gu-WC; Fri, 06 Sep 2019 03:59:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27DB610C6964; Fri, 6 Sep 2019 07:58:58 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C4751000321; Fri, 6 Sep 2019 07:58:56 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:48 +0200 Message-Id: <20190906075750.14791-27-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Fri, 06 Sep 2019 07:58:58 +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 Subject: [Qemu-devel] [PATCH v2 26/28] s390x/tcg: MVST: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 4c67c6f37e..73b00b582b 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -845,21 +845,30 @@ uint32_t HELPER(mvst)(CPUS390XState *env, uint64_t c,= 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 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 (c & 0xffffff00ull) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); } c =3D c & 0xff; =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, ra); + desta =3D access_prepare(env, d, len, MMU_DATA_STORE, 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 02:51:47 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=1567758070; cv=none; d=zoho.com; s=zohoarc; b=NQa2xejidH3AbwFKzFsKTauY+IT1D1DaPvMqx9s2n5YqiSuEubw7eahdyOXUVEFHKxs30nsv09oJCRLRMHVNHg3Rl8B07Trls1f/dJivCWBEd9hOOXsySb9egdFqy2Z4EB6FkTO8tVoTpb8NN5OjW66SznGmsUPT2Tu2W+n8tn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567758070; 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=CciNUX1WbEcIfdQZ0cIsWbG0CXxTq4Mu5c4CV8Viths=; b=R9CDu2lNeQ0myWykUI1bMa11Gn/JlI8T6OWlXpTr2h70RwhNaQAfaXh1agQgAxJj/8pMtM7N7kpKN05KTNGR1h53hG7LxLr0mmQkE3QQNKvP68OrBxFwcSMbRtobZaP0AJwgYz/siyn1H+Djridcqz0rlVRKCoMmEw9D6XMnZVQ= 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 156775807036075.9729399200229; Fri, 6 Sep 2019 01:21:10 -0700 (PDT) Received: from localhost ([::1]:53408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69UT-0004hI-AQ for importer@patchew.org; Fri, 06 Sep 2019 04:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42597) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6997-0004S2-50 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6994-0003kS-3w for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6993-0003is-B3; Fri, 06 Sep 2019 03:59:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B6C730860A8; Fri, 6 Sep 2019 07:59:00 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FAB11001B00; Fri, 6 Sep 2019 07:58:58 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:49 +0200 Message-Id: <20190906075750.14791-28-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 06 Sep 2019 07:59:00 +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 Subject: [Qemu-devel] [PATCH v2 27/28] s390x/tcg: MVO: Fault-safe handling 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/mem_helper.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 73b00b582b..7403124763 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -514,31 +514,33 @@ 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) { + /* 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, ra); + desta =3D access_prepare(env, dest, len_dest, MMU_DATA_STORE, 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 02:51:47 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=1567758119; cv=none; d=zoho.com; s=zohoarc; b=iidknrBZ0M9Ylm72R7CuUFkMtX6CuWwrcj289i9th24ICf1lt6zxzqz9zTRfg25cQHagsyn3Ftjk9LQXMvnWonCETOIg+GamXNZ7fiepQ+BApTT3o+6RWVJtepoo5/wVS84ZRDLW69KsNJD3Qd3ol58nYxnwngdDnyfzkrl55K0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567758119; 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=TyCVcTMz++MW/PDIQwolLo1KOsigU/YHPSEHffFgwOI=; b=SL3E7Zg7kg+XGoiVcCCwem188WRGaqAxkrGlDUJYPBwAyurNSpHImKbPrNQyz2kkML8oYRKb7EqpsMzjt4PRLFssP8/CZvDmKXSIYsT78LzSkTpX3GQFRniRl36bIShGuKxx0MTveBuHUUrojPbGU1eqQitNHTYlvFlNQB2ezVw= 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 156775811924919.074714851870567; Fri, 6 Sep 2019 01:21:59 -0700 (PDT) Received: from localhost ([::1]:53428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i69VF-0005ty-T9 for importer@patchew.org; Fri, 06 Sep 2019 04:21:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42637) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6999-0004VL-A3 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6996-0003mh-5X for qemu-devel@nongnu.org; Fri, 06 Sep 2019 03:59:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45414) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6995-0003km-Ea; Fri, 06 Sep 2019 03:59:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FE26806A2; Fri, 6 Sep 2019 07:59:02 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-162.ams2.redhat.com [10.36.117.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 631451001B00; Fri, 6 Sep 2019 07:59:00 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 6 Sep 2019 09:57:50 +0200 Message-Id: <20190906075750.14791-29-david@redhat.com> In-Reply-To: <20190906075750.14791-1-david@redhat.com> References: <20190906075750.14791-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 06 Sep 2019 07:59:02 +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 Subject: [Qemu-devel] [PATCH v2 28/28] tests/tcg: target/s390x: Test MVO 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: Florian Weimer , Thomas Huth , David Hildenbrand , Cornelia Huck , Stefano Brivio , 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 add the simple test based on the example from the PoP. 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