From nobody Thu May 2 11:57:11 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=1568823807; cv=none; d=zoho.com; s=zohoarc; b=cg9JY4gGpjnbVR3bcMCHAArRmEYSgnQxGQ5iMr97UucLk9q57m3/Zj0yP/Gd8Z3syrcJ8ByOkAC0TJWtdzscyMaQhC3CSvptqwZlwPsSK3aHL54WDY3SYVfGAxI+yUJ9Wdb/hIZqTAae7Ed5jtM94hRumJY5ezUKuUgJ4Jyb4J4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823807; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9WFGLjaUgnGtsGiAsj0XdT2wV99CQBjwNF4p4XNU2hc=; b=ajWVid+EI5xTSUxUJqDtmWeJnZ+K6M/ckWxwkt3kY7sR5M7Q5iklr2okb3ctlSmL4KQbl7wxdbn1Y/pvSUyvDHC7Pz6Y+p9a+/TBvlCCLGebXkR4FWwX1QJAgh7xOdGHoifV4n4oAo+pfpBw7e0z6zJC3sSQv1tB3W58JpJigFI= 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 1568823807509964.629419273213; Wed, 18 Sep 2019 09:23:27 -0700 (PDT) Received: from localhost ([::1]:60626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcjl-0004En-SO for importer@patchew.org; Wed, 18 Sep 2019 12:23:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50189) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbtc-0008SM-Js for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbtb-0007XH-Hc for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtb-0007Wx-CR; Wed, 18 Sep 2019 11:29:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A363C307D974; Wed, 18 Sep 2019 15:29:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC7BE5D6A5; Wed, 18 Sep 2019 15:29:27 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:28:54 +0200 Message-Id: <20190918152922.18949-2-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 18 Sep 2019 15:29: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] [PULL SUBSYSTEM s390x 01/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We use the marker "-1" for "no exception". s390_cpu_do_interrupt() might get confused by that. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 29fcce426e..39ee9b3175 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1747,7 +1747,7 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a= 1, uint64_t a2) =20 if (env->int_pgm_code =3D=3D PGM_PROTECTION) { /* retry if reading is possible */ - cs->exception_index =3D 0; + cs->exception_index =3D -1; if (!s390_cpu_virt_mem_check_read(cpu, a1, 0, 1)) { /* Fetching permitted; storing not permitted */ return 1; @@ -1757,7 +1757,7 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a= 1, uint64_t a2) switch (env->int_pgm_code) { case PGM_PROTECTION: /* Fetching not permitted; storing not permitted */ - cs->exception_index =3D 0; + cs->exception_index =3D -1; return 2; case PGM_ADDRESSING: case PGM_TRANS_SPEC: @@ -1767,7 +1767,7 @@ uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a= 1, uint64_t a2) } =20 /* Translation not available */ - cs->exception_index =3D 0; + cs->exception_index =3D -1; return 3; } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823982; cv=none; d=zoho.com; s=zohoarc; b=eWjRDFpXo4lyMOq33eZX2L+87yTzjbqeQWcUAHksCfRL5DS2gKjTuiI3qv/8/BigPoZ6G+cRIcrkSiWjo/VMZELMj90pGOaWOgNnw1fAef6mlfl9rI8AB4iSZXQjSiQ/kr3CWcYAPJst7zGkg9SkrV46vXSYcyXDIVKEgne+gIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823982; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PgBP7K/RQw2WKgTnFtSs3LLLtu45PUfnmJP74rJAAmY=; b=JDCgehuM/ED9TDqLvymyeZ2+6wFeGEna9Rn/oM6JWvx5j4Xni9r6Oc8Y8jPOqDkn2LriZ/8nrv8R2+iO+Ujkd01pFzThKBrFPN+8XM5MuoLTJ41Ku2D/I1XtlWINkcIZ0X3JakIAeB7BfYcPmrb3OC3xMPPhSpZLhrfy4cxF/RM= 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 1568823982204918.7585424446569; Wed, 18 Sep 2019 09:26:22 -0700 (PDT) Received: from localhost ([::1]:60658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcmX-000806-El for importer@patchew.org; Wed, 18 Sep 2019 12:26:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50241) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbth-000077-JF for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbtg-0007ae-CW for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26549) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtg-0007Zk-7P; Wed, 18 Sep 2019 11:29:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30E96191864A; Wed, 18 Sep 2019 15:29:35 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02B985D6A5; Wed, 18 Sep 2019 15:29:30 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:28:55 +0200 Message-Id: <20190918152922.18949-3-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Wed, 18 Sep 2019 15:29:35 +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] [PULL SUBSYSTEM s390x 02/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have to zero out unused bits in 24 and 31-bit addressing mode. Provide a new helper. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 39ee9b3175..b02ad148e5 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -469,6 +469,25 @@ static inline uint64_t get_address(CPUS390XState *env,= int reg) return wrap_address(env, env->regs[reg]); } =20 +/* + * Store the address to the given register, zeroing out unused leftmost + * bits in bit positions 32-63 (24-bit and 31-bit mode only). + */ +static inline void set_address_zero(CPUS390XState *env, int reg, + uint64_t address) +{ + if (env->psw.mask & PSW_MASK_64) { + env->regs[reg] =3D address; + } else { + if (!(env->psw.mask & PSW_MASK_32)) { + address &=3D 0x00ffffff; + } else { + address &=3D 0x7fffffff; + } + env->regs[reg] =3D deposit64(env->regs[reg], 0, 32, address); + } +} + static inline void set_address(CPUS390XState *env, int reg, uint64_t addre= ss) { if (env->psw.mask & PSW_MASK_64) { @@ -772,8 +791,8 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) =20 env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srclen); - set_address(env, r1, dest); - set_address(env, r2, src); + set_address_zero(env, r1, dest); + set_address_zero(env, r2, src); =20 return cc; } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823616; cv=none; d=zoho.com; s=zohoarc; b=R94CX5LzoxI/GkqvwHciTONU3sm/NIbVS5vATlXWE43l6WtxePgenX5wi+ZWmWew4XNQamCQlw1BEjdPcgdw1h42efyAMuDEJoN0bAWdPBgadBmhZaP0gyvIY0pU7jwGQP5bIkgQ3ci0qitEyi1L4HBky0B/oVUVl9pxchvs4F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823616; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CJQj4LsDFZho4+24S4iIYhD3ecei7Cg6vUJI/TYSgM4=; b=ddUOHyz0M3C8YKb1TA30DhHBh1/yKact6FLq3jhr9bwIs7lhA/sNJCZmywPQInBfF3Izp4FS0OYI0tKXRuVHtjCTkG1XV7IB+8BQ+JIn9OChtCGL2FWLOq02EhpvrSjHMCHY2F0nBJillDUM1/whP0QGf2NC22+M1OzgnlyE1zE= 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 1568823616334315.07733440029847; Wed, 18 Sep 2019 09:20:16 -0700 (PDT) Received: from localhost ([::1]:60580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcgg-0008HB-Br for importer@patchew.org; Wed, 18 Sep 2019 12:20:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50253) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbtj-0000Ay-9K for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbth-0007bz-TX for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44294) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbth-0007bB-O2; Wed, 18 Sep 2019 11:29:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1282F8980EF; Wed, 18 Sep 2019 15:29:37 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80D535D6B2; Wed, 18 Sep 2019 15:29:35 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:28:56 +0200 Message-Id: <20190918152922.18949-4-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Wed, 18 Sep 2019 15:29:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 03/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We'll have to zero-out unused bit positions, so make sure to write the addresses back. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b02ad148e5..223312a4b1 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -52,6 +52,19 @@ static inline bool psw_key_valid(CPUS390XState *env, uin= t8_t psw_key) return true; } =20 +static bool is_destructive_overlap(CPUS390XState *env, uint64_t dest, + uint64_t src, uint32_t len) +{ + if (!len || src =3D=3D dest) { + return false; + } + /* Take care of wrapping at the end of address space. */ + if (unlikely(wrap_address(env, src + len - 1) < src)) { + return dest > src || dest <=3D wrap_address(env, src + len - 1); + } + return dest > src && dest <=3D src + len - 1; +} + /* Reduce the length so that addr + len doesn't cross a page boundary. */ static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr) { @@ -787,7 +800,11 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1,= uint32_t r2) uint8_t pad =3D env->regs[r2 + 1] >> 24; uint32_t cc; =20 - cc =3D do_mvcl(env, &dest, &destlen, &src, &srclen, pad, 1, ra); + if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { + cc =3D 3; + } else { + cc =3D do_mvcl(env, &dest, &destlen, &src, &srclen, pad, 1, ra); + } =20 env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srclen); --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823871; cv=none; d=zoho.com; s=zohoarc; b=A9o5xWchz3ChtT4PkpYwPZ8FVBmmBoNMPznmycvlZwPC/5RCKdOPouCkQIcUy2Zkc5orkr58ynoEMFP3UNoGAk5SjO6qyw3hNpKRkaie1QX08udiuzbplTSSJYo+rfSKp7nqoescg1TD4AMy3e675L+cXGszaN0xL9TT75zDIAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823871; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8mCugWdYoSLThXhLcrTT9eRn+ab2/7dWsEP8VIR8atE=; b=OBxOFiPXzt4kPTr0RsbEjWk4ipVB/bt4SQJ/gZGdLSJhWJWwyg1tT8bp+NOJsjMaRBbc7D0ZJ8TOliiEt+4L73amtcKe3GxFrc9+t9qq3aOMHYUSBHDBzQZe6vnw3LA+tEGycvivEcZt5wEaQiQZdkWlQXOnhhmep12Zw2EaI68= 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 1568823871193909.6591660050766; Wed, 18 Sep 2019 09:24:31 -0700 (PDT) Received: from localhost ([::1]:60634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAckn-0005cn-9F for importer@patchew.org; Wed, 18 Sep 2019 12:24:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50280) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbtl-0000FI-J8 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbtk-0007ea-AC for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtk-0007e2-2C; Wed, 18 Sep 2019 11:29:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18D7F3084045; Wed, 18 Sep 2019 15:29:39 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A5735D70D; Wed, 18 Sep 2019 15:29:37 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:28:57 +0200 Message-Id: <20190918152922.18949-5-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 18 Sep 2019 15:29:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 04/29] s390x/tcg: MVCL: 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Process max 4k bytes at a time, writing back registers between the accesses. The instruction is interruptible. "For operands longer than 2K bytes, access exceptions are not recognized for locations more than 2K bytes beyond the current location being processed." Note that on z/Architecture, 2k vs. 4k access cannot get differentiated as long as pages are not crossed. This seems to be a leftover from ESA/390. Simply stay within single pages. MVCL handling is quite different than MVCLE/MVCLU handling, so split up the handlers. Defer interrupt handling, as that will require more thought, add a TODO for that. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 44 +++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 223312a4b1..58ab2e48e3 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -798,19 +798,51 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1= , uint32_t r2) uint64_t srclen =3D env->regs[r2 + 1] & 0xffffff; uint64_t src =3D get_address(env, r2); uint8_t pad =3D env->regs[r2 + 1] >> 24; - uint32_t cc; + uint32_t cc, cur_len; =20 if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { cc =3D 3; + } else if (srclen =3D=3D destlen) { + cc =3D 0; + } else if (destlen < srclen) { + cc =3D 1; } else { - cc =3D do_mvcl(env, &dest, &destlen, &src, &srclen, pad, 1, ra); + cc =3D 2; } =20 - env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); - env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srclen); - set_address_zero(env, r1, dest); - set_address_zero(env, r2, src); + /* We might have to zero-out some bits even if there was no action. */ + if (unlikely(!destlen || cc =3D=3D 3)) { + set_address_zero(env, r2, src); + set_address_zero(env, r1, dest); + return cc; + } else if (!srclen) { + set_address_zero(env, r2, src); + } =20 + /* + * Only perform one type of type of operation (move/pad) in one step. + * Stay within single pages. + */ + while (destlen) { + cur_len =3D MIN(destlen, -(dest | TARGET_PAGE_MASK)); + if (!srclen) { + fast_memset(env, dest, pad, cur_len, ra); + } else { + cur_len =3D MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_le= n); + + fast_memmove(env, dest, src, cur_len, ra); + src =3D wrap_address(env, src + cur_len); + srclen -=3D cur_len; + env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srcl= en); + set_address_zero(env, r2, src); + } + dest =3D wrap_address(env, dest + cur_len); + destlen -=3D cur_len; + env->regs[r1 + 1] =3D deposit64(env->regs[r1 + 1], 0, 24, destlen); + set_address_zero(env, r1, dest); + + /* TODO: Deliver interrupts. */ + } return cc; } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824047; cv=none; d=zoho.com; s=zohoarc; b=hhDvVCmSlcJQ8AFKQ1dPNsbzkluOAwnilABrQosbj14MfZ+DAjn4LoAmAFCHdd871w/Q4H+OP4BLiD5GczLDkIJr7hX76nsqAQhv4iZgVu6mo88i4RVi9u5m4JNN+iqALq0sNSOIrMoRH087vuAwdwFcW3IpSdXm+EEwp4qzJMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824047; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Av0Dq9BYaqcD+LLNtTXDkCb04cn2AKYdyJxoE+r7pYs=; b=N4bh4SVguqQVHnhmZyUqYiZPoHL+bUmCVUa8ne4RuKLkW7mq0LY2WZedc9TVRpW3QLbmwVi4gvbcb/d6bqNVXAb3lgeDz+dxNS9FZOfGzEWSXMDtcQnX1X47o5AlIEUkPsaMRXP3mwEMWtKr1YQ2SMrkUataEMlWN19rWFGxwto= 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 1568824047854878.6625032923683; Wed, 18 Sep 2019 09:27:27 -0700 (PDT) Received: from localhost ([::1]:60662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcnd-00018c-W4 for importer@patchew.org; Wed, 18 Sep 2019 12:27:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50315) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbtn-0000I2-SV for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbtm-0007gx-OT for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59274) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtm-0007gC-IF; Wed, 18 Sep 2019 11:29:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0A583090FD3; Wed, 18 Sep 2019 15:29:41 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74CF35D6A5; Wed, 18 Sep 2019 15:29:39 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:28:58 +0200 Message-Id: <20190918152922.18949-6-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 18 Sep 2019 15:29:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 05/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's increment the length once. While at it, cleanup the comment. The memset() example is given as a programming note in the PoP, so drop the description. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 58ab2e48e3..013e8d6045 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -320,16 +320,20 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uin= t32_t l, uint64_t dest, HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - /* mvc and memmove do not behave the same when areas overlap! */ - /* mvc with source pointing to the byte after the destination is the - same as memset with the first source byte */ + /* MVC always copies one more byte than specified - maximum is 256 */ + l++; + + /* + * "When the operands overlap, the result is obtained as if the operan= ds + * were processed one byte at a time". Only non-destructive overlaps + * behave like memmove(). + */ if (dest =3D=3D src + 1) { - fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l + 1, ra); - } else if (dest < src || src + l < dest) { - fast_memmove(env, dest, src, l + 1, ra); + fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); + } else if (dest < src || src + l <=3D dest) { + fast_memmove(env, dest, src, l, ra); } else { - /* slow version with byte accesses which always work */ - for (i =3D 0; i <=3D l; i++) { + for (i =3D 0; i < l; i++) { uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); cpu_stb_data_ra(env, dest + i, x, ra); } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824183; cv=none; d=zoho.com; s=zohoarc; b=guk6f1yKzVIHZJlAmdBINXCAMw7IiOUAcgi2Xdb+4ccBGmwdAOIHgJ+1inN/A28y5hHYjI3GzB0kxCGXu7QsSu6INyK19JpJ6Mno2awbAr4m6I4CWAo4SKtS6B0pTNWNKCVn1KOY4ujsqCBfqtkyvGFtkQtR7iWSSjNL+jCLjwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824183; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3vbtQ/lB62vbeTp8UpH/tHmVVZImEv2SZ9fmQDRT3ME=; b=X/Z0z5HdMQRj8g6khi8ZF4UNDQwcd6XtvaFCEZfiC1kB+P2ppmXTTmut4WI2dBMMM2Z8FNwNtz8CqluuDQGvX3usPFBFFlwBH0xbIKGNAFTlsgmzhp3q2TOc5pnJ6SiQoV6AzeLRNzlpX/jK66SbahaiKBLTpoMvCg6HL6oYfHA= 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 1568824183946734.0896653443368; Wed, 18 Sep 2019 09:29:43 -0700 (PDT) Received: from localhost ([::1]:60688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcpo-0003d3-52 for importer@patchew.org; Wed, 18 Sep 2019 12:29:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50370) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbtv-0000Ra-Bx for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbtu-0007mM-AA for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtu-0007kz-0k; Wed, 18 Sep 2019 11:29:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABCB910CC1E6; Wed, 18 Sep 2019 15:29:48 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 100FF5D6D0; Wed, 18 Sep 2019 15:29:41 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:28:59 +0200 Message-Id: <20190918152922.18949-7-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Wed, 18 Sep 2019 15:29: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] [PULL SUBSYSTEM s390x 06/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's use the new helper, that also detects destructive overlaps when wrapping. We'll make the remaining code (e.g., fast_memmove()) aware of wrapping later. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 013e8d6045..c31cf49593 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -330,7 +330,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, */ if (dest =3D=3D src + 1) { fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); - } else if (dest < src || src + l <=3D dest) { + } else if (!is_destructive_overlap(env, dest, src, l)) { fast_memmove(env, dest, src, l, ra); } else { for (i =3D 0; i < l; i++) { --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823511; cv=none; d=zoho.com; s=zohoarc; b=GzorYbCe9OAZJJJijPrPxU31EVdOWB5F41dIjhDL7JPSVXymhnmFbYlsCxfpdgZG46GpCU4+0ewGpy/r0ASRMuDr9Nku86C4WYfvvaS18JCKZGspfu9RJYFK4IN1TQHS/MlCOx/XlcTgvhb2Xr05JMJB3GSLDURuw8gcxbdV/xE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823511; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GJ7szFietHKW/p9EIhgvaGaLDjVUCVRufBOpfdpg66w=; b=n/kJh45Wta5gnyjgIUt5ey0ezf8fzZDEbuCMJrSVaEDmBcPBVp9wU3BY4CbeYzumUGGjhhBOzHU565gBb9DLXpxjA3Tq6jeWMwJA0/ChzTsc1xELnSPWA5hE3K2419k/xrl3p7uRunyjTpxpzEtk8EOVOvVkX1fRaPH+xjEXJ0I= 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 156882351165225.86278278799591; Wed, 18 Sep 2019 09:18:31 -0700 (PDT) Received: from localhost ([::1]:60564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcew-0006EP-Bu for importer@patchew.org; Wed, 18 Sep 2019 12:18:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50408) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbtz-0000UR-BY for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbty-0007oM-1d for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtx-0007nF-SW; Wed, 18 Sep 2019 11:29:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06717A3D397; Wed, 18 Sep 2019 15:29:52 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 095DF5D6A5; Wed, 18 Sep 2019 15:29:48 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:00 +0200 Message-Id: <20190918152922.18949-8-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Wed, 18 Sep 2019 15:29: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] [PULL SUBSYSTEM s390x 07/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Perform the checks documented in the PoP. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index c31cf49593..7dfa848744 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -672,6 +672,13 @@ uint64_t HELPER(clst)(CPUS390XState *env, uint64_t c, = uint64_t s1, uint64_t s2) /* move page */ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64= _t r2) { + const bool f =3D extract64(r0, 11, 1); + const bool s =3D extract64(r0, 10, 1); + + if ((f && s) || extract64(r0, 12, 4)) { + s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC()); + } + /* ??? missing r0 handling, which includes access keys, but more importantly optional suppression of the exception! */ fast_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824310; cv=none; d=zoho.com; s=zohoarc; b=AnMs7Rhj+RdF21szYCA/ZgdPHVjVwEk40YZky4g1zWtmODmL5Kqhi1LZgwTxcjcsJV5q2fdDQEWIPwMEiX04UNAKWyyeKoF5hpmbG89rUL/FLlf0/a3Aay6GSBWkn4uOqC55Sk8ziwxsHra1NoXcKtyxQKN5bcgaBj1nfI1i6jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824310; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4eJVTKFHX9x+VPPIp429Ro5Wu2P++xQJz+haeHTaJr8=; b=M70xDNlApggotVDYnHdMTZ5oKgfq5vkQGTttxH5I2s4F+c+Fo4UEbYQ0op8bssAiVNl5xsPPp5qbuLdnMVe3KPriiu6uQUlxCAR52RWTTsTBBYSmBDTOjLiizkbTS2IkYdAdJI2eUNVC1ZYI2Uq0h+e1/2TLiZbrJCtWr8e/t6o= 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 1568824310052314.5410125982181; Wed, 18 Sep 2019 09:31:50 -0700 (PDT) Received: from localhost ([::1]:60710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcro-0005QX-Fe for importer@patchew.org; Wed, 18 Sep 2019 12:31:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50434) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbu0-0000V9-Fa for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbtz-0007pQ-GW for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbtz-0007oX-9L; Wed, 18 Sep 2019 11:29:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C730302C096; Wed, 18 Sep 2019 15:29:54 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 658B35D6A5; Wed, 18 Sep 2019 15:29:52 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:01 +0200 Message-Id: <20190918152922.18949-9-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 18 Sep 2019 15:29: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] [PULL SUBSYSTEM s390x 08/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have to mask of any unused bits. While at it, document what exactly is missing. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 7dfa848744..746f647303 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -679,8 +679,15 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0,= uint64_t r1, uint64_t r2) s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC()); } =20 - /* ??? missing r0 handling, which includes access keys, but more - importantly optional suppression of the exception! */ + r1 =3D wrap_address(env, r1 & TARGET_PAGE_MASK); + r2 =3D wrap_address(env, r2 & TARGET_PAGE_MASK); + + /* + * TODO: + * - Access key handling + * - CC-option with surpression of page-translation exceptions + * - Store r1/r2 register identifiers at real location 162 + */ fast_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); return 0; /* data moved */ } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824461; cv=none; d=zoho.com; s=zohoarc; b=NA+u7n04SHKnqf8aPffV12WLxCXUWKtUb3gJJ2kPW0JhwRWdPU/Rj6053R//giktfT8Octldz5hG7sOT3mPWJQe1MVtR7LADzFikZO4kIcPU6t6dipHNaWxhYY9YrTqvJH7NUbJZcMwWe2613LgHelJVh1qLTKNlP6PbKDifIKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824461; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PQcKp6HOn3St9MZkXioQCqVSwAE6SiOG+3lwRjCZpv0=; b=HQXeVm+sGMjmxiuSzxXvOywzPtFHchhr4XsDw2YmqHDlE+ONdg3SKzQGatFu8Hf9YJWALOnSPs6a2qGE9uE56MOenVTuMaULOH1V+qO3CoqieXqh309j5DANYQn/k2NXlyGjT51aRJ9BlhDsFqbeTBNG0Rfx+IYbtOXF7I+j+WU= 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 1568824461109259.5781140248714; Wed, 18 Sep 2019 09:34:21 -0700 (PDT) Received: from localhost ([::1]:60734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcuJ-0008LS-3O for importer@patchew.org; Wed, 18 Sep 2019 12:34:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbu2-0000Vz-Sg for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbu1-0007qm-DW for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:29:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbu1-0007q7-6K; Wed, 18 Sep 2019 11:29:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BE7B18CB904; Wed, 18 Sep 2019 15:29:56 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5771B5D6D0; Wed, 18 Sep 2019 15:29:54 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:02 +0200 Message-Id: <20190918152922.18949-10-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Wed, 18 Sep 2019 15:29: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] [PULL SUBSYSTEM s390x 09/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's stay within single pages. ... and indicate cc=3D3 in case there is work remaining. Keep unicode padding simple. While reworking, properly wrap the addresses. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 54 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 746f647303..86238e0163 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -768,8 +768,8 @@ static inline uint32_t do_mvcl(CPUS390XState *env, uint64_t *src, uint64_t *srclen, uint16_t pad, int wordsize, uintptr_t ra) { - uint64_t len =3D MIN(*srclen, *destlen); - uint32_t cc; + int len =3D MIN(*destlen, -(*dest | TARGET_PAGE_MASK)); + int i, cc; =20 if (*destlen =3D=3D *srclen) { cc =3D 0; @@ -779,32 +779,40 @@ static inline uint32_t do_mvcl(CPUS390XState *env, cc =3D 2; } =20 - /* Copy the src array */ - fast_memmove(env, *dest, *src, len, ra); - *src +=3D len; - *srclen -=3D len; - *dest +=3D len; - *destlen -=3D len; + if (!*destlen) { + return cc; + } =20 - /* Pad the remaining area */ - if (wordsize =3D=3D 1) { - fast_memset(env, *dest, pad, *destlen, ra); - *dest +=3D *destlen; - *destlen =3D 0; + /* + * Only perform one type of type of operation (move/pad) at a time. + * Stay within single pages. + */ + if (*srclen) { + /* Copy the src array */ + len =3D MIN(MIN(*srclen, -(*src | TARGET_PAGE_MASK)), len); + *destlen -=3D len; + *srclen -=3D len; + fast_memmove(env, *dest, *src, len, ra); + *src =3D wrap_address(env, *src + len); + *dest =3D wrap_address(env, *dest + len); + } else if (wordsize =3D=3D 1) { + /* Pad the remaining area */ + *destlen -=3D len; + fast_memset(env, *dest, pad, len, ra); + *dest =3D wrap_address(env, *dest + len); } else { - /* If remaining length is odd, pad with odd byte first. */ - if (*destlen & 1) { - cpu_stb_data_ra(env, *dest, pad & 0xff, ra); - *dest +=3D 1; - *destlen -=3D 1; - } - /* The remaining length is even, pad using words. */ - for (; *destlen; *dest +=3D 2, *destlen -=3D 2) { - cpu_stw_data_ra(env, *dest, pad, ra); + /* The remaining length selects the padding byte. */ + for (i =3D 0; i < len; (*destlen)--, i++) { + if (*destlen & 1) { + cpu_stb_data_ra(env, *dest, pad, ra); + } else { + cpu_stb_data_ra(env, *dest, pad >> 8, ra); + } + *dest =3D wrap_address(env, *dest + 1); } } =20 - return cc; + return *destlen ? 3 : cc; } =20 /* move long */ --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823712; cv=none; d=zoho.com; s=zohoarc; b=l2kEBffLVlXrA6nc/lbFjo5IRqXJG9dUD2ioJ1ZyHgtSx8w+Vi7Ue8Iom/d9FejKmyyHKGubCEFTf+5BHtKoax7fF9BXY4K/eTTdSOHK1pYaYt56I8pjzCU7WKuFbRP8+j3dXkGKQ6xPFLuYt7UmHyu93kUFQNYhIRAvKIdVWRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823712; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ta3xDJdf1twB/P0yHinG5Y8t4yBSTsGgY9arihUNrM4=; b=k3/YM9EVMBJSUkndu4YwZzo6CXoiQV8S5V2Qkh0TVdaOZeQeBt2+RR9c1dmcMe/zX5l1plSyh+OVKy3cSgL9XTDwRl8/Mhlq8aMGVWY2Uuto0HJ9ul1psT2Cw37v1+MyAe/weblOlBFBnIEz0d5yqvyx/K7+71q9xIszSL9IfxY= 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 1568823712466802.1513890236955; Wed, 18 Sep 2019 09:21:52 -0700 (PDT) Received: from localhost ([::1]:60598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAciE-0001v1-I1 for importer@patchew.org; Wed, 18 Sep 2019 12:21:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50490) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbu7-0000YB-07 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbu5-0007tF-K6 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbu5-0007sm-DP; Wed, 18 Sep 2019 11:30:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC84F111B947; Wed, 18 Sep 2019 15:30:00 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 748455D6A5; Wed, 18 Sep 2019 15:29:56 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:03 +0200 Message-Id: <20190918152922.18949-11-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Wed, 18 Sep 2019 15:30: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] [PULL SUBSYSTEM s390x 10/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's perform the documented checks. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 86238e0163..20e1ac0ea9 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1960,12 +1960,18 @@ uint32_t HELPER(rrbe)(CPUS390XState *env, uint64_t = r2) =20 uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { + const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; uintptr_t ra =3D GETPC(); int cc =3D 0, i; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); =20 + if (!(env->psw.mask & PSW_MASK_DAT) || !(env->cregs[0] & CR0_SECONDARY= ) || + psw_as =3D=3D AS_HOME || psw_as =3D=3D AS_ACCREG) { + s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); + } + if (l > 256) { /* max 256 */ l =3D 256; @@ -1983,12 +1989,18 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) =20 uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { + const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; uintptr_t ra =3D GETPC(); int cc =3D 0, i; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); =20 + if (!(env->psw.mask & PSW_MASK_DAT) || !(env->cregs[0] & CR0_SECONDARY= ) || + psw_as =3D=3D AS_HOME || psw_as =3D=3D AS_ACCREG) { + s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); + } + if (l > 256) { /* max 256 */ l =3D 256; --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823864; cv=none; d=zoho.com; s=zohoarc; b=XyyddlHnuBzaOQfQP1ZIZ6RFAS4rncqvzfI1gwjt/kFmB6/dPCbXRhEPQBnxc4g9GR/sA2VCUIv4VirKe1rZQxHDeJDAdpQv00X/+MQd3wQ6D3O8KuRtNjeQPy9VUmfJCJ7j6cepw4jxCJSQGJyyM/Z4EEEtvpHUCUitXB6GmjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823864; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QYDWtBeDEcq080AUvz+Fe9NHCB4RgHKthwMLQO93XW0=; b=lkaUpC2Mg6IoAlPo11MkafO2Wq+p63JEZA1OIPsCASgvAo0+SS1zJfUVTapO8mGYNwQomoAGO6rZNSyAO2HNtWKJiskKTlh0ZZ/8XJ9ZyESbYcJagdJn7A7RLk/yHj0TIBYwnc/EjY7gx87m7kN5IrO0RQgPHi89xHjflpMpK1Y= 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 1568823864901510.08766739100656; Wed, 18 Sep 2019 09:24:24 -0700 (PDT) Received: from localhost ([::1]:60630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAckc-0005RM-NE for importer@patchew.org; Wed, 18 Sep 2019 12:24:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50524) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbuI-0000nc-13 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbuG-000860-PK for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbuG-000855-Jw; Wed, 18 Sep 2019 11:30:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D756E7F759; Wed, 18 Sep 2019 15:30:11 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 016535D6B2; Wed, 18 Sep 2019 15:30:00 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:04 +0200 Message-Id: <20190918152922.18949-12-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Wed, 18 Sep 2019 15:30:11 +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] [PULL SUBSYSTEM s390x 11/29] s390x/tcg: MVCOS: Lengths are 32 bit in 24/31-bit mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Triggered by a review comment from Richard, also MVCOS has a 32-bit length in 24/31-bit addressing mode. Add a new helper. Rename wrap_length() to wrap_length31(). Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 20e1ac0ea9..320e9ee65c 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -528,7 +528,15 @@ static inline void set_address(CPUS390XState *env, int= reg, uint64_t address) } } =20 -static inline uint64_t wrap_length(CPUS390XState *env, uint64_t length) +static inline uint64_t wrap_length32(CPUS390XState *env, uint64_t length) +{ + if (!(env->psw.mask & PSW_MASK_64)) { + return (uint32_t)length; + } + return length; +} + +static inline uint64_t wrap_length31(CPUS390XState *env, uint64_t length) { if (!(env->psw.mask & PSW_MASK_64)) { /* 24-Bit and 31-Bit mode */ @@ -539,7 +547,7 @@ static inline uint64_t wrap_length(CPUS390XState *env, = uint64_t length) =20 static inline uint64_t get_length(CPUS390XState *env, int reg) { - return wrap_length(env, env->regs[reg]); + return wrap_length31(env, env->regs[reg]); } =20 static inline void set_length(CPUS390XState *env, int reg, uint64_t length) @@ -2378,7 +2386,7 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t d= est, uint64_t src, s390_program_interrupt(env, PGM_PRIVILEGED, 6, ra); } =20 - len =3D wrap_length(env, len); + len =3D wrap_length32(env, len); if (len > 4096) { cc =3D 3; len =3D 4096; --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824041; cv=none; d=zoho.com; s=zohoarc; b=jtr/0WCMwPjhWBD7So80wx3X8p2K3beGQXPuKSVU41LwR1oWK8KGIWmph21maHROkUntyVgM/Xu5MmTQTrd49+DvrNeGNp3FDGqdErkpTt25/x8lNZ5ThWh5UB1WcknFwAzDnNhrS0cu/uLMnbxEkSzRZxGZERCeYQC6y1RDYJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824041; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PhtO3a3QpyY0ZLhN9leeXZ7DGvQyukeX9hfZEyx1Urc=; b=Z/awA2r11XcYjF6oqu57lXUrvzaH3N3Gz9FxL1AmMdpPua3cRvzZEUlJaYkFKDzuMB/mu45ya5/PkVdkWEXVTTXNKuVyu/960N1qMvwfiBiuwTvNyhgo9l2YVdQRxym2gg7fokKtgRiZPhtR7yQ6N8Ug+UR7J+nPtqtHitIia2k= 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 1568824041380350.99331399541904; Wed, 18 Sep 2019 09:27:21 -0700 (PDT) Received: from localhost ([::1]:60660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcnU-0000wl-Il for importer@patchew.org; Wed, 18 Sep 2019 12:27:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50554) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbuZ-0001Fo-NY for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbuY-0008GW-I5 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbuY-0008Fx-Cv; Wed, 18 Sep 2019 11:30:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3AF710DCC9F; Wed, 18 Sep 2019 15:30:29 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3311D61F21; Wed, 18 Sep 2019 15:30:12 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:05 +0200 Message-Id: <20190918152922.18949-13-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Wed, 18 Sep 2019 15:30:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 12/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" ... and don't perform any move in case the length is zero. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 320e9ee65c..41d7336a1a 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1980,10 +1980,13 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); } =20 + l =3D wrap_length32(env, l); if (l > 256) { /* max 256 */ l =3D 256; cc =3D 3; + } else if (!l) { + return cc; } =20 /* XXX replace w/ memcpy */ @@ -2009,10 +2012,13 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) s390_program_interrupt(env, PGM_SPECIAL_OP, ILEN_AUTO, ra); } =20 + l =3D wrap_length32(env, l); if (l > 256) { /* max 256 */ l =3D 256; cc =3D 3; + } else if (!l) { + return cc; } =20 /* XXX replace w/ memcpy */ --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568823883; cv=none; d=zoho.com; s=zohoarc; b=Q+Ncc4lekBDoiBLHu5yh8kBBS+Rd1aOspYV1jCExau9QRHirgiYJ5Wy/pFKQu3+a57QuR0Pk+INgyhvLSVbet1q5ji6YttBDWhfGOmtS/uy92qVud+R1GW694K1noe99Uek77agltfwVILr/i2ENps2q7UXR6JiKf8z3qvtma24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568823883; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JWb5mB8OScsytaBd+Q7VG884iKwWMaCTRQQkRFYpscg=; b=KHdxZuoJVdqx/EH3eBUlhVW51go0u5X9rEaE+FadUHMSHvwQfmazYhstDUwK6eEljYtOLamxzIIe2KL9aoyuzusGuV4ceSduii2qwxtUfnhXpXUlWk9QvHNXdvlpIg46wlQGyTxQ2RQAQBoCtVAjNARYPF5ohe7+GJAOGVWnCDY= 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 1568823883860696.9755269058942; Wed, 18 Sep 2019 09:24:43 -0700 (PDT) Received: from localhost ([::1]:60636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcl0-0005um-2k for importer@patchew.org; Wed, 18 Sep 2019 12:24:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50577) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbug-0001OW-5B for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbue-0008Jh-TI for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44890) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbue-0008JE-Gg; Wed, 18 Sep 2019 11:30:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3A5A315C030; Wed, 18 Sep 2019 15:30:35 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39BC5D6C8; Wed, 18 Sep 2019 15:30:29 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:06 +0200 Message-Id: <20190918152922.18949-14-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 18 Sep 2019 15:30:35 +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] [PULL SUBSYSTEM s390x 13/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Bit position 32-55 of general register 0 must be zero. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 41d7336a1a..ec27be174b 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -706,6 +706,9 @@ uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c, u= int64_t d, uint64_t s) uintptr_t ra =3D GETPC(); uint32_t len; =20 + if (c & 0xffffff00ull) { + s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); + } c =3D c & 0xff; d =3D wrap_address(env, d); s =3D wrap_address(env, s); --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824530; cv=none; d=zoho.com; s=zohoarc; b=mb6U8e7z333UF5936rwCCrpSOXz/TyZDzXQ935xjKP5RGfWXoG7BH3Y/toJW/ce2tXbNS2EqqGt2Ebmhba8ea5LXyx/m499Wum4Uhaq7Vo7GgmQp7PI0vWb0x63nHSB6GouUr66PDVEBiMUYm61LasNcsdJeBW2ibSipif4gXvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824530; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iLlW5P7me8TjkWL2oZqeYBVEcd5QQeRvp/6cNT6xXf4=; b=kjjKXULpFW7zzKuwvGpXIm7oINmaJlwep4nneHwEyuatYWLmIcpcvH3z+Mp0aMnmHOD8D1VIRbu0YPFkL/D/WNFISBW4AJ1uOI3kkzE7Rv8oebuJWUSbdNsvWo+qjpwS17mwxvAVdY//itIUQ/Yfp6TbrUsyS113nBcjPlh5H5Y= 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 1568824530517414.3151716647808; Wed, 18 Sep 2019 09:35:30 -0700 (PDT) Received: from localhost ([::1]:60744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcvO-0001bK-Cu for importer@patchew.org; Wed, 18 Sep 2019 12:35:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50653) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbuq-0001eb-9w for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbuo-00004r-W1 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbuo-0008WA-OZ; Wed, 18 Sep 2019 11:30:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F05D300BEB4; Wed, 18 Sep 2019 15:30:46 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23B2A5D6B2; Wed, 18 Sep 2019 15:30:35 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:07 +0200 Message-Id: <20190918152922.18949-15-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 18 Sep 2019 15:30: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] [PULL SUBSYSTEM s390x 14/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 24 and 31-bit address space handling is wrong when it comes to storing back the addresses to the register. While at it, read gprs 0 implicitly. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/helper.h | 2 +- target/s390x/insn-data.def | 2 +- target/s390x/mem_helper.c | 26 +++++++++++--------------- target/s390x/translate.c | 8 ++++++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index e9aff83b05..56e8149866 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -20,7 +20,7 @@ DEF_HELPER_FLAGS_4(mvn, TCG_CALL_NO_WG, void, env, i32, i= 64, i64) DEF_HELPER_FLAGS_4(mvo, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(mvpg, TCG_CALL_NO_WG, i32, env, i64, i64, i64) DEF_HELPER_FLAGS_4(mvz, TCG_CALL_NO_WG, void, env, i32, i64, i64) -DEF_HELPER_4(mvst, i64, env, i64, i64, i64) +DEF_HELPER_3(mvst, i32, env, i32, i32) DEF_HELPER_4(ex, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(stam, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index f421184fcd..449eee1662 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -637,7 +637,7 @@ /* MOVE PAGE */ C(0xb254, MVPG, RRE, Z, r1_o, r2_o, 0, 0, mvpg, 0) /* MOVE STRING */ - C(0xb255, MVST, RRE, Z, r1_o, r2_o, 0, 0, mvst, 0) + C(0xb255, MVST, RRE, Z, 0, 0, 0, 0, mvst, 0) /* MOVE WITH OPTIONAL SPECIFICATION */ C(0xc800, MVCOS, SSF, MVCOS, la1, a2, 0, 0, mvcos, 0) /* MOVE WITH OFFSET */ diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index ec27be174b..a24506676b 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -700,18 +700,18 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0= , uint64_t r1, uint64_t r2) return 0; /* data moved */ } =20 -/* string copy (c is string terminator) */ -uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c, uint64_t d, uint64_t= s) +/* string copy */ +uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2) { + const uint64_t d =3D get_address(env, r1); + const uint64_t s =3D get_address(env, r2); + const uint8_t c =3D env->regs[0]; uintptr_t ra =3D GETPC(); uint32_t len; =20 - if (c & 0xffffff00ull) { + if (env->regs[0] & 0xffffff00ull) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); } - c =3D c & 0xff; - d =3D wrap_address(env, d); - s =3D wrap_address(env, s); =20 /* Lest we fail to service interrupts in a timely manner, limit the amount of work we're willing to do. For now, let's cap at 8k. */ @@ -719,17 +719,13 @@ uint64_t HELPER(mvst)(CPUS390XState *env, uint64_t c,= uint64_t d, uint64_t s) uint8_t v =3D cpu_ldub_data_ra(env, s + len, ra); cpu_stb_data_ra(env, d + len, v, ra); if (v =3D=3D c) { - /* Complete. Set CC=3D1 and advance R1. */ - env->cc_op =3D 1; - env->retxl =3D s; - return d + len; + set_address_zero(env, r1, d + len); + return 1; } } - - /* Incomplete. Set CC=3D3 and signal to advance R1 and R2. */ - env->cc_op =3D 3; - env->retxl =3D s + len; - return d + len; + set_address_zero(env, r1, d + len); + set_address_zero(env, r2, s + len); + return 3; } =20 /* load access registers r1 to r3 from memory at a2 */ diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 2927247c82..b0a2500e5f 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3488,9 +3488,13 @@ static DisasJumpType op_mvpg(DisasContext *s, DisasO= ps *o) =20 static DisasJumpType op_mvst(DisasContext *s, DisasOps *o) { - gen_helper_mvst(o->in1, cpu_env, regs[0], o->in1, o->in2); + TCGv_i32 t1 =3D tcg_const_i32(get_field(s->fields, r1)); + TCGv_i32 t2 =3D tcg_const_i32(get_field(s->fields, r2)); + + gen_helper_mvst(cc_op, cpu_env, t1, t2); + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t2); set_cc_static(s); - return_low128(o->in2); return DISAS_NEXT; } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824663; cv=none; d=zoho.com; s=zohoarc; b=PgKLeAX8aFH60rNeOwrQlHevTnBQGnpB6yf70O601jdzKqRgsvmmCTSFokm0MULkNIGCCjZTjM+0yDaDm3tkkpO59GlJpyMarvaIs3Ghh4MoAWlvEzz5FEcC/S2TXYX4BqKJiYCFHW7zjaySpb02P43alQZD8x49mJFDGh64/Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824663; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=B6D3H4fq/SqAp0OP3zYKoJh4PFgIUQ8xc0jce1MtqyY=; b=jaGpk61QCht9dg9Gr6FacAUtzUji3OjKRclyWz+MQhAGOb7QkW8aGwLlMiR1kdQGciKmzcKti8G/fmKvlo0V8ce3tc1Kql3F8+6bWKZrs6B1p7LuwkZlfDvB/daYTV21k+3/RF6T+0lOESDBxDHqdh0SmUNKbUU8WSaM8XvQwuU= 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 1568824663756926.8427110391667; Wed, 18 Sep 2019 09:37:43 -0700 (PDT) Received: from localhost ([::1]:60788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcxZ-0004mN-Tu for importer@patchew.org; Wed, 18 Sep 2019 12:37:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50665) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbus-0001gs-8G for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbur-00006N-4O for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:30:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbuq-00005j-VZ; Wed, 18 Sep 2019 11:30:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4833E3058359; Wed, 18 Sep 2019 15:30:48 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D1075D6B2; Wed, 18 Sep 2019 15:30:46 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:08 +0200 Message-Id: <20190918152922.18949-16-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 18 Sep 2019 15:30: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] [PULL SUBSYSTEM s390x 15/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Although we basically ignore the index all the time for CONFIG_USER_ONLY, let's simply skip all the checks and always return MMU_USER_IDX in cpu_mmu_index() and get_mem_index(). Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 4 ++++ target/s390x/translate.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 79202c0980..163dae13d7 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -328,6 +328,9 @@ extern const VMStateDescription vmstate_s390_cpu; =20 static inline int cpu_mmu_index(CPUS390XState *env, bool ifetch) { +#ifdef CONFIG_USER_ONLY + return MMU_USER_IDX; +#else if (!(env->psw.mask & PSW_MASK_DAT)) { return MMU_REAL_IDX; } @@ -351,6 +354,7 @@ static inline int cpu_mmu_index(CPUS390XState *env, boo= l ifetch) default: abort(); } +#endif } =20 static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *= pc, diff --git a/target/s390x/translate.c b/target/s390x/translate.c index b0a2500e5f..a3e43ff9ec 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -318,6 +318,9 @@ static inline uint64_t ld_code4(CPUS390XState *env, uin= t64_t pc) =20 static int get_mem_index(DisasContext *s) { +#ifdef CONFIG_USER_ONLY + return MMU_USER_IDX; +#else if (!(s->base.tb->flags & FLAG_MASK_DAT)) { return MMU_REAL_IDX; } @@ -333,6 +336,7 @@ static int get_mem_index(DisasContext *s) tcg_abort(); break; } +#endif } =20 static void gen_exception(int excp) --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824360; cv=none; d=zoho.com; s=zohoarc; b=mYtNuoknpHAO8fmRMi7DTpKMDfUI3tKiJYTjqKL08UHqsNFQgpmOIdpYEtAa8bbau5X5C2Jr3wsf6bn04aKWl2MEYizpLkOnIYMsNA0MdlLXGGz3xRxQZF0DHD2y62T4u9HhGyjMg5Qs/3XVxuo1GZ4XXa2t1m+HvhhwC9k0Nhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824360; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3/5u6E28FmxNGeeoAFmS+8BbZJvEEoNo+c62AbfRCEo=; b=haohvA6Uikn/CE91qyyLaokc7ZqjlsxkbMEKzOGwMYh1ZJt9klcRL4bML6glqcO5QAXF4T2APXv5Nwls+VTDiZG65cqLEYJLT1SDpe3QnlPW1wdYf+4jMN7vthXtv4TYSywfu0k5fS9loWIIFVRofHf/Elp9Thb2d1E4h9A2TCU= 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 1568824360901475.28709085749745; Wed, 18 Sep 2019 09:32:40 -0700 (PDT) Received: from localhost ([::1]:60720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcsc-0006To-7H for importer@patchew.org; Wed, 18 Sep 2019 12:32:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50723) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvO-00023M-Se for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvN-0000W7-5d for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvM-0000Vc-UR; Wed, 18 Sep 2019 11:31:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DAA8C0546F2; Wed, 18 Sep 2019 15:31:20 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id A516B5D6B2; Wed, 18 Sep 2019 15:30:48 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:09 +0200 Message-Id: <20190918152922.18949-17-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 16/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Replace fast_memset() by access_memset(), that first tries to probe access to all affected pages (maximum is two). We'll use the same mechanism for other types of accesses soon. Only in very rare cases (especially TLB_NOTDIRTY), we'll have to fallback to ld/st helpers. Try to speed up that case as suggested by Richard. We'll rework most involved handlers soon to do all accesses via new fault-safe helpers, especially MVC. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 123 +++++++++++++++++++++++++++++++------- 1 file changed, 103 insertions(+), 20 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index a24506676b..dd5da70746 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -117,27 +117,95 @@ static inline void cpu_stsize_data_ra(CPUS390XState *= env, uint64_t addr, } } =20 -static void fast_memset(CPUS390XState *env, uint64_t dest, uint8_t byte, - uint32_t l, uintptr_t ra) +/* An access covers at most 4096 bytes and therefore at most two pages. */ +typedef struct S390Access { + target_ulong vaddr1; + target_ulong vaddr2; + char *haddr1; + char *haddr2; + uint16_t size1; + uint16_t size2; + /* + * If we can't access the host page directly, we'll have to do I/O acc= ess + * via ld/st helpers. These are internal details, so we store the + * mmu idx to do the access here instead of passing it around in the + * helpers. Maybe, one day we can get rid of ld/st access - once we can + * handle TLB_NOTDIRTY differently. We don't expect these special acce= sses + * to trigger exceptions - only if we would have TLB_NOTDIRTY on LAP + * pages, we might trigger a new MMU translation - very unlikely that + * the mapping changes in between and we would trigger a fault. + */ + int mmu_idx; +} S390Access; + +static S390Access access_prepare(CPUS390XState *env, vaddr vaddr, int size, + MMUAccessType access_type, int mmu_idx, + uintptr_t ra) { - int mmu_idx =3D cpu_mmu_index(env, false); + S390Access access =3D { + .vaddr1 =3D vaddr, + .size1 =3D MIN(size, -(vaddr | TARGET_PAGE_MASK)), + .mmu_idx =3D mmu_idx, + }; =20 - while (l > 0) { - void *p =3D tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_idx); - if (p) { - /* Access to the whole page in write mode granted. */ - uint32_t l_adj =3D adj_len_to_page(l, dest); - memset(p, byte, l_adj); - dest +=3D l_adj; - l -=3D l_adj; + g_assert(size > 0 && size <=3D 4096); + access.haddr1 =3D probe_access(env, access.vaddr1, access.size1, acces= s_type, + mmu_idx, ra); + + if (unlikely(access.size1 !=3D size)) { + /* The access crosses page boundaries. */ + access.vaddr2 =3D wrap_address(env, vaddr + access.size1); + access.size2 =3D size - access.size1; + access.haddr2 =3D probe_access(env, access.vaddr2, access.size2, + access_type, mmu_idx, ra); + } + return access; +} + +/* Helper to handle memset on a single page. */ +static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr, + uint8_t byte, uint16_t size, int mmu_idx, + uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + g_assert(haddr); + memset(haddr, byte, size); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + int i; + + if (likely(haddr)) { + memset(haddr, byte, size); + } else { + /* + * Do a single access and test if we can then get access to the + * page. This is especially relevant to speed up TLB_NOTDIRTY. + */ + g_assert(size > 0); + helper_ret_stb_mmu(env, vaddr, byte, oi, ra); + haddr =3D tlb_vaddr_to_host(env, vaddr, MMU_DATA_STORE, mmu_idx); + if (likely(haddr)) { + memset(haddr + 1, byte, size - 1); } else { - /* We failed to get access to the whole page. The next write - access will likely fill the QEMU TLB for the next iteration= . */ - cpu_stb_data_ra(env, dest, byte, ra); - dest++; - l--; + for (i =3D 1; i < size; i++) { + helper_ret_stb_mmu(env, vaddr + i, byte, oi, ra); + } } } +#endif +} + +static void access_memset(CPUS390XState *env, S390Access *desta, + uint8_t byte, uintptr_t ra) +{ + + do_access_memset(env, desta->vaddr1, desta->haddr1, byte, desta->size1, + desta->mmu_idx, ra); + if (likely(!desta->size2)) { + return; + } + do_access_memset(env, desta->vaddr2, desta->haddr2, byte, desta->size2, + desta->mmu_idx, ra); } =20 #ifndef CONFIG_USER_ONLY @@ -259,15 +327,19 @@ uint32_t HELPER(nc)(CPUS390XState *env, uint32_t l, u= int64_t dest, static uint32_t do_helper_xc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 + desta =3D access_prepare(env, dest, l + 1, MMU_DATA_STORE, mmu_idx, ra= ); + /* xor with itself is the same as memset(0) */ if (src =3D=3D dest) { - fast_memset(env, dest, 0, l + 1, ra); + access_memset(env, &desta, 0, ra); return 0; } =20 @@ -315,6 +387,8 @@ uint32_t HELPER(oc)(CPUS390XState *env, uint32_t l, uin= t64_t dest, static uint32_t do_helper_mvc(CPUS390XState *env, uint32_t l, uint64_t des= t, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access desta; uint32_t i; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", @@ -323,13 +397,15 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uin= t32_t l, uint64_t dest, /* MVC always copies one more byte than specified - maximum is 256 */ l++; =20 + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + /* * "When the operands overlap, the result is obtained as if the operan= ds * were processed one byte at a time". Only non-destructive overlaps * behave like memmove(). */ if (dest =3D=3D src + 1) { - fast_memset(env, dest, cpu_ldub_data_ra(env, src, ra), l, ra); + access_memset(env, &desta, cpu_ldub_data_ra(env, src, ra), ra); } else if (!is_destructive_overlap(env, dest, src, l)) { fast_memmove(env, dest, src, l, ra); } else { @@ -775,7 +851,9 @@ static inline uint32_t do_mvcl(CPUS390XState *env, uint64_t *src, uint64_t *srclen, uint16_t pad, int wordsize, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); int len =3D MIN(*destlen, -(*dest | TARGET_PAGE_MASK)); + S390Access desta; int i, cc; =20 if (*destlen =3D=3D *srclen) { @@ -805,7 +883,8 @@ static inline uint32_t do_mvcl(CPUS390XState *env, } else if (wordsize =3D=3D 1) { /* Pad the remaining area */ *destlen -=3D len; - fast_memset(env, *dest, pad, len, ra); + desta =3D access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx,= ra); + access_memset(env, &desta, pad, ra); *dest =3D wrap_address(env, *dest + len); } else { /* The remaining length selects the padding byte. */ @@ -825,6 +904,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, /* move long */ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, uint32_t r2) { + const int mmu_idx =3D cpu_mmu_index(env, false); uintptr_t ra =3D GETPC(); uint64_t destlen =3D env->regs[r1 + 1] & 0xffffff; uint64_t dest =3D get_address(env, r1); @@ -832,6 +912,7 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) uint64_t src =3D get_address(env, r2); uint8_t pad =3D env->regs[r2 + 1] >> 24; uint32_t cc, cur_len; + S390Access desta; =20 if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { cc =3D 3; @@ -859,7 +940,9 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) while (destlen) { cur_len =3D MIN(destlen, -(dest | TARGET_PAGE_MASK)); if (!srclen) { - fast_memset(env, dest, pad, cur_len, ra); + desta =3D access_prepare(env, dest, cur_len, MMU_DATA_STORE, m= mu_idx, + ra); + access_memset(env, &desta, pad, ra); } else { cur_len =3D MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_le= n); =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824866; cv=none; d=zoho.com; s=zohoarc; b=OPDlCXWrACseP3579nWrfL6y14AH5LNg6ZAuz9U4ZkRdDkrlzbhROOriArkpZnmRmZK3X/QKhxpjdDnNEWz9fSpggiUigx3aswRwkLe4KfRxXXL5mKDH8HQpCA97RsYAUlq3LDiFbdnk4N5R+7B2DUzai9WdpCxx87aRgjVkaGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824866; 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=v7DUeIpMnALtW5MyH0+Go6q8DdbO1Gy1zalU4S/qT4o=; b=WnnDbMjkjlf/Y4fIzqrKwhp73VyAJZ2Ny+PBJFtHoCjW1K6iOQA4CKmPV8lklyUI8TLoTiI3pqVNBacWyoO30/VWdGOc2X329udIQMhxkIHLdvMQBd//772ke8ol2Ei2xWimCMdQfw3VJZ6F5GhBxqVb/Q1IVZpokDw/xbrSvHw= 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 1568824866263467.7235521558448; Wed, 18 Sep 2019 09:41:06 -0700 (PDT) Received: from localhost ([::1]:60820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd0q-0008Ef-3P for importer@patchew.org; Wed, 18 Sep 2019 12:41:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50741) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvR-00025n-4R for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvP-0000XV-4R for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33300) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvO-0000Wt-Rs; Wed, 18 Sep 2019 11:31:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C72C3C93D; Wed, 18 Sep 2019 15:31:22 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87FA95D6B2; Wed, 18 Sep 2019 15:31:20 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:10 +0200 Message-Id: <20190918152922.18949-18-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 18 Sep 2019 15:31:22 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 17/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Replace fast_memmove() variants by access_memmove() variants, that first try to probe access to all affected pages (maximum is two pages). Introduce access_get_byte()/access_set_byte(). We might be able to speed up memmove in special cases even further (do single-byte access, use memmove() for remaining bytes in page), however, we'll skip that for now. In MVCOS, simply always call access_memmove_as() and drop the TODO about LAP. LAP is already handled in the MMU. Get rid of adj_len_to_page(), which is now unused. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 232 ++++++++++++++++++++++---------------- 1 file changed, 133 insertions(+), 99 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index dd5da70746..e50cec9263 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -65,17 +65,6 @@ static bool is_destructive_overlap(CPUS390XState *env, u= int64_t dest, return dest > src && dest <=3D src + len - 1; } =20 -/* Reduce the length so that addr + len doesn't cross a page boundary. */ -static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr) -{ -#ifndef CONFIG_USER_ONLY - if ((addr & ~TARGET_PAGE_MASK) + len - 1 >=3D TARGET_PAGE_SIZE) { - return -(addr | TARGET_PAGE_MASK); - } -#endif - return len; -} - /* Trigger a SPECIFICATION exception if an address or a length is not naturally aligned. */ static inline void check_alignment(CPUS390XState *env, uint64_t v, @@ -208,39 +197,110 @@ static void access_memset(CPUS390XState *env, S390Ac= cess *desta, desta->mmu_idx, ra); } =20 -#ifndef CONFIG_USER_ONLY -static void fast_memmove_idx(CPUS390XState *env, uint64_t dest, uint64_t s= rc, - uint32_t len, int dest_idx, int src_idx, - uintptr_t ra) +static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, char **= haddr, + int offset, int mmu_idx, uintptr_t ra) { - TCGMemOpIdx oi_dest =3D make_memop_idx(MO_UB, dest_idx); - TCGMemOpIdx oi_src =3D make_memop_idx(MO_UB, src_idx); - uint32_t len_adj; - void *src_p; - void *dest_p; - uint8_t x; - - while (len > 0) { - src =3D wrap_address(env, src); - dest =3D wrap_address(env, dest); - src_p =3D tlb_vaddr_to_host(env, src, MMU_DATA_LOAD, src_idx); - dest_p =3D tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, dest_idx); - - if (src_p && dest_p) { - /* Access to both whole pages granted. */ - len_adj =3D adj_len_to_page(adj_len_to_page(len, src), dest); - memmove(dest_p, src_p, len_adj); - } else { - /* We failed to get access to one or both whole pages. The next - read or write access will likely fill the QEMU TLB for the - next iteration. */ - len_adj =3D 1; - x =3D helper_ret_ldub_mmu(env, src, oi_src, ra); - helper_ret_stb_mmu(env, dest, x, oi_dest, ra); +#ifdef CONFIG_USER_ONLY + return ldub_p(*haddr + offset); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + uint8_t byte; + + if (likely(*haddr)) { + return ldub_p(*haddr + offset); + } + /* + * Do a single access and test if we can then get access to the + * page. This is especially relevant to speed up TLB_NOTDIRTY. + */ + byte =3D helper_ret_ldub_mmu(env, vaddr + offset, oi, ra); + *haddr =3D tlb_vaddr_to_host(env, vaddr, MMU_DATA_LOAD, mmu_idx); + return byte; +#endif +} + +static uint8_t access_get_byte(CPUS390XState *env, S390Access *access, + int offset, uintptr_t ra) +{ + if (offset < access->size1) { + return do_access_get_byte(env, access->vaddr1, &access->haddr1, + offset, access->mmu_idx, ra); + } + return do_access_get_byte(env, access->vaddr2, &access->haddr2, + offset - access->size1, access->mmu_idx, ra); +} + +static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, char **had= dr, + int offset, uint8_t byte, int mmu_idx, + uintptr_t ra) +{ +#ifdef CONFIG_USER_ONLY + stb_p(*haddr + offset, byte); +#else + TCGMemOpIdx oi =3D make_memop_idx(MO_UB, mmu_idx); + + if (likely(*haddr)) { + stb_p(*haddr + offset, byte); + return; + } + /* + * Do a single access and test if we can then get access to the + * page. This is especially relevant to speed up TLB_NOTDIRTY. + */ + helper_ret_stb_mmu(env, vaddr + offset, byte, oi, ra); + *haddr =3D tlb_vaddr_to_host(env, vaddr, MMU_DATA_STORE, mmu_idx); +#endif +} + +static void access_set_byte(CPUS390XState *env, S390Access *access, + int offset, uint8_t byte, uintptr_t ra) +{ + if (offset < access->size1) { + do_access_set_byte(env, access->vaddr1, &access->haddr1, offset, b= yte, + access->mmu_idx, ra); + } else { + do_access_set_byte(env, access->vaddr2, &access->haddr2, + offset - access->size1, byte, access->mmu_idx, = ra); + } +} + +/* + * Move data with the same semantics as memmove() in case ranges don't ove= rlap + * or src > dest. Undefined behavior on destructive overlaps. + */ +static void access_memmove(CPUS390XState *env, S390Access *desta, + S390Access *srca, uintptr_t ra) +{ + int diff; + + g_assert(desta->size1 + desta->size2 =3D=3D srca->size1 + srca->size2); + + /* Fallback to slow access in case we don't have access to all host pa= ges */ + if (unlikely(!desta->haddr1 || (desta->size2 && !desta->haddr2) || + !srca->haddr1 || (srca->size2 && !srca->haddr2))) { + int i; + + for (i =3D 0; i < desta->size1 + desta->size2; i++) { + uint8_t byte =3D access_get_byte(env, srca, i, ra); + + access_set_byte(env, desta, i, byte, ra); } - 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 @@ -259,45 +319,6 @@ static int mmu_idx_from_as(uint8_t as) } } =20 -static void fast_memmove_as(CPUS390XState *env, uint64_t dest, uint64_t sr= c, - uint32_t len, uint8_t dest_as, uint8_t src_as, - uintptr_t ra) -{ - int src_idx =3D mmu_idx_from_as(src_as); - int dest_idx =3D mmu_idx_from_as(dest_as); - - fast_memmove_idx(env, dest, src, len, dest_idx, src_idx, ra); -} -#endif - -static void fast_memmove(CPUS390XState *env, uint64_t dest, uint64_t src, - uint32_t l, uintptr_t ra) -{ - int mmu_idx =3D cpu_mmu_index(env, false); - - while (l > 0) { - void *src_p =3D tlb_vaddr_to_host(env, src, MMU_DATA_LOAD, mmu_idx= ); - void *dest_p =3D tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_= idx); - if (src_p && dest_p) { - /* Access to both whole pages granted. */ - uint32_t l_adj =3D adj_len_to_page(l, src); - l_adj =3D adj_len_to_page(l_adj, dest); - memmove(dest_p, src_p, l_adj); - src +=3D l_adj; - dest +=3D l_adj; - l -=3D l_adj; - } else { - /* We failed to get access to one or both whole pages. The next - read or write access will likely fill the QEMU TLB for the - next iteration. */ - cpu_stb_data_ra(env, dest, cpu_ldub_data_ra(env, src, ra), ra); - src++; - dest++; - l--; - } - } -} - /* and on array */ static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) @@ -388,7 +409,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, uint64_t src, uintptr_t ra) { const int mmu_idx =3D cpu_mmu_index(env, false); - S390Access desta; + S390Access srca, desta; uint32_t i; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", @@ -397,6 +418,7 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, /* MVC always copies one more byte than specified - maximum is 256 */ l++; =20 + srca =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); =20 /* @@ -405,9 +427,9 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, * behave like memmove(). */ if (dest =3D=3D src + 1) { - access_memset(env, &desta, cpu_ldub_data_ra(env, src, ra), ra); + access_memset(env, &desta, access_get_byte(env, &srca, 0, ra), ra); } else if (!is_destructive_overlap(env, dest, src, l)) { - fast_memmove(env, dest, src, l, ra); + access_memmove(env, &desta, &srca, ra); } else { for (i =3D 0; i < l; i++) { uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); @@ -756,8 +778,11 @@ uint64_t HELPER(clst)(CPUS390XState *env, uint64_t c, = uint64_t s1, uint64_t s2) /* move page */ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64= _t r2) { + const int mmu_idx =3D cpu_mmu_index(env, false); const bool f =3D extract64(r0, 11, 1); const bool s =3D extract64(r0, 10, 1); + uintptr_t ra =3D GETPC(); + S390Access srca, desta; =20 if ((f && s) || extract64(r0, 12, 4)) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, GETPC()); @@ -772,7 +797,11 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0,= uint64_t r1, uint64_t r2) * - CC-option with surpression of page-translation exceptions * - Store r1/r2 register identifiers at real location 162 */ - fast_memmove(env, r1, r2, TARGET_PAGE_SIZE, GETPC()); + srca =3D access_prepare(env, r2, TARGET_PAGE_SIZE, MMU_DATA_LOAD, mmu_= idx, + ra); + desta =3D access_prepare(env, r1, TARGET_PAGE_SIZE, MMU_DATA_STORE, mm= u_idx, + ra); + access_memmove(env, &desta, &srca, ra); return 0; /* data moved */ } =20 @@ -853,7 +882,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, { const int mmu_idx =3D cpu_mmu_index(env, false); int len =3D MIN(*destlen, -(*dest | TARGET_PAGE_MASK)); - S390Access desta; + S390Access srca, desta; int i, cc; =20 if (*destlen =3D=3D *srclen) { @@ -877,7 +906,9 @@ static inline uint32_t do_mvcl(CPUS390XState *env, len =3D MIN(MIN(*srclen, -(*src | TARGET_PAGE_MASK)), len); *destlen -=3D len; *srclen -=3D len; - fast_memmove(env, *dest, *src, len, ra); + srca =3D access_prepare(env, *src, len, MMU_DATA_LOAD, mmu_idx, ra= ); + desta =3D access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx,= ra); + access_memmove(env, &desta, &srca, ra); *src =3D wrap_address(env, *src + len); *dest =3D wrap_address(env, *dest + len); } else if (wordsize =3D=3D 1) { @@ -911,8 +942,8 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, = uint32_t r2) uint64_t srclen =3D env->regs[r2 + 1] & 0xffffff; uint64_t src =3D get_address(env, r2); uint8_t pad =3D env->regs[r2 + 1] >> 24; + S390Access srca, desta; uint32_t cc, cur_len; - S390Access desta; =20 if (is_destructive_overlap(env, dest, src, MIN(srclen, destlen))) { cc =3D 3; @@ -946,7 +977,11 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1,= uint32_t r2) } else { cur_len =3D MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_le= n); =20 - fast_memmove(env, dest, src, cur_len, ra); + srca =3D access_prepare(env, src, cur_len, MMU_DATA_LOAD, mmu_= idx, + ra); + desta =3D access_prepare(env, dest, cur_len, MMU_DATA_STORE, m= mu_idx, + ra); + access_memmove(env, &desta, &srca, ra); src =3D wrap_address(env, src + cur_len); srclen -=3D cur_len; env->regs[r2 + 1] =3D deposit64(env->regs[r2 + 1], 0, 24, srcl= en); @@ -2488,16 +2523,15 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t= dest, uint64_t src, s390_program_interrupt(env, PGM_ADDRESSING, 6, ra); } =20 - /* FIXME: a) LAP - * b) Access using correct keys - * c) AR-mode - */ -#ifdef CONFIG_USER_ONLY - /* psw keys are never valid in user mode, we will never reach this */ - g_assert_not_reached(); -#else - fast_memmove_as(env, dest, src, len, dest_as, src_as, ra); -#endif + /* FIXME: Access using correct keys and AR-mode */ + if (len) { + S390Access srca =3D access_prepare(env, src, len, MMU_DATA_LOAD, + mmu_idx_from_as(src_as), ra); + S390Access desta =3D access_prepare(env, dest, len, MMU_DATA_STORE, + mmu_idx_from_as(dest_as), ra); + + access_memmove(env, &desta, &srca, ra); + } =20 return cc; } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824719; cv=none; d=zoho.com; s=zohoarc; b=TCj8K6AAFaU20ZNWIizaUcBh/G0+Ox4rcn1XC+kv825TTBcUs8hkOwcYQSueRweN7RBHTu6zLt85mmLxiMvOEc1Tr6mERxk931BEBYknEV3Mzc9oNG2XczY9AeXXnld8QxcD1X9/13ayVfN1i3Ikv9SrT60FTGVy1egGoWY/bO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824719; 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=cu8gmaIpNjL24YxbogFIapfINDG80pTTDNatOsieiYo=; b=eWBl3x1MtoDVbYAciL13MtkBGd+w7c7ptrxbHIz2SZaMdvhAT1zXm71VfW55B61QxP8xNSGD/oM2L+O2c2z/rcLV7TdLZIqlKlVGuGREKur9Ll6bVurzIgqGSveksdDZ9tqntDu/WXP94CjPDGB2fG5KsIqcLf/Pz/wKZyNttak= 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 156882471983793.62405888700073; Wed, 18 Sep 2019 09:38:39 -0700 (PDT) Received: from localhost ([::1]:60794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcyP-0005gA-N5 for importer@patchew.org; Wed, 18 Sep 2019 12:38:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvY-00027c-V4 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvW-0000cL-WD for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvW-0000bU-MR; Wed, 18 Sep 2019 11:31:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D1D269094; Wed, 18 Sep 2019 15:31:29 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75F115D721; Wed, 18 Sep 2019 15:31:22 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:11 +0200 Message-Id: <20190918152922.18949-19-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 18 Sep 2019 15:31:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 18/29] s390x/tcg: MVCS/MVCP: Use access_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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As we are moving between address spaces, we can use access_memmove() without checking for destructive overlaps (especially of real storage locations): "Each storage operand is processed left to right. The storage-operand-consistency rules are the same as for MOVE (MVC), except that when the operands overlap in real storage, the use of the common real- storage locations is not necessarily recognized." Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index e50cec9263..6b85f44e22 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2086,8 +2086,9 @@ uint32_t HELPER(rrbe)(CPUS390XState *env, uint64_t r2) uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; + S390Access srca, desta; uintptr_t ra =3D GETPC(); - int cc =3D 0, i; + int cc =3D 0; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); @@ -2106,20 +2107,19 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) return cc; } =20 - /* XXX replace w/ memcpy */ - for (i =3D 0; i < l; i++) { - uint8_t x =3D cpu_ldub_primary_ra(env, a2 + i, ra); - cpu_stb_secondary_ra(env, a1 + i, x, ra); - } - + /* TODO: Access key handling */ + srca =3D access_prepare(env, a2, l, MMU_DATA_LOAD, MMU_PRIMARY_IDX, ra= ); + desta =3D access_prepare(env, a1, l, MMU_DATA_STORE, MMU_SECONDARY_IDX= , ra); + access_memmove(env, &desta, &srca, ra); return cc; } =20 uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_= t a2) { const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; + S390Access srca, desta; uintptr_t ra =3D GETPC(); - int cc =3D 0, i; + int cc =3D 0; =20 HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n", __func__, l, a1, a2); @@ -2138,12 +2138,10 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t = l, uint64_t a1, uint64_t a2) return cc; } =20 - /* XXX replace w/ memcpy */ - for (i =3D 0; i < l; i++) { - uint8_t x =3D cpu_ldub_secondary_ra(env, a2 + i, ra); - cpu_stb_primary_ra(env, a1 + i, x, ra); - } - + /* TODO: Access key handling */ + srca =3D access_prepare(env, a2, l, MMU_DATA_LOAD, MMU_SECONDARY_IDX, = ra); + desta =3D access_prepare(env, a1, l, MMU_DATA_STORE, MMU_PRIMARY_IDX, = ra); + access_memmove(env, &desta, &srca, ra); return cc; } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824913; cv=none; d=zoho.com; s=zohoarc; b=Py6q1xxT1RYznK1WZGLtu4INymzqaSyOcwq9NSbJwRJrLmzoGh6JlHSIf8o3RzI2lDgk9fx0KGsjsW+LI54ohHgYdEuMs+ufdCkBsyaQT01tx8WOTt6PTRywALj7aM6E4mvoRbCRdHfqfdU0UDsd2DZN2B1YqprTTvPlD75/pcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824913; 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=LwD2xAenI6LnWO4c6EIHeJKnh2CuoQShAv5MGmZpmus=; b=GtxIbbJnV8nmRpmoDUqcPToTFL4VSjDE/WfpQSAhtzMdPCix4ywu32iEJvHT6hVNPnLBIt609df1dTdnfCcQ+s5SAdvsIy1UQy6KgXh7lHPhy1EJ3Y7ajMkTO3xZQDAnDS51Q1HNzYy+gDkjStlZymttoHDephN/8lFaJe6I3tA= 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 1568824913444191.80947357989226; Wed, 18 Sep 2019 09:41:53 -0700 (PDT) Received: from localhost ([::1]:60836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd1c-0001Jm-AN for importer@patchew.org; Wed, 18 Sep 2019 12:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50802) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbve-00028m-It for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvZ-0000ed-5b for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvY-0000cn-Rg; Wed, 18 Sep 2019 11:31:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D657C369D3; Wed, 18 Sep 2019 15:31:31 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA9ED61F24; Wed, 18 Sep 2019 15:31:29 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:12 +0200 Message-Id: <20190918152922.18949-20-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 18 Sep 2019 15:31:31 +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] [PULL SUBSYSTEM s390x 19/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The last remaining bit for MVC is handling destructive overlaps in a fault-safe way. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 6b85f44e22..abb9d4d70c 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -432,8 +432,9 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint3= 2_t l, uint64_t dest, access_memmove(env, &desta, &srca, ra); } else { for (i =3D 0; i < l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - cpu_stb_data_ra(env, dest + i, x, ra); + uint8_t byte =3D access_get_byte(env, &srca, i, ra); + + access_set_byte(env, &desta, i, byte, ra); } } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568825092; cv=none; d=zoho.com; s=zohoarc; b=OWpcfDmkCInFXURGUGHwg1edpH4cd04+pIrMCajvBM/KyYpaoz6hTWeSAXOknh/BL4MuOgC3i3B426wDPRPADW4WEliUrLFce+6t50E2VXY5aGoZlj473Njc4lfrwxlEZIqDennMAuUvrUWdHxOv086+P3kG+MveeQiWpzyaOJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568825092; 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=2c/3KgYbSOGzyc0MD+eSJSXmz1yk9jK0dvZ5t6sygaE=; b=kDdfUoz0ZnGs8O8oOkEk85Nd+Xt87Irp2C57y8NnQ24zEfxfiW6Hd6CB40RqUXM6YiaExyk+rLJX5aDqG7pYLxJpr7gfj7pCxann1iohbHtvFM4lO0zOtCBVV9StDwsf5Y03wLw90IFKofKdzrwNwPQxX2kQM3A4pQQPr2iK1/k= 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 1568825092414500.90285915435345; Wed, 18 Sep 2019 09:44:52 -0700 (PDT) Received: from localhost ([::1]:60910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd4V-0004w8-46 for importer@patchew.org; Wed, 18 Sep 2019 12:44:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50823) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvf-0002BS-Vk for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbve-0000iA-Ol for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8889) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvc-0000fH-OB; Wed, 18 Sep 2019 11:31:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 446A620F2; Wed, 18 Sep 2019 15:31:34 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3893062A8B; Wed, 18 Sep 2019 15:31:31 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:13 +0200 Message-Id: <20190918152922.18949-21-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 20/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The last remaining bit is padding with two bytes. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index abb9d4d70c..853b9557cf 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -919,15 +919,17 @@ static inline uint32_t do_mvcl(CPUS390XState *env, access_memset(env, &desta, pad, ra); *dest =3D wrap_address(env, *dest + len); } else { + desta =3D access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx,= ra); + /* The remaining length selects the padding byte. */ for (i =3D 0; i < len; (*destlen)--, i++) { if (*destlen & 1) { - cpu_stb_data_ra(env, *dest, pad, ra); + access_set_byte(env, &desta, i, pad, ra); } else { - cpu_stb_data_ra(env, *dest, pad >> 8, ra); + access_set_byte(env, &desta, i, pad >> 8, ra); } - *dest =3D wrap_address(env, *dest + 1); } + *dest =3D wrap_address(env, *dest + len); } =20 return *destlen ? 3 : cc; --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568825126; cv=none; d=zoho.com; s=zohoarc; b=jZH5Oj69Hy/SM4Vt/iOYTo6jxulCjlY8qBzZXebLfORr6fIVv3DE3gR/Sn1TYTSsPfBHpg2NP/TWnojxgrS4/gmegXAJ8jAa659XGoF1wKc5dysNhgAWCv1SU1tY57g0Au6l4s4kmPlkozReeHjxPtv2lEvRqyIUYhFv2GqFLyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568825126; 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=SHhiNRfL7mCEKj0/zR2jyyAGJ7YfHiCMeexUcoJUZJg=; b=eyayrOBCYDk9zgw7Oix86o6iP0TsxVvHNZueq/2RMALgbbr3Zp306rwklbtChlVPsRd6ubyboifhfEcdCvhsEua0kjVQCx8F3OJoJnyQt2AJf65OOJgGcGFfiFluiJnSOzeVSxCwwDqAATdPDDOx1PNeTJPcbhf14TZCPbhjZV0= 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 1568825126565288.2642879200598; Wed, 18 Sep 2019 09:45:26 -0700 (PDT) Received: from localhost ([::1]:60940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd52-0005fM-6s for importer@patchew.org; Wed, 18 Sep 2019 12:45:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50861) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvh-0002CB-5Q for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvf-0000k5-Ux for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62269) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbve-0000gJ-OH; Wed, 18 Sep 2019 11:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54BD77EB89; Wed, 18 Sep 2019 15:31:36 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E4BC5D721; Wed, 18 Sep 2019 15:31:34 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:14 +0200 Message-Id: <20190918152922.18949-22-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 21/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 853b9557cf..0574c31d9a 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -383,17 +383,26 @@ uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, u= int64_t dest, static uint32_t do_helper_oc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - x |=3D cpu_ldub_data_ra(env, dest + i, ra); + /* OC always processes one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca1, i, ra) | + access_get_byte(env, &srca2, i, ra); + c |=3D x; - cpu_stb_data_ra(env, dest + i, x, ra); + access_set_byte(env, &desta, i, x, ra); } return c !=3D 0; } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824557; cv=none; d=zoho.com; s=zohoarc; b=Zqs2xy9XFPIgKJpYLQISTpQhlmqcbgGSs/GJ3ZlDHrZ8ViTVfy/KAigiV+ApkVR5t9krubKGgDB8/P5WL51ijF+mvvFsF4INUt7auUrX0588QAon1Yc80cZPOSmnMsNympYnjhtYPtuiqdZtWq/KEhQlTfSacIj+Ct9HXDu5L5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824557; 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=j4Ucf9/O7jI8Wpyx7hlpIEMLuMrio//kwKCQfzwxBkM=; b=UKg7vH657ssSPUzTubmPy8PECiwtL81/LNMXg1P1Qe3oLd+61Kv47q7I0ErRHtv+uj6KP/p3BvJZnBPwLUbzcZLYp5ge1B4NvODss21BgC7Z97LSjeknncazWyovq71gPSISpst6rT5yaDdzevznIdXtBpEYxNA8ZNRTiiQDFjQ= 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 1568824557917302.7307647532465; Wed, 18 Sep 2019 09:35:57 -0700 (PDT) Received: from localhost ([::1]:60756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcvs-0002Rd-5V for importer@patchew.org; Wed, 18 Sep 2019 12:35:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50863) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvh-0002CC-8s for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvg-0000kV-21 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvf-0000hO-R6; Wed, 18 Sep 2019 11:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4152E302C097; Wed, 18 Sep 2019 15:31:38 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1AEA5EE1D; Wed, 18 Sep 2019 15:31:36 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:15 +0200 Message-Id: <20190918152922.18949-23-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 22/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. While at it, increment the length once. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 0574c31d9a..a2118a82e3 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -349,14 +349,19 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint= 32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { const int mmu_idx =3D cpu_mmu_index(env, false); - S390Access desta; + S390Access srca1, srca2, desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - desta =3D access_prepare(env, dest, l + 1, MMU_DATA_STORE, mmu_idx, ra= ); + /* XC always processes one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); =20 /* xor with itself is the same as memset(0) */ if (src =3D=3D dest) { @@ -364,11 +369,12 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint= 32_t l, uint64_t dest, return 0; } =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - x ^=3D cpu_ldub_data_ra(env, dest + i, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca1, i, ra) ^ + access_get_byte(env, &srca2, i, ra); + c |=3D x; - cpu_stb_data_ra(env, dest + i, x, ra); + access_set_byte(env, &desta, i, x, ra); } return c !=3D 0; } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568825344; cv=none; d=zoho.com; s=zohoarc; b=jW66682u0q0U0R9vJmLzLjZuApNItFi2iZpNnvQwK8lgYt0n5/UMPA4IzmUQuPxoZINzAeoaZ1iMTBsCZ7jq5uQTt8btUCwlHh+W+FKhKDSHP/YaIahhwMQTxQTDluxvIXzBbc0PGrDxkzr7QLGbxCtDQA3FT3VN3RmZ6vbjPBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568825344; 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=2W7q98DZYDNSf04EAyV10IrLp89cyeUsynQBEkKC8dk=; b=BGHkSDi2H0N/HBeTVCJ46H9/EOX/Sj0yqgOSV/M8UkxvT6tMUkBwcHurbYjFu+5GK0vP1WyqiwZqvmPE77/04852xQm5gHl8QDpoRbEftk9RS1jOMbhuWIVyTOeRV72pgQJPtTzTf1c/T5ijdiNuPqa33kPJEhkADNOUzMYNMpk= 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 1568825344946230.2140786632608; Wed, 18 Sep 2019 09:49:04 -0700 (PDT) Received: from localhost ([::1]:60966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd8Y-0008Ty-Pi for importer@patchew.org; Wed, 18 Sep 2019 12:49:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50882) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvj-0002CE-Bq for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvh-0000lV-8M for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvh-0000l4-2d; Wed, 18 Sep 2019 11:31:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C624306F4BE; Wed, 18 Sep 2019 15:31:40 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BD285D6A5; Wed, 18 Sep 2019 15:31:38 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:16 +0200 Message-Id: <20190918152922.18949-24-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 23/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index a2118a82e3..20fc17d44d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -323,17 +323,26 @@ static int mmu_idx_from_as(uint8_t as) static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src, uintptr_t ra) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uint32_t i; uint8_t c =3D 0; =20 HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", __func__, l, dest, src); =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t x =3D cpu_ldub_data_ra(env, src + i, ra); - x &=3D cpu_ldub_data_ra(env, dest + i, ra); + /* NC always processes one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca1, i, ra) & + access_get_byte(env, &srca2, i, ra); + c |=3D x; - cpu_stb_data_ra(env, dest + i, x, ra); + access_set_byte(env, &desta, i, x, ra); } return c !=3D 0; } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824068; cv=none; d=zoho.com; s=zohoarc; b=jDb4wuIBOqsuPhx5MWDbdSbFwqSU1s+VmVVjpH7qdzxuqPavha0DyYH7MaVK0FLBVTiqQgzH3ZELlnyVtV0YhNRTCkFD4XFdPD0jubEjAi/gmJj+mkIrC988peIyEtd1cG0rWPLjwwMNERKzBGNGJm3ij8doL49K1vNATbHTayE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824068; 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=DNkpDvtZHbAMHw1/2hv7L1u0fDqRP5igximiVWNdsXo=; b=HMPIRfKPSLf7uA+hFGk//8X9rWn4lNP2L1Cdw3dl+7ROaANe+pbiFHnWQFVxA/UUwBJgHOY8nBqWeLuPJdmDMRL1VA8wIetcBveiIGRLsRXvuunif8b4F2siJ6Y4C3iES18ZZiVpSFxTUt8bKp0G4U1LEeJ4OuOFEkRQUtwxxd4= 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 1568824068813712.6685075159592; Wed, 18 Sep 2019 09:27:48 -0700 (PDT) Received: from localhost ([::1]:60666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcny-0001Un-TY for importer@patchew.org; Wed, 18 Sep 2019 12:27:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvl-0002DH-Mn for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvj-0000nA-Kk for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47780) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvj-0000mX-Bb; Wed, 18 Sep 2019 11:31:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DE1B302C084; Wed, 18 Sep 2019 15:31:42 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85B8F5D6A5; Wed, 18 Sep 2019 15:31:40 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:17 +0200 Message-Id: <20190918152922.18949-25-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 24/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Calculate the accessed range upfront - src is accessed right-to-left. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 20fc17d44d..4f46d0be90 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -473,12 +473,21 @@ void HELPER(mvc)(CPUS390XState *env, uint32_t l, uint= 64_t dest, uint64_t src) /* move inverse */ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t= src) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca, desta; uintptr_t ra =3D GETPC(); int i; =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t v =3D cpu_ldub_data_ra(env, src - i, ra); - cpu_stb_data_ra(env, dest + i, v, ra); + /* MVCIN always copies one more byte than specified - maximum is 256 */ + l++; + + src =3D wrap_address(env, src - l + 1); + srca =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D access_get_byte(env, &srca, l - i - 1, ra); + + access_set_byte(env, &desta, i, x, ra); } } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568825386; cv=none; d=zoho.com; s=zohoarc; b=DniAGm4xVoAHf5yp9WfFycFkNvISrha0SSrtAXQSAju5Q5ZlCRE7BJG/ErDaQdvhorTo978kr4Ow4ItMLJ8VXPjFDovLqY0KlL562/JiteKOr7NEAViHqw5jOEKAgl7QEPDIeYfS0sIvcirfc2Qx22auKfQIfxxzLcN5MjumijM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568825386; 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=T4i/dCNgeCSe5m5Th6Gy+yRYuKV3No4kMk4ItZDvH7Q=; b=mG7A/zpWBI+79HQx+JRZ5T0y+QUFh+NYn1vuTtjYKi9iZsjiW2/B2cZdoNUHvyICHbUyVKejla7f6hmUVUhIDreR3pFjmEZd0fd4CPHzr9Ie1m8LC7A2SNtA1PPRo60L+qPd3MK9h+/Krb3z7Q9B4DvDJ8+HyJeesGMgN9S8fH8= 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 1568825386505461.7807750191706; Wed, 18 Sep 2019 09:49:46 -0700 (PDT) Received: from localhost ([::1]:60974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAd9B-0000rx-P5 for importer@patchew.org; Wed, 18 Sep 2019 12:49:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50946) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvn-0002Ew-4F for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvl-0000om-PR for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1572) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvl-0000ns-JO; Wed, 18 Sep 2019 11:31:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BE10302C084; Wed, 18 Sep 2019 15:31:44 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 831F35D6A5; Wed, 18 Sep 2019 15:31:42 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:18 +0200 Message-Id: <20190918152922.18949-26-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 25/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 4f46d0be90..fbf65ac42b 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -494,13 +494,22 @@ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, ui= nt64_t dest, uint64_t src) /* move numerics */ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t s= rc) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uintptr_t ra =3D GETPC(); int i; =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t v =3D cpu_ldub_data_ra(env, dest + i, ra) & 0xf0; - v |=3D cpu_ldub_data_ra(env, src + i, ra) & 0x0f; - cpu_stb_data_ra(env, dest + i, v, ra); + /* MVN always copies one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D (access_get_byte(env, &srca1, i, ra) & 0x0f) | + (access_get_byte(env, &srca2, i, ra) & 0xf0); + + access_set_byte(env, &desta, i, x, ra); } } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568825557; cv=none; d=zoho.com; s=zohoarc; b=J7O2hhXbb1nr2KhSWF8OR7tBCXKce2uerVZnBH9a8QOZTLHlzhPh2nnxnabtc4ZlCvHlwwAjjnTuFLIMP/chG782zQBbnxlBRYzf0ycSQ5fUlnq/vHAO4ZTQdTZzvcOkMGE95kHHZZNuWtgw/XQbVheWlwx/wz9NRPeffkZ0RVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568825557; 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=+iyye8pB9h5quM/UUC7ytMP2XDc7IsKR7OgH722oDqk=; b=JzCFE51OWWCmNTwIfocSqIIW5MaH/IvN2kc99loDPVr27eRlBSiHYFWf3jEid8iifhYZy8uHfAsML5qk0KcCoriRDDyDJtf36gYV7pIi8APIDYZ/XF8t88v+qqEg1Md8ku2bA8uaFn7dRQAOaIJd20T1CbrZU1t3k8DlYgvQdDM= 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 1568825557845897.7563397462359; Wed, 18 Sep 2019 09:52:37 -0700 (PDT) Received: from localhost ([::1]:32788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAdBw-0004m2-SN for importer@patchew.org; Wed, 18 Sep 2019 12:52:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50967) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvo-0002GT-9j for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvn-0000q6-15 for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvm-0000pL-SH; Wed, 18 Sep 2019 11:31:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C58F30821C2; Wed, 18 Sep 2019 15:31:46 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8525B5D70D; Wed, 18 Sep 2019 15:31:44 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:19 +0200 Message-Id: <20190918152922.18949-27-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 26/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We can process a maximum of 256 bytes, crossing two pages. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index fbf65ac42b..c836b69fcc 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -547,13 +547,22 @@ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint= 64_t dest, uint64_t src) /* move zones */ void HELPER(mvz)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t s= rc) { + const int mmu_idx =3D cpu_mmu_index(env, false); + S390Access srca1, srca2, desta; uintptr_t ra =3D GETPC(); int i; =20 - for (i =3D 0; i <=3D l; i++) { - uint8_t b =3D cpu_ldub_data_ra(env, dest + i, ra) & 0x0f; - b |=3D cpu_ldub_data_ra(env, src + i, ra) & 0xf0; - cpu_stb_data_ra(env, dest + i, b, ra); + /* MVZ always copies one more byte than specified - maximum is 256 */ + l++; + + srca1 =3D access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + srca2 =3D access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < l; i++) { + const uint8_t x =3D (access_get_byte(env, &srca1, i, ra) & 0xf0) | + (access_get_byte(env, &srca2, i, ra) & 0x0f); + + access_set_byte(env, &desta, i, x, ra); } } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568825772; cv=none; d=zoho.com; s=zohoarc; b=ikBFh+wepE+VeVp+ZowzeVGsnV/nzTwUs2YE3mxGJb6PsZgEyqria2YG+jaujlapVwJkK2nqyhlygbDqDIS7K1Bvy1CyLAjFyvUEHTFA4ngzegnhL4RuQfZ/oAVRItjJS1u02Z3OUe4qa6Suk48Fj9fs5fUesai52UKSws4s9DY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568825772; 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=2+I0iVuSNUx08o+8yNj0tn/oYM+NY6AQX3nobO8Yv1Y=; b=A1Kk//IrN1X4GVKA+ksnGOAeBXTaKZJG32HL5XpyUXzcyRPPVjVdSv4WSuQHTp+cvMYqGFaqkdemcfZfqGas1ezBJS252j24II6AcOoVFi4DWr8/2dKTIbttxeioCq3t3SVBmHUgLaynWBrjKe5YYC+7OphdyN+Y5q4RJR9tqS0= 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 1568825772788766.170455833418; Wed, 18 Sep 2019 09:56:12 -0700 (PDT) Received: from localhost ([::1]:32834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAdFT-0000np-0m for importer@patchew.org; Wed, 18 Sep 2019 12:56:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50998) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvq-0002Ii-Gu for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvp-0000ru-2G for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvo-0000rD-TI; Wed, 18 Sep 2019 11:31:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32F863060399; Wed, 18 Sep 2019 15:31:48 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75ED55D6A5; Wed, 18 Sep 2019 15:31:46 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:20 +0200 Message-Id: <20190918152922.18949-28-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 27/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Access at most single pages and document why. Using the access helpers might over-indicate watchpoints within the same page, I guess we can live with that. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index c836b69fcc..671e917dc1 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -860,23 +860,33 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0= , uint64_t r1, uint64_t r2) /* string copy */ uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2) { + const int mmu_idx =3D cpu_mmu_index(env, false); const uint64_t d =3D get_address(env, r1); const uint64_t s =3D get_address(env, r2); const uint8_t c =3D env->regs[0]; + const int len =3D MIN(-(d | TARGET_PAGE_MASK), -(s | TARGET_PAGE_MASK)= ); + S390Access srca, desta; uintptr_t ra =3D GETPC(); - uint32_t len; + int i; =20 if (env->regs[0] & 0xffffff00ull) { s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, ra); } =20 - /* Lest we fail to service interrupts in a timely manner, limit the - amount of work we're willing to do. For now, let's cap at 8k. */ - for (len =3D 0; len < 0x2000; ++len) { - uint8_t v =3D cpu_ldub_data_ra(env, s + len, ra); - cpu_stb_data_ra(env, d + len, v, ra); + /* + * Our access should not exceed single pages, as we must not report ac= cess + * exceptions exceeding the actually copied range (which we don't know= at + * this point). We might over-indicate watchpoints within the pages + * (if we ever care, we have to limit processing to a single byte). + */ + srca =3D access_prepare(env, s, len, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, d, len, MMU_DATA_STORE, mmu_idx, ra); + for (i =3D 0; i < len; i++) { + const uint8_t v =3D access_get_byte(env, &srca, i, ra); + + access_set_byte(env, &desta, i, v, ra); if (v =3D=3D c) { - set_address_zero(env, r1, d + len); + set_address_zero(env, r1, d + i); return 1; } } --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568826073; cv=none; d=zoho.com; s=zohoarc; b=ChGLIx/5jqze4tXWK9ABfWnKZ2gPcaBuwIOAdkNZACA7BdRnIryZqv+JdLqBFdeNH6ceOwOVyiukhg2Q0yW/QxQo9OOuYrNOarp/0CvzZB7J4k5XGWNlcLuTbZRVt4CbA0jkdRwb+jygVpfiTygkDXJ1d9Eed1WpMFGFiYvklLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568826073; 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=MxIq/nFcH3zeCqnqHVls9SCtFnSzVOSPPpd/R2HNTRU=; b=EpQ3Yr6YN+1Y3TkSM0ktTKUR53xmjTnN3UfN9EhwvV4oiLZbwycrcnft1+PPa9Hq5wHGCV3eKE2P4gv4V1SnpSMLkG675CpjyXMFPYtyWXe9AgpuUpUCy6s/I+mh2KGlgaH41uls3+rEH0MBdyDFIQprkrnNBls0gBsq66Ax2ZU= 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 1568826073445139.7320182207161; Wed, 18 Sep 2019 10:01:13 -0700 (PDT) Received: from localhost ([::1]:32896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAdKJ-0005C2-MA for importer@patchew.org; Wed, 18 Sep 2019 13:01:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51025) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvs-0002L7-IO for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvr-0000tK-6m for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvr-0000sv-0y; Wed, 18 Sep 2019 11:31:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A37A86663; Wed, 18 Sep 2019 15:31:50 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DA125D6A5; Wed, 18 Sep 2019 15:31:48 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:21 +0200 Message-Id: <20190918152922.18949-29-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 18 Sep 2019 15:31:50 +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] [PULL SUBSYSTEM s390x 28/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Each operand can have a maximum length of 16. Make sure to prepare all reads/writes before writing. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/mem_helper.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 671e917dc1..5045420020 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -516,31 +516,34 @@ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint= 64_t dest, uint64_t src) /* move with offset */ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t s= rc) { + const int mmu_idx =3D cpu_mmu_index(env, false); + /* MVO always processes one more byte than specified - maximum is 16 */ + const int len_dest =3D (l >> 4) + 1; + const int len_src =3D (l & 0xf) + 1; uintptr_t ra =3D GETPC(); - int len_dest =3D l >> 4; - int len_src =3D l & 0xf; uint8_t byte_dest, byte_src; - int i; + S390Access srca, desta; + int i, j; =20 - src +=3D len_src; - dest +=3D len_dest; + srca =3D access_prepare(env, src, len_src, MMU_DATA_LOAD, mmu_idx, ra); + desta =3D access_prepare(env, dest, len_dest, MMU_DATA_STORE, mmu_idx,= ra); =20 /* Handle rightmost byte */ - byte_src =3D cpu_ldub_data_ra(env, src, ra); - byte_dest =3D cpu_ldub_data_ra(env, dest, ra); + byte_dest =3D cpu_ldub_data_ra(env, dest + len_dest - 1, ra); + byte_src =3D access_get_byte(env, &srca, len_src - 1, ra); byte_dest =3D (byte_dest & 0x0f) | (byte_src << 4); - cpu_stb_data_ra(env, dest, byte_dest, ra); + access_set_byte(env, &desta, len_dest - 1, byte_dest, ra); =20 /* Process remaining bytes from right to left */ - for (i =3D 1; i <=3D len_dest; i++) { + for (i =3D len_dest - 2, j =3D len_src - 2; i >=3D 0; i--, j--) { byte_dest =3D byte_src >> 4; - if (len_src - i >=3D 0) { - byte_src =3D cpu_ldub_data_ra(env, src - i, ra); + if (j >=3D 0) { + byte_src =3D access_get_byte(env, &srca, j, ra); } else { byte_src =3D 0; } byte_dest |=3D byte_src << 4; - cpu_stb_data_ra(env, dest - i, byte_dest, ra); + access_set_byte(env, &desta, i, byte_dest, ra); } } =20 --=20 2.21.0 From nobody Thu May 2 11:57:11 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=1568824340; cv=none; d=zoho.com; s=zohoarc; b=ZsshCphft5a+RYK9fS06QzdTQep+x5+3mLheTvVP2pv01U+ZNPmZtGHKUhSTHVJGTqDH6ADcqrMxTkQl7jIiRYFbFC6685SReTg37EUWN4apTNtkXtKQy2K2890sjQBHD6/bV46morhiNobMmxEbeDxSIiE8O/CubbT2EDlv2mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568824340; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XAN/VzT+VivUDatw02nm27pcStCXBbcXAHRcdQgLlC8=; b=ANH6k5IzjNo9R+QN/8EySafv63ou8Ba3iRo21nDeV0tTvmShl1gpAZn0Ne8mni3e1vNx6Hc455hMhoxM2rUHEOTL6eIk+5OKlm6O/9vmiEBtlj484W683uVORrCoFvlLxOIiArOCGgJQbG3xnED/EeI62QdJzebc3ns5vWO0Ljs= 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 1568824340837681.3066369706588; Wed, 18 Sep 2019 09:32:20 -0700 (PDT) Received: from localhost ([::1]:60714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAcsM-00060d-O1 for importer@patchew.org; Wed, 18 Sep 2019 12:32:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51046) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAbvu-0002NC-Ub for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAbvt-0000uz-Ex for qemu-devel@nongnu.org; Wed, 18 Sep 2019 11:31:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAbvt-0000uS-7n; Wed, 18 Sep 2019 11:31:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 653A48A1C99; Wed, 18 Sep 2019 15:31:52 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-119.ams2.redhat.com [10.36.117.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94F0F5D6A5; Wed, 18 Sep 2019 15:31:50 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 17:29:22 +0200 Message-Id: <20190918152922.18949-30-david@redhat.com> In-Reply-To: <20190918152922.18949-1-david@redhat.com> References: <20190918152922.18949-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Wed, 18 Sep 2019 15:31: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] [PULL SUBSYSTEM s390x 29/29] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Richard Henderson , qemu-s390x@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's add the simple test based on the example from the PoP. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: David Hildenbrand --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/mvo.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/tcg/s390x/mvo.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 151dc075aa..6a3bfa8b29 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -6,3 +6,4 @@ TESTS+=3Dipm TESTS+=3Dexrl-trt TESTS+=3Dexrl-trtr TESTS+=3Dpack +TESTS+=3Dmvo diff --git a/tests/tcg/s390x/mvo.c b/tests/tcg/s390x/mvo.c new file mode 100644 index 0000000000..5546fe2a97 --- /dev/null +++ b/tests/tcg/s390x/mvo.c @@ -0,0 +1,25 @@ +#include +#include + +int main(void) +{ + uint8_t dest[6] =3D {0xff, 0x77, 0x88, 0x99, 0x0c, 0xff}; + uint8_t src[5] =3D {0xee, 0x12, 0x34, 0x56, 0xee}; + uint8_t expected[6] =3D {0xff, 0x01, 0x23, 0x45, 0x6c, 0xff}; + int i; + + asm volatile ( + " mvo 0(4,%[dest]),0(3,%[src])\n" + : + : [dest] "d" (dest + 1), + [src] "d" (src + 1) + : "memory"); + + for (i =3D 0; i < sizeof(expected); i++) { + if (dest[i] !=3D expected[i]) { + fprintf(stderr, "bad data\n"); + return 1; + } + } + return 0; +} --=20 2.21.0