From: Peter Maydell <peter.maydell@linaro.org>
To: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] arm: basic support for ARMv4/ARMv4T emulation
Date: Tue, 29 Mar 2011 18:56:25 +0100 [thread overview]
Message-ID: <AANLkTimzmxOkkj7WBimyRekbFjhE4eeAa3RLFSFen2b1@mail.gmail.com> (raw)
In-Reply-To: <1301417898-9322-1-git-send-email-dbaryshkov@gmail.com>
On 29 March 2011 17:58, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
Looks good, nearly there I think.
> @@ -7172,10 +7191,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
> }
> if (insn & (1 << 20)) {
> /* Complete the load. */
> - if (rd == 15)
> + if (rd == 15 && ENABLE_ARCH_4T) {
> gen_bx(s, tmp);
> - else
> + } else {
> store_reg(s, rd, tmp);
> + }
> }
> break;
> case 0x08:
Shouldn't this be ENABLE_ARCH_5T ? Loads to PC are only interworking
in v5T and above.
(But see below...)
> @@ -7229,7 +7249,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
> /* load */
> tmp = gen_ld32(addr, IS_USER(s));
> if (i == 15) {
> - gen_bx(s, tmp);
> + if (ENABLE_ARCH_5) {
> + gen_bx(s, tmp);
> + } else {
> + store_reg(s, i, tmp);
> + }
> } else if (user) {
> tmp2 = tcg_const_i32(i);
> gen_helper_set_user_reg(tmp2, tmp);
> @@ -8980,8 +9006,13 @@ static void disas_thumb_insn(CPUState *env, DisasContext *s)
> /* write back the new stack pointer */
> store_reg(s, 13, addr);
> /* set the new PC value */
> - if ((insn & 0x0900) == 0x0900)
> - gen_bx(s, tmp);
> + if ((insn & 0x0900) == 0x0900) {
> + if (ENABLE_ARCH_5) {
> + gen_bx(s, tmp);
> + } else {
> + store_reg(s, 15, tmp);
> + }
> + }
> break;
>
> case 1: case 3: case 9: case 11: /* czb */
These two are right, but I think we should have a utility function
(put it next to store_reg_bx()):
/* Variant of store_reg which uses branch&exchange logic when storing
* to r15 in ARM architecture v5T and above. This is used for storing
* the results of a LDR/LDM/POP into r15, and corresponds to the cases
* in the ARM ARM which use the LoadWritePC() pseudocode function.
*/
static inline void store_reg_from_load(CPUState *env, DisasContext *s,
int reg, TCGv var)
{
if (reg == 15 && ENABLE_ARCH_5TE) {
gen_bx(s, var);
} else {
store_reg(s, reg, var);
}
}
Then you can use this in the three code hunks above. (You'll want
to tweak the middle one, you can move it to
if (user) {
...
} else if (i == rn) {
...
} else {
store_reg_from_load(env, s, i, tmp);
}
because if i==15 then user must be false, and if rn == 15 this
is UNPREDICTABLE anyway.)
These comments from last round still hold for this patch:
The CPSR Q bit needs to RAZ/WI on v4 and v4T.
For v4 you need to make sure that the core can't get into
thumb mode at all. So feature guards in gen_bx_imm() and
gen_bx(), make sure PSR masks prevent the T bit getting set,
and check helper.c for anything that sets env->thumb from
somewhere else...
-- PMM
next prev parent reply other threads:[~2011-03-29 17:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-29 16:58 [Qemu-devel] [PATCH 1/3] arm: basic support for ARMv4/ARMv4T emulation Dmitry Eremin-Solenikov
2011-03-29 16:58 ` [Qemu-devel] [PATCH 2/3] Implement basic part of SA-1110/SA-1100 Dmitry Eremin-Solenikov
2011-03-29 16:58 ` [Qemu-devel] [PATCH 3/3] Basic implementation of Sharp Zaurus SL-5500 collie PDA Dmitry Eremin-Solenikov
2011-03-29 17:56 ` Peter Maydell [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-04-04 13:38 [Qemu-devel] [PATCH 0/3] StrongARM/collie support Dmitry Eremin-Solenikov
2011-04-04 13:38 ` [Qemu-devel] [PATCH 1/3] arm: basic support for ARMv4/ARMv4T emulation Dmitry Eremin-Solenikov
2011-04-06 13:56 ` Peter Maydell
2011-04-06 17:41 ` Dmitry Eremin-Solenikov
2011-04-06 17:50 ` Peter Maydell
2011-04-10 11:25 ` Aurelien Jarno
2011-04-10 12:24 ` Marek Vasut
2011-04-11 15:18 ` Dmitry Eremin-Solenikov
2011-04-04 12:15 Dmitry Eremin-Solenikov
2011-03-30 11:41 Dmitry Eremin-Solenikov
2011-03-30 16:12 ` Peter Maydell
2011-03-30 23:27 ` Dmitry Eremin-Solenikov
2011-04-02 15:25 ` Dmitry Eremin-Solenikov
2011-04-04 11:21 ` Peter Maydell
2011-03-24 22:07 Dmitry Eremin-Solenikov
2011-03-25 15:00 ` Peter Maydell
2011-03-26 17:23 ` Dmitry Eremin-Solenikov
2011-03-26 18:08 ` Peter Maydell
2011-03-26 22:31 ` Dmitry Eremin-Solenikov
2011-03-26 23:41 ` Peter Maydell
2011-03-29 16:47 ` Dmitry Eremin-Solenikov
2011-03-24 10:22 Dmitry Eremin-Solenikov
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=AANLkTimzmxOkkj7WBimyRekbFjhE4eeAa3RLFSFen2b1@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=dbaryshkov@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).