[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: ignore spurious interrupts from virtual timer


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Wed, 2 Dec 2026 01:06:02 +0200
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QBDPdJCcMKdVDE++jahmGIxW2bs2kGtpB42KU15j5tM=; fh=zL8KVAj6rSaYbk/102rEWeOa69wm5cw+i9nXMzeM8z8=; b=dSMsbn8AkhFRkFOh1fqq8QsI8xQerAlMZXNHJPUndWpJFQj7rZ8uUp09W33kVezraU KNX+12gzLN8Q/NBO6KAm1aJem+wXfP+qqzYXB8jywRvg04zZUNoQNiFAFNTn5Sljj6wO XR8bLvhH17ZocRHjOKIkpcXfu8sHnLBha+UZXNmK+vXC4w29mjT0uqQESyhx2MZU0sHj s44Cd7QO9kalNvKgRLi6FSxjvrg00nZLrJpLvw4ufwtPsZy1ZlhXzYIXZDDsWMUwjrMb p2xsRulCrgryf+O0PyP00lOHsjAcx1aFoG+rEikjlnqxyb0UzuRkZIqEGbIeIaLMEr1z zKLg==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1796166374; cv=none; d=google.com; s=arc-20260327; b=bItxgZUAoPoOa1AWgtKYKFrgEvZlB9M/YHUJ/RPlfrG+Jmk/AST57l3piGOhAEuStl kQgsfpAvYwTq6hk2LnVmZdLwGUzZRP9ju2XWwqciOFKZYF5ol8oE9k70+naEKygNByn2 UTkCXQVACNetcEdR9JyKD6wAh8DNEAnVYmV1nTkqYnSL5kPN1/xInYf5N17sycPm1eg5 cktuxaw+mRzvuvuFy9CxDY0yBzfnWF7jvejJZ9NUTmOFGtp8Td8vpgeicv/OaTqtEZIy XEvvSeIRnzlqE8GkR+jOXYb0M/iuipW4mzf8n1G4G8Tnxz2MksihFRQ2JTbJXWS3I/UQ KSkg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Mykola Kvach <mykola_kvach@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 01 Dec 2026 23:06:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Michal,

On Tue, Dec 1, 2026 at 12:08 PM Orzel, Michal <michal.orzel@xxxxxxx> wrote:
>
>
>
> On 12-Jan-26 13:50, Mykola Kvach wrote:
> > From: Mykola Kvach <mykola_kvach@xxxxxxxx>
> >
> > 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
> How does this spurious vtimer IRQ comes about?

I don't know what caused the IRQ. I saw it under heavy load on the
R-Car X5H. Xen read CNTV_CTL_EL0 as 0x1 in vtimer_interrupt(). The
timer was enabled and ISTATUS was clear, so there was no timer event
to deliver to the guest. If Xen masks the timer here and the guest
ignores the IRQ, the guest can miss its next timer interrupt.

> As Julien suggested, please say `... pending i.e. ISTATUS bit clear`

Will do in v2.

>
> > 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@xxxxxxxx>
> This needs a Fixes tag:
> Fixes: b765caf5101a ("xen/arm: support the ARM generic virtual timer")

Ack, will add in v2.

>
> > ---
> >  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)) )
> I think this deserves a comment saying that we must not inject virq masked 
> when
> not pending.

Will add.

Best regards,
Mykola



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.