[PATCH] Fix handling of AVR interrupts above 33.

Lucas Dietrich posted 1 patch 10 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230614140748.3584-1-ld.adecy@gmail.com
Maintainers: Michael Rolnik <mrolnik@gmail.com>
target/avr/helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] Fix handling of AVR interrupts above 33.
Posted by Lucas Dietrich 10 months, 3 weeks ago
This commit addresses a bug in the AVR interrupt handling code.
The modification involves replacing the usage of the ctz32 function
with ctz64 to ensure proper handling of interrupts above 33 in the AVR
target.

Previously, timers 3, 4, and 5 interrupts were not functioning correctly
because most of their interrupt vectors are numbered above 33.

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
---
 target/avr/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/avr/helper.c b/target/avr/helper.c
index 2bad242a66..e6e7d51487 100644
--- a/target/avr/helper.c
+++ b/target/avr/helper.c
@@ -52,7 +52,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     }
     if (interrupt_request & CPU_INTERRUPT_HARD) {
         if (cpu_interrupts_enabled(env) && env->intsrc != 0) {
-            int index = ctz32(env->intsrc);
+            int index = ctz64(env->intsrc);
             cs->exception_index = EXCP_INT(index);
             avr_cpu_do_interrupt(cs);
 
@@ -79,7 +79,7 @@ void avr_cpu_do_interrupt(CPUState *cs)
     if (cs->exception_index == EXCP_RESET) {
         vector = 0;
     } else if (env->intsrc != 0) {
-        vector = ctz32(env->intsrc) + 1;
+        vector = ctz64(env->intsrc) + 1;
     }
 
     if (avr_feature(env, AVR_FEATURE_3_BYTE_PC)) {
-- 
2.40.1
Re: [PATCH] Fix handling of AVR interrupts above 33.
Posted by Michael Tokarev 10 months, 3 weeks ago
Applied to the trivial tree, thank you!

/mjt
Re: [PATCH] Fix handling of AVR interrupts above 33.
Posted by Philippe Mathieu-Daudé 10 months, 3 weeks ago
On 18/6/23 08:56, Michael Tokarev wrote:
> Applied to the trivial tree, thank you!

Thanks. Do you mind updating the patch subject to:
"target/avr: Fix handling of interrupts above 33"?
Re: [PATCH] Fix handling of AVR interrupts above 33.
Posted by Philippe Mathieu-Daudé 10 months, 3 weeks ago
On 14/6/23 16:07, Lucas Dietrich wrote:
> This commit addresses a bug in the AVR interrupt handling code.
> The modification involves replacing the usage of the ctz32 function
> with ctz64 to ensure proper handling of interrupts above 33 in the AVR
> target.
> 
> Previously, timers 3, 4, and 5 interrupts were not functioning correctly
> because most of their interrupt vectors are numbered above 33.
> 
> Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
> ---
>   target/avr/helper.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Thanks for insisting with the patch posting process :)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH] Fix handling of AVR interrupts above 33.
Posted by Michael Rolnik 10 months, 3 weeks ago
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>

On Wed, Jun 14, 2023 at 3:22 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> On 14/6/23 16:07, Lucas Dietrich wrote:
> > This commit addresses a bug in the AVR interrupt handling code.
> > The modification involves replacing the usage of the ctz32 function
> > with ctz64 to ensure proper handling of interrupts above 33 in the AVR
> > target.
> >
> > Previously, timers 3, 4, and 5 interrupts were not functioning correctly
> > because most of their interrupt vectors are numbered above 33.
> >
> > Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
> > ---
> >   target/avr/helper.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
>
> Thanks for insisting with the patch posting process :)
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>

-- 
Best Regards,
Michael Rolnik