kdump on ARM

Bernd Walter ticso at cicely7.cicely.de
Wed Feb 17 15:19:46 UTC 2010


On Wed, Feb 17, 2010 at 04:16:07PM +0100, Bernd Walter wrote:
> On Wed, Feb 17, 2010 at 02:54:05PM +0000, Rui Paulo wrote:
> > 
> > On 17 Feb 2010, at 14:18, Grzegorz Bernacki wrote:
> > 
> > > Hi,
> > > 
> > > I've noticed that kdump on ARM doesn't work properly, it generates bus error. The problem is that structures dumped into ktrace.out are not aligned. Processing such a structure causes Aligment Fault. One solution is to copy structure into local variable and then process it, please see patch below. But I am not sure if this is the best solution and maybe someone has a better idea.
> 
> Excellent!
> 
> > > grzesiek
> > > 
> > > 
> > > diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
> > > index 386221e..5a15886 100644
> > > --- a/usr.bin/kdump/kdump.c
> > > +++ b/usr.bin/kdump/kdump.c
> > > @@ -1325,6 +1325,10 @@ ktrstat(struct stat *statp)
> > > void
> > > ktrstruct(char *buf, size_t buflen)
> > > {
> > > +#if defined(__arm__)
> > > +       struct stat stat;
> > > +       struct sockaddr sockaddr;
> > > +#endif
> > >        char *name, *data;
> > >        size_t namelen, datalen;
> > >        int i;
> > > @@ -1348,12 +1352,22 @@ ktrstruct(char *buf, size_t buflen)
> > >        if (strcmp(name, "stat") == 0) {
> > >                if (datalen != sizeof(struct stat))
> > >                        goto invalid;
> > > +#if defined(__arm__)
> > > +               memcpy(&stat, data, sizeof(struct stat));
> > > +               ktrstat(&stat);
> > > +#else
> > >                ktrstat((struct stat *)data);
> > > +#endif
> > >        } else if (strcmp(name, "sockaddr") == 0) {
> > >                if (datalen < sizeof(struct sockaddr) ||
> > >                    datalen != ((struct sockaddr *)(data))->sa_len)
> > >                        goto invalid;
> > > +#if defined(__arm__)
> > > +               memcpy(&sockaddr, data, sizeof(struct sockaddr));
> > > +               ktrsockaddr(&sockaddr);
> > > +#else
> > >                ktrsockaddr((struct sockaddr *)data);
> > > +#endif
> > >        } else {
> > >                printf("unknown structure\n");
> > >        }
> > 
> > I wonder if this can't be made non arm conditional?

Ups - I'd just recovered from Mr. Sandman's work.
So we all agree about.
Nevertheless it should be verified if this is just a faulty struct
definition.
On the other hand I think it is not because someone else wrote it is
a brokem on mips as well.

> Either this struct is properly aligned or not.
> So why should this be made conditional?
> Non strict alignment architecturs also have problems with this, but
> it is usualy just speed penalties.
> There is one ARM sepcific struct missalignment problem.
> In this case we usually add __packed macro to structure definition.
> For most structures this usually means no change on other
> archtitectures and we only declare the struct to forcibly be what the
> programmer already expected.
> Only a few programmers are aware that they expect something from
> structures, which is not garantied.
> 

-- 
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.


More information about the freebsd-arm mailing list