[Xen-ia64-devel] [PATCH] paravirtualize itc and support save/restore.

2008-10-19 Thread Isaku Yamahata
This patch is needed for save/restore pv_ops domU.
Since old non-pv_ops domU (Linux 2.6.18-xen) ignores the 
new member in shared_info, itc_offset, itc_last,
save/restore also continues to work with the old kernel.

thanks,

[IA64] paravirtualize itc and support save/restore.

ia64 linux 2.6.18 only use ar.itc for local ticks so that
ar.itc didn't need paravirtualization and it can be work arounded
when save/restore.
However recent ia64 linux uses ar.itc for sched_clock() and 
CONFIG_VIRT_CPU_ACCOUNTING and other issues. So ar.itc needs
paravirtualization. Although Most part is done in guest OS, 
save/restore needs hypervisor support.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]

diff -r 48db4eee7d58 tools/libxc/ia64/xc_ia64_linux_restore.c
--- a/tools/libxc/ia64/xc_ia64_linux_restore.c  Mon Aug 25 19:04:37 2008 +0900
+++ b/tools/libxc/ia64/xc_ia64_linux_restore.c  Fri Aug 29 16:20:15 2008 +0900
@@ -128,7 +128,8 @@
 fprintf(stderr, ip=%016lx, b0=%016lx\n, ctxt-regs.ip, ctxt-regs.b[0]);
 
 /* Initialize and set registers.  */
-ctxt-flags = VGCF_EXTRA_REGS | VGCF_SET_CR_IRR | VGCF_online;
+ctxt-flags = VGCF_EXTRA_REGS | VGCF_SET_CR_IRR | VGCF_online |
+VGCF_SET_AR_ITC;
 if (xc_vcpu_setcontext(xc_handle, dom, vcpu, ctxt_any) != 0) {
 ERROR(Couldn't set vcpu context);
 return -1;
diff -r 48db4eee7d58 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.cMon Aug 25 19:04:37 2008 +0900
+++ b/xen/arch/ia64/xen/domain.cFri Aug 29 16:20:15 2008 +0900
@@ -706,6 +706,48 @@
*nats = ~(1UL  reg);
 }
 
+static unsigned long
+__vcpu_get_itc(struct vcpu *v)
+{
+   unsigned long itc_last;
+   unsigned long itc_offset;
+   unsigned long itc;
+
+   if (unlikely(v-arch.privregs == NULL))
+   return ia64_get_itc();
+   
+   itc_last = v-arch.privregs-itc_last;
+   itc_offset = v-arch.privregs-itc_offset;
+   itc = ia64_get_itc();
+   itc += itc_offset;
+   if (itc_last = itc)
+   itc = itc_last;
+   return itc;
+}
+
+static void
+__vcpu_set_itc(struct vcpu *v, u64 val)
+{
+   unsigned long itc;
+   unsigned long itc_offset;
+   unsigned long itc_last;
+
+   BUG_ON(v-arch.privregs == NULL);
+
+   if (v != current)
+   vcpu_pause(v);
+   
+   itc = ia64_get_itc();
+   itc_offset = val - itc;
+   itc_last = val;
+   
+   v-arch.privregs-itc_offset = itc_offset;
+   v-arch.privregs-itc_last = itc_last;
+
+   if (v != current)
+   vcpu_unpause(v);
+}
+
 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
 {
int i;
@@ -744,6 +786,10 @@
unw_get_ar(info, UNW_AR_LC, c.nat-regs.ar.lc);
unw_get_ar(info, UNW_AR_EC, c.nat-regs.ar.ec);
}
+
+   if (!is_hvm)
+   c.nat-regs.ar.itc = __vcpu_get_itc(v);
+
c.nat-regs.ar.csd = uregs-ar_csd;
c.nat-regs.ar.ssd = uregs-ar_ssd;
 
@@ -1231,6 +1277,10 @@
unw_set_ar(info, UNW_AR_LC, c.nat-regs.ar.lc);
unw_set_ar(info, UNW_AR_EC, c.nat-regs.ar.ec);
}
+
+   if (!is_hvm_domain(d)  (c.nat-flags  VGCF_SET_AR_ITC))
+   __vcpu_set_itc(v, c.nat-regs.ar.itc);
+
uregs-ar_csd = c.nat-regs.ar.csd;
uregs-ar_ssd = c.nat-regs.ar.ssd;

diff -r 48db4eee7d58 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.hMon Aug 25 19:04:37 2008 +0900
+++ b/xen/include/public/arch-ia64.hFri Aug 29 16:20:15 2008 +0900
@@ -198,6 +198,15 @@
 unsigned long rrs[8]; // region registers
 unsigned long krs[8]; // kernel registers
 unsigned long tmp[16]; // temp registers (e.g. for hyperprivops)
+
+/* itc paravirtualization
+ * vAR.ITC = mAR.ITC + itc_offset
+ * itc_last is one which was lastly passed to
+ * the guest OS in order to prevent it from
+ * going backwords.
+ */
+unsigned long itc_offset;
+unsigned long itc_last;
 };
 };
 };
@@ -392,6 +401,7 @@
 #define VGCF_EXTRA_REGS (1UL  1) /* Set extra regs.  */
 #define VGCF_SET_CR_IRR (1UL  2) /* Set cr_irr[0:3]. */
 #define VGCF_online (1UL  3)  /* make this vcpu online */
+#define VGCF_SET_AR_ITC (1UL  4)  /* set pv ar.itc. itc_offset, itc_last */
 unsigned long flags;   /* VGCF_* flags */
 
 struct vcpu_guest_context_regs regs;


-- 
yamahata

___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 08/13] ia64/pv_ops/xen/pv_time_ops: implement sched_clock.

2008-10-19 Thread Isaku Yamahata
paravirtualize sched_clock.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/xen/Kconfig |1 +
 arch/ia64/xen/time.c  |   48 
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/xen/Kconfig b/arch/ia64/xen/Kconfig
index f1683a2..48839da 100644
--- a/arch/ia64/xen/Kconfig
+++ b/arch/ia64/xen/Kconfig
@@ -8,6 +8,7 @@ config XEN
depends on PARAVIRT  MCKINLEY  IA64_PAGE_SIZE_16KB  EXPERIMENTAL
select XEN_XENCOMM
select NO_IDLE_HZ
+   select HAVE_UNSTABLE_SCHED_CLOCK
 
# those are required to save/restore.
select ARCH_SUSPEND_POSSIBLE
diff --git a/arch/ia64/xen/time.c b/arch/ia64/xen/time.c
index d15a94c..c85d319 100644
--- a/arch/ia64/xen/time.c
+++ b/arch/ia64/xen/time.c
@@ -175,10 +175,58 @@ static void xen_itc_jitter_data_reset(void)
} while (unlikely(ret != lcycle));
 }
 
