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

Re: [PATCH v2 2/5] x86/ioapic: RTE modifications must use ioapic_write_entry


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 19 Jul 2023 17:20:24 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FD0RRnWoxDBvYsETeuXA8Jf8a3WiOG2ldK0TwrHFqUY=; b=eTbx5wuL76gXBh2548sHfQRgXCBNgmuhCta1LFlQszOpwFwFK84iM/uQH1UD0fpmIzSzdoGAgCwRkrHrGVAg7rBaeWWeNIjC7ENtAaeHZdpUmFac98LgZRz95sohH2ZqIA4kH/6XXVmqamedWBkjmNCcE/A+5UWJSrgqCH2+zFt/YNoyD3nFI/nVtPfJkqkG/IX2e96O3eMfYyvkBXo77f0TPtBXZPqIlIlGcMdtN6WWLINBcj5hi+d3QJIN0ntIcXWsRos9bzzxehG5ZTXVuAxV0G4Xj5qC/vxPmI657unFvxMXAmqMvOQYmW9ng3VoYrWY0nYrgE+tm9KprlWezg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H41xenTo4DTvoGt07uWsvBoLnU8psDvfQlj/jfwAYPp2X31m5r3MTCaWvFgx4sKI85LRI/n5Cvk4m/1O3ZlHYpMMfe4aHbVsfM8tZLOLtOeFXn55WnouQ+LRhf0V77v5dSpZwR/35/nqi4NiSccE4AKpS9KEXXnAgyf2pUxbc/tUquSVHcKPsN4anzOd6xJbg85MJNeEt0J4FozmmhrbpkE/JaeibbyKCVSxdSE+AnIFc+US/4RrgJW4TRn+lngwEc8O4OEiCcATTAeZEPZ4wd1YfRJbieTCYLbQAcZTV50TuXQzPzCyiphDMyrBRHeJ9mHEYCtgwiZ5YapjFb1QEw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 19 Jul 2023 15:21:04 +0000
  • Ironport-data: A9a23:f88kTq1kkFbWpBKx8vbD5fRwkn2cJEfYwER7XKvMYLTBsI5bpzwBy TdKXj2DaffcYzb9coh+PYvi9kIF7J6DyIdmQAc+pC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8teTb8XuDgNyo4GlD5gNnNKgR1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfCkhr7 vFAGBc0Uzegt/iZn7zkatBDv5F2RCXrFNt3VnBI6xj8VapjbbWdBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPGJRpSJlMQD5F4l+Ct7pX9W2QA9BTJ+uxouC6PnGSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iv12LGVw36iBur+EpWUqOVyj0ao+1UXVhA9BQWSgfaygVSHDoc3x 0s8v3BGQbIJ3E6hQ8T5Xha4iGWZpRNaUN1Ve8Ul7Cmdx6yS5ByWbkAUQzgEZNE4ucseQT0xy kTPj97vHSZosrCeVTSa7Lj8kN+pES0cLGtHaSpaSwIAu4XnuNtr0kKJSct/GqmoiNGzASv33 z2BsCk5gfMUkNIP0KK4u1vAhlpAu6T0c+L83S2PNkrN0++zTNXNi1CAgbQD0ct9EQ==
  • Ironport-hdrordr: A9a23:E/T4mKw2iN8H2i5GTM5PKrPw1r1zdoMgy1knxilNoHxuH/BwWf rPoB17726RtN91YhsdcL+7V5VoLUmzyXcX2/h1AV7BZniEhILAFugLgbcKqweKJ8SUzJ8+6U 4PSclD4N2bNykGsS75ijPIb+rJFrO8gd+VbeS19QYScelzAZsQiDuQkmygYzZLrA8tP+teKL OsovBpihCHYnotYsGyFhA+LpL+T42iruOeXfYebSRXkDWzsQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Jul 18, 2023 at 05:40:18PM +0200, Jan Beulich wrote:
