List Info

Thread: ia64/xen domU take 7




ia64/pv_ops/xen: define xen pv_cpu_ops.
user name
2008-06-10 02:47:11
define xen pv_cpu_ops which implementes xen paravirtualized
privileged instructions.

Signed-off-by: Yaozu (Eddie) Dong <eddie.dongintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/xen_pv_ops.c |  114
++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/xen/xen_pv_ops.c
b/arch/ia64/xen/xen_pv_ops.c
index 433af1a..b84286b 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
 -163,6
+163,119  static const struct pv_init_ops xen_init_ops
__initdata = {
 };
 
 /**********************************************************
*****************
+ * pv_cpu_ops
+ * intrinsics hooks.
+ */
+
+static void xen_setreg(int regnum, unsigned long val)
+{
+	switch (regnum) {
+	case _IA64_REG_AR_KR0 ... _IA64_REG_AR_KR7:
+		xen_set_kr(regnum - _IA64_REG_AR_KR0, val);
+		break;
+#ifdef CONFIG_IA32_SUPPORT
+	case _IA64_REG_AR_EFLAG:
+		xen_set_eflag(val);
+		break;
+#endif
+	case _IA64_REG_CR_TPR:
+		xen_set_tpr(val);
+		break;
+	case _IA64_REG_CR_ITM:
+		xen_set_itm(val);
+		break;
+	case _IA64_REG_CR_EOI:
+		xen_eoi(val);
+		break;
+	default:
+		ia64_native_setreg_func(regnum, val);
+		break;
+	}
+}
+
+static unsigned long xen_getreg(int regnum)
+{
+	unsigned long res;
+
+	switch (regnum) {
+	case _IA64_REG_PSR:
+		res = xen_get_psr();
+		break;
+#ifdef CONFIG_IA32_SUPPORT
+	case _IA64_REG_AR_EFLAG:
+		res = xen_get_eflag();
+		break;
+#endif
+	case _IA64_REG_CR_IVR:
+		res = xen_get_ivr();
+		break;
+	case _IA64_REG_CR_TPR:
+		res = xen_get_tpr();
+		break;
+	default:
+		res = ia64_native_getreg_func(regnum);
+		break;
+	}
+	return res;
+}
+
+/* turning on interrupts is a bit more complicated.. write
to the
+ * memory-mapped virtual psr.i bit first (to avoid race
condition),
+ * then if any interrupts were pending, we have to execute
a hyperprivop
+ * to ensure the pending interrupt gets delivered; else
we're done! */
+static void
+xen_ssm_i(void)
+{
+	int old = xen_get_virtual_psr_i();
+	xen_set_virtual_psr_i(1);
+	barrier();
+	if (!old && xen_get_virtual_pend())
+		xen_hyper_ssm_i();
+}
+
+/* turning off interrupts can be paravirtualized simply by
writing
+ * to a memory-mapped virtual psr.i bit (implemented as a
16-bit bool) */
+static void
+xen_rsm_i(void)
+{
+	xen_set_virtual_psr_i(0);
+	barrier();
+}
+
+static unsigned long
+xen_get_psr_i(void)
+{
+	return xen_get_virtual_psr_i() ? IA64_PSR_I : 0;
+}
+
+static void
+xen_intrin_local_irq_restore(unsigned long mask)
+{
+	if (mask & IA64_PSR_I)
+		xen_ssm_i();
+	else
+		xen_rsm_i();
+}
+
+static const struct pv_cpu_ops xen_cpu_ops __initdata = {
+	.fc		= xen_fc,
+	.thash		= xen_thash,
+	.get_cpuid	= xen_get_cpuid,
+	.get_pmd	= xen_get_pmd,
+	.getreg		= xen_getreg,
+	.setreg		= xen_setreg,
+	.ptcga		= xen_ptcga,
+	.get_rr		= xen_get_rr,
+	.set_rr		= xen_set_rr,
+	.set_rr0_to_rr4	= xen_set_rr0_to_rr4,
+	.ssm_i		= xen_ssm_i,
+	.rsm_i		= xen_rsm_i,
+	.get_psr_i	= xen_get_psr_i,
+	.intrin_local_irq_restore
+			= xen_intrin_local_irq_restore,
+};
+
+/**********************************************************
*****************
  * pv_ops initialization
  */
 
 -172,4
+285,5  xen_setup_pv_ops(void)
 	xen_info_init();
 	pv_info = xen_info;
 	pv_init_ops = xen_init_ops;
+	pv_cpu_ops = xen_cpu_ops;
 }
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: define xen paravirtualized instructions for hand wri
user name
2008-06-10 02:47:12
define xen paravirtualized instructions for hand written
assembly code.

Signed-off-by: Yaozu (Eddie) Dong <eddie.dongintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 include/asm-ia64/xen/inst.h |  450
+++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 450 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-ia64/xen/inst.h

diff --git a/include/asm-ia64/xen/inst.h
b/include/asm-ia64/xen/inst.h
new file mode 100644
index 0000000..4298e17
--- /dev/null
+++ b/include/asm-ia64/xen/inst.h
 -0,0
