Merge tag 'stable/for-linus-3.5-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jun 2012 00:17:15 +0000 (17:17 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jun 2012 00:17:15 +0000 (17:17 -0700)
Pull five Xen bug-fixes from Konrad Rzeszutek Wilk:

 - When booting as PVHVM we would try to use PV console - but would not validate
   the parameters causing us to crash during restore b/c we re-use the wrong event
   channel.
 - When booting on machines with SR-IOV PCI bridge we didn't check for the bridge
   and tried to use it.
 - Under AMD machines would advertise the APERFMPERF resulting in needless amount
   of MSRs from the guest.
 - A global value (xen_released_pages) was not subtracted at bootup when pages
   were added back in. This resulted in the balloon worker having the wrong
   account of how many pages were truly released.
 - Fix dead-lock when xen-blkfront is run in the same domain as xen-blkback.

* tag 'stable/for-linus-3.5-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
  xen: mark local pages as FOREIGN in the m2p_override
  xen/setup: filter APERFMPERF cpuid feature out
  xen/balloon: Subtract from xen_released_pages the count that is populated.
  xen/pci: Check for PCI bridge before using it.
  xen/events: Add WARN_ON when quick lookup found invalid type.
  xen/hvc: Check HVM_PARAM_CONSOLE_[EVTCHN|PFN] for correctness.
  xen/hvc: Fix error cases around HVM_PARAM_CONSOLE_PFN
  xen/hvc: Collapse error logic.

1  2 
arch/x86/xen/enlighten.c
drivers/xen/events.c

diff --combined arch/x86/xen/enlighten.c
index e74df9548a025c2d66b3052f8ac0002695e59498,272ebd0ce3266468d54314d514b405775b979299..ff962d4b821e5162415fa06ddf75e8c57d498b51
@@@ -64,7 -64,6 +64,7 @@@
  #include <asm/stackprotector.h>
  #include <asm/hypervisor.h>
  #include <asm/mwait.h>
 +#include <asm/pci_x86.h>
  
  #ifdef CONFIG_ACPI
  #include <linux/acpi.h>
@@@ -209,6 -208,9 +209,9 @@@ static void __init xen_banner(void
               xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
  }
  
+ #define CPUID_THERM_POWER_LEAF 6
+ #define APERFMPERF_PRESENT 0
  static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
  static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
  
@@@ -242,6 -244,11 +245,11 @@@ static void xen_cpuid(unsigned int *ax
                *dx = cpuid_leaf5_edx_val;
                return;
  
+       case CPUID_THERM_POWER_LEAF:
+               /* Disabling APERFMPERF for kernel usage */
+               maskecx = ~(1 << APERFMPERF_PRESENT);
+               break;
        case 0xb:
                /* Suppress extended topology stuff */
                maskebx = 0;
  
  static bool __init xen_check_mwait(void)
  {
 -#ifdef CONFIG_ACPI
 +#if defined(CONFIG_ACPI) && !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) && \
 +      !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
        struct xen_platform_op op = {
                .cmd                    = XENPF_set_processor_pminfo,
                .u.set_pminfo.id        = -1,
@@@ -353,6 -359,7 +361,6 @@@ static void __init xen_init_cpuid_mask(
        /* Xen will set CR4.OSXSAVE if supported and not disabled by force */
        if ((cx & xsave_mask) != xsave_mask)
                cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */
 -
        if (xen_check_mwait())
                cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
  }
@@@ -812,40 -819,9 +820,40 @@@ static void xen_io_delay(void
  }
  
  #ifdef CONFIG_X86_LOCAL_APIC
 +static unsigned long xen_set_apic_id(unsigned int x)
 +{
 +      WARN_ON(1);
 +      return x;
 +}
 +static unsigned int xen_get_apic_id(unsigned long x)
 +{
 +      return ((x)>>24) & 0xFFu;
 +}
  static u32 xen_apic_read(u32 reg)
  {
 -      return 0;
 +      struct xen_platform_op op = {
 +              .cmd = XENPF_get_cpuinfo,
 +              .interface_version = XENPF_INTERFACE_VERSION,
 +              .u.pcpu_info.xen_cpuid = 0,
 +      };
 +      int ret = 0;
 +
 +      /* Shouldn't need this as APIC is turned off for PV, and we only
 +       * get called on the bootup processor. But just in case. */
 +      if (!xen_initial_domain() || smp_processor_id())
 +              return 0;
 +
 +      if (reg == APIC_LVR)
 +              return 0x10;
 +
 +      if (reg != APIC_ID)
 +              return 0;
 +
 +      ret = HYPERVISOR_dom0_op(&op);
 +      if (ret)
 +              return 0;
 +
 +      return op.u.pcpu_info.apic_id << 24;
  }
  
  static void xen_apic_write(u32 reg, u32 val)
@@@ -883,8 -859,6 +891,8 @@@ static void set_xen_basic_apic_ops(void
        apic->icr_write = xen_apic_icr_write;
        apic->wait_icr_idle = xen_apic_wait_icr_idle;
        apic->safe_wait_icr_idle = xen_safe_apic_wait_icr_idle;
 +      apic->set_apic_id = xen_set_apic_id;
 +      apic->get_apic_id = xen_get_apic_id;
  
  #ifdef CONFIG_SMP
        apic->send_IPI_allbutself = xen_send_IPI_allbutself;
@@@ -1116,10 -1090,7 +1124,10 @@@ static const struct pv_cpu_ops xen_cpu_
        .wbinvd = native_wbinvd,
  
        .read_msr = native_read_msr_safe,
 +      .rdmsr_regs = native_rdmsr_safe_regs,
        .write_msr = xen_write_msr_safe,
 +      .wrmsr_regs = native_wrmsr_safe_regs,
 +
        .read_tsc = native_read_tsc,
        .read_pmc = native_read_pmc,
  
@@@ -1408,17 -1379,13 +1416,17 @@@ asmlinkage void __init xen_start_kernel
                xen_start_info->console.domU.mfn = 0;
                xen_start_info->console.domU.evtchn = 0;
  
 +              xen_init_apic();
 +
                /* Make sure ACS will be enabled */
                pci_request_acs();
  
                xen_acpi_sleep_register();
        }
 -              
 -
 +#ifdef CONFIG_PCI
 +      /* PCI BIOS service won't work from a PV guest. */
 +      pci_probe &= ~PCI_PROBE_BIOS;
 +#endif
        xen_raw_console_write("about to get started...\n");
  
        xen_setup_runstate_info(0);
diff --combined drivers/xen/events.c
index 6908e4ce2a0d69aa67ca0e11251d834770bbd68c,af8b8fbd9d88778e198811b8a3369917ae01ca07..7595581d032cc9d9c5a7f04ee12b861dc76051ee
@@@ -274,7 -274,7 +274,7 @@@ static unsigned int cpu_from_evtchn(uns
  
  static bool pirq_check_eoi_map(unsigned irq)
  {
 -      return test_bit(irq, pirq_eoi_map);
 +      return test_bit(pirq_from_irq(irq), pirq_eoi_map);
  }
  
  static bool pirq_needs_eoi_flag(unsigned irq)
@@@ -827,6 -827,9 +827,9 @@@ int bind_evtchn_to_irq(unsigned int evt
                                              handle_edge_irq, "event");
  
                xen_irq_info_evtchn_init(irq, evtchn);
+       } else {
+               struct irq_info *info = info_for_irq(irq);
+               WARN_ON(info == NULL || info->type != IRQT_EVTCHN);
        }
  
  out:
@@@ -862,6 -865,9 +865,9 @@@ static int bind_ipi_to_irq(unsigned in
                xen_irq_info_ipi_init(cpu, irq, evtchn, ipi);
  
                bind_evtchn_to_cpu(evtchn, cpu);
+       } else {
+               struct irq_info *info = info_for_irq(irq);
+               WARN_ON(info == NULL || info->type != IRQT_IPI);
        }
  
   out:
@@@ -939,6 -945,9 +945,9 @@@ int bind_virq_to_irq(unsigned int virq
                xen_irq_info_virq_init(cpu, irq, evtchn, virq);
  
                bind_evtchn_to_cpu(evtchn, cpu);
+       } else {
+               struct irq_info *info = info_for_irq(irq);
+               WARN_ON(info == NULL || info->type != IRQT_VIRQ);
        }
  
  out: