List Info

Thread: ia64/xen domU take 7




ia64/xen domU take 7
user name
2008-06-10 02:46:56
Hi. This patchset implements ia64/xen domU support based on
ia64/pv_ops frame work which was already merged to linux
ia64 test branch.
This patch is for linux ia64 test branch.

This patchset does the followings.
- Some preparation work. Mainly importing header files to
define
  related structures.
- Then, define functions related to hypercall which is the
way to
  communicate with Xen hypervisor.
- Add some helper functions which is necessary to utilize
  xen arch generic portion.
- Next implements the xen instance of pv_ops introducing
  pv_info, pv_init_ops, pv_cpu_ops and its assembler counter
part,
  pv_iosapic_ops, pv_irq_ops and, pv_time_ops step by step.
- Introduce xen machine vector to describe xen platform.
  By using machine vector, xen domU implementation can be
simplified.
- Lastly update Kconfig to allow paravirtualization support
and
  xen domU support to compile.


The working full source is available from
http://people.valinux.co.jp/~y
amahata/xen-ia64/for_eagl/linux-2.6-ia64-pv-ops.git/
branch: ia64-pv-ops-2008june10-xen-ia64

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

At this phase, we don't address the following issues.
Those will be addressed after the first merge.
- optimization by binary patch
  In fact, we had the patch to do that, but we intentionally
dropped
  for patch size/readability/cleanness.
- freeing the unused pages, i.e. pages for unused ivt.S.
- complete save/restore support

Changes from take 6:
- rebased to linux ia64 test branch
- xen bsw_1 simplification.
- add documentation. Documentation/ia64/xen.txt
- preliminary support for save/restore.
- network fix. NET_SKB_PAD.

Changes from take 5:
- rebased to Linux 2.6.26-rc3
- fix ivt.S paravirtualization.
  One instruction was wrongly paravirtualized.
  It wasn't revealed with Xen HVM domain so far, but with
real hw
- multi entry point support.
- revised changelog to add CCs.

Changes from take 4:
- fix synch bit ops definitions to prevent accidental
namespace clashes.
- rebased and fixed breakages due to the upstream change.

Changes from take 3:
- split the patch set into pv_op part and xen domU part.
- many clean ups.
- introduced pv_ops: pv_cpu_ops and pv_time_ops.

Changes from take 2:
- many clean ups following to comments.
- clean up:assembly instruction macro.
- introduced pv_ops: pv_info, pv_init_ops, pv_iosapic_ops,
pv_irq_ops.

Changes from take 1:
Single IVT source code. compile multitimes using assembler
macros.

thanks,

Diffstat:
 Documentation/ia64/xen.txt         |  183 ++++++++++++++
 arch/ia64/Kconfig                  |   32 +++
 arch/ia64/Makefile                 |    2 +
 arch/ia64/kernel/acpi.c            |    5 +
 arch/ia64/kernel/asm-offsets.c     |   38 +++
 arch/ia64/kernel/nr-irqs.c         |    1 +
 arch/ia64/kernel/process.c         |    1 -
 arch/ia64/xen/Kconfig              |   26 ++
 arch/ia64/xen/Makefile             |   22 ++
 arch/ia64/xen/grant-table.c        |  155 ++++++++++++
 arch/ia64/xen/hypercall.S          |   91 +++++++
 arch/ia64/xen/hypervisor.c         |   96 ++++++++
 arch/ia64/xen/irq_xen.c            |  422
+++++++++++++++++++++++++++++++++
 arch/ia64/xen/irq_xen.h            |   34 +++
 arch/ia64/xen/machvec.c            |    4 +
 arch/ia64/xen/suspend.c            |   59 +++++
 arch/ia64/xen/time.c               |  198 +++++++++++++++
 arch/ia64/xen/time.h               |   24 ++
 arch/ia64/xen/xcom_hcall.c         |  441
++++++++++++++++++++++++++++++++++
 arch/ia64/xen/xen_pv_ops.c         |  364
++++++++++++++++++++++++++++
 arch/ia64/xen/xencomm.c            |  106 ++++++++
 arch/ia64/xen/xenivt.S             |   52 ++++
 arch/ia64/xen/xensetup.S           |   83 +++++++
 include/asm-ia64/machvec.h         |    2 +
 include/asm-ia64/machvec_xen.h     |   22 ++
 include/asm-ia64/meminit.h         |    3 +-
 include/asm-ia64/sync_bitops.h     |   57 +++++
 include/asm-ia64/timex.h           |    2 +
 include/asm-ia64/xen/events.h      |   50 ++++
 include/asm-ia64/xen/grant_table.h |   29 +++
 include/asm-ia64/xen/hypercall.h   |  265
+++++++++++++++++++++
 include/asm-ia64/xen/hypervisor.h  |   72 ++++++
 include/asm-ia64/xen/inst.h        |  461
++++++++++++++++++++++++++++++++++++
 include/asm-ia64/xen/interface.h   |  320
+++++++++++++++++++++++++
 include/asm-ia64/xen/irq.h         |   44 ++++
 include/asm-ia64/xen/minstate.h    |  134 +++++++++++
 include/asm-ia64/xen/page.h        |   65 +++++
 include/asm-ia64/xen/privop.h      |  129 ++++++++++
 include/asm-ia64/xen/xcom_hcall.h  |   51 ++++
 include/asm-ia64/xen/xencomm.h     |   34 +++
 40 files changed, 4177 insertions(+), 2 deletions(-)

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

ia64/xen: define NET_SKB_NET to 18 if xen.
user name
2008-06-10 02:47:02
On native ia64 NET_SKB_NET isn't necessary to define.
However on xen it needs to be slightly larger. (More
specifically
it's xen-netfront.c requirement.)
It causes annoying kernel unalgned access message and
network layer troubles.
Resolve it by increasing NET_SKB_NET from the default value
16 to 18.

Cc: Kouya SHIMURA <kouyajp.fujitsu.com>
Cc: Akio Takebe <takebe_akiojp.fujitsu.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/kernel/asm-offsets.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/ia64/kernel/asm-offsets.c
b/arch/ia64/kernel/asm-offsets.c
index 6bd3fc5..6a8d95e 100644
--- a/arch/ia64/kernel/asm-offsets.c
+++ b/arch/ia64/kernel/asm-offsets.c
 -292,6
+292,17  void foo(void)
 #ifdef CONFIG_XEN
 	BLANK();
 
+	{
+		union __net_skb_pad
+		{
+			/* default NET_SKB_PAD (= 16) + NET_IP_ALIGN (= 2) */
+			char xen_pad[16 + 2];
+		};
+		COMMENT("On xen NET_SKB_PAD needs to be");
+		COMMENT(" default NET_SKB_PAD (= 16) + NET_IP_ALIGN
(= 2)");
+		DEFINE(NET_SKB_PAD, sizeof(union __net_skb_pad));
+	}
+
 #define DEFINE_MAPPED_REG_OFS(sym, field) 
 	DEFINE(sym, (XMAPPEDREGS_OFS + offsetof(struct
mapped_regs, field)))
 
-- 
1.5.3


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

ia64/xen: define several constants for ia64/xen.
user name
2008-06-10 02:47:01
define several constants for ia64/xen.

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

diff --git a/arch/ia64/kernel/asm-offsets.c
b/arch/ia64/kernel/asm-offsets.c
index c64a55a..6bd3fc5 100644
--- a/arch/ia64/kernel/asm-offsets.c
+++ b/arch/ia64/kernel/asm-offsets.c
 -16,6
+16,8 
 #include <asm-ia64/sigcontext.h>
 #include <asm-ia64/mca.h>
 
+#include <asm-ia64/xen/interface.h>
+
 #include "../kernel/sigframe.h"
 #include "../kernel/fsyscall_gtod_data.h"
 
 -286,4
+288,29  void foo(void)
 		offsetof (struct itc_jitter_data_t, itc_jitter));
 	DEFINE(IA64_ITC_LASTCYCLE_OFFSET,
 		offsetof (struct itc_jitter_data_t, itc_lastcycle));
+
+#ifdef CONFIG_XEN
+	BLANK();
+
+#define DEFINE_MAPPED_REG_OFS(sym, field) 
+	DEFINE(sym, (XMAPPEDREGS_OFS + offsetof(struct
mapped_regs, field)))
+
+	DEFINE_MAPPED_REG_OFS(XSI_PSR_I_ADDR_OFS,
interrupt_mask_addr);
+	DEFINE_MAPPED_REG_OFS(XSI_IPSR_OFS, ipsr);
+	DEFINE_MAPPED_REG_OFS(XSI_IIP_OFS, iip);
+	DEFINE_MAPPED_REG_OFS(XSI_IFS_OFS, ifs);
+	DEFINE_MAPPED_REG_OFS(XSI_PRECOVER_IFS_OFS,
precover_ifs);
+	DEFINE_MAPPED_REG_OFS(XSI_ISR_OFS, isr);
+	DEFINE_MAPPED_REG_OFS(XSI_IFA_OFS, ifa);
+	DEFINE_MAPPED_REG_OFS(XSI_IIPA_OFS, iipa);
+	DEFINE_MAPPED_REG_OFS(XSI_IIM_OFS, iim);
+	DEFINE_MAPPED_REG_OFS(XSI_IHA_OFS, iha);
+	DEFINE_MAPPED_REG_OFS(XSI_ITIR_OFS, itir);
+	DEFINE_MAPPED_REG_OFS(XSI_PSR_IC_OFS,
interrupt_collection_enabled);
+	DEFINE_MAPPED_REG_OFS(XSI_BANKNUM_OFS, banknum);
+	DEFINE_MAPPED_REG_OFS(XSI_BANK0_R16_OFS, bank0_regs[0]);
+	DEFINE_MAPPED_REG_OFS(XSI_BANK1_R16_OFS, bank1_regs[0]);
+	DEFINE_MAPPED_REG_OFS(XSI_B0NATS_OFS, vbnat);
+	DEFINE_MAPPED_REG_OFS(XSI_B1NATS_OFS, vnat);
+#endif /* CONFIG_XEN */
 }