+1,450 
+/**********************************************************
********************
+ * include/asm-ia64/xen/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
+ *
+ */
+
+#include <asm/xen/privop.h>
+
+#define MOV_FROM_IFA(reg)	
+	movl reg = XSI_IFA;	
+	;;			
+	ld8 reg = [reg]
+
+#define MOV_FROM_ITIR(reg)	
+	movl reg = XSI_ITIR;	
+	;;			
+	ld8 reg = [reg]
+
+#define MOV_FROM_ISR(reg)	
+	movl reg = XSI_ISR;	
+	;;			
+	ld8 reg = [reg]
+
+#define MOV_FROM_IHA(reg)	
+	movl reg = XSI_IHA;	
+	;;			
+	ld8 reg = [reg]
+
+#define MOV_FROM_IPSR(pred, reg)	
+(pred)	movl reg = XSI_IPSR;		
+	;;				
+(pred)	ld8 reg = [reg]
+
+#define MOV_FROM_IIM(reg)	
+	movl reg = XSI_IIM;	
+	;;			
+	ld8 reg = [reg]
+
+#define MOV_FROM_IIP(reg)	
+	movl reg = XSI_IIP;	
+	;;			
+	ld8 reg = [reg]
+
+.macro __MOV_FROM_IVR reg, clob
+	.ifc "reg", "r8"
+		XEN_HYPER_GET_IVR
+		.exitm
+	.endif
+	.ifc "clob", "r8"
+		XEN_HYPER_GET_IVR
+		;;
+		mov reg = r8
+		.exitm
+	.endif
+	.ifc "reg", "clob"
+		.error "it should be reg reg != clob clob"
+	.endif
+
+	mov clob = r8
+	;;
+	XEN_HYPER_GET_IVR
+	;;
+	mov reg = r8
+	;;
+	mov r8 = clob
+.endm
+#define MOV_FROM_IVR(reg, clob)	__MOV_FROM_IVR reg, clob
+
+.macro __MOV_FROM_PSR pred, reg, clob
+	.ifc "reg", "r8"
+		(pred)	XEN_HYPER_GET_PSR;
+		.exitm
+	.endif
+	.ifc "clob", "r8"
+		(pred)	XEN_HYPER_GET_PSR
+		;;
+		(pred)	mov reg = r8
+		.exitm
+	.endif
+
+	(pred)	mov clob = r8
+	(pred)	XEN_HYPER_GET_PSR
+	;;
+	(pred)	mov reg = r8
+	(pred)	mov r8 = clob
+.endm
+#define MOV_FROM_PSR(pred, reg, clob)	__MOV_FROM_PSR pred,
reg, clob
+
+
+#define MOV_TO_IFA(reg, clob)	
+	movl clob = XSI_IFA;	
+	;;			
+	st8 [clob] = reg	
+
+#define MOV_TO_ITIR(pred, reg, clob)	
+(pred)	movl clob = XSI_ITIR;		
+	;;				
+(pred)	st8 [clob] = reg
+
+#define MOV_TO_IHA(pred, reg, clob)	
+(pred)	movl clob = XSI_IHA;		
+	;;				
+(pred)	st8 [clob] = reg
+
+#define MOV_TO_IPSR(pred, reg, clob)	
+(pred)	movl clob = XSI_IPSR;		
+	;;				
+(pred)	st8 [clob] = reg;		
+	;;
+
+#define MOV_TO_IFS(pred, reg, clob)	
+(pred)	movl clob = XSI_IFS;		
+	;;				
+(pred)	st8 [clob] = reg;		
+	;;
+
+#define MOV_TO_IIP(reg, clob)	
+	movl clob = XSI_IIP;	
+	;;			
+	st8 [clob] = reg
+
+.macro ____MOV_TO_KR kr, reg, clob0, clob1
+	.ifc "clob0", "r9"
+		.error "clob0 clob0 must not be r9"
+	.endif
+	.ifc "clob1", "r8"
+		.error "clob1 clob1 must not be r8"
+	.endif
+
+	.ifnc "reg", "r9"
+		.ifnc "clob1", "r9"
+			mov clob1 = r9
+		.endif
+		mov r9 = reg
+	.endif
+	.ifnc "clob0", "r8"
+		mov clob0 = r8
+	.endif
+	mov r8 = kr
+	;;
+	XEN_HYPER_SET_KR
+
+	.ifnc "reg", "r9"
+		.ifnc "clob1", "r9"
+			mov r9 = clob1
+		.endif
+	.endif
+	.ifnc "clob0", "r8"
+		mov r8 = clob0
+	.endif
+.endm
+
+.macro __MOV_TO_KR kr, reg, clob0, clob1
+	.ifc "clob0", "r9"
+		____MOV_TO_KR kr, reg, clob1, clob0
+		.exitm
+	.endif
+	.ifc "clob1", "r8"
+		____MOV_TO_KR kr, reg, clob1, clob0
+		.exitm
+	.endif
+
+	____MOV_TO_KR kr, reg, clob0, clob1
+.endm
+
+#define MOV_TO_KR(kr, reg, clob0, clob1) 
+	__MOV_TO_KR IA64_KR_ ## kr, reg, clob0, clob1
+
+
+.macro __ITC_I pred, reg, clob
+	.ifc "reg", "r8"
+		(pred)	XEN_HYPER_ITC_I
+		.exitm
+	.endif
+	.ifc "clob", "r8"
+		(pred)	mov r8 = reg
+		;;
+		(pred)	XEN_HYPER_ITC_I
+		.exitm
+	.endif
+
+	(pred)	mov clob = r8
+	(pred)	mov r8 = reg
+	;;
+	(pred)	XEN_HYPER_ITC_I
+	;;
+	(pred)	mov r8 = clob
+	;;
+.endm
+#define ITC_I(pred, reg, clob)	__ITC_I pred, reg, clob
+
+.macro __ITC_D pred, reg, clob
+	.ifc "reg", "r8"
+		(pred)	XEN_HYPER_ITC_D
+		;;
+		.exitm
+	.endif
+	.ifc "clob", "r8"
+		(pred)	mov r8 = reg
+		;;
+		(pred)	XEN_HYPER_ITC_D
+		;;
+		.exitm
+	.endif
+
+	(pred)	mov clob = r8
+	(pred)	mov r8 = reg
+	;;
+	(pred)	XEN_HYPER_ITC_D
+	;;
+	(pred)	mov r8 = clob
+	;;
+.endm
+#define ITC_D(pred, reg, clob)	__ITC_D pred, reg, clob
+
+.macro __ITC_I_AND_D pred_i, pred_d, reg, clob
+	.ifc "reg", "r8"
+		(pred_i)XEN_HYPER_ITC_I
+		;;
+		(pred_d)XEN_HYPER_ITC_D
+		;;
+		.exitm
+	.endif
+	.ifc "clob", "r8"
+		mov r8 = reg
+		;;
+		(pred_i)XEN_HYPER_ITC_I
+		;;
+		(pred_d)XEN_HYPER_ITC_D
+		;;
+		.exitm
+	.endif
+
+	mov clob = r8
+	mov r8 = reg
+	;;
+	(pred_i)XEN_HYPER_ITC_I
+	;;
+	(pred_d)XEN_HYPER_ITC_D
+	;;
+	mov r8 = clob
+	;;
+.endm
+#define ITC_I_AND_D(pred_i, pred_d, reg, clob) 
+	__ITC_I_AND_D pred_i, pred_d, reg, clob
+
+.macro __THASH pred, reg0, reg1, clob
+	.ifc "reg0", "r8"
+		(pred)	mov r8 = reg1
+		(pred)	XEN_HYPER_THASH
+		.exitm
+	.endc
+	.ifc "reg1", "r8"
+		(pred)	XEN_HYPER_THASH
+		;;
+		(pred)	mov reg0 = r8
+		;;
+		.exitm
+	.endif
+	.ifc "clob", "r8"
+		(pred)	mov r8 = reg1
+		(pred)	XEN_HYPER_THASH
+		;;
+		(pred)	mov reg0 = r8
+		;;
+		.exitm
+	.endif
+
+	(pred)	mov clob = r8
+	(pred)	mov r8 = reg1
+	(pred)	XEN_HYPER_THASH
+	;;
+	(pred)	mov reg0 = r8
+	(pred)	mov r8 = clob
+	;;
+.endm
+#define THASH(pred, reg0, reg1, clob) __THASH pred, reg0,
reg1, clob
+
+#define SSM_PSR_IC_AND_DEFAULT_BITS_AND_SRLZ_I(clob0,
clob1)	
+	mov clob0 = 1;						
+	movl clob1 = XSI_PSR_IC;				
+	;;							
+	st4 [clob1] = clob0					
+	;;
+
+#define SSM_PSR_IC_AND_SRLZ_D(clob0, clob1)	
+	;;					
+	srlz.d;					
+	mov clob1 = 1;				
+	movl clob0 = XSI_PSR_IC;		
+	;;					
+	st4 [clob0] = clob1
+
+#define RSM_PSR_IC(clob)	
+	movl clob = XSI_PSR_IC;	
+	;;			
+	st4 [clob] = r0;	
+	;;
+
+/* pred will be clobbered */
+#define MASK_TO_PEND_OFS    (-1)
+#define SSM_PSR_I(pred, pred_clob, clob)				
+(pred)	movl clob = XSI_PSR_I_ADDR					
+	;;								
+(pred)	ld8 clob = [clob]						
+	;;								
+	/* if (pred) vpsr.i = 1 */					
+	/* if (pred) (vcpu->vcpu_info->evtchn_upcall_mask)=0
*/		
+(pred)	st1 [clob] = r0, MASK_TO_PEND_OFS				
+	;;								
+	/* if (vcpu->vcpu_info->evtchn_upcall_pending)
*/		
+(pred)	ld1 clob = [clob]						
+	;;								
+(pred)	cmp.ne.unc pred_clob, p0 = clob, r0				
+	;;								
+(pred_clob)XEN_HYPER_SSM_I	/* do areal ssm psr.i */
+
+#define RSM_PSR_I(pred, clob0, clob1)	
+	movl clob0 = XSI_PSR_I_ADDR;	
+	mov clob1 = 1;			
+	;;				
+	ld8 clob0 = [clob0];		
+	;;				
+(pred)	st1 [clob0] = clob1
+
+#define RSM_PSR_I_IC(clob0, clob1, clob2)		
+	movl clob0 = XSI_PSR_I_ADDR;			
+	movl clob1 = XSI_PSR_IC;			
+	;;						
+	ld8 clob0 = [clob0];				
+	mov clob2 = 1;					
+	;;						
+	/* note: clears both vpsr.i and vpsr.ic! */	
+	st1 [clob0] = clob2;				
+	st4 [clob1] = r0;				
+	;;
+
+#define RSM_PSR_DT		
+	XEN_HYPER_RSM_PSR_DT
+
+#define SSM_PSR_DT_AND_SRLZ_I	
+	XEN_HYPER_SSM_PSR_DT
+
+#define BSW_0(clob0, clob1, clob2)			
+	;;						
+	/* r16-r31 all now hold bank1 values */		
+	mov clob2 = ar.unat;				
+	movl clob0 = XSI_BANK1_R16;			
+	movl clob1 = XSI_BANK1_R16 + 8;			
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r16, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r17, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r18, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r19, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r20, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r21, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r22, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r23, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r24, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r25, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r26, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r27, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r28, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r29, 16;		
+	;;						
+.mem.offset 0, 0; st8.spill [clob0] = r30, 16;		
+.mem.offset 8, 0; st8.spill [clob1] = r31, 16;		
+	;;						
+	mov clob1 = ar.unat;				
+	movl clob0 = XSI_B1NAT;				
+	;;						
+	st8 [clob0] = clob1;				
+	mov ar.unat = clob2;				
+	movl clob0 = XSI_BANKNUM;			
+	;;						
+	st4 [clob0] = r0
+
+
+	/* FIXME: THIS CODE IS NOT NaT SAFE! */
+#define XEN_BSW_1(clob)			
+	mov clob = ar.unat;		
+	movl r30 = XSI_B1NAT;		
+	;;				
+	ld8 r30 = [r30];		
+	mov r31 = 1;			
+	;;				
+	mov ar.unat = r30;		
+	movl r30 = XSI_BANKNUM;		
+	;;				
+	st4 [r30] = r31;		
+	movl r30 = XSI_BANK1_R16;	
+	movl r31 = XSI_BANK1_R16+8;	
+	;;				
+	ld8.fill r16 = [r30], 16;	
+	ld8.fill r17 = [r31], 16;	
+	;;				
+	ld8.fill r18 = [r30], 16;	
+	ld8.fill r19 = [r31], 16;	
+	;;				
+	ld8.fill r20 = [r30], 16;	
+	ld8.fill r21 = [r31], 16;	
+	;;				
+	ld8.fill r22 = [r30], 16;	
+	ld8.fill r23 = [r31], 16;	
+	;;				
+	ld8.fill r24 = [r30], 16;	
+	ld8.fill r25 = [r31], 16;	
+	;;				
+	ld8.fill r26 = [r30], 16;	
+	ld8.fill r27 = [r31], 16;	
+	;;				
+	ld8.fill r28 = [r30], 16;	
+	ld8.fill r29 = [r31], 16;	
+	;;				
+	ld8.fill r30 = [r30];		
+	ld8.fill r31 = [r31];		
+	;;				
+	mov ar.unat = clob
+
+#define BSW_1(clob0, clob1)	XEN_BSW_1(clob1)
+
+
+#define COVER	
+	XEN_HYPER_COVER
+
+#define RFI			
+	XEN_HYPER_RFI;		
+	dv_serialize_data
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: paravirtualize ivt.S for xen.
user name
2008-06-10 02:47:14
paravirtualize ivt.S for xen by multi compile.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile      |   16 ++++++++++++-
 arch/ia64/xen/xenivt.S      |   52