+/* based on xen_sched_clock() in arch/x86/xen/time.c. */
+/*
+ * This relies on HAVE_UNSTABLE_SCHED_CLOCK. If it can't be defined,
+ * something similar logic should be implemented here.
+ */
+/*
+ * Xen sched_clock implementation.  Returns the number of unstolen
+ * nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED
+ * states.
+ */
+static unsigned long long xen_sched_clock(void)
+{
+   struct vcpu_runstate_info runstate;
+
+   unsigned long long now;
+   unsigned long long offset;
+   unsigned long long ret;
+
+   /*
+* Ideally sched_clock should be called on a per-cpu basis
+* anyway, so preempt should already be disabled, but that's
+* not current practice at the moment.
+*/
+   preempt_disable();
+
+   /*
+* both ia64_native_sched_clock() and xen's runstate are
+* based on mAR.ITC. So difference of them makes sense.
+*/
+   now = ia64_native_sched_clock();
+
+   get_runstate_snapshot(runstate);
+
+   WARN_ON(runstate.state != RUNSTATE_running);
+
+   offset = 0;
+   if (now  runstate.state_entry_time)
+   offset = now - runstate.state_entry_time;
+   ret = runstate.time[RUNSTATE_blocked] +
+   runstate.time[RUNSTATE_running] +
+   offset;
+
+   preempt_enable();
+
+   return ret;
+}
+
 struct pv_time_ops xen_time_ops __initdata = {
.init_missing_ticks_accounting  = xen_init_missing_ticks_accounting,
.do_steal_accounting= xen_do_steal_accounting,
.clocksource_resume = xen_itc_jitter_data_reset,
+   .sched_clock= xen_sched_clock,
 };
 
 /* Called after suspend, to resume time.  */
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 07/13] ia64/pv_ops/pv_time_ops: add sched_clock hook.

2008-10-19 Thread Isaku Yamahata
add sched_clock() hook to paravirtualize sched_clock().
ia64 sched_clock() is based on ar.itc which isn't stable
on virtualized environment because vcpu may move around on
pcpus. So it needs paravirtualization.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/paravirt.h |7 +++
 arch/ia64/include/asm/timex.h|1 +
 arch/ia64/kernel/head.S  |4 ++--
 arch/ia64/kernel/paravirt.c  |1 +
 arch/ia64/kernel/time.c  |   12 
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/include/asm/paravirt.h b/arch/ia64/include/asm/paravirt.h
index 56f69f9..a73e77a 100644
--- a/arch/ia64/include/asm/paravirt.h
+++ b/arch/ia64/include/asm/paravirt.h
@@ -225,6 +225,8 @@ struct pv_time_ops {
int (*do_steal_accounting)(unsigned long *new_itm);
 
void (*clocksource_resume)(void);
+
+   unsigned long long (*sched_clock)(void);
 };
 
 extern struct pv_time_ops pv_time_ops;
@@ -242,6 +244,11 @@ paravirt_do_steal_accounting(unsigned long *new_itm)
return pv_time_ops.do_steal_accounting(new_itm);
 }
 
+static inline unsigned long long paravirt_sched_clock(void)
+{
+   return pv_time_ops.sched_clock();
+}
+
 #endif /* !__ASSEMBLY__ */
 
 #else
diff --git a/arch/ia64/include/asm/timex.h b/arch/ia64/include/asm/timex.h
index 4e03cfe..86c7db8 100644
--- a/arch/ia64/include/asm/timex.h
+++ b/arch/ia64/include/asm/timex.h
@@ -40,5 +40,6 @@ get_cycles (void)
 }
 
 extern void ia64_cpu_local_tick (void);
+extern unsigned long long ia64_native_sched_clock (void);
 
 #endif /* _ASM_IA64_TIMEX_H */
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 66e491d..ca1336a 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -1050,7 +1050,7 @@ END(ia64_delay_loop)
  * except that the multiplication and the shift are done with 128-bit
  * intermediate precision so that we can produce a full 64-bit result.
  */
-GLOBAL_ENTRY(sched_clock)
+GLOBAL_ENTRY(ia64_native_sched_clock)
addl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0
mov.m r9=ar.itc // fetch cycle-counter  
(35 cyc)
;;
@@ -1066,7 +1066,7 @@ GLOBAL_ENTRY(sched_clock)
;;
shrp r8=r9,r8,IA64_NSEC_PER_CYC_SHIFT
br.ret.sptk.many rp
-END(sched_clock)
+END(ia64_native_sched_clock)
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
 GLOBAL_ENTRY(cycle_to_cputime)
diff --git a/arch/ia64/kernel/paravirt.c b/arch/ia64/kernel/paravirt.c
index de35d8e..6ebbcc1 100644
--- a/arch/ia64/kernel/paravirt.c
+++ b/arch/ia64/kernel/paravirt.c
@@ -366,4 +366,5 @@ ia64_native_do_steal_accounting(unsigned long *new_itm)
 
 struct pv_time_ops pv_time_ops = {
.do_steal_accounting = ia64_native_do_steal_accounting,
+   .sched_clock = ia64_native_sched_clock,
 };
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 65c10a4..6f6ca42 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -50,6 +50,18 @@ EXPORT_SYMBOL(last_cli_ip);
 #endif
 
 #ifdef CONFIG_PARAVIRT
+/* We need to define a real function for sched_clock, to override the
+   weak default version */
+unsigned long long sched_clock(void)
+{
+return paravirt_sched_clock();
+}
+#else
+unsigned long long
+sched_clock(void) __attribute__((alias(ia64_native_sched_clock)));
+#endif
+
+#ifdef CONFIG_PARAVIRT
 static void
 paravirt_clocksource_resume(void)
 {
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 10/13] ia64/pv_ops/xen: define xen specific gate page.

2008-10-19 Thread Isaku Yamahata
define xen specific gate page.
At this phase bits in the gate page is same to native.
At the next phase, it will be paravirtualized.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/xen/patchlist.h |   38 +
 arch/ia64/kernel/vmlinux.lds.S|6 +
 arch/ia64/xen/Makefile|   16 +-
 arch/ia64/xen/gate-data.S |3 ++
 arch/ia64/xen/xen_pv_ops.c|   32 +++
 5 files changed, 94 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/include/asm/xen/patchlist.h
 create mode 100644 arch/ia64/xen/gate-data.S

diff --git a/arch/ia64/include/asm/xen/patchlist.h 
b/arch/ia64/include/asm/xen/patchlist.h
new file mode 100644
index 000..eae944e
--- /dev/null
+++ b/arch/ia64/include/asm/xen/patchlist.h
@@ -0,0 +1,38 @@
+/**
+ * arch/ia64/include/asm/xen/patchlist.h
+ *
+ * Copyright (c) 2008 Isaku Yamahata yamahata at valinux co jp
+ *VA Linux Systems Japan K.K.
+ *
+ * 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
+ *
+ */
+
+#define __paravirt_start_gate_fsyscall_patchlist   \
+   __xen_start_gate_fsyscall_patchlist
+#define __paravirt_end_gate_fsyscall_patchlist \
+   __xen_end_gate_fsyscall_patchlist
+#define __paravirt_start_gate_brl_fsys_bubble_down_patchlist   \
+   __xen_start_gate_brl_fsys_bubble_down_patchlist
+#define __paravirt_end_gate_brl_fsys_bubble_down_patchlist \
+   __xen_end_gate_brl_fsys_bubble_down_patchlist
+#define __paravirt_start_gate_vtop_patchlist   \
+   __xen_start_gate_vtop_patchlist
+#define __paravirt_end_gate_vtop_patchlist \
+   __xen_end_gate_vtop_patchlist
+#define __paravirt_start_gate_mckinley_e9_patchlist\
+   __xen_start_gate_mckinley_e9_patchlist
+#define __paravirt_end_gate_mckinley_e9_patchlist  \
+   __xen_end_gate_mckinley_e9_patchlist
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 10a7d47..92ae7e8 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -201,6 +201,12 @@ SECTIONS
  __start_gate_section = .;
  *(.data.gate)
  __stop_gate_section = .;
+#ifdef CONFIG_XEN
+ . = ALIGN(PAGE_SIZE);
+ __xen_start_gate_section = .;
+ *(.data.gate.xen)
+ __xen_stop_gate_section = .;
+#endif
}
   . = ALIGN(PAGE_SIZE);/* make sure the gate page doesn't 
expose
 * kernel data
diff --git a/arch/ia64/xen/Makefile b/arch/ia64/xen/Makefile
index b4ca2e6..94f0d8e 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
@@ -3,10 +3,24 @@
 #
 
 obj-y := hypercall.o xenivt.o xensetup.o xen_pv_ops.o irq_xen.o \
-hypervisor.o xencomm.o xcom_hcall.o grant-table.o time.o suspend.o
+hypervisor.o xencomm.o xcom_hcall.o grant-table.o time.o suspend.o \
+gate-data.o
 
 obj-$(CONFIG_IA64_GENERIC) += machvec.o
 
+# The gate DSO image is built using a special linker script.
+include $(srctree)/arch/ia64/kernel/Makefile.gate
+
+# tell compiled for xen
+CPPFLAGS_gate.lds += -D__IA64_GATE_PARAVIRTUALIZED_XEN
+
+# use same file of native.
+$(obj)/gate.o: $(src)/../kernel/gate.S FORCE
+   $(call if_changed_dep,as_o_S)
+$(obj)/gate.lds: $(src)/../kernel/gate.lds.S FORCE
+   $(call if_changed_dep,cpp_lds_S)
+
+
 AFLAGS_xenivt.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN
 
 # xen multi compile
diff --git a/arch/ia64/xen/gate-data.S b/arch/ia64/xen/gate-data.S
new file mode 100644
index 000..7d4830a
--- /dev/null
+++ b/arch/ia64/xen/gate-data.S
@@ -0,0 +1,3 @@
+   .section .data.gate.xen, aw
+
+   .incbin arch/ia64/xen/gate.so
diff --git a/arch/ia64/xen/xen_pv_ops.c b/arch/ia64/xen/xen_pv_ops.c
index 2515d8f..f53b48c 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
@@ -179,6 +179,37 @@ struct pv_fsys_data xen_fsys_data __initdata = {
 };
 
 /***
+ * pv_patchdata
+ * patchdata addresses
+ */
+
+#define DECLARE(name)  \
+   

[Xen-ia64-devel] [PATCH 13/13] ia64/pv_ops/xen/gate.S: xen gate page paravirtualization

2008-10-19 Thread Isaku Yamahata
xen gate page paravirtualization

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/xen/inst.h |4 
 arch/ia64/xen/Makefile   |1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/include/asm/xen/inst.h b/arch/ia64/include/asm/xen/inst.h
index 90537dc..c53a476 100644
--- a/arch/ia64/include/asm/xen/inst.h
+++ b/arch/ia64/include/asm/xen/inst.h
@@ -386,6 +386,10 @@
 #define RSM_PSR_DT \
XEN_HYPER_RSM_PSR_DT
 
+#define RSM_PSR_BE_I(clob0, clob1) \
+   RSM_PSR_I(p0, clob0, clob1);\
+   rum psr.be
+
 #define SSM_PSR_DT_AND_SRLZ_I  \
XEN_HYPER_SSM_PSR_DT
 
diff --git a/arch/ia64/xen/Makefile b/arch/ia64/xen/Makefile
index 94f0d8e..e6f4a0a 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
@@ -13,6 +13,7 @@ include $(srctree)/arch/ia64/kernel/Makefile.gate
 
 # tell compiled for xen
 CPPFLAGS_gate.lds += -D__IA64_GATE_PARAVIRTUALIZED_XEN
+AFLAGS_gate.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN 
-D__IA64_GATE_PARAVIRTUALIZED_XEN
 
 # use same file of native.
 $(obj)/gate.o: $(src)/../kernel/gate.S FORCE
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 12/13] ia64/pv_ops: paravirtualize gate.S.

2008-10-19 Thread Isaku Yamahata
paravirtualize gate.S.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/native/inst.h   |5 +
 arch/ia64/include/asm/native/pvchk_inst.h |3 +++
 arch/ia64/kernel/gate.S   |   17 +
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/include/asm/native/inst.h 
b/arch/ia64/include/asm/native/inst.h
index ad59fc6..d2d46ef 100644
--- a/arch/ia64/include/asm/native/inst.h
+++ b/arch/ia64/include/asm/native/inst.h
@@ -166,6 +166,11 @@
 #define RSM_PSR_DT \
rsm psr.dt
 
+#define RSM_PSR_BE_I(clob0, clob1) \
+   rsm psr.be | psr.i  \
+   CLOBBER(clob0)  \
+   CLOBBER(clob1)
+
 #define SSM_PSR_DT_AND_SRLZ_I  \
ssm psr.dt  \
;;  \
diff --git a/arch/ia64/include/asm/native/pvchk_inst.h 
b/arch/ia64/include/asm/native/pvchk_inst.h
index 13b289e..8d72962 100644
--- a/arch/ia64/include/asm/native/pvchk_inst.h
+++ b/arch/ia64/include/asm/native/pvchk_inst.h
@@ -251,6 +251,9 @@
IS_RREG_CLOB(clob2)
 #define RSM_PSR_DT \
nop 0
+#define RSM_PSR_BE_I(clob0, clob1) \
+   IS_RREG_CLOB(clob0) \
+   IS_RREG_CLOB(clob1)
 #define SSM_PSR_DT_AND_SRLZ_I  \
nop 0
 #define BSW_0(clob0, clob1, clob2) \
diff --git a/arch/ia64/kernel/gate.S b/arch/ia64/kernel/gate.S
index c957228..cf5e0a1 100644
--- a/arch/ia64/kernel/gate.S
+++ b/arch/ia64/kernel/gate.S
@@ -13,6 +13,7 @@
 #include asm/sigcontext.h
 #include asm/system.h
 #include asm/unistd.h
+#include paravirt_inst.h
 
 /*
  * We can't easily refer to symbols inside the kernel.  To avoid full runtime 
relocation,
@@ -323,7 +324,7 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
epc // Bcauses split-issue
 }
;;
-   rsm psr.be | psr.i  // M2 (5 cyc to srlz.d)
+   RSM_PSR_BE_I(r20, r22)  // M2 (5 cyc to srlz.d)
LOAD_FSYSCALL_TABLE(r14)// X
;;
mov r16=IA64_KR(CURRENT)// M2 (12 cyc)
@@ -331,7 +332,7 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
mov r19=NR_syscalls-1   // A
;;
lfetch [r18]// M0|1
-   mov r29=psr // M2 (12 cyc)
+   MOV_FROM_PSR(p0, r29, r8)   // M2 (12 cyc)
// If r17 is a NaT, p6 will be zero
cmp.geu p6,p7=r19,r17   // A(sysnr  0  sysnr  
1024+NR_syscalls)?
;;
@@ -347,7 +348,7 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
 (p6)   tbit.z.unc p8,p0=r18,0  // I0 (dual-issues with mov 
b7=r18!)
nop.i 0
;;
-(p8)   ssm psr.i
+   SSM_PSR_I(p8, p14, r25)
 (p6)   mov b7=r18  // I0
 (p8)   br.dptk.many b7 // B
 
@@ -368,9 +369,17 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
 #else
BRL_COND_FSYS_BUBBLE_DOWN(p6)
 #endif
-   ssm psr.i
+   SSM_PSR_I(p0, p14, r10)
mov r10=-1
 (p10)  mov r8=EINVAL
 (p9)   mov r8=ENOSYS
FSYS_RETURN
+
+#ifdef CONFIG_PARAVIRT
+   /*
+* padd to make the size of this symbol constant
+* independent of paravirtualization.
+*/
+   .align PAGE_SIZE / 8
+#endif
 END(__kernel_syscall_via_epc)
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 11/13] ia64/pv_ops: move down __kernel_syscall_via_epc.

2008-10-19 Thread Isaku Yamahata
Move down __kernel_syscall_via_epc to the end of the page.
We want to paravirtualize only __kernel_syscall_via_epc because
it includes privileged instructions. Its paravirtualization increases
its symbols size.

On the other hand, each paravirtualized gate must have e symbols of
same value and size to native's because the page is mapped to GATE_ADDR
and GATE_ADDR + PERCPU_PAGE_SIZE and vmlinux is linked to those symbols.
Later to have the same symbol size, we pads NOPs at the end of
__kernel_syscall_via_epc. Move it after other functions to keep
symbols of other functions have same values and sizes.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/kernel/gate.S |  162 +++---
 1 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/arch/ia64/kernel/gate.S b/arch/ia64/kernel/gate.S
index 74b1ccc..c957228 100644
--- a/arch/ia64/kernel/gate.S
+++ b/arch/ia64/kernel/gate.S
@@ -48,87 +48,6 @@ GLOBAL_ENTRY(__kernel_syscall_via_break)
 }
 END(__kernel_syscall_via_break)
 
-/*
- * On entry:
- * r11 = saved ar.pfs
- * r15 = system call #
- * b0  = saved return address
- * b6  = return address
- * On exit:
- * r11 = saved ar.pfs
- * r15 = system call #
- * b0  = saved return address
- * all other scratch registers:  undefined
- * all preserved registers:  same as on entry
- */
-
-GLOBAL_ENTRY(__kernel_syscall_via_epc)
-   .prologue
-   .altrp b6
-   .body
-{
-   /*
-* Note: the kernel cannot assume that the first two instructions in 
this
-* bundle get executed.  The remaining code must be safe even if
-* they do not get executed.
-*/
-   adds r17=-1024,r15  // A
-   mov r10=0   // Adefault to successful 
syscall execution
-   epc // Bcauses split-issue
-}
-   ;;
-   rsm psr.be | psr.i  // M2 (5 cyc to srlz.d)
-   LOAD_FSYSCALL_TABLE(r14)// X
-   ;;
-   mov r16=IA64_KR(CURRENT)// M2 (12 cyc)
-   shladd r18=r17,3,r14// A
-   mov r19=NR_syscalls-1   // A
-   ;;
-   lfetch [r18]// M0|1
-   mov r29=psr // M2 (12 cyc)
-   // If r17 is a NaT, p6 will be zero
-   cmp.geu p6,p7=r19,r17   // A(sysnr  0  sysnr  
1024+NR_syscalls)?
-   ;;
-   mov r21=ar.fpsr // M2 (12 cyc)
-   tnat.nz p10,p9=r15  // I0
-   mov.i r26=ar.pfs// I0 (would stall anyhow due 
to srlz.d...)
-   ;;
-   srlz.d  // M0 (forces split-issue) 
ensure PSR.BE==0
-(p6)   ld8 r18=[r18]   // M0|1
-   nop.i 0
-   ;;
-   nop.m 0
-(p6)   tbit.z.unc p8,p0=r18,0  // I0 (dual-issues with mov 
b7=r18!)
-   nop.i 0
-   ;;
-(p8)   ssm psr.i
-(p6)   mov b7=r18  // I0
-(p8)   br.dptk.many b7 // B
-
-   mov r27=ar.rsc  // M2 (12 cyc)
-/*
- * brl.cond doesn't work as intended because the linker would convert this 
branch
- * into a branch to a PLT.  Perhaps there will be a way to avoid this with some
- * future version of the linker.  In the meantime, we just use an indirect 
branch
- * instead.
- */
-#ifdef CONFIG_ITANIUM
-(p6)   add r14=-8,r14  // r14 - addr of 
fsys_bubble_down entry
-   ;;
-(p6)   ld8 r14=[r14]   // r14 - fsys_bubble_down
-   ;;
-(p6)   mov b7=r14
-(p6)   br.sptk.many b7
-#else
-   BRL_COND_FSYS_BUBBLE_DOWN(p6)
-#endif
-   ssm psr.i
-   mov r10=-1
-(p10)  mov r8=EINVAL
-(p9)   mov r8=ENOSYS
-   FSYS_RETURN
-END(__kernel_syscall_via_epc)
-
 #  define ARG0_OFF (16 + IA64_SIGFRAME_ARG0_OFFSET)
 #  define ARG1_OFF (16 + IA64_SIGFRAME_ARG1_OFFSET)
 #  define ARG2_OFF (16 + IA64_SIGFRAME_ARG2_OFFSET)
@@ -374,3 +293,84 @@ restore_rbs:
// invala not necessary as that will happen when returning to user-mode
br.cond.sptk back_from_restore_rbs
 END(__kernel_sigtramp)
