From nobody Tue Feb 10 23:58:49 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; dkim=fail; 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 1517182118568247.32127987580964; Sun, 28 Jan 2018 15:28:38 -0800 (PST) Received: from localhost ([::1]:44980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwNJ-0003Pg-JB for importer@patchew.org; Sun, 28 Jan 2018 18:28:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwAy-0002es-0O for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:15:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efwAw-0008K8-Sf for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:15:51 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:34654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efwAw-0008JP-ND for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:15:50 -0500 Received: by mail-pg0-x244.google.com with SMTP id r19so3014005pgn.1 for ; Sun, 28 Jan 2018 15:15:50 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id r27sm26949344pfj.75.2018.01.28.15.15.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jan 2018 15:15:48 -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=UVTXsMpj8MjhA/KEjiH09wCBIqU3Reoa5kq2A7q67Y8=; b=bBPN0+z01pkkxLfkwoG0a26GxQ8OAYh629akkHk7QB5DhsdcWtXWO9m0nH+gNKF+au 10XSVf+XcB7AaO9cdjPA5yhKgtSJYJzLxRGJiaibuDEF41b3CLSVZNoSEzJ622bFPoFh oxdec72e1MhzN/c8uMGUu6xR0lk4bqUIQrJu8= 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=UVTXsMpj8MjhA/KEjiH09wCBIqU3Reoa5kq2A7q67Y8=; b=BPHQ91mS3mD4CY+Xkmc/fyx5rlgnJ4kyVxhEHqFOUzpw0IxjofXwS3dR2hdBCJSn4+ qXsQZmxuudGLfJ5os/e+S97J6SMskOsvmJiDNfYTnw4pE3rvJYvmlKvZHXuBUJpZZsN3 8TxD9DDTM3cZNFL7SMP5XJ+lVMaU6PtGicausIng42mQYy5UTldi6RihWGz35dcP+GYN C+K1f4RJvQKpq2TluGZPDhIYu/Lq8qkl5SiRkHMtTk7LHbUlrOHN3SQ3Y/6caTAKI4Uc tfwYuBAgRwcGMbyhjHqJUIBFpCp+KB/VQeTbkZV65J+oa49C/7ZjfYDBncuwyPxHvC0E jTFg== X-Gm-Message-State: AKwxytdi79Q3z6lhB5te10cJSGLcLD4FirG6dHKzq4ESUWigF/dYjc4b fC8BfseCBpdfSV6Ji6ZRAScJRTGMyPE= X-Google-Smtp-Source: AH8x224K/5gUGwtxYj7Op+YK0i8BiVwKaYvSJ5liXglGaXdghi8iBLk79LX+pOTDDszABxVPwHr5oQ== X-Received: by 10.98.135.76 with SMTP id i73mr24719290pfe.183.1517181349398; Sun, 28 Jan 2018 15:15:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 28 Jan 2018 15:14:56 -0800 Message-Id: <20180128231528.22719-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180128231528.22719-1-richard.henderson@linaro.org> References: <20180128231528.22719-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:c05::244 Subject: [Qemu-devel] [PULL v4 11/43] 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 | 30 ++++++++++++++++++++++++++++-- 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 7524cf8aa6..ef36826f54 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -178,6 +178,7 @@ struct CPUHPPAState { =20 target_ureg cr[32]; /* control registers */ target_ureg cr_back[2]; /* back of cr17/cr18 */ + target_ureg shadow[7]; /* shadow registers */ =20 /* 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) =20 #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 1d56ba497b..cf9fe46942 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 =3D (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 =3D env->cr[CR_IIAOQ]; + env->iaoq_b =3D env->cr_back[1]; + cpu_hppa_put_psw(env, env->cr[CR_IPSW]); +} + +void HELPER(rfi_r)(CPUHPPAState *env) +{ + env->gr[1] =3D env->shadow[0]; + env->gr[8] =3D env->shadow[1]; + env->gr[9] =3D env->shadow[2]; + env->gr[16] =3D env->shadow[3]; + env->gr[17] =3D env->shadow[4]; + env->gr[24] =3D env->shadow[5]; + env->gr[25] =3D env->shadow[6]; + helper_rfi(env); +} #endif diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 8ca58f3df3..df0bb04907 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -655,6 +655,10 @@ static DisasJumpType nullify_end(DisasContext *ctx, Di= sasJumpType status) { TCGLabel *null_lab =3D ctx->null_lab; =20 + /* For NEXT, NORETURN, STALE, we can easily continue (or exit). + For UPDATED, we cannot update on the nullified path. */ + assert(status !=3D DISAS_IAQ_N_UPDATED); + if (likely(null_lab =3D=3D NULL)) { /* The current insn wasn't conditional or handled the condition applied to it without a branch, so the (new) setting of @@ -676,8 +680,6 @@ static DisasJumpType nullify_end(DisasContext *ctx, Dis= asJumpType status) gen_set_label(null_lab); ctx->null_cond =3D cond_make_n(); } - - assert(status !=3D DISAS_NORETURN && status !=3D DISAS_IAQ_N_UPDATED); if (status =3D=3D DISAS_NORETURN) { status =3D DISAS_NEXT; } @@ -2153,6 +2155,29 @@ static DisasJumpType trans_mtsm(DisasContext *ctx, u= int32_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 =3D extract32(insn, 5, 4); + + CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); + nullify_over(ctx); + + if (comp =3D=3D 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 */ =20 static const DisasInsn table_system[] =3D { @@ -2169,6 +2194,7 @@ static const DisasInsn table_system[] =3D { { 0x00000e60u, 0xfc00ffe0u, trans_rsm }, { 0x00000d60u, 0xfc00ffe0u, trans_ssm }, { 0x00001860u, 0xffe0ffffu, trans_mtsm }, + { 0x00000c00u, 0xfffffe1fu, trans_rfi }, #endif }; =20 --=20 2.14.3