From ac3ede5371af34b0a89fa72b7a5bb706457b99ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Date: Wed, 12 May 2021 12:17:53 +0200 Subject: [PATCH] x86/xen: remove PVHv1 code PVHv1 was officially removed from Xen in 4.9, so just axe the related code from FreeBSD. Note FreeBSD supports PVHv2, which is the replacement for PVHv1. Sponsored by: Citrix Systems R&D Reviewed by: kib, Elliott Mitchell Differential Revision: https://reviews.freebsd.org/D30228 --- sys/amd64/amd64/machdep.c | 12 +- sys/amd64/amd64/mp_machdep.c | 4 +- sys/amd64/include/smp.h | 2 +- sys/conf/files | 1 - sys/conf/files.amd64 | 4 - sys/conf/files.x86 | 2 - sys/dev/xen/pci/xen_acpi_pci.c | 97 ---------- sys/dev/xen/pci/xen_pci.c | 79 -------- sys/dev/xen/pvcpu/pvcpu.c | 99 ---------- sys/i386/i386/machdep.c | 3 - sys/x86/include/init.h | 3 - sys/x86/x86/local_apic.c | 2 +- sys/x86/xen/pv.c | 6 - sys/x86/xen/pvcpu_enum.c | 264 ------------------------- sys/x86/xen/xen_intr.c | 340 +-------------------------------- sys/x86/xen/xen_msi.c | 133 ------------- sys/x86/xen/xen_nexus.c | 166 ---------------- sys/x86/xen/xen_pci_bus.c | 90 --------- sys/xen/evtchn/evtchnvar.h | 1 - sys/xen/xen_intr.h | 44 ----- sys/xen/xen_msi.h | 39 ---- sys/xen/xen_pci.h | 37 ---- 22 files changed, 14 insertions(+), 1414 deletions(-) delete mode 100644 sys/dev/xen/pci/xen_acpi_pci.c delete mode 100644 sys/dev/xen/pci/xen_pci.c delete mode 100644 sys/dev/xen/pvcpu/pvcpu.c delete mode 100644 sys/x86/xen/pvcpu_enum.c delete mode 100644 sys/x86/xen/xen_msi.c delete mode 100644 sys/x86/xen/xen_nexus.c delete mode 100644 sys/x86/xen/xen_pci_bus.c delete mode 100644 sys/xen/xen_msi.h delete mode 100644 sys/xen/xen_pci.h diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 497975f0ee30..9ddad323449b 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -187,13 +187,6 @@ struct init_ops init_ops = { .early_clock_source_init = i8254_init, .early_delay = i8254_delay, .parse_memmap = native_parse_memmap, -#ifdef SMP - .mp_bootaddress = mp_bootaddress, - .start_all_aps = native_start_all_aps, -#endif -#ifdef DEV_PCI - .msi_init = msi_init, -#endif }; /* @@ -1283,8 +1276,9 @@ getmemsize(caddr_t kmdp, u_int64_t first) * is configured to support APs and APs for the system start * in real mode mode (e.g. SMP bare metal). */ - if (init_ops.mp_bootaddress) - init_ops.mp_bootaddress(physmap, &physmap_idx); +#ifdef SMP + mp_bootaddress(physmap, &physmap_idx); +#endif /* call pmap initialization to make new kernel address space */ pmap_bootstrap(&first); diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 11f2bb8bbfc1..6f788c087f06 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -245,7 +245,7 @@ cpu_mp_start(void) mptramp_la57 = la57; /* Start each Application Processor */ - init_ops.start_all_aps(); + start_all_aps(); set_interrupt_apic_ids(); @@ -397,7 +397,7 @@ mp_realloc_pcpu(int cpuid, int domain) * start each AP in our list */ int -native_start_all_aps(void) +start_all_aps(void) { u_int64_t *pt5, *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index 8fbd89da0e57..ac9ed5f61a23 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -38,7 +38,7 @@ inthand_t IDTVEC(rendezvous_pti); void invlop_handler(void); -int native_start_all_aps(void); +int start_all_aps(void); void mp_bootaddress(vm_paddr_t *, unsigned int *); #endif /* !LOCORE */ diff --git a/sys/conf/files b/sys/conf/files index 40b02aba28d6..22083169bfc7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3545,7 +3545,6 @@ dev/xen/netback/netback.c optional xenhvm dev/xen/netfront/netfront.c optional xenhvm dev/xen/xenpci/xenpci.c optional xenpci dev/xen/timer/timer.c optional xenhvm -dev/xen/pvcpu/pvcpu.c optional xenhvm dev/xen/xenstore/xenstore.c optional xenhvm dev/xen/xenstore/xenstore_dev.c optional xenhvm dev/xen/xenstore/xenstored_dev.c optional xenhvm diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 9afaad72af74..1dd3a51a3af3 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -387,8 +387,6 @@ dev/viawd/viawd.c optional viawd dev/vmd/vmd.c optional vmd dev/vmd/vmd_bus.c optional vmd_bus dev/wbwd/wbwd.c optional wbwd -dev/xen/pci/xen_acpi_pci.c optional xenhvm -dev/xen/pci/xen_pci.c optional xenhvm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/imgact_aout.c optional compat_aout @@ -461,8 +459,6 @@ x86/x86/mptable.c optional mptable x86/x86/mptable_pci.c optional mptable pci x86/x86/msi.c optional pci x86/xen/pv.c optional xenhvm -x86/xen/pvcpu_enum.c optional xenhvm -x86/xen/xen_pci_bus.c optional xenhvm compat/linuxkpi/common/src/linux_fpu.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 index 0a2cd1554eb4..b8d1e5a17048 100644 --- a/sys/conf/files.x86 +++ b/sys/conf/files.x86 @@ -328,5 +328,3 @@ x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xenhvm x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xenhvm -x86/xen/xen_msi.c optional xenhvm -x86/xen/xen_nexus.c optional xenhvm diff --git a/sys/dev/xen/pci/xen_acpi_pci.c b/sys/dev/xen/pci/xen_acpi_pci.c deleted file mode 100644 index 11797fb772dd..000000000000 --- a/sys/dev/xen/pci/xen_acpi_pci.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" -#include "pci_if.h" - -static int -xen_acpi_pci_probe(device_t dev) -{ - - if (!xen_pv_domain()) - return (ENXIO); - if (acpi_get_handle(dev) == NULL) - return (ENXIO); - - device_set_desc(dev, "Xen ACPI PCI bus"); - - return (BUS_PROBE_SPECIFIC); -} - -static void -xen_acpi_pci_child_added(device_t dev, device_t child) -{ - - acpi_pci_child_added(dev, child); - xen_pci_child_added_method(dev, child); -} - -static device_method_t xen_acpi_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, xen_acpi_pci_probe), - - /* PCI interface overwrites */ - DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), - DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), - DEVMETHOD(pci_child_added, xen_acpi_pci_child_added), - - DEVMETHOD_END -}; - -static devclass_t pci_devclass; - -DECLARE_CLASS(acpi_pci_driver); -DEFINE_CLASS_1(pci, xen_acpi_pci_driver, xen_acpi_pci_methods, - sizeof(struct pci_softc), acpi_pci_driver); -DRIVER_MODULE(xen_acpi_pci, pcib, xen_acpi_pci_driver, pci_devclass, 0, 0); -MODULE_DEPEND(xen_acpi_pci, pci, 1, 1, 1); -MODULE_DEPEND(xen_acpi_pci, acpi, 1, 1, 1); -MODULE_VERSION(xen_acpi_pci, 1); diff --git a/sys/dev/xen/pci/xen_pci.c b/sys/dev/xen/pci/xen_pci.c deleted file mode 100644 index d1bd439d4b76..000000000000 --- a/sys/dev/xen/pci/xen_pci.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" -#include "pci_if.h" - -static int -xen_pci_probe(device_t dev) -{ - - if (!xen_pv_domain()) - return (ENXIO); - - device_set_desc(dev, "Xen PCI bus"); - - return (BUS_PROBE_DEFAULT); -} - -static device_method_t xen_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, xen_pci_probe), - - /* PCI interface overwrites */ - DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), - DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), - DEVMETHOD(pci_child_added, xen_pci_child_added_method), - - DEVMETHOD_END -}; - -static devclass_t pci_devclass; - -DEFINE_CLASS_1(pci, xen_pci_driver, xen_pci_methods, sizeof(struct pci_softc), - pci_driver); -DRIVER_MODULE(xen_pci, pcib, xen_pci_driver, pci_devclass, 0, 0); -MODULE_DEPEND(xen_pci, pci, 1, 1, 1); -MODULE_VERSION(xen_pci, 1); diff --git a/sys/dev/xen/pvcpu/pvcpu.c b/sys/dev/xen/pvcpu/pvcpu.c deleted file mode 100644 index 2d41dac387ad..000000000000 --- a/sys/dev/xen/pvcpu/pvcpu.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* - * Dummy Xen cpu device - * - * Since there's no ACPI on PVH guests, we need to create a dummy - * CPU device in order to fill the pcpu->pc_device field. - */ - -static void -xenpvcpu_identify(driver_t *driver, device_t parent) -{ - int i; - - /* Only attach in case the per-CPU device is not set. */ - if (!xen_domain() || PCPU_GET(device) != NULL) - return; - - CPU_FOREACH(i) { - if (BUS_ADD_CHILD(parent, 0, "pvcpu", i) == NULL) - panic("Unable to add Xen PV CPU device."); - } -} - -static int -xenpvcpu_probe(device_t dev) -{ - - device_set_desc(dev, "Xen PV CPU"); - return (BUS_PROBE_NOWILDCARD); -} - -static int -xenpvcpu_attach(device_t dev) -{ - struct pcpu *pc; - int cpu; - - cpu = device_get_unit(dev); - pc = pcpu_find(cpu); - pc->pc_device = dev; - return (0); -} - -static device_method_t xenpvcpu_methods[] = { - DEVMETHOD(device_identify, xenpvcpu_identify), - DEVMETHOD(device_probe, xenpvcpu_probe), - DEVMETHOD(device_attach, xenpvcpu_attach), - - DEVMETHOD_END -}; - -static driver_t xenpvcpu_driver = { - "pvcpu", - xenpvcpu_methods, - 0, -}; - -devclass_t xenpvcpu_devclass; - -DRIVER_MODULE(xenpvcpu, xenpv, xenpvcpu_driver, xenpvcpu_devclass, 0, 0); -MODULE_DEPEND(xenpvcpu, xenpv, 1, 1, 1); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 5fec2e448c53..ce4a264ede01 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -212,9 +212,6 @@ extern struct sysentvec elf32_freebsd_sysvec; struct init_ops init_ops = { .early_clock_source_init = i8254_init, .early_delay = i8254_delay, -#ifdef DEV_APIC - .msi_init = msi_init, -#endif }; static void diff --git a/sys/x86/include/init.h b/sys/x86/include/init.h index 880cabaa9496..4b1d318a6523 100644 --- a/sys/x86/include/init.h +++ b/sys/x86/include/init.h @@ -41,9 +41,6 @@ struct init_ops { void (*early_clock_source_init)(void); void (*early_delay)(int); void (*parse_memmap)(caddr_t, vm_paddr_t *, int *); - void (*mp_bootaddress)(vm_paddr_t *, unsigned int *); - int (*start_all_aps)(void); - void (*msi_init)(void); }; extern struct init_ops init_ops; diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 36010fe38102..5b4910d4b891 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -1979,7 +1979,7 @@ apic_setup_io(void *dummy __unused) lapic_dump("BSP"); /* Enable the MSI "pic". */ - init_ops.msi_init(); + msi_init(); #ifdef XENHVM xen_intr_alloc_irqs(); diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 3511df779a92..c6dfff511c0c 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -121,11 +120,6 @@ struct init_ops xen_pvh_init_ops = { .early_clock_source_init = xen_clock_init, .early_delay = xen_delay, .parse_memmap = xen_pvh_parse_memmap, -#ifdef SMP - .mp_bootaddress = mp_bootaddress, - .start_all_aps = native_start_all_aps, -#endif - .msi_init = msi_init, }; static struct bios_smap xen_smap[MAX_E820_ENTRIES]; diff --git a/sys/x86/xen/pvcpu_enum.c b/sys/x86/xen/pvcpu_enum.c deleted file mode 100644 index 5d5c265fcc5f..000000000000 --- a/sys/x86/xen/pvcpu_enum.c +++ /dev/null @@ -1,264 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2013 Roger Pau Monné - * All rights reserved. - * Copyright (c) 2003 John Baldwin - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -static int xenpv_probe(void); -static int xenpv_probe_cpus(void); -static int xenpv_setup_local(void); -static int xenpv_setup_io(void); - -static ACPI_TABLE_MADT *madt; -static vm_paddr_t madt_physaddr; -static vm_offset_t madt_length; - -static struct apic_enumerator xenpv_enumerator = { - .apic_name = "Xen PV", - .apic_probe = xenpv_probe, - .apic_probe_cpus = xenpv_probe_cpus, - .apic_setup_local = xenpv_setup_local, - .apic_setup_io = xenpv_setup_io -}; - -/*--------------------- Helper functions to parse MADT -----------------------*/ - -/* - * Parse an interrupt source override for an ISA interrupt. - */ -static void -madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr) -{ - enum intr_trigger trig; - enum intr_polarity pol; - int ret; - - if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 && - intr->GlobalIrq == 2) { - if (bootverbose) - printf("MADT: Skipping timer override\n"); - return; - } - - madt_parse_interrupt_values(intr, &trig, &pol); - - /* Remap the IRQ if it is mapped to a different interrupt vector. */ - if (intr->SourceIrq != intr->GlobalIrq && intr->GlobalIrq > 15 && - intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) - /* - * If the SCI is remapped to a non-ISA global interrupt, - * then override the vector we use to setup. - */ - acpi_OverrideInterruptLevel(intr->GlobalIrq); - - /* Register the IRQ with the polarity and trigger mode found. */ - ret = xen_register_pirq(intr->GlobalIrq, trig, pol); - if (ret != 0) - panic("Unable to register interrupt override"); -} - -/* - * Call the handler routine for each entry in the MADT table. - */ -static void -madt_walk_table(acpi_subtable_handler *handler, void *arg) -{ - - acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, - handler, arg); -} - -/* - * Parse interrupt entries. - */ -static void -madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, void *arg __unused) -{ - - if (entry->Type == ACPI_MADT_TYPE_INTERRUPT_OVERRIDE) - madt_parse_interrupt_override( - (ACPI_MADT_INTERRUPT_OVERRIDE *)entry); -} - -/*---------------------------- Xen PV enumerator -----------------------------*/ - -/* - * This enumerator will only be registered on PVH - */ -static int -xenpv_probe(void) -{ - return (0); -} - -/* - * Test each possible vCPU in order to find the number of vCPUs - */ -static int -xenpv_probe_cpus(void) -{ -#ifdef SMP - int i, ret; - - for (i = 0; i < MAXCPU && (i * 2) < MAX_APIC_ID; i++) { - ret = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); - mp_ncpus = min(mp_ncpus + 1, MAXCPU); - } - mp_maxid = mp_ncpus - 1; - max_apic_id = mp_ncpus * 2; -#endif - return (0); -} - -/* - * Initialize the vCPU id of the BSP - */ -static int -xenpv_setup_local(void) -{ -#ifdef SMP - int i, ret; - - for (i = 0; i < MAXCPU && (i * 2) < MAX_APIC_ID; i++) { - ret = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); - if (ret >= 0) - lapic_create((i * 2), (i == 0)); - } -#endif - - PCPU_SET(vcpu_id, 0); - lapic_init(0); - return (0); -} - -/* - * On PVH guests there's no IO APIC - */ -static int -xenpv_setup_io(void) -{ - - if (xen_initial_domain()) { - /* - * NB: we could iterate over the MADT IOAPIC entries in order - * to figure out the exact number of IOAPIC interrupts, but - * this is legacy code so just keep using the previous - * behaviour and assume a maximum of 256 interrupts. - */ - num_io_irqs = max(255, num_io_irqs); - - acpi_SetDefaultIntrModel(ACPI_INTR_APIC); - } - return (0); -} - -void -xenpv_register_pirqs(struct pic *pic __unused) -{ - unsigned int i; - int ret; - - /* Map MADT */ - madt_physaddr = acpi_find_table(ACPI_SIG_MADT); - madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT); - madt_length = madt->Header.Length; - - /* Try to initialize ACPI so that we can access the FADT. */ - ret = acpi_Startup(); - if (ACPI_FAILURE(ret)) { - printf("MADT: ACPI Startup failed with %s\n", - AcpiFormatException(ret)); - printf("Try disabling either ACPI or apic support.\n"); - panic("Using MADT but ACPI doesn't work"); - } - - /* Run through the table to see if there are any overrides. */ - madt_walk_table(madt_parse_ints, NULL); - - /* - * If there was not an explicit override entry for the SCI, - * force it to use level trigger and active-low polarity. - */ - if (!madt_found_sci_override) { - printf( -"MADT: Forcing active-low polarity and level trigger for SCI\n"); - ret = xen_register_pirq(AcpiGbl_FADT.SciInterrupt, - INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW); - if (ret != 0) - panic("Unable to register SCI IRQ"); - } - - /* Register legacy ISA IRQs */ - for (i = 1; i < 16; i++) { - if (intr_lookup_source(i) != NULL) - continue; - ret = xen_register_pirq(i, INTR_TRIGGER_EDGE, - INTR_POLARITY_LOW); - if (ret != 0 && bootverbose) - printf("Unable to register legacy IRQ#%u: %d\n", i, - ret); - } -} - -static void -xenpv_register(void *dummy __unused) -{ - if (xen_pv_domain()) { - apic_register_enumerator(&xenpv_enumerator); - } -} -SYSINIT(xenpv_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, xenpv_register, NULL); diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index 435db2e31693..c729ffddb345 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -114,8 +114,6 @@ DPCPU_DEFINE_STATIC(struct xen_intr_pcpu_data, xen_intr_pcpu) = { DPCPU_DECLARE(struct vcpu_info *, vcpu_info); -#define XEN_EEXIST 17 /* Xen "already exists" error */ -#define XEN_ALLOCATE_VECTOR 0 /* Allocate a vector for this event channel */ #define XEN_INVALID_EVTCHN 0 /* Invalid event channel */ #define is_valid_evtchn(x) ((x) != XEN_INVALID_EVTCHN) @@ -126,7 +124,6 @@ struct xenisrc { int xi_cpu; /* VCPU for delivery. */ int xi_vector; /* Global isrc vector number. */ evtchn_port_t xi_port; - int xi_pirq; int xi_virq; void *xi_cookie; u_int xi_close:1; /* close on unbind? */ @@ -149,14 +146,6 @@ static int xen_intr_config_intr(struct intsrc *isrc, enum intr_trigger trig, enum intr_polarity pol); static int xen_intr_assign_cpu(struct intsrc *isrc, u_int apic_id); -static void xen_intr_pirq_enable_source(struct intsrc *isrc); -static void xen_intr_pirq_disable_source(struct intsrc *isrc, int eoi); -static void xen_intr_pirq_eoi_source(struct intsrc *isrc); -static void xen_intr_pirq_enable_intr(struct intsrc *isrc); -static void xen_intr_pirq_disable_intr(struct intsrc *isrc); -static int xen_intr_pirq_config_intr(struct intsrc *isrc, - enum intr_trigger trig, enum intr_polarity pol); - /** * PIC interface for all event channel port types except physical IRQs. */ @@ -174,30 +163,9 @@ struct pic xen_intr_pic = { .pic_assign_cpu = xen_intr_assign_cpu }; -/** - * PIC interface for all event channel representing - * physical interrupt sources. - */ -struct pic xen_intr_pirq_pic = { -#ifdef __amd64__ - .pic_register_sources = xenpv_register_pirqs, -#endif - .pic_enable_source = xen_intr_pirq_enable_source, - .pic_disable_source = xen_intr_pirq_disable_source, - .pic_eoi_source = xen_intr_pirq_eoi_source, - .pic_enable_intr = xen_intr_pirq_enable_intr, - .pic_disable_intr = xen_intr_pirq_disable_intr, - .pic_vector = xen_intr_vector, - .pic_source_pending = xen_intr_source_pending, - .pic_config_intr = xen_intr_pirq_config_intr, - .pic_assign_cpu = xen_intr_assign_cpu -}; - static struct mtx xen_intr_isrc_lock; static u_int xen_intr_auto_vector_count; static struct xenisrc *xen_intr_port_to_isrc[NR_EVENT_CHANNELS]; -static u_long *xen_intr_pirq_eoi_map; -static boolean_t xen_intr_pirq_eoi_map_enabled; /*------------------------- Private Functions --------------------------------*/ /** @@ -305,10 +273,11 @@ xen_intr_find_unused_isrc(enum evtchn_type type) * object or NULL. */ static struct xenisrc * -xen_intr_alloc_isrc(enum evtchn_type type, int vector) +xen_intr_alloc_isrc(enum evtchn_type type) { static int warned; struct xenisrc *isrc; + unsigned int vector; KASSERT(mtx_owned(&xen_intr_isrc_lock), ("Evtchn alloc lock not held")); @@ -320,18 +289,15 @@ xen_intr_alloc_isrc(enum evtchn_type type, int vector) return (NULL); } - if (type != EVTCHN_TYPE_PIRQ) { - vector = first_evtchn_irq + xen_intr_auto_vector_count; - xen_intr_auto_vector_count++; - } + vector = first_evtchn_irq + xen_intr_auto_vector_count; + xen_intr_auto_vector_count++; KASSERT((intr_lookup_source(vector) == NULL), ("Trying to use an already allocated vector")); mtx_unlock(&xen_intr_isrc_lock); isrc = malloc(sizeof(*isrc), M_XENINTR, M_WAITOK | M_ZERO); - isrc->xi_intsrc.is_pic = - (type == EVTCHN_TYPE_PIRQ) ? &xen_intr_pirq_pic : &xen_intr_pic; + isrc->xi_intsrc.is_pic = &xen_intr_pic; isrc->xi_vector = vector; isrc->xi_type = type; intr_register_source(&isrc->xi_intsrc); @@ -416,7 +382,7 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, mtx_lock(&xen_intr_isrc_lock); isrc = xen_intr_find_unused_isrc(type); if (isrc == NULL) { - isrc = xen_intr_alloc_isrc(type, XEN_ALLOCATE_VECTOR); + isrc = xen_intr_alloc_isrc(type); if (isrc == NULL) { mtx_unlock(&xen_intr_isrc_lock); return (ENOSPC); @@ -632,8 +598,7 @@ xen_intr_init(void *dummy __unused) { shared_info_t *s = HYPERVISOR_shared_info; struct xen_intr_pcpu_data *pcpu; - struct physdev_pirq_eoi_gmfn eoi_gmfn; - int i, rc; + int i; if (!xen_domain()) return (0); @@ -653,18 +618,7 @@ xen_intr_init(void *dummy __unused) for (i = 0; i < nitems(s->evtchn_mask); i++) atomic_store_rel_long(&s->evtchn_mask[i], ~0); - /* Try to register PIRQ EOI map */ - xen_intr_pirq_eoi_map = malloc(PAGE_SIZE, M_XENINTR, M_WAITOK | M_ZERO); - eoi_gmfn.gmfn = atop(vtophys(xen_intr_pirq_eoi_map)); - rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn); - if (rc != 0 && bootverbose) - printf("Xen interrupts: unable to register PIRQ EOI map\n"); - else - xen_intr_pirq_eoi_map_enabled = true; - intr_register_pic(&xen_intr_pic); - if (xen_pv_domain() && xen_initial_domain()) - intr_register_pic(&xen_intr_pirq_pic); if (bootverbose) printf("Xen interrupt system initialized\n"); @@ -1020,184 +974,6 @@ xen_intr_enable_intr(struct intsrc *base_isrc) evtchn_unmask_port(isrc->xi_port); } -/*------------------ Physical Interrupt Source PIC Functions -----------------*/ -/* - * Mask a level triggered interrupt source. - * - * \param isrc The interrupt source to mask (if necessary). - * \param eoi If non-zero, perform any necessary end-of-interrupt - * acknowledgements. - */ -static void -xen_intr_pirq_disable_source(struct intsrc *base_isrc, int eoi) -{ - struct xenisrc *isrc; - - isrc = (struct xenisrc *)base_isrc; - - if (isrc->xi_edgetrigger == 0) - evtchn_mask_port(isrc->xi_port); - if (eoi == PIC_EOI) - xen_intr_pirq_eoi_source(base_isrc); -} - -/* - * Unmask a level triggered interrupt source. - * - * \param isrc The interrupt source to unmask (if necessary). - */ -static void -xen_intr_pirq_enable_source(struct intsrc *base_isrc) -{ - struct xenisrc *isrc; - - isrc = (struct xenisrc *)base_isrc; - - if (isrc->xi_edgetrigger == 0) - evtchn_unmask_port(isrc->xi_port); -} - -/* - * Perform any necessary end-of-interrupt acknowledgements. - * - * \param isrc The interrupt source to EOI. - */ -static void -xen_intr_pirq_eoi_source(struct intsrc *base_isrc) -{ - struct xenisrc *isrc; - int error; - - isrc = (struct xenisrc *)base_isrc; - - if (xen_test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)) { - struct physdev_eoi eoi = { .irq = isrc->xi_pirq }; - - error = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); - if (error != 0) - panic("Unable to EOI PIRQ#%d: %d\n", - isrc->xi_pirq, error); - } -} - -/* - * Enable and unmask the interrupt source. - * - * \param isrc The interrupt source to enable. - */ -static void -xen_intr_pirq_enable_intr(struct intsrc *base_isrc) -{ - struct xenisrc *isrc; - struct evtchn_bind_pirq bind_pirq; - struct physdev_irq_status_query irq_status; - int error; - - isrc = (struct xenisrc *)base_isrc; - - if (!xen_intr_pirq_eoi_map_enabled) { - irq_status.irq = isrc->xi_pirq; - error = HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, - &irq_status); - if (error) - panic("unable to get status of IRQ#%d", isrc->xi_pirq); - - if (irq_status.flags & XENIRQSTAT_needs_eoi) { - /* - * Since the dynamic PIRQ EOI map is not available - * mark the PIRQ as needing EOI unconditionally. - */ - xen_set_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map); - } - } - - bind_pirq.pirq = isrc->xi_pirq; - bind_pirq.flags = isrc->xi_edgetrigger ? 0 : BIND_PIRQ__WILL_SHARE; - error = HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &bind_pirq); - if (error) - panic("unable to bind IRQ#%d", isrc->xi_pirq); - - isrc->xi_port = bind_pirq.port; - - mtx_lock(&xen_intr_isrc_lock); - KASSERT((xen_intr_port_to_isrc[bind_pirq.port] == NULL), - ("trying to override an already setup event channel port")); - xen_intr_port_to_isrc[bind_pirq.port] = isrc; - mtx_unlock(&xen_intr_isrc_lock); - - evtchn_unmask_port(isrc->xi_port); -} - -/* - * Disable an interrupt source. - * - * \param isrc The interrupt source to disable. - */ -static void -xen_intr_pirq_disable_intr(struct intsrc *base_isrc) -{ - struct xenisrc *isrc; - struct evtchn_close close; - int error; - - isrc = (struct xenisrc *)base_isrc; - - evtchn_mask_port(isrc->xi_port); - - close.port = isrc->xi_port; - error = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close); - if (error) - panic("unable to close event channel %d IRQ#%d", - isrc->xi_port, isrc->xi_pirq); - - mtx_lock(&xen_intr_isrc_lock); - xen_intr_port_to_isrc[isrc->xi_port] = NULL; - mtx_unlock(&xen_intr_isrc_lock); - - isrc->xi_port = 0; -} - -/** - * Perform configuration of an interrupt source. - * - * \param isrc The interrupt source to configure. - * \param trig Edge or level. - * \param pol Active high or low. - * - * \returns 0 if no events are pending, otherwise non-zero. - */ -static int -xen_intr_pirq_config_intr(struct intsrc *base_isrc, enum intr_trigger trig, - enum intr_polarity pol) -{ - struct xenisrc *isrc = (struct xenisrc *)base_isrc; - struct physdev_setup_gsi setup_gsi; - int error; - - KASSERT(!(trig == INTR_TRIGGER_CONFORM || pol == INTR_POLARITY_CONFORM), - ("%s: Conforming trigger or polarity\n", __func__)); - - setup_gsi.gsi = isrc->xi_pirq; - setup_gsi.triggering = trig == INTR_TRIGGER_EDGE ? 0 : 1; - setup_gsi.polarity = pol == INTR_POLARITY_HIGH ? 0 : 1; - - error = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi); - if (error == -XEN_EEXIST) { - if ((isrc->xi_edgetrigger && (trig != INTR_TRIGGER_EDGE)) || - (isrc->xi_activehi && (pol != INTR_POLARITY_HIGH))) - panic("unable to reconfigure interrupt IRQ#%d", - isrc->xi_pirq); - error = 0; - } - if (error) - panic("unable to configure IRQ#%d\n", isrc->xi_pirq); - - isrc->xi_activehi = pol == INTR_POLARITY_HIGH ? 1 : 0; - isrc->xi_edgetrigger = trig == INTR_TRIGGER_EDGE ? 1 : 0; - - return (0); -} - /*--------------------------- Public Functions -------------------------------*/ /*------- API comments for these methods can be found in xen/xenintr.h -------*/ int @@ -1412,101 +1188,6 @@ xen_intr_alloc_and_bind_ipi(u_int cpu, driver_filter_t filter, #endif } -int -xen_register_pirq(int vector, enum intr_trigger trig, enum intr_polarity pol) -{ - struct physdev_map_pirq map_pirq; - struct xenisrc *isrc; - int error; - - if (vector == 0) - return (EINVAL); - - if (bootverbose) - printf("xen: register IRQ#%d\n", vector); - - map_pirq.domid = DOMID_SELF; - map_pirq.type = MAP_PIRQ_TYPE_GSI; - map_pirq.index = vector; - map_pirq.pirq = vector; - - error = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_pirq); - if (error) { - printf("xen: unable to map IRQ#%d\n", vector); - return (error); - } - - mtx_lock(&xen_intr_isrc_lock); - isrc = xen_intr_alloc_isrc(EVTCHN_TYPE_PIRQ, vector); - mtx_unlock(&xen_intr_isrc_lock); - KASSERT((isrc != NULL), ("xen: unable to allocate isrc for interrupt")); - isrc->xi_pirq = vector; - isrc->xi_activehi = pol == INTR_POLARITY_HIGH ? 1 : 0; - isrc->xi_edgetrigger = trig == INTR_TRIGGER_EDGE ? 1 : 0; - - return (0); -} - -int -xen_register_msi(device_t dev, int vector, int count) -{ - struct physdev_map_pirq msi_irq; - struct xenisrc *isrc; - int ret; - - memset(&msi_irq, 0, sizeof(msi_irq)); - msi_irq.domid = DOMID_SELF; - msi_irq.type = count == 1 ? - MAP_PIRQ_TYPE_MSI_SEG : MAP_PIRQ_TYPE_MULTI_MSI; - msi_irq.index = -1; - msi_irq.pirq = -1; - msi_irq.bus = pci_get_bus(dev) | (pci_get_domain(dev) << 16); - msi_irq.devfn = (pci_get_slot(dev) << 3) | pci_get_function(dev); - msi_irq.entry_nr = count; - - ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &msi_irq); - if (ret != 0) - return (ret); - if (count != msi_irq.entry_nr) { - panic("unable to setup all requested MSI vectors " - "(expected %d got %d)", count, msi_irq.entry_nr); - } - - mtx_lock(&xen_intr_isrc_lock); - for (int i = 0; i < count; i++) { - isrc = xen_intr_alloc_isrc(EVTCHN_TYPE_PIRQ, vector + i); - KASSERT(isrc != NULL, - ("xen: unable to allocate isrc for interrupt")); - isrc->xi_pirq = msi_irq.pirq + i; - /* MSI interrupts are always edge triggered */ - isrc->xi_edgetrigger = 1; - } - mtx_unlock(&xen_intr_isrc_lock); - - return (0); -} - -int -xen_release_msi(int vector) -{ - struct physdev_unmap_pirq unmap; - struct xenisrc *isrc; - int ret; - - isrc = (struct xenisrc *)intr_lookup_source(vector); - if (isrc == NULL) - return (ENXIO); - - unmap.pirq = isrc->xi_pirq; - ret = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap); - if (ret != 0) - return (ret); - - xen_intr_release_isrc(isrc); - - return (0); -} - int xen_intr_describe(xen_intr_handle_t port_handle, const char *fmt, ...) { @@ -1630,7 +1311,6 @@ xen_intr_print_type(enum evtchn_type type) { static const char *evtchn_type_to_string[EVTCHN_TYPE_COUNT] = { [EVTCHN_TYPE_UNBOUND] = "UNBOUND", - [EVTCHN_TYPE_PIRQ] = "PIRQ", [EVTCHN_TYPE_VIRQ] = "VIRQ", [EVTCHN_TYPE_IPI] = "IPI", [EVTCHN_TYPE_PORT] = "PORT", @@ -1651,12 +1331,6 @@ xen_intr_dump_port(struct xenisrc *isrc) db_printf("Port %d Type: %s\n", isrc->xi_port, xen_intr_print_type(isrc->xi_type)); - if (isrc->xi_type == EVTCHN_TYPE_PIRQ) { - db_printf("\tPirq: %d ActiveHi: %d EdgeTrigger: %d " - "NeedsEOI: %d\n", - isrc->xi_pirq, isrc->xi_activehi, isrc->xi_edgetrigger, - !!xen_test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)); - } if (isrc->xi_type == EVTCHN_TYPE_VIRQ) db_printf("\tVirq: %d\n", isrc->xi_virq); diff --git a/sys/x86/xen/xen_msi.c b/sys/x86/xen/xen_msi.c deleted file mode 100644 index 54215cfc0b3e..000000000000 --- a/sys/x86/xen/xen_msi.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -static struct mtx msi_lock; -static u_int msi_last_irq; - -void -xen_msi_init(void) -{ - - MPASS(num_io_irqs > 0); - first_msi_irq = num_io_irqs; - if (num_msi_irqs > UINT_MAX - first_msi_irq) - panic("num_msi_irqs too high"); - num_io_irqs = first_msi_irq + num_msi_irqs; - - mtx_init(&msi_lock, "msi", NULL, MTX_DEF); -} - -/* - * Try to allocate 'count' interrupt sources with contiguous IDT values. - */ -int -xen_msi_alloc(device_t dev, int count, int maxcount, int *irqs) -{ - int i, ret = 0; - - mtx_lock(&msi_lock); - - /* If we would exceed the max, give up. */ - if (msi_last_irq + count > num_msi_irqs) { - mtx_unlock(&msi_lock); - return (ENXIO); - } - - /* Allocate MSI vectors */ - for (i = 0; i < count; i++) - irqs[i] = first_msi_irq + msi_last_irq++; - - mtx_unlock(&msi_lock); - - ret = xen_register_msi(dev, irqs[0], count); - if (ret != 0) - return (ret); - - for (i = 0; i < count; i++) - nexus_add_irq(irqs[i]); - - return (0); -} - -int -xen_msi_release(int *irqs, int count) -{ - int i, ret; - - for (i = 0; i < count; i++) { - ret = xen_release_msi(irqs[i]); - if (ret != 0) - return (ret); - } - - return (0); -} - -int -xen_msi_map(int irq, uint64_t *addr, uint32_t *data) -{ - - return (0); -} - -int -xen_msix_alloc(device_t dev, int *irq) -{ - - return (ENXIO); -} - -int -xen_msix_release(int irq) -{ - - return (ENOENT); -} diff --git a/sys/x86/xen/xen_nexus.c b/sys/x86/xen/xen_nexus.c deleted file mode 100644 index 2469abb63266..000000000000 --- a/sys/x86/xen/xen_nexus.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2013 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" - -/* - * Xen nexus(4) driver. - */ -static int -nexus_xen_probe(device_t dev) -{ - - if (!xen_pv_domain()) - return (ENXIO); - - return (BUS_PROBE_SPECIFIC); -} - -static int -nexus_xen_attach(device_t dev) -{ - int error; - device_t acpi_dev = NULL; - - nexus_init_resources(); - bus_generic_probe(dev); - - if (xen_initial_domain()) { - /* Disable some ACPI devices that are not usable by Dom0 */ - acpi_cpu_disabled = true; - acpi_hpet_disabled = true; - acpi_timer_disabled = true; - - acpi_dev = BUS_ADD_CHILD(dev, 10, "acpi", 0); - if (acpi_dev == NULL) - panic("Unable to add ACPI bus to Xen Dom0"); - } - - error = bus_generic_attach(dev); - if (xen_initial_domain() && (error == 0)) - acpi_install_wakeup_handler(device_get_softc(acpi_dev)); - - return (error); -} - -static int -nexus_xen_config_intr(device_t dev, int irq, enum intr_trigger trig, - enum intr_polarity pol) -{ - int ret; - - /* - * ISA and PCI intline IRQs are not preregistered on Xen, so - * intercept calls to configure those and register them on the fly. - */ - if ((irq < first_msi_irq) && (intr_lookup_source(irq) == NULL)) { - ret = xen_register_pirq(irq, trig, pol); - if (ret != 0) - return (ret); - nexus_add_irq(irq); - } - return (intr_config_intr(irq, trig, pol)); -} - -static int -nexus_xen_alloc_msix(device_t pcib, device_t dev, int *irq) -{ - - return (xen_msix_alloc(dev, irq)); -} - -static int -nexus_xen_release_msix(device_t pcib, device_t dev, int irq) -{ - - return (xen_msix_release(irq)); -} - -static int -nexus_xen_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) -{ - - return (xen_msi_alloc(dev, count, maxcount, irqs)); -} - -static int -nexus_xen_release_msi(device_t pcib, device_t dev, int count, int *irqs) -{ - - return (xen_msi_release(irqs, count)); -} - -static int -nexus_xen_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data) -{ - - return (xen_msi_map(irq, addr, data)); -} - -static device_method_t nexus_xen_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, nexus_xen_probe), - DEVMETHOD(device_attach, nexus_xen_attach), - - /* INTR */ - DEVMETHOD(bus_config_intr, nexus_xen_config_intr), - - /* MSI */ - DEVMETHOD(pcib_alloc_msi, nexus_xen_alloc_msi), - DEVMETHOD(pcib_release_msi, nexus_xen_release_msi), - DEVMETHOD(pcib_alloc_msix, nexus_xen_alloc_msix), - DEVMETHOD(pcib_release_msix, nexus_xen_release_msix), - DEVMETHOD(pcib_map_msi, nexus_xen_map_msi), - { 0, 0 } -}; - -DEFINE_CLASS_1(nexus, nexus_xen_driver, nexus_xen_methods, 1, nexus_driver); -static devclass_t nexus_devclass; - -DRIVER_MODULE(nexus_xen, root, nexus_xen_driver, nexus_devclass, 0, 0); diff --git a/sys/x86/xen/xen_pci_bus.c b/sys/x86/xen/xen_pci_bus.c deleted file mode 100644 index e75463fa0249..000000000000 --- a/sys/x86/xen/xen_pci_bus.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" -#include "pci_if.h" - -void -xen_pci_enable_msi_method(device_t dev, device_t child, uint64_t address, - uint16_t data) -{ - struct pci_devinfo *dinfo = device_get_ivars(child); - struct pcicfg_msi *msi = &dinfo->cfg.msi; - - /* Enable MSI in the control register. */ - msi->msi_ctrl |= PCIM_MSICTRL_MSI_ENABLE; - pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, - msi->msi_ctrl, 2); -} - -void -xen_pci_disable_msi_method(device_t dev, device_t child) -{ - struct pci_devinfo *dinfo = device_get_ivars(child); - struct pcicfg_msi *msi = &dinfo->cfg.msi; - - msi->msi_ctrl &= ~PCIM_MSICTRL_MSI_ENABLE; - pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, - msi->msi_ctrl, 2); -} - -void -xen_pci_child_added_method(device_t dev, device_t child) -{ - struct pci_devinfo *dinfo; - struct physdev_pci_device_add add_pci; - int error; - - dinfo = device_get_ivars(child); - KASSERT((dinfo != NULL), - ("xen_pci_add_child_method called with NULL dinfo")); - - bzero(&add_pci, sizeof(add_pci)); - add_pci.seg = dinfo->cfg.domain; - add_pci.bus = dinfo->cfg.bus; - add_pci.devfn = (dinfo->cfg.slot << 3) | dinfo->cfg.func; - error = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add_pci); - if (error) - panic("unable to add device bus %u devfn %u error: %d\n", - add_pci.bus, add_pci.devfn, error); -} diff --git a/sys/xen/evtchn/evtchnvar.h b/sys/xen/evtchn/evtchnvar.h index 8008d23297d3..c7c38df34a00 100644 --- a/sys/xen/evtchn/evtchnvar.h +++ b/sys/xen/evtchn/evtchnvar.h @@ -39,7 +39,6 @@ enum evtchn_type { EVTCHN_TYPE_UNBOUND, - EVTCHN_TYPE_PIRQ, EVTCHN_TYPE_VIRQ, EVTCHN_TYPE_IPI, EVTCHN_TYPE_PORT, diff --git a/sys/xen/xen_intr.h b/sys/xen/xen_intr.h index 74570267364d..6725fa9e0399 100644 --- a/sys/xen/xen_intr.h +++ b/sys/xen/xen_intr.h @@ -152,18 +152,6 @@ int xen_intr_alloc_and_bind_ipi(u_int cpu, driver_filter_t filter, enum intr_type irqflags, xen_intr_handle_t *handlep); -/** - * Register a physical interrupt vector and setup the interrupt source. - * - * \param vector The global vector to use. - * \param trig Default trigger method. - * \param pol Default polarity of the interrupt. - * - * \returns 0 on success, otherwise an errno. - */ -int xen_register_pirq(int vector, enum intr_trigger trig, - enum intr_polarity pol); - /** * Unbind an interrupt handler from its interrupt source. * @@ -218,28 +206,6 @@ void xen_intr_signal(xen_intr_handle_t handle); */ evtchn_port_t xen_intr_port(xen_intr_handle_t handle); -/** - * Setup MSI vector interrupt(s). - * - * \param dev The device that requests the binding. - * - * \param vector Requested initial vector to bind the MSI interrupt(s) to. - * - * \param count Number of vectors to allocate. - * - * \returns 0 on success, otherwise an errno. - */ -int xen_register_msi(device_t dev, int vector, int count); - -/** - * Teardown a MSI vector interrupt. - * - * \param vector Requested vector to release. - * - * \returns 0 on success, otherwise an errno. - */ -int xen_release_msi(int vector); - /** * Bind an event channel port with a handler * @@ -271,14 +237,4 @@ int xen_intr_add_handler(const char *name, driver_filter_t filter, int xen_intr_get_evtchn_from_port(evtchn_port_t port, xen_intr_handle_t *handlep); -/** - * Register the IO-APIC PIRQs when running in legacy PVH Dom0 mode. - * - * \param pic PIC instance. - * - * NB: this should be removed together with the support for legacy PVH mode. - */ -struct pic; -void xenpv_register_pirqs(struct pic *pic); - #endif /* _XEN_INTR_H_ */ diff --git a/sys/xen/xen_msi.h b/sys/xen/xen_msi.h deleted file mode 100644 index 2817878fc71b..000000000000 --- a/sys/xen/xen_msi.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef __XEN_MSI_H__ -#define __XEN_MSI_H__ - -void xen_msi_init(void); -int xen_msi_map(int irq, uint64_t *addr, uint32_t *data); -int xen_msi_alloc(device_t dev, int count, int maxcount, int *irqs); -int xen_msi_release(int *irqs, int count); -int xen_msix_alloc(device_t dev, int *irq); -int xen_msix_release(int irq); - -#endif /* !__XEN_MSI_H__ */ diff --git a/sys/xen/xen_pci.h b/sys/xen/xen_pci.h deleted file mode 100644 index f19168e0598d..000000000000 --- a/sys/xen/xen_pci.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef __XEN_PCI_H__ -#define __XEN_PCI_H__ - -void xen_pci_enable_msi_method(device_t dev, device_t child, uint64_t address, - uint16_t data); -void xen_pci_disable_msi_method(device_t dev, device_t child); -void xen_pci_child_added_method(device_t dev, device_t child); - -#endif /* !__XEN_PCI_H__ */