All of lore.kernel.org
 help / color / mirror / Atom feed
From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Mykola Kvach <xakep.amatop@gmail.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Mykola Kvach <Mykola_Kvach@epam.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>
Subject: Re: [PATCH] xen/arm: ignore spurious interrupts from virtual timer
Date: Tue, 1 Dec 2026 02:33:36 +0000	[thread overview]
Message-ID: <87cxrlivb6.fsf@epam.com> (raw)
In-Reply-To: <436a0405a9482dadce7f7cdb1e9721ee461f26a7.1768219676.git.mykola_kvach@epam.com>

Hi Mykola,

Mykola Kvach <xakep.amatop@gmail.com> writes:

> From: Mykola Kvach <mykola_kvach@epam.com>
>
> If a spurious virtual timer interrupt occurs (i.e. the interrupt fires
> but CNTV_CTL_EL0 does not report it as pending), Xen masks the virtual
> timer and injects the vtimer IRQ into the guest. For Linux guests, the
> timer interrupt is unmasked only after programming a new CVAL value from
> the timer interrupt handler. When the interrupt is not reported as
> pending, the handler can skip that programming step, leaving the timer
> masked and stalling the affected CPU.
>
> This patch mirrors the Linux arm generic timer handler: if the interrupt
> fires but the pending bit is not set, treat it as spurious and ignore it.
>
> This issue is reproducible under heavy load on the R-Car X5H board
> (Cortex-A720AE r0p0).
>
> Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>

Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

> ---
>  xen/arch/arm/include/asm/perfc_defn.h |  7 ++++---
>  xen/arch/arm/time.c                   | 11 ++++++++++-
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/xen/arch/arm/include/asm/perfc_defn.h b/xen/arch/arm/include/asm/perfc_defn.h
> index effd25b69e..f83989d95a 100644
> --- a/xen/arch/arm/include/asm/perfc_defn.h
> +++ b/xen/arch/arm/include/asm/perfc_defn.h
> @@ -69,9 +69,10 @@ PERFCOUNTER(ppis,                 "#PPIs")
>  PERFCOUNTER(spis,                 "#SPIs")
>  PERFCOUNTER(guest_irqs,           "#GUEST-IRQS")
>  
> -PERFCOUNTER(hyp_timer_irqs,   "Hypervisor timer interrupts")
> -PERFCOUNTER(virt_timer_irqs,  "Virtual timer interrupts")
> -PERFCOUNTER(maintenance_irqs, "Maintenance interrupts")
> +PERFCOUNTER(hyp_timer_irqs,             "Hypervisor timer interrupts")
> +PERFCOUNTER(virt_timer_irqs,            "Virtual timer interrupts")
> +PERFCOUNTER(virt_timer_spurious_irqs,   "Virtual timer spurious interrupts")
> +PERFCOUNTER(maintenance_irqs,           "Maintenance interrupts")
>  
>  PERFCOUNTER(atomics_guest,    "atomics: guest access")
>  PERFCOUNTER(atomics_guest_paused,   "atomics: guest paused")
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index cc3fcf47b6..d18d6568bb 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -258,6 +258,8 @@ static void htimer_interrupt(int irq, void *dev_id)
>  
>  static void vtimer_interrupt(int irq, void *dev_id)
>  {
> +    register_t ctl;
> +
>      /*
>       * Edge-triggered interrupts can be used for the virtual timer. Even
>       * if the timer output signal is masked in the context switch, the
> @@ -271,9 +273,16 @@ static void vtimer_interrupt(int irq, void *dev_id)
>      if ( unlikely(is_idle_vcpu(current)) )
>          return;
>  
> +    ctl = READ_SYSREG(CNTV_CTL_EL0);
> +    if ( unlikely(!(ctl & CNTx_CTL_PENDING)) )
> +    {
> +        perfc_incr(virt_timer_spurious_irqs);
> +        return;
> +    }
> +
>      perfc_incr(virt_timer_irqs);
>  
> -    current->arch.virt_timer.ctl = READ_SYSREG(CNTV_CTL_EL0);
> +    current->arch.virt_timer.ctl = ctl;
>      WRITE_SYSREG(current->arch.virt_timer.ctl | CNTx_CTL_MASK, CNTV_CTL_EL0);
>      vgic_inject_irq(current->domain, current, current->arch.virt_timer.irq, true);
>  }

-- 
WBR, Volodymyr

  parent reply	other threads:[~2026-12-01  2:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 12:50 [PATCH] xen/arm: ignore spurious interrupts from virtual timer Mykola Kvach
2026-01-12 14:04 ` Julien Grall
2026-01-29 11:29   ` Mykola Kvach
2026-11-18 23:38     ` Mykola Kvach
2026-12-01  2:33 ` Volodymyr Babchuk [this message]
2026-12-01 10:08 ` Orzel, Michal
2026-12-01 23:06   ` Mykola Kvach

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=87cxrlivb6.fsf@epam.com \
    --to=volodymyr_babchuk@epam.com \
    --cc=Mykola_Kvach@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=xakep.amatop@gmail.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.