-- 
1.5.3


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

ia64/xen: implement the arch specific part of xencomm.
user name
2008-06-10 02:47:05
On ia64/xen, pointer argument for the hypercall is passed
by pseudo physical address (guest phsysical address.)
So it is necessary to convert virtual address into pseudo
physical
address rigth before issuing hypercall. The frame work is
called
xencomm. This patch implements arch specific part.

Signed-off-by: Alex Williamson <alex.williamsonhp.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile         |    2 +-
 arch/ia64/xen/xencomm.c        |   95
++++++++++++++++++++++++++++++++++++++++
 include/asm-ia64/xen/xencomm.h |   33 ++++++++++++++
 3 files changed, 129 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/xencomm.c
 create mode 100644 include/asm-ia64/xen/xencomm.h

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index c200704..ad0c9f7 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -2,4
+2,4 
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o
+obj-y := hypercall.o xencomm.o
diff --git a/arch/ia64/xen/xencomm.c
b/arch/ia64/xen/xencomm.c
new file mode 100644
index 0000000..659d98f
--- /dev/null
+++ b/arch/ia64/xen/xencomm.c
 -0,0
+1,95 
+/*
+ * Copyright (C) 2006 Hollis Blanchard <hollisbus.ibm.com>, IBM Corporation
+ *
+ * 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/mm.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
+static unsigned long kernel_start_pa;
+
+void
+xencomm_initialize(void)
+{
+	kernel_start_pa = KERNEL_START - ia64_tpa(KERNEL_START);
+}
+
+/* Translate virtual address to physical address.  */
+unsigned long
+xencomm_vtop(unsigned long vaddr)
+{
+	struct page *page;
+	struct vm_area_struct *vma;
+
+	if (vaddr == 0)
+		return 0;
+
+#ifdef __ia64__
+	if (REGION_NUMBER(vaddr) == 5) {
+		pgd_t *pgd;
+		pud_t *pud;
+		pmd_t *pmd;
+		pte_t *ptep;
+
+		/* On ia64, TASK_SIZE refers to current.  It is not
initialized
+		   during boot.
+		   Furthermore the kernel is relocatable and __pa()
doesn't
+		   work on  addresses.  */
+		if (vaddr >= KERNEL_START
+		    && vaddr < (KERNEL_START +
KERNEL_TR_PAGE_SIZE))
+			return vaddr - kernel_start_pa;
+
+		/* In kernel area -- virtually mapped.  */
+		pgd = pgd_offset_k(vaddr);
+		if (pgd_none(*pgd) || pgd_bad(*pgd))
+			return ~0UL;
+
+		pud = pud_offset(pgd, vaddr);
+		if (pud_none(*pud) || pud_bad(*pud))
+			return ~0UL;
+
+		pmd = pmd_offset(pud, vaddr);
+		if (pmd_none(*pmd) || pmd_bad(*pmd))
+			return ~0UL;
+
+		ptep = pte_offset_kernel(pmd, vaddr);
+		if (!ptep)
+			return ~0UL;
+
+		return (pte_val(*ptep) & _PFN_MASK) | (vaddr &
~PAGE_MASK);
+	}
+#endif
+
+	if (vaddr > TASK_SIZE) {
+		/* kernel address */
+		return __pa(vaddr);
+	}
+
+	/* XXX double-check (lack of) locking */
+	vma = find_extend_vma(current->mm, vaddr);
+	if (!vma)
+		return ~0UL;
+
+	/* We assume the page is modified.  */
+	page = follow_page(vma, vaddr, FOLL_WRITE | FOLL_TOUCH);
+	if (!page)
+		return ~0UL;
+
+	return (page_to_pfn(page) << PAGE_SHIFT) | (vaddr
& ~PAGE_MASK);
+}
diff --git a/include/asm-ia64/xen/xencomm.h
b/include/asm-ia64/xen/xencomm.h
new file mode 100644
index 0000000..e95db51
--- /dev/null
+++ b/include/asm-ia64/xen/xencomm.h
 -0,0
+1,33 
+/*
+ * Copyright (C) 2006 Hollis Blanchard <hollisbus.ibm.com>, IBM Corporation
+ *
+ * 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_XENCOMM_H
+#define _ASM_IA64_XEN_XENCOMM_H
+
+#define is_kernel_addr(x)					
+	((PAGE_OFFSET <= (x) &&					
+	  (x) < (PAGE_OFFSET + (1UL <<
IA64_MAX_PHYS_BITS))) ||	
+	 (KERNEL_START <= (x) &&				
+	  (x) < KERNEL_START + KERNEL_TR_PAGE_SIZE))
+
+/* Must be called before any hypercall.  */
+extern void xencomm_initialize(void);
+
+#include <xen/xencomm.h>
+
+#endif /* _ASM_IA64_XEN_XENCOMM_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: elf note based xen startup.
user name
2008-06-10 02:47:09
This patch enables elf note based xen startup for IA-64,
which gives the
kernel an early hint for running on xen like x86 case.
In order to avoid the multi entry point, presumably
extending booting
protocol(i.e. extending struct ia64_boot_param) would be
necessary.
It probably means that elilo also needs modification.

Signed-off-by: Qing He <qing.heintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile     |    3 +-
 arch/ia64/xen/xen_pv_ops.c |   65
++++++++++++++++++++++++++++++++++
 arch/ia64/xen/xensetup.S   |   83
++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/xen_pv_ops.c
 create mode 100644 arch/ia64/xen/xensetup.S

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index eb59563..abc356f 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -2,4
+2,5 
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xencomm.o xcom_hcall.o grant-table.o
+obj-y := hypercall.o xensetup.o xen_pv_ops.o 
+	xencomm.o xcom_hcall.o grant-table.o
diff --git a/arch/ia64/xen/xen_pv_ops.c
b/arch/ia64/xen/xen_pv_ops.c
new file mode 100644
index 0000000..77db214
--- /dev/null
+++ b/arch/ia64/xen/xen_pv_ops.c
 -0,0
+1,65 
+/**********************************************************
********************
+ * arch/ia64/xen/xen_pv_ops.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/console.h>
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/pm.h>
+
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/xencomm.h>
+#include <asm/xen/privop.h>
+
+/**********************************************************
*****************
+ * general info
+ */
+static struct pv_info xen_info __initdata = {
+	.kernel_rpl = 2,	/* or 1: determin at runtime */
+	.paravirt_enabled = 1,
+	.name = "Xen/ia64",
+};
+
+#define IA64_RSC_PL_SHIFT	2
+#define IA64_RSC_PL_BIT_SIZE	2
+#define IA64_RSC_PL_MASK	
+	(((1UL << IA64_RSC_PL_BIT_SIZE) - 1) <<
IA64_RSC_PL_SHIFT)
+
+static void __init
+xen_info_init(void)
+{
+	/* Xenified Linux/ia64 may run on pl = 1 or 2.
+	 * determin at run time. */
+	unsigned long rsc = ia64_getreg(_IA64_REG_AR_RSC);
+	unsigned int rpl = (rsc & IA64_RSC_PL_MASK) >>
IA64_RSC_PL_SHIFT;
+	xen_info.kernel_rpl = rpl;
+}
+
+/**********************************************************
*****************
+ * pv_ops initialization
+ */
+
+void __init
+xen_setup_pv_ops(void)
+{
+	xen_info_init();
+	pv_info = xen_info;
+}
diff --git a/arch/ia64/xen/xensetup.S
b/arch/ia64/xen/xensetup.S
new file mode 100644
index 0000000..7d71333
--- /dev/null
+++ b/arch/ia64/xen/xensetup.S
 -0,0
+1,83 
+/*
+ * Support routines for Xen
+ *
+ * Copyright (C) 2005 Dan Magenheimer
<dan.magenheimerhp.com>
+ */
+
+#include <asm/processor.h>
+#include <asm/asmmacro.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+#include <asm/paravirt.h>
+#include <asm/xen/privop.h>
+#include <linux/elfnote.h>
+#include <linux/init.h>
+#include <xen/interface/elfnote.h>
+
+	.section .data.read_mostly
+	.align 8
+	.global running_on_xen
+running_on_xen:
+	data4 0
+	.previous
+
+	__INIT
+ENTRY(startup_xen)
+	// Calculate load offset.
+	// The constant, LOAD_OFFSET, can't be used because the
boot
+	// loader doesn't always load to the LMA specified by the
vmlinux.lds.
+	mov r9=ip	// must be the first instruction to make sure
+			// that r9 = the physical address of startup_xen.
+			// Usually r9 = startup_xen - LOAD_OFFSET
+	movl r8=startup_xen
+	;;
+	sub r9=r9,r8	// Usually r9 = -LOAD_OFFSET.
+
+	mov r10=PARAVIRT_HYPERVISOR_TYPE_XEN
+	movl r11=_start
+	;;
+	add r11=r11,r9
+	movl r8=hypervisor_type
+	;;
+	add r8=r8,r9
+	mov b0=r11
+	;;
+	st8 [r8]=r10
+	br.cond.sptk.many b0
+	;;
+END(startup_xen)
+
+	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,	.asciz
"linux")
+	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,	.asciz
"2.6")
+	ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,	.asciz
"xen-3.0")
+	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,		data8.ua startup_xen -
LOAD_OFFSET)
+
+#define isBP	p3	// are we the Bootstrap Processor?
+
+	.text
+
+GLOBAL_ENTRY(xen_setup_hook)
+	mov r8=1		// booleanize.
+(isBP)	movl r9=running_on_xen;;
+(isBP)	st4 [r9]=r8
+	movl r10=xen_ivt;;
+
+	mov cr.iva=r10
+
+	/* Set xsi base.  */
+#define FW_HYPERCALL_SET_SHARED_INFO_VA			0x600
+(isBP)	mov r2=FW_HYPERCALL_SET_SHARED_INFO_VA
+(isBP)	movl r28=XSI_BASE;;
+(isBP)	break 0x1000;;
+
+	/* setup pv_ops */
+(isBP)	mov r4=rp
+	;;
+(isBP)	br.call.sptk.many rp=xen_setup_pv_ops
+	;;
+(isBP)	mov rp=r4
+	;;
+
+	br.ret.sptk.many rp
+	;;
+END(xen_setup_hook)
-- 
1.5.3


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