+++++++++++++++++++++++++++++++++++++++++++
 include/asm-ia64/xen/inst.h |    1 +
 3 files changed, 68 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/xenivt.S

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index 7cb4247..5c87e4a 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -2,5
+2,19 
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xensetup.o xen_pv_ops.o 
+obj-y := hypercall.o xenivt.o xensetup.o xen_pv_ops.o 
 	 hypervisor.o xencomm.o xcom_hcall.o grant-table.o
+
+AFLAGS_xenivt.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN
+
+# xen multi compile
+ASM_PARAVIRT_MULTI_COMPILE_SRCS = ivt.S
+ASM_PARAVIRT_OBJS = $(addprefix
xen-,$(ASM_PARAVIRT_MULTI_COMPILE_SRCS:.S=.o))
+obj-y += $(ASM_PARAVIRT_OBJS)
+define paravirtualized_xen
+AFLAGS_$(1) += -D__IA64_ASM_PARAVIRTUALIZED_XEN
+endef
+$(foreach o,$(ASM_PARAVIRT_OBJS),$(eval $(call
paravirtualized_xen,$(o))))
+
+$(obj)/xen-%.o: $(src)/../kernel/%.S FORCE
+	$(call if_changed_dep,as_o_S)
diff --git a/arch/ia64/xen/xenivt.S
b/arch/ia64/xen/xenivt.S
new file mode 100644
index 0000000..3e71d50
--- /dev/null
+++ b/arch/ia64/xen/xenivt.S
 -0,0
+1,52 
+/*
+ * arch/ia64/xen/ivt.S
+ *
+ * Copyright (C) 2005 Hewlett-Packard Co
+ *	Dan Magenheimer <dan.magenheimerhp.com>
+ *
+ * Copyright (c) 2008 Isaku Yamahata <yamahata at
valinux co jp>
+ *                    VA Linux Systems Japan K.K.
+ *                    pv_ops.
+ */
+
+#include <asm/asmmacro.h>
+#include <asm/kregs.h>
+#include <asm/pgtable.h>
+
+#include "../kernel/minstate.h"
+
+	.section .text,"ax"
+GLOBAL_ENTRY(xen_event_callback)
+	mov r31=pr		// prepare to save predicates
+	;;
+	SAVE_MIN_WITH_COVER	// uses r31; defines r2 and r3
+	;;
+	movl r3=XSI_PSR_IC
+	mov r14=1
+	;;
+	st4 [r3]=r14
+	;;
+	adds r3=8,r2		// set up second base pointer for SAVE_REST
+	srlz.i			// ensure everybody knows psr.ic is back on
+	;;
+	SAVE_REST
+	;;
+1:
+	alloc r14=ar.pfs,0,0,1,0 // must be first in an insn
group
+	add out0=16,sp		// pass pointer to pt_regs as first arg
+	;;
+	br.call.sptk.many b0=xen_evtchn_do_upcall
+	;;
+	movl r20=XSI_PSR_I_ADDR
+	;;
+	ld8 r20=[r20]
+	;;
+	adds r20=-1,r20		// vcpu_info->evtchn_upcall_pending
+	;;
+	ld1 r20=[r20]
+	;;
+	cmp.ne p6,p0=r20,r0	// if there are pending events,
+	(p6) br.spnt.few 1b	// call evtchn_do_upcall again.
+	br.sptk.many xen_leave_kernel	// we know ia64_leave_kernel
is
+					// paravirtualized as xen_leave_kernel
+END(xen_event_callback)
diff --git a/include/asm-ia64/xen/inst.h
b/include/asm-ia64/xen/inst.h
index f62e0b6..ed5ebeb 100644
--- a/include/asm-ia64/xen/inst.h
+++ b/include/asm-ia64/xen/inst.h
 -22,6
