target/xtensa: Assert that interrupt level is within bounds
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 23 Jun 2023 15:41:35 +0000 (16:41 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 6 Jul 2023 12:26:43 +0000 (13:26 +0100)
commitad18376b90c8101b8eed2fd571bdbb94636ccc2e
tree0a99782705624114bb6e404292d717c5c2ad4aea
parent9057e5f7c9550d1ea419ce838ae6d0df96fb062e
target/xtensa: Assert that interrupt level is within bounds

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 <peter.maydell@linaro.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Message-id: 20230623154135.1930261-1-peter.maydell@linaro.org
target/xtensa/exc_helper.c