ia64/xen: add definitions necessary for xen event channel.
user name
2008-06-10 02:47:08
Xen paravirtualizes interrupt as event channel.
This patch defines arch specific part of xen event channel.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 include/asm-ia64/xen/events.h |   50
+++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-ia64/xen/events.h

diff --git a/include/asm-ia64/xen/events.h
b/include/asm-ia64/xen/events.h
new file mode 100644
index 0000000..42bb0b5
--- /dev/null
+++ b/include/asm-ia64/xen/events.h
 -0,0
+1,50 
+/**********************************************************
********************
+ * include/asm-ia64/xen/events.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_EVENTS_H
+#define _ASM_IA64_XEN_EVENTS_H
+
+enum ipi_vector {
+	XEN_RESCHEDULE_VECTOR,
+	XEN_IPI_VECTOR,
+	XEN_CMCP_VECTOR,
+	XEN_CPEP_VECTOR,
+
+	XEN_NR_IPIS,
+};
+
+static inline int xen_irqs_disabled(struct pt_regs *regs)
+{
+	return !(ia64_psr(regs)->i);
+}
+
+static inline void xen_do_IRQ(int irq, struct pt_regs
*regs)
+{
+	struct pt_regs *old_regs;
+	old_regs = set_irq_regs(regs);
+	irq_enter();
+	__do_IRQ(irq);
+	irq_exit();
+	set_irq_regs(old_regs);
+}
+#define irq_ctx_init(cpu)	do { } while (0)
+
+#endif /* _ASM_IA64_XEN_EVENTS_H */
-- 
1.5.3


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

ia64/xen: xencomm conversion functions for hypercalls
user name
2008-06-10 02:47:06
On ia64/xen, pointer arguments for hypercall is passed
by pseudo physical address(guest physical address.)
So such hypercalls needs address conversion functions.
This patch implements concreate conversion functions for
such hypercalls.

Signed-off-by: Akio Takebe <takebe_akiojp.fujitsu.com>
Signed-off-by: Yaozu (Eddie) Dong <eddie.dongintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile            |    2 +-
 arch/ia64/xen/xcom_hcall.c        |  441
+++++++++++++++++++++++++++++++++++++
 arch/ia64/xen/xencomm.c           |   11 +
 include/asm-ia64/xen/xcom_hcall.h |   51 +++++
 include/asm-ia64/xen/xencomm.h    |    1 +
 5 files changed, 505 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/xcom_hcall.c
 create mode 100644 include/asm-ia64/xen/xcom_hcall.h

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index ad0c9f7..ae08822 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -2,4
+2,4 
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xencomm.o
+obj-y := hypercall.o xencomm.o xcom_hcall.o
diff --git a/arch/ia64/xen/xcom_hcall.c
b/arch/ia64/xen/xcom_hcall.c
new file mode 100644
index 0000000..ccaf743
--- /dev/null
+++ b/arch/ia64/xen/xcom_hcall.c
 -0,0
+1,441 
+/*
+ * 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, 51 Franklin Street, Fifth Floor, Boston, MA 
02110-1301, USA.
+ *
+ *          Tristan Gingold <tristan.gingoldbull.net>
+ *
+ *          Copyright (c) 2007
+ *          Isaku Yamahata <yamahata at valinux co
jp>
+ *                          VA Linux Systems Japan K.K.
+ *          consolidate mini and inline version.
+ */
+
+#include <linux/module.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/memory.h>
+#include <xen/interface/grant_table.h>
+#include <xen/interface/callback.h>
+#include <xen/interface/vcpu.h>
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/xencomm.h>
+
+/* Xencomm notes:
+ * This file defines hypercalls to be used by xencomm.  The
hypercalls simply
+ * create inlines or mini descriptors for pointers and then
call the raw arch
+ * hypercall xencomm_arch_hypercall_XXX
+ *
+ * If the arch wants to directly use these hypercalls,
simply define macros
+ * in asm/xen/hypercall.h, eg:
+ *  #define HYPERVISOR_sched_op xencomm_hypercall_sched_op
+ *
+ * The arch may also define HYPERVISOR_xxx as a function
and do more operations
+ * before/after doing the hypercall.
+ *
+ * Note: because only inline or mini descriptors are
created these functions
+ * must only be called with in kernel memory parameters.
+ */
+
+int
+xencomm_hypercall_console_io(int cmd, int count, char
*str)
+{
+	/* xen early printk uses console io hypercall before
+	 * xencomm initialization. In that case, we just ignore
it.
+	 */
+	if (!xencomm_is_initialized())
+		return 0;
+
+	return xencomm_arch_hypercall_console_io
+		(cmd, count, xencomm_map_no_alloc(str, count));
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_console_io);
+
+int
+xencomm_hypercall_event_channel_op(int cmd, void *op)
+{
+	struct xencomm_handle *desc;
+	desc = xencomm_map_no_alloc(op, sizeof(struct
evtchn_op));
+	if (desc == NULL)
+		return -EINVAL;
+
+	return xencomm_arch_hypercall_event_channel_op(cmd,
desc);
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_event_channel_op);
+
+int
+xencomm_hypercall_xen_version(int cmd, void *arg)
+{
+	struct xencomm_handle *desc;
+	unsigned int argsize;
+
+	switch (cmd) {
+	case XENVER_version:
+		/* do not actually pass an argument */
+		return xencomm_arch_hypercall_xen_version(cmd, 0);
+	case XENVER_extraversion:
+		argsize = sizeof(struct xen_extraversion);
+		break;
+	case XENVER_compile_info:
+		argsize = sizeof(struct xen_compile_info);
+		break;
+	case XENVER_capabilities:
+		argsize = sizeof(struct xen_capabilities_info);
+		break;
+	case XENVER_changeset:
+		argsize = sizeof(struct xen_changeset_info);
+		break;
+	case XENVER_platform_parameters:
+		argsize = sizeof(struct xen_platform_parameters);
+		break;
+	case XENVER_get_features:
+		argsize = (arg == NULL) ? 0 : sizeof(struct
xen_feature_info);
+		break;
+
+	default:
+		printk(KERN_DEBUG
+		       "%s: unknown version op %dn", __func__,
cmd);
+		return -ENOSYS;
+	}
+
+	desc = xencomm_map_no_alloc(arg, argsize);
+	if (desc == NULL)
+		return -EINVAL;
+
+	return xencomm_arch_hypercall_xen_version(cmd, desc);
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_xen_version);
+
+int
+xencomm_hypercall_physdev_op(int cmd, void *op)
+{
+	unsigned int argsize;
+
+	switch (cmd) {
+	case PHYSDEVOP_apic_read:
+	case PHYSDEVOP_apic_write:
+		argsize = sizeof(struct physdev_apic);
+		break;
+	case PHYSDEVOP_alloc_irq_vector:
+	case PHYSDEVOP_free_irq_vector:
+		argsize = sizeof(struct physdev_irq);
+		break;
+	case PHYSDEVOP_irq_status_query:
+		argsize = sizeof(struct physdev_irq_status_query);
+		break;
+
+	default:
+		printk(KERN_DEBUG
+		       "%s: unknown physdev op %dn", __func__,
cmd);
+		return -ENOSYS;
+	}
+
+	return xencomm_arch_hypercall_physdev_op
+		(cmd, xencomm_map_no_alloc(op, argsize));
+}
+
+static int
+xencommize_grant_table_op(struct xencomm_mini **xc_area,
+			  unsigned int cmd, void *op, unsigned int count,
+			  struct xencomm_handle **desc)
+{
+	struct xencomm_handle *desc1;
+	unsigned int argsize;
+
+	switch (cmd) {
+	case GNTTABOP_map_grant_ref:
+		argsize = sizeof(struct gnttab_map_grant_ref);
+		break;
+	case GNTTABOP_unmap_grant_ref:
+		argsize = sizeof(struct gnttab_unmap_grant_ref);
+		break;
+	case GNTTABOP_setup_table:
+	{
+		struct gnttab_setup_table *setup = op;
+
+		argsize = sizeof(*setup);
+
+		if (count != 1)
+			return -EINVAL;
+		desc1 = __xencomm_map_no_alloc
+			(xen_guest_handle(setup->frame_list),
+			 setup->nr_frames *
+			 sizeof(*xen_guest_handle(setup->frame_list)),
+			 *xc_area);
+		if (desc1 == NULL)
+			return -EINVAL;
+		(*xc_area)++;
+		set_xen_guest_handle(setup->frame_list, (void
*)desc1);
+		break;
+	}
+	case GNTTABOP_dump_table:
+		argsize = sizeof(struct gnttab_dump_table);
+		break;
+	case GNTTABOP_transfer:
+		argsize = sizeof(struct gnttab_transfer);
+		break;
+	case GNTTABOP_copy:
+		argsize = sizeof(struct gnttab_copy);
+		break;
+	case GNTTABOP_query_size:
+		argsize = sizeof(struct gnttab_query_size);
+		break;
+	default:
+		printk(KERN_DEBUG "%s: unknown hypercall grant table
op %dn",
+		       __func__, cmd);
+		BUG();
+	}
+
+	*desc = __xencomm_map_no_alloc(op, count * argsize,
*xc_area);
+	if (*desc == NULL)
+		return -EINVAL;
+	(*xc_area)++;
+
+	return 0;
+}
+
+int
+xencomm_hypercall_grant_table_op(unsigned int cmd, void
*op,
+				 unsigned int count)
+{
+	int rc;
+	struct xencomm_handle *desc;
+	XENCOMM_MINI_ALIGNED(xc_area, 2);
+
+	rc = xencommize_grant_table_op(&xc_area, cmd, op,
count, &desc);
+	if (rc)
+		return rc;
+
+	return xencomm_arch_hypercall_grant_table_op(cmd, desc,
count);
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_grant_table_op);
+
+int
+xencomm_hypercall_sched_op(int cmd, void *arg)
+{
+	struct xencomm_handle *desc;
+	unsigned int argsize;
+
+	switch (cmd) {
+	case SCHEDOP_yield:
+	case SCHEDOP_block:
+		argsize = 0;
+		break;
+	case SCHEDOP_shutdown:
+		argsize = sizeof(struct sched_shutdown);
+		break;
+	case SCHEDOP_poll:
+	{
+		struct sched_poll *poll = arg;
+		struct xencomm_handle *ports;
+
+		argsize = sizeof(struct sched_poll);
+		ports =
xencomm_map_no_alloc(xen_guest_handle(poll->ports),
+				     sizeof(*xen_guest_handle(poll->ports)));
+
+		set_xen_guest_handle(poll->ports, (void *)ports);
+		break;
+	}
+	default:
+		printk(KERN_DEBUG "%s: unknown sched op %dn",
__func__, cmd);
+		return -ENOSYS;
+	}
+
+	desc = xencomm_map_no_alloc(arg, argsize);
+	if (desc == NULL)
+		return -EINVAL;
+
+	return xencomm_arch_hypercall_sched_op(cmd, desc);
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_sched_op);
+
+int
+xencomm_hypercall_multicall(void *call_list, int nr_calls)
+{
+	int rc;
+	int i;
+	struct multicall_entry *mce;
+	struct xencomm_handle *desc;
+	XENCOMM_MINI_ALIGNED(xc_area, nr_calls * 2);
+
+	for (i = 0; i < nr_calls; i++) {
+		mce = (struct multicall_entry *)call_list + i;
+
+		switch (mce->op) {
+		case __HYPERVISOR_update_va_mapping:
+		case __HYPERVISOR_mmu_update:
+			/* No-op on ia64.  */
+			break;
+		case __HYPERVISOR_grant_table_op:
+			rc = xencommize_grant_table_op
+				(&xc_area,
+				 mce->args[0], (void *)mce->args[1],
+				 mce->args[2], &desc);
+			if (rc)
+				return rc;
+			mce->args[1] = (unsigned long)desc;
+			break;
+		case __HYPERVISOR_memory_op:
+		default:
+			printk(KERN_DEBUG
+			       "%s: unhandled multicall op entry op
%lun",
+			       __func__, mce->op);
+			return -ENOSYS;
+		}
+	}
+
+	desc = xencomm_map_no_alloc(call_list,
+				    nr_calls * sizeof(struct multicall_entry));
+	if (desc == NULL)
+		return -EINVAL;
+
+	return xencomm_arch_hypercall_multicall(desc, nr_calls);
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_multicall);
+
+int
+xencomm_hypercall_callback_op(int cmd, void *arg)
+{
+	unsigned int argsize;
+	switch (cmd) {
+	case CALLBACKOP_register:
+		argsize = sizeof(struct callback_register);
+		break;
+	case CALLBACKOP_unregister:
+		argsize = sizeof(struct callback_unregister);
+		break;
+	default:
+		printk(KERN_DEBUG
+		       "%s: unknown callback op %dn",
__func__, cmd);
+		return -ENOSYS;
+	}
+
+	return xencomm_arch_hypercall_callback_op
+		(cmd, xencomm_map_no_alloc(arg, argsize));
+}
+
+static int
+xencommize_memory_reservation(struct xencomm_mini
*xc_area,
+			      struct xen_memory_reservation *mop)
+{
+	struct xencomm_handle *desc;
+
+	desc =
__xencomm_map_no_alloc(xen_guest_handle(mop->extent_start
),
+			mop->nr_extents *
+			sizeof(*xen_guest_handle(mop->extent_start)),
+			xc_area);
+	if (desc == NULL)
+		return -EINVAL;
+
+	set_xen_guest_handle(mop->extent_start, (void *)desc);
+	return 0;
+}
+
+int
+xencomm_hypercall_memory_op(unsigned int cmd, void *arg)
+{
+	GUEST_HANDLE(xen_pfn_t) extent_start_va[2] = { ,
 };
+	struct xen_memory_reservation *xmr = NULL;
+	int rc;
+	struct xencomm_handle *desc;
+	unsigned int argsize;
+	XENCOMM_MINI_ALIGNED(xc_area, 2);
+
+	switch (cmd) {
+	case XENMEM_increase_reservation:
+	case XENMEM_decrease_reservation:
+	case XENMEM_populate_physmap:
+		xmr = (struct xen_memory_reservation *)arg;
+		set_xen_guest_handle(extent_start_va[0],
+				     xen_guest_handle(xmr->extent_start));
+
+		argsize = sizeof(*xmr);
+		rc = xencommize_memory_reservation(xc_area, xmr);
+		if (rc)
+			return rc;
+		xc_area++;
+		break;
+
+	case XENMEM_maximum_ram_page:
+		argsize = 0;
+		break;
+
+	case XENMEM_add_to_physmap:
+		argsize = sizeof(struct xen_add_to_physmap);
+		break;
+
+	default:
+		printk(KERN_DEBUG "%s: unknown memory op %dn",
__func__, cmd);
+		return -ENOSYS;
+	}
+
+	desc = xencomm_map_no_alloc(arg, argsize);
+	if (desc == NULL)
+		return -EINVAL;
+
+	rc = xencomm_arch_hypercall_memory_op(cmd, desc);
+
+	switch (cmd) {
+	case XENMEM_increase_reservation:
+	case XENMEM_decrease_reservation:
+	case XENMEM_populate_physmap:
+		set_xen_guest_handle(xmr->extent_start,
+				     xen_guest_handle(extent_start_va[0]));
+		break;
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(xencomm_hypercall_memory_op);
+
+int
+xencomm_hypercall_suspend(unsigned long srec)
+{
+	struct sched_shutdown arg;
+
+	arg.reason = SHUTDOWN_suspend;
+
+	return xencomm_arch_hypercall_sched_op(
+		SCHEDOP_shutdown, xencomm_map_no_alloc(&arg,
sizeof(arg)));
+}
+
+long
+xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg)
+{
+	unsigned int argsize;
+	switch (cmd) {
+	case VCPUOP_register_runstate_memory_area: {
+		struct vcpu_register_runstate_memory_area *area =
+			(struct vcpu_register_runstate_memory_area *)arg;
+		argsize = sizeof(*arg);
+		set_xen_guest_handle(area->addr.h,
+		     (void *)xencomm_map_no_alloc(area->addr.v,
+						  sizeof(area->addr.v)));
+		break;
+	}
+
+	default:
+		printk(KERN_DEBUG "%s: unknown vcpu op %dn",
__func__, cmd);
+		return -ENOSYS;
+	}
+
+	return xencomm_arch_hypercall_vcpu_op(cmd, cpu,
+					xencomm_map_no_alloc(arg, argsize));
+}
+
+long
+xencomm_hypercall_opt_feature(void *arg)
+{
+	return xencomm_arch_hypercall_opt_feature(
+		xencomm_map_no_alloc(arg,
+				     sizeof(struct xen_ia64_opt_feature)));
+}
diff --git a/arch/ia64/xen/xencomm.c
b/arch/ia64/xen/xencomm.c
index 659d98f..253330e 100644
--- a/arch/ia64/xen/xencomm.c
+++ b/arch/ia64/xen/xencomm.c
 -23,11
+23,22 
 #endif
 
 static unsigned long kernel_start_pa;
+static int is_xencomm_initialized;
+
+/* for xen early printk. It uses console io hypercall which
uses xencomm.
+ * However early printk may use it before xencomm
initialization.
+ */
+int
+xencomm_is_initialized(void)
+{
+	return is_xencomm_initialized;
+}
 
 void
 xencomm_initialize(void)
 {
 	kernel_start_pa = KERNEL_START - ia64_tpa(KERNEL_START);
+	is_xencomm_initialized = 1;
 }
 
 /* Translate virtual address to physical address.  */
diff --git a/include/asm-ia64/xen/xcom_hcall.h
b/include/asm-ia64/xen/xcom_hcall.h
new file mode 100644
index 0000000..20b2950
--- /dev/null
+++ b/include/asm-ia64/xen/xcom_hcall.h
 -0,0
+1,51 
+/*
+ * Copyright (C) 2006 Tristan Gingold
<tristan.gingoldbull.net>, Bull SAS
+ *
+ * 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_XCOM_HCALL_H
+#define _ASM_IA64_XEN_XCOM_HCALL_H
+
+/* These function creates inline or mini descriptor for the
parameters and
+   calls the corresponding xencomm_arch_hypercall_X.
+   Architectures should defines HYPERVISOR_xxx as
xencomm_hypercall_xxx unless
+   they want to use their own wrapper.  */
+extern int xencomm_hypercall_console_io(int cmd, int count,
char *str);
+
+extern int xencomm_hypercall_event_channel_op(int cmd, void
*op);
+
+extern int xencomm_hypercall_xen_version(int cmd, void
*arg);
+
+extern int xencomm_hypercall_physdev_op(int cmd, void
*op);
+
+extern int xencomm_hypercall_grant_table_op(unsigned int
cmd, void *op,
+					    unsigned int count);
+
+extern int xencomm_hypercall_sched_op(int cmd, void *arg);
+
+extern int xencomm_hypercall_multicall(void *call_list, int
nr_calls);
+
+extern int xencomm_hypercall_callback_op(int cmd, void
*arg);
+
+extern int xencomm_hypercall_memory_op(unsigned int cmd,
void *arg);
+
+extern int xencomm_hypercall_suspend(unsigned long srec);
+
+extern long xencomm_hypercall_vcpu_op(int cmd, int cpu,
void *arg);
+
+extern long xencomm_hypercall_opt_feature(void *arg);
+
+#endif /* _ASM_IA64_XEN_XCOM_HCALL_H */
diff --git a/include/asm-ia64/xen/xencomm.h
b/include/asm-ia64/xen/xencomm.h
index e95db51..d4e2ee7 100644
--- a/include/asm-ia64/xen/xencomm.h
+++ b/include/asm-ia64/xen/xencomm.h
 -27,6
+27,7 
 
 /* Must be called before any hypercall.  */
 extern void xencomm_initialize(void);
+extern int xencomm_is_initialized(void);
 
 #include <xen/xencomm.h>
 
-- 
1.5.3


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

ia64/xen: define helper functions for xen hypercalls.
user name
2008-06-10 02:47:04
introduce helper functions for xen hypercalls which
traps to hypervisor.

Signed-off-by: Yaozu (Eddie) Dong <eddie.dongintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile           |    5 +
 arch/ia64/xen/hypercall.S        |   91 +++++++++++++
 include/asm-ia64/xen/hypercall.h |  265
++++++++++++++++++++++++++++++++++++++
 include/asm-ia64/xen/privop.h    |  129 ++++++++++++++++++
 4 files changed, 490 insertions(+), 0 deletions(-)
 create mode 100644 arch/ia64/xen/Makefile
 create mode 100644 arch/ia64/xen/hypercall.S
 create mode 100644 include/asm-ia64/xen/hypercall.h
 create mode 100644 include/asm-ia64/xen/privop.h

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
new file mode 100644
index 0000000..c200704
--- /dev/null
+++ b/arch/ia64/xen/Makefile
 -0,0
+1,5 
+#
+# Makefile for Xen components
+#
+
+obj-y := hypercall.o
diff --git a/arch/ia64/xen/hypercall.S
b/arch/ia64/xen/hypercall.S
new file mode 100644
index 0000000..d4ff0b9
--- /dev/null
+++ b/arch/ia64/xen/hypercall.S
 -0,0
+1,91 
+/*
+ * Support routines for Xen hypercalls
+ *
+ * Copyright (C) 2005 Dan Magenheimer
<dan.magenheimerhp.com>
+ * Copyright (C) 2008 Yaozu (Eddie) Dong <eddie.dongintel.com>
+ */
+
+#include <asm/asmmacro.h>
+#include <asm/intrinsics.h>
+#include <asm/xen/privop.h>
+
+/*
+ * Hypercalls without parameter.
+ */
+#define __HCALL0(name,hcall)		
+	GLOBAL_ENTRY(name);		
+	break	hcall;			
+	br.ret.sptk.many rp;		
+	END(name)
+
+/*
+ * Hypercalls with 1 parameter.
+ */
+#define __HCALL1(name,hcall)		
+	GLOBAL_ENTRY(name);		
+	mov r8=r32;			
+	break	hcall;			
+	br.ret.sptk.many rp;		
+	END(name)
+
+/*
+ * Hypercalls with 2 parameters.
+ */
+#define __HCALL2(name,hcall)		
+	GLOBAL_ENTRY(name);		
+	mov r8=r32;			
+	mov r9=r33;			
+	break	hcall;			
+	br.ret.sptk.many rp;		
+	END(name)
+
+__HCALL0(xen_get_psr, HYPERPRIVOP_GET_PSR)
+__HCALL0(xen_get_ivr, HYPERPRIVOP_GET_IVR)
+__HCALL0(xen_get_tpr, HYPERPRIVOP_GET_TPR)
+__HCALL0(xen_hyper_ssm_i, HYPERPRIVOP_SSM_I)
+
+__HCALL1(xen_set_tpr, HYPERPRIVOP_SET_TPR)
+__HCALL1(xen_eoi, HYPERPRIVOP_EOI)
+__HCALL1(xen_thash, HYPERPRIVOP_THASH)
+__HCALL1(xen_set_itm, HYPERPRIVOP_SET_ITM)
+__HCALL1(xen_get_rr, HYPERPRIVOP_GET_RR)
+__HCALL1(xen_fc, HYPERPRIVOP_FC)
+__HCALL1(xen_get_cpuid, HYPERPRIVOP_GET_CPUID)
+__HCALL1(xen_get_pmd, HYPERPRIVOP_GET_PMD)
+
+__HCALL2(xen_ptcga, HYPERPRIVOP_PTC_GA)
+__HCALL2(xen_set_rr, HYPERPRIVOP_SET_RR)
+__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR)
+
+#ifdef CONFIG_IA32_SUPPORT
+__HCALL1(xen_get_eflag, HYPERPRIVOP_GET_EFLAG)
+__HCALL1(xen_set_eflag, HYPERPRIVOP_SET_EFLAG)	// refer SDM
vol1 3.1.8
+#endif /* CONFIG_IA32_SUPPORT */
+
+GLOBAL_ENTRY(xen_set_rr0_to_rr4)
+	mov r8=r32
+	mov r9=r33
+	mov r10=r34
+	mov r11=r35
+	mov r14=r36
+	XEN_HYPER_SET_RR0_TO_RR4
+	br.ret.sptk.many rp
+	;;
+END(xen_set_rr0_to_rr4)
+
+GLOBAL_ENTRY(xen_send_ipi)
+	mov r14=r32
+	mov r15=r33
+	mov r2=0x400
+	break 0x1000
+	;;
+	br.ret.sptk.many rp
+	;;
+END(xen_send_ipi)
+
+GLOBAL_ENTRY(__hypercall)
+	mov r2=r37
+	break 0x1000
+	br.ret.sptk.many b0
+	;;
+END(__hypercall)
diff --git a/include/asm-ia64/xen/hypercall.h
b/include/asm-ia64/xen/hypercall.h
new file mode 100644
index 0000000..96fc623
--- /dev/null
+++ b/include/asm-ia64/xen/hypercall.h
 -0,0
+1,265 
+/**********************************************************
********************
+ * hypercall.h
+ *
+ * Linux-specific hypervisor handling.
+ *
+ * Copyright (c) 2002-2004, K A Fraser
+ *
+ * This program is free software; you can redistribute it
and/or
+ * modify it under the terms of the GNU General Public
License version 2
+ * as published by the Free Software Foundation; or, when
distributed
+ * separately from the Linux kernel or incorporated into
other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any
person obtaining a copy
+ * of this source file (the "Software"), to deal
in the Software without
+ * restriction, including without limitation the rights to
use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell
copies of the Software,
+ * and to permit persons to whom the Software is furnished
to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice
shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _ASM_IA64_XEN_HYPERCALL_H
+#define _ASM_IA64_XEN_HYPERCALL_H
+
+#include <xen/interface/xen.h>
+#include <xen/interface/physdev.h>
+#include <xen/interface/sched.h>
+#include <asm/xen/xcom_hcall.h>
+struct xencomm_handle;
+extern unsigned long __hypercall(unsigned long a1, unsigned
long a2,
+				 unsigned long a3, unsigned long a4,
+				 unsigned long a5, unsigned long cmd);
+
+/*
+ * Assembler stubs for hyper-calls.
+ */
+
+#define _hypercall0(type, name)					
+({								
+	long __res;						
+	__res = __hypercall(0, 0, 0, 0, 0, __HYPERVISOR_##name);
+	(type)__res;						
+})
+
+#define _hypercall1(type, name, a1)				
+({								
+	long __res;						
+	__res = __hypercall((unsigned long)a1,			
+			     0, 0, 0, 0, __HYPERVISOR_##name);	
+	(type)__res;						
+})
+
+#define _hypercall2(type, name, a1, a2)				
+({								
+	long __res;						
+	__res = __hypercall((unsigned long)a1,			
+			    (unsigned long)a2,			
+			    0, 0, 0, __HYPERVISOR_##name);	
+	(type)__res;						
+})
+
+#define _hypercall3(type, name, a1, a2, a3)			
+({								
+	long __res;						
+	__res = __hypercall((unsigned long)a1,			
+			    (unsigned long)a2,			
+			    (unsigned long)a3,			
+			    0, 0, __HYPERVISOR_##name);		
+	(type)__res;						
+})
+
+#define _hypercall4(type, name, a1, a2, a3, a4)			
+({								
+	long __res;						
+	__res = __hypercall((unsigned long)a1,			
+			    (unsigned long)a2,			
+			    (unsigned long)a3,			
+			    (unsigned long)a4,			
+			    0, __HYPERVISOR_##name);		
+	(type)__res;						
+})
+
+#define _hypercall5(type, name, a1, a2, a3, a4, a5)		
+({								
+	long __res;						
+	__res = __hypercall((unsigned long)a1,			
+			    (unsigned long)a2,			
+			    (unsigned long)a3,			
+			    (unsigned long)a4,			
+			    (unsigned long)a5,			
+			    __HYPERVISOR_##name);		
+	(type)__res;						
+})
+
+
+static inline int
+xencomm_arch_hypercall_sched_op(int cmd, struct
xencomm_handle *arg)
+{
+	return _hypercall2(int, sched_op_new, cmd, arg);
+}
+
+static inline long
+HYPERVISOR_set_timer_op(u64 timeout)
+{
+	unsigned long timeout_hi = (unsigned long)(timeout
>> 32);
+	unsigned long timeout_lo = (unsigned long)timeout;
+	return _hypercall2(long, set_timer_op, timeout_lo,
timeout_hi);
+}
+
+static inline int
+xencomm_arch_hypercall_multicall(struct xencomm_handle
*call_list,
+				 int nr_calls)
+{
+	return _hypercall2(int, multicall, call_list, nr_calls);
+}
+
+static inline int
+xencomm_arch_hypercall_memory_op(unsigned int cmd, struct
xencomm_handle *arg)
+{
+	return _hypercall2(int, memory_op, cmd, arg);
+}
+
+static inline int
+xencomm_arch_hypercall_event_channel_op(int cmd, struct
xencomm_handle *arg)
+{
+	return _hypercall2(int, event_channel_op, cmd, arg);
+}
+
+static inline int
+xencomm_arch_hypercall_xen_version(int cmd, struct
xencomm_handle *arg)
+{
+	return _hypercall2(int, xen_version, cmd, arg);
+}
+
+static inline int
+xencomm_arch_hypercall_console_io(int cmd, int count,
+				  struct xencomm_handle *str)
+{
+	return _hypercall3(int, console_io, cmd, count, str);
+}
+
+static inline int
+xencomm_arch_hypercall_physdev_op(int cmd, struct
xencomm_handle *arg)
+{
+	return _hypercall2(int, physdev_op, cmd, arg);
+}
+
+static inline int
+xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
+				      struct xencomm_handle *uop,
+				      unsigned int count)
+{
+	return _hypercall3(int, grant_table_op, cmd, uop, count);
+}
+
+int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop,
unsigned int count);
+
+extern int xencomm_arch_hypercall_suspend(struct
xencomm_handle *arg);
+
+static inline int
+xencomm_arch_hypercall_callback_op(int cmd, struct
xencomm_handle *arg)
+{
+	return _hypercall2(int, callback_op, cmd, arg);
+}
+
+static inline long
+xencomm_arch_hypercall_vcpu_op(int cmd, int cpu, void
*arg)
+{
+	return _hypercall3(long, vcpu_op, cmd, cpu, arg);
+}
+
+static inline int
+HYPERVISOR_physdev_op(int cmd, void *arg)
+{
+	switch (cmd) {
+	case PHYSDEVOP_eoi:
+		return _hypercall1(int, ia64_fast_eoi,
+				   ((struct physdev_eoi *)arg)->irq);
+	default:
+		return xencomm_hypercall_physdev_op(cmd, arg);
+	}
+}
+
+static inline long
+xencomm_arch_hypercall_opt_feature(struct xencomm_handle
*arg)
+{
+	return _hypercall1(long, opt_feature, arg);
+}
+
+/* for balloon driver */
+#define HYPERVISOR_update_va_mapping(va, new_val, flags)
(0)
+
+/* Use xencomm to do hypercalls.  */
+#define HYPERVISOR_sched_op xencomm_hypercall_sched_op
+#define HYPERVISOR_event_channel_op
xencomm_hypercall_event_channel_op
+#define HYPERVISOR_callback_op
xencomm_hypercall_callback_op
+#define HYPERVISOR_multicall xencomm_hypercall_multicall
+#define HYPERVISOR_xen_version
xencomm_hypercall_xen_version
+#define HYPERVISOR_console_io xencomm_hypercall_console_io
+#define HYPERVISOR_memory_op xencomm_hypercall_memory_op
+#define HYPERVISOR_suspend xencomm_hypercall_suspend
+#define HYPERVISOR_vcpu_op xencomm_hypercall_vcpu_op
+#define HYPERVISOR_opt_feature
xencomm_hypercall_opt_feature
+
+/* to compile gnttab_copy_grant_page() in
drivers/xen/core/gnttab.c */
+#define HYPERVISOR_mmu_update(req, count, success_count,
domid) ({ BUG(); 0; })
+
+static inline int
+HYPERVISOR_shutdown(
+	unsigned int reason)
+{
+	struct sched_shutdown sched_shutdown = {
+		.reason = reason
+	};
+
+	int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown,
&sched_shutdown);
+
+	return rc;
+}
+
+/* for netfront.c, netback.c */
+#define MULTI_UVMFLAGS_INDEX 0 /* XXX any value */
+
+static inline void
+MULTI_update_va_mapping(
+	struct multicall_entry *mcl, unsigned long va,
+	pte_t new_val, unsigned long flags)
+{
+	mcl->op = __HYPERVISOR_update_va_mapping;
+	mcl->result = 0;
+}
+
+static inline void
+MULTI_grant_table_op(struct multicall_entry *mcl, unsigned
int cmd,
+	void *uop, unsigned int count)
+{
+	mcl->op = __HYPERVISOR_grant_table_op;
+	mcl->args[0] = cmd;
+	mcl->args[1] = (unsigned long)uop;
+	mcl->args[2] = count;
+}
+
+static inline void
+MULTI_mmu_update(struct multicall_entry *mcl, struct
mmu_update *req,
+		 int count, int *success_count, domid_t domid)
+{
+	mcl->op = __HYPERVISOR_mmu_update;
+	mcl->args[0] = (unsigned long)req;
+	mcl->args[1] = count;
+	mcl->args[2] = (unsigned long)success_count;
+	mcl->args[3] = domid;
+}
+
+#endif /* _ASM_IA64_XEN_HYPERCALL_H */
diff --git a/include/asm-ia64/xen/privop.h
b/include/asm-ia64/xen/privop.h
new file mode 100644
index 0000000..71ec754
--- /dev/null
+++ b/include/asm-ia64/xen/privop.h
 -0,0
+1,129 
+#ifndef _ASM_IA64_XEN_PRIVOP_H
+#define _ASM_IA64_XEN_PRIVOP_H
+
+/*
+ * Copyright (C) 2005 Hewlett-Packard Co
+ *	Dan Magenheimer <dan.magenheimerhp.com>
+ *
+ * Paravirtualizations of privileged operations for
Xen/ia64
+ *
+ *
+ * inline privop and paravirt_alt support
+ * Copyright (c) 2007 Isaku Yamahata <yamahata at
valinux co jp>
+ *                    VA Linux Systems Japan K.K.
+ *
+ */
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>		/* arch-ia64.h requires
uint64_t */
+#endif
+#include <asm/xen/interface.h>
+
+/* At 1 MB, before per-cpu space but still addressable
using addl instead
+   of movl. */
+#define XSI_BASE			0xfffffffffff00000
+
+/* Address of mapped regs.  */
+#define XMAPPEDREGS_BASE		(XSI_BASE + XSI_SIZE)
+
+#ifdef __ASSEMBLY__
+#define XEN_HYPER_RFI			break HYPERPRIVOP_RFI
+#define XEN_HYPER_RSM_PSR_DT		break HYPERPRIVOP_RSM_DT
+#define XEN_HYPER_SSM_PSR_DT		break HYPERPRIVOP_SSM_DT
+#define XEN_HYPER_COVER			break HYPERPRIVOP_COVER
+#define XEN_HYPER_ITC_D			break HYPERPRIVOP_ITC_D
+#define XEN_HYPER_ITC_I			break HYPERPRIVOP_ITC_I
+#define XEN_HYPER_SSM_I			break HYPERPRIVOP_SSM_I
+#define XEN_HYPER_GET_IVR		break HYPERPRIVOP_GET_IVR
+#define XEN_HYPER_THASH			break HYPERPRIVOP_THASH
+#define XEN_HYPER_ITR_D			break HYPERPRIVOP_ITR_D
+#define XEN_HYPER_SET_KR		break HYPERPRIVOP_SET_KR
+#define XEN_HYPER_GET_PSR		break HYPERPRIVOP_GET_PSR
+#define XEN_HYPER_SET_RR0_TO_RR4	break
HYPERPRIVOP_SET_RR0_TO_RR4
+
+#define XSI_IFS				(XSI_BASE + XSI_IFS_OFS)
+#define XSI_PRECOVER_IFS		(XSI_BASE +
XSI_PRECOVER_IFS_OFS)
+#define XSI_IFA				(XSI_BASE + XSI_IFA_OFS)
+#define XSI_ISR				(XSI_BASE + XSI_ISR_OFS)
+#define XSI_IIM				(XSI_BASE + XSI_IIM_OFS)
+#define XSI_ITIR			(XSI_BASE + XSI_ITIR_OFS)
+#define XSI_PSR_I_ADDR			(XSI_BASE + XSI_PSR_I_ADDR_OFS)
+#define XSI_PSR_IC			(XSI_BASE + XSI_PSR_IC_OFS)
+#define XSI_IPSR			(XSI_BASE + XSI_IPSR_OFS)
+#define XSI_IIP				(XSI_BASE + XSI_IIP_OFS)
+#define XSI_B1NAT			(XSI_BASE + XSI_B1NATS_OFS)
+#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)
+#endif
+
+#ifndef __ASSEMBLY__
+
+/************************************************/
+/* Instructions paravirtualized for correctness */
+/************************************************/
+
+/* "fc" and "thash" are
privilege-sensitive instructions, meaning they
+ *  may have different semantics depending on whether they
are executed
+ *  at PL0 vs PL!=0.  When paravirtualized, these
instructions mustn't
+ *  be allowed to execute directly, lest incorrect
semantics result. */
+extern void xen_fc(unsigned long addr);
+extern unsigned long xen_thash(unsigned long addr);
+
+/* Note that "ttag" and "cover" are
also privilege-sensitive; "ttag"
+ * is not currently used (though it may be in a long-format
VHPT system!)
+ * and the semantics of cover only change if psr.ic is off
which is very
+ * rare (and currently non-existent outside of assembly
code */
+
+/* There are also privilege-sensitive registers.  These
registers are
+ * readable at any privilege level but only writable at
PL0. */
+extern unsigned long xen_get_cpuid(int index);
+extern unsigned long xen_get_pmd(int index);
+
+extern unsigned long xen_get_eflag(void);	/* see
xen_ia64_getreg */
+extern void xen_set_eflag(unsigned long);	/* see
xen_ia64_setreg */
+
+/************************************************/
+/* Instructions paravirtualized for performance */
+/************************************************/
+
+/* Xen uses memory-mapped virtual privileged registers for
access to many
+ * performance-sensitive privileged registers.  Some, like
the processor
+ * status register (psr), are broken up into multiple
memory locations.
+ * Others, like "pend", are abstractions based on
privileged registers.
+ * "Pend" is guaranteed to be set if reading
cr.ivr would return a
+ * (non-spurious) interrupt. */
+#define XEN_MAPPEDREGS ((struct mapped_regs
*)XMAPPEDREGS_BASE)
+
+#define XSI_PSR_I			
+	(*XEN_MAPPEDREGS->interrupt_mask_addr)
+#define xen_get_virtual_psr_i()		
+	(!XSI_PSR_I)
+#define xen_set_virtual_psr_i(_val)	
+	({ XSI_PSR_I = (uint8_t)(_val) ? 0 : 1; })
+#define xen_set_virtual_psr_ic(_val)	
+	({ XEN_MAPPEDREGS->interrupt_collection_enabled = _val
? 1 : 0; })
+#define xen_get_virtual_pend()		
+	(*(((uint8_t *)XEN_MAPPEDREGS->interrupt_mask_addr) -
1))
+
+/* Although all privileged operations can be left to trap
and will
+ * be properly handled by Xen, some are frequent enough
that we use
+ * hyperprivops for performance. */
+extern unsigned long xen_get_psr(void);
+extern unsigned long xen_get_ivr(void);
+extern unsigned long xen_get_tpr(void);
+extern void xen_hyper_ssm_i(void);
+extern void xen_set_itm(unsigned long);
+extern void xen_set_tpr(unsigned long);
+extern void xen_eoi(unsigned long);
+extern unsigned long xen_get_rr(unsigned long index);
+extern void xen_set_rr(unsigned long index, unsigned long
val);
+extern void xen_set_rr0_to_rr4(unsigned long val0, unsigned
long val1,
+			       unsigned long val2, unsigned long val3,
+			       unsigned long val4);
+extern void xen_set_kr(unsigned long index, unsigned long
val);
+extern void xen_ptcga(unsigned long addr, unsigned long
size);
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* _ASM_IA64_XEN_PRIVOP_H */
-- 
1.5.3


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

ia64/xen: implement arch specific part of xen grant table.
user name
2008-06-10 02:47:07
Xen implements grant tables which is for sharing pages with
guest domains.
This patch implements arch specific part of grant table
initialization.
and xen_alloc_vm_area()/xen_free_vm_area() which are helper
functions
for xen grant table.

Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile             |    2 +-
 arch/ia64/xen/grant-table.c        |  155
++++++++++++++++++++++++++++++++++++
 include/asm-ia64/xen/grant_table.h |   29 +++++++
 3 files changed, 185 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/grant-table.c
 create mode 100644 include/asm-ia64/xen/grant_table.h

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index ae08822..eb59563 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -2,4
+2,4 
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xencomm.o xcom_hcall.o
+obj-y := hypercall.o xencomm.o xcom_hcall.o grant-table.o
diff --git a/arch/ia64/xen/grant-table.c
b/arch/ia64/xen/grant-table.c
new file mode 100644
index 0000000..777dd9a
--- /dev/null
+++ b/arch/ia64/xen/grant-table.c
 -0,0
+1,155 
+/**********************************************************
********************
+ * arch/ia64/xen/grant-table.c
+ *
+ * Copyright (c) 2006 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/module.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+
+#include <xen/interface/xen.h>
+#include <xen/interface/memory.h>
+#include <xen/grant_table.h>
+
+#include <asm/xen/hypervisor.h>
+
+struct vm_struct *xen_alloc_vm_area(unsigned long size)
+{
+	int order;
+	unsigned long virt;
+	unsigned long nr_pages;
+	struct vm_struct *area;
+
+	order = get_order(size);
+	virt = __get_free_pages(GFP_KERNEL, order);
+	if (virt == 0)
+		goto err0;
+	nr_pages = 1 << order;
+	scrub_pages(virt, nr_pages);
+
+	area = kmalloc(sizeof(*area), GFP_KERNEL);
+	if (area == NULL)
+		goto err1;
+
+	area->flags = VM_IOREMAP;
+	area->addr = (void *)virt;
+	area->size = size;
+	area->pages = NULL;
+	area->nr_pages = nr_pages;
+	area->phys_addr = 0;	/* xenbus_map_ring_valloc uses
this field!  */
+
+	return area;
+
+err1:
+	free_pages(virt, order);
+err0:
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(xen_alloc_vm_area);
+
+void xen_free_vm_area(struct vm_struct *area)
+{
+	unsigned int order = get_order(area->size);
+	unsigned long i;
+	unsigned long phys_addr = __pa(area->addr);
+
+	/* This area is used for foreign page mappping.
+	 * So underlying machine page may not be assigned. */
+	for (i = 0; i < (1 << order); i++) {
+		unsigned long ret;
+		unsigned long gpfn = (phys_addr >> PAGE_SHIFT) +
i;
+		struct xen_memory_reservation reservation = {
+			.nr_extents   = 1,
+			.address_bits = 0,
+			.extent_order = 0,
+			.domid        = DOMID_SELF
+		};
+		set_xen_guest_handle(reservation.extent_start,
&gpfn);
+		ret = HYPERVISOR_memory_op(XENMEM_populate_physmap,
+					   &reservation);
+		BUG_ON(ret != 1);
+	}
+	free_pages((unsigned long)area->addr, order);
+	kfree(area);
+}
+EXPORT_SYMBOL_GPL(xen_free_vm_area);
+
+
+/**********************************************************
******************
+ * grant table hack
+ * cmd: GNTTABOP_xxx
+ */
+
+int arch_gnttab_map_shared(unsigned long *frames, unsigned
long nr_gframes,
+			   unsigned long max_nr_gframes,
+			   struct grant_entry **__shared)
+{
+	*__shared = __va(frames[0] << PAGE_SHIFT);
+	return 0;
+}
+
+void arch_gnttab_unmap_shared(struct grant_entry *shared,
+			      unsigned long nr_gframes)
+{
+	/* nothing */
+}
+
+static void
+gnttab_map_grant_ref_pre(struct gnttab_map_grant_ref *uop)
+{
+	uint32_t flags;
+
+	flags = uop->flags;
+
+	if (flags & GNTMAP_host_map) {
+		if (flags & GNTMAP_application_map) {
+			printk(KERN_DEBUG
+			       "GNTMAP_application_map is not supported
yet: "
+			       "flags 0x%xn", flags);
+			BUG();
+		}
+		if (flags & GNTMAP_contains_pte) {
+			printk(KERN_DEBUG
+			       "GNTMAP_contains_pte is not supported yet:
"
+			       "flags 0x%xn", flags);
+			BUG();
+		}
+	} else if (flags & GNTMAP_device_map) {
+		printk("GNTMAP_device_map is not supported yet
0x%xn", flags);
+		BUG();	/* not yet. actually this flag is not used. */
+	} else {
+		BUG();
+	}
+}
+
+int
+HYPERVISOR_grant_table_op(unsigned int cmd, void *uop,
unsigned int count)
+{
+	if (cmd == GNTTABOP_map_grant_ref) {
+		unsigned int i;
+		for (i = 0; i < count; i++) {
+			gnttab_map_grant_ref_pre(
+				(struct gnttab_map_grant_ref *)uop + i);
+		}
+	}
+	return xencomm_hypercall_grant_table_op(cmd, uop, count);
+}
+
+EXPORT_SYMBOL(HYPERVISOR_grant_table_op);
diff --git a/include/asm-ia64/xen/grant_table.h
b/include/asm-ia64/xen/grant_table.h
new file mode 100644
index 0000000..ebdf2ea
--- /dev/null
+++ b/include/asm-ia64/xen/grant_table.h
 -0,0
+1,29 
+/**********************************************************
********************
+ * include/asm-ia64/xen/grant_table.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_GRANT_TABLE_H
+#define _ASM_IA64_XEN_GRANT_TABLE_H
+
+struct vm_struct *xen_alloc_vm_area(unsigned long size);
+void xen_free_vm_area(struct vm_struct *area);
+
+#endif /* _ASM_IA64_XEN_GRANT_TABLE_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: define xen pv_init_ops for various xen initializatio
user name
2008-06-10 02:47:10
This patch implements xen version of pv_init_ops to do
various
xen initialization.
This patch includes ia64 counter part of
9e124fe16ff24746d6de5a2ad685266d7bce0e08 and
83abc70a4c6e306f4c1672e25884322f797e4fcb for xen early
printk support.

Signed-off-by: Akio Takebe <takebe_akiojp.fujitsu.com>
Signed-off-by: Alex Williamson <alex.williamsonhp.com>
Signed-off-by: Yaozu (Eddie) Dong <eddie.dongintel.com>
Signed-off-by: Isaku Yamahata <yamahatavalinux.co.jp>
---
 arch/ia64/xen/Makefile            |    2 +-
 arch/ia64/xen/hypervisor.c        |   96
++++++++++++++++++++++++++++++++
 arch/ia64/xen/xen_pv_ops.c        |  110
+++++++++++++++++++++++++++++++++++++
 include/asm-ia64/xen/hypervisor.h |   72
++++++++++++++++++++++++
 4 files changed, 279 insertions(+), 1 deletions(-)
 create mode 100644 arch/ia64/xen/hypervisor.c
 create mode 100644 include/asm-ia64/xen/hypervisor.h

diff --git a/arch/ia64/xen/Makefile
b/arch/ia64/xen/Makefile
index abc356f..7cb4247 100644
--- a/arch/ia64/xen/Makefile
+++ b/arch/ia64/xen/Makefile
 -3,4
+3,4 
 #
 
 obj-y := hypercall.o xensetup.o xen_pv_ops.o 
-	xencomm.o xcom_hcall.o grant-table.o
+	 hypervisor.o xencomm.o xcom_hcall.o grant-table.o
diff --git a/arch/ia64/xen/hypervisor.c
b/arch/ia64/xen/hypervisor.c
new file mode 100644
index 0000000..b48595e
--- /dev/null
+++ b/arch/ia64/xen/hypervisor.c
 -0,0
+1,96 
+/**********************************************************
********************
+ * arch/ia64/xen/hypervisor.c
+ *
+ * Copyright (c) 2006 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/efi.h>
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/privop.h>
+
+#include "irq_xen.h"
+
+struct shared_info *HYPERVISOR_shared_info __read_mostly =
+	(struct shared_info *)XSI_BASE;
+EXPORT_SYMBOL(HYPERVISOR_shared_info);
+
+DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
+
+struct start_info *xen_start_info;
+EXPORT_SYMBOL(xen_start_info);
+
+EXPORT_SYMBOL(running_on_xen);
+
+EXPORT_SYMBOL(__hypercall);
+
+/* Stolen from arch/x86/xen/enlighten.c */
+/*
+ * Flag to determine whether vcpu info placement is
available on all
+ * VCPUs.  We assume it is to start with, and then set it
to zero on
+ * the first failure.  This is because it can succeed on
some VCPUs
+ * and not others, since it can involve hypervisor memory
allocation,
+ * or because the guest failed to guarantee all the
appropriate
+ * constraints on all VCPUs (ie buffer can't cross a page
boundary).
+ *
+ * Note that any particular CPU may be using a placed vcpu
structure,
+ * but we can only optimise if the all are.
+ *
+ * 0: not available, 1: available
+ */
+
+static void __init xen_vcpu_setup(int cpu)
+{
+	/*
+	 * WARNING:
+	 * before changing MAX_VIRT_CPUS,
+	 * check that shared_info fits on a page
+	 */
+	BUILD_BUG_ON(sizeof(struct shared_info) > PAGE_SIZE);
+	per_cpu(xen_vcpu, cpu) =
&HYPERVISOR_shared_info->vcpu_info[cpu];
+}
+
+void __init xen_setup_vcpu_info_placement(void)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu)
+		xen_vcpu_setup(cpu);
+}
+
+void __cpuinit
+xen_cpu_init(void)
+{
+	xen_smp_intr_init();
+}
+
+/**********************************************************
****************
+ * opt feature
+ */
+void
+xen_ia64_enable_opt_feature(void)
+{
+	/* Enable region 7 identity map optimizations in Xen */
+	struct xen_ia64_opt_feature optf;
+
+	optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7;
+	optf.on = XEN_IA64_OPTF_ON;
+	optf.pgprot = pgprot_val(PAGE_KERNEL);
+	optf.key = 0;	/* No key on linux. */
+	HYPERVISOR_opt_feature(&optf);
+}
diff --git a/arch/ia64/xen/xen_pv_ops.c
b/arch/ia64/xen/xen_pv_ops.c
index 77db214..433af1a 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
 -54,6
+54,115  xen_info_init(void)
 }
 
 /**********************************************************
*****************
+ * pv_init_ops
+ * initialization hooks.
+ */
+
+static void
+xen_panic_hypercall(struct unw_frame_info *info, void
*arg)
+{
+	current->thread.ksp = (__u64)info->sw - 16;
+	HYPERVISOR_shutdown(SHUTDOWN_crash);
+	/* we're never actually going to get here... */
+}
+
+static int
+xen_panic_event(struct notifier_block *this, unsigned long
event, void *ptr)
+{
+	unw_init_running(xen_panic_hypercall, NULL);
+	/* we're never actually going to get here... */
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block xen_panic_block = {
+	xen_panic_event, NULL, 0 /* try to go last */
+};
+
+static void xen_pm_power_off(void)
+{
+	local_irq_disable();
+	HYPERVISOR_shutdown(SHUTDOWN_poweroff);
+}
+
+static void __init
+xen_banner(void)
+{
+	printk(KERN_INFO
+	       "Running on Xen! pl = %d start_info_pfn=0x%lx
nr_pages=%ld "
+	       "flags=0x%xn",
+	       xen_info.kernel_rpl,
+	       HYPERVISOR_shared_info->arch.start_info_pfn,
+	       xen_start_info->nr_pages,
xen_start_info->flags);
+}
+
+static int __init
+xen_reserve_memory(struct rsvd_region *region)
+{
+	region->start = (unsigned long)__va(
+		(HYPERVISOR_shared_info->arch.start_info_pfn <<
PAGE_SHIFT));
+	region->end   = region->start + PAGE_SIZE;
+	return 1;
+}
+
+static void __init
+xen_arch_setup_early(void)
+{
+	struct shared_info *s;
+	BUG_ON(!is_running_on_xen());
+
+	s = HYPERVISOR_shared_info;
+	xen_start_info = __va(s->arch.start_info_pfn <<
PAGE_SHIFT);
+
+	/* Must be done before any hypercall.  */
+	xencomm_initialize();
+
+	xen_setup_features();
+	/* Register a call for panic conditions. */
+	atomic_notifier_chain_register(&panic_notifier_list,
+				       &xen_panic_block);
+	pm_power_off = xen_pm_power_off;
+
+	xen_ia64_enable_opt_feature();
+}
+
+static void __init
+xen_arch_setup_console(char **cmdline_p)
+{
+	add_preferred_console("xenboot", 0, NULL);
+	add_preferred_console("tty", 0, NULL);
+	/* use hvc_xen */
+	add_preferred_console("hvc", 0, NULL);
+
+#if !defined(CONFIG_VT) || !defined(CONFIG_DUMMY_CONSOLE)
+	conswitchp = NULL;
+#endif
+}
+
+static int __init
+xen_arch_setup_nomca(void)
+{
+	return 1;
+}
+
+static void __init
+xen_post_smp_prepare_boot_cpu(void)
+{
+	xen_setup_vcpu_info_placement();
+}
+
+static const struct pv_init_ops xen_init_ops __initdata =
{
+	.banner = xen_banner,
+
+	.reserve_memory = xen_reserve_memory,
+
+	.arch_setup_early = xen_arch_setup_early,
+	.arch_setup_console = xen_arch_setup_console,
+	.arch_setup_nomca = xen_arch_setup_nomca,
+
+	.post_smp_prepare_boot_cpu =
xen_post_smp_prepare_boot_cpu,
+};
+
+/**********************************************************
*****************
  * pv_ops initialization
  */
 
 -62,4
+171,5  xen_setup_pv_ops(void)
 {
 	xen_info_init();
 	pv_info = xen_info;
+	pv_init_ops = xen_init_ops;
 }
diff --git a/include/asm-ia64/xen/hypervisor.h
b/include/asm-ia64/xen/hypervisor.h
new file mode 100644
index 0000000..a7527c2
--- /dev/null
+++ b/include/asm-ia64/xen/hypervisor.h
 -0,0
+1,72 
+/**********************************************************
********************
+ * hypervisor.h
+ *
+ * Linux-specific hypervisor handling.
+ *
+ * Copyright (c) 2002-2004, K A Fraser
+ *
+ * This program is free software; you can redistribute it
and/or
+ * modify it under the terms of the GNU General Public
License version 2
+ * as published by the Free Software Foundation; or, when
distributed
+ * separately from the Linux kernel or incorporated into
other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any
person obtaining a copy
+ * of this source file (the "Software"), to deal
in the Software without
+ * restriction, including without limitation the rights to
use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell
copies of the Software,
+ * and to permit persons to whom the Software is furnished
to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice
shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _ASM_IA64_XEN_HYPERVISOR_H
+#define _ASM_IA64_XEN_HYPERVISOR_H
+
+#ifdef CONFIG_XEN
+
+#include <linux/init.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/version.h>	/* to compile
feature.c */
+#include <xen/features.h>		/* to comiple
xen-netfront.c */
+#include <asm/xen/hypercall.h>
+
+/* running_on_xen is set before executing any C code by
early_xen_setup */
+extern const int running_on_xen;
+# define is_running_on_xen()			(running_on_xen)
+
+extern struct shared_info *HYPERVISOR_shared_info;
+extern struct start_info *xen_start_info;
+
+void __init xen_setup_vcpu_info_placement(void);
+void force_evtchn_callback(void);
+
+/* for drivers/xen/balloon/balloon.c */
+#ifdef CONFIG_XEN_SCRUB_PAGES
+#define scrub_pages(_p, _n) memset((void *)(_p), 0, (_n)
<< PAGE_SHIFT)
+#else
+#define scrub_pages(_p, _n) ((void)0)
+#endif
+
+/* For setup_arch() in arch/ia64/kernel/setup.c */
+void xen_ia64_enable_opt_feature(void);
+
+#else /* CONFIG_XEN */
+
+#define is_running_on_xen()			(0)
+
+#endif
+
+#define is_initial_xendomain()			(0)
+
+#endif /* _ASM_IA64_XEN_HYPERVISOR_H */
-- 
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 )