Re: [PATCH] target/xtensa: Assert that interrupt level is within bounds
On Tue, Jul 4, 2023 at 6:27 AM Peter Maydell wrote: > > On Sat, 24 Jun 2023 at 01:20, Max Filippov wrote: > > > > On Fri, Jun 23, 2023 at 8:41 AM Peter Maydell > > wrote: > > > > > > In handle_interrupt() we use level as an index into the interrupt_vector[] > > > array. This is safe because we have checked it against > > > env->config->nlevel, > > > but Coverity can't see that (and it is only true because each CPU config > > > sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it > > > complains about a possible array overrun (CID 1507131) > > > > > > Add an assert() which will make Coverity happy and catch the unlikely > > > case of a mis-set XCHAL_NUM_INTLEVELS in future. > > > > > > Signed-off-by: Peter Maydell > > > --- > > > NB: only tested with 'make check-avocado'. You could argue that we > > > should mark the coverity issue as false-positive instead if you like. > > > --- > > > target/xtensa/exc_helper.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > Acked-by: Max Filippov > > Thanks. I'll take it via target-arm since I'm doing a pullreq > anyway, unless you'd prefer otherwise. It's good, please go ahead. -- Thanks. -- Max
Re: [PATCH] target/xtensa: Assert that interrupt level is within bounds
On Sat, 24 Jun 2023 at 01:20, Max Filippov wrote: > > On Fri, Jun 23, 2023 at 8:41 AM Peter Maydell > wrote: > > > > In handle_interrupt() we use level as an index into the interrupt_vector[] > > array. This is safe because we have checked it against env->config->nlevel, > > but Coverity can't see that (and it is only true because each CPU config > > sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it > > complains about a possible array overrun (CID 1507131) > > > > Add an assert() which will make Coverity happy and catch the unlikely > > case of a mis-set XCHAL_NUM_INTLEVELS in future. > > > > Signed-off-by: Peter Maydell > > --- > > NB: only tested with 'make check-avocado'. You could argue that we > > should mark the coverity issue as false-positive instead if you like. > > --- > > target/xtensa/exc_helper.c | 3 +++ > > 1 file changed, 3 insertions(+) > > Acked-by: Max Filippov Thanks. I'll take it via target-arm since I'm doing a pullreq anyway, unless you'd prefer otherwise. -- PMM
Re: [PATCH] target/xtensa: Assert that interrupt level is within bounds
On Fri, Jun 23, 2023 at 8:41 AM Peter Maydell wrote: > > In handle_interrupt() we use level as an index into the interrupt_vector[] > array. This is safe because we have checked it against env->config->nlevel, > but Coverity can't see that (and it is only true because each CPU config > sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it > complains about a possible array overrun (CID 1507131) > > Add an assert() which will make Coverity happy and catch the unlikely > case of a mis-set XCHAL_NUM_INTLEVELS in future. > > Signed-off-by: Peter Maydell > --- > NB: only tested with 'make check-avocado'. You could argue that we > should mark the coverity issue as false-positive instead if you like. > --- > target/xtensa/exc_helper.c | 3 +++ > 1 file changed, 3 insertions(+) Acked-by: Max Filippov -- Thanks. -- Max