From: Laurent Desnogues <laurent.desnogues@gmail.com>
To: Riku Voipio <riku.voipio@iki.fi>
Cc: Riku Voipio <riku.voipio@nokia.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/4] target-arm: refactor cp15.c13 register access
Date: Wed, 27 Jan 2010 14:55:35 +0100 [thread overview]
Message-ID: <761ea48b1001270555p2d2e5adwd97ef3624f74e8df@mail.gmail.com> (raw)
In-Reply-To: <1264596565-8907-5-git-send-email-riku.voipio@iki.fi>
On Wed, Jan 27, 2010 at 1:49 PM, Riku Voipio <riku.voipio@iki.fi> wrote:
> From: Riku Voipio <riku.voipio@nokia.com>
>
> Access the cp15.c13 TLS registers directly with TCG ops instead of with
> a slow helper. If the the cp15 read/write was not TLS register access,
> fall back to the cp15 helper.
>
> This makes accessing __thread variables in linux-user when apps are compiled
> with -mtp=cp15 possible. legal cp15 register to acces from linux-user are
> already checked in cp15_user_ok.
>
> While at it, make the cp15.c13 Thread ID registers available only on
> ARMv6K and newer.
>
> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Acked-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Laurent
> ---
> target-arm/helper.c | 16 --------------
> target-arm/translate.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 55 insertions(+), 16 deletions(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index b3aec99..27001e8 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -511,7 +511,6 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
> uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
> {
> cpu_abort(env, "cp15 insn %08x\n", insn);
> - return 0;
> }
>
> /* These should probably raise undefined insn exceptions. */
> @@ -1491,15 +1490,6 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
> tlb_flush(env, 0);
> env->cp15.c13_context = val;
> break;
> - case 2:
> - env->cp15.c13_tls1 = val;
> - break;
> - case 3:
> - env->cp15.c13_tls2 = val;
> - break;
> - case 4:
> - env->cp15.c13_tls3 = val;
> - break;
> default:
> goto bad_reg;
> }
> @@ -1779,12 +1769,6 @@ uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
> return env->cp15.c13_fcse;
> case 1:
> return env->cp15.c13_context;
> - case 2:
> - return env->cp15.c13_tls1;
> - case 3:
> - return env->cp15.c13_tls2;
> - case 4:
> - return env->cp15.c13_tls3;
> default:
> goto bad_reg;
> }
> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index 5cf3e06..786c329 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -2455,6 +2455,57 @@ static int cp15_user_ok(uint32_t insn)
> return 0;
> }
>
> +static int cp15_tls_load_store(CPUState *env, DisasContext *s, uint32_t insn, uint32_t rd)
> +{
> + TCGv tmp;
> + int cpn = (insn >> 16) & 0xf;
> + int cpm = insn & 0xf;
> + int op = ((insn >> 5) & 7) | ((insn >> 18) & 0x38);
> +
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + return 0;
> +
> + if (!(cpn == 13 && cpm == 0))
> + return 0;
> +
> + if (insn & ARM_CP_RW_BIT) {
> + tmp = new_tmp();
> + switch (op) {
> + case 2:
> + tcg_gen_ld_i32(tmp, cpu_env, offsetof(CPUARMState, cp15.c13_tls1));
> + break;
> + case 3:
> + tcg_gen_ld_i32(tmp, cpu_env, offsetof(CPUARMState, cp15.c13_tls2));
> + break;
> + case 4:
> + tcg_gen_ld_i32(tmp, cpu_env, offsetof(CPUARMState, cp15.c13_tls3));
> + break;
> + default:
> + dead_tmp(tmp);
> + return 0;
> + }
> + store_reg(s, rd, tmp);
> +
> + } else {
> + tmp = load_reg(s, rd);
> + switch (op) {
> + case 2:
> + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUARMState, cp15.c13_tls1));
> + break;
> + case 3:
> + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUARMState, cp15.c13_tls2));
> + break;
> + case 4:
> + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUARMState, cp15.c13_tls3));
> + break;
> + default:
> + return 0;
> + }
> + dead_tmp(tmp);
> + }
> + return 1;
> +}
> +
> /* Disassemble system coprocessor (cp15) instruction. Return nonzero if
> instruction is not defined. */
> static int disas_cp15_insn(CPUState *env, DisasContext *s, uint32_t insn)
> @@ -2489,6 +2540,10 @@ static int disas_cp15_insn(CPUState *env, DisasContext *s, uint32_t insn)
> return 0;
> }
> rd = (insn >> 12) & 0xf;
> +
> + if (cp15_tls_load_store(env, s, insn, rd))
> + return 0;
> +
> tmp2 = tcg_const_i32(insn);
> if (insn & ARM_CP_RW_BIT) {
> tmp = new_tmp();
> --
> 1.6.5
>
>
>
>
prev parent reply other threads:[~2010-01-27 13:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-27 12:49 [Qemu-devel] [PATCH 0/4] linux-user-for-upstream patches Riku Voipio
2010-01-27 12:49 ` [Qemu-devel] [PATCH 1/4] linux-user: adapt uname machine to emulated CPU Riku Voipio
2010-01-27 12:49 ` [Qemu-devel] [PATCH 2/4] fix locking error with current_tb Riku Voipio
2010-01-27 12:49 ` [Qemu-devel] [PATCH 3/4] linux-user: remove signal handler before calling abort() Riku Voipio
2010-01-27 12:49 ` [Qemu-devel] [PATCH 4/4] target-arm: refactor cp15.c13 register access Riku Voipio
2010-01-27 13:55 ` Laurent Desnogues [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=761ea48b1001270555p2d2e5adwd97ef3624f74e8df@mail.gmail.com \
--to=laurent.desnogues@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=riku.voipio@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).