All of lore.kernel.org
 help / color / mirror / Atom feed
* [parisc-linux] misaligned data
@ 2002-12-28  2:01 Grant Grundler
  2002-12-28  2:49 ` John David Anglin
  0 siblings, 1 reply; 5+ messages in thread
From: Grant Grundler @ 2002-12-28  2:01 UTC (permalink / raw)
  To: parisc-linux

Two more tidbits on the misaligned data problem in 2.5.53:
o using -g instead of -O2 compiles just fine

o The generating the warning is the "tv_add" call in sctp_pack_cookie():
	...
        /* Set an expiration time for the cookie.  */
        do_gettimeofday(&cookie->c.expiration);
        tv_add(&asoc->cookie_life, &cookie->c.expiration);
	...

But I'm under the impression the do_gettimeofday() above would puke when
trying to access the same misaligned timeval_t as well. tv_add() catches
the problem since it is a macro and code gets generated to directly
reference the struct instead of an anonymous address.

The asm output is:
...
        ldw 5144(%r8),%r19
        ldw 8(%r6),%r20
        add,l %r20,%r19,%r20
        ldd 5136(%r8),%r21
        ldd 52(%r3),%r19		# line 2347 is misaligned.
        extrd,s %r20,63,32,%r20
        add,l %r19,%r21,%r25
        ldil L'999999,%r19
        cmpb,*>= %r19,%r20,.L1873
	copy %r4,%r27

	ldil L'-1000000,%r19
	ldo 1(%r25),%r25
	ldo R'-1000000(%r19),%r19
	add,l %r20,%r19,%r20
.L1873:
	std %r25,52(%r3)		# also misaligned

Based on the math, looks like %r25 has the "seconds" field and %r19
the microseconds.

Oh, only one definition and usage of tv_add().
The offending field is "&cookie->c.expiration".
cookie is type "sctp_signed_cookie_t". (include/net/sctp/structs.h)

/* The format of our cookie that we send to our peer. */
typedef struct sctp_signed_cookie {
        __u8 signature[SCTP_SECRET_SIZE];
	sctp_cookie_t c;
} sctp_signed_cookie_t;

struct sctp_cookie mostly uses __u32 except for "struct timeval expiration".
"struct timeval" is declared in include/linux/time.h.
Not sure if it's safe to just pad "struct sctp_cookie" or if something
else needs to be done.

If this isn't a parisc toolchain bug, then other arches (eg ia64) will need 
a fix as well.

cheers,
grant

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [parisc-linux] misaligned data
  2002-12-28  2:01 [parisc-linux] misaligned data Grant Grundler
@ 2002-12-28  2:49 ` John David Anglin
  2002-12-30  5:39   ` Grant Grundler
  2002-12-30  7:15   ` Grant Grundler
  0 siblings, 2 replies; 5+ messages in thread
From: John David Anglin @ 2002-12-28  2:49 UTC (permalink / raw)
  To: Grant Grundler; +Cc: parisc-linux

>         ldd 52(%r3),%r19		# line 2347 is misaligned.

> 	std %r25,52(%r3)		# also misaligned
> 
> Based on the math, looks like %r25 has the "seconds" field and %r19
> the microseconds.
> 
> Oh, only one definition and usage of tv_add().
> The offending field is "&cookie->c.expiration".
> cookie is type "sctp_signed_cookie_t". (include/net/sctp/structs.h)
> 
> /* The format of our cookie that we send to our peer. */
> typedef struct sctp_signed_cookie {
>         __u8 signature[SCTP_SECRET_SIZE];
> 	sctp_cookie_t c;
> } sctp_signed_cookie_t;
> 
> struct sctp_cookie mostly uses __u32 except for "struct timeval expiration".
> "struct timeval" is declared in include/linux/time.h.
> Not sure if it's safe to just pad "struct sctp_cookie" or if something
> else needs to be done.

I'd wonder more about the packed attribute on sctp_init_chunk_t and
sctp_inithdr_t.  What version of gcc?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [parisc-linux] misaligned data
  2002-12-28  2:49 ` John David Anglin
@ 2002-12-30  5:39   ` Grant Grundler
  2002-12-30  7:15   ` Grant Grundler
  1 sibling, 0 replies; 5+ messages in thread
From: Grant Grundler @ 2002-12-30  5:39 UTC (permalink / raw)
  To: John David Anglin; +Cc: parisc-linux

On Fri, Dec 27, 2002 at 09:49:18PM -0500, John David Anglin wrote:
> I'd wonder more about the packed attribute on sctp_init_chunk_t and
> sctp_inithdr_t.  What version of gcc?

sorry...I overlooked the attribute.

gcc version 3.0.4

I don't recall if I tried gcc-3.2.

thanks,
grant

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [parisc-linux] misaligned data
  2002-12-28  2:49 ` John David Anglin
  2002-12-30  5:39   ` Grant Grundler
@ 2002-12-30  7:15   ` Grant Grundler
  2002-12-31 21:50     ` John David Anglin
  1 sibling, 1 reply; 5+ messages in thread
From: Grant Grundler @ 2002-12-30  7:15 UTC (permalink / raw)
  To: John David Anglin; +Cc: parisc-linux

On Fri, Dec 27, 2002 at 09:49:18PM -0500, John David Anglin wrote:
...
> > Not sure if it's safe to just pad "struct sctp_cookie" or if something
> > else needs to be done.
> 
> I'd wonder more about the packed attribute on sctp_init_chunk_t and
> sctp_inithdr_t.

I think that's the problem.

I've wimped out and just disabled CONFIG_IP_SCTP.
I really want to chase final problems with 2.4 and get $#@&% XF86
working on the OB600CT again (yes, XF86 4.0 worked, 4.2 does not :^( )


> What version of gcc?

In reflecting on it a bit more, I'm pretty sure I tried gcc-3.2
and came to the same result.
("gcc version 3.2.2 20021212 (Debian prerelease)")

grant

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [parisc-linux] misaligned data
  2002-12-30  7:15   ` Grant Grundler
@ 2002-12-31 21:50     ` John David Anglin
  0 siblings, 0 replies; 5+ messages in thread
From: John David Anglin @ 2002-12-31 21:50 UTC (permalink / raw)
  To: Grant Grundler; +Cc: parisc-linux

> > I'd wonder more about the packed attribute on sctp_init_chunk_t and
> > sctp_inithdr_t.
> 
> I think that's the problem.

I am not aware of any specific code in the backend related to the
handling of packed structures.  So, this is likely a generic problem,
maybe on big endian machines.

> > What version of gcc?
> 
> In reflecting on it a bit more, I'm pretty sure I tried gcc-3.2
> and came to the same result.
> ("gcc version 3.2.2 20021212 (Debian prerelease)")

There are some fixes in the passing of small structs in 3.3 (less
than 8 bytes).  This affects varargs and library functions that
pass small structs by value.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-12-31 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-28  2:01 [parisc-linux] misaligned data Grant Grundler
2002-12-28  2:49 ` John David Anglin
2002-12-30  5:39   ` Grant Grundler
2002-12-30  7:15   ` Grant Grundler
2002-12-31 21:50     ` John David Anglin

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.