+22,7 
 
 #include <asm/xen/privop.h>
 
+#define ia64_ivt				xen_ivt
 #define DO_SAVE_MIN				XEN_DO_SAVE_MIN
 
 #define MOV_FROM_IFA(reg)	
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: paravirtualize DO_SAVE_MIN for xen.
user name
2008-06-10 02:47:13
paravirtualize DO_SAVE_MIN in minstate.h for xen.

Signed-off-by: Yaozu (Eddie) Dong <eddie.dongintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 include/asm-ia64/xen/inst.h     |    2 +
 include/asm-ia64/xen/minstate.h |  134
+++++++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-ia64/xen/minstate.h

diff --git a/include/asm-ia64/xen/inst.h
b/include/asm-ia64/xen/inst.h
index 4298e17..f62e0b6 100644
--- a/include/asm-ia64/xen/inst.h
+++ b/include/asm-ia64/xen/inst.h
 -22,6
+22,8 
 
 #include <asm/xen/privop.h>
 
+#define DO_SAVE_MIN				XEN_DO_SAVE_MIN
+
 #define MOV_FROM_IFA(reg)	
 	movl reg = XSI_IFA;	
 	;;			
diff --git a/include/asm-ia64/xen/minstate.h
b/include/asm-ia64/xen/minstate.h
new file mode 100644
index 0000000..4d92d9b
--- /dev/null
+++ b/include/asm-ia64/xen/minstate.h
 -0,0
+1,134 
+/*
+ * DO_SAVE_MIN switches to the kernel stacks (if necessary)
and saves
+ * the minimum state necessary that allows us to turn
psr.ic back
+ * on.
+ *
+ * Assumed state upon entry:
+ *	psr.ic: off
+ *	r31:	contains saved predicates (pr)
+ *
+ * Upon exit, the state is as follows:
+ *	psr.ic: off
+ *	 r2 = points to &pt_regs.r16
+ *	 r8 = contents of ar.ccv
+ *	 r9 = contents of ar.csd
+ *	r10 = contents of ar.ssd
+ *	r11 = FPSR_DEFAULT
+ *	r12 = kernel sp (kernel virtual address)
+ *	r13 = points to current task_struct (kernel virtual
address)
+ *	p15 = TRUE if psr.i is set in cr.ipsr
+ *	predicate registers (other than p2, p3, and p15), b6,
r3, r14, r15:
+ *		preserved
+ * CONFIG_XEN note: p6/p7 are not preserved
+ *
+ * Note that psr.ic is NOT turned on by this macro.  This
is so that
+ * we can pass interruption state as arguments to a
handler.
+ */
+#define
XEN_DO_SAVE_MIN(__COVER,SAVE_IFS,EXTRA,WORKAROUND)					
+	mov r16=IA64_KR(CURRENT);	/* M */							
+	mov r27=ar.rsc;			/* M */							
+	mov r20=r1;			/* A */							
+	mov r25=ar.unat;		/* M */							
+	MOV_FROM_IPSR(p0,r29);		/* M */							
+	MOV_FROM_IIP(r28);		/* M */							
+	mov r21=ar.fpsr;		/* M */							
+	mov r26=ar.pfs;			/* I */							
+	__COVER;			/* B;; (or nothing) */					
+	adds r16=IA64_TASK_THREAD_ON_USTACK_OFFSET,r16;						
+	;;											
+	ld1 r17=[r16];				/* load current->thread.on_ustack
flag */	
+	st1 [r16]=r0;				/* clear current->thread.on_ustack
flag */	
+	adds r1=-IA64_TASK_THREAD_ON_USTACK_OFFSET,r16						
+	/* switch from user to kernel RBS: */							
+	;;											
+	invala;				/* M */							
+	/* SAVE_IFS;*/ /* see xen special handling below */					
+	cmp.eq pKStk,pUStk=r0,r17;		/* are we in kernel mode
already? */		
+	;;											
+(pUStk)	mov ar.rsc=0;		/* set enforced lazy mode, pl 0,
little-endian, loadrs=0 */	
+	;;											
+(pUStk)	mov.m r24=ar.rnat;									
+(pUStk)	addl r22=IA64_RBS_OFFSET,r1;			/* compute base of
RBS */		
+(pKStk) mov r1=sp;					/* get sp  */				
+	;;											
+(pUStk) lfetch.fault.excl.nt1 [r22];								
+(pUStk)	addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r1;	/*
compute base of memory stack */	
+(pUStk)	mov r23=ar.bspstore;				/* save ar.bspstore */			
+	;;											
+(pUStk)	mov ar.bspstore=r22;				/* switch to kernel RBS
*/		
+(pKStk) addl r1=-IA64_PT_REGS_SIZE,r1;			/* if in kernel
mode, use sp (r12) */	
+	;;											
+(pUStk)	mov r18=ar.bsp;										
+(pUStk)	mov ar.rsc=0x3;		/* set eager mode, pl 0,
little-endian, loadrs=0 */		
+	adds r17=2*L1_CACHE_BYTES,r1;		/* really: biggest
cache-line size */		
+	adds r16=PT(CR_IPSR),r1;								
+	;;											
+	lfetch.fault.excl.nt1 [r17],L1_CACHE_BYTES;						
+	st8 [r16]=r29;		/* save cr.ipsr */						
+	;;											
+	lfetch.fault.excl.nt1 [r17];								
+	tbit.nz p15,p0=r29,IA64_PSR_I_BIT;							
+	mov r29=b0										
+	;;											
+	WORKAROUND;										
+	adds r16=PT(R8),r1;	/* initialize first base pointer
*/				
+	adds r17=PT(R9),r1;	/* initialize second base pointer
*/				
+(pKStk)	mov r18=r0;		/* make sure r18 isn't NaT */					
+	;;											
+.mem.offset 0,0; st8.spill [r16]=r8,16;								
+.mem.offset 8,0; st8.spill [r17]=r9,16;								
+        ;;											
+.mem.offset 0,0; st8.spill [r16]=r10,24;							
+	movl r8=XSI_PRECOVER_IFS;								
+.mem.offset 8,0; st8.spill [r17]=r11,24;							
+        ;;											
+	/* xen special handling for possibly lazy cover */					
+	/* SAVE_MIN case in dispatch_ia32_handler: mov r30=r0
*/				
+	ld8 r30=[r8];										
+(pUStk)	sub r18=r18,r22;	/* r18=RSE.ndirty*8 */						
+	st8 [r16]=r28,16;	/* save cr.iip */						
+	;;											
+	st8 [r17]=r30,16;	/* save cr.ifs */						
+	mov r8=ar.ccv;										
+	mov r9=ar.csd;										
+	mov r10=ar.ssd;										
+	movl r11=FPSR_DEFAULT;   /* L-unit */							
+	;;											
+	st8 [r16]=r25,16;	/* save ar.unat */						
+	st8 [r17]=r26,16;	/* save ar.pfs */						
+	shl r18=r18,16;		/* compute ar.rsc to be used for
"loadrs" */			
+	;;											
+	st8 [r16]=r27,16;	/* save ar.rsc */						
+(pUStk)	st8 [r17]=r24,16;	/* save ar.rnat */						
+(pKStk)	adds r17=16,r17;	/* skip over ar_rnat field
*/					
+	;;			/* avoid RAW on r16 & r17 */					
+(pUStk)	st8 [r16]=r23,16;	/* save ar.bspstore */						
+	st8 [r17]=r31,16;	/* save predicates */						
+(pKStk)	adds r16=16,r16;	/* skip over ar_bspstore field
*/				
+	;;											
+	st8 [r16]=r29,16;	/* save b0 */							
+	st8 [r17]=r18,16;	/* save ar.rsc value for
"loadrs" */				
+	cmp.eq pNonSys,pSys=r0,r0	/* initialize pSys=0, pNonSys=1
*/			
+	;;											
+.mem.offset 0,0; st8.spill [r16]=r20,16;	/* save original
r1 */				
+.mem.offset 8,0; st8.spill [r17]=r12,16;							
+	adds r12=-16,r1;	/* switch to kernel memory stack (with 16
bytes of scratch) */	
+	;;											
+.mem.offset 0,0; st8.spill [r16]=r13,16;							
+.mem.offset 8,0; st8.spill [r17]=r21,16;	/* save ar.fpsr
*/				
+	mov r13=IA64_KR(CURRENT);	/* establish `current' */				
+	;;											
+.mem.offset 0,0; st8.spill [r16]=r15,16;							
+.mem.offset 8,0; st8.spill [r17]=r14,16;							
+	;;											
+.mem.offset 0,0; st8.spill [r16]=r2,16;								
+.mem.offset 8,0; st8.spill [r17]=r3,16;								
+	ACCOUNT_GET_STAMP									
+	adds r2=IA64_PT_REGS_R16_OFFSET,r1;							
+	;;											
+	EXTRA;											
+	movl r1=__gp;		/* establish kernel global pointer */				
+	;;											
+	ACCOUNT_SYS_ENTER									
+	BSW_1(r3,r14);	/* switch back to bank 1 (must be last in
insn group) */		
+	;;
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: define the nubmer of irqs which xen needs.
user name
2008-06-10 02:47:17
define include/asm-ia64/xen/irq.h to define the number of
irqs which xen needs.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/kernel/nr-irqs.c |    1 +
 include/asm-ia64/xen/irq.h |   44
++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-ia64/xen/irq.h

diff --git a/arch/ia64/kernel/nr-irqs.c
b/arch/ia64/kernel/nr-irqs.c
index 1ae0491..bf89a8f 100644
--- a/arch/ia64/kernel/nr-irqs.c
+++ b/arch/ia64/kernel/nr-irqs.c
 -10,6
+10,7 
 #include <linux/kbuild.h>
 #include <linux/threads.h>
 #include <asm-ia64/native/irq.h>
+#include <asm-ia64/xen/irq.h>
 
 void foo(void)
 {
diff --git a/include/asm-ia64/xen/irq.h
b/include/asm-ia64/xen/irq.h
new file mode 100644
index 0000000..3a5a15c
--- /dev/null
+++ b/include/asm-ia64/xen/irq.h
 -0,0
+1,44 
+/**********************************************************
********************
+ * include/asm-ia64/xen/irq.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
+ *
+ */
+
+#ifndef _ASM_IA64_XEN_IRQ_H
+#define _ASM_IA64_XEN_IRQ_H
+
+/*
+ * The flat IRQ space is divided into two regions:
+ *  1. A one-to-one mapping of real physical IRQs. This
space is only used
+ *     if we have physical device-access privilege. This
region is at the
+ *     start of the IRQ space so that existing device
drivers do not need
+ *     to be modified to translate physical IRQ numbers
into our IRQ space.
+ *  3. A dynamic mapping of inter-domain and Xen-sourced
virtual IRQs. These
+ *     are bound using the provided bind/unbind functions.
+ */
+
+#define XEN_PIRQ_BASE		0
+#define XEN_NR_PIRQS		256
+
+#define XEN_DYNIRQ_BASE		(XEN_PIRQ_BASE + XEN_NR_PIRQS)
+#define XEN_NR_DYNIRQS		(NR_CPUS * 8)
+
+#define XEN_NR_IRQS		(XEN_NR_PIRQS + XEN_NR_DYNIRQS)
+
+#endif /* _ASM_IA64_XEN_IRQ_H */
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: paravirtualize entry.S for ia64/xen.
user name
2008-06-10 02:47:15
paravirtualize entry.S for ia64/xen by multi compile.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile      |    2 +-
 arch/ia64/xen/xen_pv_ops.c  |   18 ++++++++++++++++++
 include/asm-ia64/xen/inst.h |    8 ++++++++
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index 5c87e4a..9b77e8a 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -8,7
+8,7  obj-y := hypercall.o xenivt.o xensetup.o
xen_pv_ops.o 
 AFLAGS_xenivt.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN
 
 # xen multi compile
-ASM_PARAVIRT_MULTI_COMPILE_SRCS = ivt.S
+ASM_PARAVIRT_MULTI_COMPILE_SRCS = ivt.S entry.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 b84286b..1ba4617 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
 -275,6
+275,22  static const struct pv_cpu_ops xen_cpu_ops
__initdata = {
 			= xen_intrin_local_irq_restore,
 };
 
+/**********************************************************
********************
+ * replacement of hand written assembly codes.
+ */
+
+extern char xen_switch_to;
+extern char xen_leave_syscall;
+extern char xen_work_processed_syscall;
+extern char xen_leave_kernel;
+
+const struct pv_cpu_asm_switch xen_cpu_asm_switch = {
+	.switch_to		= (unsigned long)&xen_switch_to,
+	.leave_syscall		= (unsigned long)&xen_leave_syscall,
+	.work_processed_syscall	= (unsigned
long)&xen_work_processed_syscall,
+	.leave_kernel		= (unsigned long)&xen_leave_kernel,
+};
+
 /**********************************************************
*****************
  * pv_ops initialization
  */
 -286,4
+302,6  xen_setup_pv_ops(void)
 	pv_info = xen_info;
 	pv_init_ops = xen_init_ops;
 	pv_cpu_ops = xen_cpu_ops;
+
+	paravirt_cpu_asm_init(&xen_cpu_asm_switch);
 }
diff --git a/include/asm-ia64/xen/inst.h
b/include/asm-ia64/xen/inst.h
index ed5ebeb..f4e1085 100644
--- a/include/asm-ia64/xen/inst.h
+++ b/include/asm-ia64/xen/inst.h
 -25,6
+25,14 
 #define ia64_ivt				xen_ivt
 #define DO_SAVE_MIN				XEN_DO_SAVE_MIN
 
+#define __paravirt_switch_to			xen_switch_to
+#define __paravirt_leave_syscall		xen_leave_syscall
+#define
__paravirt_work_processed_syscall	xen_work_processed_syscall

+#define __paravirt_leave_kernel			xen_leave_kernel
+#define
__paravirt_pending_syscall_end		xen_work_pending_syscall_end

+#define __paravirt_work_processed_syscall_target 
+						xen_work_processed_syscall
+
 #define MOV_FROM_IFA(reg)	
 	movl reg = XSI_IFA;	
 	;;			
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: implement xen pv_iosapic_ops.
user name
2008-06-10 02:47:16
implement xen pv_iosapic_ops for xen paravirtualized
iosapic.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/xen_pv_ops.c |   52
++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/xen/xen_pv_ops.c
b/arch/ia64/xen/xen_pv_ops.c
index 1ba4617..6978131 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
 -292,6
