[PATCH 1/1] ARM : missing corrupted reg in __do_div_asm

Dave Martin Dave.Martin at arm.com
Thu Mar 31 03:30:24 PDT 2016


On Thu, Mar 31, 2016 at 07:56:05AM +0000, 陈刚(Gangchen) wrote:
> On 03/30/2016 10:07 PM, Dave Martin wrote:
> > On Wed, Mar 30, 2016 at 03:27:01AM +0000, 陈刚(Gangchen) wrote:
> >> On 03/29/2016 06:56 PM, Dave Martin wrote:

[...]

> >>> I wonder whether the following would be cleaner than having these
> >>> aliased arguments:
> >>>
> >>> 	asm(	/* ... */
> >>> 		"bl	__do_div64"
> >>> 		: "+r" (__n), "=r" (__res)
> >>> 		: "r" (__base)
> >>> 		: "ip", "lr", "cc");
> >>> 	*n = __res;
> >>> 	return __n >> 32;
> >>>
> >>> (providing that GCC doesn't make a mess of the "easy" shift).
> >> I tried your proposal. It didn't make any difference: this is inline
> >> function and gcc just ignores your trick.
> > What doesn't work for you when using this method?
> >
> > Why does the fact that this is an inline function make a difference?
> With the help of other colleagues, I understand your proposal now.
> I create a patch and I can verify that it works!

Ah, OK.  I was wondering whether I made a mistake somewhere.

> Should I submit it, as it seems better than this one I sent?

It's up to you -- I think my approach is a bit cleaner, but your
approach worked too and is not vulnerable to compilers that generate
silly code for (uint64_t) >> 32.

Note that I only tested my code for little endian -- it should do the
right thing for BE, but I recommend that you try it and examine the
generated code, to make sure.

Cheers
---Date



More information about the linux-arm-kernel mailing list