LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 00/12] Xen arch portability patches (take 4)
@ 2008-03-28 11:40 Isaku Yamahata
2008-03-28 11:40 ` [PATCH 01/12] xen: add missing __HYPERVISOR_arch_[0-7] definisions which ia64 needs Isaku Yamahata
` (11 more replies)
0 siblings, 12 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Hi Jeremy.
According to your suggestion, I recreated patches for Ingo's x86.git tree.
And this patch series includes Eddie's modification.
Please review and forward them. (or push back to respin.)
Recently the xen-ia64 community started to make efforts to merge
xen/ia64 Linux to upstream. The first step is to merge up domU portion.
This patchset is preliminary for xen/ia64 domU linux making the current
xen/x86 domU code more arch generic and adding missing definitions and
files.
Changes from the last version.
- revised commit log messages.
- split up the modifications to events.c into three patches.
- minor changes caused by rebase.
Diffstat:
arch/x86/xen/Makefile | 4 +-
arch/x86/xen/grant-table.c | 91 +++++++++++++
arch/x86/xen/xen-ops.h | 2 +-
drivers/xen/Makefile | 3 +-
{arch/x86 => drivers}/xen/events.c | 34 ++++--
{arch/x86 => drivers}/xen/features.c | 0
drivers/xen/grant-table.c | 37 +-----
drivers/xen/xenbus/xenbus_client.c | 6 +-
drivers/xen/xencomm.c | 232 ++++++++++++++++++++++++++++++++++
include/asm-x86/xen/hypervisor.h | 13 ++
include/asm-x86/xen/interface.h | 24 ++++
include/{ => asm-x86}/xen/page.h | 0
include/xen/events.h | 1 +
include/xen/grant_table.h | 6 +
include/xen/interface/grant_table.h | 11 ++-
include/xen/interface/vcpu.h | 5 +
include/xen/interface/xen.h | 22 +++-
include/xen/interface/xencomm.h | 41 ++++++
include/xen/page.h | 169 +------------------------
include/xen/xen-ops.h | 8 ++
include/xen/xencomm.h | 77 +++++++++++
21 files changed, 565 insertions(+), 221 deletions(-)
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 01/12] xen: add missing __HYPERVISOR_arch_[0-7] definisions which ia64 needs.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 02/12] xen: add missing VIRQ_ARCH_[0-7] definitions which ia64/xen needs Isaku Yamahata
` (10 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Add xen hypercall numbers defined for arch specific use.
ia64/xen domU uses __HYPERVISOR_arch_1 to manipulate paravirtualized
IOSAPIC. Although all those constants aren't used yet by IA64 at this
moment, add all arch specific hypercall numbers.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
include/xen/interface/xen.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index 518a5bf..87ad143 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -58,6 +58,16 @@
#define __HYPERVISOR_physdev_op 33
#define __HYPERVISOR_hvm_op 34
+/* Architecture-specific hypercall definitions. */
+#define __HYPERVISOR_arch_0 48
+#define __HYPERVISOR_arch_1 49
+#define __HYPERVISOR_arch_2 50
+#define __HYPERVISOR_arch_3 51
+#define __HYPERVISOR_arch_4 52
+#define __HYPERVISOR_arch_5 53
+#define __HYPERVISOR_arch_6 54
+#define __HYPERVISOR_arch_7 55
+
/*
* VIRTUAL INTERRUPTS
*
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 02/12] xen: add missing VIRQ_ARCH_[0-7] definitions which ia64/xen needs.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
2008-03-28 11:40 ` [PATCH 01/12] xen: add missing __HYPERVISOR_arch_[0-7] definisions which ia64 needs Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 03/12] xen: add missing definitions for xen grant table " Isaku Yamahata
` (9 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Add xen VIRQ numbers defined for arch specific use.
ia64/xen domU uses VIRQ_ARCH_0 for virtual itc timer.
Although all those constants aren't used yet by ia64
at this moment, add all arch specific VIRQ numbers.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
include/xen/interface/xen.h | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index 87ad143..9b018da 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -78,8 +78,18 @@
#define VIRQ_CONSOLE 2 /* (DOM0) Bytes received on emergency console. */
#define VIRQ_DOM_EXC 3 /* (DOM0) Exceptional event for some domain. */
#define VIRQ_DEBUGGER 6 /* (DOM0) A domain has paused for debugging. */
-#define NR_VIRQS 8
+/* Architecture-specific VIRQ definitions. */
+#define VIRQ_ARCH_0 16
+#define VIRQ_ARCH_1 17
+#define VIRQ_ARCH_2 18
+#define VIRQ_ARCH_3 19
+#define VIRQ_ARCH_4 20
+#define VIRQ_ARCH_5 21
+#define VIRQ_ARCH_6 22
+#define VIRQ_ARCH_7 23
+
+#define NR_VIRQS 24
/*
* MMU-UPDATE REQUESTS
*
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 03/12] xen: add missing definitions for xen grant table which ia64/xen needs.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
2008-03-28 11:40 ` [PATCH 01/12] xen: add missing __HYPERVISOR_arch_[0-7] definisions which ia64 needs Isaku Yamahata
2008-03-28 11:40 ` [PATCH 02/12] xen: add missing VIRQ_ARCH_[0-7] definitions which ia64/xen needs Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 04/12] xen: add missing definitions in include/xen/interface/vcpu.h " Isaku Yamahata
` (8 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Add xen handles realted definitions for grant table which ia64/xen
needs.
Pointer argumsnts for ia64/xen hypercall are passed in pseudo physical
address (guest physical address) so that it is required to convert
guest kernel virtual address into pseudo physical address right before
issuing hypercall.
The xen guest handle represents such arguments.
Define necessary handles and helper functions.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/grant-table.c | 2 +-
include/asm-x86/xen/interface.h | 24 ++++++++++++++++++++++++
include/xen/interface/grant_table.h | 11 ++++++++---
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index ea94dba..95016fd 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -466,7 +466,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
setup.dom = DOMID_SELF;
setup.nr_frames = nr_gframes;
- setup.frame_list = frames;
+ set_xen_guest_handle(setup.frame_list, frames);
rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
if (rc == -ENOSYS) {
diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index 588a071..6227000 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -22,6 +22,30 @@
#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
#define GUEST_HANDLE(name) __guest_handle_ ## name
+#ifdef __XEN__
+#if defined(__i386__)
+#define set_xen_guest_handle(hnd, val) \
+ do { \
+ if (sizeof(hnd) == 8) \
+ *(uint64_t *)&(hnd) = 0; \
+ (hnd).p = val; \
+ } while (0)
+#elif defined(__x86_64__)
+#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
+#endif
+#else
+#if defined(__i386__)
+#define set_xen_guest_handle(hnd, val) \
+ do { \
+ if (sizeof(hnd) == 8) \
+ *(uint64_t *)&(hnd) = 0; \
+ (hnd) = val; \
+ } while (0)
+#elif defined(__x86_64__)
+#define set_xen_guest_handle(hnd, val) do { (hnd) = val; } while (0)
+#endif
+#endif
+
#ifndef __ASSEMBLY__
/* Guest handles for primitive C types. */
__DEFINE_GUEST_HANDLE(uchar, unsigned char);
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index 2190498..39da93c 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -185,6 +185,7 @@ struct gnttab_map_grant_ref {
grant_handle_t handle;
uint64_t dev_bus_addr;
};
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_map_grant_ref);
/*
* GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -206,6 +207,7 @@ struct gnttab_unmap_grant_ref {
/* OUT parameters. */
int16_t status; /* GNTST_* */
};
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_grant_ref);
/*
* GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -223,8 +225,9 @@ struct gnttab_setup_table {
uint32_t nr_frames;
/* OUT parameters. */
int16_t status; /* GNTST_* */
- ulong *frame_list;
+ GUEST_HANDLE(ulong) frame_list;
};
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table);
/*
* GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -237,6 +240,7 @@ struct gnttab_dump_table {
/* OUT parameters. */
int16_t status; /* GNTST_* */
};
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table);
/*
* GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -255,7 +259,7 @@ struct gnttab_transfer {
/* OUT parameters. */
int16_t status;
};
-
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer);
/*
* GNTTABOP_copy: Hypervisor based copy
@@ -296,6 +300,7 @@ struct gnttab_copy {
/* OUT parameters. */
int16_t status;
};
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy);
/*
* GNTTABOP_query_size: Query the current and maximum sizes of the shared
@@ -313,7 +318,7 @@ struct gnttab_query_size {
uint32_t max_nr_frames;
int16_t status; /* GNTST_* */
};
-
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size);
/*
* Bitfield values for update_pin_status.flags.
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 04/12] xen: add missing definitions in include/xen/interface/vcpu.h which ia64/xen needs
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (2 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 03/12] xen: add missing definitions for xen grant table " Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 05/12] xen: move features.c from arch/x86/xen/features.c to drivers/xen Isaku Yamahata
` (7 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Add xen handles realted definitions for xen vcpu which ia64/xen needs.
Pointer argumsnts for ia64/xen hypercall are passed in pseudo physical
address (guest physical address) so that it is required to convert
guest kernel virtual address into pseudo physical address.
The xen guest handle represents such arguments.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
include/xen/interface/vcpu.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/xen/interface/vcpu.h b/include/xen/interface/vcpu.h
index b05d8a6..87e6f8a 100644
--- a/include/xen/interface/vcpu.h
+++ b/include/xen/interface/vcpu.h
@@ -85,6 +85,7 @@ struct vcpu_runstate_info {
*/
uint64_t time[4];
};
+DEFINE_GUEST_HANDLE_STRUCT(vcpu_runstate_info);
/* VCPU is currently running on a physical CPU. */
#define RUNSTATE_running 0
@@ -119,6 +120,7 @@ struct vcpu_runstate_info {
#define VCPUOP_register_runstate_memory_area 5
struct vcpu_register_runstate_memory_area {
union {
+ GUEST_HANDLE(vcpu_runstate_info) h;
struct vcpu_runstate_info *v;
uint64_t p;
} addr;
@@ -134,6 +136,7 @@ struct vcpu_register_runstate_memory_area {
struct vcpu_set_periodic_timer {
uint64_t period_ns;
};
+DEFINE_GUEST_HANDLE_STRUCT(vcpu_set_periodic_timer);
/*
* Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot
@@ -145,6 +148,7 @@ struct vcpu_set_singleshot_timer {
uint64_t timeout_abs_ns;
uint32_t flags; /* VCPU_SSHOTTMR_??? */
};
+DEFINE_GUEST_HANDLE_STRUCT(vcpu_set_singleshot_timer);
/* Flags to VCPUOP_set_singleshot_timer. */
/* Require the timeout to be in the future (return -ETIME if it's passed). */
@@ -164,5 +168,6 @@ struct vcpu_register_vcpu_info {
uint32_t offset; /* offset within page */
uint32_t rsvd; /* unused */
};
+DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_vcpu_info);
#endif /* __XEN_PUBLIC_VCPU_H__ */
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 05/12] xen: move features.c from arch/x86/xen/features.c to drivers/xen.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (3 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 04/12] xen: add missing definitions in include/xen/interface/vcpu.h " Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 06/12] xen: Move events.c to drivers/xen for IA64/Xen support Isaku Yamahata
` (6 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
ia64/xen also uses it too. Move it into common place so that
ia64/xen can share the code.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
arch/x86/xen/Makefile | 2 +-
drivers/xen/Makefile | 2 +-
{arch/x86 => drivers}/xen/features.c | 0
3 files changed, 2 insertions(+), 2 deletions(-)
rename {arch/x86 => drivers}/xen/features.c (100%)
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 343df24..c5e9aa4 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,4 +1,4 @@
-obj-y := enlighten.o setup.o features.o multicalls.o mmu.o \
+obj-y := enlighten.o setup.o multicalls.o mmu.o \
events.o time.o manage.o xen-asm.o
obj-$(CONFIG_SMP) += smp.o
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 56592f0..609fdda 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -1,2 +1,2 @@
-obj-y += grant-table.o
+obj-y += grant-table.o features.o
obj-y += xenbus/
diff --git a/arch/x86/xen/features.c b/drivers/xen/features.c
similarity index 100%
rename from arch/x86/xen/features.c
rename to drivers/xen/features.c
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 06/12] xen: Move events.c to drivers/xen for IA64/Xen support.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (4 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 05/12] xen: move features.c from arch/x86/xen/features.c to drivers/xen Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 07/12] Xen: Make events.c portable for ia64/xen support Isaku Yamahata
` (5 subsequent siblings)
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
move arch/x86/xen/events.c undedr drivers/xen to share codes
with x86 and ia64. And minor adjustment to compile.
ia64/xen also uses events.c
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
arch/x86/xen/Makefile | 2 +-
arch/x86/xen/xen-ops.h | 2 +-
drivers/xen/Makefile | 2 +-
{arch/x86 => drivers}/xen/events.c | 3 +--
include/xen/xen-ops.h | 8 ++++++++
5 files changed, 12 insertions(+), 5 deletions(-)
rename {arch/x86 => drivers}/xen/events.c (99%)
create mode 100644 include/xen/xen-ops.h
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index c5e9aa4..95c5926 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,4 +1,4 @@
obj-y := enlighten.o setup.o multicalls.o mmu.o \
- events.o time.o manage.o xen-asm.o
+ time.o manage.o xen-asm.o
obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 22395d2..f1063ae 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -3,6 +3,7 @@
#include <linux/init.h>
#include <linux/irqreturn.h>
+#include <xen/xen-ops.h>
/* These are code, but not functions. Defined in entry.S */
extern const char xen_hypervisor_callback[];
@@ -10,7 +11,6 @@ extern const char xen_failsafe_callback[];
void xen_copy_trap_info(struct trap_info *traps);
-DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
DECLARE_PER_CPU(unsigned long, xen_cr3);
DECLARE_PER_CPU(unsigned long, xen_current_cr3);
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 609fdda..823ce78 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -1,2 +1,2 @@
-obj-y += grant-table.o features.o
+obj-y += grant-table.o features.o events.o
obj-y += xenbus/
diff --git a/arch/x86/xen/events.c b/drivers/xen/events.c
similarity index 99%
rename from arch/x86/xen/events.c
rename to drivers/xen/events.c
index 85bac29..c50d499 100644
--- a/arch/x86/xen/events.c
+++ b/drivers/xen/events.c
@@ -33,12 +33,11 @@
#include <asm/xen/hypercall.h>
#include <asm/xen/hypervisor.h>
+#include <xen/xen-ops.h>
#include <xen/events.h>
#include <xen/interface/xen.h>
#include <xen/interface/event_channel.h>
-#include "xen-ops.h"
-
/*
* This lock protects updates to the following mapping and reference-count
* arrays. The lock does not need to be acquired to read the mapping tables.
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
new file mode 100644
index 0000000..10ddfe0
--- /dev/null
+++ b/include/xen/xen-ops.h
@@ -0,0 +1,8 @@
+#ifndef INCLUDE_XEN_OPS_H
+#define INCLUDE_XEN_OPS_H
+
+#include <linux/percpu.h>
+
+DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
+
+#endif /* INCLUDE_XEN_OPS_H */
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/12] Xen: Make events.c portable for ia64/xen support.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (5 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 06/12] xen: Move events.c to drivers/xen for IA64/Xen support Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 20:27 ` Jeremy Fitzhardinge
2008-03-28 11:40 ` [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c Isaku Yamahata
` (4 subsequent siblings)
11 siblings, 1 reply; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Remove x86 dependency in drivers/xen/events.c for ia64/xen support.
Introduce xen_irqs_disabled() to hide regs->flags
Introduce xen_do_IRQ() to hide regs->orig_ax.
Add one rmb() because on ia64 xchg() isn't barrier.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/events.c | 13 +++++++------
include/asm-x86/xen/hypervisor.h | 10 ++++++++++
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index c50d499..2396b44 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -469,7 +469,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
for_each_online_cpu(i) {
struct vcpu_info *v = per_cpu(xen_vcpu, i);
printk("%d: masked=%d pending=%d event_sel %08lx\n ", i,
- (get_irq_regs() && i == cpu) ? !(get_irq_regs()->flags & X86_EFLAGS_IF) : v->evtchn_upcall_mask,
+ (get_irq_regs() && i == cpu) ? xen_irqs_disabled(get_irq_regs()) : v->evtchn_upcall_mask,
v->evtchn_upcall_pending,
v->evtchn_pending_sel);
}
@@ -527,7 +527,10 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
if (__get_cpu_var(nesting_count)++)
goto out;
- /* NB. No need for a barrier here -- XCHG is a barrier on x86. */
+#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
+ /* Clear master flag /before/ clearing selector flag. */
+ rmb();
+#endif
pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0);
while (pending_words != 0) {
unsigned long pending_bits;
@@ -539,10 +542,8 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
int port = (word_idx * BITS_PER_LONG) + bit_idx;
int irq = evtchn_to_irq[port];
- if (irq != -1) {
- regs->orig_ax = ~irq;
- do_IRQ(regs);
- }
+ if (irq != -1)
+ xen_do_IRQ(irq, regs);
}
}
diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h
index 8e15dd2..767a361 100644
--- a/include/asm-x86/xen/hypervisor.h
+++ b/include/asm-x86/xen/hypervisor.h
@@ -61,6 +61,16 @@ extern struct start_info *xen_start_info;
/* Force a proper event-channel callback from Xen. */
extern void force_evtchn_callback(void);
+/* macro to avoid header inclusion dependncy hell */
+#define xen_irqs_disabled(regs) (!((regs)->flags & X86_EFLAGS_IF))
+
+/* macro to avoid header inclusion dependncy hell */
+#define xen_do_IRQ(irq, regs) \
+ do { \
+ (regs)->orig_ax = ~(irq); \
+ do_IRQ(regs); \
+ } while (0)
+
/* Turn jiffies into Xen system time. */
u64 jiffies_to_st(unsigned long jiffies);
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (6 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 07/12] Xen: Make events.c portable for ia64/xen support Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 20:29 ` Jeremy Fitzhardinge
2008-03-28 11:40 ` [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir Isaku Yamahata
` (3 subsequent siblings)
11 siblings, 1 reply; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Define resend_irq_on_evtchn() which ia64/xen uses.
Although it isn't used by current x86/xen code, it's arch generic
so that put it into common code.
make ipi_to_irq[] visible removing static because
ia64/xen needs to access the variable from ia64 specific code
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/events.c | 18 +++++++++++++++++-
include/xen/events.h | 1 +
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 2396b44..1c2c193 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(irq_mapping_update_lock);
static DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};
/* IRQ <-> IPI mapping */
-static DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
+DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
/* Packed IRQ information: binding type, sub-type index, and event channel. */
struct packed_irq
@@ -586,6 +586,22 @@ static void set_affinity_irq(unsigned irq, cpumask_t dest)
rebind_irq_to_cpu(irq, tcpu);
}
+int resend_irq_on_evtchn(unsigned int irq)
+{
+ int masked, evtchn = evtchn_from_irq(irq);
+ struct shared_info *s = HYPERVISOR_shared_info;
+
+ if (!VALID_EVTCHN(evtchn))
+ return 1;
+
+ masked = sync_test_and_set_bit(evtchn, s->evtchn_mask);
+ sync_set_bit(evtchn, s->evtchn_pending);
+ if (!masked)
+ unmask_evtchn(evtchn);
+
+ return 1;
+}
+
static void enable_dynirq(unsigned int irq)
{
int evtchn = evtchn_from_irq(irq);
diff --git a/include/xen/events.h b/include/xen/events.h
index 2bde54d..574cfa4 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -37,6 +37,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
void unbind_from_irqhandler(unsigned int irq, void *dev_id);
void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
+int resend_irq_on_evtchn(unsigned int irq);
static inline void notify_remote_via_evtchn(int port)
{
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (7 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 20:41 ` Jeremy Fitzhardinge
2008-03-28 11:40 ` [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one Isaku Yamahata
` (2 subsequent siblings)
11 siblings, 1 reply; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
The definitions in include/asm/xen/page.h are arch specific.
ia64/xen wants to define its own version. So move them to arch specific
directory and keep include/xen/page.h in order not to break compilation.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
include/{ => asm-x86}/xen/page.h | 0
include/xen/page.h | 169 +-------------------------------------
2 files changed, 1 insertions(+), 168 deletions(-)
copy include/{ => asm-x86}/xen/page.h (100%)
diff --git a/include/xen/page.h b/include/asm-x86/xen/page.h
similarity index 100%
copy from include/xen/page.h
copy to include/asm-x86/xen/page.h
diff --git a/include/xen/page.h b/include/xen/page.h
index 0179930..eaf85fa 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -1,168 +1 @@
-#ifndef __XEN_PAGE_H
-#define __XEN_PAGE_H
-
-#include <linux/pfn.h>
-
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-
-#include <xen/features.h>
-
-/* Xen machine address */
-typedef struct xmaddr {
- phys_addr_t maddr;
-} xmaddr_t;
-
-/* Xen pseudo-physical address */
-typedef struct xpaddr {
- phys_addr_t paddr;
-} xpaddr_t;
-
-#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
-#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
-
-/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
-#define INVALID_P2M_ENTRY (~0UL)
-#define FOREIGN_FRAME_BIT (1UL<<31)
-#define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT)
-
-extern unsigned long *phys_to_machine_mapping;
-
-static inline unsigned long pfn_to_mfn(unsigned long pfn)
-{
- if (xen_feature(XENFEAT_auto_translated_physmap))
- return pfn;
-
- return phys_to_machine_mapping[(unsigned int)(pfn)] &
- ~FOREIGN_FRAME_BIT;
-}
-
-static inline int phys_to_machine_mapping_valid(unsigned long pfn)
-{
- if (xen_feature(XENFEAT_auto_translated_physmap))
- return 1;
-
- return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
-}
-
-static inline unsigned long mfn_to_pfn(unsigned long mfn)
-{
- unsigned long pfn;
-
- if (xen_feature(XENFEAT_auto_translated_physmap))
- return mfn;
-
-#if 0
- if (unlikely((mfn >> machine_to_phys_order) != 0))
- return max_mapnr;
-#endif
-
- pfn = 0;
- /*
- * The array access can fail (e.g., device space beyond end of RAM).
- * In such cases it doesn't matter what we return (we return garbage),
- * but we must handle the fault without crashing!
- */
- __get_user(pfn, &machine_to_phys_mapping[mfn]);
-
- return pfn;
-}
-
-static inline xmaddr_t phys_to_machine(xpaddr_t phys)
-{
- unsigned offset = phys.paddr & ~PAGE_MASK;
- return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
-}
-
-static inline xpaddr_t machine_to_phys(xmaddr_t machine)
-{
- unsigned offset = machine.maddr & ~PAGE_MASK;
- return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
-}
-
-/*
- * We detect special mappings in one of two ways:
- * 1. If the MFN is an I/O page then Xen will set the m2p entry
- * to be outside our maximum possible pseudophys range.
- * 2. If the MFN belongs to a different domain then we will certainly
- * not have MFN in our p2m table. Conversely, if the page is ours,
- * then we'll have p2m(m2p(MFN))==MFN.
- * If we detect a special mapping then it doesn't have a 'struct page'.
- * We force !pfn_valid() by returning an out-of-range pointer.
- *
- * NB. These checks require that, for any MFN that is not in our reservation,
- * there is no PFN such that p2m(PFN) == MFN. Otherwise we can get confused if
- * we are foreign-mapping the MFN, and the other domain as m2p(MFN) == PFN.
- * Yikes! Various places must poke in INVALID_P2M_ENTRY for safety.
- *
- * NB2. When deliberately mapping foreign pages into the p2m table, you *must*
- * use FOREIGN_FRAME(). This will cause pte_pfn() to choke on it, as we
- * require. In all the cases we care about, the FOREIGN_FRAME bit is
- * masked (e.g., pfn_to_mfn()) so behaviour there is correct.
- */
-static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
-{
- extern unsigned long max_mapnr;
- unsigned long pfn = mfn_to_pfn(mfn);
- if ((pfn < max_mapnr)
- && !xen_feature(XENFEAT_auto_translated_physmap)
- && (phys_to_machine_mapping[pfn] != mfn))
- return max_mapnr; /* force !pfn_valid() */
- return pfn;
-}
-
-static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
-{
- if (xen_feature(XENFEAT_auto_translated_physmap)) {
- BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
- return;
- }
- phys_to_machine_mapping[pfn] = mfn;
-}
-
-/* VIRT <-> MACHINE conversion */
-#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
-#define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v))))
-#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
-
-static inline unsigned long pte_mfn(pte_t pte)
-{
- return (pte.pte & ~_PAGE_NX) >> PAGE_SHIFT;
-}
-
-static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
-{
- pte_t pte;
-
- pte.pte = ((phys_addr_t)page_nr << PAGE_SHIFT) |
- (pgprot_val(pgprot) & __supported_pte_mask);
-
- return pte;
-}
-
-static inline pteval_t pte_val_ma(pte_t pte)
-{
- return pte.pte;
-}
-
-static inline pte_t __pte_ma(pteval_t x)
-{
- return (pte_t) { .pte = x };
-}
-
-#ifdef CONFIG_X86_PAE
-#define pmd_val_ma(v) ((v).pmd)
-#define pud_val_ma(v) ((v).pgd.pgd)
-#define __pmd_ma(x) ((pmd_t) { (x) } )
-#else /* !X86_PAE */
-#define pmd_val_ma(v) ((v).pud.pgd.pgd)
-#endif /* CONFIG_X86_PAE */
-
-#define pgd_val_ma(x) ((x).pgd)
-
-
-xmaddr_t arbitrary_virt_to_machine(unsigned long address);
-void make_lowmem_page_readonly(void *vaddr);
-void make_lowmem_page_readwrite(void *vaddr);
-
-#endif /* __XEN_PAGE_H */
+#include <asm/xen/page.h>
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (8 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 20:31 ` Jeremy Fitzhardinge
2008-03-28 11:40 ` [PATCH 11/12] xen: make grant table arch portable Isaku Yamahata
2008-03-28 11:40 ` [PATCH 12/12] xen: import arch generic part of xencomm Isaku Yamahata
11 siblings, 1 reply; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
Don't use alloc_vm_area()/free_vm_area() directly, instead define
xen_alloc_vm_area()/xen_free_vm_area() and use them.
alloc_vm_area()/free_vm_area() are used to allocate/free area which
are for grant table mapping. Xen/x86 grant table is based on virtual
address so that alloc_vm_area()/free_vm_area() are suitable.
On the other hand Xen/ia64 (and Xen/powerpc) grant table is based on
pseudo physical address (guest physical address) so that allocation
should be done differently.
The original version of xenified Linux/IA64 have its own
allocate_vm_area()/free_vm_area() definitions which don't allocate vm area
contradictory to those names.
Now vanilla Linux already has its definitions so that it's impossible
to have IA64 definitions of allocate_vm_area()/free_vm_area().
Instead introduce xen_allocate_vm_area()/xen_free_vm_area() and use them.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/grant-table.c | 2 +-
drivers/xen/xenbus/xenbus_client.c | 6 +++---
include/asm-x86/xen/hypervisor.h | 3 +++
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 95016fd..9fcde20 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -478,7 +478,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
if (shared == NULL) {
struct vm_struct *area;
- area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
+ area = xen_alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
BUG_ON(area == NULL);
shared = area->addr;
}
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 9fd2f70..0f86b0f 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -399,7 +399,7 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
*vaddr = NULL;
- area = alloc_vm_area(PAGE_SIZE);
+ area = xen_alloc_vm_area(PAGE_SIZE);
if (!area)
return -ENOMEM;
@@ -409,7 +409,7 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
BUG();
if (op.status != GNTST_okay) {
- free_vm_area(area);
+ xen_free_vm_area(area);
xenbus_dev_fatal(dev, op.status,
"mapping in shared page %d from domain %d",
gnt_ref, dev->otherend_id);
@@ -508,7 +508,7 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
BUG();
if (op.status == GNTST_okay)
- free_vm_area(area);
+ xen_free_vm_area(area);
else
xenbus_dev_error(dev, op.status,
"unmapping page at handle %d error %d",
diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h
index 767a361..31e526d 100644
--- a/include/asm-x86/xen/hypervisor.h
+++ b/include/asm-x86/xen/hypervisor.h
@@ -57,6 +57,9 @@ extern struct shared_info *HYPERVISOR_shared_info;
extern struct start_info *xen_start_info;
#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
+#define xen_alloc_vm_area(size) alloc_vm_area(size)
+#define xen_free_vm_area(area) free_vm_area(area)
+
/* arch/i386/mach-xen/evtchn.c */
/* Force a proper event-channel callback from Xen. */
extern void force_evtchn_callback(void);
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 11/12] xen: make grant table arch portable.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (9 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 12/12] xen: import arch generic part of xencomm Isaku Yamahata
11 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
split out x86 specific part from grant-table.c and
allow ia64/xen specific initialization.
ia64/xen grant table is based on pseudo physical address
(guest physical address) unlike x86/xen. On ia64 init_mm
doesn't map identity straight mapped area.
ia64/xen specific grant table initialization is necessary.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
arch/x86/xen/Makefile | 2 +-
arch/x86/xen/grant-table.c | 91 ++++++++++++++++++++++++++++++++++++++++++++
drivers/xen/grant-table.c | 35 +---------------
include/xen/grant_table.h | 6 +++
4 files changed, 101 insertions(+), 33 deletions(-)
create mode 100644 arch/x86/xen/grant-table.c
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 95c5926..3d8df98 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,4 +1,4 @@
obj-y := enlighten.o setup.o multicalls.o mmu.o \
- time.o manage.o xen-asm.o
+ time.o manage.o xen-asm.o grant-table.o
obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c
new file mode 100644
index 0000000..49ba9b5
--- /dev/null
+++ b/arch/x86/xen/grant-table.c
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * grant_table.c
+ * x86 specific part
+ *
+ * Granting foreign access to our memory reservation.
+ *
+ * Copyright (c) 2005-2006, Christopher Clark
+ * Copyright (c) 2004-2005, K A Fraser
+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
+ * VA Linux Systems Japan. Split out x86 specific part.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+
+#include <xen/interface/xen.h>
+#include <xen/page.h>
+#include <xen/grant_table.h>
+
+#include <asm/pgtable.h>
+
+static int map_pte_fn(pte_t *pte, struct page *pmd_page,
+ unsigned long addr, void *data)
+{
+ unsigned long **frames = (unsigned long **)data;
+
+ set_pte_at(&init_mm, addr, pte, mfn_pte((*frames)[0], PAGE_KERNEL));
+ (*frames)++;
+ return 0;
+}
+
+static int unmap_pte_fn(pte_t *pte, struct page *pmd_page,
+ unsigned long addr, void *data)
+{
+
+ set_pte_at(&init_mm, addr, pte, __pte(0));
+ return 0;
+}
+
+int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
+ unsigned long max_nr_gframes,
+ struct grant_entry **__shared)
+{
+ int rc;
+ struct grant_entry *shared = *__shared;
+
+ if (shared == NULL) {
+ struct vm_struct *area =
+ xen_alloc_vm_area(PAGE_SIZE * max_nr_gframes);
+ BUG_ON(area == NULL);
+ shared = area->addr;
+ *__shared = shared;
+ }
+
+ rc = apply_to_page_range(&init_mm, (unsigned long)shared,
+ PAGE_SIZE * nr_gframes,
+ map_pte_fn, &frames);
+ return rc;
+}
+
+void arch_gnttab_unmap_shared(struct grant_entry *shared,
+ unsigned long nr_gframes)
+{
+ apply_to_page_range(&init_mm, (unsigned long)shared,
+ PAGE_SIZE * nr_gframes, unmap_pte_fn, NULL);
+}
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 9fcde20..22f5104 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -435,24 +435,6 @@ static inline unsigned int max_nr_grant_frames(void)
return xen_max;
}
-static int map_pte_fn(pte_t *pte, struct page *pmd_page,
- unsigned long addr, void *data)
-{
- unsigned long **frames = (unsigned long **)data;
-
- set_pte_at(&init_mm, addr, pte, mfn_pte((*frames)[0], PAGE_KERNEL));
- (*frames)++;
- return 0;
-}
-
-static int unmap_pte_fn(pte_t *pte, struct page *pmd_page,
- unsigned long addr, void *data)
-{
-
- set_pte_at(&init_mm, addr, pte, __pte(0));
- return 0;
-}
-
static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
{
struct gnttab_setup_table setup;
@@ -476,17 +458,9 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
BUG_ON(rc || setup.status);
- if (shared == NULL) {
- struct vm_struct *area;
- area = xen_alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
- BUG_ON(area == NULL);
- shared = area->addr;
- }
- rc = apply_to_page_range(&init_mm, (unsigned long)shared,
- PAGE_SIZE * nr_gframes,
- map_pte_fn, &frames);
+ rc = arch_gnttab_map_shared(frames, nr_gframes, max_nr_grant_frames(),
+ &shared);
BUG_ON(rc);
- frames -= nr_gframes; /* adjust after map_pte_fn() */
kfree(frames);
@@ -502,10 +476,7 @@ static int gnttab_resume(void)
static int gnttab_suspend(void)
{
- apply_to_page_range(&init_mm, (unsigned long)shared,
- PAGE_SIZE * nr_grant_frames,
- unmap_pte_fn, NULL);
-
+ arch_gnttab_unmap_shared(shared, nr_grant_frames);
return 0;
}
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 761c834..50ca16e 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -102,6 +102,12 @@ void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid,
unsigned long pfn);
+int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
+ unsigned long max_nr_gframes,
+ struct grant_entry **__shared);
+void arch_gnttab_unmap_shared(struct grant_entry *shared,
+ unsigned long nr_gframes);
+
#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
#endif /* __ASM_GNTTAB_H__ */
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 12/12] xen: import arch generic part of xencomm.
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
` (10 preceding siblings ...)
2008-03-28 11:40 ` [PATCH 11/12] xen: make grant table arch portable Isaku Yamahata
@ 2008-03-28 11:40 ` Isaku Yamahata
2008-03-28 20:09 ` Jeremy Fitzhardinge
11 siblings, 1 reply; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-28 11:40 UTC (permalink / raw)
To: jeremy
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel,
eddie.dong, yamahata
On xen/ia64 and xen/powerpc hypercall arguments are passed by pseudo
physical address (guest physical address) so that it's necessary to
convert from virtual address into pseudo physical address. The frame
work is called xencomm.
Import arch generic part of xencomm.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/Makefile | 1 +
drivers/xen/xencomm.c | 232 +++++++++++++++++++++++++++++++++++++++
include/xen/interface/xencomm.h | 41 +++++++
include/xen/xencomm.h | 77 +++++++++++++
4 files changed, 351 insertions(+), 0 deletions(-)
create mode 100644 drivers/xen/xencomm.c
create mode 100644 include/xen/interface/xencomm.h
create mode 100644 include/xen/xencomm.h
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 823ce78..43f014c 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -1,2 +1,3 @@
obj-y += grant-table.o features.o events.o
obj-y += xenbus/
+obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
diff --git a/drivers/xen/xencomm.c b/drivers/xen/xencomm.c
new file mode 100644
index 0000000..797cb4e
--- /dev/null
+++ b/drivers/xen/xencomm.c
@@ -0,0 +1,232 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) IBM Corp. 2006
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#include <linux/gfp.h>
+#include <linux/mm.h>
+#include <asm/page.h>
+#include <xen/xencomm.h>
+#include <xen/interface/xen.h>
+#ifdef __ia64__
+#include <asm/xen/xencomm.h> /* for is_kern_addr() */
+#endif
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
+static int xencomm_init(struct xencomm_desc *desc,
+ void *buffer, unsigned long bytes)
+{
+ unsigned long recorded = 0;
+ int i = 0;
+
+ while ((recorded < bytes) && (i < desc->nr_addrs)) {
+ unsigned long vaddr = (unsigned long)buffer + recorded;
+ unsigned long paddr;
+ int offset;
+ int chunksz;
+
+ offset = vaddr % PAGE_SIZE; /* handle partial pages */
+ chunksz = min(PAGE_SIZE - offset, bytes - recorded);
+
+ paddr = xencomm_vtop(vaddr);
+ if (paddr == ~0UL) {
+ printk(KERN_DEBUG "%s: couldn't translate vaddr %lx\n",
+ __func__, vaddr);
+ return -EINVAL;
+ }
+
+ desc->address[i++] = paddr;
+ recorded += chunksz;
+ }
+
+ if (recorded < bytes) {
+ printk(KERN_DEBUG
+ "%s: could only translate %ld of %ld bytes\n",
+ __func__, recorded, bytes);
+ return -ENOSPC;
+ }
+
+ /* mark remaining addresses invalid (just for safety) */
+ while (i < desc->nr_addrs)
+ desc->address[i++] = XENCOMM_INVALID;
+
+ desc->magic = XENCOMM_MAGIC;
+
+ return 0;
+}
+
+static struct xencomm_desc *xencomm_alloc(gfp_t gfp_mask,
+ void *buffer, unsigned long bytes)
+{
+ struct xencomm_desc *desc;
+ unsigned long buffer_ulong = (unsigned long)buffer;
+ unsigned long start = buffer_ulong & PAGE_MASK;
+ unsigned long end = (buffer_ulong + bytes) | ~PAGE_MASK;
+ unsigned long nr_addrs = (end - start + 1) >> PAGE_SHIFT;
+ unsigned long size = sizeof(*desc) +
+ sizeof(desc->address[0]) * nr_addrs;
+
+ /*
+ * slab allocator returns at least sizeof(void*) aligned pointer.
+ * When sizeof(*desc) > sizeof(void*), struct xencomm_desc might
+ * cross page boundary.
+ */
+ if (sizeof(*desc) > sizeof(void *)) {
+ unsigned long order = get_order(size);
+ desc = (struct xencomm_desc *)__get_free_pages(gfp_mask,
+ order);
+ if (desc == NULL)
+ return NULL;
+
+ desc->nr_addrs =
+ ((PAGE_SIZE << order) - sizeof(struct xencomm_desc)) /
+ sizeof(*desc->address);
+ } else {
+ desc = kmalloc(size, gfp_mask);
+ if (desc == NULL)
+ return NULL;
+
+ desc->nr_addrs = nr_addrs;
+ }
+ return desc;
+}
+
+void xencomm_free(struct xencomm_handle *desc)
+{
+ if (desc && !((ulong)desc & XENCOMM_INLINE_FLAG)) {
+ struct xencomm_desc *desc__ = (struct xencomm_desc *)desc;
+ if (sizeof(*desc__) > sizeof(void *)) {
+ unsigned long size = sizeof(*desc__) +
+ sizeof(desc__->address[0]) * desc__->nr_addrs;
+ unsigned long order = get_order(size);
+ free_pages((unsigned long)__va(desc), order);
+ } else
+ kfree(__va(desc));
+ }
+}
+
+static int xencomm_create(void *buffer, unsigned long bytes,
+ struct xencomm_desc **ret, gfp_t gfp_mask)
+{
+ struct xencomm_desc *desc;
+ int rc;
+
+ pr_debug("%s: %p[%ld]\n", __func__, buffer, bytes);
+
+ if (bytes == 0) {
+ /* don't create a descriptor; Xen recognizes NULL. */
+ BUG_ON(buffer != NULL);
+ *ret = NULL;
+ return 0;
+ }
+
+ BUG_ON(buffer == NULL); /* 'bytes' is non-zero */
+
+ desc = xencomm_alloc(gfp_mask, buffer, bytes);
+ if (!desc) {
+ printk(KERN_DEBUG "%s failure\n", "xencomm_alloc");
+ return -ENOMEM;
+ }
+
+ rc = xencomm_init(desc, buffer, bytes);
+ if (rc) {
+ printk(KERN_DEBUG "%s failure: %d\n", "xencomm_init", rc);
+ xencomm_free((struct xencomm_handle *)__pa(desc));
+ return rc;
+ }
+
+ *ret = desc;
+ return 0;
+}
+
+/* check if memory address is within VMALLOC region */
+static int is_phys_contiguous(unsigned long addr)
+{
+ if (!is_kernel_addr(addr))
+ return 0;
+
+ return (addr < VMALLOC_START) || (addr >= VMALLOC_END);
+}
+
+static struct xencomm_handle *xencomm_create_inline(void *ptr)
+{
+ unsigned long paddr;
+
+ BUG_ON(!is_phys_contiguous((unsigned long)ptr));
+
+ paddr = (unsigned long)xencomm_pa(ptr);
+ BUG_ON(paddr & XENCOMM_INLINE_FLAG);
+ return (struct xencomm_handle *)(paddr | XENCOMM_INLINE_FLAG);
+}
+
+/* "mini" routine, for stack-based communications: */
+static int xencomm_create_mini(void *buffer,
+ unsigned long bytes, struct xencomm_mini *xc_desc,
+ struct xencomm_desc **ret)
+{
+ int rc = 0;
+ struct xencomm_desc *desc;
+ BUG_ON(((unsigned long)xc_desc) % sizeof(*xc_desc) != 0);
+
+ desc = (void *)xc_desc;
+
+ desc->nr_addrs = XENCOMM_MINI_ADDRS;
+
+ rc = xencomm_init(desc, buffer, bytes);
+ if (!rc)
+ *ret = desc;
+
+ return rc;
+}
+
+struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes)
+{
+ int rc;
+ struct xencomm_desc *desc;
+
+ if (is_phys_contiguous((unsigned long)ptr))
+ return xencomm_create_inline(ptr);
+
+ rc = xencomm_create(ptr, bytes, &desc, GFP_KERNEL);
+
+ if (rc || desc == NULL)
+ return NULL;
+
+ return xencomm_pa(desc);
+}
+
+struct xencomm_handle *__xencomm_map_no_alloc(void *ptr, unsigned long bytes,
+ struct xencomm_mini *xc_desc)
+{
+ int rc;
+ struct xencomm_desc *desc = NULL;
+
+ if (is_phys_contiguous((unsigned long)ptr))
+ return xencomm_create_inline(ptr);
+
+ rc = xencomm_create_mini(ptr, bytes, xc_desc,
+ &desc);
+
+ if (rc)
+ return NULL;
+
+ return xencomm_pa(desc);
+}
diff --git a/include/xen/interface/xencomm.h b/include/xen/interface/xencomm.h
new file mode 100644
index 0000000..ac45e07
--- /dev/null
+++ b/include/xen/interface/xencomm.h
@@ -0,0 +1,41 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (C) IBM Corp. 2006
+ */
+
+#ifndef _XEN_XENCOMM_H_
+#define _XEN_XENCOMM_H_
+
+/* A xencomm descriptor is a scatter/gather list containing physical
+ * addresses corresponding to a virtually contiguous memory area. The
+ * hypervisor translates these physical addresses to machine addresses to copy
+ * to and from the virtually contiguous area.
+ */
+
+#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
+#define XENCOMM_INVALID (~0UL)
+
+struct xencomm_desc {
+ uint32_t magic;
+ uint32_t nr_addrs; /* the number of entries in address[] */
+ uint64_t address[0];
+};
+
+#endif /* _XEN_XENCOMM_H_ */
diff --git a/include/xen/xencomm.h b/include/xen/xencomm.h
new file mode 100644
index 0000000..e43b039
--- /dev/null
+++ b/include/xen/xencomm.h
@@ -0,0 +1,77 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) IBM Corp. 2006
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ * Jerone Young <jyoung5@us.ibm.com>
+ */
+
+#ifndef _LINUX_XENCOMM_H_
+#define _LINUX_XENCOMM_H_
+
+#include <xen/interface/xencomm.h>
+
+#define XENCOMM_MINI_ADDRS 3
+struct xencomm_mini {
+ struct xencomm_desc _desc;
+ uint64_t address[XENCOMM_MINI_ADDRS];
+};
+
+/* To avoid additionnal virt to phys conversion, an opaque structure is
+ presented. */
+struct xencomm_handle;
+
+extern void xencomm_free(struct xencomm_handle *desc);
+extern struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes);
+extern struct xencomm_handle *__xencomm_map_no_alloc(void *ptr,
+ unsigned long bytes, struct xencomm_mini *xc_area);
+
+#if 0
+#define XENCOMM_MINI_ALIGNED(xc_desc, n) \
+ struct xencomm_mini xc_desc ## _base[(n)] \
+ __attribute__((__aligned__(sizeof(struct xencomm_mini)))); \
+ struct xencomm_mini *xc_desc = &xc_desc ## _base[0];
+#else
+/*
+ * gcc bug workaround:
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660
+ * gcc doesn't handle properly stack variable with
+ * __attribute__((__align__(sizeof(struct xencomm_mini))))
+ */
+#define XENCOMM_MINI_ALIGNED(xc_desc, n) \
+ unsigned char xc_desc ## _base[((n) + 1 ) * \
+ sizeof(struct xencomm_mini)]; \
+ struct xencomm_mini *xc_desc = (struct xencomm_mini *) \
+ ((unsigned long)xc_desc ## _base + \
+ (sizeof(struct xencomm_mini) - \
+ ((unsigned long)xc_desc ## _base) % \
+ sizeof(struct xencomm_mini)));
+#endif
+#define xencomm_map_no_alloc(ptr, bytes) \
+ ({ XENCOMM_MINI_ALIGNED(xc_desc, 1); \
+ __xencomm_map_no_alloc(ptr, bytes, xc_desc); })
+
+/* provided by architecture code: */
+extern unsigned long xencomm_vtop(unsigned long vaddr);
+
+static inline void *xencomm_pa(void *ptr)
+{
+ return (void *)xencomm_vtop((unsigned long)ptr);
+}
+
+#define xen_guest_handle(hnd) ((hnd).p)
+
+#endif /* _LINUX_XENCOMM_H_ */
--
1.5.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 12/12] xen: import arch generic part of xencomm.
2008-03-28 11:40 ` [PATCH 12/12] xen: import arch generic part of xencomm Isaku Yamahata
@ 2008-03-28 20:09 ` Jeremy Fitzhardinge
2008-03-31 9:49 ` Isaku Yamahata
0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-28 20:09 UTC (permalink / raw)
To: Isaku Yamahata
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
Isaku Yamahata wrote:
> On xen/ia64 and xen/powerpc hypercall arguments are passed by pseudo
> physical address (guest physical address) so that it's necessary to
> convert from virtual address into pseudo physical address. The frame
> work is called xencomm.
> Import arch generic part of xencomm.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> drivers/xen/Makefile | 1 +
> drivers/xen/xencomm.c | 232 +++++++++++++++++++++++++++++++++++++++
> include/xen/interface/xencomm.h | 41 +++++++
> include/xen/xencomm.h | 77 +++++++++++++
>
There's no Kconfig for this.
What ends up using xencomm? Could we defer adding it until there's an
in-tree user?
J
> 4 files changed, 351 insertions(+), 0 deletions(-)
> create mode 100644 drivers/xen/xencomm.c
> create mode 100644 include/xen/interface/xencomm.h
> create mode 100644 include/xen/xencomm.h
>
> diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> index 823ce78..43f014c 100644
> --- a/drivers/xen/Makefile
> +++ b/drivers/xen/Makefile
> @@ -1,2 +1,3 @@
> obj-y += grant-table.o features.o events.o
> obj-y += xenbus/
> +obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
> diff --git a/drivers/xen/xencomm.c b/drivers/xen/xencomm.c
> new file mode 100644
> index 0000000..797cb4e
> --- /dev/null
> +++ b/drivers/xen/xencomm.c
> @@ -0,0 +1,232 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + *
> + * Copyright (C) IBM Corp. 2006
> + *
> + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
> + */
> +
> +#include <linux/gfp.h>
> +#include <linux/mm.h>
> +#include <asm/page.h>
> +#include <xen/xencomm.h>
> +#include <xen/interface/xen.h>
> +#ifdef __ia64__
> +#include <asm/xen/xencomm.h> /* for is_kern_addr() */
> +#endif
> +
> +#ifdef HAVE_XEN_PLATFORM_COMPAT_H
> +#include <xen/platform-compat.h>
> +#endif
> +
> +static int xencomm_init(struct xencomm_desc *desc,
> + void *buffer, unsigned long bytes)
> +{
> + unsigned long recorded = 0;
> + int i = 0;
> +
> + while ((recorded < bytes) && (i < desc->nr_addrs)) {
> + unsigned long vaddr = (unsigned long)buffer + recorded;
> + unsigned long paddr;
> + int offset;
> + int chunksz;
> +
> + offset = vaddr % PAGE_SIZE; /* handle partial pages */
> + chunksz = min(PAGE_SIZE - offset, bytes - recorded);
> +
> + paddr = xencomm_vtop(vaddr);
> + if (paddr == ~0UL) {
> + printk(KERN_DEBUG "%s: couldn't translate vaddr %lx\n",
> + __func__, vaddr);
> + return -EINVAL;
> + }
> +
> + desc->address[i++] = paddr;
> + recorded += chunksz;
> + }
> +
> + if (recorded < bytes) {
> + printk(KERN_DEBUG
> + "%s: could only translate %ld of %ld bytes\n",
> + __func__, recorded, bytes);
> + return -ENOSPC;
> + }
> +
> + /* mark remaining addresses invalid (just for safety) */
> + while (i < desc->nr_addrs)
> + desc->address[i++] = XENCOMM_INVALID;
> +
> + desc->magic = XENCOMM_MAGIC;
> +
> + return 0;
> +}
> +
> +static struct xencomm_desc *xencomm_alloc(gfp_t gfp_mask,
> + void *buffer, unsigned long bytes)
> +{
> + struct xencomm_desc *desc;
> + unsigned long buffer_ulong = (unsigned long)buffer;
> + unsigned long start = buffer_ulong & PAGE_MASK;
> + unsigned long end = (buffer_ulong + bytes) | ~PAGE_MASK;
> + unsigned long nr_addrs = (end - start + 1) >> PAGE_SHIFT;
> + unsigned long size = sizeof(*desc) +
> + sizeof(desc->address[0]) * nr_addrs;
> +
> + /*
> + * slab allocator returns at least sizeof(void*) aligned pointer.
> + * When sizeof(*desc) > sizeof(void*), struct xencomm_desc might
> + * cross page boundary.
> + */
> + if (sizeof(*desc) > sizeof(void *)) {
> + unsigned long order = get_order(size);
> + desc = (struct xencomm_desc *)__get_free_pages(gfp_mask,
> + order);
> + if (desc == NULL)
> + return NULL;
> +
> + desc->nr_addrs =
> + ((PAGE_SIZE << order) - sizeof(struct xencomm_desc)) /
> + sizeof(*desc->address);
> + } else {
> + desc = kmalloc(size, gfp_mask);
> + if (desc == NULL)
> + return NULL;
> +
> + desc->nr_addrs = nr_addrs;
> + }
> + return desc;
> +}
> +
> +void xencomm_free(struct xencomm_handle *desc)
> +{
> + if (desc && !((ulong)desc & XENCOMM_INLINE_FLAG)) {
> + struct xencomm_desc *desc__ = (struct xencomm_desc *)desc;
> + if (sizeof(*desc__) > sizeof(void *)) {
> + unsigned long size = sizeof(*desc__) +
> + sizeof(desc__->address[0]) * desc__->nr_addrs;
> + unsigned long order = get_order(size);
> + free_pages((unsigned long)__va(desc), order);
> + } else
> + kfree(__va(desc));
> + }
> +}
> +
> +static int xencomm_create(void *buffer, unsigned long bytes,
> + struct xencomm_desc **ret, gfp_t gfp_mask)
> +{
> + struct xencomm_desc *desc;
> + int rc;
> +
> + pr_debug("%s: %p[%ld]\n", __func__, buffer, bytes);
> +
> + if (bytes == 0) {
> + /* don't create a descriptor; Xen recognizes NULL. */
> + BUG_ON(buffer != NULL);
> + *ret = NULL;
> + return 0;
> + }
> +
> + BUG_ON(buffer == NULL); /* 'bytes' is non-zero */
> +
> + desc = xencomm_alloc(gfp_mask, buffer, bytes);
> + if (!desc) {
> + printk(KERN_DEBUG "%s failure\n", "xencomm_alloc");
> + return -ENOMEM;
> + }
> +
> + rc = xencomm_init(desc, buffer, bytes);
> + if (rc) {
> + printk(KERN_DEBUG "%s failure: %d\n", "xencomm_init", rc);
> + xencomm_free((struct xencomm_handle *)__pa(desc));
> + return rc;
> + }
> +
> + *ret = desc;
> + return 0;
> +}
> +
> +/* check if memory address is within VMALLOC region */
> +static int is_phys_contiguous(unsigned long addr)
> +{
> + if (!is_kernel_addr(addr))
> + return 0;
> +
> + return (addr < VMALLOC_START) || (addr >= VMALLOC_END);
> +}
> +
> +static struct xencomm_handle *xencomm_create_inline(void *ptr)
> +{
> + unsigned long paddr;
> +
> + BUG_ON(!is_phys_contiguous((unsigned long)ptr));
> +
> + paddr = (unsigned long)xencomm_pa(ptr);
> + BUG_ON(paddr & XENCOMM_INLINE_FLAG);
> + return (struct xencomm_handle *)(paddr | XENCOMM_INLINE_FLAG);
> +}
> +
> +/* "mini" routine, for stack-based communications: */
> +static int xencomm_create_mini(void *buffer,
> + unsigned long bytes, struct xencomm_mini *xc_desc,
> + struct xencomm_desc **ret)
> +{
> + int rc = 0;
> + struct xencomm_desc *desc;
> + BUG_ON(((unsigned long)xc_desc) % sizeof(*xc_desc) != 0);
> +
> + desc = (void *)xc_desc;
> +
> + desc->nr_addrs = XENCOMM_MINI_ADDRS;
> +
> + rc = xencomm_init(desc, buffer, bytes);
> + if (!rc)
> + *ret = desc;
> +
> + return rc;
> +}
> +
> +struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes)
> +{
> + int rc;
> + struct xencomm_desc *desc;
> +
> + if (is_phys_contiguous((unsigned long)ptr))
> + return xencomm_create_inline(ptr);
> +
> + rc = xencomm_create(ptr, bytes, &desc, GFP_KERNEL);
> +
> + if (rc || desc == NULL)
> + return NULL;
> +
> + return xencomm_pa(desc);
> +}
> +
> +struct xencomm_handle *__xencomm_map_no_alloc(void *ptr, unsigned long bytes,
> + struct xencomm_mini *xc_desc)
> +{
> + int rc;
> + struct xencomm_desc *desc = NULL;
> +
> + if (is_phys_contiguous((unsigned long)ptr))
> + return xencomm_create_inline(ptr);
> +
> + rc = xencomm_create_mini(ptr, bytes, xc_desc,
> + &desc);
> +
> + if (rc)
> + return NULL;
> +
> + return xencomm_pa(desc);
> +}
> diff --git a/include/xen/interface/xencomm.h b/include/xen/interface/xencomm.h
> new file mode 100644
> index 0000000..ac45e07
> --- /dev/null
> +++ b/include/xen/interface/xencomm.h
> @@ -0,0 +1,41 @@
> +/*
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to
> + * deal in the Software without restriction, including without limitation the
> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
> + * sell copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + *
> + * Copyright (C) IBM Corp. 2006
> + */
> +
> +#ifndef _XEN_XENCOMM_H_
> +#define _XEN_XENCOMM_H_
> +
> +/* A xencomm descriptor is a scatter/gather list containing physical
> + * addresses corresponding to a virtually contiguous memory area. The
> + * hypervisor translates these physical addresses to machine addresses to copy
> + * to and from the virtually contiguous area.
> + */
> +
> +#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
> +#define XENCOMM_INVALID (~0UL)
> +
> +struct xencomm_desc {
> + uint32_t magic;
> + uint32_t nr_addrs; /* the number of entries in address[] */
> + uint64_t address[0];
> +};
> +
> +#endif /* _XEN_XENCOMM_H_ */
> diff --git a/include/xen/xencomm.h b/include/xen/xencomm.h
> new file mode 100644
> index 0000000..e43b039
> --- /dev/null
> +++ b/include/xen/xencomm.h
> @@ -0,0 +1,77 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + *
> + * Copyright (C) IBM Corp. 2006
> + *
> + * Authors: Hollis Blanchard <hollisb@us.ibm.com>
> + * Jerone Young <jyoung5@us.ibm.com>
> + */
> +
> +#ifndef _LINUX_XENCOMM_H_
> +#define _LINUX_XENCOMM_H_
> +
> +#include <xen/interface/xencomm.h>
> +
> +#define XENCOMM_MINI_ADDRS 3
> +struct xencomm_mini {
> + struct xencomm_desc _desc;
> + uint64_t address[XENCOMM_MINI_ADDRS];
> +};
> +
> +/* To avoid additionnal virt to phys conversion, an opaque structure is
> + presented. */
> +struct xencomm_handle;
> +
> +extern void xencomm_free(struct xencomm_handle *desc);
> +extern struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes);
> +extern struct xencomm_handle *__xencomm_map_no_alloc(void *ptr,
> + unsigned long bytes, struct xencomm_mini *xc_area);
> +
> +#if 0
> +#define XENCOMM_MINI_ALIGNED(xc_desc, n) \
> + struct xencomm_mini xc_desc ## _base[(n)] \
> + __attribute__((__aligned__(sizeof(struct xencomm_mini)))); \
> + struct xencomm_mini *xc_desc = &xc_desc ## _base[0];
> +#else
> +/*
> + * gcc bug workaround:
> + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660
> + * gcc doesn't handle properly stack variable with
> + * __attribute__((__align__(sizeof(struct xencomm_mini))))
> + */
> +#define XENCOMM_MINI_ALIGNED(xc_desc, n) \
> + unsigned char xc_desc ## _base[((n) + 1 ) * \
> + sizeof(struct xencomm_mini)]; \
> + struct xencomm_mini *xc_desc = (struct xencomm_mini *) \
> + ((unsigned long)xc_desc ## _base + \
> + (sizeof(struct xencomm_mini) - \
> + ((unsigned long)xc_desc ## _base) % \
> + sizeof(struct xencomm_mini)));
> +#endif
> +#define xencomm_map_no_alloc(ptr, bytes) \
> + ({ XENCOMM_MINI_ALIGNED(xc_desc, 1); \
> + __xencomm_map_no_alloc(ptr, bytes, xc_desc); })
> +
> +/* provided by architecture code: */
> +extern unsigned long xencomm_vtop(unsigned long vaddr);
> +
> +static inline void *xencomm_pa(void *ptr)
> +{
> + return (void *)xencomm_vtop((unsigned long)ptr);
> +}
> +
> +#define xen_guest_handle(hnd) ((hnd).p)
> +
> +#endif /* _LINUX_XENCOMM_H_ */
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 07/12] Xen: Make events.c portable for ia64/xen support.
2008-03-28 11:40 ` [PATCH 07/12] Xen: Make events.c portable for ia64/xen support Isaku Yamahata
@ 2008-03-28 20:27 ` Jeremy Fitzhardinge
2008-03-31 9:34 ` Isaku Yamahata
0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-28 20:27 UTC (permalink / raw)
To: Isaku Yamahata
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
Isaku Yamahata wrote:
> +/* macro to avoid header inclusion dependncy hell */
> +#define xen_irqs_disabled(regs) (!((regs)->flags & X86_EFLAGS_IF))
>
This seems pretty generic. Is there no suitable existing function?
Could irqs_disabled_flags() be pressed into service? I guess it depends
on how ia64 (and other architectures) can get the saved flags state from
the interrupt context.
> +
> +/* macro to avoid header inclusion dependncy hell */
> +#define xen_do_IRQ(irq, regs) \
> + do { \
> + (regs)->orig_ax = ~(irq); \
> + do_IRQ(regs); \
> + } while (0)
>
It's not possible to put this somewhere it could be an inline function?
It might be better to make it an out of line function then.
J
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c.
2008-03-28 11:40 ` [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c Isaku Yamahata
@ 2008-03-28 20:29 ` Jeremy Fitzhardinge
2008-03-31 9:36 ` Isaku Yamahata
0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-28 20:29 UTC (permalink / raw)
To: Isaku Yamahata
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
Isaku Yamahata wrote:
> Define resend_irq_on_evtchn() which ia64/xen uses.
> Although it isn't used by current x86/xen code, it's arch generic
> so that put it into common code.
> make ipi_to_irq[] visible removing static because
> ia64/xen needs to access the variable from ia64 specific code
>
What kind of access? Would it be better to add some accessor functions?
If nothing else, it needs to be prefixed with xen_ if it goes non-static.
(As should resend_irq_on_evtchn(), but I'm less concerned about a name
collision.)
J
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> drivers/xen/events.c | 18 +++++++++++++++++-
> include/xen/events.h | 1 +
> 2 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> index 2396b44..1c2c193 100644
> --- a/drivers/xen/events.c
> +++ b/drivers/xen/events.c
> @@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(irq_mapping_update_lock);
> static DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};
>
> /* IRQ <-> IPI mapping */
> -static DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
> +DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
>
> /* Packed IRQ information: binding type, sub-type index, and event channel. */
> struct packed_irq
> @@ -586,6 +586,22 @@ static void set_affinity_irq(unsigned irq, cpumask_t dest)
> rebind_irq_to_cpu(irq, tcpu);
> }
>
> +int resend_irq_on_evtchn(unsigned int irq)
> +{
> + int masked, evtchn = evtchn_from_irq(irq);
> + struct shared_info *s = HYPERVISOR_shared_info;
> +
> + if (!VALID_EVTCHN(evtchn))
> + return 1;
> +
> + masked = sync_test_and_set_bit(evtchn, s->evtchn_mask);
> + sync_set_bit(evtchn, s->evtchn_pending);
> + if (!masked)
> + unmask_evtchn(evtchn);
> +
> + return 1;
> +}
> +
> static void enable_dynirq(unsigned int irq)
> {
> int evtchn = evtchn_from_irq(irq);
> diff --git a/include/xen/events.h b/include/xen/events.h
> index 2bde54d..574cfa4 100644
> --- a/include/xen/events.h
> +++ b/include/xen/events.h
> @@ -37,6 +37,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
> void unbind_from_irqhandler(unsigned int irq, void *dev_id);
>
> void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
> +int resend_irq_on_evtchn(unsigned int irq);
>
> static inline void notify_remote_via_evtchn(int port)
> {
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one.
2008-03-28 11:40 ` [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one Isaku Yamahata
@ 2008-03-28 20:31 ` Jeremy Fitzhardinge
2008-03-31 10:11 ` Isaku Yamahata
0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-28 20:31 UTC (permalink / raw)
To: Isaku Yamahata
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
Isaku Yamahata wrote:
> Don't use alloc_vm_area()/free_vm_area() directly, instead define
> xen_alloc_vm_area()/xen_free_vm_area() and use them.
>
> alloc_vm_area()/free_vm_area() are used to allocate/free area which
> are for grant table mapping. Xen/x86 grant table is based on virtual
> address so that alloc_vm_area()/free_vm_area() are suitable.
> On the other hand Xen/ia64 (and Xen/powerpc) grant table is based on
> pseudo physical address (guest physical address) so that allocation
> should be done differently.
> The original version of xenified Linux/IA64 have its own
> allocate_vm_area()/free_vm_area() definitions which don't allocate vm area
> contradictory to those names.
> Now vanilla Linux already has its definitions so that it's impossible
> to have IA64 definitions of allocate_vm_area()/free_vm_area().
> Instead introduce xen_allocate_vm_area()/xen_free_vm_area() and use them.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> drivers/xen/grant-table.c | 2 +-
> drivers/xen/xenbus/xenbus_client.c | 6 +++---
> include/asm-x86/xen/hypervisor.h | 3 +++
> 3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
> index 95016fd..9fcde20 100644
> --- a/drivers/xen/grant-table.c
> +++ b/drivers/xen/grant-table.c
> @@ -478,7 +478,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
>
> if (shared == NULL) {
> struct vm_struct *area;
> - area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
> + area = xen_alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
> BUG_ON(area == NULL);
> shared = area->addr;
> }
> diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
> index 9fd2f70..0f86b0f 100644
> --- a/drivers/xen/xenbus/xenbus_client.c
> +++ b/drivers/xen/xenbus/xenbus_client.c
> @@ -399,7 +399,7 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
>
> *vaddr = NULL;
>
> - area = alloc_vm_area(PAGE_SIZE);
> + area = xen_alloc_vm_area(PAGE_SIZE);
> if (!area)
> return -ENOMEM;
>
> @@ -409,7 +409,7 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
> BUG();
>
> if (op.status != GNTST_okay) {
> - free_vm_area(area);
> + xen_free_vm_area(area);
> xenbus_dev_fatal(dev, op.status,
> "mapping in shared page %d from domain %d",
> gnt_ref, dev->otherend_id);
> @@ -508,7 +508,7 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
> BUG();
>
> if (op.status == GNTST_okay)
> - free_vm_area(area);
> + xen_free_vm_area(area);
> else
> xenbus_dev_error(dev, op.status,
> "unmapping page at handle %d error %d",
> diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h
> index 767a361..31e526d 100644
> --- a/include/asm-x86/xen/hypervisor.h
> +++ b/include/asm-x86/xen/hypervisor.h
> @@ -57,6 +57,9 @@ extern struct shared_info *HYPERVISOR_shared_info;
> extern struct start_info *xen_start_info;
> #define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
>
> +#define xen_alloc_vm_area(size) alloc_vm_area(size)
> +#define xen_free_vm_area(area) free_vm_area(area)
> +
>
This change looks fine overall, but asm/xen/hypervisor.h seems to be
turning into a bit of a dumping-ground. I wonder if we can't come up
with a better-named header...
J
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir.
2008-03-28 11:40 ` [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir Isaku Yamahata
@ 2008-03-28 20:41 ` Jeremy Fitzhardinge
2008-03-30 13:41 ` Avi Kivity
0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-28 20:41 UTC (permalink / raw)
To: Isaku Yamahata
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
Isaku Yamahata wrote:
> The definitions in include/asm/xen/page.h are arch specific.
> ia64/xen wants to define its own version. So move them to arch specific
> directory and keep include/xen/page.h in order not to break compilation.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> include/{ => asm-x86}/xen/page.h | 0
> include/xen/page.h | 169 +-------------------------------------
> 2 files changed, 1 insertions(+), 168 deletions(-)
> copy include/{ => asm-x86}/xen/page.h (100%)
>
> diff --git a/include/xen/page.h b/include/asm-x86/xen/page.h
> similarity index 100%
> copy from include/xen/page.h
> copy to include/asm-x86/xen/page.h
> diff --git a/include/xen/page.h b/include/xen/page.h
>
Is this a magic git-format patch, or is it simply missing
asm-x86/xen/page.h?
> index 0179930..eaf85fa 100644
> --- a/include/xen/page.h
> +++ b/include/xen/page.h
> @@ -1,168 +1 @@
> -#ifndef __XEN_PAGE_H
> -#define __XEN_PAGE_H
> -
> -#include <linux/pfn.h>
> -
> -#include <asm/uaccess.h>
> -#include <asm/pgtable.h>
> -
> -#include <xen/features.h>
> -
> -/* Xen machine address */
> -typedef struct xmaddr {
> - phys_addr_t maddr;
> -} xmaddr_t;
> -
> -/* Xen pseudo-physical address */
> -typedef struct xpaddr {
> - phys_addr_t paddr;
> -} xpaddr_t;
> -
> -#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
> -#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
> -
> -/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
> -#define INVALID_P2M_ENTRY (~0UL)
> -#define FOREIGN_FRAME_BIT (1UL<<31)
> -#define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT)
> -
> -extern unsigned long *phys_to_machine_mapping;
> -
> -static inline unsigned long pfn_to_mfn(unsigned long pfn)
> -{
> - if (xen_feature(XENFEAT_auto_translated_physmap))
> - return pfn;
> -
> - return phys_to_machine_mapping[(unsigned int)(pfn)] &
> - ~FOREIGN_FRAME_BIT;
> -}
> -
> -static inline int phys_to_machine_mapping_valid(unsigned long pfn)
> -{
> - if (xen_feature(XENFEAT_auto_translated_physmap))
> - return 1;
> -
> - return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
> -}
> -
> -static inline unsigned long mfn_to_pfn(unsigned long mfn)
> -{
> - unsigned long pfn;
> -
> - if (xen_feature(XENFEAT_auto_translated_physmap))
> - return mfn;
> -
> -#if 0
> - if (unlikely((mfn >> machine_to_phys_order) != 0))
> - return max_mapnr;
> -#endif
> -
> - pfn = 0;
> - /*
> - * The array access can fail (e.g., device space beyond end of RAM).
> - * In such cases it doesn't matter what we return (we return garbage),
> - * but we must handle the fault without crashing!
> - */
> - __get_user(pfn, &machine_to_phys_mapping[mfn]);
> -
> - return pfn;
> -}
> -
> -static inline xmaddr_t phys_to_machine(xpaddr_t phys)
> -{
> - unsigned offset = phys.paddr & ~PAGE_MASK;
> - return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
> -}
> -
> -static inline xpaddr_t machine_to_phys(xmaddr_t machine)
> -{
> - unsigned offset = machine.maddr & ~PAGE_MASK;
> - return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
> -}
> -
> -/*
> - * We detect special mappings in one of two ways:
> - * 1. If the MFN is an I/O page then Xen will set the m2p entry
> - * to be outside our maximum possible pseudophys range.
> - * 2. If the MFN belongs to a different domain then we will certainly
> - * not have MFN in our p2m table. Conversely, if the page is ours,
> - * then we'll have p2m(m2p(MFN))==MFN.
> - * If we detect a special mapping then it doesn't have a 'struct page'.
> - * We force !pfn_valid() by returning an out-of-range pointer.
> - *
> - * NB. These checks require that, for any MFN that is not in our reservation,
> - * there is no PFN such that p2m(PFN) == MFN. Otherwise we can get confused if
> - * we are foreign-mapping the MFN, and the other domain as m2p(MFN) == PFN.
> - * Yikes! Various places must poke in INVALID_P2M_ENTRY for safety.
> - *
> - * NB2. When deliberately mapping foreign pages into the p2m table, you *must*
> - * use FOREIGN_FRAME(). This will cause pte_pfn() to choke on it, as we
> - * require. In all the cases we care about, the FOREIGN_FRAME bit is
> - * masked (e.g., pfn_to_mfn()) so behaviour there is correct.
> - */
> -static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
> -{
> - extern unsigned long max_mapnr;
> - unsigned long pfn = mfn_to_pfn(mfn);
> - if ((pfn < max_mapnr)
> - && !xen_feature(XENFEAT_auto_translated_physmap)
> - && (phys_to_machine_mapping[pfn] != mfn))
> - return max_mapnr; /* force !pfn_valid() */
> - return pfn;
> -}
> -
> -static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
> -{
> - if (xen_feature(XENFEAT_auto_translated_physmap)) {
> - BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
> - return;
> - }
> - phys_to_machine_mapping[pfn] = mfn;
> -}
> -
> -/* VIRT <-> MACHINE conversion */
> -#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
> -#define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v))))
> -#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
> -
> -static inline unsigned long pte_mfn(pte_t pte)
> -{
> - return (pte.pte & ~_PAGE_NX) >> PAGE_SHIFT;
> -}
> -
> -static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
> -{
> - pte_t pte;
> -
> - pte.pte = ((phys_addr_t)page_nr << PAGE_SHIFT) |
> - (pgprot_val(pgprot) & __supported_pte_mask);
> -
> - return pte;
> -}
> -
> -static inline pteval_t pte_val_ma(pte_t pte)
> -{
> - return pte.pte;
> -}
> -
> -static inline pte_t __pte_ma(pteval_t x)
> -{
> - return (pte_t) { .pte = x };
> -}
> -
> -#ifdef CONFIG_X86_PAE
> -#define pmd_val_ma(v) ((v).pmd)
> -#define pud_val_ma(v) ((v).pgd.pgd)
> -#define __pmd_ma(x) ((pmd_t) { (x) } )
> -#else /* !X86_PAE */
> -#define pmd_val_ma(v) ((v).pud.pgd.pgd)
> -#endif /* CONFIG_X86_PAE */
> -
> -#define pgd_val_ma(x) ((x).pgd)
> -
> -
> -xmaddr_t arbitrary_virt_to_machine(unsigned long address);
> -void make_lowmem_page_readonly(void *vaddr);
> -void make_lowmem_page_readwrite(void *vaddr);
> -
> -#endif /* __XEN_PAGE_H */
> +#include <asm/xen/page.h>
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir.
2008-03-28 20:41 ` Jeremy Fitzhardinge
@ 2008-03-30 13:41 ` Avi Kivity
0 siblings, 0 replies; 24+ messages in thread
From: Avi Kivity @ 2008-03-30 13:41 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Isaku Yamahata, eddie.dong, linux-kernel, virtualization, chrisw,
xen-ia64-devel
Jeremy Fitzhardinge wrote:
> Isaku Yamahata wrote:
>
>> The definitions in include/asm/xen/page.h are arch specific.
>> ia64/xen wants to define its own version. So move them to arch specific
>> directory and keep include/xen/page.h in order not to break compilation.
>>
>> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
>> ---
>> include/{ => asm-x86}/xen/page.h | 0
>> include/xen/page.h | 169 +-------------------------------------
>> 2 files changed, 1 insertions(+), 168 deletions(-)
>> copy include/{ => asm-x86}/xen/page.h (100%)
>>
>> diff --git a/include/xen/page.h b/include/asm-x86/xen/page.h
>> similarity index 100%
>> copy from include/xen/page.h
>> copy to include/asm-x86/xen/page.h
>> diff --git a/include/xen/page.h b/include/xen/page.h
>>
>>
>
> Is this a magic git-format patch, or is it simply missing
> asm-x86/xen/page.h?
>
>
Magic git format. Look at lines beginning with 'copy' above.
(a better result would have been a move along with a creation of a new
include/xen/page.h)
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 07/12] Xen: Make events.c portable for ia64/xen support.
2008-03-28 20:27 ` Jeremy Fitzhardinge
@ 2008-03-31 9:34 ` Isaku Yamahata
0 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-31 9:34 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
On Fri, Mar 28, 2008 at 01:27:58PM -0700, Jeremy Fitzhardinge wrote:
> Isaku Yamahata wrote:
> >+/* macro to avoid header inclusion dependncy hell */
> >+#define xen_irqs_disabled(regs) (!((regs)->flags & X86_EFLAGS_IF))
> >
>
> This seems pretty generic. Is there no suitable existing function?
> Could irqs_disabled_flags() be pressed into service? I guess it depends
> on how ia64 (and other architectures) can get the saved flags state from
> the interrupt context.
Unfortunately ia64 doesn't support CONFIG_TRACE_IRQFLAGS_SUPPORT.
I couldn't found any generic one.
> >+
> >+/* macro to avoid header inclusion dependncy hell */
> >+#define xen_do_IRQ(irq, regs) \
> >+ do { \
> >+ (regs)->orig_ax = ~(irq); \
> >+ do_IRQ(regs); \
> >+ } while (0)
> >
>
> It's not possible to put this somewhere it could be an inline function?
> It might be better to make it an out of line function then.
I revised events.c again so that I found that enum ipi_vector needs to
be arch specific because ia64/xen needs 4 vectors for ipi.
Thus I reached this one.
Changes before
- inetroduced include/asm/xen/events.h
- make enum ipi_vector arch spefic
- make xen_irqs_disabled() static inline.
- make xen_do_IRQ() static inline
>From 871d085cf15450a35497ded6b56a8bcb133d597a Mon Sep 17 00:00:00 2001
From: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Mon, 31 Mar 2008 18:18:56 -0700
Subject: [PATCH 007/112] Xen: Make events.c portable for ia64/xen support.
Remove x86 dependency in drivers/xen/events.c for ia64/xen support
introducing include/asm/xen/events.h.
Introduce xen_irqs_disabled() to hide regs->flags
Introduce xen_do_IRQ() to hide regs->orig_ax.
make enum ipi_vector definition arch specific. ia64/xen needs four vectors.
Add one rmb() because on ia64 xchg() isn't barrier.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/events.c | 13 +++++++------
include/asm-x86/xen/events.h | 22 ++++++++++++++++++++++
include/xen/events.h | 8 +-------
3 files changed, 30 insertions(+), 13 deletions(-)
create mode 100644 include/asm-x86/xen/events.h
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index c50d499..2396b44 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -469,7 +469,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
for_each_online_cpu(i) {
struct vcpu_info *v = per_cpu(xen_vcpu, i);
printk("%d: masked=%d pending=%d event_sel %08lx\n ", i,
- (get_irq_regs() && i == cpu) ? !(get_irq_regs()->flags & X86_EFLAGS_IF) : v->evtchn_upcall_mask,
+ (get_irq_regs() && i == cpu) ? xen_irqs_disabled(get_irq_regs()) : v->evtchn_upcall_mask,
v->evtchn_upcall_pending,
v->evtchn_pending_sel);
}
@@ -527,7 +527,10 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
if (__get_cpu_var(nesting_count)++)
goto out;
- /* NB. No need for a barrier here -- XCHG is a barrier on x86. */
+#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
+ /* Clear master flag /before/ clearing selector flag. */
+ rmb();
+#endif
pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0);
while (pending_words != 0) {
unsigned long pending_bits;
@@ -539,10 +542,8 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
int port = (word_idx * BITS_PER_LONG) + bit_idx;
int irq = evtchn_to_irq[port];
- if (irq != -1) {
- regs->orig_ax = ~irq;
- do_IRQ(regs);
- }
+ if (irq != -1)
+ xen_do_IRQ(irq, regs);
}
}
diff --git a/include/asm-x86/xen/events.h b/include/asm-x86/xen/events.h
new file mode 100644
index 0000000..596312a
--- /dev/null
+++ b/include/asm-x86/xen/events.h
@@ -0,0 +1,22 @@
+#ifndef __XEN_EVENTS_H
+#define __XEN_EVENTS_H
+
+enum ipi_vector {
+ XEN_RESCHEDULE_VECTOR,
+ XEN_CALL_FUNCTION_VECTOR,
+
+ XEN_NR_IPIS,
+};
+
+static inline int xen_irqs_disabled(struct pt_regs *regs)
+{
+ return raw_irqs_disabled_flags(regs->flags);
+}
+
+static inline void xen_do_IRQ(int irq, struct pt_regs *regs)
+{
+ regs->orig_ax = ~irq;
+ do_IRQ(regs);
+}
+
+#endif /* __XEN_EVENTS_H */
diff --git a/include/xen/events.h b/include/xen/events.h
index 2bde54d..d99a3e0 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -5,13 +5,7 @@
#include <xen/interface/event_channel.h>
#include <asm/xen/hypercall.h>
-
-enum ipi_vector {
- XEN_RESCHEDULE_VECTOR,
- XEN_CALL_FUNCTION_VECTOR,
-
- XEN_NR_IPIS,
-};
+#include <asm/xen/events.h>
int bind_evtchn_to_irq(unsigned int evtchn);
int bind_evtchn_to_irqhandler(unsigned int evtchn,
--
1.5.3
--
yamahata
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c.
2008-03-28 20:29 ` Jeremy Fitzhardinge
@ 2008-03-31 9:36 ` Isaku Yamahata
0 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-31 9:36 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
On Fri, Mar 28, 2008 at 01:29:54PM -0700, Jeremy Fitzhardinge wrote:
> Isaku Yamahata wrote:
> >Define resend_irq_on_evtchn() which ia64/xen uses.
> >Although it isn't used by current x86/xen code, it's arch generic
> >so that put it into common code.
> >make ipi_to_irq[] visible removing static because
> >ia64/xen needs to access the variable from ia64 specific code
> >
>
> What kind of access? Would it be better to add some accessor functions?
>
> If nothing else, it needs to be prefixed with xen_ if it goes non-static.
>
> (As should resend_irq_on_evtchn(), but I'm less concerned about a name
> collision.)
After revising code, I found the access to ipi_to_irq[] isn't necessary
by calling xen_send_IPI_one(). so dropped the line.
changes from the previous one.
- dropped ipi_to_irq[] change.
>From 0b7806fd86c9dcbcd46946aeefedb7acf8d37451 Mon Sep 17 00:00:00 2001
From: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Mon, 31 Mar 2008 17:45:32 -0700
Subject: [PATCH 008/112] xen: add resend_irq_on_evtchn() definition into events.c.
Define resend_irq_on_evtchn() which ia64/xen uses.
Although it isn't used by current x86/xen code, it's arch generic
so that put it into common code.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/events.c | 16 ++++++++++++++++
include/xen/events.h | 1 +
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 2396b44..4f0f22b 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -586,6 +586,22 @@ static void set_affinity_irq(unsigned irq, cpumask_t dest)
rebind_irq_to_cpu(irq, tcpu);
}
+int resend_irq_on_evtchn(unsigned int irq)
+{
+ int masked, evtchn = evtchn_from_irq(irq);
+ struct shared_info *s = HYPERVISOR_shared_info;
+
+ if (!VALID_EVTCHN(evtchn))
+ return 1;
+
+ masked = sync_test_and_set_bit(evtchn, s->evtchn_mask);
+ sync_set_bit(evtchn, s->evtchn_pending);
+ if (!masked)
+ unmask_evtchn(evtchn);
+
+ return 1;
+}
+
static void enable_dynirq(unsigned int irq)
{
int evtchn = evtchn_from_irq(irq);
diff --git a/include/xen/events.h b/include/xen/events.h
index d99a3e0..acd8e06 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -31,6 +31,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
void unbind_from_irqhandler(unsigned int irq, void *dev_id);
void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
+int resend_irq_on_evtchn(unsigned int irq);
static inline void notify_remote_via_evtchn(int port)
{
--
1.5.3
--
yamahata
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 12/12] xen: import arch generic part of xencomm.
2008-03-28 20:09 ` Jeremy Fitzhardinge
@ 2008-03-31 9:49 ` Isaku Yamahata
2008-03-31 15:01 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-31 9:49 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
On Fri, Mar 28, 2008 at 01:09:48PM -0700, Jeremy Fitzhardinge wrote:
> Isaku Yamahata wrote:
> >On xen/ia64 and xen/powerpc hypercall arguments are passed by pseudo
> >physical address (guest physical address) so that it's necessary to
> >convert from virtual address into pseudo physical address. The frame
> >work is called xencomm.
> >Import arch generic part of xencomm.
> >
> >Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> >---
> > drivers/xen/Makefile | 1 +
> > drivers/xen/xencomm.c | 232
> > +++++++++++++++++++++++++++++++++++++++
> > include/xen/interface/xencomm.h | 41 +++++++
> > include/xen/xencomm.h | 77 +++++++++++++
> >
>
> There's no Kconfig for this.
>
> What ends up using xencomm? Could we defer adding it until there's an
> in-tree user?
We are in a dilemma.
ia64/xen needs xencomm so that it needs common xencomm code.
However merging common xencomm code needs the real user i.e. ia64/xen.
Another user of xencomm is powerpc/xen which isn't merged into
upstream. So another choice would be
- put the file into ia64 specific directory and
merge the file through linux-ia64.
When another user appears (possibly powerpc/xen),
move the file into common place (drivers/xen).
We're now struggling for ia64/xen domU merge, so we want to make
ia64/xen domU patch series as small as possible.
Putting the file into drivers/xen is desirable for that.
However either way is ok.
Which way do you want (putting common dir or ia64 specfic dir)?
thanks,
--
yamahata
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one.
2008-03-28 20:31 ` Jeremy Fitzhardinge
@ 2008-03-31 10:11 ` Isaku Yamahata
0 siblings, 0 replies; 24+ messages in thread
From: Isaku Yamahata @ 2008-03-31 10:11 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
On Fri, Mar 28, 2008 at 01:31:55PM -0700, Jeremy Fitzhardinge wrote:
> This change looks fine overall, but asm/xen/hypervisor.h seems to be
> turning into a bit of a dumping-ground. I wonder if we can't come up
> with a better-named header...
How about include/asm/xen/grant_table.h?
xen_{alloc, free}_vm_area() are used for allocate/free grant table
mappable area. So they are grant table related operations.
changes from the previsous one:
- move the declarations from asm/xen/hypervisor.h into
asm/xen/grant_table.h
>From 4c36bb857fda0f4ddaad5ccf07da83d2e15881f5 Mon Sep 17 00:00:00 2001
From: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Mon, 31 Mar 2008 19:03:43 -0700
Subject: [PATCH 010/113] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one.
Don't use alloc_vm_area()/free_vm_area() directly, instead define
xen_alloc_vm_area()/xen_free_vm_area() and use them.
alloc_vm_area()/free_vm_area() are used to allocate/free area which
are for grant table mapping. Xen/x86 grant table is based on virtual
address so that alloc_vm_area()/free_vm_area() are suitable.
On the other hand Xen/ia64 (and Xen/powerpc) grant table is based on
pseudo physical address (guest physical address) so that allocation
should be done differently.
The original version of xenified Linux/IA64 have its own
allocate_vm_area()/free_vm_area() definitions which don't allocate vm area
contradictory to those names.
Now vanilla Linux already has its definitions so that it's impossible
to have IA64 definitions of allocate_vm_area()/free_vm_area().
Instead introduce xen_allocate_vm_area()/xen_free_vm_area() and use them.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
drivers/xen/grant-table.c | 2 +-
drivers/xen/xenbus/xenbus_client.c | 6 +++---
include/asm-x86/xen/grant_table.h | 7 +++++++
include/xen/grant_table.h | 1 +
4 files changed, 12 insertions(+), 4 deletions(-)
create mode 100644 include/asm-x86/xen/grant_table.h
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 95016fd..9fcde20 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -478,7 +478,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
if (shared == NULL) {
struct vm_struct *area;
- area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
+ area = xen_alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
BUG_ON(area == NULL);
shared = area->addr;
}
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 9fd2f70..0f86b0f 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -399,7 +399,7 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
*vaddr = NULL;
- area = alloc_vm_area(PAGE_SIZE);
+ area = xen_alloc_vm_area(PAGE_SIZE);
if (!area)
return -ENOMEM;
@@ -409,7 +409,7 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
BUG();
if (op.status != GNTST_okay) {
- free_vm_area(area);
+ xen_free_vm_area(area);
xenbus_dev_fatal(dev, op.status,
"mapping in shared page %d from domain %d",
gnt_ref, dev->otherend_id);
@@ -508,7 +508,7 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
BUG();
if (op.status == GNTST_okay)
- free_vm_area(area);
+ xen_free_vm_area(area);
else
xenbus_dev_error(dev, op.status,
"unmapping page at handle %d error %d",
diff --git a/include/asm-x86/xen/grant_table.h b/include/asm-x86/xen/grant_table.h
new file mode 100644
index 0000000..2444d45
--- /dev/null
+++ b/include/asm-x86/xen/grant_table.h
@@ -0,0 +1,7 @@
+#ifndef __XEN_GRANT_TABLE_H
+#define __XEN_GRANT_TABLE_H
+
+#define xen_alloc_vm_area(size) alloc_vm_area(size)
+#define xen_free_vm_area(area) free_vm_area(area)
+
+#endif /* __XEN_GRANT_TABLE_H */
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 761c834..d282292 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -39,6 +39,7 @@
#include <asm/xen/hypervisor.h>
#include <xen/interface/grant_table.h>
+#include <asm/xen/grant_table.h>
/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
#define NR_GRANT_FRAMES 4
--
1.5.3
--
yamahata
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 12/12] xen: import arch generic part of xencomm.
2008-03-31 9:49 ` Isaku Yamahata
@ 2008-03-31 15:01 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-31 15:01 UTC (permalink / raw)
To: Isaku Yamahata
Cc: chrisw, sct, virtualization, linux-kernel, xen-ia64-devel, eddie.dong
Isaku Yamahata wrote:
> On Fri, Mar 28, 2008 at 01:09:48PM -0700, Jeremy Fitzhardinge wrote:
>
>> Isaku Yamahata wrote:
>>
>>> On xen/ia64 and xen/powerpc hypercall arguments are passed by pseudo
>>> physical address (guest physical address) so that it's necessary to
>>> convert from virtual address into pseudo physical address. The frame
>>> work is called xencomm.
>>> Import arch generic part of xencomm.
>>>
>>> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
>>> ---
>>> drivers/xen/Makefile | 1 +
>>> drivers/xen/xencomm.c | 232
>>> +++++++++++++++++++++++++++++++++++++++
>>> include/xen/interface/xencomm.h | 41 +++++++
>>> include/xen/xencomm.h | 77 +++++++++++++
>>>
>>>
>> There's no Kconfig for this.
>>
>> What ends up using xencomm? Could we defer adding it until there's an
>> in-tree user?
>>
>
> We are in a dilemma.
> ia64/xen needs xencomm so that it needs common xencomm code.
> However merging common xencomm code needs the real user i.e. ia64/xen.
>
> Another user of xencomm is powerpc/xen which isn't merged into
> upstream. So another choice would be
> - put the file into ia64 specific directory and
> merge the file through linux-ia64.
> When another user appears (possibly powerpc/xen),
> move the file into common place (drivers/xen).
>
> We're now struggling for ia64/xen domU merge, so we want to make
> ia64/xen domU patch series as small as possible.
> Putting the file into drivers/xen is desirable for that.
> However either way is ok.
> Which way do you want (putting common dir or ia64 specfic dir)?
No, it's fine as-is.
J
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2008-03-31 15:02 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-28 11:40 [PATCH 00/12] Xen arch portability patches (take 4) Isaku Yamahata
2008-03-28 11:40 ` [PATCH 01/12] xen: add missing __HYPERVISOR_arch_[0-7] definisions which ia64 needs Isaku Yamahata
2008-03-28 11:40 ` [PATCH 02/12] xen: add missing VIRQ_ARCH_[0-7] definitions which ia64/xen needs Isaku Yamahata
2008-03-28 11:40 ` [PATCH 03/12] xen: add missing definitions for xen grant table " Isaku Yamahata
2008-03-28 11:40 ` [PATCH 04/12] xen: add missing definitions in include/xen/interface/vcpu.h " Isaku Yamahata
2008-03-28 11:40 ` [PATCH 05/12] xen: move features.c from arch/x86/xen/features.c to drivers/xen Isaku Yamahata
2008-03-28 11:40 ` [PATCH 06/12] xen: Move events.c to drivers/xen for IA64/Xen support Isaku Yamahata
2008-03-28 11:40 ` [PATCH 07/12] Xen: Make events.c portable for ia64/xen support Isaku Yamahata
2008-03-28 20:27 ` Jeremy Fitzhardinge
2008-03-31 9:34 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c Isaku Yamahata
2008-03-28 20:29 ` Jeremy Fitzhardinge
2008-03-31 9:36 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 09/12] xen: make include/xen/page.h portable moving those definitions under asm dir Isaku Yamahata
2008-03-28 20:41 ` Jeremy Fitzhardinge
2008-03-30 13:41 ` Avi Kivity
2008-03-28 11:40 ` [PATCH 10/12] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one Isaku Yamahata
2008-03-28 20:31 ` Jeremy Fitzhardinge
2008-03-31 10:11 ` Isaku Yamahata
2008-03-28 11:40 ` [PATCH 11/12] xen: make grant table arch portable Isaku Yamahata
2008-03-28 11:40 ` [PATCH 12/12] xen: import arch generic part of xencomm Isaku Yamahata
2008-03-28 20:09 ` Jeremy Fitzhardinge
2008-03-31 9:49 ` Isaku Yamahata
2008-03-31 15:01 ` Jeremy Fitzhardinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).