[Linux-Xtensa] RAM load/store reorder

Baruch Siach baruch at tkos.co.il
Wed Nov 27 13:09:43 UTC 2013


Hi linux-xtensa list,

I have ported U-Boot v2013.07 (based on
https://github.com/czankel/xtensa-uboot) to our platform running on the KC705
board. Everything seems to work fine except the following little problem. For
this code from lib/libfdt/fdt.c:

int fdt_next_subnode(const void *fdt, int offset)
{
        int depth = 1;

        /*
         * With respect to the parent, the depth of the next subnode will be
         * the same as the last.
         */
        do {
                offset = fdt_next_node(fdt, offset, &depth);
                if (offset < 0 || depth < 1)
                        return -FDT_ERR_NOTFOUND;
        } while (depth > 1);

        return offset;
}

the following code is generated (first few instructions):

05f3d408 <fdt_next_subnode>:
 5f3d408:       008136                  entry   a1, 64
 5f3d40b:       03bd                    mov.n   a11, a3
 5f3d40d:       cd8c31                  l32r    a3, 5f30a40
 5f3d410:       180c                    movi.n  a8, 1
 5f3d412:       0189                    s32i.n  a8, a1, 0
 5f3d414:       4139                    s32i.n  a3, a1, 16
 5f3d416:       4138                    l32i.n  a3, a1, 16
 5f3d418:       02ad                    mov.n   a10, a2
 5f3d41a:       20c110                  or      a12, a1, a1
 5f3d41d:       0003e0                  callx8  a3

Running this code under a debugger with hardware breakpoints at 0x5f3d410 and
0x5f3d41d indicates that the values at a3 and *(a1+16) got swapped. The
following pseudo code illustrates the situation:

	tmp      <- a3
	a3       <- *(a1+16)
	*(a1+16) <- tmp

The result is, or course, that the code blows up a little after the 'callx8'
instruction. 

I have two questions:

1. Why is this seemingly NOP store/load pair at 0x5f3d414 and 0x5f3d416
   needed at all?

2. How can I avoid this execution reorder?

Thanks,
baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


More information about the linux-xtensa mailing list