From patchwork Thu Dec 19 11:01:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 11303325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04E9714F6 for ; Thu, 19 Dec 2019 11:17:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4558218AC for ; Thu, 19 Dec 2019 11:16:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q8H2pF4Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4558218AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtne-000252-WF for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 06:16:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43358) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtYp-0006nS-VU for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtYo-0000u0-9G for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:39 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57839 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihtYo-0000lK-2U for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576753296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yMFwKfRm+znqqMiwPzP6tu+VjUIlW/d/JXNoyTC3Vb8=; b=Q8H2pF4Q8+/OUWcsoY1V2sbLK3LjGvLo5/AnxMplZQaVU9kxIS9+Tc2ziEg0sN89rcqgZP /vwomrbtsWbXBbvGSmBLLJvyS9fIqAqBp7VYVAaGMWw+tXpVwFS66+BUHkCgKOq2ZYVl8r HTSSkrO9A+1FEuQIKaKhw1vsO9xUB+g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-JbfEo7xaMKqw4YLVz-L-KA-1; Thu, 19 Dec 2019 06:01:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D98B1005513; Thu, 19 Dec 2019 11:01:21 +0000 (UTC) Received: from localhost (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBD7D10013A1; Thu, 19 Dec 2019 11:01:18 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Subject: [PULL 1/6] target/s390x: Split out helper_per_store_real Date: Thu, 19 Dec 2019 12:01:07 +0100 Message-Id: <20191219110112.8343-2-cohuck@redhat.com> In-Reply-To: <20191219110112.8343-1-cohuck@redhat.com> References: <20191219110112.8343-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: JbfEo7xaMKqw4YLVz-L-KA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Split the PER handling for store-to-real-address into its own helper function, conditionally called when PER is enabled, just as we do for per_branch and per_ifetch. Signed-off-by: Richard Henderson Message-Id: <20191211203614.15611-2-richard.henderson@linaro.org> Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- target/s390x/helper.h | 1 + target/s390x/mem_helper.c | 16 ---------------- target/s390x/misc_helper.c | 10 ++++++++++ target/s390x/translate.c | 8 ++++++++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 56e8149866f4..f5b4bb6a316b 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -331,6 +331,7 @@ DEF_HELPER_FLAGS_3(sturg, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_1(per_check_exception, void, env) DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64) DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64) +DEF_HELPER_FLAGS_1(per_store_real, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_1(stfl, TCG_CALL_NO_RWG, void, env) DEF_HELPER_2(xsch, void, env, i64) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 2325767f1787..b1b3f406c9e0 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2344,27 +2344,11 @@ uint64_t HELPER(lurag)(CPUS390XState *env, uint64_t addr) void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1) { cpu_stl_real_ra(env, wrap_address(env, addr), (uint32_t)v1, GETPC()); - - if ((env->psw.mask & PSW_MASK_PER) && - (env->cregs[9] & PER_CR9_EVENT_STORE) && - (env->cregs[9] & PER_CR9_EVENT_STORE_REAL)) { - /* PSW is saved just before calling the helper. */ - env->per_address = env->psw.addr; - env->per_perc_atmid = PER_CODE_EVENT_STORE_REAL | get_per_atmid(env); - } } void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1) { cpu_stq_real_ra(env, wrap_address(env, addr), v1, GETPC()); - - if ((env->psw.mask & PSW_MASK_PER) && - (env->cregs[9] & PER_CR9_EVENT_STORE) && - (env->cregs[9] & PER_CR9_EVENT_STORE_REAL)) { - /* PSW is saved just before calling the helper. */ - env->per_address = env->psw.addr; - env->per_perc_atmid = PER_CODE_EVENT_STORE_REAL | get_per_atmid(env); - } } /* load real address */ diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index bfb457fb631a..58dbc023eb54 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -620,6 +620,16 @@ void HELPER(per_ifetch)(CPUS390XState *env, uint64_t addr) } } } + +void HELPER(per_store_real)(CPUS390XState *env) +{ + if ((env->cregs[9] & PER_CR9_EVENT_STORE) && + (env->cregs[9] & PER_CR9_EVENT_STORE_REAL)) { + /* PSW is saved just before calling the helper. */ + env->per_address = env->psw.addr; + env->per_perc_atmid = PER_CODE_EVENT_STORE_REAL | get_per_atmid(env); + } +} #endif static uint8_t stfl_bytes[2048]; diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 151dfa91fb9f..ef751fefa4e5 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4507,12 +4507,20 @@ static DisasJumpType op_stnosm(DisasContext *s, DisasOps *o) static DisasJumpType op_stura(DisasContext *s, DisasOps *o) { gen_helper_stura(cpu_env, o->in2, o->in1); + if (s->base.tb->flags & FLAG_MASK_PER) { + update_psw_addr(s); + gen_helper_per_store_real(cpu_env); + } return DISAS_NEXT; } static DisasJumpType op_sturg(DisasContext *s, DisasOps *o) { gen_helper_sturg(cpu_env, o->in2, o->in1); + if (s->base.tb->flags & FLAG_MASK_PER) { + update_psw_addr(s); + gen_helper_per_store_real(cpu_env); + } return DISAS_NEXT; } #endif From patchwork Thu Dec 19 11:01:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 11303313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7607214E3 for ; Thu, 19 Dec 2019 11:10:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BB2F222C2 for ; Thu, 19 Dec 2019 11:10:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h1Wwtpw/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BB2F222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihth8-00024b-3P for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 06:10:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42393) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtYj-0006fv-PM for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtYi-0000Ma-5S for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51007 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihtYh-0000IA-Tq for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576753291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qIeGxDzPPfjt2yoiWN9A5KRxsOXYS9OSgM4V3ajWsN0=; b=h1Wwtpw/Gx/fJpQ9b2nXAfo69aNqtRipfqZchh8ilL4ypmeO4X+UOtX3pPfSXf9A6vwlkq aGGodlPiw/NysxwU1mLiuETnKatC/Lu/vRJovH6f9V9tikWPRa7djgQkPJ8abPY0aIaGCX TSyur5RR4pC8xVYf01XnCpiRbTthdx4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-yUnTq2hPMs2h0mOXz6244g-1; Thu, 19 Dec 2019 06:01:27 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02B57593AB; Thu, 19 Dec 2019 11:01:26 +0000 (UTC) Received: from localhost (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4510363B92; Thu, 19 Dec 2019 11:01:23 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Subject: [PULL 2/6] target/s390x: Implement LOAD/STORE TO REAL ADDRESS inline Date: Thu, 19 Dec 2019 12:01:08 +0100 Message-Id: <20191219110112.8343-3-cohuck@redhat.com> In-Reply-To: <20191219110112.8343-1-cohuck@redhat.com> References: <20191219110112.8343-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: yUnTq2hPMs2h0mOXz6244g-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson These are trivially done by performing a memory operation with the correct mmu_idx. The only tricky part is using get_address directly in order to get the address wrapped; we cannot use la2 because of the format. Signed-off-by: Richard Henderson Message-Id: <20191211203614.15611-3-richard.henderson@linaro.org> Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- target/s390x/helper.h | 4 ---- target/s390x/insn-data.def | 8 ++++---- target/s390x/mem_helper.c | 22 ---------------------- target/s390x/translate.c | 21 ++++----------------- 4 files changed, 8 insertions(+), 47 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index f5b4bb6a316b..b5813c2ac2b9 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -324,10 +324,6 @@ DEF_HELPER_FLAGS_4(ipte, TCG_CALL_NO_RWG, void, env, i64, i64, i32) DEF_HELPER_FLAGS_1(ptlb, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_1(purge, TCG_CALL_NO_RWG, void, env) DEF_HELPER_2(lra, i64, env, i64) -DEF_HELPER_FLAGS_2(lura, TCG_CALL_NO_WG, i64, env, i64) -DEF_HELPER_FLAGS_2(lurag, TCG_CALL_NO_WG, i64, env, i64) -DEF_HELPER_FLAGS_3(stura, TCG_CALL_NO_WG, void, env, i64, i64) -DEF_HELPER_FLAGS_3(sturg, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_1(per_check_exception, void, env) DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64) DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 449eee1662d0..2bc77f087102 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -1275,8 +1275,8 @@ F(0xe313, LRAY, RXY_a, LD, 0, a2, r1, 0, lra, 0, IF_PRIV) F(0xe303, LRAG, RXY_a, Z, 0, a2, r1, 0, lra, 0, IF_PRIV) /* LOAD USING REAL ADDRESS */ - F(0xb24b, LURA, RRE, Z, 0, r2, new, r1_32, lura, 0, IF_PRIV) - F(0xb905, LURAG, RRE, Z, 0, r2, r1, 0, lurag, 0, IF_PRIV) + E(0xb24b, LURA, RRE, Z, 0, 0, new, r1_32, lura, 0, MO_TEUL, IF_PRIV) + E(0xb905, LURAG, RRE, Z, 0, 0, r1, 0, lura, 0, MO_TEQ, IF_PRIV) /* MOVE TO PRIMARY */ F(0xda00, MVCP, SS_d, Z, la1, a2, 0, 0, mvcp, 0, IF_PRIV) /* MOVE TO SECONDARY */ @@ -1329,8 +1329,8 @@ /* STORE THEN OR SYSTEM MASK */ F(0xad00, STOSM, SI, Z, la1, 0, 0, 0, stnosm, 0, IF_PRIV) /* STORE USING REAL ADDRESS */ - F(0xb246, STURA, RRE, Z, r1_o, r2_o, 0, 0, stura, 0, IF_PRIV) - F(0xb925, STURG, RRE, Z, r1_o, r2_o, 0, 0, sturg, 0, IF_PRIV) + E(0xb246, STURA, RRE, Z, r1_o, 0, 0, 0, stura, 0, MO_TEUL, IF_PRIV) + E(0xb925, STURG, RRE, Z, r1_o, 0, 0, 0, stura, 0, MO_TEQ, IF_PRIV) /* TEST BLOCK */ F(0xb22c, TB, RRE, Z, 0, r2_o, 0, 0, testblock, 0, IF_PRIV) /* TEST PROTECTION */ diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b1b3f406c9e0..2921419c27cd 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -2329,28 +2329,6 @@ void HELPER(purge)(CPUS390XState *env) tlb_flush_all_cpus_synced(env_cpu(env)); } -/* load using real address */ -uint64_t HELPER(lura)(CPUS390XState *env, uint64_t addr) -{ - return cpu_ldl_real_ra(env, wrap_address(env, addr), GETPC()); -} - -uint64_t HELPER(lurag)(CPUS390XState *env, uint64_t addr) -{ - return cpu_ldq_real_ra(env, wrap_address(env, addr), GETPC()); -} - -/* store using real address */ -void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1) -{ - cpu_stl_real_ra(env, wrap_address(env, addr), (uint32_t)v1, GETPC()); -} - -void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1) -{ - cpu_stq_real_ra(env, wrap_address(env, addr), v1, GETPC()); -} - /* load real address */ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr) { diff --git a/target/s390x/translate.c b/target/s390x/translate.c index ef751fefa4e5..4292bb0dd078 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3272,13 +3272,8 @@ static DisasJumpType op_lpq(DisasContext *s, DisasOps *o) #ifndef CONFIG_USER_ONLY static DisasJumpType op_lura(DisasContext *s, DisasOps *o) { - gen_helper_lura(o->out, cpu_env, o->in2); - return DISAS_NEXT; -} - -static DisasJumpType op_lurag(DisasContext *s, DisasOps *o) -{ - gen_helper_lurag(o->out, cpu_env, o->in2); + o->addr1 = get_address(s, 0, get_field(s->fields, r2), 0); + tcg_gen_qemu_ld_tl(o->out, o->addr1, MMU_REAL_IDX, s->insn->data); return DISAS_NEXT; } #endif @@ -4506,17 +4501,9 @@ static DisasJumpType op_stnosm(DisasContext *s, DisasOps *o) static DisasJumpType op_stura(DisasContext *s, DisasOps *o) { - gen_helper_stura(cpu_env, o->in2, o->in1); - if (s->base.tb->flags & FLAG_MASK_PER) { - update_psw_addr(s); - gen_helper_per_store_real(cpu_env); - } - return DISAS_NEXT; -} + o->addr1 = get_address(s, 0, get_field(s->fields, r2), 0); + tcg_gen_qemu_st_tl(o->in1, o->addr1, MMU_REAL_IDX, s->insn->data); -static DisasJumpType op_sturg(DisasContext *s, DisasOps *o) -{ - gen_helper_sturg(cpu_env, o->in2, o->in1); if (s->base.tb->flags & FLAG_MASK_PER) { update_psw_addr(s); gen_helper_per_store_real(cpu_env); From patchwork Thu Dec 19 11:01:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 11303317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D5D614E3 for ; Thu, 19 Dec 2019 11:12:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 139C1222C2 for ; Thu, 19 Dec 2019 11:12:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eQ7e4EXZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 139C1222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtir-0004Bh-2d for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 06:12:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43522) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtYq-0006oh-Ss for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtYp-00010V-HJ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:40 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60890 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihtYp-0000y1-At for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576753298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xHpMM384RdXLzpFE6SjAZkdl42OK3Or+UxwQ8vHaGjs=; b=eQ7e4EXZVlf3oSi0mZEditzL1Jt0wc3hd/n29QF7L1RIkIlxY+zkD3hsQyh8Y2ft7hCGdi lvExeX1CUaSlcNykuRWCArvrr7ghQN++QuQ0AEP9CsMqMVGbQl2gREHWwA/kh8soLwCZji /QNVqEMfQkvQ6D2uYXsIetCwKXUWYnM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-V4CIXPzsOm6JY6G4ARcCYw-1; Thu, 19 Dec 2019 06:01:29 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 289011005514; Thu, 19 Dec 2019 11:01:28 +0000 (UTC) Received: from localhost (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B32F710013A1; Thu, 19 Dec 2019 11:01:27 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Subject: [PULL 3/6] tests/boot-sector: Fix the bad s390x assembler code Date: Thu, 19 Dec 2019 12:01:09 +0100 Message-Id: <20191219110112.8343-4-cohuck@redhat.com> In-Reply-To: <20191219110112.8343-1-cohuck@redhat.com> References: <20191219110112.8343-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: V4CIXPzsOm6JY6G4ARcCYw-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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 , Christian Borntraeger , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth There are currently two bugs in s390x_code[]: First, the initial jump uses the wrong offset, so it was jumping to 0x10014 instead of 0x10010. Second, LHI only loads the lower 32-bit of the register. Everything worked fine as long as the s390-ccw bios code was jumping here with r3 containing zeroes in the uppermost 48 bit - which just happened to be the case so far by accident. But we can not rely on this fact, and indeed one of the recent suggested patches to jump2ipl.c cause the newer GCCs to put different values into r3. In that case the code from s390x_code[] crashes very ungracefully. Thus let's make sure to jump to the right instruction, and use LGHI instead of LHI to make sure that we always zero out the upper bits of the register. Signed-off-by: Thomas Huth Message-Id: <20191217150642.27946-1-thuth@redhat.com> Reviewed-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- tests/boot-sector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/boot-sector.c b/tests/boot-sector.c index 7824286b9a4e..9e66c6d0130a 100644 --- a/tests/boot-sector.c +++ b/tests/boot-sector.c @@ -75,11 +75,11 @@ static const uint8_t s390x_psw_and_magic[] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 /* in the s390-ccw bios */ }; static const uint8_t s390x_code[] = { - 0xa7, 0xf4, 0x00, 0x0a, /* j 0x10010 */ + 0xa7, 0xf4, 0x00, 0x08, /* j 0x10010 */ 0x00, 0x00, 0x00, 0x00, 'S', '3', '9', '0', 'E', 'P', 0x00, 0x01, - 0xa7, 0x38, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lhi r3,0x7c10 */ + 0xa7, 0x39, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lghi r3,0x7c10 */ 0xa7, 0x48, LOW(SIGNATURE), HIGH(SIGNATURE), /* lhi r4,0xadde */ 0x40, 0x40, 0x30, 0x00, /* sth r4,0(r3) */ 0xa7, 0xf4, 0xff, 0xfa /* j 0x10010 */ From patchwork Thu Dec 19 11:01:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 11303297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94C8D14E3 for ; Thu, 19 Dec 2019 11:04:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 69F7D24650 for ; Thu, 19 Dec 2019 11:04:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XRes72Ee" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69F7D24650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtbc-0002HB-R2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 06:04:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43304) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtYp-0006mw-Ii for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtYo-0000uN-AQ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:39 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21956 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihtYo-0000k3-3o for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576753296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GN3BOXoY+K3lCkpEd8ZedRLEqb9ptuEu3tYT9xjH8uM=; b=XRes72Eeq1BEbucKhXMN6vdCLebZTraWFji+QEDcYym911XdU9INGmef3PA1bm5aUrJpG6 WniLMA8wQ7ReYqyBkZFsESnJmXU7sxowKZnBdrIeJteSya90MYJOisMbtSdBScHqC+bdq2 b9krM5GN7YpgCOpKCUqp5L1izanKAz4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-LvIVz8PuNqazKSncH7aZ6w-1; Thu, 19 Dec 2019 06:01:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40FA9190D349; Thu, 19 Dec 2019 11:01:33 +0000 (UTC) Received: from localhost (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D45AE675B8; Thu, 19 Dec 2019 11:01:32 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Subject: [PULL 4/6] pc-bios/s390x: Fix reset psw mask Date: Thu, 19 Dec 2019 12:01:10 +0100 Message-Id: <20191219110112.8343-5-cohuck@redhat.com> In-Reply-To: <20191219110112.8343-1-cohuck@redhat.com> References: <20191219110112.8343-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: LvIVz8PuNqazKSncH7aZ6w-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Christian Borntraeger , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, Janosch Frank Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Janosch Frank We need to set the short psw indication bit in the reset psw, as it is a short psw. Exposed by "s390x: Properly fetch and test the short psw on diag308 subc 0/1". Fixes: 962982329029 ("pc-bios/s390-ccw: do a subsystem reset before running the guest") Signed-off-by: Janosch Frank Message-Id: <20191203132813.2734-5-frankja@linux.ibm.com> Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/jump2ipl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c index 266f1502b967..da13c43cc047 100644 --- a/pc-bios/s390-ccw/jump2ipl.c +++ b/pc-bios/s390-ccw/jump2ipl.c @@ -12,11 +12,11 @@ #define KERN_IMAGE_START 0x010000UL #define PSW_MASK_64 0x0000000100000000ULL #define PSW_MASK_32 0x0000000080000000ULL -#define IPL_PSW_MASK (PSW_MASK_32 | PSW_MASK_64) +#define PSW_MASK_SHORTPSW 0x0008000000000000ULL +#define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_32 | PSW_MASK_64) typedef struct ResetInfo { - uint32_t ipl_mask; - uint32_t ipl_addr; + uint64_t ipl_psw; uint32_t ipl_continue; } ResetInfo; @@ -50,7 +50,9 @@ void jump_to_IPL_code(uint64_t address) ResetInfo *current = 0; save = *current; - current->ipl_addr = (uint32_t) (uint64_t) &jump_to_IPL_2; + + current->ipl_psw = (uint64_t) &jump_to_IPL_2; + current->ipl_psw |= RESET_PSW_MASK; current->ipl_continue = address & 0x7fffffff; debug_print_int("set IPL addr to", current->ipl_continue); @@ -82,7 +84,7 @@ void jump_to_low_kernel(void) } /* Trying to get PSW at zero address */ - if (*((uint64_t *)0) & IPL_PSW_MASK) { + if (*((uint64_t *)0) & RESET_PSW_MASK) { jump_to_IPL_code((*((uint64_t *)0)) & 0x7fffffff); } From patchwork Thu Dec 19 11:01:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 11303305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0C57109A for ; Thu, 19 Dec 2019 11:07:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6584222C2 for ; Thu, 19 Dec 2019 11:07:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="B5hplWzT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6584222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihteC-00065t-F2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 06:07:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45538) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtZ5-0007Aa-Ti for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtZ4-00028C-AH for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:55 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48837 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihtZ3-00024I-Tv for qemu-devel@nongnu.org; Thu, 19 Dec 2019 06:01:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576753313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SsKlgFVaY90ZmdAuFQza/rRwJIEq8CzteF4gT9FMQ5M=; b=B5hplWzTXmW3F+upJC0aDUMTVFMVpMrcqVuEciRvXPqi+wkc32L1dLoN+2Aj2qotd+kosb z8+kq0uog/IamsoxhfX6TtAnhBQJvWKfciNMpJn6kMZ6CKCaTtJDAexLKfmrZhRlSIdGss GlsgOOZwK8WlegsavQpAPTdHpN1MhaM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-5yEOigs-N6yhXwYy-pobyw-1; Thu, 19 Dec 2019 06:01:49 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AD871005510; Thu, 19 Dec 2019 11:01:48 +0000 (UTC) Received: from localhost (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE92D63B89; Thu, 19 Dec 2019 11:01:45 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Subject: [PULL 6/6] s390x: Properly fetch and test the short psw on diag308 subc 0/1 Date: Thu, 19 Dec 2019 12:01:12 +0100 Message-Id: <20191219110112.8343-7-cohuck@redhat.com> In-Reply-To: <20191219110112.8343-1-cohuck@redhat.com> References: <20191219110112.8343-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: 5yEOigs-N6yhXwYy-pobyw-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 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: Cornelia Huck , qemu-s390x@nongnu.org, David Hildenbrand , qemu-devel@nongnu.org, Janosch Frank Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Janosch Frank We need to actually fetch the cpu mask and set it. As we invert the short psw indication in the mask, SIE will report a specification exception, if it wasn't present in the reset psw. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Message-Id: <20191129142025.21453-2-frankja@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/s390x/cpu.c | 12 ++++++++++-- target/s390x/cpu.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 99ea09085a30..625daeedd133 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -76,8 +76,16 @@ static bool s390_cpu_has_work(CPUState *cs) static void s390_cpu_load_normal(CPUState *s) { S390CPU *cpu = S390_CPU(s); - cpu->env.psw.addr = ldl_phys(s->as, 4) & PSW_MASK_ESA_ADDR; - cpu->env.psw.mask = PSW_MASK_32 | PSW_MASK_64; + uint64_t spsw = ldq_phys(s->as, 0); + + cpu->env.psw.mask = spsw & 0xffffffff80000000ULL; + /* + * Invert short psw indication, so SIE will report a specification + * exception if it was not set. + */ + cpu->env.psw.mask ^= PSW_MASK_SHORTPSW; + cpu->env.psw.addr = spsw & 0x7fffffffULL; + s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); } #endif diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index aa829e954cbf..e195e5c7c8bb 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -269,6 +269,7 @@ extern const VMStateDescription vmstate_s390_cpu; #define PSW_MASK_EXT 0x0100000000000000ULL #define PSW_MASK_KEY 0x00F0000000000000ULL #define PSW_SHIFT_KEY 52 +#define PSW_MASK_SHORTPSW 0x0008000000000000ULL #define PSW_MASK_MCHECK 0x0004000000000000ULL #define PSW_MASK_WAIT 0x0002000000000000ULL #define PSW_MASK_PSTATE 0x0001000000000000ULL