qemu-arm.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-arm] [PATCH 3/3] hw/intc/arm_gicv3: Don't signal Pending+Active interrupts to CPU
Date: Wed, 7 Dec 2016 23:46:34 +0100	[thread overview]
Message-ID: <20161207224634.GG9606@toto> (raw)
In-Reply-To: <1481046379-32632-4-git-send-email-peter.maydell@linaro.org>

On Tue, Dec 06, 2016 at 05:46:19PM +0000, Peter Maydell wrote:
> The GICv3 requires that we only signal Pending interrupts to
> the CPU. This category does not include Pending+Active interrupts,
> which means we need to check whether the interrupt is Active in
> the gicr_int_pending() and gicd_int_pending() functions.
> 
> Interrupts are rarely in the Active+Pending state, but KVM
> uses this as part of its handling of the virtual timer, so
> this bug was causing KVM to go into an infinite loop of
> taking the vtimer interrupt when the guest first triggered it.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> ---
>  hw/intc/arm_gicv3.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
> index 8a6c647..f0c967b 100644
> --- a/hw/intc/arm_gicv3.c
> +++ b/hw/intc/arm_gicv3.c
> @@ -54,6 +54,7 @@ static uint32_t gicd_int_pending(GICv3State *s, int irq)
>       *  + the PENDING latch is set OR it is level triggered and the input is 1
>       *  + its ENABLE bit is set
>       *  + the GICD enable bit for its group is set
> +     *  + its ACTIVE bit is not set (otherwise it would be Active+Pending)
>       * Conveniently we can bulk-calculate this with bitwise operations.
>       */
>      uint32_t pend, grpmask;
> @@ -63,9 +64,11 @@ static uint32_t gicd_int_pending(GICv3State *s, int irq)
>      uint32_t group = *gic_bmp_ptr32(s->group, irq);
>      uint32_t grpmod = *gic_bmp_ptr32(s->grpmod, irq);
>      uint32_t enable = *gic_bmp_ptr32(s->enabled, irq);
> +    uint32_t active = *gic_bmp_ptr32(s->active, irq);
>  
>      pend = pending | (~edge_trigger & level);
>      pend &= enable;
> +    pend &= ~active;
>  
>      if (s->gicd_ctlr & GICD_CTLR_DS) {
>          grpmod = 0;
> @@ -96,12 +99,14 @@ static uint32_t gicr_int_pending(GICv3CPUState *cs)
>       *  + the PENDING latch is set OR it is level triggered and the input is 1
>       *  + its ENABLE bit is set
>       *  + the GICD enable bit for its group is set
> +     *  + its ACTIVE bit is not set (otherwise it would be Active+Pending)
>       * Conveniently we can bulk-calculate this with bitwise operations.
>       */
>      uint32_t pend, grpmask, grpmod;
>  
>      pend = cs->gicr_ipendr0 | (~cs->edge_trigger & cs->level);
>      pend &= cs->gicr_ienabler0;
> +    pend &= ~cs->gicr_iactiver0;
>  
>      if (cs->gic->gicd_ctlr & GICD_CTLR_DS) {
>          grpmod = 0;
> -- 
> 2.7.4
> 

      reply	other threads:[~2016-12-07 22:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 17:46 [Qemu-arm] [PATCH 0/3] GICv3 bugfixes (preliminary for virt) Peter Maydell
2016-12-06 17:46 ` [Qemu-arm] [PATCH 1/3] target-arm: Log AArch64 exception returns Peter Maydell
2016-12-07 21:01   ` Edgar E. Iglesias
2016-12-06 17:46 ` [Qemu-arm] [PATCH 2/3] hw/intc/arm_gicv3: Remove incorrect usage of fieldoffset Peter Maydell
2016-12-07 21:02   ` Edgar E. Iglesias
2016-12-06 17:46 ` [Qemu-arm] [PATCH 3/3] hw/intc/arm_gicv3: Don't signal Pending+Active interrupts to CPU Peter Maydell
2016-12-07 22:46   ` Edgar E. Iglesias [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161207224634.GG9606@toto \
    --to=edgar.iglesias@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).