[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: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 18 Jul 2023 17:40:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=iGNqzj5auuECKCtrg/wRT+UMA+m5RQVhzkueY9/jP3o=; b=YT7JGXzoqnXOuwW0dTo1kxF9qgJcy7hQGWFRczuRXSp7ko+sU4n+Ri1xFp3FU1zJEQJ4gb36rVCjJ4sIMY8LQxurTP0uuGW98RywnUJAoqOkQvHNiVgvDnLAxvBGqWydUxInlZlV8ghAzUe3pH8y6XAmAaT1D2nfg5f4GNPdWJGdp0VsAgCgjC6moMcXRvhWMtRgOBFauzlht4Mb8SfvyA9sp6m2dCqRPXB1dudRhWiRNedrxrbZgWAqszuGxxhQp64eYBcoS3+upg74oSYBXEcERGVAzFLiTe5OifgQ83On8tsGZpxKD2VBnMN5pQcIknuG103VOxxM3hXyns1f3w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IlP9YKq5WMTz9lrJVM7/r/vs2hV1wC33T0GzD0lCE8LbwIRv0j2YHCy7svl6DFnkvZT6vRuT2/y7Gj4dwjV+qmOmRPZS70ZCHhhpIRXcBdtrUQRNwto3ATidBR40IYsMfkC3m15emzpccIb+OqsNxEasnUrkjZ0uQ7a4gLk2U90Rp5yFtfu3k1d137dbOUvGiFgnuwwewlBxMZ8CuDRF2fk7T7GCfamGdbWSAN1laSzY6rSi0pUyQlwAQVm2ek0u3lq7OHjeNwrXc5/A8EJKoVckqEbCVY7fIS00kXpI1vK7AoqVAL1NklQ6D6mr5NqiFnFeW+3mYLfLgCQRQYIxAg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 18 Jul 2023 15:40:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

> @@ -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).

Jan



 


Rackspace

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