Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2014 22:04:36 -0800
From:      John-Mark Gurney <jmg@funkthat.com>
To:        arch@FreeBSD.org
Subject:   casting td_retval to off_t...
Message-ID:  <20140113060436.GC2982@funkthat.com>

next in thread | raw e-mail | index | archive | help
So, I've been working on bringing FreeBSD back up on an AVILA board
and have run into an issue where we cast td_retval to an off_t to write
back a value (see the end of kern/vfs_vnops.c).

The issue is that td_retval is defined as:
	register_t      td_retval[2];

and on arm register_t is an int32_t so in struct thread, it doesn't
get aligned to an 8 byte boundary...  Recently attilo added an int
before td_retval that caused td_retval to be no longer be aligned to
8 bytes.

What is the best way to fix this?

One simple & quick fix was to add __aligned(sizeof(off_t)) to the
td_retval, but if we really want to fix this cleanly (make it alias
clean), we should change td_retval to be a union, and I guess have
a define for td_retval to access it through the union, something
like:

union {
	register_t tdu_retval[2];
	off_t	tdu_off;
} td_uretoff;
#define td_retval	td_uretoff.tdu_retval

Comments?

Thanks.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140113060436.GC2982>