From patchwork Mon Feb 18 11:11:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 158586 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2363330jaa; Mon, 18 Feb 2019 03:15:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IZxUkIEMWbZsRUizbtVU4O/MhMC70sCQFYr2DpUEaEFNWec6BJq7lPVRJ5LP0LXQHGDkfOT X-Received: by 2002:a81:2ac1:: with SMTP id q184mr17554052ywq.99.1550488512501; Mon, 18 Feb 2019 03:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550488512; cv=none; d=google.com; s=arc-20160816; b=VoCVXZsRYxekG8ToXpqlA3T8ZGBRQLUnfcfEv4djkRMHTogGfpO6HObRuhR4/usthD R83CV3UqeBYB0z3/AMC9zeFUhks01YE860z0yUN/AINRwcwJdm13vwmhO356A9iDKMx8 vYrfS+8HqemnT879V3MYSuAfRtHz8b+q2ofwXS/FtmOnEPZPxSv1LizCfOwUyzRLKZbd 7iOYSRXf1rLG4p34dzcjU/S5TSmrncnm8ZSjMQBgZ5pSfGXN9VuFtlO3+KlFhp7/KZUr ffNpMmFcUpqRpNMP4NCppwA7i4IxZRNWYqONGLdV+eCU5KcwvjTasiG57pZl9c7Tv63H /xaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from; bh=EHiIbnIMV0vka8VF5Fg2O0j6GgNHw4BPqQ30wqy9AWU=; b=A6NcBx0kdV8rQltjq10AMu1uRS9dB00fVf0+6KpsUzkBcUJAqdn4dbzASamfoU1HDp 3FL1nAhrddiI75nYRz9FKS2A5Av2RED+2GPexvcdKEDFBtvTB+4Dd8YIEPjiD2cizUoP F76tBwdmYN4kC07OJVgz6323SPJ87lau53KC4D8oc9jeDvYIXWwvaw6a3qdsAf25bKoe xQLy9YbQkKoD8+QxzjM/LebDc6ayIaIgzWGOleggLYlnwvhtCUOID8BwV1srBUr9xOKY 53cDcOO7sxbagZ6Ln7VVCTJuSGSrK6N+3IKz/5BkhSS11+axp9D/+RTsxsxqMdTOyP+K W3qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w201si638030ywa.240.2019.02.18.03.15.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Feb 2019 03:15:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([127.0.0.1]:56559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvgtE-00087U-0P for patch@linaro.org; Mon, 18 Feb 2019 06:15:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvgqH-0006sh-EV for qemu-devel@nongnu.org; Mon, 18 Feb 2019 06:12:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvgqG-0006jl-AJ for qemu-devel@nongnu.org; Mon, 18 Feb 2019 06:12:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvgqG-0006jB-0B; Mon, 18 Feb 2019 06:12:08 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B302C7E8B; Mon, 18 Feb 2019 11:12:07 +0000 (UTC) Received: from localhost (ovpn-116-217.ams2.redhat.com [10.36.116.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2D0217C2B; Mon, 18 Feb 2019 11:12:06 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Mon, 18 Feb 2019 12:11:47 +0100 Message-Id: <20190218111153.22681-5-cohuck@redhat.com> In-Reply-To: <20190218111153.22681-1-cohuck@redhat.com> References: <20190218111153.22681-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 18 Feb 2019 11:12:07 +0000 (UTC) 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 04/10] target/s390x: Implement STCK et al for CONFIG_USER_ONLY 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: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This is a non-privileged instruction that was only implemented for system mode. However, the stck instruction is used by glibc, so this was causing SIGILL for programs run under debian stretch. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson Message-Id: <20190212053044.29015-3-richard.henderson@linaro.org> Signed-off-by: Cornelia Huck --- target/s390x/helper.h | 2 +- target/s390x/insn-data.def | 11 ++++++----- target/s390x/misc_helper.c | 34 ++++++++++++++++++++++------------ target/s390x/translate.c | 2 ++ 4 files changed, 31 insertions(+), 18 deletions(-) -- 2.17.2 diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 018e9dd41487..6260b5049621 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -121,13 +121,13 @@ DEF_HELPER_4(cu41, i32, env, i32, i32, i32) DEF_HELPER_4(cu42, i32, env, i32, i32, i32) DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32) DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env) +DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env) #ifndef CONFIG_USER_ONLY DEF_HELPER_3(servc, i32, env, i64, i64) DEF_HELPER_4(diag, void, env, i32, i32, i32) DEF_HELPER_3(load_psw, noreturn, env, i64, i64) DEF_HELPER_FLAGS_2(spx, TCG_CALL_NO_RWG, void, env, i64) -DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env) DEF_HELPER_FLAGS_2(sck, TCG_CALL_NO_RWG, i32, env, i64) DEF_HELPER_FLAGS_2(sckc, TCG_CALL_NO_RWG, void, env, i64) DEF_HELPER_FLAGS_2(sckpf, TCG_CALL_NO_RWG, void, env, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index dab805fd90b4..61582372abb7 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -837,6 +837,12 @@ C(0xe33e, STRV, RXY_a, Z, la2, r1_32u, new, m1_32, rev32, 0) C(0xe32f, STRVG, RXY_a, Z, la2, r1_o, new, m1_64, rev64, 0) +/* STORE CLOCK */ + C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0) + C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0) +/* STORE CLOCK EXTENDED */ + C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0) + /* STORE FACILITY LIST EXTENDED */ C(0xb2b0, STFLE, S, SFLE, 0, a2, 0, 0, stfle, 0) /* STORE FPC */ @@ -1020,11 +1026,6 @@ F(0x8000, SSM, S, Z, 0, m2_8u, 0, 0, ssm, 0, IF_PRIV) /* SIGNAL PROCESSOR */ F(0xae00, SIGP, RS_a, Z, 0, a2, 0, 0, sigp, 0, IF_PRIV) -/* STORE CLOCK */ - C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0) - C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0) -/* STORE CLOCK EXTENDED */ - C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0) /* STORE CLOCK COMPARATOR */ F(0xb207, STCKC, S, Z, la2, 0, new, m1_64a, stckc, 0, IF_PRIV) /* STORE CONTROL */ diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 52262f62df26..ee67c1fa0c51 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -30,6 +30,7 @@ #include "exec/cpu_ldst.h" #include "qapi/error.h" #include "tcg_s390x.h" +#include "s390-tod.h" #if !defined(CONFIG_USER_ONLY) #include "sysemu/cpus.h" @@ -76,8 +77,28 @@ uint64_t HELPER(stpt)(CPUS390XState *env) #endif } -#ifndef CONFIG_USER_ONLY +/* Store Clock */ +uint64_t HELPER(stck)(CPUS390XState *env) +{ +#ifdef CONFIG_USER_ONLY + struct timespec ts; + uint64_t ns; + + clock_gettime(CLOCK_REALTIME, &ts); + ns = ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec; + + return TOD_UNIX_EPOCH + time2tod(ns); +#else + S390TODState *td = s390_get_todstate(); + S390TODClass *tdc = S390_TOD_GET_CLASS(td); + S390TOD tod; + tdc->get(td, &tod, &error_abort); + return tod.low; +#endif +} + +#ifndef CONFIG_USER_ONLY /* SCLP service call */ uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2) { @@ -138,17 +159,6 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1) tlb_flush_page(cs, TARGET_PAGE_SIZE); } -/* Store Clock */ -uint64_t HELPER(stck)(CPUS390XState *env) -{ - S390TODState *td = s390_get_todstate(); - S390TODClass *tdc = S390_TOD_GET_CLASS(td); - S390TOD tod; - - tdc->get(td, &tod, &error_abort); - return tod.low; -} - static void update_ckc_timer(CPUS390XState *env) { S390TODState *td = s390_get_todstate(); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 639084af07d0..19072efec655 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4060,6 +4060,7 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps *o) tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, core_id)); return DISAS_NEXT; } +#endif static DisasJumpType op_stck(DisasContext *s, DisasOps *o) { @@ -4096,6 +4097,7 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o) return DISAS_NEXT; } +#ifndef CONFIG_USER_ONLY static DisasJumpType op_sck(DisasContext *s, DisasOps *o) { tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEQ | MO_ALIGN);