From patchwork Tue Feb 12 05:30:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158092 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3437938jaa; Mon, 11 Feb 2019 21:36:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJ+fgkPmHlGjMSmR0OrdSSNavB5Iy1r6RbJ4A35eRXFLvuf32sHY8mfBtNuNVVKWtw2qCc X-Received: by 2002:a25:8388:: with SMTP id t8mr1451324ybk.376.1549949803028; Mon, 11 Feb 2019 21:36:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549949803; cv=none; d=google.com; s=arc-20160816; b=A0RqEQgPWOuCBp82y5DWy2TxY/wJXXm79VQ0nciLHvuKg8vgLx3H6yUu1y+oz5pWmU KjOg8cfrsx9dF4mLYZc15e+SGycZ6PZUzG+7rQc4tW3jP92hcJ72F9akSj+8/xYz2WEq t2Aum+XcncbGuWVgcnimUNOrHHCoDC6iQx0ZOzmvCquhOMfnTHC3wUD7p0CcoFsBV392 HkAzWa8A//Zp8izA+dCyfdpUF7ed15G+EGiX2obWYfBWEoGesi3E+Cp7KRmaIabNBnEq wawIUUJ2TzTq7T1A34AEfPG6PninEKgE4ZcZwwyTuMVg9lGs+yMivMXWx5v3ta1N+uqT Y8bw== 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:dkim-signature; bh=sYqOuPIKKMuM+JSYbUKLjF6TsNjMKw+rF+QLJqqZn8k=; b=ftgQmWYR4s5pj9cDtJmKYHmEtl18uBqe134VXsCO91O+QNGggQmHaLGo7x3bIK9/zL YwsGYgd2Youcjc8ThJGEn1h0hjp8M2asWMMaivSdjvRMBXP56z7RfQzBY+UiV+57VF2I 0AK66tFWs/0VJUgJjx9wuAWUa99/56q/egFVoPHyCccWohdJSuzn9bVyos7lIMcxpZRw aIvFnyatO1Vm7b4Nj34KFodjo0WPZMYbHSzWR8kzFcf6me6DxsbGzT+mdtwgKjwJsBp6 IRc9nFK4QK5nOqkswE2XIKM4d3hPK4udYI5of1MjsJEEXttpTmtLK4vdLOhbMPHKA265 R/ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="A/2Tyssi"; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m185si7471517ywf.256.2019.02.11.21.36.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Feb 2019 21:36:43 -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; dkim=fail header.i=@linaro.org header.s=google header.b="A/2Tyssi"; 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=linaro.org Received: from localhost ([127.0.0.1]:33583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtQkM-0005dU-FZ for patch@linaro.org; Tue, 12 Feb 2019 00:36:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtQhw-00041E-A9 for qemu-devel@nongnu.org; Tue, 12 Feb 2019 00:34:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtQel-00075f-9K for qemu-devel@nongnu.org; Tue, 12 Feb 2019 00:30:58 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:45361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtQek-0006Tk-Cb for qemu-devel@nongnu.org; Tue, 12 Feb 2019 00:30:54 -0500 Received: by mail-pg1-x543.google.com with SMTP id y4so688884pgc.12 for ; Mon, 11 Feb 2019 21:30:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sYqOuPIKKMuM+JSYbUKLjF6TsNjMKw+rF+QLJqqZn8k=; b=A/2TyssiVT+rObwJqrRoANXRP0OsquSOWt/UBqmsKkFD+/zbtDg7LdvuW66ZauKr0Q re5kWGqSS0SDORqc7/kR2fcfX34U85Eu1vcv8aY1lGa8iwUYJ41HnDhbvqWDsIPWNFTh 3LYJSXyVhryzNd8SC4z/SL19h3YPnMysEAS72T+0IoUBlud6dEfzjFx5/oXvZtcS6YKn tQeNll5eQ7PaqanNgImwUdgGqkOSDm9tnS1BzGKEBe2n5yZRVhNtkayXc2Fbvcl6J8zE sgVKRW09Pd+nHr6szc+dr8CfBfUBruo8idiEMK+6rO/OvT/ZjRO9K5/eihG3/GaAYzO8 iBdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sYqOuPIKKMuM+JSYbUKLjF6TsNjMKw+rF+QLJqqZn8k=; b=oFKd3XOlxsEpza30khl7ecM1/hVkOaOoOS+k2gDpzHO0ahFQ+JWC5uP06hI+YGd+O1 r4mJcYuNt10SOmWJG84AcYYBiCz/wEAThpR/FsBXdNrNbOo7d7yIbUaPsyCZ5xiiKlQ9 ZagFOLytqw5tNGhRr+AhAoFO1m3BBfqc4VgwDT0fbPMg5j48qEKnI6axYODk2/a2PwmF EQee/bxV4rO/z9UhwnordhANW0bZaE4F+T9quSQY2p7GZjI5Gak2MREg8GHh69iGVr/F tqcEpVd0EiiB1JBoJ9wOx4OWdJHh7A66RCc69OOzr3Bzstlsh/KyWdAiAfsAlaKNcP0Q 9oPA== X-Gm-Message-State: AHQUAuZ0EMWgqppnPen6VmugHJQMsmOfeQCM4d5sUNU5KNjHzhlpSwZM 9mi92AkQDLla7F/Osg+yneDn1fNn/7U= X-Received: by 2002:a63:d703:: with SMTP id d3mr2016484pgg.167.1549949448986; Mon, 11 Feb 2019 21:30:48 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d16sm13625036pgj.21.2019.02.11.21.30.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 21:30:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 21:30:44 -0800 Message-Id: <20190212053044.29015-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190212053044.29015-1-richard.henderson@linaro.org> References: <20190212053044.29015-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v3 2/2] 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, cohuck@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- target/s390x/helper.h | 2 +- target/s390x/misc_helper.c | 34 ++++++++++++++++++++++------------ target/s390x/translate.c | 2 ++ target/s390x/insn-data.def | 11 ++++++----- 4 files changed, 31 insertions(+), 18 deletions(-) -- 2.17.2 diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 018e9dd414..6260b50496 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/misc_helper.c b/target/s390x/misc_helper.c index 52262f62df..ee67c1fa0c 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 639084af07..19072efec6 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); diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index dab805fd90..61582372ab 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 */