qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: eddie.dong@intel.com, qemu-devel@nongnu.org, kvm@vger.kernel.org,
	agraf@suse.de
Subject: Re: [Qemu-devel] RFC: ioapic polarity vs. qemu os-x guest
Date: Sun, 16 Feb 2014 13:37:48 +0200	[thread overview]
Message-ID: <20140216113748.GA30056@redhat.com> (raw)
In-Reply-To: <20140214211311.GH29329@ERROL.INI.CMU.EDU>

On Fri, Feb 14, 2014 at 04:13:11PM -0500, Gabriel L. Somlo wrote:
> On Tue, Feb 11, 2014 at 09:54:44PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Feb 11, 2014 at 01:23:31PM -0500, Gabriel L. Somlo wrote:
> > > 1. Regarding KVM and the polarity xor line in the patch above: Does
> > > anyone have experience with any *other* guests which insist on setting
> > > level-triggered interrupt polarity to 1/active-low ? Is that xor line
> > > actually doing anything useful in practice, for any other guest, on
> > > either QEMU or any other platform ?
> > > 
> > > 
> > > 2. Is there anything in QEMU (besides the ACPI DSDT .dsl files) which
> > > has a hardcoded assumption re. "polarity == 0", or active-high, for
> > > level-triggered interrupts? I tried to dig through hw/i386/kvm/ioapic.c
> > > and a bunch of other files, but couldn't isolate anything that I could
> > > "flip" to fix things in userspace.
> > > 
> > > 
> > > Any ideas or suggestions about the appropriate way to move forward would
> > > be much appreciated !!!
> > > 
> > > 
> > > Thanks much,
> > > --Gabriel
> > 
> > I think changing ACPI is the right thing to
> > do really. But we'll need to fix some things
> > first of course.
> 
> So I followed your advice, and was able to boot OS X just fine (but
> booting Linux after this patch still resulted in multiple "no one
> cared" complaints on IRQs 17, 18, 19, etc.:
> 
> diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> index d618e9e..9c52f64 100644
> --- a/hw/i386/q35-acpi-dsdt.dsl
> +++ b/hw/i386/q35-acpi-dsdt.dsl
> @@ -353,7 +353,7 @@ DefinitionBlock (
>          Method(IQCR, 1, Serialized) {
>              // _CRS method - get current settings
>              Name(PRR0, ResourceTemplate() {
> -                Interrupt(, Level, ActiveHigh, Shared) { 0 }
> +                Interrupt(, Level, ActiveLow, Shared) { 0 }
>              })
>              CreateDWordField(PRR0, 0x05, PRRI)
>              Store(And(Arg0, 0x0F), PRRI)
> @@ -365,7 +365,7 @@ DefinitionBlock (
>              Name(_HID, EISAID("PNP0C0F"))                       \
>              Name(_UID, uid)                                     \
>              Name(_PRS, ResourceTemplate() {                     \
> -                Interrupt(, Level, ActiveHigh, Shared) {        \
> +                Interrupt(, Level, ActiveLow, Shared) {        \
>                      5, 10, 11                                   \
>                  }                                               \
>              })                                                  \
> @@ -398,12 +398,12 @@ DefinitionBlock (
>              Name(_HID, EISAID("PNP0C0F"))                       \
>              Name(_UID, uid)                                     \
>              Name(_PRS, ResourceTemplate() {                     \
> -                Interrupt(, Level, ActiveHigh, Shared) {        \
> +                Interrupt(, Level, ActiveLow, Shared) {        \
>                      gsi                                         \
>                  }                                               \
>              })                                                  \
>              Name(_CRS, ResourceTemplate() {                     \
> -                Interrupt(, Level, ActiveHigh, Shared) {        \
> +                Interrupt(, Level, ActiveLow, Shared) {        \
>                      gsi                                         \
>                  }                                               \
>              })                                                  \
> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
> index 51ce12d..fe1527a 100644
> --- a/hw/isa/lpc_ich9.c
> +++ b/hw/isa/lpc_ich9.c
> @@ -206,17 +206,17 @@ static void ich9_lpc_update_pic(ICH9LPCState *lpc, int pic_irq)
>      int i, pic_level;
>  
>      /* The pic level is the logical OR of all the PCI irqs mapped to it */
> -    pic_level = 0;
> +    pic_level = 1;
>      for (i = 0; i < ICH9_LPC_NB_PIRQS; i++) {
>          int tmp_irq;
>          int tmp_dis;
>          ich9_lpc_pic_irq(lpc, i, &tmp_irq, &tmp_dis);
>          if (!tmp_dis && pic_irq == tmp_irq) {
> -            pic_level |= pci_bus_get_irq_level(lpc->d.bus, i);
> +            pic_level &= !pci_bus_get_irq_level(lpc->d.bus, i);
>          }
>      }
>      if (pic_irq == ich9_lpc_sci_irq(lpc)) {
> -        pic_level |= lpc->sci_level;
> +        pic_level &= !lpc->sci_level;
>      }
>  
>      qemu_set_irq(lpc->pic[pic_irq], pic_level);
> --
> 
> However, even on OS X, the Ethernet (e1000) card won't link up at all.
> Fixing that requires another patch:
> 
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index 58ba93b..c7a2c07 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -301,7 +301,7 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val)
>      s->mac_reg[ICS] = val;
>  
>      pending_ints = (s->mac_reg[IMS] & s->mac_reg[ICR]);
> -    if (!s->mit_irq_level && pending_ints) {
> +    if (s->mit_irq_level && pending_ints) {
>          /*
>           * Here we detect a potential raising edge. We postpone raising the
>           * interrupt line if we are inside the mitigation delay window
> @@ -339,7 +339,7 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val)
>          }
>      }
>  
> -    s->mit_irq_level = (pending_ints != 0);
> +    s->mit_irq_level = (pending_ints == 0);
>      pci_set_irq(d, s->mit_irq_level);
>  }
>  

If we really wanted to change it, we could
change pci_set_irq to reverse the polarity.
But I think doing this in PIC is cleaner.


> @@ -393,7 +393,7 @@ static void e1000_reset(void *opaque)
>      timer_del(d->autoneg_timer);
>      timer_del(d->mit_timer);
>      d->mit_timer_on = 0;
> -    d->mit_irq_level = 0;
> +    d->mit_irq_level = 1;
>      d->mit_ide = 0;
>      memset(d->phy_reg, 0, sizeof d->phy_reg);
>      memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init);
> @@ -1324,7 +1324,7 @@ static int e1000_post_load(void *opaque, int version_id)
>      if (!(s->compat_flags & E1000_FLAG_MIT)) {
>          s->mac_reg[ITR] = s->mac_reg[RDTR] = s->mac_reg[RADV] =
>              s->mac_reg[TADV] = 0;
> -        s->mit_irq_level = false;
> +        s->mit_irq_level = true;
>      }
>      s->mit_ide = 0;
>      s->mit_timer_on = false;
> ---
> 
> At this point, I'm beginning to realize that the "ActiveHigh"
> assumption is rather pervasively baked in throughout the QEMU
> source code...
> 
> And I'm wondering whether a ton of changes to make it either
> programatically configurable or change the hard-codded assumption
> to "ActiveLow" would be feasible, welcome, etc... I personally
> would prefer configurable
> (e.g. "-machine foo,kernel_irqchip=on,polarity=high", or some such).
> 
> Thanks much for any ideas,
> --Gabriel

  parent reply	other threads:[~2014-02-16 11:33 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 20:02 [Qemu-devel] [PATCH] Add option to disable FDC from ISA bus and ACPI on i386 Gabriel L. Somlo
2014-01-08 20:38 ` Michael S. Tsirkin
2014-01-08 21:09   ` Gabriel L. Somlo
2014-01-15 11:13     ` Paolo Bonzini
2014-01-08 22:13 ` Paolo Bonzini
2014-01-08 23:39   ` Gabriel L. Somlo
2014-01-09  0:12     ` Alexander Graf
2014-01-09  1:51     ` Michael S. Tsirkin
2014-01-09 18:51       ` Gabriel L. Somlo
2014-01-09 20:12         ` Paolo Bonzini
2014-01-09 21:33           ` Michael S. Tsirkin
2014-01-09 21:58             ` Gabriel L. Somlo
2014-01-09 21:44           ` Gabriel L. Somlo
2014-01-10 12:37             ` Paolo Bonzini
2014-01-10 15:35               ` Gabriel L. Somlo
2014-01-10 16:13                 ` Igor Mammedov
2014-01-17 21:10                   ` [Qemu-devel] RFC: ACPI, HPET._CRS, MacOSX vs. WinXP Gabriel L. Somlo
2014-01-20 11:58                     ` Michael S. Tsirkin
2014-01-20 11:57                       ` Paolo Bonzini
2014-01-20 12:08                         ` Michael S. Tsirkin
2014-01-20 12:16                           ` Paolo Bonzini
2014-01-20 18:54                             ` Gabriel L. Somlo
2014-01-20 20:31                               ` Michael S. Tsirkin
2014-01-20 21:25                                 ` Gabriel L. Somlo
2014-01-21 10:33                                   ` Paolo Bonzini
2014-01-21 11:02                                     ` Michael S. Tsirkin
2014-01-21 11:05                                       ` Paolo Bonzini
2014-01-21 11:44                                         ` Michael S. Tsirkin
2014-01-21 18:11                                           ` [Qemu-devel] [PATCH] ACPI: Add IRQ resource to HPET._CRS on Mac OS X Gabriel L. Somlo
2014-01-21 18:38                                             ` Michael S. Tsirkin
2014-01-24 16:46                                               ` Gabriel L. Somlo
2014-01-24 21:18                                                 ` Alexander Graf
2014-01-25  0:09                                                   ` Gabriel L. Somlo
2014-01-25  9:08                                                     ` Alexander Graf
2014-01-27 22:51                                                       ` Gabriel L. Somlo
2014-01-27 23:51                                                         ` Alexander Graf
2014-01-28 16:45                                                           ` [Qemu-devel] OSX guest support review Gabriel L. Somlo
2014-01-28 16:57                                                             ` Michael S. Tsirkin
2014-01-29 14:17                                                             ` Alexander Graf
2014-01-29 21:36                                                               ` [Qemu-devel] OSX guest vs. kvm ioapic polarity Gabriel L. Somlo
2014-01-29 22:18                                                                 ` Michael S. Tsirkin
2014-01-30 14:18                                                                   ` Gabriel L. Somlo
2014-01-30 19:48                                                                     ` Michael S. Tsirkin
2014-01-30 20:21                                                                       ` Gabriel L. Somlo
2014-01-30 20:28                                                                         ` Michael S. Tsirkin
2014-01-30 20:33                                                                         ` Michael S. Tsirkin
2014-01-30 20:44                                                                           ` Gabriel L. Somlo
2014-02-11 18:23                                                                             ` [Qemu-devel] RFC: ioapic polarity vs. qemu os-x guest Gabriel L. Somlo
2014-02-11 19:54                                                                               ` Michael S. Tsirkin
2014-02-11 21:35                                                                                 ` Gabriel L. Somlo
2014-02-14 21:13                                                                                 ` Gabriel L. Somlo
2014-02-14 21:21                                                                                   ` Alexander Graf
2014-02-14 22:06                                                                                     ` Gabriel L. Somlo
2014-02-14 22:13                                                                                       ` Alexander Graf
2014-02-16 11:18                                                                                         ` Michael S. Tsirkin
2014-02-16 11:41                                                                                         ` Michael S. Tsirkin
2014-02-16 14:47                                                                                           ` Alex Williamson
2014-02-16 16:23                                                                                             ` Michael S. Tsirkin
2014-02-17 17:57                                                                                               ` Gabriel L. Somlo
2014-02-17 18:01                                                                                                 ` Gabriel L. Somlo
2014-02-17 18:06                                                                                                   ` Paolo Bonzini
2014-02-17 19:38                                                                                                     ` Gabriel L. Somlo
2014-02-18  0:58                                                                                                       ` Gabriel L. Somlo
2014-02-27 17:05                                                                                               ` [Qemu-devel] [PATCH RFC] kvm: ignore apic polarity Michael S. Tsirkin
2014-02-27 21:41                                                                                                 ` Gabriel L. Somlo
2014-02-27 22:30                                                                                                   ` Paolo Bonzini
2014-02-27 23:13                                                                                                     ` Gabriel L. Somlo
2014-02-27 23:31                                                                                                       ` Paolo Bonzini
2014-02-28  4:06                                                                                                         ` [Qemu-devel] [RFC PATCH v2] kvm: x86: ignore ioapic polarity Gabriel L. Somlo
2014-02-28 17:23                                                                                                           ` [Qemu-devel] [RFC PATCH] qemu: " Gabriel L. Somlo
2014-02-28 18:57                                                                                                             ` [Qemu-devel] [RFC PATCH v2] " Gabriel L. Somlo
2014-02-28 19:14                                                                                                               ` [Qemu-devel] [PATCH] qemu: x86: report lapic version as 0x14 instead of 0x11 Gabriel L. Somlo
2014-03-01  3:44                                                                                                                 ` Alexander Graf
2014-03-01  4:25                                                                                                                   ` Gabriel L. Somlo
2014-03-01  5:45                                                                                                                     ` Alexander Graf
2014-03-01 14:46                                                                                                                 ` Paolo Bonzini
2014-03-02  0:17                                                                                                                   ` Gabriel L. Somlo
2014-03-02  8:56                                                                                                                     ` Paolo Bonzini
2014-03-02 14:31                                                                                                                       ` Michael S. Tsirkin
2014-03-02 16:02                                                                                                                         ` Michael S. Tsirkin
2014-03-06  7:50                                                                                                                     ` Michael S. Tsirkin
2014-03-02 14:52                                                                                                               ` [Qemu-devel] [RFC PATCH v2] qemu: x86: ignore ioapic polarity Michael S. Tsirkin
2014-03-02 16:15                                                                                                                 ` Gabriel L. Somlo
2014-03-02 17:09                                                                                                                   ` Michael S. Tsirkin
2014-03-06  7:45                                                                                                               ` Michael S. Tsirkin
2014-03-02 14:55                                                                                                           ` [Qemu-devel] [RFC PATCH v2] kvm: " Michael S. Tsirkin
2014-03-13 10:53                                                                                                           ` Paolo Bonzini
2014-03-13 13:43                                                                                                             ` Gabriel L. Somlo
2014-02-28  4:55                                                                                                     ` [Qemu-devel] [PATCH RFC] kvm: ignore apic polarity Michael S. Tsirkin
2014-02-28  8:10                                                                                                       ` Paolo Bonzini
2014-02-28  8:11                                                                                                       ` Paolo Bonzini
2014-03-01  5:03                                                                                                 ` Alex Williamson
2014-02-16 11:34                                                                                   ` [Qemu-devel] RFC: ioapic polarity vs. qemu os-x guest Michael S. Tsirkin
2014-02-16 15:12                                                                                     ` Peter Maydell
2014-02-16 11:37                                                                                   ` Michael S. Tsirkin [this message]
2014-01-29 23:13                                                                 ` [Qemu-devel] OSX guest vs. kvm ioapic polarity Alexander Graf
2014-01-30 15:56                                                                   ` Gabriel L. Somlo
2014-01-28 20:40                                                       ` [Qemu-devel] osx bootloader Gabriel L. Somlo
2014-01-28 22:51                                                         ` BALATON Zoltan
2014-01-29  3:07                                                           ` Gabriel L. Somlo
2014-01-29 11:29                                                             ` BALATON Zoltan
2014-01-29 14:53                                                               ` Gabriel L. Somlo
2014-01-29 15:00                                                                 ` Alexander Graf
2014-01-30  0:15                                                                   ` BALATON Zoltan
2014-02-01 17:43                                                                   ` BALATON Zoltan
2014-02-01  0:38                                                                 ` BALATON Zoltan
2014-02-01 10:07                                                                   ` Alexander Graf
2014-02-01 14:35                                                                     ` [Qemu-devel] OVMF with q35 (was: osx bootloader) BALATON Zoltan
2014-02-01 15:13                                                                       ` Alexander Graf
2014-02-01 17:38                                                                         ` BALATON Zoltan
2014-02-03  7:47                                                                       ` Gerd Hoffmann
2014-02-01 21:19                                                                   ` [Qemu-devel] osx bootloader Paolo Bonzini
2014-02-02  2:18                                                                     ` BALATON Zoltan
2014-01-29 12:10                                                             ` BALATON Zoltan
2014-01-29 14:20                                                             ` Alexander Graf
2014-01-21 11:38                                   ` [Qemu-devel] RFC: ACPI, HPET._CRS, MacOSX vs. WinXP Michael S. Tsirkin
2014-01-20 20:23                             ` Michael S. Tsirkin
2014-01-20 12:03                     ` Igor Mammedov
2014-01-09  8:46   ` [Qemu-devel] [PATCH] Add option to disable FDC from ISA bus and ACPI on i386 Markus Armbruster
2014-01-09 10:24     ` Paolo Bonzini
2014-01-31 19:03       ` [Qemu-devel] [RFC PATCH v2] Add option to switch off FDC Gabriel L. Somlo
2014-01-31 19:39         ` Eric Blake
2014-02-02 13:47           ` Michael S. Tsirkin
2014-02-10 14:10             ` Marcel Apfelbaum

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=20140216113748.GA30056@redhat.com \
    --to=mst@redhat.com \
    --cc=agraf@suse.de \
    --cc=eddie.dong@intel.com \
    --cc=gsomlo@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).