All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Igor Kovalenko <igor.v.kovalenko@gmail.com>
Cc: Laurent Desnogues <laurent.desnogues@gmail.com>,
	Blue Swirl <blauwirbel@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Artyom Tarasenko <atar4qemu@gmail.com>,
	peter.maydell@linaro.org
Subject: Re: [Qemu-devel] tcg/tcg.c:1892: tcg fatal error
Date: Mon, 25 Apr 2011 22:29:27 +0200	[thread overview]
Message-ID: <20110425202927.GD21831@volta.aurel32.net> (raw)
In-Reply-To: <BANLkTi=S0DyudwSBz_tQC==L=BUS2E=vcg@mail.gmail.com>

On Fri, Apr 22, 2011 at 06:14:06PM +0400, Igor Kovalenko wrote:
> On Fri, Apr 22, 2011 at 2:39 AM, Laurent Desnogues
> <laurent.desnogues@gmail.com> wrote:
> > On Thu, Apr 21, 2011 at 9:45 PM, Igor Kovalenko
> > <igor.v.kovalenko@gmail.com> wrote:
> >> On Thu, Apr 21, 2011 at 7:44 PM, Laurent Desnogues
> >> <laurent.desnogues@gmail.com> wrote:
> >>> On Thu, Apr 21, 2011 at 4:57 PM, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
> >>>> On Tue, Apr 12, 2011 at 4:14 AM, Igor Kovalenko
> >>>> <igor.v.kovalenko@gmail.com> wrote:
> >>>>>>> Do you have public test case?
> >>>>>>> It is possible to code this delay slot write test but real issue may
> >>>>>>> be corruption elsewhere.
> >>>>
> >>>> The test case is trivial: it's just the two instructions, branch and wrpr.
> >>>>
> >>>>> In theory there could be multiple issues including compiler induced ones.
> >>>>> I'd prefer to see some kind of reproducible testcase.
> >>>>
> >>>> Ok, attached a 40 byte long test (the first 32 bytes are not used and
> >>>> needed only because the bios entry point is 0x20).
> >>>>
> >>>> $ git pull && make && sparc64-softmmu/qemu-system-sparc64 -bios
> >>>> test-wrpr.bin -nographic
> >>>> Already up-to-date.
> >>>> make[1]: Nothing to be done for `all'.
> >>>> /mnt/terra/projects/vanilla/qemu/tcg/tcg.c:1892: tcg fatal error
> >>>> Aborted
> >>>
> >>> The problem seems to be that wrpr is using a non-local
> >>> TCG tmp (cpu_tmp0).
> >>
> >> Just tried the test case with write to %pil - seems like write itself is OK.
> >> The issue appears to be with save_state() call since adding save_state
> >> to %pil case provokes the same tcg abort.
> >
> > The problem is that cpu_tmp0, not being a local tmp, doesn't
> > need to be saved across helper calls.  This results in the
> > TCG "optimizer" getting rid of it even though it's later used.
> > Look at the log and you'll see what I mean :-)
> 
> I'm not very comfortable with tcg yet. Would it be possible to teach
> optimizer working with delay slots? Or do I look in the wrong place.
> 

The problem is not on the TCG side, but on the target-sparc/translate.c
side:

|                    case 0x32: /* wrwim, V9 wrpr */
|                         {
|                             if (!supervisor(dc))
|                                 goto priv_insn;
|                             tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
| #ifdef TARGET_SPARC64

Here cpu_tmp0 is loaded. cpu_tmp0 is a TCG temp, which means it is not
saved across TCG branches.

[...]

|                             case 6: // pstate
|                                 save_state(dc, cpu_cond);
|                                 gen_helper_wrpstate(cpu_tmp0);
|                                 dc->npc = DYNAMIC_PC;
|                                 break;

save_state() calls save_npc(), which in turns might call 
gen_generic_branch():

| static inline void gen_generic_branch(target_ulong npc1, target_ulong npc2,
|                                       TCGv r_cond)
| {
|     int l1, l2;
|
|     l1 = gen_new_label();
|     l2 = gen_new_label();
|
|     tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
|     tcg_gen_movi_tl(cpu_npc, npc1);
|     tcg_gen_br(l2);
| 
|     gen_set_label(l1);
|     tcg_gen_movi_tl(cpu_npc, npc2);
|     gen_set_label(l2);
| }

And here is the TCG branch, which drop the TCG temp cpu_temp0.

The solution is either to rewrite gen_generic_branch() without TCG
branches, or to use a TCG temp local instead of a TCG temp.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2011-04-25 21:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10 12:29 [Qemu-devel] tcg/tcg.c:1892: tcg fatal error Artyom Tarasenko
2011-04-10 13:24 ` Aurelien Jarno
2011-04-10 14:09   ` Artyom Tarasenko
2011-04-10 14:44     ` Blue Swirl
2011-04-10 17:48       ` Artyom Tarasenko
2011-04-10 17:57         ` Blue Swirl
2011-04-10 18:35           ` Artyom Tarasenko
2011-04-10 18:52             ` Igor Kovalenko
2011-04-10 19:37               ` Artyom Tarasenko
     [not found]                 ` <BANLkTik2NChYi8hADjCSbjdZeyP_oo8_Qg@mail.gmail.com>
2011-04-10 20:00                   ` Artyom Tarasenko
2011-04-11  3:16                     ` Igor Kovalenko
2011-04-11 17:53                       ` Artyom Tarasenko
2011-04-12  2:14                         ` Igor Kovalenko
2011-04-21 14:57                           ` Artyom Tarasenko
2011-04-21 15:44                             ` Laurent Desnogues
2011-04-21 19:45                               ` Igor Kovalenko
2011-04-21 22:39                                 ` Laurent Desnogues
2011-04-22 14:14                                   ` Igor Kovalenko
2011-04-25 20:29                                     ` Aurelien Jarno [this message]
2011-04-26  3:34                                       ` Igor Kovalenko
2011-04-26 16:26                                         ` Artyom Tarasenko
2011-04-26 18:07                                           ` Igor Kovalenko
2011-04-26 17:02                                       ` Artyom Tarasenko
2011-04-26 18:36                                         ` Blue Swirl
2011-04-26 19:07                                           ` Igor Kovalenko
2011-04-26 20:07                                             ` Blue Swirl
2011-04-26 21:35                                               ` Igor Kovalenko
2011-04-27 17:40                                                 ` Blue Swirl
2011-04-27 16:29                                           ` Artyom Tarasenko
2011-04-27 17:41                                             ` Blue Swirl
2011-04-10 14:59     ` Peter Maydell
2011-04-10 17:31       ` Artyom Tarasenko

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=20110425202927.GD21831@volta.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=atar4qemu@gmail.com \
    --cc=blauwirbel@gmail.com \
    --cc=igor.v.kovalenko@gmail.com \
    --cc=laurent.desnogues@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.