All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sander Eikelenboom <linux@eikelenboom.it>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Keir Fraser <keir@xen.org>,
	Suravee Suthikulanit <suravee.suthikulpanit@amd.com>,
	xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH RFC 2/2] AMD IOMMU: allow command line overrides for broken IVRS tables
Date: Tue, 27 Aug 2013 11:52:36 +0200	[thread overview]
Message-ID: <759475415.20130827115236@eikelenboom.it> (raw)
In-Reply-To: <521C79F502000078000EEA56@nat28.tlf.novell.com>


Tuesday, August 27, 2013, 10:05:41 AM, you wrote:

> With there being so many systems with broken ACPI tables, and with it
> generally being known what's wrong with those tables, give people a
> handle to overcome the resulting disabling of their IOMMUs.

> Inspired by Linux side patches providing similar functionality.

> TODO: documentation

Hi Jan,

Would the syntax be the same as linux ?
f.e. ivrs_ioapic[6]=00:14.0 for my case ?

I'm asking because using it on the command line seems to enable the iommu fine (which it shouldn't without the override), but i don't seem to see the
"IVHD: Command line override present for IO-APIC %#x" in my xl dmesg... 

--
Sander


> Suggested-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -81,9 +81,15 @@ void __init cmdline_parse(const char *cm
>          /* Search for value part of a key=value option. */
>          optval = strchr(opt, '=');
>          if ( optval != NULL )
> +        {
>              *optval++ = '\0'; /* nul-terminate the option value */
> +            q = strpbrk(opt, "([{<");
> +        }
>          else
> +        {
>              optval = q;       /* default option value is empty string */
> +            q = NULL;
> +        }
>  
>          /* Boolean parameters can be inverted with 'no-' prefix. */
>          bool_assert = !!strncmp("no-", optkey, 3);
> @@ -93,7 +99,17 @@ void __init cmdline_parse(const char *cm
>          for ( param = &__setup_start; param < &__setup_end; param++ )
>          {
>              if ( strcmp(param->name, optkey) )
> +            {
> +                if ( param->type == OPT_CUSTOM && q &&
> +                     strlen(param->name) == q + 1 - opt &&
> +                     !strncmp(param->name, opt, q + 1 - opt) )
> +                {
> +                    optval[-1] = '=';
> +                    ((void (*)(const char *))param->var)(q);
> +                    optval[-1] = '\0';
> +                }
>                  continue;
> +            }
>  
>              switch ( param->type )
>              {
> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
> @@ -633,6 +633,50 @@ static u16 __init parse_ivhd_device_exte
>      return dev_length;
>  }
>  
> +static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
> +
> +static void __init parse_ivrs_ioapic(char *str)
> +{
> +    const char *s = str;
> +    unsigned long id;
> +    unsigned int seg, bus, dev, func;
> +
> +    ASSERT(*s == '[');
> +    id = simple_strtoul(s + 1, &s, 0);
+    if ( id >>= ARRAY_SIZE(ioapic_sbdf) || *s != ']' || *++s != '=' )
> +        return;
> +
> +    s = parse_pci(s + 1, &seg, &bus, &dev, &func);
> +    if ( !s || *s )
> +        return;
> +
> +    ioapic_sbdf[id].bdf = PCI_BDF(bus, dev, func);
> +    ioapic_sbdf[id].seg = seg;
> +    __set_bit(id, ioapic_cmdline);
> +}
> +custom_param("ivrs_ioapic[", parse_ivrs_ioapic);
> +
> +static void __init parse_ivrs_hpet(char *str)
> +{
> +    const char *s = str;
> +    unsigned long id;
> +    unsigned int seg, bus, dev, func;
> +
> +    ASSERT(*s == '[');
> +    id = simple_strtoul(s + 1, &s, 0);
> +    if ( id != (typeof(hpet_sbdf.id))id || *s != ']' || *++s != '=' )
> +        return;
> +
> +    s = parse_pci(s + 1, &seg, &bus, &dev, &func);
> +    if ( !s || *s )
> +        return;
> +
> +    hpet_sbdf.bdf = PCI_BDF(bus, dev, func);
> +    hpet_sbdf.seg = seg;
> +    hpet_sbdf.cmdline = 1;
> +}
> +custom_param("ivrs_hpet[", parse_ivrs_hpet);
> +
>  static u16 __init parse_ivhd_device_special(
>      const struct acpi_ivrs_device8c *special, u16 seg,
>      u16 header_length, u16 block_length, struct amd_iommu *iommu)
> @@ -674,7 +718,17 @@ static u16 __init parse_ivhd_device_spec
>              if ( IO_APIC_ID(apic) != special->handle )
>                  continue;
>  
> -            if ( ioapic_sbdf[special->handle].pin_2_idx )
> +            if ( special->handle >= ARRAY_SIZE(ioapic_sbdf) )
> +            {
> +                printk(XENLOG_ERR "IVHD Error: IO-APIC %#x entry beyond bounds\n",
> +                       special->handle);
> +                return 0;
> +            }
> +
> +            if ( test_bit(special->handle, ioapic_cmdline) )
> +                AMD_IOMMU_DEBUG("IVHD: Command line override present for IO-APIC %#x\n",
> +                                special->handle);
> +            else if ( ioapic_sbdf[special->handle].pin_2_idx )
>              {
>                  if ( ioapic_sbdf[special->handle].bdf == bdf &&
>                       ioapic_sbdf[special->handle].seg == seg )
> @@ -717,14 +771,18 @@ static u16 __init parse_ivhd_device_spec
>          break;
>      case ACPI_IVHD_HPET:
>          /* set device id of hpet */
> -        if ( hpet_sbdf.iommu )
> +        if ( hpet_sbdf.iommu ||
> +             (hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) )
>          {
>              printk(XENLOG_WARNING "Only one IVHD HPET entry is supported\n");
>              break;
>          }
>          hpet_sbdf.id = special->handle;
> -        hpet_sbdf.bdf = bdf;
> -        hpet_sbdf.seg = seg;
> +        if ( !hpet_sbdf.cmdline )
> +        {
> +            hpet_sbdf.bdf = bdf;
> +            hpet_sbdf.seg = seg;
> +        }
>          hpet_sbdf.iommu = iommu;
>          break;
>      default:
> @@ -935,21 +993,23 @@ static int __init parse_ivrs_table(struc
>               ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
>              continue;
>  
> -        printk(XENLOG_ERR "IVHD Error: no information for IO-APIC %#x\n",
> -               IO_APIC_ID(apic));
> -        if ( amd_iommu_perdev_intremap )
> -            error = -ENXIO;
> -        else
> +        if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )
>          {
> -            ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx = xmalloc_array(
> -                u16, nr_ioapic_entries[apic]);
> -            if ( !ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
> -            {
> -                printk(XENLOG_ERR "IVHD Error: Out of memory\n");
> -                error = -ENOMEM;
> -            }
> +            printk(XENLOG_ERR "IVHD Error: no information for IO-APIC %#x\n",
> +                   IO_APIC_ID(apic));
> +            if ( amd_iommu_perdev_intremap )
> +                return -ENXIO;
> +        }
> +
> +        ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx = xmalloc_array(
> +            u16, nr_ioapic_entries[apic]);
> +        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
>              memset(ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx, -1,
>                     nr_ioapic_entries[apic] * sizeof(*ioapic_sbdf->pin_2_idx));
> +        else
> +        {
> +            printk(XENLOG_ERR "IVHD Error: Out of memory\n");
> +            error = -ENOMEM;
>          }
>      }
>  
> --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
> +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
> @@ -108,6 +108,7 @@ extern struct ioapic_sbdf {
>  
>  extern struct hpet_sbdf {
>      u16 bdf, seg, id;
> +    bool_t cmdline;
>      struct amd_iommu *iommu;
>  } hpet_sbdf;
>  

  reply	other threads:[~2013-08-27  9:52 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 20:50 [xen-unstable] Commit 2ca9fbd739b8a72b16dd790d0fff7b75f5488fb8 AMD IOMMU: allocate IRTE entries instead of using a static mapping, makes dom0 boot process stall several times Sander Eikelenboom
2013-08-05  7:48 ` Jan Beulich
2013-08-06 15:47   ` Suravee Suthikulanit
2013-08-15 14:43     ` Sander Eikelenboom
2013-08-15 15:15       ` Jan Beulich
2013-08-15 23:22         ` Sander Eikelenboom
2013-08-15 23:41           ` Sander Eikelenboom
2013-08-16  7:21             ` Jan Beulich
2013-08-16  7:42               ` Sander Eikelenboom
2013-08-16  8:03                 ` Jan Beulich
2013-08-16  8:40                   ` Sander Eikelenboom
2013-08-16  9:18                     ` Jan Beulich
2013-08-16 10:44                       ` Sander Eikelenboom
2013-08-16 13:15                         ` Jan Beulich
2013-08-16 13:22                           ` Sander Eikelenboom
2013-08-16 14:43                           ` Sander Eikelenboom
2013-08-16 15:51                           ` Sander Eikelenboom
2013-08-22 22:51                           ` Sander Eikelenboom
2013-08-22 23:42                             ` Sander Eikelenboom
2013-08-23 14:28                             ` Jan Beulich
2013-08-23 14:45                               ` Sander Eikelenboom
2013-08-23 15:05                               ` Sander Eikelenboom
2013-08-23 15:11                                 ` Jan Beulich
2013-08-23 15:21                                   ` Jan Beulich
2013-08-23 15:48                                     ` Sander Eikelenboom
2013-08-23 16:01                                       ` Jan Beulich
2013-08-23 16:06                                         ` Sander Eikelenboom
2013-08-26 15:10                                           ` Suravee Suthikulpanit
2013-08-26 15:33                                             ` Jan Beulich
2013-08-23 17:01                                         ` Sander Eikelenboom
2013-08-23 15:29                                   ` Sander Eikelenboom
2013-08-26  6:59                                     ` Jan Beulich
2013-08-26  9:51                                       ` Sander Eikelenboom
2013-08-26 10:33                                         ` Jan Beulich
2013-08-26 11:07                                           ` Sander Eikelenboom
2013-08-26 11:23                                             ` Jan Beulich
2013-08-26 12:34                                               ` Sander Eikelenboom
2013-08-26 14:15                                                 ` Jan Beulich
2013-08-26 14:35                                                   ` Sander Eikelenboom
2013-08-26 11:21                                           ` Sander Eikelenboom
2013-08-26 11:25                                             ` Jan Beulich
2013-08-26 11:29                                             ` Jan Beulich
2013-08-26 11:36                                               ` Sander Eikelenboom
2013-08-26 15:37                                                 ` Suravee Suthikulpanit
2013-08-26 15:50                                                   ` Suravee Suthikulpanit
2013-08-27  8:23                                                     ` Jan Beulich
2013-08-26 15:50                                                   ` Jan Beulich
2013-08-26 16:19                                                     ` Sander Eikelenboom
2013-08-27  8:00                             ` [PATCH RFC 0/2] AMD IOMMU: allow command line overrides for broken IVRS tables Jan Beulich
2013-08-27  8:05                               ` [PATCH RFC 1/2] PCI: centralize parsing of device coordinates in command line options Jan Beulich
2013-08-27  8:05                               ` [PATCH RFC 2/2] AMD IOMMU: allow command line overrides for broken IVRS tables Jan Beulich
2013-08-27  9:52                                 ` Sander Eikelenboom [this message]
2013-08-27 11:09                                   ` Sander Eikelenboom
2013-08-27 12:04                                     ` Jan Beulich
2013-08-27 13:32                                       ` Sander Eikelenboom
2013-08-27 13:55                                         ` Jan Beulich
2013-08-27 14:15                                           ` Andrew Cooper
2013-08-27 16:17                                             ` Jan Beulich
2013-08-27 16:19                                               ` Sander Eikelenboom
2013-08-27 14:11                                       ` Jan Beulich
2013-08-27 14:15                                         ` Sander Eikelenboom
2013-08-27 15:59                                           ` Jan Beulich
2013-08-27 16:14                                             ` Sander Eikelenboom
2013-08-27 16:21                                               ` Jan Beulich
2013-08-27 16:30                                                 ` Sander Eikelenboom
2013-08-27 17:09                                                   ` Sander Eikelenboom
2013-08-28  8:06                                                   ` Jan Beulich
2013-08-28 14:59                                 ` Suravee Suthikulpanit
2013-08-28 15:18                                   ` Jan Beulich
2013-08-27 18:07                               ` [PATCH RFC 0/2] " Keir Fraser
     [not found] <521E36AF02000078000EF2FD@nat28.tlf.novell.com>
2013-08-28 17:33 ` [RESEND] Re: [PATCH RFC 2/2] " Suravee Suthikulpanit
2013-08-29  6:22   ` Jan Beulich

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=759475415.20130827115236@eikelenboom.it \
    --to=linux@eikelenboom.it \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=keir@xen.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=xen-devel@lists.xen.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.