Skip to content

Xpulp kernel in conv_2d.h has out of bounds memory accesses #47

@oakentling

Description

@oakentling

The kernel conv2d_3x3_unrolled2_i8_xpulpv2 from software/runtime/xpulp/conv_2d.h used in the application software/apps/onv2d_i8/main.c will result in out of bounds memory accesses. This was discovered by running the benchmark in the hardware folder with snitch_tracing enabled. The trace will contain X values which hardware/scripts/gen_trace.py cannot handle at the moment.

Steps to reproduce problem:

  1. In hardware/Makefile set snitch_trace?=1 (l. 49) and change l. 271 to benchmark: log simcvcs.

  2. In software/runtime/crt0.S replace l.88-89 with wfi. (This step might be optional)

  3. In the software folder, run make apps xpulpimg=1 config=mempool.

  4. If necessary, do unset CC && unset CXX. In the hardware folder, run make benchmark config=mempool xpulpimg=1 app=conv2d_i8.
    --> this will result in hardware/scripts/gen_trace.py failing
    TRACE:
    python3 /scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py -p --csv build/traces/results.csv build/traces/trace_hart_0x0000 > build/trace_hart_0x0000.trace
    Traceback (most recent call last):
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 910, in <module> sys.exit(main()
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 828, in main args.permissive)
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 541, in annotate_insn permissive)
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 374, in annotate_snitch int_lit(extras['ld_result_32'])))
    KeyError: 'ld_result_32'
    make[1]: *** [build/trace_hart_0x0000.trace] Error 1

  5. When looking at the end of the file hardware/build/trace_hart_0x0000.trace it is clear that the last few instructions try to load values from an out of bound address 0x0040400. The address is defined in software/bin/conv2d_i8.dump as <out>.

  6. Further when looking in hardware/build/trace_hart_0x0000.dasm and searching for the number in the first column of trace_hart_0x0000.trace where the problem occurs, one can find values which contain X's. These are the reason why gen_trace.py fails.

@SamuelRiedel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions