ia64/xen-unstable

changeset 18081:4d5de1e4d85a

[IA64] kexec: Define macros for EFI RID

Macros to be called by PAL, SAL and EFI to switch into
and out of EFI RID.

Cc: Tristan Gingold <tgingold@free.fr>
Cc: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: Alex Williamson <alex.williamson@hp.com>
Cc: Aron Griffis <aron@hp.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Tue Jul 22 12:15:02 2008 +0900 (2008-07-22)
parents 400e5d4877ca
children 7ab45f1a6e83
files xen/include/asm-ia64/linux-xen/linux/efi.h xen/include/asm-ia64/mmu_context.h
line diff
     1.1 --- a/xen/include/asm-ia64/linux-xen/linux/efi.h	Fri Jul 18 12:12:41 2008 +0900
     1.2 +++ b/xen/include/asm-ia64/linux-xen/linux/efi.h	Tue Jul 22 12:15:02 2008 +0900
     1.3 @@ -1,6 +1,8 @@
     1.4  #ifndef _LINUX_EFI_H
     1.5  #define _LINUX_EFI_H
     1.6  
     1.7 +#ifndef __ASSEMBLY__
     1.8 +
     1.9  /*
    1.10   * Extensible Firmware Interface
    1.11   * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
    1.12 @@ -408,4 +410,93 @@ struct efi_generic_dev_path {
    1.13  	u16 length;
    1.14  } __attribute ((packed));
    1.15  
    1.16 +#ifdef XEN
    1.17 +/*
    1.18 + * According to xen/arch/ia64/xen/regionreg.c the RID space is broken up
    1.19 + * into large-blocks. Each block belongs to a domain, except 0th block,
    1.20 + * which is broken up into small-blocks. The small-blocks are used for
    1.21 + * metaphysical mappings, again one per domain, except for the 0th
    1.22 + * small-block which is unused other than very early on in the
    1.23 + * hypervisor boot.
    1.24 + *
    1.25 + * By default each large-block is 18 bits wide, which is also the minimum
    1.26 + * allowed width for a block. Each small-block is by default 1/64 the width
    1.27 + * of a large-block, which is the maximum division allowed. In other words
    1.28 + * each small-block is at least 12 bits wide.
    1.29 + *
    1.30 + * The portion of the 0th small-block that is used early on during
    1.31 + * the hypervisor boot relates to IA64_REGION_ID_KERNEL, which is
    1.32 + * used to form an RID using the following scheme which seems to be
    1.33 + * have been inherited from Linux:
    1.34 + *
    1.35 + * a: bits 0-2: Region Number (0-7)
    1.36 + * b: 3-N:      IA64_REGION_ID_KERNEL (0)
    1.37 + * c: N-23:     reserved (0)
    1.38 + *
    1.39 + * N is defined by the platform.
    1.40 + *
    1.41 + * For EFI we use the following RID:
    1.42 + *
    1.43 + * a: bits 0-2:  Region Number (0-7)
    1.44 + * e: bits 3-N:  IA64_REGION_ID_KERNEL (1)
    1.45 + * f: bits N-53: reserved (0)
    1.46 + *
    1.47 + * + Only 0 is used as we only need one RID. Its not really important
    1.48 + *   what this number is, so long as its between 0 and 7.
    1.49 + *
    1.50 + * The nice thing about this is that we are only using 4 bits of RID
    1.51 + * space, so it shouldn't have any chance of running into an adjacent
    1.52 + * small-block since small-blocks are at least 12 bits wide.
    1.53 + *
    1.54 + * It would actually be possible to just use a IA64_REGION_ID_KERNEL
    1.55 + * based RID for EFI use. The important thing is that it is in the 0th
    1.56 + * small block, and thus not available to domains. But as we have
    1.57 + * lots of space, its seems to be nice and clean to just use a separate
    1.58 + * RID for EFI.
    1.59 + *
    1.60 + * This can be trivially changed by updating the definition of XEN_EFI_RR.
    1.61 + *
    1.62 + * For reference, the RID is used to produce the value inserted
    1.63 + * in to a region register in the following way:
    1.64 + *
    1.65 + * A: bit 0:     VHPT (0 = off, 1 = on)
    1.66 + * B: bit 1:     reserved (0)
    1.67 + * C: bits 2-7:  log 2 page_size
    1.68 + * D: bits 8-N:  RID
    1.69 + * E: bits N-53: reserved (0)
    1.70 + */
    1.71 +
    1.72 +#define XEN_EFI_RR_ENTER(rr6, rr7) do {			\
    1.73 +	rr6 = ia64_get_rr(6UL << 61);			\
    1.74 +	rr7 = ia64_get_rr(7UL << 61);			\
    1.75 +	set_one_rr_efi(6UL << 61, XEN_EFI_RR);		\
    1.76 +	set_one_rr_efi(7UL << 61, XEN_EFI_RR);		\
    1.77 +} while (0)
    1.78 +
    1.79 +#define XEN_EFI_RR_LEAVE(rr6, rr7) do {			\
    1.80 +	set_one_rr_efi(6UL << 61, rr6);			\
    1.81 +	set_one_rr_efi(7UL << 61, rr7);			\
    1.82 +} while (0)
    1.83 +
    1.84 +#else
    1.85 +/* Just use rr6 and rr7 in a dummy fashion here to get
    1.86 + * rid of compiler warnings - a better solution should
    1.87 + * be found if this code is ever actually used */
    1.88 +#define XEN_EFI_RR_ENTER(rr6, rr7)	do { rr6 = 0; rr7 = 0; } while (0)
    1.89 +#define XEN_EFI_RR_LEAVE(rr6, rr7)	do {} while (0)
    1.90 +#endif /* XEN */
    1.91 +
    1.92 +#define XEN_EFI_RR_DECLARE(rr6, rr7)	unsigned long rr6, rr7;
    1.93 +
    1.94 +#endif /* !__ASSEMBLY__ */
    1.95 +
    1.96 +#ifdef XEN
    1.97 +#include <asm/mmu_context.h> /* For IA64_REGION_ID_EFI and ia64_rid() */
    1.98 +#include <asm/pgtable.h>     /* IA64_GRANULE_SHIFT */
    1.99 +#define XEN_EFI_REGION_NO __IA64_UL_CONST(0)
   1.100 +#define XEN_EFI_RR ((ia64_rid(XEN_IA64_REGION_ID_EFI,			\
   1.101 +			      XEN_EFI_REGION_NO) << 8) |		\
   1.102 +		    (IA64_GRANULE_SHIFT << 2))
   1.103 +#endif /* XEN */
   1.104 +
   1.105  #endif /* _LINUX_EFI_H */
     2.1 --- a/xen/include/asm-ia64/mmu_context.h	Fri Jul 18 12:12:41 2008 +0900
     2.2 +++ b/xen/include/asm-ia64/mmu_context.h	Tue Jul 22 12:15:02 2008 +0900
     2.3 @@ -3,6 +3,7 @@
     2.4  //dummy file to resolve non-arch-indep include
     2.5  #ifdef XEN
     2.6  #define IA64_REGION_ID_KERNEL 0
     2.7 +#define XEN_IA64_REGION_ID_EFI 1
     2.8  #define ia64_rid(ctx,addr)	(((ctx) << 3) | (addr >> 61))
     2.9  
    2.10  #ifndef __ASSEMBLY__