From patchwork Mon Jan 22 03:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125304 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp946752ljf; Sun, 21 Jan 2018 19:56:01 -0800 (PST) X-Google-Smtp-Source: AH8x227WP31iWnfqFG9afpvCs4ZKbxuhHaSs4ORem3MPCC7aoqS04+yS9Fpg97/YnQWRb4aKXm5P X-Received: by 10.37.25.136 with SMTP id 130mr6112756ybz.414.1516593361554; Sun, 21 Jan 2018 19:56:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516593361; cv=none; d=google.com; s=arc-20160816; b=ZdzmSPh6jd4B5d+XmGV7D/RwzaF9YLcZEIdEb/H9zfABrsHMjTpeukaRfQf5M6HuRs Py2G+9UofgZlCq0XIOZr2o4yWKusheBz2+qfpc7rUogg4gNSPl3b3qI+PjuFqenP65mq 88e/nThNIGAqeej+EnuzX/vyC1hMbkHM/bvDgsxjFcaawUr/8Mi7tvltKtH4KcMvSyXE /qlVx9/vmn1e7EGmphvbDwZBlkSjPtjG/DN+Q7QNGs4Wr7F7KOZnAGPZ/YljfI1MgWlk BYJLsz4B+5syReGg70d4lZOHfbDfYvmm8RHUZfWey8SqjJOXbqVrkDpmeaGwj+wSqooX rLDA== 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=4v9sEiBGAG4Ztqc7pZb7dChRVtEW7591nKjhbkJ+XWE=; b=cSZfutd+tv5kiM6rIIsMA1APVWyYm2b92/fiQwQ6ItV8ezKmqXEs7A5huRlYFtwKSB kl9NKPg166GUTECm+dmXYf/y/bB1hlzsl6KPHS/kpx8S3U0kIT8nzr1q/QS/+UZrlLeY 0IuWkh4SLrVmHWWR5jWOA3btN7gQ1XQ96+pf3lCUP4qR8oQQKDsVBMLqa8/pzYKmnxWD c6NHSuCYDX3qAPb2/thySgE9y3Zc0l/5P9jzMcnczwRsoluzwdA6pRI2XE38hG/TsuDs TF3gxDIElB2PHqPK2RBXCppF9h/h4/FL0qCeVJHbjS5P4uR0sBiNVfAn6Z/YQH8JkM/O 3J5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d8mvsfRq; 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 w3si1412601ywj.540.2018.01.21.19.56.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 21 Jan 2018 19:56:01 -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=d8mvsfRq; 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]:41698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edTDE-0005vD-Q8 for patch@linaro.org; Sun, 21 Jan 2018 22:56:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edT0I-0005OO-HW for qemu-devel@nongnu.org; Sun, 21 Jan 2018 22:42:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edT0H-0006DK-Bj for qemu-devel@nongnu.org; Sun, 21 Jan 2018 22:42:38 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:46297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edT0H-0006Bn-4T for qemu-devel@nongnu.org; Sun, 21 Jan 2018 22:42:37 -0500 Received: by mail-pg0-x243.google.com with SMTP id s9so6073757pgq.13 for ; Sun, 21 Jan 2018 19:42:36 -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=4v9sEiBGAG4Ztqc7pZb7dChRVtEW7591nKjhbkJ+XWE=; b=d8mvsfRqkDAMiHALBJhCZnSCf1Z2m0oC6KCIFJKIo3eVKKRig11fpY5EkX7+wUepKd WMG9sAcXcD4GYWEJ90CojjZ8Ght2UsZqERGN1Rhco23StPVn9oyqNVDoMY8m1qKHtUst Da0P/qp+896WFbyiufaa6/P8eOH4vtxjSjIEQ= 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=4v9sEiBGAG4Ztqc7pZb7dChRVtEW7591nKjhbkJ+XWE=; b=eMno91bUI+8oe2KD+/NbsEhiYu6pc3ZAwg+xE2mCu0872RVaMjSkz/ZBAY+0kX4pci vfeGwHFhNrMIIGBh+PI/HgTHgDDjZK4QQlkgZfYr4+qfG02DBrsUQf4aT+nbOYYYw3Gp b2Xl/pXg8Y+zpOmXzU/3WyqwARol3fJb6vMTqkJYzmenaqiA6p7rWFsYMyt8fYPynv92 INgT/Y5MYZ1+9znljYlDs8RurH57Q89/oeVJlKxkLCfkbBQvWrbhBOpgPPI87BNgppBj Q94jqrZDKNivdVAQbdovdXmeRHFpptJTybRjmkpqAnV7RGPq2CVWkuACKvmZjNN7cGIX 4vgg== X-Gm-Message-State: AKwxytfXLVP15AGJJzNwKr2KvgEr5tnhP5XDqMbOgimLROFzHkLJ3XFl YFGXyOali2v2SUnllwjzjFFaGNDd3wc= X-Received: by 2002:a17:902:20e8:: with SMTP id v37-v6mr2702095plg.66.1516592555805; Sun, 21 Jan 2018 19:42:35 -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 z125sm182023pfz.27.2018.01.21.19.42.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Jan 2018 19:42:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 21 Jan 2018 19:41:45 -0800 Message-Id: <20180122034217.19593-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180122034217.19593-1-richard.henderson@linaro.org> References: <20180122034217.19593-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::243 Subject: [Qemu-devel] [PULL 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 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 b201e5ace2..89c22a4c3e 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -651,6 +651,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 @@ -672,8 +676,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; } @@ -2142,6 +2144,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[] = { @@ -2158,6 +2183,7 @@ static const DisasInsn table_system[] = { { 0x00000e60u, 0xfc00ffe0u, trans_rsm }, { 0x00000d60u, 0xfc00ffe0u, trans_ssm }, { 0x00001860u, 0xffe0ffffu, trans_mtsm }, + { 0x00000c00u, 0xfffffe1fu, trans_rfi }, #endif };