lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 22 Apr 2009 23:15:01 +0200
From:	Andi Kleen <andi@...stfloor.org>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Andi Kleen <andi@...stfloor.org>, Ingo Molnar <mingo@...e.hu>,
	Jeff Garzik <jeff@...zik.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org
Subject: Re: [PATCH] X86-32: Let gcc decide whether to inline memcpy was Re: New x86 warning

On Wed, Apr 22, 2009 at 01:56:54PM -0700, Linus Torvalds wrote:
> 
> 
> On Wed, 22 Apr 2009, Andi Kleen wrote:
> > 
> > Modern gcc (and that is all that is supported now) should be able to
> > generate this code on its own already.  So if you call __builtin_* it
> > will  just work (that is what 64bit does) without that explicit code.
> 
> Last time we tried that, it wasn't true. Gcc wouldn't inline even trivial 
> cases of constant sizes.

AFAIK it's all true on 3.2+ when it can figure out the alignment
(but some gcc versions had problems passing the alignment around e.g.
through inlining), under the assumption that out of line can do
a better job with unaligned data. That's not true with my patch,
but could be true in theory.

Quick test here:

char a[10];
char b[2];
char c[4];
char d[8];

short x;
long y;

char xyz[100];


f()
{
#define C(x) memcpy(&x, xyz, sizeof(x));
        C(x)
        C(y)
        C(a)
        C(b)
        C(c)
        C(d)
}

and everything gets inlined with gcc 3.2 which is the oldest
we still care about:

gcc version 3.2.3

        movzwl  xyz+8(%rip), %eax
        movzwl  xyz(%rip), %ecx
        movq    xyz(%rip), %rdx
        movw    %ax, a+8(%rip)
        movw    %cx, x(%rip)
        movw    %cx, b(%rip)
        movl    xyz(%rip), %eax
        movq    %rdx, y(%rip)
        movq    %rdx, a(%rip)
        movq    %rdx, d(%rip)
        movl    %eax, c(%rip)
        ret

-Andi
-- 
ak@...ux.intel.com -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