diff mbox series

[RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled

Message ID DM5PR11MB18339389B4BD1BB2B4B5AB7A8D860@DM5PR11MB1833.namprd11.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series [RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled | expand

Commit Message

Wu, Wentong June 5, 2020, 5:59 a.m. UTC
Hi all,
I'm running icount mode on qemu_nios2 with customized  platform(almost same with 10m50_devboard),
but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O function) when guest code changes
state register with wrctl instruction, add some debug code finding that it's caused by the interrupt_request
mismatch, so I made a patch as below, not sure if it's right, hope I can have some discussion with maintainers
first! Thanks a lot!



commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
Author: Wentong Wu <wentong.wu@intel.com>
Date:   Fri Jun 5 09:29:43 2020 -0400

    hw: nios2: update interrupt_request when CR_STATUS_PIE disabled

    Update interrupt_request when external interupt pends for STATUS_PIE
    disabled. Otherwise on icount enabled nios2 target there will be cpu
    abort when guest code changes state register with wrctl instruction.

    Signed-off-by: Wentong Wu <wentong.wu@intel.com>

Comments

Thomas Huth June 5, 2020, 7:06 a.m. UTC | #1
On 05/06/2020 07.59, Wu, Wentong wrote:
> Hi all,
> 
> I’m running icount mode on qemu_nios2 with customized  platform(almost
> same with 10m50_devboard),
> 
> but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O
> function) when guest code changes
> 
> state register with wrctl instruction, add some debug code finding that
> it’s caused by the interrupt_request
> 
> mismatch, so I made a patch as below, not sure if it’s right, hope I can
> have some discussion with maintainers

 Hi,

please have a look at the MAINTAINERS file in the main directory of the
sources, you can find the corresponding maintainers there. Thus if you
have questions related to nios2, please make sure to put Chris and Marek
into CC: so that your patch gets the right attention!

 Thanks,
  Thomas



> commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
> 
> Author: Wentong Wu <wentong.wu@intel.com>
> 
> Date:   Fri Jun 5 09:29:43 2020 -0400
> 
>  
> 
>     hw: nios2: update interrupt_request when CR_STATUS_PIE disabled
> 
>  
> 
>     Update interrupt_request when external interupt pends for STATUS_PIE
> 
>     disabled. Otherwise on icount enabled nios2 target there will be cpu
> 
>     abort when guest code changes state register with wrctl instruction.
> 
>  
> 
>     Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> 
>  
> 
> diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
> 
> index 1c1989d5..b04db4d7 100644
> 
> --- a/hw/nios2/cpu_pic.c
> 
> +++ b/hw/nios2/cpu_pic.c
> 
> @@ -42,7 +42,9 @@ static void nios2_pic_cpu_handler(void *opaque, int
> irq, int level)
> 
>          } else if (!level) {
> 
>              env->irq_pending = 0;
> 
>              cpu_reset_interrupt(cs, type);
> 
> -        }
> 
> +        } else {
> 
> +            cs->interrupt_request |= type;
> 
> +       }
> 
>      } else {
> 
>          if (level) {
> 
>              cpu_interrupt(cs, type);
>
Wu, Wentong June 5, 2020, 7:14 a.m. UTC | #2
Thanks Thomas!

@Chris Wulff @Marek Vasut could you please give some suggestions? Thanks

-----Original Message-----
From: Thomas Huth <thuth@redhat.com> 
Sent: Friday, June 5, 2020 3:07 PM
To: Wu, Wentong <wentong.wu@intel.com>; qemu-devel@nongnu.org
Cc: Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
Subject: Re: [RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled

On 05/06/2020 07.59, Wu, Wentong wrote:
> Hi all,
> 
> I’m running icount mode on qemu_nios2 with customized  platform(almost 
> same with 10m50_devboard),
> 
> but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O
> function) when guest code changes
> 
> state register with wrctl instruction, add some debug code finding 
> that it’s caused by the interrupt_request
> 
> mismatch, so I made a patch as below, not sure if it’s right, hope I 
> can have some discussion with maintainers

 Hi,

please have a look at the MAINTAINERS file in the main directory of the sources, you can find the corresponding maintainers there. Thus if you have questions related to nios2, please make sure to put Chris and Marek into CC: so that your patch gets the right attention!

 Thanks,
  Thomas



> commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
> 
> Author: Wentong Wu <wentong.wu@intel.com>
> 
> Date:   Fri Jun 5 09:29:43 2020 -0400
> 
>  
> 
>     hw: nios2: update interrupt_request when CR_STATUS_PIE disabled
> 
>  
> 
>     Update interrupt_request when external interupt pends for 
> STATUS_PIE
> 
>     disabled. Otherwise on icount enabled nios2 target there will be 
> cpu
> 
>     abort when guest code changes state register with wrctl instruction.
> 
>  
> 
>     Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> 
>  
> 
> diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
> 
> index 1c1989d5..b04db4d7 100644
> 
> --- a/hw/nios2/cpu_pic.c
> 
> +++ b/hw/nios2/cpu_pic.c
> 
> @@ -42,7 +42,9 @@ static void nios2_pic_cpu_handler(void *opaque, int 
> irq, int level)
> 
>          } else if (!level) {
> 
>              env->irq_pending = 0;
> 
>              cpu_reset_interrupt(cs, type);
> 
> -        }
> 
> +        } else {
> 
> +            cs->interrupt_request |= type;
> 
> +       }
> 
>      } else {
> 
>          if (level) {
> 
>              cpu_interrupt(cs, type);
>
Wu, Wentong June 8, 2020, 1 a.m. UTC | #3
@Chris Wulff @Marek Vasut could you please take a look this issue and patch? Thanks in advance!

-----Original Message-----
From: Thomas Huth <thuth@redhat.com> 
Sent: Friday, June 5, 2020 3:07 PM
To: Wu, Wentong <wentong.wu@intel.com>; qemu-devel@nongnu.org
Cc: Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
Subject: Re: [RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled

On 05/06/2020 07.59, Wu, Wentong wrote:
> Hi all,
> 
> I’m running icount mode on qemu_nios2 with customized  platform(almost 
> same with 10m50_devboard),
> 
> but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O
> function) when guest code changes
> 
> state register with wrctl instruction, add some debug code finding 
> that it’s caused by the interrupt_request
> 
> mismatch, so I made a patch as below, not sure if it’s right, hope I 
> can have some discussion with maintainers

 Hi,

please have a look at the MAINTAINERS file in the main directory of the sources, you can find the corresponding maintainers there. Thus if you have questions related to nios2, please make sure to put Chris and Marek into CC: so that your patch gets the right attention!

 Thanks,
  Thomas



> commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
> 
> Author: Wentong Wu <wentong.wu@intel.com>
> 
> Date:   Fri Jun 5 09:29:43 2020 -0400
> 
>  
> 
>     hw: nios2: update interrupt_request when CR_STATUS_PIE disabled
> 
>  
> 
>     Update interrupt_request when external interupt pends for 
> STATUS_PIE
> 
>     disabled. Otherwise on icount enabled nios2 target there will be 
> cpu
> 
>     abort when guest code changes state register with wrctl instruction.
> 
>  
> 
>     Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> 
>  
> 
> diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
> 
> index 1c1989d5..b04db4d7 100644
> 
> --- a/hw/nios2/cpu_pic.c
> 
> +++ b/hw/nios2/cpu_pic.c
> 
> @@ -42,7 +42,9 @@ static void nios2_pic_cpu_handler(void *opaque, int 
> irq, int level)
> 
>          } else if (!level) {
> 
>              env->irq_pending = 0;
> 
>              cpu_reset_interrupt(cs, type);
> 
> -        }
> 
> +        } else {
> 
> +            cs->interrupt_request |= type;
> 
> +       }
> 
>      } else {
> 
>          if (level) {
> 
>              cpu_interrupt(cs, type);
>
Wu, Wentong June 9, 2020, 8:39 a.m. UTC | #4
Hi @Thomas Huth,
It's my first time to send patch in qemu community, not sure if there is something wrong sending patch like below and I'm happy to receive any suggestions. And by the way, could you please help review the patch? 

Thanks

-----Original Message-----
From: Thomas Huth <thuth@redhat.com> 
Sent: Friday, June 5, 2020 3:07 PM
To: Wu, Wentong <wentong.wu@intel.com>; qemu-devel@nongnu.org
Cc: Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
Subject: Re: [RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled

On 05/06/2020 07.59, Wu, Wentong wrote:
> Hi all,
> 
> I’m running icount mode on qemu_nios2 with customized  platform(almost 
> same with 10m50_devboard),
> 
> but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O
> function) when guest code changes
> 
> state register with wrctl instruction, add some debug code finding 
> that it’s caused by the interrupt_request
> 
> mismatch, so I made a patch as below, not sure if it’s right, hope I 
> can have some discussion with maintainers

 Hi,

please have a look at the MAINTAINERS file in the main directory of the sources, you can find the corresponding maintainers there. Thus if you have questions related to nios2, please make sure to put Chris and Marek into CC: so that your patch gets the right attention!

 Thanks,
  Thomas



> commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
> 
> Author: Wentong Wu <wentong.wu@intel.com>
> 
> Date:   Fri Jun 5 09:29:43 2020 -0400
> 
>  
> 
>     hw: nios2: update interrupt_request when CR_STATUS_PIE disabled
> 
>  
> 
>     Update interrupt_request when external interupt pends for 
> STATUS_PIE
> 
>     disabled. Otherwise on icount enabled nios2 target there will be 
> cpu
> 
>     abort when guest code changes state register with wrctl instruction.
> 
>  
> 
>     Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> 
>  
> 
> diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
> 
> index 1c1989d5..b04db4d7 100644
> 
> --- a/hw/nios2/cpu_pic.c
> 
> +++ b/hw/nios2/cpu_pic.c
> 
> @@ -42,7 +42,9 @@ static void nios2_pic_cpu_handler(void *opaque, int 
> irq, int level)
> 
>          } else if (!level) {
> 
>              env->irq_pending = 0;
> 
>              cpu_reset_interrupt(cs, type);
> 
> -        }
> 
> +        } else {
> 
> +            cs->interrupt_request |= type;
> 
> +       }
> 
>      } else {
> 
>          if (level) {
> 
>              cpu_interrupt(cs, type);
>
Thomas Huth June 10, 2020, 1:29 p.m. UTC | #5
On 09/06/2020 10.39, Wu, Wentong wrote:
> Hi @Thomas Huth,
> It's my first time to send patch in qemu community, not sure if there is something wrong sending patch like below and I'm happy to receive any suggestions. And by the way, could you please help review the patch? 

 Hi,

it would be good if you could send the patch as plain text e-mail, not
as HTML mail, otherwise it's impossible to apply it with "git am" or
"patch". If you can, try to use "git send-email" to send out patches.
Also see https://wiki.qemu.org/Contribute/SubmitAPatch for some more
details.

Technically, I don't have a clue about nios2, so sorry, I can't help
reviewing it. But it's a very small patch, so maybe send the plain-text
mail with CC: to qemu-trivial@nongnu.org - if Chris or Marek provide an
Reviewed-by or Acked-by then, it should get merged with the next trivial
pull request.

 HTH,
  Thomas


> Thanks
> 
> -----Original Message-----
> From: Thomas Huth <thuth@redhat.com> 
> Sent: Friday, June 5, 2020 3:07 PM
> To: Wu, Wentong <wentong.wu@intel.com>; qemu-devel@nongnu.org
> Cc: Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
> Subject: Re: [RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled
> 
> On 05/06/2020 07.59, Wu, Wentong wrote:
>> Hi all,
>>
>> I’m running icount mode on qemu_nios2 with customized  platform(almost 
>> same with 10m50_devboard),
>>
>> but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O
>> function) when guest code changes
>>
>> state register with wrctl instruction, add some debug code finding 
>> that it’s caused by the interrupt_request
>>
>> mismatch, so I made a patch as below, not sure if it’s right, hope I 
>> can have some discussion with maintainers
> 
>  Hi,
> 
> please have a look at the MAINTAINERS file in the main directory of the sources, you can find the corresponding maintainers there. Thus if you have questions related to nios2, please make sure to put Chris and Marek into CC: so that your patch gets the right attention!
> 
>  Thanks,
>   Thomas
> 
> 
> 
>> commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
>>
>> Author: Wentong Wu <wentong.wu@intel.com>
>>
>> Date:   Fri Jun 5 09:29:43 2020 -0400
>>
>>  
>>
>>     hw: nios2: update interrupt_request when CR_STATUS_PIE disabled
>>
>>  
>>
>>     Update interrupt_request when external interupt pends for 
>> STATUS_PIE
>>
>>     disabled. Otherwise on icount enabled nios2 target there will be 
>> cpu
>>
>>     abort when guest code changes state register with wrctl instruction.
>>
>>  
>>
>>     Signed-off-by: Wentong Wu <wentong.wu@intel.com>
>>
>>  
>>
>> diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
>>
>> index 1c1989d5..b04db4d7 100644
>>
>> --- a/hw/nios2/cpu_pic.c
>>
>> +++ b/hw/nios2/cpu_pic.c
>>
>> @@ -42,7 +42,9 @@ static void nios2_pic_cpu_handler(void *opaque, int 
>> irq, int level)
>>
>>          } else if (!level) {
>>
>>              env->irq_pending = 0;
>>
>>              cpu_reset_interrupt(cs, type);
>>
>> -        }
>>
>> +        } else {
>>
>> +            cs->interrupt_request |= type;
>>
>> +       }
>>
>>      } else {
>>
>>          if (level) {
>>
>>              cpu_interrupt(cs, type);
>>
>
Wu, Wentong June 11, 2020, 6:05 a.m. UTC | #6
HI Thomas,
Thanks for the help, I updated the patch in the new thread https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg03103.html, hoping that follows QEMU's working style, Thanks again.

BR,
Wentong
-----Original Message-----
From: Thomas Huth <thuth@redhat.com> 
Sent: Wednesday, June 10, 2020 9:29 PM
To: Wu, Wentong <wentong.wu@intel.com>; qemu-devel@nongnu.org
Cc: Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
Subject: Re: [RFC] hw: nios2: update interrupt_request when STATUS_PIE disabled

On 09/06/2020 10.39, Wu, Wentong wrote:
> Hi @Thomas Huth,
> It's my first time to send patch in qemu community, not sure if there is something wrong sending patch like below and I'm happy to receive any suggestions. And by the way, could you please help review the patch? 

 Hi,

it would be good if you could send the patch as plain text e-mail, not as HTML mail, otherwise it's impossible to apply it with "git am" or "patch". If you can, try to use "git send-email" to send out patches.
Also see https://wiki.qemu.org/Contribute/SubmitAPatch for some more details.

Technically, I don't have a clue about nios2, so sorry, I can't help reviewing it. But it's a very small patch, so maybe send the plain-text mail with CC: to qemu-trivial@nongnu.org - if Chris or Marek provide an Reviewed-by or Acked-by then, it should get merged with the next trivial pull request.

 HTH,
  Thomas


> Thanks
> 
> -----Original Message-----
> From: Thomas Huth <thuth@redhat.com>
> Sent: Friday, June 5, 2020 3:07 PM
> To: Wu, Wentong <wentong.wu@intel.com>; qemu-devel@nongnu.org
> Cc: Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
> Subject: Re: [RFC] hw: nios2: update interrupt_request when STATUS_PIE 
> disabled
> 
> On 05/06/2020 07.59, Wu, Wentong wrote:
>> Hi all,
>>
>> I’m running icount mode on qemu_nios2 with customized  
>> platform(almost same with 10m50_devboard),
>>
>> but cpu abort happened(qemu: fatal: Raised interrupt while not in I/O
>> function) when guest code changes
>>
>> state register with wrctl instruction, add some debug code finding 
>> that it’s caused by the interrupt_request
>>
>> mismatch, so I made a patch as below, not sure if it’s right, hope I 
>> can have some discussion with maintainers
> 
>  Hi,
> 
> please have a look at the MAINTAINERS file in the main directory of the sources, you can find the corresponding maintainers there. Thus if you have questions related to nios2, please make sure to put Chris and Marek into CC: so that your patch gets the right attention!
> 
>  Thanks,
>   Thomas
> 
> 
> 
>> commit efdb3da4e145a7a34ba8b3ab1cdcfc346ae20a11 (HEAD -> master)
>>
>> Author: Wentong Wu <wentong.wu@intel.com>
>>
>> Date:   Fri Jun 5 09:29:43 2020 -0400
>>
>>  
>>
>>     hw: nios2: update interrupt_request when CR_STATUS_PIE disabled
>>
>>  
>>
>>     Update interrupt_request when external interupt pends for 
>> STATUS_PIE
>>
>>     disabled. Otherwise on icount enabled nios2 target there will be 
>> cpu
>>
>>     abort when guest code changes state register with wrctl instruction.
>>
>>  
>>
>>     Signed-off-by: Wentong Wu <wentong.wu@intel.com>
>>
>>  
>>
>> diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
>>
>> index 1c1989d5..b04db4d7 100644
>>
>> --- a/hw/nios2/cpu_pic.c
>>
>> +++ b/hw/nios2/cpu_pic.c
>>
>> @@ -42,7 +42,9 @@ static void nios2_pic_cpu_handler(void *opaque, int 
>> irq, int level)
>>
>>          } else if (!level) {
>>
>>              env->irq_pending = 0;
>>
>>              cpu_reset_interrupt(cs, type);
>>
>> -        }
>>
>> +        } else {
>>
>> +            cs->interrupt_request |= type;
>>
>> +       }
>>
>>      } else {
>>
>>          if (level) {
>>
>>              cpu_interrupt(cs, type);
>>
>
diff mbox series

Patch

diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
index 1c1989d5..b04db4d7 100644
--- a/hw/nios2/cpu_pic.c
+++ b/hw/nios2/cpu_pic.c
@@ -42,7 +42,9 @@  static void nios2_pic_cpu_handler(void *opaque, int irq, int level)
         } else if (!level) {
             env->irq_pending = 0;
             cpu_reset_interrupt(cs, type);
-        }
+        } else {
+            cs->interrupt_request |= type;
+       }
     } else {
         if (level) {
             cpu_interrupt(cs, type);