Subject: Re: sparc and gcc4?
To: Michael <macallan1888@gmail.com>
From: Martin Husemann <martin@duskware.de>
List: port-sparc
Date: 06/29/2006 23:28:28
On Thu, Jun 29, 2006 at 02:36:38PM -0400, Michael wrote:
> Instead it borks here:
> trap type 0x7: pc=0xf0060274 npc=0xf0060278 psr=48001c3<S,PS>
> kernel: alignment fault trap
> stopped in pid 41.1 (cp) at netbsd:tmpfs_vptofh+0x14:
> std %g2, [%o1 + 8]
> db> bt
> tmpfs_vptofh(0x2d, 0xf44d5be4, 0xf3a20478, 0xf3a2c3b8, 0x0, 0xf3a2ee70)
> at netbsd:nqsrv_getlease+0x288
This is easy:
struct fid {
unsigned short fid_len; /* length of data in bytes */
unsigned short fid_reserved; /* force longword alignment */
char fid_data[_VFS_MAXFIDSZ];/* data (variable length) */
};
If I calculated correctly, required alignement is 2 byte.
Now for tmpfs:
struct tmpfs_fid {
uint16_t tf_len;
uint16_t tf_pad;
uint32_t tf_gen;
ino_t tf_id;
};
Required alignement here is that of ino_t, so 8 byte.
Now the code filling the fid is:
static int
tmpfs_vptofh(struct vnode *vp, struct fid *fhp)
{
struct tmpfs_fid *tfhp;
struct tmpfs_node *node;
tfhp = (struct tmpfs_fid *)fhp;
node = VP_TO_TMPFS_NODE(vp);
tfhp->tf_len = sizeof(struct tmpfs_fid);
tfhp->tf_id = node->tn_id;
tfhp->tf_gen = node->tn_gen;
return 0;
}
And if you look at the assembler code, the
tfhp->tf_id = node->tn_id;
line is implemented as the faulting "std" instruction.
Not gcc's fault - we have to fix it.
Martin