From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Xen-devel <xen-devel@lists.xensource.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Subject: [PATCH 02/18] xen: hook io_apic read/write operations
Date: Thu, 7 May 2009 14:14:27 -0700 [thread overview]
Message-ID: <1241730883-4917-3-git-send-email-jeremy@goop.org> (raw)
In-Reply-To: <1241730883-4917-1-git-send-email-jeremy@goop.org>
Impact: paravirtualize io_apic_read/write
In Xen, writes to the IO APIC are paravirtualized via hypercalls, so
implement the appropriate operations.
This version of the patch just hooks the io_apic read/write functions
directly, rather than introducing another layer of indirection. The
xen_initial_domain() tests compile to 0 if CONFIG_XEN_DOM0 isn't set,
and are cheap if it is.
(An alternative would be to add io_apic_ops, and point them to the Xen
implementation as needed. HPA deemed this extra level of indirection to
be excessive.)
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Reviewed-by: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/io_apic.h | 6 ++++
arch/x86/kernel/apic/io_apic.c | 32 ++++++++++++++++++++--
arch/x86/xen/Makefile | 2 +-
arch/x86/xen/apic.c | 57 ++++++++++++++++++++++++++++++++++++++++
arch/x86/xen/enlighten.c | 2 +
arch/x86/xen/xen-ops.h | 6 ++++
6 files changed, 101 insertions(+), 4 deletions(-)
create mode 100644 arch/x86/xen/apic.c
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 9d826e4..894ffb8 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -187,4 +187,10 @@ static inline void ioapic_init_mappings(void) { }
static inline void probe_nr_irqs_gsi(void) { }
#endif
+void xen_io_apic_init(void);
+unsigned int xen_io_apic_read(unsigned apic, unsigned reg);
+void xen_io_apic_write(unsigned int apic,
+ unsigned int reg, unsigned int value);
+
+
#endif /* _ASM_X86_IO_APIC_H */
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 767fe7e..c8240f7 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -62,8 +62,10 @@
#include <asm/uv/uv_hub.h>
#include <asm/uv/uv_irq.h>
+#include <asm/xen/hypervisor.h>
#include <asm/apic.h>
+
#define __apicdebuginit(type) static type __init
/*
@@ -407,14 +409,26 @@ static inline void io_apic_eoi(unsigned int apic, unsigned int vector)
static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
{
- struct io_apic __iomem *io_apic = io_apic_base(apic);
+ struct io_apic __iomem *io_apic;
+
+ if (xen_initial_domain())
+ return xen_io_apic_read(apic, reg);
+
+ io_apic = io_apic_base(apic);
writel(reg, &io_apic->index);
return readl(&io_apic->data);
}
static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
{
- struct io_apic __iomem *io_apic = io_apic_base(apic);
+ struct io_apic __iomem *io_apic;
+
+ if (xen_initial_domain()) {
+ xen_io_apic_write(apic, reg, value);
+ return;
+ }
+
+ io_apic = io_apic_base(apic);
writel(reg, &io_apic->index);
writel(value, &io_apic->data);
}
@@ -427,7 +441,14 @@ static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned i
*/
static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
{
- struct io_apic __iomem *io_apic = io_apic_base(apic);
+ struct io_apic __iomem *io_apic;
+
+ if (xen_initial_domain()) {
+ xen_io_apic_write(apic, reg, value);
+ return;
+ }
+
+ io_apic = io_apic_base(apic);
if (sis_apic_bug)
writel(reg, &io_apic->index);
@@ -4140,6 +4161,11 @@ void __init ioapic_init_mappings(void)
struct resource *ioapic_res;
int i;
+ if (xen_initial_domain()) {
+ xen_io_apic_init();
+ return;
+ }
+
ioapic_res = ioapic_setup_resources();
for (i = 0; i < nr_ioapics; i++) {
if (smp_found_config) {
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index c4cda96..73ecb74 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -11,4 +11,4 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
obj-$(CONFIG_SMP) += smp.o spinlock.o
obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o
-obj-$(CONFIG_XEN_DOM0) += vga.o
+obj-$(CONFIG_XEN_DOM0) += vga.o apic.o
diff --git a/arch/x86/xen/apic.c b/arch/x86/xen/apic.c
new file mode 100644
index 0000000..17736a0
--- /dev/null
+++ b/arch/x86/xen/apic.c
@@ -0,0 +1,57 @@
+#include <linux/kernel.h>
+#include <linux/threads.h>
+#include <linux/bitmap.h>
+
+#include <asm/io_apic.h>
+#include <asm/acpi.h>
+
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+#include <xen/interface/xen.h>
+#include <xen/interface/physdev.h>
+
+void __init xen_io_apic_init(void)
+{
+ printk("xen apic init\n");
+ dump_stack();
+}
+
+unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
+{
+ struct physdev_apic apic_op;
+ int ret;
+
+ apic_op.apic_physbase = mp_ioapics[apic].apicaddr;
+ apic_op.reg = reg;
+ ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
+ if (ret)
+ BUG();
+ return apic_op.value;
+}
+
+
+void xen_io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
+{
+ struct physdev_apic apic_op;
+
+ apic_op.apic_physbase = mp_ioapics[apic].apicaddr;
+ apic_op.reg = reg;
+ apic_op.value = value;
+ if (HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op))
+ BUG();
+}
+
+void xen_init_apic(void)
+{
+ if (!xen_initial_domain())
+ return;
+
+#ifdef CONFIG_ACPI
+ /*
+ * Pretend ACPI found our lapic even though we've disabled it,
+ * to prevent MP tables from setting up lapics.
+ */
+ acpi_lapic = 1;
+#endif
+}
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 2d0341f..0ce10ef 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1034,6 +1034,8 @@ asmlinkage void __init xen_start_kernel(void)
set_iopl.iopl = 1;
if (HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl) == -1)
BUG();
+
+ xen_init_apic();
}
/* set the limit of our address space */
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 40abcef..82ba25c 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -83,6 +83,12 @@ static inline void xen_init_vga(const struct dom0_vga_console_info *info,
}
#endif
+#ifdef CONFIG_XEN_DOM0
+void xen_init_apic(void);
+#else
+static inline void xen_init_apic(void) {}
+#endif
+
/* Declare an asm function, along with symbols needed to make it
inlineable */
#define DECL_ASM(ret, name, ...) \
--
1.6.0.6
next prev parent reply other threads:[~2009-05-08 0:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 21:14 [GIT PULL] xen: apic support for dom0 Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 01/18] xen/dom0: handle acpi lapic parsing in Xen dom0 Jeremy Fitzhardinge
2009-05-07 21:14 ` Jeremy Fitzhardinge [this message]
2009-05-09 8:42 ` [PATCH 02/18] xen: hook io_apic read/write operations Ingo Molnar
2009-05-09 8:43 ` Ingo Molnar
2009-05-09 15:40 ` Jeremy Fitzhardinge
2009-05-11 11:19 ` Ingo Molnar
2009-05-11 18:25 ` Jeremy Fitzhardinge
2009-05-11 21:43 ` Ingo Molnar
2009-05-11 22:06 ` Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 03/18] xen: create dummy ioapic mapping Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 04/18] xen: implement pirq type event channels Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 05/18] x86/io_apic: add get_nr_irqs_gsi() Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 06/18] xen/apic: identity map gsi->irqs Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 07/18] xen: direct irq registration to pirq event channels Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 08/18] xen: bind pirq to vector and event channel Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 09/18] xen: pre-initialize legacy irqs early Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 10/18] xen: don't setup acpi interrupt unless there is one Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 11/18] xen: use acpi_get_override_irq() to get triggering for legacy irqs Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 12/18] xen: initialize irq 0 too Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 13/18] xen: dynamically allocate irq & event structures Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 14/18] xen: set pirq name to something useful Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 15/18] xen: fix legacy irq setup, make ioapic-less machines work Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 16/18] xen: disable MSI Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 17/18] xen/apic: checkpatch cleanups Jeremy Fitzhardinge
2009-05-07 21:14 ` [PATCH 18/18] xen/apic: add pin argument to setup_ioapic_entry() Jeremy Fitzhardinge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1241730883-4917-3-git-send-email-jeremy@goop.org \
--to=jeremy@goop.org \
--cc=jeremy.fitzhardinge@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®