ia64/xen-unstable

changeset 13880:9c88b5f3b4eb

Merge
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Feb 08 13:43:19 2007 +0000 (2007-02-08)
parents 6e74932c9a64 9d103e5fd471
children 16ba1d434f89
files xen/include/asm-ia64/kexec.h xen/include/asm-powerpc/kexec.h xen/include/asm-x86/kexec.h xen/include/asm-x86/x86_32/kexec.h xen/include/asm-x86/x86_64/kexec.h
line diff
     1.1 --- a/xen/arch/powerpc/machine_kexec.c	Thu Feb 08 13:42:49 2007 +0000
     1.2 +++ b/xen/arch/powerpc/machine_kexec.c	Thu Feb 08 13:43:19 2007 +0000
     1.3 @@ -19,6 +19,11 @@ void machine_reboot_kexec(xen_kexec_imag
     1.4      printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
     1.5  }
     1.6  
     1.7 +void machine_kexec(xen_kexec_image_t *image)
     1.8 +{
     1.9 +    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
    1.10 +}
    1.11 +
    1.12  /*
    1.13   * Local variables:
    1.14   * mode: C
     2.1 --- a/xen/arch/x86/crash.c	Thu Feb 08 13:42:49 2007 +0000
     2.2 +++ b/xen/arch/x86/crash.c	Thu Feb 08 13:43:19 2007 +0000
     2.3 @@ -11,7 +11,6 @@
     2.4  #include <asm/atomic.h>
     2.5  #include <asm/elf.h>
     2.6  #include <asm/percpu.h>
     2.7 -#include <asm/kexec.h>
     2.8  #include <xen/types.h>
     2.9  #include <xen/irq.h>
    2.10  #include <asm/ipi.h>
     3.1 --- a/xen/arch/x86/machine_kexec.c	Thu Feb 08 13:42:49 2007 +0000
     3.2 +++ b/xen/arch/x86/machine_kexec.c	Thu Feb 08 13:43:19 2007 +0000
     3.3 @@ -15,11 +15,15 @@
     3.4  #include <xen/types.h>
     3.5  #include <xen/console.h>
     3.6  #include <xen/kexec.h>
     3.7 -#include <asm/kexec.h>
     3.8  #include <xen/domain_page.h>
     3.9  #include <asm/fixmap.h>
    3.10  #include <asm/hvm/hvm.h>
    3.11  
    3.12 +typedef void (*relocate_new_kernel_t)(
    3.13 +                unsigned long indirection_page,
    3.14 +                unsigned long *page_list,
    3.15 +                unsigned long start_address);
    3.16 +
    3.17  int machine_kexec_load(int type, int slot, xen_kexec_image_t *image)
    3.18  {
    3.19      unsigned long prev_ma = 0;
    3.20 @@ -40,8 +44,26 @@ int machine_kexec_load(int type, int slo
    3.21          else
    3.22          {
    3.23              /* Odd pages: va for previous ma. */
    3.24 -            set_fixmap(fix_base + (k >> 1), prev_ma);
    3.25 -            image->page_list[k] = fix_to_virt(fix_base + (k >> 1));
    3.26 +            if ( IS_COMPAT(dom0) )
    3.27 +            {
    3.28 +
    3.29 +                /*
    3.30 +                 * The compatability bounce code sets up a page table
    3.31 +                 * with a 1-1 mapping of the first 1G of memory so
    3.32 +                 * VA==PA here.
    3.33 +                 *
    3.34 +                 * This Linux purgatory code still sets up separate
    3.35 +                 * high and low mappings on the control page (entries
    3.36 +                 * 0 and 1) but it is harmless if they are equal since
    3.37 +                 * that PT is not live at the time.
    3.38 +                 */
    3.39 +                image->page_list[k] = prev_ma;
    3.40 +            }
    3.41 +            else
    3.42 +            {
    3.43 +                set_fixmap(fix_base + (k >> 1), prev_ma);
    3.44 +                image->page_list[k] = fix_to_virt(fix_base + (k >> 1));
    3.45 +            }
    3.46          }
    3.47      }
    3.48  
    3.49 @@ -94,6 +116,31 @@ void machine_reboot_kexec(xen_kexec_imag
    3.50      BUG();
    3.51  }
    3.52  
    3.53 +void machine_kexec(xen_kexec_image_t *image)
    3.54 +{
    3.55 +#ifdef CONFIG_COMPAT
    3.56 +    if ( IS_COMPAT(dom0) )
    3.57 +    {
    3.58 +        extern void compat_machine_kexec(unsigned long rnk,
    3.59 +                                         unsigned long indirection_page,
    3.60 +                                         unsigned long *page_list,
    3.61 +                                         unsigned long start_address);
    3.62 +        compat_machine_kexec(image->page_list[1],
    3.63 +                             image->indirection_page,
    3.64 +                             image->page_list,
    3.65 +                             image->start_address);
    3.66 +    }
    3.67 +    else
    3.68 +#endif
    3.69 +    {
    3.70 +        relocate_new_kernel_t rnk;
    3.71 +
    3.72 +        rnk = (relocate_new_kernel_t) image->page_list[1];
    3.73 +        (*rnk)(image->indirection_page, image->page_list,
    3.74 +               image->start_address);
    3.75 +    }
    3.76 +}
    3.77 +
    3.78  /*
    3.79   * Local variables:
    3.80   * mode: C
     4.1 --- a/xen/arch/x86/x86_64/Makefile	Thu Feb 08 13:42:49 2007 +0000
     4.2 +++ b/xen/arch/x86/x86_64/Makefile	Thu Feb 08 13:43:19 2007 +0000
     4.3 @@ -1,4 +1,5 @@
     4.4  obj-y += entry.o
     4.5 +obj-y += compat_kexec.o
     4.6  obj-y += gpr_switch.o
     4.7  obj-y += mm.o
     4.8  obj-y += traps.o
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xen/arch/x86/x86_64/compat_kexec.S	Thu Feb 08 13:43:19 2007 +0000
     5.3 @@ -0,0 +1,126 @@
     5.4 +/*
     5.5 + * Compatibility kexec handler.
     5.6 + */
     5.7 +
     5.8 +#include <xen/config.h>
     5.9 +
    5.10 +#include <asm/asm_defns.h>
    5.11 +#include <asm/msr.h>
    5.12 +#include <asm/page.h>
    5.13 +
    5.14 +.text
    5.15 +
    5.16 +        .code64
    5.17 +
    5.18 +ENTRY(compat_machine_kexec)
    5.19 +        /* x86/64                        x86/32  */
    5.20 +        /* %rdi - relocate_new_kernel_t  CALL    */
    5.21 +        /* %rsi - indirection page       4(%esp) */
    5.22 +        /* %rdx - page_list              8(%esp) */
    5.23 +        /* %rcx - start address         12(%esp) */
    5.24 +        /*        cpu has pae           16(%esp) */
    5.25 +
    5.26 +        /* Shim the 64 bit page_list into a 32 bit page_list. */
    5.27 +        mov $12,%r9
    5.28 +        lea compat_page_list(%rip), %rbx
    5.29 +1:      dec %r9
    5.30 +        movl (%rdx,%r9,8),%eax
    5.31 +        movl %eax,(%rbx,%r9,4)
    5.32 +        test %r9,%r9
    5.33 +        jnz 1b
    5.34 +
    5.35 +        movq %rbx,%rdx
    5.36 +        mov $__PAGE_OFFSET,%rbx
    5.37 +        sub %rbx, %rdx
    5.38 +
    5.39 +        /*
    5.40 +         * Setup an identity mapped region in PML4[0] of idle page
    5.41 +         * table.
    5.42 +         */
    5.43 +        lea idle_pg_table_l3(%rip),%rax
    5.44 +        sub %rbx,%rax
    5.45 +        or  $0x63,%rax
    5.46 +        mov %rax, idle_pg_table(%rip)
    5.47 +
    5.48 +        /* Switch to idle page table. */
    5.49 +        movq $(idle_pg_table - __PAGE_OFFSET), %rax
    5.50 +        movq %rax, %cr3
    5.51 +
    5.52 +        /* Jump to low identity mapping in compatibility mode. */
    5.53 +        ljmp *compatibility_mode_far(%rip)
    5.54 +        ud2
    5.55 +
    5.56 +compatibility_mode_far:
    5.57 +        .long compatibility_mode - __PAGE_OFFSET
    5.58 +        .long __HYPERVISOR_CS32
    5.59 +
    5.60 +        .code32
    5.61 +
    5.62 +compatibility_mode:
    5.63 +        /* Setup some sane segments. */
    5.64 +        movl $__HYPERVISOR_DS32, %eax
    5.65 +        movl %eax, %ds
    5.66 +        movl %eax, %es
    5.67 +        movl %eax, %fs
    5.68 +        movl %eax, %gs
    5.69 +        movl %eax, %ss
    5.70 +
    5.71 +        /* Push arguments onto stack. */
    5.72 +        pushl $1   /* 16(%esp) - cpu has pae */
    5.73 +        pushl %ecx /* 12(%esp) - start address */
    5.74 +        pushl %edx /*  8(%esp) - page list */
    5.75 +        pushl %esi /*  4(%esp) - indirection page */
    5.76 +        pushl %edi /*  0(%esp) - CALL */
    5.77 +
    5.78 +        /* Disable paging and therefore leave 64 bit mode. */
    5.79 +        movl %cr0, %eax
    5.80 +        andl $~X86_CR0_PG, %eax
    5.81 +        movl %eax, %cr0
    5.82 +
    5.83 +        /* Switch to 32 bit page table. */
    5.84 +        movl  $compat_pg_table - __PAGE_OFFSET, %eax
    5.85 +        movl  %eax, %cr3
    5.86 +
    5.87 +        /* Clear MSR_EFER[LME], disabling long mode */
    5.88 +        movl    $MSR_EFER,%ecx
    5.89 +        rdmsr
    5.90 +        btcl    $_EFER_LME,%eax
    5.91 +        wrmsr
    5.92 +
    5.93 +        /* Re-enable paging, but only 32 bit mode now. */
    5.94 +        movl %cr0, %eax
    5.95 +        orl $X86_CR0_PG, %eax
    5.96 +        movl %eax, %cr0
    5.97 +
    5.98 +        popl %eax
    5.99 +        call *%eax
   5.100 +        ud2
   5.101 +
   5.102 +compat_page_list:
   5.103 +        .fill 12,4,0
   5.104 +
   5.105 +        .align 32,0
   5.106 +
   5.107 +        /*
   5.108 +         * These compat page tables contain an identity mapping of the
   5.109 +         * first 1G of the physical address space.
   5.110 +         */
   5.111 +compat_pg_table:
   5.112 +        .long compat_pg_table_l2 + 0*PAGE_SIZE + 0x01 - __PAGE_OFFSET, 0
   5.113 +        .long 0, 0
   5.114 +        .long 0, 0
   5.115 +        .long 0, 0
   5.116 +
   5.117 +        .align 4096,0
   5.118 +
   5.119 +compat_pg_table_l2:
   5.120 +        .macro identmap from=0, count=512
   5.121 +        .if \count-1
   5.122 +        identmap "(\from+0)","(\count/2)"
   5.123 +        identmap "(\from+(0x200000*(\count/2)))","(\count/2)"
   5.124 +        .else
   5.125 +        .quad 0x00000000000000e3 + \from
   5.126 +        .endif
   5.127 +        .endm
   5.128 +
   5.129 +        identmap
     6.1 --- a/xen/common/kexec.c	Thu Feb 08 13:42:49 2007 +0000
     6.2 +++ b/xen/common/kexec.c	Thu Feb 08 13:43:19 2007 +0000
     6.3 @@ -6,7 +6,6 @@
     6.4   * - Magnus Damm <magnus@valinux.co.jp>
     6.5   */
     6.6  
     6.7 -#include <asm/kexec.h>
     6.8  #include <xen/lib.h>
     6.9  #include <xen/ctype.h>
    6.10  #include <xen/errno.h>
     7.1 --- a/xen/include/asm-ia64/kexec.h	Thu Feb 08 13:42:49 2007 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,25 +0,0 @@
     7.4 -#ifndef __IA64_KEXEC_H__
     7.5 -#define __IA64_KEXEC_H__
     7.6 -
     7.7 -#include <xen/lib.h>       /* for printk() used in stub */
     7.8 -#include <xen/types.h>
     7.9 -#include <public/xen.h>
    7.10 -#include <xen/kexec.h>
    7.11 -
    7.12 -static inline void machine_kexec(xen_kexec_image_t *image)
    7.13 -{
    7.14 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
    7.15 -}
    7.16 -
    7.17 -#endif /* __IA64_KEXEC_H__ */
    7.18 -
    7.19 -/*
    7.20 - * Local variables:
    7.21 - * mode: C
    7.22 - * c-set-style: "BSD"
    7.23 - * c-basic-offset: 4
    7.24 - * tab-width: 4
    7.25 - * indent-tabs-mode: nil
    7.26 - * End:
    7.27 - */
    7.28 -
     8.1 --- a/xen/include/asm-powerpc/kexec.h	Thu Feb 08 13:42:49 2007 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,25 +0,0 @@
     8.4 -#ifndef _ASM_KEXEC_H__
     8.5 -#define _ASM_KEXEC_H__
     8.6 -
     8.7 -#include <xen/lib.h>       /* for printk() used in stub */
     8.8 -#include <xen/types.h>
     8.9 -#include <public/xen.h>
    8.10 -#include <xen/kexec.h>
    8.11 -
    8.12 -static inline void machine_kexec(xen_kexec_image_t *image)
    8.13 -{
    8.14 -    printk("STUB: " __FILE__ ": %s: not implemented\n", __FUNCTION__);
    8.15 -}
    8.16 -
    8.17 -#endif /* _ASM_KEXEC_H__ */
    8.18 -
    8.19 -/*
    8.20 - * Local variables:
    8.21 - * mode: C
    8.22 - * c-set-style: "BSD"
    8.23 - * c-basic-offset: 4
    8.24 - * tab-width: 4
    8.25 - * indent-tabs-mode: nil
    8.26 - * End:
    8.27 - */
    8.28 -
     9.1 --- a/xen/include/asm-x86/config.h	Thu Feb 08 13:42:49 2007 +0000
     9.2 +++ b/xen/include/asm-x86/config.h	Thu Feb 08 13:43:19 2007 +0000
     9.3 @@ -145,9 +145,9 @@
     9.4   * Compatibility guest area layout:
     9.5   *  0x0000000000000000 - 0x00000000f57fffff [3928MB,            PML4:0]
     9.6   *    Guest-defined use.
     9.7 - *  0x0000000f58000000 - 0x00000000ffffffff [168MB,             PML4:0]
     9.8 + *  0x00000000f5800000 - 0x00000000ffffffff [168MB,             PML4:0]
     9.9   *    Read-only machine-to-phys translation table (GUEST ACCESSIBLE).
    9.10 - *  0x0000000000000000 - 0x00000000ffffffff [508GB,             PML4:0]
    9.11 + *  0x0000000100000000 - 0x0000007fffffffff [508GB,             PML4:0]
    9.12   *    Unused.
    9.13   *  0x0000008000000000 - 0x000000ffffffffff [512GB, 2^39 bytes, PML4:1]
    9.14   *    Hypercall argument translation area.
    10.1 --- a/xen/include/asm-x86/kexec.h	Thu Feb 08 13:42:49 2007 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,20 +0,0 @@
    10.4 -#ifndef __X86_KEXEC_H__
    10.5 -#define __X86_KEXEC_H__
    10.6 -
    10.7 -#ifdef __x86_64__
    10.8 -#include <asm/x86_64/kexec.h>
    10.9 -#else
   10.10 -#include <asm/x86_32/kexec.h>
   10.11 -#endif
   10.12 -
   10.13 -#endif /* __X86_KEXEC_H__ */
   10.14 -
   10.15 -/*
   10.16 - * Local variables:
   10.17 - * mode: C
   10.18 - * c-set-style: "BSD"
   10.19 - * c-basic-offset: 4
   10.20 - * tab-width: 4
   10.21 - * indent-tabs-mode: nil
   10.22 - * End:
   10.23 - */
    11.1 --- a/xen/include/asm-x86/x86_32/kexec.h	Thu Feb 08 13:42:49 2007 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,39 +0,0 @@
    11.4 -/******************************************************************************
    11.5 - * kexec.h
    11.6 - * 
    11.7 - * Based heavily on machine_kexec.c and kexec.h from Linux 2.6.19-rc1
    11.8 - *
    11.9 - */
   11.10 -  
   11.11 -#ifndef __X86_KEXEC_X86_32_H__
   11.12 -#define __X86_KEXEC_X86_32_H__
   11.13 -
   11.14 -#include <xen/types.h>
   11.15 -#include <xen/kexec.h>
   11.16 -
   11.17 -typedef asmlinkage void (*relocate_new_kernel_t)(
   11.18 -               unsigned long indirection_page,
   11.19 -               unsigned long page_list,
   11.20 -               unsigned long start_address,
   11.21 -               unsigned int has_pae);
   11.22 -
   11.23 -static inline void machine_kexec(xen_kexec_image_t *image)
   11.24 -{
   11.25 -    relocate_new_kernel_t rnk;
   11.26 -
   11.27 -    rnk = (relocate_new_kernel_t) image->page_list[1];
   11.28 -    (*rnk)(image->indirection_page, (unsigned long)image->page_list, 
   11.29 -           image->start_address, (unsigned long)cpu_has_pae);
   11.30 -}
   11.31 -
   11.32 -#endif /* __X86_KEXEC_X86_32_H__ */
   11.33 -
   11.34 -/*
   11.35 - * Local variables:
   11.36 - * mode: C
   11.37 - * c-set-style: "BSD"
   11.38 - * c-basic-offset: 4
   11.39 - * tab-width: 4
   11.40 - * indent-tabs-mode: nil
   11.41 - * End:
   11.42 - */
    12.1 --- a/xen/include/asm-x86/x86_64/kexec.h	Thu Feb 08 13:42:49 2007 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,38 +0,0 @@
    12.4 -/******************************************************************************
    12.5 - * kexec.h
    12.6 - * 
    12.7 - * Based heavily on machine_kexec.c and kexec.h from Linux 2.6.19-rc1
    12.8 - *
    12.9 - */
   12.10 -
   12.11 -#ifndef __X86_64_KEXEC_H__
   12.12 -#define __X86_64_KEXEC_H__
   12.13 -  
   12.14 -#include <xen/types.h>
   12.15 -#include <xen/kexec.h>
   12.16 -
   12.17 -typedef void (*relocate_new_kernel_t)(
   12.18 -                unsigned long indirection_page,
   12.19 -                unsigned long page_list,
   12.20 -                unsigned long start_address);
   12.21 -
   12.22 -static inline void machine_kexec(xen_kexec_image_t *image)
   12.23 -{
   12.24 -    relocate_new_kernel_t rnk;
   12.25 -
   12.26 -    rnk = (relocate_new_kernel_t) image->page_list[1];
   12.27 -    (*rnk)(image->indirection_page, (unsigned long)image->page_list, 
   12.28 -           image->start_address);
   12.29 -}
   12.30 -
   12.31 -#endif /* __X86_64_KEXEC_H__ */
   12.32 -
   12.33 -/*
   12.34 - * Local variables:
   12.35 - * mode: C
   12.36 - * c-set-style: "BSD"
   12.37 - * c-basic-offset: 4
   12.38 - * tab-width: 4
   12.39 - * indent-tabs-mode: nil
   12.40 - * End:
   12.41 - */
    13.1 --- a/xen/include/xen/kexec.h	Thu Feb 08 13:42:49 2007 +0000
    13.2 +++ b/xen/include/xen/kexec.h	Thu Feb 08 13:43:19 2007 +0000
    13.3 @@ -25,6 +25,7 @@ int machine_kexec_load(int type, int slo
    13.4  void machine_kexec_unload(int type, int slot, xen_kexec_image_t *image);
    13.5  void machine_kexec_reserved(xen_kexec_reserve_t *reservation);
    13.6  void machine_reboot_kexec(xen_kexec_image_t *image);
    13.7 +void machine_kexec(xen_kexec_image_t *image);
    13.8  void kexec_crash(void);
    13.9  void kexec_crash_save_cpu(void);
   13.10  crash_xen_info_t *kexec_crash_save_info(void);