+
+/*
+ * On entry:
+ * r11 = saved ar.pfs
+ * r15 = system call #
+ * b0  = saved return address
+ * b6  = return address
+ * On exit:
+ * r11 = saved ar.pfs
+ * r15 = system call #
+ * b0  = saved return address
+ * all other scratch registers:  undefined
+ * all preserved registers:  same as on entry
+ */
+
+GLOBAL_ENTRY(__kernel_syscall_via_epc)
+   .prologue
+   .altrp b6
+   .body
+{
+   /*
+* Note: the kernel cannot assume that the first two instructions in 
this
+* bundle get executed.  The remaining code must be safe even if
+* they do not get executed.
+*/
+   

[Xen-ia64-devel] [PATCH 04/13] ia64/pv_ops/pvchecker: support mov = ar.itc paravirtualization

2008-10-19 Thread Isaku Yamahata
add suport for mov = ar.itc to pvchecker.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/native/pvchk_inst.h |5 +
 arch/ia64/scripts/pvcheck.sed |1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/include/asm/native/pvchk_inst.h 
b/arch/ia64/include/asm/native/pvchk_inst.h
index b8e6eb1..13b289e 100644
--- a/arch/ia64/include/asm/native/pvchk_inst.h
+++ b/arch/ia64/include/asm/native/pvchk_inst.h
@@ -180,6 +180,11 @@
IS_PRED_IN(pred)\
IS_RREG_OUT(reg)\
IS_RREG_CLOB(clob)
+#define MOV_FROM_ITC(pred, pred_clob, reg, clob)   \
+   IS_PRED_IN(pred)\
+   IS_PRED_CLOB(pred_clob) \
+   IS_RREG_OUT(reg)\
+   IS_RREG_CLOB(clob)
 #define MOV_TO_IFA(reg, clob)  \
IS_RREG_IN(reg) \
IS_RREG_CLOB(clob)
diff --git a/arch/ia64/scripts/pvcheck.sed b/arch/ia64/scripts/pvcheck.sed
index ba66ac2..e59809a 100644
--- a/arch/ia64/scripts/pvcheck.sed
+++ b/arch/ia64/scripts/pvcheck.sed
@@ -17,6 +17,7 @@ s/mov.*=.*cr\.iip/.warning \cr.iip should not used 
directly\/g
 s/mov.*=.*cr\.ivr/.warning \cr.ivr should not used directly\/g
 s/mov.*=[^\.]*psr/.warning \psr should not used directly\/g  # avoid ar.fpsr
 s/mov.*=.*ar\.eflags/.warning \ar.eflags should not used directly\/g
+s/mov.*=.*ar\.itc.*/.warning \ar.itc should not used directly\/g
 s/mov.*cr\.ifa.*=.*/.warning \cr.ifa should not used directly\/g
 s/mov.*cr\.itir.*=.*/.warning \cr.itir should not used directly\/g
 s/mov.*cr\.iha.*=.*/.warning \cr.iha should not used directly\/g
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 03/13] ia64/pv_ops: paravirtualize fsys.S.

2008-10-19 Thread Isaku Yamahata
paravirtualize fsys.S.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/kernel/fsys.S |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
index 788319f..3544d75 100644
--- a/arch/ia64/kernel/fsys.S
+++ b/arch/ia64/kernel/fsys.S
@@ -419,7 +419,7 @@ EX(.fail_efault, ld8 r14=[r33]) // r14 
- *set
mov r17=(1  (SIGKILL - 1)) | (1  (SIGSTOP - 1))
;;
 
-   rsm psr.i   // mask interrupt delivery
+   RSM_PSR_I(p0, r18, r19) // mask interrupt delivery
mov ar.ccv=0
andcm r14=r14,r17   // filter out SIGKILL  SIGSTOP
 
@@ -492,7 +492,7 @@ EX(.fail_efault, ld8 r14=[r33]) // r14 
- *set
 #ifdef CONFIG_SMP
st4.rel [r31]=r0// release the lock
 #endif
-   ssm psr.i
+   SSM_PSR_I(p0, p9, r31)
;;
 
srlz.d  // ensure psr.i is set again
@@ -514,7 +514,7 @@ EX(.fail_efault, (p15) st8 [r34]=r3)
 #ifdef CONFIG_SMP
st4.rel [r31]=r0// release the lock
 #endif
-   ssm psr.i
+   SSM_PSR_I(p0, p9, r17)
;;
srlz.d
br.sptk.many fsys_fallback_syscall  // with signal pending, do the 
heavy-weight syscall
@@ -522,7 +522,7 @@ EX(.fail_efault, (p15) st8 [r34]=r3)
 #ifdef CONFIG_SMP
 .lock_contention:
/* Rather than spinning here, fall back on doing a heavy-weight 
syscall.  */
-   ssm psr.i
+   SSM_PSR_I(p0, p9, r17)
;;
srlz.d
br.sptk.many fsys_fallback_syscall
@@ -593,11 +593,11 @@ ENTRY(fsys_fallback_syscall)
adds r17=-1024,r15
movl r14=sys_call_table
;;
-   rsm psr.i
+   RSM_PSR_I(p0, r26, r27)
shladd r18=r17,3,r14
;;
ld8 r18=[r18]   // load normal (heavy-weight) 
syscall entry-point
-   mov r29=psr // read psr (12 cyc load 
latency)
+   MOV_FROM_PSR(p0, r29, r26)  // read psr (12 cyc load 
latency)
mov r27=ar.rsc
mov r21=ar.fpsr
mov r26=ar.pfs
@@ -735,7 +735,7 @@ GLOBAL_ENTRY(paravirt_fsys_bubble_down)
mov rp=r14  // I0   set the real return addr
and r3=_TIF_SYSCALL_TRACEAUDIT,r3   // A
;;
-   ssm psr.i   // M2   we're on kernel stacks 
now, reenable irqs
+   SSM_PSR_I(p0, p6, r22)  // M2   we're on kernel stacks 
now, reenable irqs
cmp.eq p8,p0=r3,r0  // A
 (p10)  br.cond.spnt.many ia64_ret_from_syscall // Breturn if bad 
call-frame or r15 is a NaT
 
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 00/13] ia64/pv_ops, xen: more paravirtualization.

2008-10-19 Thread Isaku Yamahata

This patchset is for more paravirtualization on ia64/pv_ops.
- paravirtualize fsys call (fsys.S) by multi compile
- paravirtualize gate page (gate.S) by multi compile
- support save/restore
  For this purpose, the followings needs to be paravirtualized
  - ar.itc instruction 
  - sched_clock()
  This is because timer may changed before/after saving/restoring.

For convenience the working full source is available from
http://people.valinux.co.jp/~yamahata/xen-ia64/for_eagl/linux-2.6-ia64-pv-ops.git/
branch: ia64-pv-ops-2008oct20-xen-ia64-optimized-domu

For the status of this patch series
http://wiki.xensource.com/xenwiki/XenIA64/UpstreamMerge

thanks,

Diffstat:
 arch/ia64/include/asm/native/inst.h   |   13 ++
 arch/ia64/include/asm/native/patchlist.h  |   38 ++
 arch/ia64/include/asm/native/pvchk_inst.h |8 +
 arch/ia64/include/asm/paravirt.h  |   57 +
 arch/ia64/include/asm/timex.h |1 
 arch/ia64/include/asm/xen/inst.h  |   28 
 arch/ia64/include/asm/xen/interface.h |9 +
 arch/ia64/include/asm/xen/minstate.h  |   11 +
 arch/ia64/include/asm/xen/patchlist.h |   38 ++
 arch/ia64/include/asm/xen/privop.h|2 
 arch/ia64/kernel/Makefile |   36 +-
 arch/ia64/kernel/Makefile.gate|   27 
 arch/ia64/kernel/asm-offsets.c|2 
 arch/ia64/kernel/entry.S  |4 
 arch/ia64/kernel/fsys.S   |   35 +++--
 arch/ia64/kernel/gate.S   |  179 +++---
 arch/ia64/kernel/gate.lds.S   |   17 +-
 arch/ia64/kernel/head.S   |4 
 arch/ia64/kernel/ivt.S|2 
 arch/ia64/kernel/paravirt.c   |1 
 arch/ia64/kernel/paravirt_patchlist.c |   78 +
 arch/ia64/kernel/paravirt_patchlist.h |   28 
 arch/ia64/kernel/patch.c  |   38 --
 arch/ia64/kernel/time.c   |   12 ++
 arch/ia64/kernel/vmlinux.lds.S|6 +
 arch/ia64/mm/init.c   |8 -
 arch/ia64/scripts/pvcheck.sed |1 
 arch/ia64/xen/Kconfig |1 
 arch/ia64/xen/Makefile|   19 ++-
 arch/ia64/xen/gate-data.S |3 
 arch/ia64/xen/time.c  |   48 
 arch/ia64/xen/xen_pv_ops.c|  126 -
 32 files changed, 720 insertions(+), 160 deletions(-)

___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 09/13] ia64/pv_ops: gate page paravirtualization.

2008-10-19 Thread Isaku Yamahata
paravirtualize gate page by allowing each pv_ops instances
to define its own gate page.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/native/patchlist.h |   38 ++
 arch/ia64/include/asm/paravirt.h |   35 +
 arch/ia64/kernel/Makefile|   32 ++--
 arch/ia64/kernel/Makefile.gate   |   27 ++
 arch/ia64/kernel/gate.lds.S  |   17 ---
 arch/ia64/kernel/paravirt_patchlist.c|   78 ++
 arch/ia64/kernel/paravirt_patchlist.h|   28 +++
 arch/ia64/kernel/patch.c |   12 ++--
 arch/ia64/mm/init.c  |6 ++-
 9 files changed, 230 insertions(+), 43 deletions(-)
 create mode 100644 arch/ia64/include/asm/native/patchlist.h
 create mode 100644 arch/ia64/kernel/Makefile.gate
 create mode 100644 arch/ia64/kernel/paravirt_patchlist.c
 create mode 100644 arch/ia64/kernel/paravirt_patchlist.h

diff --git a/arch/ia64/include/asm/native/patchlist.h 
b/arch/ia64/include/asm/native/patchlist.h
new file mode 100644
index 000..be16ca9
--- /dev/null
+++ b/arch/ia64/include/asm/native/patchlist.h
@@ -0,0 +1,38 @@
+/**
+ * arch/ia64/include/asm/native/inst.h
+ *
+ * Copyright (c) 2008 Isaku Yamahata yamahata at valinux co jp
+ *VA Linux Systems Japan K.K.
+ *
+ * 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
+ *
+ */
+
+#define __paravirt_start_gate_fsyscall_patchlist   \
+   __ia64_native_start_gate_fsyscall_patchlist
+#define __paravirt_end_gate_fsyscall_patchlist \
+   __ia64_native_end_gate_fsyscall_patchlist
+#define __paravirt_start_gate_brl_fsys_bubble_down_patchlist   \
+   __ia64_native_start_gate_brl_fsys_bubble_down_patchlist
+#define __paravirt_end_gate_brl_fsys_bubble_down_patchlist \
+   __ia64_native_end_gate_brl_fsys_bubble_down_patchlist
+#define __paravirt_start_gate_vtop_patchlist   \
+   __ia64_native_start_gate_vtop_patchlist
+#define __paravirt_end_gate_vtop_patchlist \
+   __ia64_native_end_gate_vtop_patchlist
+#define __paravirt_start_gate_mckinley_e9_patchlist\
+   __ia64_native_start_gate_mckinley_e9_patchlist
+#define __paravirt_end_gate_mckinley_e9_patchlist  \
+   __ia64_native_end_gate_mckinley_e9_patchlist
diff --git a/arch/ia64/include/asm/paravirt.h b/arch/ia64/include/asm/paravirt.h
index a73e77a..fc433f6 100644
--- a/arch/ia64/include/asm/paravirt.h
+++ b/arch/ia64/include/asm/paravirt.h
@@ -35,6 +35,41 @@ extern struct pv_fsys_data pv_fsys_data;
 
 unsigned long *paravirt_get_fsyscall_table(void);
 char *paravirt_get_fsys_bubble_down(void);
+
+/**
+ * patchlist addresses for gate page
+ */
+enum pv_gate_patchlist {
+   PV_GATE_START_FSYSCALL,
+   PV_GATE_END_FSYSCALL,
+
+   PV_GATE_START_BRL_FSYS_BUBBLE_DOWN,
+   PV_GATE_END_BRL_FSYS_BUBBLE_DOWN,
+
+   PV_GATE_START_VTOP,
+   PV_GATE_END_VTOP,
+
+   PV_GATE_START_MCKINLEY_E9,
+   PV_GATE_END_MCKINLEY_E9,
+};
+
+struct pv_patchdata {
+   unsigned long start_fsyscall_patchlist;
+   unsigned long end_fsyscall_patchlist;
+   unsigned long start_brl_fsys_bubble_down_patchlist;
+   unsigned long end_brl_fsys_bubble_down_patchlist;
+   unsigned long start_vtop_patchlist;
+   unsigned long end_vtop_patchlist;
+   unsigned long start_mckinley_e9_patchlist;
+   unsigned long end_mckinley_e9_patchlist;
+
+   void *gate_section;
+};
+
+extern struct pv_patchdata pv_patchdata;
+
+unsigned long paravirt_get_gate_patchlist(enum pv_gate_patchlist type);
+void *paravirt_get_gate_section(void);
 #endif
 
 #ifdef CONFIG_PARAVIRT_GUEST
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index 1ab150e..8dc9df8 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -5,7 +5,7 @@
 extra-y:= head.o init_task.o vmlinux.lds
 
 obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o 
irq_ia64.o  \
-irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o 
ptrace.o sal.o  \
+ 

[Xen-ia64-devel] [PATCH 02/13] ia64/pv_ops/xen: preliminary to paravirtualizing fsys.S for xen.

2008-10-19 Thread Isaku Yamahata
This is a preliminary patch to paravirtualizing fsys.S.
compile fsys.S twice one for native and one for xen, and switch
them at run tine.
Later fsys.S will be paravirtualized.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/xen/inst.h |3 +++
 arch/ia64/xen/Makefile   |2 +-
 arch/ia64/xen/xen_pv_ops.c   |   14 ++
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/ia64/include/asm/xen/inst.h b/arch/ia64/include/asm/xen/inst.h
index 19c2ae1..e8e01b2 100644
--- a/arch/ia64/include/asm/xen/inst.h
+++ b/arch/ia64/include/asm/xen/inst.h
@@ -33,6 +33,9 @@
 #define __paravirt_work_processed_syscall_target \
xen_work_processed_syscall
 
+#define paravirt_fsyscall_tablexen_fsyscall_table
+#define paravirt_fsys_bubble_down  xen_fsys_bubble_down
+
 #define MOV_FROM_IFA(reg)  \
movl reg = XSI_IFA; \
;;  \
diff --git a/arch/ia64/xen/Makefile b/arch/ia64/xen/Makefile
index 0ad0224..b4ca2e6 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_IA64_GENERIC) += machvec.o
 AFLAGS_xenivt.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN
 
 # xen multi compile
-ASM_PARAVIRT_MULTI_COMPILE_SRCS = ivt.S entry.S
+ASM_PARAVIRT_MULTI_COMPILE_SRCS = ivt.S entry.S fsys.S
 ASM_PARAVIRT_OBJS = $(addprefix xen-,$(ASM_PARAVIRT_MULTI_COMPILE_SRCS:.S=.o))
 obj-y += $(ASM_PARAVIRT_OBJS)
 define paravirtualized_xen
diff --git a/arch/ia64/xen/xen_pv_ops.c b/arch/ia64/xen/xen_pv_ops.c
index 04cd123..17eed4f 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
@@ -24,6 +24,7 @@
 #include linux/irq.h
 #include linux/kernel.h
 #include linux/pm.h
+#include linux/unistd.h
 
 #include asm/xen/hypervisor.h
 #include asm/xen/xencomm.h
@@ -166,6 +167,18 @@ static const struct pv_init_ops xen_init_ops __initdata = {
 };
 
 /***
+ * pv_fsys_data
+ * addresses for fsys
+ */
+
+extern unsigned long xen_fsyscall_table[NR_syscalls];
+extern char xen_fsys_bubble_down[];
+struct pv_fsys_data xen_fsys_data __initdata = {
+   .fsyscall_table = (unsigned long *)xen_fsyscall_table,
+   .fsys_bubble_down = (void *)xen_fsys_bubble_down,
+};
+
+/***
  * pv_cpu_ops
  * intrinsics hooks.
  */
@@ -355,6 +368,7 @@ xen_setup_pv_ops(void)
xen_info_init();
pv_info = xen_info;
pv_init_ops = xen_init_ops;
+   pv_fsys_data = xen_fsys_data;
pv_cpu_ops = xen_cpu_ops;
pv_iosapic_ops = xen_iosapic_ops;
pv_irq_ops = xen_irq_ops;
-- 
1.6.0.2


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH 01/13] ia64/pv_ops: add hooks to paravirtualize fsyscall implementation.

2008-10-19 Thread Isaku Yamahata
Add two hooks, paravirt_get_fsyscall_table() and
paravirt_get_fsys_bubble_doen() to paravirtualize fsyscall implementation.
This patch just add the hooks fsyscall and don't paravirtualize it.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/native/inst.h |3 +++
 arch/ia64/include/asm/paravirt.h|   15 +++
 arch/ia64/kernel/Makefile   |4 ++--
 arch/ia64/kernel/fsys.S |   17 +
 arch/ia64/kernel/patch.c|   26 +++---
 arch/ia64/mm/init.c |2 +-
 6 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/arch/ia64/include/asm/native/inst.h 
b/arch/ia64/include/asm/native/inst.h
index 0a1026c..5e4e151 100644
--- a/arch/ia64/include/asm/native/inst.h
+++ b/arch/ia64/include/asm/native/inst.h
@@ -30,6 +30,9 @@
 #define __paravirt_work_processed_syscall_target \
ia64_work_processed_syscall
 
+#define paravirt_fsyscall_table
ia64_native_fsyscall_table
+#define paravirt_fsys_bubble_down  ia64_native_fsys_bubble_down
+
 #ifdef CONFIG_PARAVIRT_GUEST_ASM_CLOBBER_CHECK
 # define PARAVIRT_POISON   0xdeadbeefbaadf00d
 # define CLOBBER(clob) \
diff --git a/arch/ia64/include/asm/paravirt.h b/arch/ia64/include/asm/paravirt.h
index 2bf3636..56f69f9 100644
--- a/arch/ia64/include/asm/paravirt.h
+++ b/arch/ia64/include/asm/paravirt.h
@@ -22,6 +22,21 @@
 #ifndef __ASM_PARAVIRT_H
 #define __ASM_PARAVIRT_H
 
+#ifndef __ASSEMBLY__
+/**
+ * fsys related addresses
+ */
+struct pv_fsys_data {
+   unsigned long *fsyscall_table;
+   void *fsys_bubble_down;
+};
+
+extern struct pv_fsys_data pv_fsys_data;
+
+unsigned long *paravirt_get_fsyscall_table(void);
+char *paravirt_get_fsys_bubble_down(void);
+#endif
+
 #ifdef CONFIG_PARAVIRT_GUEST
 
 #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT   0
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index c381ea9..1ab150e 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -111,9 +111,9 @@ include/asm-ia64/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
 clean-files += $(objtree)/include/asm-ia64/nr-irqs.h
 
 #
-# native ivt.S and entry.S
+# native ivt.S, entry.S and fsys.S
 #
-ASM_PARAVIRT_OBJS = ivt.o entry.o
+ASM_PARAVIRT_OBJS = ivt.o entry.o fsys.o
 define paravirtualized_native
 AFLAGS_$(1) += -D__IA64_ASM_PARAVIRTUALIZED_NATIVE
 AFLAGS_pvchk-sed-$(1) += -D__IA64_ASM_PARAVIRTUALIZED_PVCHECK
diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
index c1625c7..788319f 100644
--- a/arch/ia64/kernel/fsys.S
+++ b/arch/ia64/kernel/fsys.S
@@ -25,6 +25,7 @@
 #include asm/unistd.h
 
 #include entry.h
+#include paravirt_inst.h
 
 /*
  * See Documentation/ia64/fsys.txt for details on fsyscalls.
@@ -602,7 +603,7 @@ ENTRY(fsys_fallback_syscall)
mov r26=ar.pfs
 END(fsys_fallback_syscall)
/* FALL THROUGH */
-GLOBAL_ENTRY(fsys_bubble_down)
+GLOBAL_ENTRY(paravirt_fsys_bubble_down)
.prologue
.altrp b6
.body
@@ -640,7 +641,7 @@ GLOBAL_ENTRY(fsys_bubble_down)
 *
 * PSR.BE : already is turned off in __kernel_syscall_via_epc()
 * PSR.AC : don't care (kernel normally turns PSR.AC on)
-* PSR.I  : already turned off by the time fsys_bubble_down gets
+* PSR.I  : already turned off by the time paravirt_fsys_bubble_down 
gets
 *  invoked
 * PSR.DFL: always 0 (kernel never turns it on)
 * PSR.DFH: don't care --- kernel never touches f32-f127 on its own
@@ -650,7 +651,7 @@ GLOBAL_ENTRY(fsys_bubble_down)
 * PSR.DB : don't care --- kernel never enables kernel-level
 *  breakpoints
 * PSR.TB : must be 0 already; if it wasn't zero on entry to
-*  __kernel_syscall_via_epc, the branch to fsys_bubble_down
+*  __kernel_syscall_via_epc, the branch to 
paravirt_fsys_bubble_down
 *  will trigger a taken branch; the taken-trap-handler then
 *  converts the syscall into a break-based system-call.
 */
@@ -741,14 +742,14 @@ GLOBAL_ENTRY(fsys_bubble_down)
nop.m 0
 (p8)   br.call.sptk.many b6=b6 // B(ignore return address)
br.cond.spnt ia64_trace_syscall // B
-END(fsys_bubble_down)
+END(paravirt_fsys_bubble_down)
 
.rodata
.align 8
-   .globl fsyscall_table
+   .globl paravirt_fsyscall_table
 
-   data8 fsys_bubble_down
-fsyscall_table:
+   data8 paravirt_fsys_bubble_down
+paravirt_fsyscall_table:
data8 fsys_ni_syscall
data8 0 // exit // 1025
data8 0 // read
@@ -1033,4 +1034,4 @@ fsyscall_table:
 
