All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Willi Junga <xenproject@ymy.be>,
	David Woodhouse <dwmw@amazon.co.uk>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v4] x86/io-apic: fix directed EOI when using AMD-Vi interrupt remapping
Date: Mon, 4 Nov 2024 12:20:00 +0100	[thread overview]
Message-ID: <Zyit4HLFOS5GZ-Ze@macbook> (raw)
In-Reply-To: <64059351-dd82-4393-8852-ff60d6d8d5bb@suse.com>

On Mon, Nov 04, 2024 at 10:56:36AM +0100, Jan Beulich wrote:
> On 31.10.2024 09:57, Roger Pau Monne wrote:
> > @@ -71,6 +72,24 @@ static int apic_pin_2_gsi_irq(int apic, int pin);
> >  
> >  static vmask_t *__read_mostly vector_map[MAX_IO_APICS];
> >  
> > +/*
> > + * Store the EOI handle when using interrupt remapping.
> > + *
> > + * If using AMD-Vi interrupt remapping the IO-APIC redirection entry remapped
> > + * format repurposes the vector field to store the offset into the Interrupt
> > + * Remap table.  This breaks directed EOI, as the CPU vector no longer matches
> > + * the contents of the RTE vector field.  Add a translation cache so that
> > + * directed EOI uses the value in the RTE vector field when interrupt remapping
> > + * is enabled.
> > + *
> > + * Intel VT-d Xen code still stores the CPU vector in the RTE vector field when
> > + * using the remapped format, but use the translation cache uniformly in order
> > + * to avoid extra logic to differentiate between VT-d and AMD-Vi.
> > + *
> > + * The matrix is accessed as [#io-apic][#pin].
> > + */
> > +static uint8_t **io_apic_pin_eoi;
> 
> __ro_after_init?

Oh, yes indeed, allocations are static after init.

> > @@ -273,6 +292,17 @@ void __ioapic_write_entry(
> >      {
> >          __io_apic_write(apic, 0x11 + 2 * pin, eu.w2);
> >          __io_apic_write(apic, 0x10 + 2 * pin, eu.w1);
> > +        /*
> > +         * Might be called before io_apic_pin_eoi is allocated.  Entry will be
> > +         * initialized to the RTE value once the cache is allocated.
> 
> With the movement of the allocation to enable_IO_APIC(), isn't this part of
> the comment stale now?

There are still paths that call __ioapic_write_entry() before
enable_IO_APIC().  See for example how x2apic_bsp_setup() makes use of
save_IO_APIC_setup() ahead of enable_IO_APIC().

> > +         * The vector field is only cached for raw RTE writes when using IR.
> > +         * In that case the vector field might have been repurposed to store
> > +         * something different than the CPU vector, and hence need to be cached
> > +         * for performing EOI.
> > +         */
> > +        if ( io_apic_pin_eoi )
> > +            io_apic_pin_eoi[apic][pin] = e.vector;
> 
> The conditional here is necessary anyway, isn't it (for the allocation
> being conditional itself)?

Indeed, the matrix won't be allocated if interrupt remapping is not
enabled.

> With the adjustments (or clarification of why they cannot be made)
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks.

> If the adjustments can be confirmed I'd also be happy to make them while
> committing, to save another round-trip.

I agree with the __ro_after_init, see my reply to the code comment.

Regards, Roger.


      reply	other threads:[~2024-11-04 11:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31  8:57 [PATCH v4] x86/io-apic: fix directed EOI when using AMD-Vi interrupt remapping Roger Pau Monne
2024-11-02  3:56 ` Marek Marczykowski-Górecki
2024-11-04  9:56 ` Jan Beulich
2024-11-04 11:20   ` Roger Pau Monné [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=Zyit4HLFOS5GZ-Ze@macbook \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dwmw@amazon.co.uk \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xenproject@ymy.be \
    /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.