diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2008-10-16 22:17:58 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2008-10-17 13:02:21 -0400 |
commit | 080104cd0f708b6bb5a121922801867a29ad63fc (patch) | |
tree | 119f220c954dc731322ff759fcfb5ae0a8836a75 | |
parent | c7fdaf338679f5e0343bfdfa7ae1e2fdb41ff0b1 (diff) |
ia64/pv_ops/xen: elf note based xen startup.
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.he@intel.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | arch/ia64/kernel/asm-offsets.c | 4 | ||||
-rw-r--r-- | arch/ia64/xen/Makefile | 3 | ||||
-rw-r--r-- | arch/ia64/xen/xen_pv_ops.c | 65 | ||||
-rw-r--r-- | arch/ia64/xen/xensetup.S | 83 |
4 files changed, 154 insertions, 1 deletions
diff --git a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c index eaa988baa877..742dbb1d5a4f 100644 --- a/arch/ia64/kernel/asm-offsets.c +++ b/arch/ia64/kernel/asm-offsets.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/mca.h> | 17 | #include <asm/mca.h> |
18 | 18 | ||
19 | #include <asm/xen/interface.h> | 19 | #include <asm/xen/interface.h> |
20 | #include <asm/xen/hypervisor.h> | ||
20 | 21 | ||
21 | #include "../kernel/sigframe.h" | 22 | #include "../kernel/sigframe.h" |
22 | #include "../kernel/fsyscall_gtod_data.h" | 23 | #include "../kernel/fsyscall_gtod_data.h" |
@@ -292,6 +293,9 @@ void foo(void) | |||
292 | #ifdef CONFIG_XEN | 293 | #ifdef CONFIG_XEN |
293 | BLANK(); | 294 | BLANK(); |
294 | 295 | ||
296 | DEFINE(XEN_NATIVE_ASM, XEN_NATIVE); | ||
297 | DEFINE(XEN_PV_DOMAIN_ASM, XEN_PV_DOMAIN); | ||
298 | |||
295 | #define DEFINE_MAPPED_REG_OFS(sym, field) \ | 299 | #define DEFINE_MAPPED_REG_OFS(sym, field) \ |
296 | DEFINE(sym, (XMAPPEDREGS_OFS + offsetof(struct mapped_regs, field))) | 300 | DEFINE(sym, (XMAPPEDREGS_OFS + offsetof(struct mapped_regs, field))) |
297 | 301 | ||
diff --git a/arch/ia64/xen/Makefile b/arch/ia64/xen/Makefile index eb595637a8ca..abc356f0c5da 100644 --- a/arch/ia64/xen/Makefile +++ b/arch/ia64/xen/Makefile | |||
@@ -2,4 +2,5 @@ | |||
2 | # Makefile for Xen components | 2 | # Makefile for Xen components |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := hypercall.o xencomm.o xcom_hcall.o grant-table.o | 5 | obj-y := hypercall.o xensetup.o xen_pv_ops.o \ |
6 | 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 000000000000..77db214b116c --- /dev/null +++ b/arch/ia64/xen/xen_pv_ops.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /****************************************************************************** | ||
2 | * arch/ia64/xen/xen_pv_ops.c | ||
3 | * | ||
4 | * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp> | ||
5 | * VA Linux Systems Japan K.K. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/console.h> | ||
24 | #include <linux/irq.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/pm.h> | ||
27 | |||
28 | #include <asm/xen/hypervisor.h> | ||
29 | #include <asm/xen/xencomm.h> | ||
30 | #include <asm/xen/privop.h> | ||
31 | |||
32 | /*************************************************************************** | ||
33 | * general info | ||
34 | */ | ||
35 | static struct pv_info xen_info __initdata = { | ||
36 | .kernel_rpl = 2, /* or 1: determin at runtime */ | ||
37 | .paravirt_enabled = 1, | ||
38 | .name = "Xen/ia64", | ||
39 | }; | ||
40 | |||
41 | #define IA64_RSC_PL_SHIFT 2 | ||
42 | #define IA64_RSC_PL_BIT_SIZE 2 | ||
43 | #define IA64_RSC_PL_MASK \ | ||
44 | (((1UL << IA64_RSC_PL_BIT_SIZE) - 1) << IA64_RSC_PL_SHIFT) | ||
45 | |||
46 | static void __init | ||
47 | xen_info_init(void) | ||
48 | { | ||
49 | /* Xenified Linux/ia64 may run on pl = 1 or 2. | ||
50 | * determin at run time. */ | ||
51 | unsigned long rsc = ia64_getreg(_IA64_REG_AR_RSC); | ||
52 | unsigned int rpl = (rsc & IA64_RSC_PL_MASK) >> IA64_RSC_PL_SHIFT; | ||
53 | xen_info.kernel_rpl = rpl; | ||
54 | } | ||
55 | |||
56 | /*************************************************************************** | ||
57 | * pv_ops initialization | ||
58 | */ | ||
59 | |||
60 | void __init | ||
61 | xen_setup_pv_ops(void) | ||
62 | { | ||
63 | xen_info_init(); | ||
64 | pv_info = xen_info; | ||
65 | } | ||
diff --git a/arch/ia64/xen/xensetup.S b/arch/ia64/xen/xensetup.S new file mode 100644 index 000000000000..28fed1fcc079 --- /dev/null +++ b/arch/ia64/xen/xensetup.S | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * Support routines for Xen | ||
3 | * | ||
4 | * Copyright (C) 2005 Dan Magenheimer <dan.magenheimer@hp.com> | ||
5 | */ | ||
6 | |||
7 | #include <asm/processor.h> | ||
8 | #include <asm/asmmacro.h> | ||
9 | #include <asm/pgtable.h> | ||
10 | #include <asm/system.h> | ||
11 | #include <asm/paravirt.h> | ||
12 | #include <asm/xen/privop.h> | ||
13 | #include <linux/elfnote.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <xen/interface/elfnote.h> | ||
16 | |||
17 | .section .data.read_mostly | ||
18 | .align 8 | ||
19 | .global xen_domain_type | ||
20 | xen_domain_type: | ||
21 | data4 XEN_NATIVE_ASM | ||
22 | .previous | ||
23 | |||
24 | __INIT | ||
25 | ENTRY(startup_xen) | ||
26 | // Calculate load offset. | ||
27 | // The constant, LOAD_OFFSET, can't be used because the boot | ||
28 | // loader doesn't always load to the LMA specified by the vmlinux.lds. | ||
29 | mov r9=ip // must be the first instruction to make sure | ||
30 | // that r9 = the physical address of startup_xen. | ||
31 | // Usually r9 = startup_xen - LOAD_OFFSET | ||
32 | movl r8=startup_xen | ||
33 | ;; | ||
34 | sub r9=r9,r8 // Usually r9 = -LOAD_OFFSET. | ||
35 | |||
36 | mov r10=PARAVIRT_HYPERVISOR_TYPE_XEN | ||
37 | movl r11=_start | ||
38 | ;; | ||
39 | add r11=r11,r9 | ||
40 | movl r8=hypervisor_type | ||
41 | ;; | ||
42 | add r8=r8,r9 | ||
43 | mov b0=r11 | ||
44 | ;; | ||
45 | st8 [r8]=r10 | ||
46 | br.cond.sptk.many b0 | ||
47 | ;; | ||
48 | END(startup_xen) | ||
49 | |||
50 | ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux") | ||
51 | ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6") | ||
52 | ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") | ||
53 | ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, data8.ua startup_xen - LOAD_OFFSET) | ||
54 | |||
55 | #define isBP p3 // are we the Bootstrap Processor? | ||
56 | |||
57 | .text | ||
58 | |||
59 | GLOBAL_ENTRY(xen_setup_hook) | ||
60 | mov r8=XEN_PV_DOMAIN_ASM | ||
61 | (isBP) movl r9=xen_domain_type;; | ||
62 | (isBP) st4 [r9]=r8 | ||
63 | movl r10=xen_ivt;; | ||
64 | |||
65 | mov cr.iva=r10 | ||
66 | |||
67 | /* Set xsi base. */ | ||
68 | #define FW_HYPERCALL_SET_SHARED_INFO_VA 0x600 | ||
69 | (isBP) mov r2=FW_HYPERCALL_SET_SHARED_INFO_VA | ||
70 | (isBP) movl r28=XSI_BASE;; | ||
71 | (isBP) break 0x1000;; | ||
72 | |||
73 | /* setup pv_ops */ | ||
74 | (isBP) mov r4=rp | ||
75 | ;; | ||
76 | (isBP) br.call.sptk.many rp=xen_setup_pv_ops | ||
77 | ;; | ||
78 | (isBP) mov rp=r4 | ||
79 | ;; | ||
80 | |||
81 | br.ret.sptk.many rp | ||
82 | ;; | ||
83 | END(xen_setup_hook) | ||