From patchwork Sun Jan 28 23:14:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126101 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp1979533ljd; Sun, 28 Jan 2018 15:26:56 -0800 (PST) X-Google-Smtp-Source: AH8x224l3RAXbAYCWd+Q6xjj0ZIl/JdgLmMCp3BV6SI0kp1yDStXMQyWj5AtU1DBW5c4B5jz1Xrb X-Received: by 10.37.37.134 with SMTP id l128mr8088214ybl.242.1517182016421; Sun, 28 Jan 2018 15:26:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517182016; cv=none; d=google.com; s=arc-20160816; b=km+KHwp05QVotxu+xm2/sA/ZWmZXoNSzpD4wNtpSLxecpda0OAoLABSGwddB5afzfV 2NdpI1iXZ018Gnq3/Xv3UOJoFZF7WFjuDWR2sEFiSBZbHfdNAKVKxyGAXNFaKuDr4QIm tJkpTm/54yJpSelVtu6tDjlNTKZUkQtaZytArJb/xJRrEzxxGWhItnAuKoSBwP7clM/y I+h0XBVE8OF04fj9KLSxMXH/V57BYh6CpNHNmxQZiv1DEfmHVpWiYeMyB7QtdZXNMn4+ /eYmH6gU/4wdWxrCL4vZnUD8qWQZKv7w5U1bMoNI3b+NJRBIJ7cLwsaVNLLP21lf3yrM IpCg== 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=UVTXsMpj8MjhA/KEjiH09wCBIqU3Reoa5kq2A7q67Y8=; b=WaLxGz0XKWfAs5IoEilZehYHGm2zM8NvIeOU07h/mRjqrkZKrtaQ0y1wyGm01cWUxO 44QxOkYVEPb4n5yAqLH8K+GZ7DGo9wJOonT+bLibnb1bgMDrK97cjDGLZWHIbcHMCnMf hoNLVlLyeZHxMCLJansQuZnhN6YaAeK37ymneQO3BRycjAQrs4w7yZ2mGx+apRATEH4h aemhdsUZ56k3hXDCzgPOnVvqhx4V0PyN9nimwA6p/kuoEC4mXAB4cKLsIjA8Zy6VlZn0 Mho6TM0lNKcp+nuIntIfE0zWMgzhsOJUqe1lKL7AwwpirM/13f3R0AtqmPoJxEhEQOep dFFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bBPN0+z0; 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 w126si1809597ywg.410.2018.01.28.15.26.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 28 Jan 2018 15:26:56 -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=bBPN0+z0; 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]:44975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwLf-0002AY-Qr for patch@linaro.org; Sun, 28 Jan 2018 18:26:55 -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) 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-Received: by 10.98.135.76 with SMTP id i73mr24719290pfe.183.1517181349398; Sun, 28 Jan 2018 15:15:49 -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) 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+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 | 30 ++++++++++++++++++++++++++++-- 4 files changed, 55 insertions(+), 2 deletions(-) -- 2.14.3 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 { 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 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 = (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 8ca58f3df3..df0bb04907 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -655,6 +655,10 @@ 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); + 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 @@ -676,8 +680,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; } @@ -2153,6 +2155,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[] = { @@ -2169,6 +2194,7 @@ static const DisasInsn table_system[] = { { 0x00000e60u, 0xfc00ffe0u, trans_rsm }, { 0x00000d60u, 0xfc00ffe0u, trans_ssm }, { 0x00001860u, 0xffe0ffffu, trans_mtsm }, + { 0x00000c00u, 0xfffffe1fu, trans_rfi }, #endif };