> On 18.07.2023 14:43, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/io_apic.c
> > +++ b/xen/arch/x86/io_apic.c
> > @@ -269,15 +269,15 @@ void __ioapic_write_entry(
> >  {
> >      union entry_union eu = { .entry = e };
> >  
> > -    if ( raw )
> > +    if ( raw || !iommu_intremap )
> >      {
> >          __io_apic_write(apic, 0x11 + 2 * pin, eu.w2);
> >          __io_apic_write(apic, 0x10 + 2 * pin, eu.w1);
> >      }
> >      else
> >      {
> > -        io_apic_write(apic, 0x11 + 2 * pin, eu.w2);
> > -        io_apic_write(apic, 0x10 + 2 * pin, eu.w1);
> > +        iommu_update_ire_from_apic(apic, 0x11 + 2 * pin, eu.w2);
> > +        iommu_update_ire_from_apic(apic, 0x10 + 2 * pin, eu.w1);
> >      }
> >  }
> 
> I think __ioapic_read_entry() wants updating similarly, so that both
> remain consistent.

My plan was to deal with __ioapic_read_entry() separately, as I would
also like to convert iommu_read_apic_from_ire() to get passed a pin
instead of a register, but I could make your requested adjustment here
for consistency with __ioapic_write_entry().

> > @@ -433,16 +433,17 @@ static void modify_IO_APIC_irq(unsigned int irq, 
> > unsigned int enable,
> >                                 unsigned int disable)
> >  {
> >      struct irq_pin_list *entry = irq_2_pin + irq;
> > -    unsigned int pin, reg;
> >  
> >      for (;;) {
> > -        pin = entry->pin;
> > +        unsigned int pin = entry->pin;
> > +        struct IO_APIC_route_entry rte;
> > +
> >          if (pin == -1)
> >              break;
> > -        reg = io_apic_read(entry->apic, 0x10 + pin*2);
> > -        reg &= ~disable;
> > -        reg |= enable;
> > -        io_apic_modify(entry->apic, 0x10 + pin*2, reg);
> > +        rte = __ioapic_read_entry(entry->apic, pin, false);
> > +        rte.raw &= ~(uint64_t)disable;
> > +        rte.raw |= enable;
> > +        __ioapic_write_entry(entry->apic, pin, false, rte);
> 
> While this isn't going to happen overly often, ...
> 
> > @@ -584,16 +585,16 @@ set_ioapic_affinity_irq(struct irq_desc *desc, const 
> > cpumask_t *mask)
> >              dest = SET_APIC_LOGICAL_ID(dest);
> >          entry = irq_2_pin + irq;
> >          for (;;) {
> > -            unsigned int data;
> > +            struct IO_APIC_route_entry rte;
> > +
> >              pin = entry->pin;
> >              if (pin == -1)
> >                  break;
> >  
> > -            io_apic_write(entry->apic, 0x10 + 1 + pin*2, dest);
> > -            data = io_apic_read(entry->apic, 0x10 + pin*2);
> > -            data &= ~IO_APIC_REDIR_VECTOR_MASK;
> > -            data |= MASK_INSR(desc->arch.vector, 
> > IO_APIC_REDIR_VECTOR_MASK);
> > -            io_apic_modify(entry->apic, 0x10 + pin*2, data);
> > +            rte = __ioapic_read_entry(entry->apic, pin, false);
> > +            rte.dest.dest32 = dest;
> > +            rte.vector = desc->arch.vector;
> > +            __ioapic_write_entry(entry->apic, pin, false, rte);
> 
> ... this makes me wonder whether there shouldn't be an
> __ioapic_modify_entry() capable of suppressing one of the two
> writes (but still being handed the full RTE).

We would then need the original RTE to be passed to
__ioapic_modify_entry() in order for it to decide whether one of the
accesses can be eliminated (as I don't think we want to read the RTE
to check for differences, as we would then perform even more
accesses).

This would only be relevant for systems without IOMMU IRTEs, as
otherwise the IO-APIC RTE gets modified by the IOMMU handlers.

Thanks, Roger.



 


Rackspace

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