+292,57  const struct pv_cpu_asm_switch xen_cpu_asm_switch =
{
 };
 
 /**********************************************************
*****************
+ * pv_iosapic_ops
+ * iosapic read/write hooks.
+ */
+static void
+xen_pcat_compat_init(void)
+{
+	/* nothing */
+}
+
+static struct irq_chip*
+xen_iosapic_get_irq_chip(unsigned long trigger)
+{
+	return NULL;
+}
+
+static unsigned int
+xen_iosapic_read(char __iomem *iosapic, unsigned int reg)
+{
+	struct physdev_apic apic_op;
+	int ret;
+
+	apic_op.apic_physbase = (unsigned long)iosapic -
+					__IA64_UNCACHED_OFFSET;
+	apic_op.reg = reg;
+	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read,
&apic_op);
+	if (ret)
+		return ret;
+	return apic_op.value;
+}
+
+static void
+xen_iosapic_write(char __iomem *iosapic, unsigned int reg,
u32 val)
+{
+	struct physdev_apic apic_op;
+
+	apic_op.apic_physbase = (unsigned long)iosapic -
+					__IA64_UNCACHED_OFFSET;
+	apic_op.reg = reg;
+	apic_op.value = val;
+	HYPERVISOR_physdev_op(PHYSDEVOP_apic_write,
&apic_op);
+}
+
+static const struct pv_iosapic_ops xen_iosapic_ops
__initdata = {
+	.pcat_compat_init = xen_pcat_compat_init,
+	.get_irq_chip = xen_iosapic_get_irq_chip,
+
+	.__read = xen_iosapic_read,
+	.__write = xen_iosapic_write,
+};
+
+/**********************************************************
*****************
  * pv_ops initialization
  */
 
 -302,6
+353,7  xen_setup_pv_ops(void)
 	pv_info = xen_info;
 	pv_init_ops = xen_init_ops;
 	pv_cpu_ops = xen_cpu_ops;
+	pv_iosapic_ops = xen_iosapic_ops;
 
 	paravirt_cpu_asm_init(&xen_cpu_asm_switch);
 }
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/xen: define xen machine vector for domU.
user name
2008-06-10 02:47:20
define xen machine vector for domU.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/Makefile             |    2 ++
 arch/ia64/kernel/acpi.c        |    5 +++++
 arch/ia64/xen/Makefile         |    2 ++
 arch/ia64/xen/machvec.c        |    4 ++++
 include/asm-ia64/machvec.h     |    2 ++
 include/asm-ia64/machvec_xen.h |   22
++++++++++++++++++++++
 6 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 arch/ia64/xen/machvec.c
 create mode 100644 include/asm-ia64/machvec_xen.h

diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 3b9c8ca..60aaaaf 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
 -56,8
+56,10  core-$(CONFIG_IA64_DIG) 	+= arch/ia64/dig/
 core-$(CONFIG_IA64_GENERIC) 	+= arch/ia64/dig/
 core-$(CONFIG_IA64_HP_ZX1)	+= arch/ia64/dig/
 core-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/dig/
+core-$(CONFIG_IA64_XEN)		+= arch/ia64/dig/
 core-$(CONFIG_IA64_SGI_SN2)	+= arch/ia64/sn/
 core-$(CONFIG_KVM) 		+= arch/ia64/kvm/
+core-$(CONFIG_XEN)		+= arch/ia64/xen/
 
 drivers-$(CONFIG_PCI)		+= arch/ia64/pci/
 drivers-$(CONFIG_IA64_HP_SIM)	+= arch/ia64/hp/sim/
diff --git a/arch/ia64/kernel/acpi.c
b/arch/ia64/kernel/acpi.c
index 853d1f1..f16be17 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
 -52,6
+52,7 
 #include <asm/numa.h>
 #include <asm/sal.h>
 #include <asm/cyclone.h>
+#include <asm/xen/hypervisor.h>
 
 #define BAD_MADT_ENTRY(entry, end) (                       
                
 		(!entry) || (unsigned long)entry + sizeof(*entry) >
end ||  
 -121,6
+122,8  acpi_get_sysname(void)
 			return "uv";
 		else
 			return "sn2";
+	} else if (is_running_on_xen() &&
!strcmp(hdr->oem_id, "XEN")) {
+		return "xen";
 	}
 
 	return "dig";
 -137,6
+140,8  acpi_get_sysname(void)
 	return "uv";
 # elif defined (CONFIG_IA64_DIG)
 	return "dig";
+# elif defined (CONFIG_IA64_XEN)
+	return "xen";
 # else
 #	error Unknown platform.  Fix acpi.c.
 # endif
diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index ed31c76..972d085 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -5,6
+5,8 
 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
 
+obj-$(CONFIG_IA64_GENERIC) += machvec.o
+
 AFLAGS_xenivt.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN
 
 # xen multi compile
diff --git a/arch/ia64/xen/machvec.c
b/arch/ia64/xen/machvec.c
new file mode 100644
index 0000000..4ad588a
--- /dev/null
+++ b/arch/ia64/xen/machvec.c
 -0,0
+1,4 
+#define MACHVEC_PLATFORM_NAME           xen
+#define MACHVEC_PLATFORM_HEADER        
<asm/machvec_xen.h>
+#include <asm/machvec_init.h>
+
diff --git a/include/asm-ia64/machvec.h
b/include/asm-ia64/machvec.h
index 0721a5e..d724342 100644
--- a/include/asm-ia64/machvec.h
+++ b/include/asm-ia64/machvec.h
 -128,6
+128,8  extern void machvec_tlb_migrate_finish (struct
mm_struct *);
 #  include <asm/machvec_sn2.h>
 # elif defined (CONFIG_IA64_SGI_UV)
 #  include <asm/machvec_uv.h>
+# elif defined (CONFIG_IA64_XEN)
+#  include <asm/machvec_xen.h>
 # elif defined (CONFIG_IA64_GENERIC)
 
 # ifdef MACHVEC_PLATFORM_HEADER
diff --git a/include/asm-ia64/machvec_xen.h
b/include/asm-ia64/machvec_xen.h
new file mode 100644
index 0000000..55f9228
--- /dev/null
+++ b/include/asm-ia64/machvec_xen.h
 -0,0
+1,22 
+#ifndef _ASM_IA64_MACHVEC_XEN_h
+#define _ASM_IA64_MACHVEC_XEN_h
+
+extern ia64_mv_setup_t			dig_setup;
+extern ia64_mv_cpu_init_t		xen_cpu_init;
+extern ia64_mv_irq_init_t		xen_irq_init;
+extern ia64_mv_send_ipi_t		xen_platform_send_ipi;
+
+/*
+ * This stuff has dual use!
+ *
+ * For a generic kernel, the macros are used to initialize
the
+ * platform's machvec structure.  When compiling a
non-generic kernel,
+ * the macros are used directly.
+ */
+#define platform_name				"xen"
+#define platform_setup				dig_setup
+#define platform_cpu_init			xen_cpu_init
+#define platform_irq_init			xen_irq_init
+#define platform_send_ipi			xen_platform_send_ipi
+
+#endif /* _ASM_IA64_MACHVEC_XEN_h */
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/pv_ops/xen: implement xen pv_time_ops.
user name
2008-06-10 02:47:19
implement xen pv_time_ops to account steal time.

Cc: Jeremy Fitzhardinge <jeremygoop.org>
Signed-off-by: Alex Williamson <alex.williamsonhp.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile     |    2 +-
 arch/ia64/xen/time.c       |  165
++++++++++++++++++++++++++++++++++++++++++++
 arch/ia64/xen/time.h       |   23 ++++++
 arch/ia64/xen/xen_pv_ops.c |    2 +
 4 files changed, 191 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/time.c
 create mode 100644 arch/ia64/xen/time.h

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index 01c4289..ed31c76 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -3,7
+3,7 
 #
 
 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
+	 hypervisor.o xencomm.o xcom_hcall.o grant-table.o time.o
 
 AFLAGS_xenivt.o += -D__IA64_ASM_PARAVIRTUALIZED_XEN
 
diff --git a/arch/ia64/xen/time.c b/arch/ia64/xen/time.c
new file mode 100644
index 0000000..3414f1e
--- /dev/null
+++ b/arch/ia64/xen/time.c
 -0,0
+1,165 
+/**********************************************************
********************
+ * arch/ia64/xen/time.c
+ *
+ * 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
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/kernel_stat.h>
+#include <linux/posix-timers.h>
+#include <linux/irq.h>
+#include <linux/clocksource.h>
+
+#include <asm/xen/hypervisor.h>
+
+#include <xen/interface/vcpu.h>
+
+#include "../kernel/fsyscall_gtod_data.h"
+
+DEFINE_PER_CPU(struct vcpu_runstate_info, runstate);
+DEFINE_PER_CPU(unsigned long, processed_stolen_time);
+DEFINE_PER_CPU(unsigned long, processed_blocked_time);
+
+/* taken from i386/kernel/time-xen.c */
+static void xen_init_missing_ticks_accounting(int cpu)
+{
+	struct vcpu_register_runstate_memory_area area;
+	struct vcpu_runstate_info *runstate =
&per_cpu(runstate, cpu);
+	int rc;
+
+	memset(runstate, 0, sizeof(*runstate));
+
+	area.addr.v = runstate;
+	rc =
HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
cpu,
+				&area);
+	WARN_ON(rc && rc != -ENOSYS);
+
+	per_cpu(processed_blocked_time, cpu) =
runstate->time[RUNSTATE_blocked];
+	per_cpu(processed_stolen_time, cpu) =
runstate->time[RUNSTATE_runnable]
+					    + runstate->time[RUNSTATE_offline];
+}
+
+#define NS_PER_TICK (1000000000LL/HZ)
+
+static unsigned long
+consider_steal_time(unsigned long new_itm)
+{
+	unsigned long stolen, blocked, sched_time;
+	unsigned long delta_itm = 0, stolentick = 0;
+	int cpu = smp_processor_id();
+	struct vcpu_runstate_info *runstate;
+	struct task_struct *p = current;
+
+	runstate = &per_cpu(runstate, smp_processor_id());
+
+	do {
+		sched_time = runstate->state_entry_time;
+		mb();
+		stolen = runstate->time[RUNSTATE_runnable] +
+			 runstate->time[RUNSTATE_offline] -
+			 per_cpu(processed_stolen_time, cpu);
+		blocked = runstate->time[RUNSTATE_blocked] -
+			  per_cpu(processed_blocked_time, cpu);
+		mb();
+	} while (sched_time != runstate->state_entry_time);
+
+	/*
+	 * Check for vcpu migration effect
+	 * In this case, itc value is reversed.
+	 * This causes huge stolen value.
+	 * This function just checks and reject this effect.
+	 */
+	if (!time_after_eq(runstate->time[RUNSTATE_blocked],
+			   per_cpu(processed_blocked_time, cpu)))
+		blocked = 0;
+
+	if (!time_after_eq(runstate->time[RUNSTATE_runnable] +
+			   runstate->time[RUNSTATE_offline],
+			   per_cpu(processed_stolen_time, cpu)))
+		stolen = 0;
+
+	if (!time_after(delta_itm + new_itm, ia64_get_itc()))
+		stolentick = ia64_get_itc() - new_itm;
+
+	do_div(stolentick, NS_PER_TICK);
+	stolentick++;
+
+	do_div(stolen, NS_PER_TICK);
+
+	if (stolen > stolentick)
+		stolen = stolentick;
+
+	stolentick -= stolen;
+	do_div(blocked, NS_PER_TICK);
+
+	if (blocked > stolentick)
+		blocked = stolentick;
+
+	if (stolen > 0 || blocked > 0) {
+		account_steal_time(NULL, jiffies_to_cputime(stolen));
+		account_steal_time(idle_task(cpu),
jiffies_to_cputime(blocked));
+		run_local_timers();
+
+		if (rcu_pending(cpu))
+			rcu_check_callbacks(cpu, user_mode(get_irq_regs()));
+
+		scheduler_tick();
+		run_posix_cpu_timers(p);
+		delta_itm += local_cpu_data->itm_delta * (stolen +
blocked);
+
+		if (cpu == time_keeper_id) {
+			write_seqlock(&xtime_lock);
+			do_timer(stolen + blocked);
+			local_cpu_data->itm_next = delta_itm + new_itm;
+			write_sequnlock(&xtime_lock);
+		} else {
+			local_cpu_data->itm_next = delta_itm + new_itm;
+		}
+		per_cpu(processed_stolen_time, cpu) += NS_PER_TICK *
stolen;
+		per_cpu(processed_blocked_time, cpu) += NS_PER_TICK *
blocked;
+	}
+	return delta_itm;
+}
+
+static int xen_do_steal_accounting(unsigned long *new_itm)
+{
+	unsigned long delta_itm;
+	delta_itm = consider_steal_time(*new_itm);
+	*new_itm += delta_itm;
+	if (time_after(*new_itm, ia64_get_itc()) &&
delta_itm)
+		return 1;
+
+	return 0;
+}
+
+static void xen_itc_jitter_data_reset(void)
+{
+	u64 lcycle, ret;
+
+	do {
+		lcycle = itc_jitter_data.itc_lastcycle;
+		ret = cmpxchg(&itc_jitter_data.itc_lastcycle, lcycle,
0);
+	} while (unlikely(ret != lcycle));
+}
+
+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,
+};
diff --git a/arch/ia64/xen/time.h b/arch/ia64/xen/time.h
new file mode 100644
index 0000000..b9c7ec5
--- /dev/null
+++ b/arch/ia64/xen/time.h
 -0,0
+1,23 
+/**********************************************************
********************
+ * arch/ia64/xen/time.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
+ *
+ */
+
+extern struct pv_time_ops xen_time_ops __initdata;
diff --git a/arch/ia64/xen/xen_pv_ops.c
b/arch/ia64/xen/xen_pv_ops.c
index 0ac166c..5f83036 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
 -30,6
+30,7 
 #include <asm/xen/privop.h>
 
 #include "irq_xen.h"
