Commit 18cb657c authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'stable/xen-pcifront-0.8.2' of...

Merge branch 'stable/xen-pcifront-0.8.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
  and branch 'for-linus' of git://xenbits.xen.org/people/sstabellini/linux-pvhvm

* 'for-linus' of git://xenbits.xen.org/people/sstabellini/linux-pvhvm:
  xen: register xen pci notifier
  xen: initialize cpu masks for pv guests in xen_smp_init
  xen: add a missing #include to arch/x86/pci/xen.c
  xen: mask the MTRR feature from the cpuid
  xen: make hvc_xen console work for dom0.
  xen: add the direct mapping area for ISA bus access
  xen: Initialize xenbus for dom0.
  xen: use vcpu_ops to setup cpu masks
  xen: map a dummy page for local apic and ioapic in xen_set_fixmap
  xen: remap MSIs into pirqs when running as initial domain
  xen: remap GSIs as pirqs when running as initial domain
  xen: introduce XEN_DOM0 as a silent option
  xen: map MSIs into pirqs
  xen: support GSI -> pirq remapping in PV on HVM guests
  xen: add xen hvm acpi_register_gsi variant
  acpi: use indirect call to register gsi in different modes
  xen: implement xen_hvm_register_pirq
  xen: get the maximum number of pirqs from xen
  xen: support pirq != irq

* 'stable/xen-pcifront-0.8.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: (27 commits)
  X86/PCI: Remove the dependency on isapnp_disable.
  xen: Update Makefile with CONFIG_BLOCK dependency for biomerge.c
  MAINTAINERS: Add myself to the Xen Hypervisor Interface and remove Chris Wright.
  x86: xen: Sanitse irq handling (part two)
  swiotlb-xen: On x86-32 builts, select SWIOTLB instead of depending on it.
  MAINTAINERS: Add myself for Xen PCI and Xen SWIOTLB maintainer.
  xen/pci: Request ACS when Xen-SWIOTLB is activated.
  xen-pcifront: Xen PCI frontend driver.
  xenbus: prevent warnings on unhandled enumeration values
  xenbus: Xen paravirtualised PCI hotplug support.
  xen/x86/PCI: Add support for the Xen PCI subsystem
  x86: Introduce x86_msi_ops
  msi: Introduce default_[teardown|setup]_msi_irqs with fallback.
  x86/PCI: Export pci_walk_bus function.
  x86/PCI: make sure _PAGE_IOMAP it set on pci mappings
  x86/PCI: Clean up pci_cache_line_size
  xen: fix shared irq device passthrough
  xen: Provide a variant of xen_poll_irq with timeout.
  xen: Find an unbound irq number in reverse order (high to low).
  xen: statically initialize cpu_evtchn_mask_p
  ...

Fix up trivial conflicts in drivers/pci/Makefile
parents 2301b65b e28c31a9
...@@ -6595,11 +6595,25 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86. ...@@ -6595,11 +6595,25 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86.
S: Maintained S: Maintained
F: drivers/platform/x86 F: drivers/platform/x86
XEN PCI SUBSYSTEM
M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
L: xen-devel@lists.xensource.com
S: Supported
F: arch/x86/pci/*xen*
F: drivers/pci/*xen*
XEN SWIOTLB SUBSYSTEM
M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
L: xen-devel@lists.xensource.com
S: Supported
F: arch/x86/xen/*swiotlb*
F: drivers/xen/*swiotlb*
XEN HYPERVISOR INTERFACE XEN HYPERVISOR INTERFACE
M: Jeremy Fitzhardinge <jeremy@xensource.com> M: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
M: Chris Wright <chrisw@sous-sol.org> M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
L: xen-devel@lists.xen.org
L: virtualization@lists.osdl.org L: virtualization@lists.osdl.org
L: xen-devel@lists.xensource.com
S: Supported S: Supported
F: arch/x86/xen/ F: arch/x86/xen/
F: drivers/*/xen-*front.c F: drivers/*/xen-*front.c
......
...@@ -1893,6 +1893,11 @@ config PCI_OLPC ...@@ -1893,6 +1893,11 @@ config PCI_OLPC
def_bool y def_bool y
depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY) depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY)
config PCI_XEN
def_bool y
depends on PCI && XEN
select SWIOTLB_XEN
config PCI_DOMAINS config PCI_DOMAINS
def_bool y def_bool y
depends on PCI depends on PCI
......
...@@ -93,6 +93,9 @@ extern u8 acpi_sci_flags; ...@@ -93,6 +93,9 @@ extern u8 acpi_sci_flags;
extern int acpi_sci_override_gsi; extern int acpi_sci_override_gsi;
void acpi_pic_sci_set_trigger(unsigned int, u16); void acpi_pic_sci_set_trigger(unsigned int, u16);
extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
int trigger, int polarity);
static inline void disable_acpi(void) static inline void disable_acpi(void)
{ {
acpi_disabled = 1; acpi_disabled = 1;
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <asm-generic/int-ll64.h> #include <asm-generic/int-ll64.h>
#include <asm/page.h> #include <asm/page.h>
#include <xen/xen.h>
#define build_mmio_read(name, size, type, reg, barrier) \ #define build_mmio_read(name, size, type, reg, barrier) \
static inline type name(const volatile void __iomem *addr) \ static inline type name(const volatile void __iomem *addr) \
{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \ { type ret; asm volatile("mov" size " %1,%0":reg (ret) \
...@@ -351,6 +353,17 @@ extern void early_iounmap(void __iomem *addr, unsigned long size); ...@@ -351,6 +353,17 @@ extern void early_iounmap(void __iomem *addr, unsigned long size);
extern void fixup_early_ioremap(void); extern void fixup_early_ioremap(void);
extern bool is_early_ioremap_ptep(pte_t *ptep); extern bool is_early_ioremap_ptep(pte_t *ptep);
#ifdef CONFIG_XEN
struct bio_vec;
extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
const struct bio_vec *vec2);
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
(__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
#endif /* CONFIG_XEN */
#define IO_SPACE_LIMIT 0xffff #define IO_SPACE_LIMIT 0xffff
#endif /* _ASM_X86_IO_H */ #endif /* _ASM_X86_IO_H */
...@@ -169,6 +169,7 @@ extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); ...@@ -169,6 +169,7 @@ extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
extern void probe_nr_irqs_gsi(void); extern void probe_nr_irqs_gsi(void);
extern int get_nr_irqs_gsi(void);
extern void setup_ioapic_ids_from_mpc(void); extern void setup_ioapic_ids_from_mpc(void);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <asm/scatterlist.h> #include <asm/scatterlist.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/x86_init.h>
#ifdef __KERNEL__ #ifdef __KERNEL__
...@@ -94,8 +95,36 @@ static inline void early_quirks(void) { } ...@@ -94,8 +95,36 @@ static inline void early_quirks(void) { }
extern void pci_iommu_alloc(void); extern void pci_iommu_alloc(void);
/* MSI arch hook */ #ifdef CONFIG_PCI_MSI
#define arch_setup_msi_irqs arch_setup_msi_irqs /* MSI arch specific hooks */
static inline int x86_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
return x86_msi.setup_msi_irqs(dev, nvec, type);
}
static inline void x86_teardown_msi_irqs(struct pci_dev *dev)
{
x86_msi.teardown_msi_irqs(dev);
}
static inline void x86_teardown_msi_irq(unsigned int irq)
{
x86_msi.teardown_msi_irq(irq);
}
#define arch_setup_msi_irqs x86_setup_msi_irqs
#define arch_teardown_msi_irqs x86_teardown_msi_irqs
#define arch_teardown_msi_irq x86_teardown_msi_irq
/* implemented in arch/x86/kernel/apic/io_apic. */
int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void native_teardown_msi_irq(unsigned int irq);
/* default to the implementation in drivers/lib/msi.c */
#define HAVE_DEFAULT_MSI_TEARDOWN_IRQS
void default_teardown_msi_irqs(struct pci_dev *dev);
#else
#define native_setup_msi_irqs NULL
#define native_teardown_msi_irq NULL
#define default_teardown_msi_irqs NULL
#endif
#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
......
...@@ -47,6 +47,7 @@ enum pci_bf_sort_state { ...@@ -47,6 +47,7 @@ enum pci_bf_sort_state {
extern unsigned int pcibios_max_latency; extern unsigned int pcibios_max_latency;
void pcibios_resource_survey(void); void pcibios_resource_survey(void);
void pcibios_set_cache_line_size(void);
/* pci-pc.c */ /* pci-pc.c */
......
...@@ -154,9 +154,18 @@ struct x86_platform_ops { ...@@ -154,9 +154,18 @@ struct x86_platform_ops {
int (*i8042_detect)(void); int (*i8042_detect)(void);
}; };
struct pci_dev;
struct x86_msi_ops {
int (*setup_msi_irqs)(struct pci_dev *dev, int nvec, int type);
void (*teardown_msi_irq)(unsigned int irq);
void (*teardown_msi_irqs)(struct pci_dev *dev);
};
extern struct x86_init_ops x86_init; extern struct x86_init_ops x86_init;
extern struct x86_cpuinit_ops x86_cpuinit; extern struct x86_cpuinit_ops x86_cpuinit;
extern struct x86_platform_ops x86_platform; extern struct x86_platform_ops x86_platform;
extern struct x86_msi_ops x86_msi;
extern void x86_init_noop(void); extern void x86_init_noop(void);
extern void x86_init_uint_noop(unsigned int unused); extern void x86_init_uint_noop(unsigned int unused);
......
#ifndef _ASM_X86_XEN_PCI_H
#define _ASM_X86_XEN_PCI_H
#if defined(CONFIG_PCI_XEN)
extern int __init pci_xen_init(void);
extern int __init pci_xen_hvm_init(void);
#define pci_xen 1
#else
#define pci_xen 0
#define pci_xen_init (0)
static inline int pci_xen_hvm_init(void)
{
return -1;
}
#endif
#if defined(CONFIG_XEN_DOM0)
void __init xen_setup_pirqs(void);
#else
static inline void __init xen_setup_pirqs(void)
{
}
#endif
#if defined(CONFIG_PCI_MSI)
#if defined(CONFIG_PCI_XEN)
/* The drivers/pci/xen-pcifront.c sets this structure to
* its own functions.
*/
struct xen_pci_frontend_ops {
int (*enable_msi)(struct pci_dev *dev, int **vectors);
void (*disable_msi)(struct pci_dev *dev);
int (*enable_msix)(struct pci_dev *dev, int **vectors, int nvec);
void (*disable_msix)(struct pci_dev *dev);
};
extern struct xen_pci_frontend_ops *xen_pci_frontend;
static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
int **vectors)
{
if (xen_pci_frontend && xen_pci_frontend->enable_msi)
return xen_pci_frontend->enable_msi(dev, vectors);
return -ENODEV;
}
static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
{
if (xen_pci_frontend && xen_pci_frontend->disable_msi)
xen_pci_frontend->disable_msi(dev);
}
static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
int **vectors, int nvec)
{
if (xen_pci_frontend && xen_pci_frontend->enable_msix)
return xen_pci_frontend->enable_msix(dev, vectors, nvec);
return -ENODEV;
}
static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
{
if (xen_pci_frontend && xen_pci_frontend->disable_msix)
xen_pci_frontend->disable_msix(dev);
}
#endif /* CONFIG_PCI_XEN */
#endif /* CONFIG_PCI_MSI */
#endif /* _ASM_X86_XEN_PCI_H */
...@@ -513,35 +513,62 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi) ...@@ -513,35 +513,62 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
return 0; return 0;
} }
/* static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
* success: return IRQ number (>=0) int trigger, int polarity)
* failure: return < 0
*/
int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
{ {
unsigned int irq;
unsigned int plat_gsi = gsi;
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
/* /*
* Make sure all (legacy) PCI IRQs are set as level-triggered. * Make sure all (legacy) PCI IRQs are set as level-triggered.
*/ */
if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { if (trigger == ACPI_LEVEL_SENSITIVE)
if (trigger == ACPI_LEVEL_SENSITIVE) eisa_set_level_irq(gsi);
eisa_set_level_irq(gsi);
}
#endif #endif
return gsi;
}
static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
int trigger, int polarity)
{
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { gsi = mp_register_gsi(dev, gsi, trigger, polarity);
plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
}
#endif #endif
return gsi;
}
int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
int trigger, int polarity) = acpi_register_gsi_pic;
/*
* success: return IRQ number (>=0)
* failure: return < 0
*/
int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
{
unsigned int irq;
unsigned int plat_gsi = gsi;
plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity);
irq = gsi_to_irq(plat_gsi); irq = gsi_to_irq(plat_gsi);
return irq; return irq;
} }
void __init acpi_set_irq_model_pic(void)
{
acpi_irq_model = ACPI_IRQ_MODEL_PIC;
__acpi_register_gsi = acpi_register_gsi_pic;
acpi_ioapic = 0;
}
void __init acpi_set_irq_model_ioapic(void)
{
acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
__acpi_register_gsi = acpi_register_gsi_ioapic;
acpi_ioapic = 1;
}
/* /*
* ACPI based hotplug support for CPU * ACPI based hotplug support for CPU
*/ */
...@@ -1259,8 +1286,7 @@ static void __init acpi_process_madt(void) ...@@ -1259,8 +1286,7 @@ static void __init acpi_process_madt(void)
*/ */
error = acpi_parse_madt_ioapic_entries(); error = acpi_parse_madt_ioapic_entries();
if (!error) { if (!error) {
acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; acpi_set_irq_model_ioapic();
acpi_ioapic = 1;
smp_found_config = 1; smp_found_config = 1;
} }
......
...@@ -3331,7 +3331,7 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) ...@@ -3331,7 +3331,7 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq)
return 0; return 0;
} }
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{ {
int node, ret, sub_handle, index = 0; int node, ret, sub_handle, index = 0;
unsigned int irq, irq_want; unsigned int irq, irq_want;
...@@ -3389,7 +3389,7 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -3389,7 +3389,7 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
return ret; return ret;
} }
void arch_teardown_msi_irq(unsigned int irq) void native_teardown_msi_irq(unsigned int irq)
{ {
destroy_irq(irq); destroy_irq(irq);
} }
...@@ -3650,6 +3650,11 @@ void __init probe_nr_irqs_gsi(void) ...@@ -3650,6 +3650,11 @@ void __init probe_nr_irqs_gsi(void)
printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi); printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi);
} }
int get_nr_irqs_gsi(void)
{
return nr_irqs_gsi;
}
#ifdef CONFIG_SPARSE_IRQ #ifdef CONFIG_SPARSE_IRQ
int __init arch_probe_nr_irqs(void) int __init arch_probe_nr_irqs(void)
{ {
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h>
#include <asm/bios_ebda.h> #include <asm/bios_ebda.h>
#include <asm/paravirt.h> #include <asm/paravirt.h>
#include <asm/pci_x86.h> #include <asm/pci_x86.h>
#include <asm/pci.h>
#include <asm/mpspec.h> #include <asm/mpspec.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/apic.h> #include <asm/apic.h>
...@@ -99,3 +101,8 @@ struct x86_platform_ops x86_platform = { ...@@ -99,3 +101,8 @@ struct x86_platform_ops x86_platform = {
}; };
EXPORT_SYMBOL_GPL(x86_platform); EXPORT_SYMBOL_GPL(x86_platform);
struct x86_msi_ops x86_msi = {
.setup_msi_irqs = native_setup_msi_irqs,
.teardown_msi_irq = native_teardown_msi_irq,
.teardown_msi_irqs = default_teardown_msi_irqs,
};
...@@ -4,6 +4,7 @@ obj-$(CONFIG_PCI_BIOS) += pcbios.o ...@@ -4,6 +4,7 @@ obj-$(CONFIG_PCI_BIOS) += pcbios.o
obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_$(BITS).o direct.o mmconfig-shared.o obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_$(BITS).o direct.o mmconfig-shared.o
obj-$(CONFIG_PCI_DIRECT) += direct.o obj-$(CONFIG_PCI_DIRECT) += direct.o
obj-$(CONFIG_PCI_OLPC) += olpc.o obj-$(CONFIG_PCI_OLPC) += olpc.o
obj-$(CONFIG_PCI_XEN) += xen.o
obj-y += fixup.o obj-y += fixup.o
obj-$(CONFIG_ACPI) += acpi.o obj-$(CONFIG_ACPI) += acpi.o
......
...@@ -421,16 +421,10 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum) ...@@ -421,16 +421,10 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
return bus; return bus;
} }
void __init pcibios_set_cache_line_size(void)
int __init pcibios_init(void)
{ {
struct cpuinfo_x86 *c = &boot_cpu_data; struct cpuinfo_x86 *c = &boot_cpu_data;
if (!raw_pci_ops) {
printk(KERN_WARNING "PCI: System does not support PCI\n");
return 0;
}
/* /*
* Set PCI cacheline size to that of the CPU if the CPU has reported it. * Set PCI cacheline size to that of the CPU if the CPU has reported it.
* (For older CPUs that don't support cpuid, we se it to 32 bytes * (For older CPUs that don't support cpuid, we se it to 32 bytes
...@@ -445,7 +439,16 @@ int __init pcibios_init(void) ...@@ -445,7 +439,16 @@ int __init pcibios_init(void)
pci_dfl_cache_line_size = 32 >> 2; pci_dfl_cache_line_size = 32 >> 2;
printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n"); printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n");
} }
}
int __init pcibios_init(void)
{
if (!raw_pci_ops) {
printk(KERN_WARNING "PCI: System does not support PCI\n");
return 0;
}
pcibios_set_cache_line_size();
pcibios_resource_survey(); pcibios_resource_survey();
if (pci_bf_sort >= pci_force_bf) if (pci_bf_sort >= pci_force_bf)
......
...@@ -316,6 +316,8 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, ...@@ -316,6 +316,8 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
*/ */
prot |= _PAGE_CACHE_UC_MINUS; prot |= _PAGE_CACHE_UC_MINUS;
prot |= _PAGE_IOMAP; /* creating a mapping for IO */
vma->vm_page_prot = __pgprot(prot); vma->vm_page_prot = __pgprot(prot);
if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
......
/*
* Xen PCI Frontend Stub - puts some "dummy" functions in to the Linux
* x86 PCI core to support the Xen PCI Frontend
*
* Author: Ryan Wilson <hap9@epoch.ncsc.mil>
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/acpi.h>
#include <linux/io.h>
#include <asm/io_apic.h>
#include <asm/pci_x86.h>
#include <asm/xen/hypervisor.h>
#include <xen/features.h>
#include <xen/events.h>
#include <asm/xen/pci.h>
#ifdef CONFIG_ACPI
static int xen_hvm_register_pirq(u32 gsi, int triggering)
{
int rc, irq;
struct physdev_map_pirq map_irq;
int shareable = 0;
char *name;
if (!xen_hvm_domain())
return -1;
map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_GSI;
map_irq.index = gsi;
map_irq.pirq = -1;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
if (rc) {
printk(KERN_WARNING "xen map irq failed %d\n", rc);
return -1;
}
if (triggering == ACPI_EDGE_SENSITIVE) {
shareable = 0;
name = "ioapic-edge";
} else {
shareable = 1;
name = "ioapic-level";
}
irq = xen_map_pirq_gsi(map_irq.pirq, gsi, shareable, name);
printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq);
return irq;
}
static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
int trigger, int polarity)
{
return xen_hvm_register_pirq(gsi, trigger);
}
#endif
#if defined(CONFIG_PCI_MSI)
#include <linux/msi.h>
#include <asm/msidef.h>
struct xen_pci_frontend_ops *xen_pci_frontend;
EXPORT_SYMBOL_GPL(xen_pci_frontend);
static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,
struct msi_msg *msg)
{
/* We set vector == 0 to tell the hypervisor we don't care about it,
* but we want a pirq setup instead.
* We use the dest_id field to pass the pirq that we want. */
msg->address_hi = MSI_ADDR_BASE_HI | MSI_ADDR_EXT_DEST_ID(pirq);
msg->address_lo =
MSI_ADDR_BASE_LO |
MSI_ADDR_DEST_MODE_PHYSICAL |
MSI_ADDR_REDIRECTION_CPU |
MSI_ADDR_DEST_ID(pirq);
msg->data =
MSI_DATA_TRIGGER_EDGE |
MSI_DATA_LEVEL_ASSERT |
/* delivery mode reserved */
(3 << 8) |
MSI_DATA_VECTOR(0);
}
static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
int irq, pirq, ret = 0;
struct msi_desc *msidesc;
struct msi_msg msg;
list_for_each_entry(msidesc, &dev->msi_list, list) {
xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
"msi-x" : "msi", &irq, &pirq);
if (irq < 0 || pirq < 0)
goto error;
printk(KERN_DEBUG "xen: msi --> irq=%d, pirq=%d\n", irq, pirq);
xen_msi_compose_msg(dev, pirq, &msg);
ret = set_irq_msi(irq, msidesc);
if (ret < 0)
goto error_while;
write_msi_msg(irq, &msg);
}
return 0;
error_while:
unbind_from_irqhandler(irq, NULL);
error:
if (ret == -ENODEV)
dev_err(&dev->dev, "Xen PCI frontend has not registered" \
" MSI/MSI-X support!\n");
return ret;
}
/*
* For MSI interrupts we have to use drivers/xen/event.s functions to
* allocate an irq_desc and setup the right */
static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
int irq, ret, i;
struct msi_desc *msidesc;
int *v;
v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
if (!v)
return -ENOMEM;
if (type == PCI_CAP_ID_MSIX)
ret = xen_pci_frontend_enable_msix(dev, &v, nvec);
else
ret = xen_pci_frontend_enable_msi(dev, &v);
if (ret)
goto error;
i = 0;
list_for_each_entry(msidesc, &dev->msi_list, list) {
irq = xen_allocate_pirq(v[i], 0, /* not sharable */
(type == PCI_CAP_ID_MSIX) ?
"pcifront-msi-x" : "pcifront-msi");
if (irq < 0)
return -1;
ret = set_irq_msi(irq, msidesc);
if (ret)
goto error_while;
i++;
}
kfree(v);
return 0;
error_while:
unbind_from_irqhandler(irq, NULL);
error:
if (ret == -ENODEV)
dev_err(&dev->dev, "Xen PCI frontend has not registered" \
" MSI/MSI-X support!\n");
kfree(v);
return ret;
}
static void xen_teardown_msi_irqs(struct pci_dev *dev)
{
struct msi_desc *msidesc;
msidesc = list_entry(dev->msi_list.next, struct msi_desc, list);
if (msidesc->msi_attrib.is_msix)
xen_pci_frontend_disable_msix(dev);
else
xen_pci_frontend_disable_msi(dev);
}
static void xen_teardown_msi_irq(unsigned int irq)
{
xen_destroy_irq(irq);
}
static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
int irq, ret;
struct msi_desc *msidesc;
list_for_each_entry(msidesc, &dev->msi_list, list) {
irq = xen_create_msi_irq(dev, msidesc, type);
if (irq < 0)
return -1;
ret = set_irq_msi(irq, msidesc);
if (ret)
goto error;
}
return 0;
error:
xen_destroy_irq(irq);
return ret;
}
#endif
static int xen_pcifront_enable_irq(struct pci_dev *dev)
{
int rc;
int share = 1;
dev_info(&dev->dev, "Xen PCI enabling IRQ: %d\n", dev->irq);
if (dev->irq < 0)
return -EINVAL;
if (dev->irq < NR_IRQS_LEGACY)
share = 0;
rc = xen_allocate_pirq(dev->irq, share, "pcifront");
if (rc < 0) {
dev_warn(&dev->dev, "Xen PCI IRQ: %d, failed to register:%d\n",
dev->irq, rc);
return rc;
}
return 0;
}
int __init pci_xen_init(void)
{
if (!xen_pv_domain() || xen_initial_domain())
return -ENODEV;
printk(KERN_INFO "PCI: setting up Xen PCI frontend stub\n");
pcibios_set_cache_line_size();
pcibios_enable_irq = xen_pcifront_enable_irq;
pcibios_disable_irq = NULL;
#ifdef CONFIG_ACPI
/* Keep ACPI out of the picture */
acpi_noirq = 1;
#endif
#ifdef CONFIG_PCI_MSI
x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
#endif
return 0;
}
int __init pci_xen_hvm_init(void)
{
if (!xen_feature(XENFEAT_hvm_pirqs))
return 0;
#ifdef CONFIG_ACPI
/*
* We don't want to change the actual ACPI delivery model,
* just how GSIs get registered.
*/
__acpi_register_gsi = acpi_register_gsi_xen_hvm;
#endif
#ifdef CONFIG_PCI_MSI
x86_msi.setup_msi_irqs = xen_hvm_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
#endif
return 0;
}
#ifdef CONFIG_XEN_DOM0
static int xen_register_pirq(u32 gsi, int triggering)
{
int rc, irq;
struct physdev_map_pirq map_irq;
int shareable = 0;
char *name;
if (!xen_pv_domain())
return -1;
if (triggering == ACPI_EDGE_SENSITIVE) {
shareable = 0;
name = "ioapic-edge";
} else {
shareable = 1;
name = "ioapic-level";
}
irq = xen_allocate_pirq(gsi, shareable, name);
printk(KERN_DEBUG "xen: --> irq=%d\n", irq);
if (irq < 0)
goto out;
map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_GSI;
map_irq.index = gsi;
map_irq.pirq = irq;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
if (rc) {
printk(KERN_WARNING "xen map irq failed %d\n", rc);
return -1;
}
out:
return irq;
}
static int xen_register_gsi(u32 gsi, int triggering, int polarity)
{
int rc, irq;
struct physdev_setup_gsi setup_gsi;
if (!xen_pv_domain())
return -1;
printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n",
gsi, triggering, polarity);
irq = xen_register_pirq(gsi, triggering);
setup_gsi.gsi = gsi;
setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1);
setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi);
if (rc == -EEXIST)
printk(KERN_INFO "Already setup the GSI :%d\n", gsi);
else if (rc) {
printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n",
gsi, rc);
}
return irq;
}
static __init void xen_setup_acpi_sci(void)
{
int rc;
int trigger, polarity;
int gsi = acpi_sci_override_gsi;
if (!gsi)
return;
rc = acpi_get_override_irq(gsi, &trigger, &polarity);
if (rc) {
printk(KERN_WARNING "xen: acpi_get_override_irq failed for acpi"
" sci, rc=%d\n", rc);
return;
}
trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d "
"polarity=%d\n", gsi, trigger, polarity);
gsi = xen_register_gsi(gsi, trigger, polarity);
printk(KERN_INFO "xen: acpi sci %d\n", gsi);
return;
}
static int acpi_register_gsi_xen(struct device *dev, u32 gsi,
int trigger, int polarity)
{
return xen_register_gsi(gsi, trigger, polarity);
}
static int __init pci_xen_initial_domain(void)
{
#ifdef CONFIG_PCI_MSI
x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
#endif
xen_setup_acpi_sci();
__acpi_register_gsi = acpi_register_gsi_xen;
return 0;
}
void __init xen_setup_pirqs(void)
{
int irq;
pci_xen_initial_domain();
if (0 == nr_ioapics) {
for (irq = 0; irq < NR_IRQS_LEGACY; irq++)
xen_allocate_pirq(irq, 0, "xt-pic");
return;
}
/* Pre-allocate legacy irqs */
for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
int trigger, polarity;
if (acpi_get_override_irq(irq, &trigger, &polarity) == -1)
continue;
xen_register_pirq(irq,
trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE);
}
}
#endif
...@@ -13,6 +13,16 @@ config XEN ...@@ -13,6 +13,16 @@ config XEN
kernel to boot in a paravirtualized environment under the kernel to boot in a paravirtualized environment under the
Xen hypervisor. Xen hypervisor.
config XEN_DOM0
def_bool y
depends on XEN && PCI_XEN && SWIOTLB_XEN
depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
# Dummy symbol since people have come to rely on the PRIVILEGED_GUEST
# name in tools.
config XEN_PRIVILEGED_GUEST
def_bool XEN_DOM0
config XEN_PVHVM config XEN_PVHVM
def_bool y def_bool y
depends on XEN depends on XEN
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <asm/paravirt.h> #include <asm/paravirt.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/xen/pci.h>
#include <asm/xen/hypercall.h> #include <asm/xen/hypercall.h>
#include <asm/xen/hypervisor.h> #include <asm/xen/hypervisor.h>
#include <asm/fixmap.h> #include <asm/fixmap.h>
...@@ -236,6 +237,7 @@ static __init void xen_init_cpuid_mask(void) ...@@ -236,6 +237,7 @@ static __init void xen_init_cpuid_mask(void)
cpuid_leaf1_edx_mask = cpuid_leaf1_edx_mask =
~((1 << X86_FEATURE_MCE) | /* disable MCE */ ~((1 << X86_FEATURE_MCE) | /* disable MCE */
(1 << X86_FEATURE_MCA) | /* disable MCA */ (1 << X86_FEATURE_MCA) | /* disable MCA */
(1 << X86_FEATURE_MTRR) | /* disable MTRR */
(1 << X86_FEATURE_ACC)); /* thermal monitoring */ (1 << X86_FEATURE_ACC)); /* thermal monitoring */
if (!xen_initial_domain()) if (!xen_initial_domain())
...@@ -1184,6 +1186,7 @@ asmlinkage void __init xen_start_kernel(void) ...@@ -1184,6 +1186,7 @@ asmlinkage void __init xen_start_kernel(void)
xen_raw_console_write("mapping kernel into physical memory\n"); xen_raw_console_write("mapping kernel into physical memory\n");
pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages);
xen_ident_map_ISA();
/* Allocate and initialize top and mid mfn levels for p2m structure */ /* Allocate and initialize top and mid mfn levels for p2m structure */
xen_build_mfn_list_list(); xen_build_mfn_list_list();
...@@ -1222,6 +1225,8 @@ asmlinkage void __init xen_start_kernel(void) ...@@ -1222,6 +1225,8 @@ asmlinkage void __init xen_start_kernel(void)
add_preferred_console("xenboot", 0, NULL); add_preferred_console("xenboot", 0, NULL);
add_preferred_console("tty", 0, NULL); add_preferred_console("tty", 0, NULL);
add_preferred_console("hvc", 0, NULL); add_preferred_console("hvc", 0, NULL);
if (pci_xen)
x86_init.pci.arch_init = pci_xen_init;
} else { } else {
/* Make sure ACS will be enabled */ /* Make sure ACS will be enabled */
pci_request_acs(); pci_request_acs();
......
...@@ -1975,6 +1975,7 @@ static void *m2v(phys_addr_t maddr) ...@@ -1975,6 +1975,7 @@ static void *m2v(phys_addr_t maddr)
return __ka(m2p(maddr)); return __ka(m2p(maddr));
} }
/* Set the page permissions on an identity-mapped pages */
static void set_page_prot(void *addr, pgprot_t prot) static void set_page_prot(void *addr, pgprot_t prot)
{ {
unsigned long pfn = __pa(addr) >> PAGE_SHIFT; unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
...@@ -2159,6 +2160,8 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, ...@@ -2159,6 +2160,8 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
} }
#endif /* CONFIG_X86_64 */ #endif /* CONFIG_X86_64 */
static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss;
static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
{ {
pte_t pte; pte_t pte;
...@@ -2178,9 +2181,6 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) ...@@ -2178,9 +2181,6 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
# endif # endif
#else #else
case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE: case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE:
#endif
#ifdef CONFIG_X86_LOCAL_APIC
case FIX_APIC_BASE: /* maps dummy local APIC */
#endif #endif
case FIX_TEXT_POKE0: case FIX_TEXT_POKE0:
case FIX_TEXT_POKE1: case FIX_TEXT_POKE1:
...@@ -2188,6 +2188,22 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) ...@@ -2188,6 +2188,22 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
pte = pfn_pte(phys, prot); pte = pfn_pte(phys, prot);
break; break;
#ifdef CONFIG_X86_LOCAL_APIC
case FIX_APIC_BASE: /* maps dummy local APIC */
pte = pfn_pte(PFN_DOWN(__pa(dummy_mapping)), PAGE_KERNEL);
break;
#endif
#ifdef CONFIG_X86_IO_APIC
case FIX_IO_APIC_BASE_0 ... FIX_IO_APIC_BASE_END:
/*
* We just don't map the IO APIC - all access is via
* hypercalls. Keep the address in the pte for reference.
*/
pte = pfn_pte(PFN_DOWN(__pa(dummy_mapping)), PAGE_KERNEL);
break;
#endif
case FIX_PARAVIRT_BOOTMAP: case FIX_PARAVIRT_BOOTMAP:
/* This is an MFN, but it isn't an IO mapping from the /* This is an MFN, but it isn't an IO mapping from the
IO domain */ IO domain */
...@@ -2212,6 +2228,29 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) ...@@ -2212,6 +2228,29 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
#endif #endif
} }
__init void xen_ident_map_ISA(void)
{
unsigned long pa;
/*
* If we're dom0, then linear map the ISA machine addresses into
* the kernel's address space.
*/
if (!xen_initial_domain())
return;
xen_raw_printk("Xen: setup ISA identity maps\n");
for (pa = ISA_START_ADDRESS; pa < ISA_END_ADDRESS; pa += PAGE_SIZE) {
pte_t pte = mfn_pte(PFN_DOWN(pa), PAGE_KERNEL_IO);
if (HYPERVISOR_update_va_mapping(PAGE_OFFSET + pa, pte, 0))
BUG();
}
xen_flush_tlb();
}
static __init void xen_post_allocator_init(void) static __init void xen_post_allocator_init(void)
{ {
pv_mmu_ops.set_pte = xen_set_pte; pv_mmu_ops.set_pte = xen_set_pte;
...@@ -2320,6 +2359,8 @@ void __init xen_init_mmu_ops(void) ...@@ -2320,6 +2359,8 @@ void __init xen_init_mmu_ops(void)
pv_mmu_ops = xen_mmu_ops; pv_mmu_ops = xen_mmu_ops;
vmap_lazy_unmap = false; vmap_lazy_unmap = false;
memset(dummy_mapping, 0xff, PAGE_SIZE);
} }
/* Protected by xen_reservation_lock. */ /* Protected by xen_reservation_lock. */
......
/* Glue code to lib/swiotlb-xen.c */ /* Glue code to lib/swiotlb-xen.c */
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/pci.h>
#include <xen/swiotlb-xen.h> #include <xen/swiotlb-xen.h>
#include <asm/xen/hypervisor.h> #include <asm/xen/hypervisor.h>
...@@ -55,6 +56,9 @@ void __init pci_xen_swiotlb_init(void) ...@@ -55,6 +56,9 @@ void __init pci_xen_swiotlb_init(void)
if (xen_swiotlb) { if (xen_swiotlb) {
xen_swiotlb_init(1); xen_swiotlb_init(1);
dma_ops = &xen_swiotlb_dma_ops; dma_ops = &xen_swiotlb_dma_ops;
/* Make sure ACS will be enabled */
pci_request_acs();
} }
} }
IOMMU_INIT_FINISH(pci_xen_swiotlb_detect, IOMMU_INIT_FINISH(pci_xen_swiotlb_detect,
......
...@@ -204,6 +204,9 @@ char * __init xen_memory_setup(void) ...@@ -204,6 +204,9 @@ char * __init xen_memory_setup(void)
* Even though this is normal, usable memory under Xen, reserve * Even though this is normal, usable memory under Xen, reserve
* ISA memory anyway because too many things think they can poke * ISA memory anyway because too many things think they can poke
* about in there. * about in there.
*
* In a dom0 kernel, this region is identity mapped with the
* hardware ISA area, so it really is out of bounds.
*/ */
e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
E820_RESERVED); E820_RESERVED);
...@@ -367,7 +370,5 @@ void __init xen_arch_setup(void) ...@@ -367,7 +370,5 @@ void __init xen_arch_setup(void)
pm_idle = xen_idle; pm_idle = xen_idle;
paravirt_disable_iospace();
fiddle_vdso(); fiddle_vdso();
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <asm/xen/interface.h> #include <asm/xen/interface.h>
#include <asm/xen/hypercall.h> #include <asm/xen/hypercall.h>
#include <xen/xen.h>
#include <xen/page.h> #include <xen/page.h>
#include <xen/events.h> #include <xen/events.h>
...@@ -156,11 +157,35 @@ static void __init xen_fill_possible_map(void) ...@@ -156,11 +157,35 @@ static void __init xen_fill_possible_map(void)
{ {
int i, rc; int i, rc;
if (xen_initial_domain())
return;
for (i = 0; i < nr_cpu_ids; i++) {
rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
if (rc >= 0) {
num_processors++;
set_cpu_possible(i, true);
}
}
}
static void __init xen_filter_cpu_maps(void)
{
int i, rc;
if (!xen_initial_domain())
return;
num_processors = 0;
disabled_cpus = 0;
for (i = 0; i < nr_cpu_ids; i++) { for (i = 0; i < nr_cpu_ids; i++) {
rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
if (rc >= 0) { if (rc >= 0) {
num_processors++; num_processors++;
set_cpu_possible(i, true); set_cpu_possible(i, true);
} else {
set_cpu_possible(i, false);
set_cpu_present(i, false);
} }
} }
} }
...@@ -174,6 +199,7 @@ static void __init xen_smp_prepare_boot_cpu(void) ...@@ -174,6 +199,7 @@ static void __init xen_smp_prepare_boot_cpu(void)
old memory can be recycled */ old memory can be recycled */
make_lowmem_page_readwrite(xen_initial_gdt); make_lowmem_page_readwrite(xen_initial_gdt);
xen_filter_cpu_maps();
xen_setup_vcpu_info_placement(); xen_setup_vcpu_info_placement();
} }
......
...@@ -1112,6 +1112,8 @@ static void blkback_changed(struct xenbus_device *dev, ...@@ -1112,6 +1112,8 @@ static void blkback_changed(struct xenbus_device *dev,
case XenbusStateInitialising: case XenbusStateInitialising:
case XenbusStateInitWait: case XenbusStateInitWait:
case XenbusStateInitialised: case XenbusStateInitialised:
case XenbusStateReconfiguring:
case XenbusStateReconfigured:
case XenbusStateUnknown: case XenbusStateUnknown:
case XenbusStateClosed: case XenbusStateClosed:
break; break;
......
...@@ -79,7 +79,7 @@ static int __write_console(const char *data, int len) ...@@ -79,7 +79,7 @@ static int __write_console(const char *data, int len)
return sent; return sent;
} }
static int write_console(uint32_t vtermno, const char *data, int len) static int domU_write_console(uint32_t vtermno, const char *data, int len)
{ {
int ret = len; int ret = len;
...@@ -102,7 +102,7 @@ static int write_console(uint32_t vtermno, const char *data, int len) ...@@ -102,7 +102,7 @@ static int write_console(uint32_t vtermno, const char *data, int len)
return ret; return ret;
} }
static int read_console(uint32_t vtermno, char *buf, int len) static int domU_read_console(uint32_t vtermno, char *buf, int len)
{ {
struct xencons_interface *intf = xencons_interface(); struct xencons_interface *intf = xencons_interface();
XENCONS_RING_IDX cons, prod; XENCONS_RING_IDX cons, prod;
...@@ -123,28 +123,62 @@ static int read_console(uint32_t vtermno, char *buf, int len) ...@@ -123,28 +123,62 @@ static int read_console(uint32_t vtermno, char *buf, int len)
return recv; return recv;
} }
static const struct hv_ops hvc_ops = { static struct hv_ops domU_hvc_ops = {
.get_chars = read_console, .get_chars = domU_read_console,
.put_chars = write_console, .put_chars = domU_write_console,
.notifier_add = notifier_add_irq, .notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq, .notifier_del = notifier_del_irq,
.notifier_hangup = notifier_hangup_irq, .notifier_hangup = notifier_hangup_irq,
}; };
static int __init xen_init(void) static int dom0_read_console(uint32_t vtermno, char *buf, int len)
{
return HYPERVISOR_console_io(CONSOLEIO_read, len, buf);
}
/*
* Either for a dom0 to write to the system console, or a domU with a
* debug version of Xen
*/
static int dom0_write_console(uint32_t vtermno, const char *str, int len)
{
int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);
if (rc < 0)
return 0;
return len;
}
static struct hv_ops dom0_hvc_ops = {
.get_chars = dom0_read_console,
.put_chars = dom0_write_console,
.notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq,
.notifier_hangup = notifier_hangup_irq,
};
static int __init xen_hvc_init(void)
{ {
struct hvc_struct *hp; struct hvc_struct *hp;
struct hv_ops *ops;
if (!xen_pv_domain() || if (!xen_pv_domain())
xen_initial_domain() ||
!xen_start_info->console.domU.evtchn)
return -ENODEV; return -ENODEV;
xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn); if (xen_initial_domain()) {
ops = &dom0_hvc_ops;
xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
} else {
if (!xen_start_info->console.domU.evtchn)
return -ENODEV;
ops = &domU_hvc_ops;
xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
}
if (xencons_irq < 0) if (xencons_irq < 0)
xencons_irq = 0; /* NO_IRQ */ xencons_irq = 0; /* NO_IRQ */
hp = hvc_alloc(HVC_COOKIE, xencons_irq, &hvc_ops, 256); hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256);
if (IS_ERR(hp)) if (IS_ERR(hp))
return PTR_ERR(hp); return PTR_ERR(hp);
...@@ -161,7 +195,7 @@ void xen_console_resume(void) ...@@ -161,7 +195,7 @@ void xen_console_resume(void)
rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq); rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq);
} }
static void __exit xen_fini(void) static void __exit xen_hvc_fini(void)
{ {
if (hvc) if (hvc)
hvc_remove(hvc); hvc_remove(hvc);
...@@ -169,29 +203,24 @@ static void __exit xen_fini(void) ...@@ -169,29 +203,24 @@ static void __exit xen_fini(void)
static int xen_cons_init(void) static int xen_cons_init(void)
{ {
struct hv_ops *ops;
if (!xen_pv_domain()) if (!xen_pv_domain())
return 0; return 0;
hvc_instantiate(HVC_COOKIE, 0, &hvc_ops); if (xen_initial_domain())
ops = &dom0_hvc_ops;
else
ops = &domU_hvc_ops;
hvc_instantiate(HVC_COOKIE, 0, ops);
return 0; return 0;
} }
module_init(xen_init); module_init(xen_hvc_init);
module_exit(xen_fini); module_exit(xen_hvc_fini);
console_initcall(xen_cons_init); console_initcall(xen_cons_init);
static void raw_console_write(const char *str, int len)
{
while(len > 0) {
int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);
if (rc <= 0)
break;
str += rc;
len -= rc;
}
}
#ifdef CONFIG_EARLY_PRINTK #ifdef CONFIG_EARLY_PRINTK
static void xenboot_write_console(struct console *console, const char *string, static void xenboot_write_console(struct console *console, const char *string,
unsigned len) unsigned len)
...@@ -199,19 +228,22 @@ static void xenboot_write_console(struct console *console, const char *string, ...@@ -199,19 +228,22 @@ static void xenboot_write_console(struct console *console, const char *string,
unsigned int linelen, off = 0; unsigned int linelen, off = 0;
const char *pos; const char *pos;
raw_console_write(string, len); dom0_write_console(0, string, len);
if (xen_initial_domain())
return;
write_console(0, "(early) ", 8); domU_write_console(0, "(early) ", 8);
while (off < len && NULL != (pos = strchr(string+off, '\n'))) { while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
linelen = pos-string+off; linelen = pos-string+off;
if (off + linelen > len) if (off + linelen > len)
break; break;
write_console(0, string+off, linelen); domU_write_console(0, string+off, linelen);
write_console(0, "\r\n", 2); domU_write_console(0, "\r\n", 2);
off += linelen + 1; off += linelen + 1;
} }
if (off < len) if (off < len)
write_console(0, string+off, len-off); domU_write_console(0, string+off, len-off);
} }
struct console xenboot_console = { struct console xenboot_console = {
...@@ -223,7 +255,7 @@ struct console xenboot_console = { ...@@ -223,7 +255,7 @@ struct console xenboot_console = {
void xen_raw_console_write(const char *str) void xen_raw_console_write(const char *str)
{ {
raw_console_write(str, strlen(str)); dom0_write_console(0, str, strlen(str));
} }
void xen_raw_printk(const char *fmt, ...) void xen_raw_printk(const char *fmt, ...)
......
...@@ -276,6 +276,8 @@ static void xenkbd_backend_changed(struct xenbus_device *dev, ...@@ -276,6 +276,8 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
switch (backend_state) { switch (backend_state) {
case XenbusStateInitialising: case XenbusStateInitialising:
case XenbusStateInitialised: case XenbusStateInitialised:
case XenbusStateReconfiguring:
case XenbusStateReconfigured:
case XenbusStateUnknown: case XenbusStateUnknown:
case XenbusStateClosed: case XenbusStateClosed:
break; break;
......
...@@ -1610,6 +1610,8 @@ static void netback_changed(struct xenbus_device *dev, ...@@ -1610,6 +1610,8 @@ static void netback_changed(struct xenbus_device *dev,
switch (backend_state) { switch (backend_state) {
case XenbusStateInitialising: case XenbusStateInitialising:
case XenbusStateInitialised: case XenbusStateInitialised:
case XenbusStateReconfiguring:
case XenbusStateReconfigured:
case XenbusStateConnected: case XenbusStateConnected:
case XenbusStateUnknown: case XenbusStateUnknown:
case XenbusStateClosed: case XenbusStateClosed:
......
...@@ -40,6 +40,27 @@ config PCI_STUB ...@@ -40,6 +40,27 @@ config PCI_STUB
When in doubt, say N. When in doubt, say N.
config XEN_PCIDEV_FRONTEND
tristate "Xen PCI Frontend"
depends on PCI && X86 && XEN
select HOTPLUG
select PCI_XEN
default y
help
The PCI device frontend driver allows the kernel to import arbitrary
PCI devices from a PCI backend to support PCI driver domains.
config XEN_PCIDEV_FE_DEBUG
bool "Xen PCI Frontend debugging"
depends on XEN_PCIDEV_FRONTEND && PCI_DEBUG
help
Say Y here if you want the Xen PCI frontend to produce a bunch of debug
messages to the system log. Select this if you are having a
problem with Xen PCI frontend support and want to see more of what is
going on.
When in doubt, say N.
config HT_IRQ config HT_IRQ
bool "Interrupts on hypertransport devices" bool "Interrupts on hypertransport devices"
default y default y
......
...@@ -65,4 +65,6 @@ obj-$(CONFIG_PCI_SYSCALL) += syscall.o ...@@ -65,4 +65,6 @@ obj-$(CONFIG_PCI_SYSCALL) += syscall.o
obj-$(CONFIG_PCI_STUB) += pci-stub.o obj-$(CONFIG_PCI_STUB) += pci-stub.o
obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
...@@ -342,6 +342,7 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), ...@@ -342,6 +342,7 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
} }
up_read(&pci_bus_sem); up_read(&pci_bus_sem);
} }
EXPORT_SYMBOL_GPL(pci_walk_bus);
EXPORT_SYMBOL(pci_bus_alloc_resource); EXPORT_SYMBOL(pci_bus_alloc_resource);
EXPORT_SYMBOL_GPL(pci_bus_add_device); EXPORT_SYMBOL_GPL(pci_bus_add_device);
......
...@@ -35,7 +35,12 @@ int arch_msi_check_device(struct pci_dev *dev, int nvec, int type) ...@@ -35,7 +35,12 @@ int arch_msi_check_device(struct pci_dev *dev, int nvec, int type)
#endif #endif
#ifndef arch_setup_msi_irqs #ifndef arch_setup_msi_irqs
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) # define arch_setup_msi_irqs default_setup_msi_irqs
# define HAVE_DEFAULT_MSI_SETUP_IRQS
#endif
#ifdef HAVE_DEFAULT_MSI_SETUP_IRQS
int default_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{ {
struct msi_desc *entry; struct msi_desc *entry;
int ret; int ret;
...@@ -60,7 +65,12 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -60,7 +65,12 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
#endif #endif
#ifndef arch_teardown_msi_irqs #ifndef arch_teardown_msi_irqs
void arch_teardown_msi_irqs(struct pci_dev *dev) # define arch_teardown_msi_irqs default_teardown_msi_irqs
# define HAVE_DEFAULT_MSI_TEARDOWN_IRQS
#endif
#ifdef HAVE_DEFAULT_MSI_TEARDOWN_IRQS
void default_teardown_msi_irqs(struct pci_dev *dev)
{ {
struct msi_desc *entry; struct msi_desc *entry;
......
This diff is collapsed.
...@@ -631,6 +631,8 @@ static void xenfb_backend_changed(struct xenbus_device *dev, ...@@ -631,6 +631,8 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
switch (backend_state) { switch (backend_state) {
case XenbusStateInitialising: case XenbusStateInitialising:
case XenbusStateInitialised: case XenbusStateInitialised:
case XenbusStateReconfiguring:
case XenbusStateReconfigured:
case XenbusStateUnknown: case XenbusStateUnknown:
case XenbusStateClosed: case XenbusStateClosed:
break; break;
......
...@@ -74,6 +74,7 @@ config XEN_PLATFORM_PCI ...@@ -74,6 +74,7 @@ config XEN_PLATFORM_PCI
config SWIOTLB_XEN config SWIOTLB_XEN
def_bool y def_bool y
depends on SWIOTLB depends on PCI
select SWIOTLB
endmenu endmenu
...@@ -4,6 +4,7 @@ obj-y += xenbus/ ...@@ -4,6 +4,7 @@ obj-y += xenbus/
nostackp := $(call cc-option, -fno-stack-protector) nostackp := $(call cc-option, -fno-stack-protector)
CFLAGS_features.o := $(nostackp) CFLAGS_features.o := $(nostackp)
obj-$(CONFIG_BLOCK) += biomerge.o
obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
obj-$(CONFIG_XEN_XENCOMM) += xencomm.o obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
obj-$(CONFIG_XEN_BALLOON) += balloon.o obj-$(CONFIG_XEN_BALLOON) += balloon.o
...@@ -12,3 +13,4 @@ obj-$(CONFIG_XENFS) += xenfs/ ...@@ -12,3 +13,4 @@ obj-$(CONFIG_XENFS) += xenfs/
obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o
obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o
obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
obj-$(CONFIG_XEN_DOM0) += pci.o
#include <linux/bio.h>
#include <linux/io.h>
#include <xen/page.h>
bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
const struct bio_vec *vec2)
{
unsigned long mfn1 = pfn_to_mfn(page_to_pfn(vec1->bv_page));
unsigned long mfn2 = pfn_to_mfn(page_to_pfn(vec2->bv_page));
return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) &&
((mfn1 == mfn2) || ((mfn1+1) == mfn2));
}
This diff is collapsed.
/*
* Copyright (c) 2009, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Author: Weidong Han <weidong.han@intel.com>
*/
#include <linux/pci.h>
#include <xen/xen.h>
#include <xen/interface/physdev.h>
#include <xen/interface/xen.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
#include "../pci/pci.h"
static int xen_add_device(struct device *dev)
{
int r;
struct pci_dev *pci_dev = to_pci_dev(dev);
#ifdef CONFIG_PCI_IOV
if (pci_dev->is_virtfn) {
struct physdev_manage_pci_ext manage_pci_ext = {
.bus = pci_dev->bus->number,
.devfn = pci_dev->devfn,
.is_virtfn = 1,
.physfn.bus = pci_dev->physfn->bus->number,
.physfn.devfn = pci_dev->physfn->devfn,
};
r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
&manage_pci_ext);
} else
#endif
if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn)) {
struct physdev_manage_pci_ext manage_pci_ext = {
.bus = pci_dev->bus->number,
.devfn = pci_dev->devfn,
.is_extfn = 1,
};
r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
&manage_pci_ext);
} else {
struct physdev_manage_pci manage_pci = {
.bus = pci_dev->bus->number,
.devfn = pci_dev->devfn,
};
r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add,
&manage_pci);
}
return r;
}
static int xen_remove_device(struct device *dev)
{
int r;
struct pci_dev *pci_dev = to_pci_dev(dev);
struct physdev_manage_pci manage_pci;
manage_pci.bus = pci_dev->bus->number;
manage_pci.devfn = pci_dev->devfn;
r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove,
&manage_pci);
return r;
}
static int xen_pci_notifier(struct notifier_block *nb,
unsigned long action, void *data)
{
struct device *dev = data;
int r = 0;
switch (action) {
case BUS_NOTIFY_ADD_DEVICE:
r = xen_add_device(dev);
break;
case BUS_NOTIFY_DEL_DEVICE:
r = xen_remove_device(dev);
break;
default:
break;
}
return r;
}
struct notifier_block device_nb = {
.notifier_call = xen_pci_notifier,
};
static int __init register_xen_pci_notifier(void)
{
if (!xen_initial_domain())
return 0;
return bus_register_notifier(&pci_bus_type, &device_nb);
}
arch_initcall(register_xen_pci_notifier);
...@@ -50,6 +50,8 @@ const char *xenbus_strstate(enum xenbus_state state) ...@@ -50,6 +50,8 @@ const char *xenbus_strstate(enum xenbus_state state)
[ XenbusStateConnected ] = "Connected", [ XenbusStateConnected ] = "Connected",
[ XenbusStateClosing ] = "Closing", [ XenbusStateClosing ] = "Closing",
[ XenbusStateClosed ] = "Closed", [ XenbusStateClosed ] = "Closed",
[XenbusStateReconfiguring] = "Reconfiguring",
[XenbusStateReconfigured] = "Reconfigured",
}; };
return (state < ARRAY_SIZE(name)) ? name[state] : "INVALID"; return (state < ARRAY_SIZE(name)) ? name[state] : "INVALID";
} }
......
...@@ -803,6 +803,7 @@ device_initcall(xenbus_probe_initcall); ...@@ -803,6 +803,7 @@ device_initcall(xenbus_probe_initcall);
static int __init xenbus_init(void) static int __init xenbus_init(void)
{ {
int err = 0; int err = 0;
unsigned long page = 0;
DPRINTK(""); DPRINTK("");
...@@ -823,7 +824,31 @@ static int __init xenbus_init(void) ...@@ -823,7 +824,31 @@ static int __init xenbus_init(void)
* Domain0 doesn't have a store_evtchn or store_mfn yet. * Domain0 doesn't have a store_evtchn or store_mfn yet.
*/ */
if (xen_initial_domain()) { if (xen_initial_domain()) {
/* dom0 not yet supported */ struct evtchn_alloc_unbound alloc_unbound;
/* Allocate Xenstore page */
page = get_zeroed_page(GFP_KERNEL);
if (!page)
goto out_error;
xen_store_mfn = xen_start_info->store_mfn =
pfn_to_mfn(virt_to_phys((void *)page) >>
PAGE_SHIFT);
/* Next allocate a local port which xenstored can bind to */
alloc_unbound.dom = DOMID_SELF;
alloc_unbound.remote_dom = 0;
err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
&alloc_unbound);
if (err == -ENOSYS)
goto out_error;
BUG_ON(err);
xen_store_evtchn = xen_start_info->store_evtchn =
alloc_unbound.port;
xen_store_interface = mfn_to_virt(xen_store_mfn);
} else { } else {
if (xen_hvm_domain()) { if (xen_hvm_domain()) {
uint64_t v = 0; uint64_t v = 0;
...@@ -869,6 +894,8 @@ static int __init xenbus_init(void) ...@@ -869,6 +894,8 @@ static int __init xenbus_init(void)
bus_unregister(&xenbus_frontend.bus); bus_unregister(&xenbus_frontend.bus);
out_error: out_error:
if (page != 0)
free_page(page);
return err; return err;
} }
......
...@@ -12,6 +12,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn, ...@@ -12,6 +12,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
irq_handler_t handler, irq_handler_t handler,
unsigned long irqflags, const char *devname, unsigned long irqflags, const char *devname,
void *dev_id); void *dev_id);
int bind_virq_to_irq(unsigned int virq, unsigned int cpu);
int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
irq_handler_t handler, irq_handler_t handler,
unsigned long irqflags, const char *devname, unsigned long irqflags, const char *devname,
...@@ -53,6 +54,10 @@ bool xen_test_irq_pending(int irq); ...@@ -53,6 +54,10 @@ bool xen_test_irq_pending(int irq);
irq will be disabled so it won't deliver an interrupt. */ irq will be disabled so it won't deliver an interrupt. */
void xen_poll_irq(int irq); void xen_poll_irq(int irq);
/* Poll waiting for an irq to become pending with a timeout. In the usual case,
* the irq will be disabled so it won't deliver an interrupt. */
void xen_poll_irq_timeout(int irq, u64 timeout);
/* Determine the IRQ which is bound to an event channel */ /* Determine the IRQ which is bound to an event channel */
unsigned irq_from_evtchn(unsigned int evtchn); unsigned irq_from_evtchn(unsigned int evtchn);
...@@ -63,4 +68,25 @@ int xen_set_callback_via(uint64_t via); ...@@ -63,4 +68,25 @@ int xen_set_callback_via(uint64_t via);
void xen_evtchn_do_upcall(struct pt_regs *regs); void xen_evtchn_do_upcall(struct pt_regs *regs);
void xen_hvm_evtchn_do_upcall(void); void xen_hvm_evtchn_do_upcall(void);
/* Allocate an irq for a physical interrupt, given a gsi. "Legacy"
* GSIs are identity mapped; others are dynamically allocated as
* usual. */
int xen_allocate_pirq(unsigned gsi, int shareable, char *name);
int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name);
#ifdef CONFIG_PCI_MSI
/* Allocate an irq and a pirq to be used with MSIs. */
void xen_allocate_pirq_msi(char *name, int *irq, int *pirq);
int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type);
#endif
/* De-allocates the above mentioned physical interrupt. */
int xen_destroy_irq(int irq);
/* Return vector allocated to pirq */
int xen_vector_from_irq(unsigned pirq);
/* Return gsi allocated to pirq */
int xen_gsi_from_irq(unsigned pirq);
#endif /* _XEN_EVENTS_H */ #endif /* _XEN_EVENTS_H */
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
/* x86: pvclock algorithm is safe to use on HVM */ /* x86: pvclock algorithm is safe to use on HVM */
#define XENFEAT_hvm_safe_pvclock 9 #define XENFEAT_hvm_safe_pvclock 9
/* x86: pirq can be used by HVM guests */
#define XENFEAT_hvm_pirqs 10
#define XENFEAT_NR_SUBMAPS 1 #define XENFEAT_NR_SUBMAPS 1
#endif /* __XEN_PUBLIC_FEATURES_H__ */ #endif /* __XEN_PUBLIC_FEATURES_H__ */
/*
* PCI Backend/Frontend Common Data Structures & Macros
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Ryan Wilson <hap9@epoch.ncsc.mil>
*/
#ifndef __XEN_PCI_COMMON_H__
#define __XEN_PCI_COMMON_H__
/* Be sure to bump this number if you change this file */
#define XEN_PCI_MAGIC "7"
/* xen_pci_sharedinfo flags */
#define _XEN_PCIF_active (0)
#define XEN_PCIF_active (1<<_XEN_PCIF_active)
#define _XEN_PCIB_AERHANDLER (1)
#define XEN_PCIB_AERHANDLER (1<<_XEN_PCIB_AERHANDLER)
#define _XEN_PCIB_active (2)
#define XEN_PCIB_active (1<<_XEN_PCIB_active)
/* xen_pci_op commands */
#define XEN_PCI_OP_conf_read (0)
#define XEN_PCI_OP_conf_write (1)
#define XEN_PCI_OP_enable_msi (2)
#define XEN_PCI_OP_disable_msi (3)
#define XEN_PCI_OP_enable_msix (4)
#define XEN_PCI_OP_disable_msix (5)
#define XEN_PCI_OP_aer_detected (6)
#define XEN_PCI_OP_aer_resume (7)
#define XEN_PCI_OP_aer_mmio (8)
#define XEN_PCI_OP_aer_slotreset (9)
/* xen_pci_op error numbers */
#define XEN_PCI_ERR_success (0)
#define XEN_PCI_ERR_dev_not_found (-1)
#define XEN_PCI_ERR_invalid_offset (-2)
#define XEN_PCI_ERR_access_denied (-3)
#define XEN_PCI_ERR_not_implemented (-4)
/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
#define XEN_PCI_ERR_op_failed (-5)
/*
* it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry))
* Should not exceed 128
*/
#define SH_INFO_MAX_VEC 128
struct xen_msix_entry {
uint16_t vector;
uint16_t entry;
};
struct xen_pci_op {
/* IN: what action to perform: XEN_PCI_OP_* */
uint32_t cmd;
/* OUT: will contain an error number (if any) from errno.h */
int32_t err;
/* IN: which device to touch */
uint32_t domain; /* PCI Domain/Segment */
uint32_t bus;
uint32_t devfn;
/* IN: which configuration registers to touch */
int32_t offset;
int32_t size;
/* IN/OUT: Contains the result after a READ or the value to WRITE */
uint32_t value;
/* IN: Contains extra infor for this operation */
uint32_t info;
/*IN: param for msi-x */
struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
};
/*used for pcie aer handling*/
struct xen_pcie_aer_op {
/* IN: what action to perform: XEN_PCI_OP_* */
uint32_t cmd;
/*IN/OUT: return aer_op result or carry error_detected state as input*/
int32_t err;
/* IN: which device to touch */
uint32_t domain; /* PCI Domain/Segment*/
uint32_t bus;
uint32_t devfn;
};
struct xen_pci_sharedinfo {
/* flags - XEN_PCIF_* */
uint32_t flags;
struct xen_pci_op op;
struct xen_pcie_aer_op aer_op;
};
#endif /* __XEN_PCI_COMMON_H__ */
...@@ -27,8 +27,14 @@ enum xenbus_state ...@@ -27,8 +27,14 @@ enum xenbus_state
XenbusStateClosing = 5, /* The device is being closed XenbusStateClosing = 5, /* The device is being closed
due to an error or an unplug due to an error or an unplug
event. */ event. */
XenbusStateClosed = 6 XenbusStateClosed = 6,
/*
* Reconfiguring: The device is being reconfigured.
*/
XenbusStateReconfiguring = 7,
XenbusStateReconfigured = 8
}; };
#endif /* _XEN_PUBLIC_IO_XENBUS_H */ #endif /* _XEN_PUBLIC_IO_XENBUS_H */
......
...@@ -106,6 +106,57 @@ struct physdev_irq { ...@@ -106,6 +106,57 @@ struct physdev_irq {
uint32_t vector; uint32_t vector;
}; };
#define MAP_PIRQ_TYPE_MSI 0x0
#define MAP_PIRQ_TYPE_GSI 0x1
#define MAP_PIRQ_TYPE_UNKNOWN 0x2
#define PHYSDEVOP_map_pirq 13
struct physdev_map_pirq {
domid_t domid;
/* IN */
int type;
/* IN */
int index;
/* IN or OUT */
int pirq;
/* IN */
int bus;
/* IN */
int devfn;
/* IN */
int entry_nr;
/* IN */
uint64_t table_base;
};
#define PHYSDEVOP_unmap_pirq 14
struct physdev_unmap_pirq {
domid_t domid;
/* IN */
int pirq;
};
#define PHYSDEVOP_manage_pci_add 15
#define PHYSDEVOP_manage_pci_remove 16
struct physdev_manage_pci {
/* IN */
uint8_t bus;
uint8_t devfn;
};
#define PHYSDEVOP_manage_pci_add_ext 20
struct physdev_manage_pci_ext {
/* IN */
uint8_t bus;
uint8_t devfn;
unsigned is_extfn;
unsigned is_virtfn;
struct {
uint8_t bus;
uint8_t devfn;
} physfn;
};
/* /*
* Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
* hypercall since 0x00030202. * hypercall since 0x00030202.
...@@ -121,6 +172,22 @@ struct physdev_op { ...@@ -121,6 +172,22 @@ struct physdev_op {
} u; } u;
}; };
#define PHYSDEVOP_setup_gsi 21
struct physdev_setup_gsi {
int gsi;
/* IN */
uint8_t triggering;
/* IN */
uint8_t polarity;
/* IN */
};
#define PHYSDEVOP_get_nr_pirqs 22
struct physdev_nr_pirqs {
/* OUT */
uint32_t nr_pirqs;
};
/* /*
* Notify that some PIRQ-bound event channels have been unmasked. * Notify that some PIRQ-bound event channels have been unmasked.
* ** This command is obsolete since interface version 0x00030202 and is ** * ** This command is obsolete since interface version 0x00030202 and is **
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment