git: ac3ede5371af - main - x86/xen: remove PVHv1 code

Roger Pau Monné royger at FreeBSD.org
Mon May 17 09:43:06 UTC 2021


The branch main has been updated by royger:

URL: https://cgit.FreeBSD.org/src/commit/?id=ac3ede5371af34b0a89fa72b7a5bb706457b99ad

commit ac3ede5371af34b0a89fa72b7a5bb706457b99ad
Author:     Roger Pau Monné <royger at FreeBSD.org>
AuthorDate: 2021-05-12 10:17:53 +0000
Commit:     Roger Pau Monné <royger at FreeBSD.org>
CommitDate: 2021-05-17 09:41:21 +0000

    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(-)

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é <roger.pau at citrix.com>
- * 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#include <dev/acpica/acpivar.h>
-#include <dev/acpica/acpi_pcivar.h>
-
-#include <sys/pciio.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pci_private.h>
-
-#include <xen/xen-os.h>
-#include <xen/hypervisor.h>
-#include <xen/xen_pci.h>
-
-#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é <roger.pau at citrix.com>
- * 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-
-#include <sys/pciio.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pci_private.h>
-
-#include <xen/xen-os.h>
-#include <xen/hypervisor.h>
-#include <xen/xen_pci.h>
-
-#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é <roger.pau at citrix.com>
- * 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/pcpu.h>
-#include <sys/smp.h>
-
-#include <xen/xen-os.h>
-
-/*
- * 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 <xen/hypervisor.h>
 #include <xen/xenstore/xenstorevar.h>
 #include <xen/xen_pv.h>
-#include <xen/xen_msi.h>
 
 #include <xen/interface/arch-x86/hvm/start_info.h>
 #include <xen/interface/vcpu.h>
@@ -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é <roger.pau at citrix.com>
- * All rights reserved.
- * Copyright (c) 2003 John Baldwin <jhb at FreeBSD.org>
- *
- * 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/smp.h>
-#include <sys/pcpu.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/intr_machdep.h>
-#include <x86/apicvar.h>
-
-#include <machine/cpu.h>
-#include <machine/smp.h>
-#include <machine/md_var.h>
-
-#include <xen/xen-os.h>
-#include <xen/xen_intr.h>
-#include <xen/hypervisor.h>
-
-#include <xen/interface/vcpu.h>
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/aclocal.h>
-#include <contrib/dev/acpica/include/actables.h>
-
-#include <dev/acpica/acpivar.h>
-
-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);
-	}
-}
-
-/*
*** 817 LINES SKIPPED ***


More information about the dev-commits-src-all mailing list