qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@codesourcery.com>
To: "Andreas Färber" <andreas.faerber@web.de>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 0/4] tcg: Add debug facilities for TCGv
Date: Mon, 12 Dec 2011 15:58:44 +0000	[thread overview]
Message-ID: <201112121558.44919.paul@codesourcery.com> (raw)
In-Reply-To: <4EE5D9E9.3080700@web.de>

> > Trying to make a 32-bit target "64-bit safe" without actually
> > implementing the 64-bit target is a complete waste of time.
> 
> That's where we disagree. I rather do things right from the start than
> leaving the cleanup work to someone else later on.
>
> > You've almost no chance of getting
> > it right.  In some cases the correct answer will be to use 32-bit
> > arithmetic, then sign/zero extend the result. In other cases the correct
> > answer will be to perform word size arithmetic.  Blindly picking one
> > just makes the bugs harder to find later.
> 
> This series picks nothing blindly. 

Sure it does - or at least it will when you get to ARM and m68k[1].  The whole 
point of your patch is to force developers to pick between an address sized 
value and a 32-bit value.  On a 32-bit target these are the same thing.  Not 
only are they the same thing, but most of the time the architecture doesn't 
even have the concept that they may be different.

Only when you introduce a variant with 64-bit addresses does the distinction 
become meaningful.  At that point they're actually different, and are 
trivially detected by the existing checks.

Ther are three ways to resolve a mismatch:
- Change everything to TCGv_i32.
- Change everything to TCGv.
- Add an explicit extension/truncation (compiles to no-op on 32-bit targets).

There's no way of the developer of a 32-bit architecture to know which of 
these a [hypothetical future] 64-bit architecture will require.  The fact they 
you've been forced to pick one (rather then leave the mismatch for the 64-bit 
porter to resolve) actually makes bugs harder to find.

> For me the most annoying issue was that tcg_gen_qemu_{ld,st}* needs TCGv.

You mean the value transferred is always TCGv sized, so ld32u requires an 
additional truncation before doing 32-bit arithmetic?  Fixing that is 
completely independent of making TCGv a separate type.

The whole point of TCGv is that it's an address sized value, so is the only 
real option for the address.  Constructing an address for a different sized 
value requires a target specific sign/szero extension or truncation/overflow 
check.

> > If you're trying to add support for targets where the primary word size
> > is neither 32 nor 64 then that's a completely different problem, and
> > probably not one that's worth solving.  In practice your port is going
> > to end up using 64- bit arithmetic and explicitly compensating for the
> > excess precision where necessary.
> 
> That's a different issue and not being addressed here.

Good.
 
> My point was that I have an inheritance hierarchy where (as opposed to,
> e.g., ppc and ppc64) both end up as TARGET_LONG_BITS==32, so I do not
> get a check for free by compiling both, and I do not want to introduce
> an artificial TARGET_LONG_BITS==64 architecture just to check that my
> tl==i32 target code is free of typos.

Huh? Now I'm completely confused.  If all your targets have T_L_B==32 how can 
mixing TCGv and TCGV_i32 be wrong? How do you know which of the 3 alternatives 
above is the right answer?

> Same issue if you pick only --target-list=<some>-softmmu BTW.

If you're only building a small subset of targets then clearly you won't see 
errors in the targets you omitted.  The only sane answer is to make sure you 
build (and preferably test) all the targets you have effected.

This is the same reason I object to code that is disabled by default.  If it 
isn't at least being built by the majority of developers (or at least any 
working in related areas) then it's going to bitrot rapidly, and probably 
won't work when someone does decide to turn it on.

> Just like with softfloat [u]int16 etc. types it's just too easy to
> forget _t somewhere (here: _i32) and to end up with a type you don't want.

I don't see how that is relevant.  TCGv (aka target_ulong) is a synonym for 
either TCGv_i32 (uint32_t) or TCGv_i64 (uint64_t).  If this is not true then 
we're completely screwed.

> If you have a better proposal how to introduce the checks I want, please
> let us hear it.

I still don't understand how your additional restructions are ever useful.
Please give an example of an actual error your checks will catch.

Paul

[1] m68k may never have a 64-bit variant, but ARM is a good example of a qemu 
target that is currently 32-bit but will grow a 64-bit variant in the not too 
distant future.

  reply	other threads:[~2011-12-12 15:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-10  9:02 [Qemu-devel] [PATCH 0/4] tcg: Add debug facilities for TCGv Andreas Färber
2011-12-10  9:02 ` [Qemu-devel] [PATCH 1/4] tcg: Introduce {MAKE,GET}_TCGV_TL macros Andreas Färber
2011-12-10  9:02 ` [Qemu-devel] [PATCH 2/4] tcg: Convert *_tl*() macros to inline functions Andreas Färber
2011-12-10 21:06   ` [Qemu-devel] [PATCH v2] " Andreas Färber
2011-12-10  9:02 ` [Qemu-devel] [PATCH 3/4] tcg: Update TCGV_{UNUSED,EQUAL}() macros Andreas Färber
2011-12-10  9:02 ` [Qemu-devel] [PATCH 4/4] tcg: Allow to detect TCGv misuses Andreas Färber
2011-12-10 10:07 ` [Qemu-devel] [PATCH 0/4] tcg: Add debug facilities for TCGv Peter Maydell
2011-12-10 11:14   ` Andreas Färber
2011-12-11 23:28     ` Paul Brook
2011-12-12 10:39       ` Andreas Färber
2011-12-12 15:58         ` Paul Brook [this message]
2011-12-13 12:43           ` Andreas Färber
2011-12-13 16:26             ` Paul Brook
2011-12-14 11:41               ` Andreas Färber
2011-12-13 13:11           ` Andreas Färber
2011-12-13 16:23             ` Paul Brook

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=201112121558.44919.paul@codesourcery.com \
    --to=paul@codesourcery.com \
    --cc=andreas.faerber@web.de \
    --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 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).