From patchwork Fri Dec 29 06:31:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 122905 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4331782qgn; Thu, 28 Dec 2017 22:46:20 -0800 (PST) X-Google-Smtp-Source: ACJfBovc8hB7CN8TChNhSyzyxdsHzxLEj+yezHJ9x77ziojIBOsAge159LiL2Z0gpKXbrZlG/upA X-Received: by 10.129.40.80 with SMTP id o77mr22326234ywo.276.1514529980501; Thu, 28 Dec 2017 22:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514529980; cv=none; d=google.com; s=arc-20160816; b=sdxxNGXVPgtq8mYTWCTVFCdIm4Be4s+fHU9L1pIz70ci2WouP5ZclkEp3krgPRVk/t 6XXptD9IYPi8StEjKsuvXvcA8sGdbDjVOTecJQ2YMzINslVHRSJ0CGAhHyhnq89oPoea 5lux1St0VlEIk1FhSnlpoZxU8PLByYXoX9n7a6hyayRNmDhM6wt+CYz2MZgOVV0+M0Yw 4MuNv0ztvAtIHSHtgwUMi3rqtnQrrXfAZ1FeachRhma4NqLnqSHeRxqJzPE9YX3HH9nq BG20xoZWPSXaq5Y/e8hEsY0RnXerc/OhIcia027RpjpYOEYArWLbHPoakvRjAou6lB4/ z35Q== 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:arc-authentication-results; bh=CcgTa9TvZfvDCiht2f8299S4JVix3wDViEHtoObuWPk=; b=Hy/ABjKUtFm7yuXwKMP0H1QPqDKLaGo0NFt4DYaHcL9aWpdgM4wYi9CqMX61KdaW94 uchd79xZo+opNYLrbPBCh3ddIJuJgxC/Lo7ETqXfktu2xgaIrpHTxTQnovjV9S4gi/Sd fWaIDLHmIRWoE0lXV8/7U/OshjXjuTWTeqap+xD0r+CJsacvLDBxwOa30q/CMzpAjNwR mrBF4t5sj3KIYdKp+lsqOKa4qtSVk3rCVsvUtKxr9AW/DlFJrjTpb9ZarlW8SjVlfGeC 97fmIBPG/cWK33F7BQWh/1K71YI4fWZTh8NZOlOthEkLt/U+/DHhUT7PxzwLt0JfGRWk N68g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XAU8A5jb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v71si3278409ybg.283.2017.12.28.22.46.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Dec 2017 22:46:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XAU8A5jb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:57003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUoQt-0005YQ-W1 for patch@linaro.org; Fri, 29 Dec 2017 01:46:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUoD7-0002wP-Md for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:32:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUoD6-0004aP-Iu for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:32:05 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45459) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eUoD6-0004Zn-8X for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:32:04 -0500 Received: by mail-pf0-x244.google.com with SMTP id u19so21809156pfa.12 for ; Thu, 28 Dec 2017 22:32:04 -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=CcgTa9TvZfvDCiht2f8299S4JVix3wDViEHtoObuWPk=; b=XAU8A5jbWR/Jd1UgireyD7m4AkulU33n4udNhb5v5Fj2A+7fEQmALbuP7vsdenePhp 56pNdwIGXGyP6EOEcJSft3WtWaocnnIcpA3l8ylQcQr/gAvgGQbGtCe3DgXV/nV0Qj/u 2lWD1O5U/oVdzqKg6iH9DCM2PI7dQpkCip3Bg= 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=CcgTa9TvZfvDCiht2f8299S4JVix3wDViEHtoObuWPk=; b=nZoQxaiW8HubC/I9BtSOT999uPGSibb7cBHnqvYeVxue3CFlSRL/UWWZDJR2sqkbXv JeRcHsapPEy/Kxl3pEdQn8DV+bxzmfSsKs4zYq6QGwIsKad1XoQYvzXMeSug0OCY30cD Dc9NoZSUv/Fz/R7Y+Hb8ZAqTpN5hs84Qwpa6XYMkoEplpJMKJx4WWTuAL0zHiCci8wJR Z5g+wApvjT/Sm4rxzoCGCQxlOU/D4SpwYIRu7faMelefO3DiB7XRjZqs6NSB0cfOYA3m VLXU0vzCs/qmzLl2pN98Xi3XpSPeKbihAe8MSD7gJ5GSm6CHYh+2jHLODY4piMNwFFLG hVwA== X-Gm-Message-State: AKGB3mIoHMHOHRVAmK30FEe8NWzXZ0qC2vy/KHH8Bv+685uSAH65z+cK 2WSuylCB5xbSvBk66x9r7gqIeQBTnA4= X-Received: by 10.98.131.69 with SMTP id h66mr33904012pfe.30.1514529123021; Thu, 28 Dec 2017 22:32:03 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-183-164.tukw.qwest.net. [97.113.183.164]) by smtp.gmail.com with ESMTPSA id c28sm76539063pfe.69.2017.12.28.22.32.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Dec 2017 22:32:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Dec 2017 22:31:18 -0800 Message-Id: <20171229063145.29167-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171229063145.29167-1-richard.henderson@linaro.org> References: <20171229063145.29167-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH 11/38] target/hppa: Implement rfi 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: deller@gmx.de Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 1 + target/hppa/helper.h | 2 ++ target/hppa/op_helper.c | 24 ++++++++++++++++++++++++ target/hppa/translate.c | 31 +++++++++++++++++++++++++++++-- 4 files changed, 56 insertions(+), 2 deletions(-) -- 2.14.3 diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index c92c564a7f..6ec3430ae3 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -178,6 +178,7 @@ struct CPUHPPAState { target_ureg cr[32]; /* control registers */ target_ureg cr_back[2]; /* back of cr17/cr18 */ + target_ureg shadow[7]; /* shadow registers */ /* Those resources are used only in QEMU core */ CPU_COMMON diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 254a4da133..79d22ae486 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -78,5 +78,7 @@ DEF_HELPER_FLAGS_4(fmpyfadd_d, TCG_CALL_NO_RWG, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(fmpynfadd_d, TCG_CALL_NO_RWG, i64, env, i64, i64, i64) #ifndef CONFIG_USER_ONLY +DEF_HELPER_1(rfi, void, env) +DEF_HELPER_1(rfi_r, void, env) DEF_HELPER_FLAGS_2(swap_system_mask, TCG_CALL_NO_RWG, tr, env, tr) #endif diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 1c3e043cc0..3f5dcbbca0 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -614,4 +614,28 @@ target_ureg HELPER(swap_system_mask)(CPUHPPAState *env, target_ureg nsm) env->psw = (psw & ~PSW_SM) | (nsm & PSW_SM); return psw & PSW_SM; } + +void HELPER(rfi)(CPUHPPAState *env) +{ + /* ??? On second reading this condition simply seems + to be undefined rather than a diagnosed trap. */ + if (env->psw & (PSW_I | PSW_R | PSW_Q)) { + helper_excp(env, EXCP_ILL); + } + env->iaoq_f = env->cr[CR_IIAOQ]; + env->iaoq_b = env->cr_back[1]; + cpu_hppa_put_psw(env, env->cr[CR_IPSW]); +} + +void HELPER(rfi_r)(CPUHPPAState *env) +{ + env->gr[1] = env->shadow[0]; + env->gr[8] = env->shadow[1]; + env->gr[9] = env->shadow[2]; + env->gr[16] = env->shadow[3]; + env->gr[17] = env->shadow[4]; + env->gr[24] = env->shadow[5]; + env->gr[25] = env->shadow[6]; + helper_rfi(env); +} #endif diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 2a61b6bc8d..8078d3cd46 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -652,6 +652,11 @@ static DisasJumpType nullify_end(DisasContext *ctx, DisasJumpType status) { TCGLabel *null_lab = ctx->null_lab; + /* For NEXT, NORETURN, STALE, we can easily continue (or exit). + For UPDATED, we cannot update on the nullified path. */ + assert(status != DISAS_IAQ_N_UPDATED && + status != DISAS_IAQ_N_UPDATED_EXIT); + if (likely(null_lab == NULL)) { /* The current insn wasn't conditional or handled the condition applied to it without a branch, so the (new) setting of @@ -673,8 +678,6 @@ static DisasJumpType nullify_end(DisasContext *ctx, DisasJumpType status) gen_set_label(null_lab); ctx->null_cond = cond_make_n(); } - - assert(status != DISAS_NORETURN && status != DISAS_IAQ_N_UPDATED); if (status == DISAS_NORETURN) { status = DISAS_NEXT; } @@ -2143,6 +2146,29 @@ static DisasJumpType trans_mtsm(DisasContext *ctx, uint32_t insn, /* Exit the TB to recognize new interrupts. */ return nullify_end(ctx, DISAS_IAQ_N_STALE_EXIT); } + +static DisasJumpType trans_rfi(DisasContext *ctx, uint32_t insn, + const DisasInsn *di) +{ + unsigned comp = extract32(insn, 5, 4); + + CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); + nullify_over(ctx); + + if (comp == 5) { + gen_helper_rfi_r(cpu_env); + } else { + gen_helper_rfi(cpu_env); + } + if (ctx->base.singlestep_enabled) { + gen_excp_1(EXCP_DEBUG); + } else { + tcg_gen_exit_tb(0); + } + + /* Exit the TB to recognize new interrupts. */ + return nullify_end(ctx, DISAS_NORETURN); +} #endif /* !CONFIG_USER_ONLY */ static const DisasInsn table_system[] = { @@ -2159,6 +2185,7 @@ static const DisasInsn table_system[] = { { 0x00000e60u, 0xfc00ffe0u, trans_rsm }, { 0x00000d60u, 0xfc00ffe0u, trans_ssm }, { 0x00001860u, 0xffe0ffffu, trans_mtsm }, + { 0x00000c00u, 0xfffffe1fu, trans_rfi }, #endif };