+#include "time.h"
 
 /**********************************************************
*****************
  * general info
 -357,6
+358,7  xen_setup_pv_ops(void)
 	pv_cpu_ops = xen_cpu_ops;
 	pv_iosapic_ops = xen_iosapic_ops;
 	pv_irq_ops = xen_irq_ops;
+	pv_time_ops = xen_time_ops;
 
 	paravirt_cpu_asm_init(&xen_cpu_asm_switch);
 }
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

ia64/xen: a recipe for using xen/ia64 with pv_ops.
user name
2008-06-10 02:47:23
Recipe for useing xen/ia64 with pv_ops domU.

Signed-off-by: Akio Takebe <takebe_akiojp.fujitsu.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 Documentation/ia64/xen.txt |  183
++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 183 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ia64/xen.txt

diff --git a/Documentation/ia64/xen.txt
b/Documentation/ia64/xen.txt
new file mode 100644
index 0000000..a5c6993
--- /dev/null
+++ b/Documentation/ia64/xen.txt
 -0,0
+1,183 
+       Recipe for getting/building/running Xen/ia64 with
pv_ops
+      
--------------------------------------------------------
+
+This recipe discribes how to get xen-ia64 source and build
it,
+and run domU with pv_ops.
+
+===========
+Requirement
+===========
+
+  - python
+  - mercurial
+    it (aka "hg") is a open-source source code
+    management software. See the below.
+    http://www.sel
enic.com/mercurial/wiki/
+  - git
+  - bridge-utils
+
+=================================
+Getting and Building Xen and Dom0
+=================================
+
+  My enviroment is;
+    Machine  : Tiger4
+    Domain0 OS  : RHEL5
+    DomainU OS  : RHEL5
+
+ 1. Download source
+    # hg clone http://xenbits.xensource.com/ext/ia64/xen-unstable.hg
+    # cd xen-unstable.hg
+    # hg clone http://xenbits.xensource.com/ext/ia64/linux-2.6.18-xen.
hg
+
+ 2. # make world
+
+ 3. # make install-tools
+
+ 4. copy kernels and xen
+    # cp xen/xen.gz /boot/efi/efi/redhat/
+    # cp build-linux-2.6.18-xen_ia64/vmlinux.gz 
+      /boot/efi/efi/redhat/vmlinuz-2.6.18.8-xen
+
+ 5. make initrd for Dom0/DomU
+    # make -C linux-2.6.18-xen.hg ARCH=ia64 modules_install

+      O=$(/bin/pwd)/build-linux-2.6.18-xen_ia64
+    # mkinitrd -f
/boot/efi/efi/redhat/initrd-2.6.18.8-xen.img 
+      2.6.18.8-xen --builtin mptspi --builtin mptbase 
+      --builtin mptscsih --builtin uhci-hcd --builtin
ohci-hcd 
+      --builtin ehci-hcd
+
+================================
+Making a disk image for guest OS
+================================
+
+ 1. make file
+    # dd if=/dev/zero of=/root/rhel5.img bs=1M seek=4096
count=0
+    # mke2fs -F -j /root/rhel5.img
+    # mount -o loop /root/rhel5.img /mnt
+    # cp -ax /{dev,var,etc,usr,bin,sbin,lib} /mnt
+    # mkdir /mnt/{root,proc,sys,home,tmp}
+
+    Note: You may miss some device files. If so, please
create them
+    with mknod. Or you can use tar intead of cp.
+
+ 2. modify DomU's fstab
+    # vi /mnt/etc/fstab
+       /dev/xvda1  /            ext3    defaults        1
1
+       none        /dev/pts     devpts  gid=5,mode=620  0
0
+       none        /dev/shm     tmpfs   defaults        0
0
+       none        /proc        proc    defaults        0
0
+       none        /sys         sysfs   defaults        0
0
+
+ 3. modify inittab
+    set runlevel to 3 to avoid X trying to start
+    # vi /mnt/etc/inittab
+       id:3:initdefault:
+    Start a getty on the hvc0 console
+       X0:2345:respawn:/sbin/mingetty hvc0
+    tty1-6 mingetty can be commented out
+
+ 4. add hvc0 into /etc/securetty
+    # vi /mnt/etc/securetty (add hvc0)
+
+ 5. umount
+    # umount /mnt
+
+FYI, virt-manager can also make a disk image for guest OS.
+It's GUI tools and easy to make it.
+
+==================
+Boot Xen & Domain0
+==================
+
+ 1. replace elilo
+    elilo of RHEL5 can boot Xen and Dom0.
+    If you use old elilo (e.g RHEL4), please download from
the below
+    http://e
lilo.sourceforge.net/cgi-bin/blosxom
+    and copy into /boot/efi/efi/redhat/
+    # cp elilo-3.6-ia64.efi /boot/efi/efi/redhat/elilo.efi
+
+ 2. modify elilo.conf (like the below)
+    # vi /boot/efi/efi/redhat/elilo.conf
+     prompt
+     timeout=20
+     default=xen
+     relocatable
+
+     image=vmlinuz-2.6.18.8-xen
+             label=xen
+             vmm=xen.gz
+             initrd=initrd-2.6.18.8-xen.img
+             read-only
+             append=" -- rhgb root=/dev/sda2"
+
+The append options before "--" are for xen
hypervisor,
+the options after "--" are for dom0.
+
+FYI, your machine may need console options like
+"com1=19200,8n1 console=vga,com1". For example,
+append="com1=19200,8n1 console=vga,com1 -- rhgb
console=tty0 
+console=ttyS0 root=/dev/sda2"
+
+=====================================
+Getting and Building domU with pv_ops
+=====================================
+
+ 1. get pv_ops tree
+    # git clone http://people.valinux.co.jp/~yamahata/xen-
ia64/linux-2.6-xen-ia64.git/
+
+ 2. git branch (if necessary)
+    # cd linux-2.6-xen-ia64/
+    # git checkout -b your_branch
origin/xen-ia64-domu-minimal-2008may19
+    (Note: The current branch is
xen-ia64-domu-minimal-2008may19.
+    But you would find the new branch. You can see with
+    "git branch -r" to get the branch lists.
+    http://people.valinux.co.jp/~y
amahata/xen-ia64/for_eagl/linux-2.6-ia64-pv-ops.git/
+    is also available. The tree is based on
+   
git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
test)
+
+
+ 3. copy .config for pv_ops of domU
+    # cp arch/ia64/configs/xen_domu_wip_defconfig .config
+
+ 4. make kernel with pv_ops
+    # make oldconfig
+    # make
+
+ 5. install the kernel and initrd
+    # cp vmlinux.gz
/boot/efi/efi/redhat/vmlinuz-2.6-pv_ops-xenU
+    # make modules_install
+    # mkinitrd -f
/boot/efi/efi/redhat/initrd-2.6-pv_ops-xenU.img 
+      2.6.26-rc3xen-ia64-08941-g1b12161 --builtin mptspi 
+      --builtin mptbase --builtin mptscsih --builtin
uhci-hcd 
+      --builtin ohci-hcd --builtin ehci-hcd
+
+========================
+Boot DomainU with pv_ops
+========================
+
+ 1. make config of DomU
+   # vi /etc/xen/rhel5
+     kernel =
"/boot/efi/efi/redhat/vmlinuz-2.6-pv_ops-xenU"
+     ramdisk =
"/boot/efi/efi/redhat/initrd-2.6-pv_ops-xenU.img"
+     vcpus = 1
+     memory = 512
+     name = "rhel5"
+     disk = [ 'file:/root/rhel5.img,xvda1,w' ]
+     root = "/dev/xvda1 ro"
+     extra= "rhgb console=hvc0"
+
+ 2. After boot xen and dom0, start xend
+   # /etc/init.d/xend start
+   ( In the debugging case, # XEND_DEBUG=1 xend trace_start
)
+
+ 3. start domU
+   # xm create -c rhel5
+
+=========
+Reference
+=========
+- Wiki of Xen/IA64 upstream merge
+  http://wiki.xensource.com/xenwiki/XenIA64/UpstreamMerge
+
+Witten by Akio Takebe <takebe_akiojp.fujitsu.com> on 28
May 2008
-- 
1.5.3


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devellists.xensource.com
http://list
s.xensource.com/xen-ia64-devel

[1-10] [11-20] [21-23]

about | contact  Other archives ( Real Estate discussion Medical topics )