From nobody Tue Feb 10 12:45:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151662291224420.351745872612014; Mon, 22 Jan 2018 04:08:32 -0800 (PST) Received: from localhost ([::1]:38093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edato-00074k-4T for importer@patchew.org; Mon, 22 Jan 2018 07:08:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edame-0001cI-H4 for qemu-devel@nongnu.org; Mon, 22 Jan 2018 07:01:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edamZ-0005qn-Ka for qemu-devel@nongnu.org; Mon, 22 Jan 2018 07:01:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1edamZ-0005pG-Cz; Mon, 22 Jan 2018 07:00:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B11A7CBA3; Mon, 22 Jan 2018 12:00:58 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA98380F7F; Mon, 22 Jan 2018 12:00:57 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Mon, 22 Jan 2018 13:00:38 +0100 Message-Id: <20180122120045.13538-3-cohuck@redhat.com> In-Reply-To: <20180122120045.13538-1-cohuck@redhat.com> References: <20180122120045.13538-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 22 Jan 2018 12:00:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/9] s390x/tcg: implement TEST PROTECTION X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, Cornelia Huck , agraf@suse.de, qemu-devel@nongnu.org, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Linux uses TEST PROTECTION to sense for available memory locations. Let's implement what we can for now (just as for the other instructions, excluding AR mode and special protection mechanisms). Signed-off-by: David Hildenbrand Message-Id: <20171218224616.21030-2-david@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- target/s390x/helper.h | 2 +- target/s390x/mem_helper.c | 41 +++++++++++++++++++++++++++++++++++++++-- target/s390x/translate.c | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 2f17b62d3d..26c1b07b44 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -137,7 +137,7 @@ DEF_HELPER_FLAGS_4(lctlg, TCG_CALL_NO_WG, void, env, i3= 2, i64, i32) DEF_HELPER_FLAGS_4(stctl, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(stctg, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_2(testblock, TCG_CALL_NO_WG, i32, env, i64) -DEF_HELPER_FLAGS_2(tprot, TCG_CALL_NO_RWG, i32, i64, i64) +DEF_HELPER_FLAGS_3(tprot, TCG_CALL_NO_RWG, i32, env, i64, i64) DEF_HELPER_FLAGS_2(iske, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_3(sske, TCG_CALL_NO_RWG, void, env, i64, i64) DEF_HELPER_FLAGS_2(rrbe, TCG_CALL_NO_RWG, i32, env, i64) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 2625d843b3..359e446c6f 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1717,9 +1717,46 @@ uint32_t HELPER(testblock)(CPUS390XState *env, uint6= 4_t real_addr) return 0; } =20 -uint32_t HELPER(tprot)(uint64_t a1, uint64_t a2) +uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a1, uint64_t a2) { - /* XXX implement */ + S390CPU *cpu =3D s390_env_get_cpu(env); + CPUState *cs =3D CPU(cpu); + + /* + * TODO: we currently don't handle all access protection types + * (including access-list and key-controlled) as well as AR mode. + */ + if (!s390_cpu_virt_mem_check_write(cpu, a1, 0, 1)) { + /* Fetching permitted; storing permitted */ + return 0; + } + switch (env->int_pgm_code) { + case PGM_PROTECTION: + /* Fetching permitted; storing not permitted */ + cs->exception_index =3D 0; + return 1; + case PGM_ADDRESSING: + /* Fetching not permitted; storing not permitted */ + cs->exception_index =3D 0; + return 2; + case PGM_ASCE_TYPE: + case PGM_REG_FIRST_TRANS: + case PGM_REG_SEC_TRANS: + case PGM_REG_THIRD_TRANS: + case PGM_SEGMENT_TRANS: + case PGM_PAGE_TRANS: + case PGM_ALET_SPEC: + case PGM_ALEN_SPEC: + case PGM_ALE_SEQ: + case PGM_ASTE_VALID: + case PGM_ASTE_SEQ: + case PGM_EXT_AUTH: + /* Translation not available */ + cs->exception_index =3D 0; + return 3; + } + /* any other exception is forwarded to the guest */ + s390_cpu_virt_mem_handle_exc(cpu, GETPC()); return 0; } =20 diff --git a/target/s390x/translate.c b/target/s390x/translate.c index ac55886792..df0b41606d 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4532,7 +4532,7 @@ static ExitStatus op_testblock(DisasContext *s, Disas= Ops *o) =20 static ExitStatus op_tprot(DisasContext *s, DisasOps *o) { - gen_helper_tprot(cc_op, o->addr1, o->in2); + gen_helper_tprot(cc_op, cpu_env, o->addr1, o->in2); set_cc_static(s); return NO_EXIT; } --=20 2.13.6