9ns: Align struct dirtab to 64 bytes devvars puts struct dirtabs into a linker table. Those tables are all 64 byte aligned, and the objects within the table will be laid out with 64 byte alignment. This was probably the cause of the intermittent startup assertion failure in vars_init() (couldn't find "."). "." is at the end of the vars table, and any confusion regarding the length, size, or alignment of the tables and objects could result in not memcpying that item. I noticed this when changing the KNAMELEN, which increased the size of the dirtab to 0x120 bytes. That's 32-byte aligned, not 64. However, the objects within the table were laid out (by the linker) in 0x140 byte strides: 0x120 rounded up to 64. Additionally, before I fixed this alignment, vars_init() had a hard time doing pointer arithmetic on the struct dirtab *s, and would come up with a really large number. Doing the math manually worked. Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/include/ns.h b/kern/include/ns.h index eb7fa9c..2e6fa2f 100644 --- a/kern/include/ns.h +++ b/kern/include/ns.h
@@ -468,7 +468,7 @@ char *(*chaninfo) (struct chan *, char *, size_t); int (*tapfd) (struct chan *, struct fd_tap *, int); int (*chan_ctl)(struct chan *, int); - /* we need to be aligned, we think to 64 bytes, for the linker tables. */ + /* we need to be aligned to 64 bytes for the linker tables. */ } __attribute__ ((aligned(64))); struct dirtab { @@ -476,7 +476,8 @@ struct qid qid; int64_t length; int perm; -}; + /* we need to be aligned to 64 bytes for the linker tables. */ +} __attribute__ ((aligned(64))); struct walkqid { struct chan *clone;