// fill in zeros for the remaining entries
.zero:
-   .space fsyscall_table 

[Xen-ia64-devel] [PATCH 05/13] ia64/pv_ops/xen: paravirtualize read/write ar.itc and ar.itm

2008-10-19 Thread Isaku Yamahata
paravirtualize ar.itc and ar.itm in order to support save/restore.

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]
---
 arch/ia64/include/asm/xen/inst.h  |   21 +
 arch/ia64/include/asm/xen/interface.h |9 
 arch/ia64/include/asm/xen/minstate.h  |   11 -
 arch/ia64/include/asm/xen/privop.h|2 +
 arch/ia64/kernel/asm-offsets.c|2 +
 arch/ia64/xen/xen_pv_ops.c|   80 -
 6 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/include/asm/xen/inst.h b/arch/ia64/include/asm/xen/inst.h
index e8e01b2..90537dc 100644
--- a/arch/ia64/include/asm/xen/inst.h
+++ b/arch/ia64/include/asm/xen/inst.h
@@ -113,6 +113,27 @@
 .endm
 #define MOV_FROM_PSR(pred, reg, clob)  __MOV_FROM_PSR pred, reg, clob
 
+/* assuming ar.itc is read with interrupt disabled. */
+#define MOV_FROM_ITC(pred, pred_clob, reg, clob)   \
+(pred) movl clob = XSI_ITC_OFFSET; \
+   ;;  \
+(pred) ld8 clob = [clob];  \
+(pred) mov reg = ar.itc;   \
+   ;;  \
+(pred) add reg = reg, clob;\
+   ;;  \
+(pred) movl clob = XSI_ITC_LAST;   \
+   ;;  \
+(pred) ld8 clob = [clob];  \
+   ;;  \
+(pred) cmp.geu.unc pred_clob, p0 = clob, reg;  \
+   ;;  \
+(pred_clob)add reg = 1, clob;  \
+   ;;  \
+(pred) movl clob = XSI_ITC_LAST;   \
+   ;;  \
+(pred) st8 [clob] = reg
+
 
 #define MOV_TO_IFA(reg, clob)  \
movl clob = XSI_IFA;\
diff --git a/arch/ia64/include/asm/xen/interface.h 
b/arch/ia64/include/asm/xen/interface.h
index f00fab4..e951e74 100644
--- a/arch/ia64/include/asm/xen/interface.h
+++ b/arch/ia64/include/asm/xen/interface.h
@@ -209,6 +209,15 @@ struct mapped_regs {
unsigned long krs[8];   /* kernel registers */
unsigned long tmp[16];  /* temp registers
   (e.g. for hyperprivops) */
+
+   /* itc paravirtualization
+* vAR.ITC = mAR.ITC + itc_offset
+* itc_last is one which was lastly passed to
+* the guest OS in order to prevent it from
+* going backwords.
+*/
+   unsigned long itc_offset;
+   unsigned long itc_last;
};
};
 };
diff --git a/arch/ia64/include/asm/xen/minstate.h 
b/arch/ia64/include/asm/xen/minstate.h
index 4d92d9b..c57fa91 100644
--- a/arch/ia64/include/asm/xen/minstate.h
+++ b/arch/ia64/include/asm/xen/minstate.h
@@ -1,3 +1,12 @@
+
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+/* read ar.itc in advance, and use it before leaving bank 0 */
+#define XEN_ACCOUNT_GET_STAMP  \
+   MOV_FROM_ITC(pUStk, p6, r20, r2);
+#else
+#define XEN_ACCOUNT_GET_STAMP
+#endif
+
 /*
  * DO_SAVE_MIN switches to the kernel stacks (if necessary) and saves
  * the minimum state necessary that allows us to turn psr.ic back
@@ -123,7 +132,7 @@
;;  
\
 .mem.offset 0,0; st8.spill [r16]=r2,16;
\
 .mem.offset 8,0; st8.spill [r17]=r3,16;
\
-   ACCOUNT_GET_STAMP   
\
+   XEN_ACCOUNT_GET_STAMP   
\
adds r2=IA64_PT_REGS_R16_OFFSET,r1; 
\
;;  
\
EXTRA;  
\
diff --git a/arch/ia64/include/asm/xen/privop.h 
b/arch/ia64/include/asm/xen/privop.h
index 71ec754..2261dda 100644
--- a/arch/ia64/include/asm/xen/privop.h
+++ b/arch/ia64/include/asm/xen/privop.h
@@ -55,6 +55,8 @@
 #define XSI_BANK1_R16  (XSI_BASE + XSI_BANK1_R16_OFS)
 #define XSI_BANKNUM(XSI_BASE + XSI_BANKNUM_OFS)
 #define XSI_IHA(XSI_BASE + XSI_IHA_OFS)
+#define XSI_ITC_OFFSET (XSI_BASE + XSI_ITC_OFFSET_OFS)
+#define 

Re: [Xen-ia64-devel][PATCH][VTD]change ioports_permit_access interface

2008-10-19 Thread Isaku Yamahata
On Fri, Oct 17, 2008 at 05:36:58PM +0800, Xu, Anthony wrote:
 Isaku Yamahata wrote:
  On Fri, Oct 17, 2008 at 05:58:45PM +0900, Isaku Yamahata wrote:
  On Fri, Oct 17, 2008 at 04:45:09PM +0800, Xu, Anthony wrote:
  Hi isaku,
 
  If I remembered correctly, last time I encountered issue at line
  page = mfn_to_page(mfn); Page returns 0.
 
  Which line do you have trouble?
  Do you mean that mfn_to_page(mfn) returned NULL?
  or
  Did you hit BUG_ON(page_get_owner(page) == NULL)?
 
 
 
 
  I suspect if page_info for IOPORTs is initialized.
  Any idea?
 
  Ah, I think they are initialized, but they are free.
  i.e. page refcount = 0, page owner = NULL.
  So you may need to make them owned by DOMID_IO somewhere of the
  initialization.
  i.e. page refcount = 1, page owner = DOMID_IO
 
 I suspect it,
 Because xen doesn't know all MMIO information, xen just initiates page_info 
 through efi memory description/
 Efi memory description doesn't provide MMIO information execpt PORT IO 
 information.

It's correct that xen VMM doesn't fully understand io area.
However the VMM know all about RAM.

So far !mfn_valid() has sufficed for the current implementation
in order to detect IO area.
However you are going to into the case which needs more precise
detection. But what we want is the way to detect whether
the page is NOT conventional memory. Not io area.
There are three (or four) cases

- !mfn_valid() case
  This means that there isn't a corresponding struct page_info.
  So we just skip reference counting over this type.

- mfn_valid() case
  - no ram
I suppose this is the case you want to address.
In this case, the corresponding struct page_info can
be owned by DOMID_IO.
This case needs to be addressed.

  - RAM
- conventional memory (EFI_MEMORY_CONVENTIONAL)
  This case was already handled by the current implementation.

- other type RAM
  I'm not sure whether this case matters.
  If it matters, we can handle this case as same as no ram case.
 
  
thanks,
-- 
yamahata

___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel