This patch enables elf note based xen startup for IA-64, which gives the
kernel an early hint for running on xen instead of relying on psr.cpl.
It is also an extension for possible support of future hypervisors.
Signed-off-by: Qing He <qing.he@xxxxxxxxx>
--
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 2f8d770..aa257b2 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -31,6 +31,8 @@
#include <asm/ptrace.h>
#include <asm/system.h>
#include <asm/mca_asm.h>
+#include <linux/init.h>
+#include <linux/linkage.h>
#ifdef CONFIG_HOTPLUG_CPU
#define SAL_PSR_BITS_TO_SET \
@@ -367,10 +369,40 @@ start_ap:
;;
(isBP) st8 [r2]=r28 // save the address of the boot param
area passed by the bootloader
-#ifdef CONFIG_XEN
- // Note: isBP is used by the subprogram.
- br.call.sptk.many rp=early_xen_setup
+#ifdef CONFIG_PARAVIRT
+
+ movl r14=hypervisor_setup_hooks
+ movl r15=hypervisor_type
+ mov r16=num_hypervisor_hooks
+ ;;
+ ld8 r2=[r15]
+ ;;
+ cmp.ltu p7,p0=r2,r16
+ shladd r8=r2,3,r14
+ ;;
+ cmp.ne.and p7,p0=r2,r0 // no actual branch to
default_setup_hook
+ ld8 r9=[r8]
+ ;;
+ mov b1=r9
;;
+(p7) br.call.sptk.many rp=b1
+
+ .weak xen_setup_hook
+
+ __INITDATA
+
+ .global hypervisor_type
+hypervisor_type:
+ data8 0
+
+ // must have the same order with PARAVIRT_HYPERVISOR_TYPE_xxx
+
+hypervisor_setup_hooks:
+ data8 0 //default_setup_hook
+ data8 xen_setup_hook
+num_hypervisor_hooks = (. - hypervisor_setup_hooks) / 8
+ .previous
+
#endif
#ifdef CONFIG_SMP
diff --git a/arch/ia64/xen/xensetup.S b/arch/ia64/xen/xensetup.S
index 43608b2..169bbf8 100644
--- a/arch/ia64/xen/xensetup.S
+++ b/arch/ia64/xen/xensetup.S
@@ -6,7 +6,15 @@
#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>
+
+#define LOAD_OFFSET (KERNEL_START - KERNEL_TR_PAGE_SIZE)
.section .data.read_mostly
.align 8
@@ -15,16 +23,35 @@ running_on_xen:
data4 0
.previous
+ __INIT
+ENTRY(startup_xen)
+ mov r10=PARAVIRT_HYPERVISOR_TYPE_XEN
+ movl r9=0-LOAD_OFFSET
+ 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(early_xen_setup)
- mov r8=ar.rsc // Initialized in head.S
-(isBP) movl r9=running_on_xen;;
- extr.u r8=r8,2,2;; // Extract pl fields
- cmp.eq p7,p0=r8,r0 // p7: !running on xen
+
+GLOBAL_ENTRY(xen_setup_hook)
mov r8=1 // booleanize.
-(p7) br.ret.sptk.many rp;;
+(isBP) movl r9=running_on_xen;;
(isBP) st4 [r9]=r8
movl r10=xen_ivt;;
@@ -46,4 +73,4 @@ GLOBAL_ENTRY(early_xen_setup)
br.ret.sptk.many rp
;;
-END(early_xen_setup)
+END(xen_setup_hook)
diff --git a/include/asm-ia64/paravirt.h b/include/asm-ia64/paravirt.h
index 44017c1..1b4df12 100644
--- a/include/asm-ia64/paravirt.h
+++ b/include/asm-ia64/paravirt.h
@@ -26,6 +26,9 @@
#ifdef CONFIG_PARAVIRT_GUEST
+#define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
+#define PARAVIRT_HYPERVISOR_TYPE_XEN 1
+
#ifndef __ASSEMBLY__
#include <asm/hw_irq.h>
linux-xen-ia64-note-based-startup.patch
Description: linux-xen-ia64-note-based-startup.patch
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
|