Home | History | Annotate | Line # | Download | only in public
      1  1.1  cherry /******************************************************************************
      2  1.1  cherry  * arch-arm.h
      3  1.1  cherry  *
      4  1.1  cherry  * Guest OS interface to ARM Xen.
      5  1.1  cherry  *
      6  1.1  cherry  * Permission is hereby granted, free of charge, to any person obtaining a copy
      7  1.1  cherry  * of this software and associated documentation files (the "Software"), to
      8  1.1  cherry  * deal in the Software without restriction, including without limitation the
      9  1.1  cherry  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     10  1.1  cherry  * sell copies of the Software, and to permit persons to whom the Software is
     11  1.1  cherry  * furnished to do so, subject to the following conditions:
     12  1.1  cherry  *
     13  1.1  cherry  * The above copyright notice and this permission notice shall be included in
     14  1.1  cherry  * all copies or substantial portions of the Software.
     15  1.1  cherry  *
     16  1.1  cherry  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  cherry  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  cherry  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19  1.1  cherry  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20  1.1  cherry  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     21  1.1  cherry  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     22  1.1  cherry  * DEALINGS IN THE SOFTWARE.
     23  1.1  cherry  *
     24  1.1  cherry  * Copyright 2011 (C) Citrix Systems
     25  1.1  cherry  */
     26  1.1  cherry 
     27  1.1  cherry #ifndef __XEN_PUBLIC_ARCH_ARM_H__
     28  1.1  cherry #define __XEN_PUBLIC_ARCH_ARM_H__
     29  1.1  cherry 
     30  1.1  cherry /*
     31  1.1  cherry  * `incontents 50 arm_abi Hypercall Calling Convention
     32  1.1  cherry  *
     33  1.1  cherry  * A hypercall is issued using the ARM HVC instruction.
     34  1.1  cherry  *
     35  1.1  cherry  * A hypercall can take up to 5 arguments. These are passed in
     36  1.1  cherry  * registers, the first argument in x0/r0 (for arm64/arm32 guests
     37  1.1  cherry  * respectively irrespective of whether the underlying hypervisor is
     38  1.1  cherry  * 32- or 64-bit), the second argument in x1/r1, the third in x2/r2,
     39  1.1  cherry  * the forth in x3/r3 and the fifth in x4/r4.
     40  1.1  cherry  *
     41  1.1  cherry  * The hypercall number is passed in r12 (arm) or x16 (arm64). In both
     42  1.1  cherry  * cases the relevant ARM procedure calling convention specifies this
     43  1.1  cherry  * is an inter-procedure-call scratch register (e.g. for use in linker
     44  1.1  cherry  * stubs). This use does not conflict with use during a hypercall.
     45  1.1  cherry  *
     46  1.1  cherry  * The HVC ISS must contain a Xen specific TAG: XEN_HYPERCALL_TAG.
     47  1.1  cherry  *
     48  1.1  cherry  * The return value is in x0/r0.
     49  1.1  cherry  *
     50  1.1  cherry  * The hypercall will clobber x16/r12 and the argument registers used
     51  1.1  cherry  * by that hypercall (except r0 which is the return value) i.e. in
     52  1.1  cherry  * addition to x16/r12 a 2 argument hypercall will clobber x1/r1 and a
     53  1.1  cherry  * 4 argument hypercall will clobber x1/r1, x2/r2 and x3/r3.
     54  1.1  cherry  *
     55  1.1  cherry  * Parameter structs passed to hypercalls are laid out according to
     56  1.1  cherry  * the Procedure Call Standard for the ARM Architecture (AAPCS, AKA
     57  1.1  cherry  * EABI) and Procedure Call Standard for the ARM 64-bit Architecture
     58  1.1  cherry  * (AAPCS64). Where there is a conflict the 64-bit standard should be
     59  1.1  cherry  * used regardless of guest type. Structures which are passed as
     60  1.1  cherry  * hypercall arguments are always little endian.
     61  1.1  cherry  *
     62  1.1  cherry  * All memory which is shared with other entities in the system
     63  1.1  cherry  * (including the hypervisor and other guests) must reside in memory
     64  1.1  cherry  * which is mapped as Normal Inner Write-Back Outer Write-Back Inner-Shareable.
     65  1.1  cherry  * This applies to:
     66  1.1  cherry  *  - hypercall arguments passed via a pointer to guest memory.
     67  1.1  cherry  *  - memory shared via the grant table mechanism (including PV I/O
     68  1.1  cherry  *    rings etc).
     69  1.1  cherry  *  - memory shared with the hypervisor (struct shared_info, struct
     70  1.1  cherry  *    vcpu_info, the grant table, etc).
     71  1.1  cherry  *
     72  1.1  cherry  * Any cache allocation hints are acceptable.
     73  1.1  cherry  */
     74  1.1  cherry 
     75  1.1  cherry /*
     76  1.1  cherry  * `incontents 55 arm_hcall Supported Hypercalls
     77  1.1  cherry  *
     78  1.1  cherry  * Xen on ARM makes extensive use of hardware facilities and therefore
     79  1.1  cherry  * only a subset of the potential hypercalls are required.
     80  1.1  cherry  *
     81  1.1  cherry  * Since ARM uses second stage paging any machine/physical addresses
     82  1.1  cherry  * passed to hypercalls are Guest Physical Addresses (Intermediate
     83  1.1  cherry  * Physical Addresses) unless otherwise noted.
     84  1.1  cherry  *
     85  1.1  cherry  * The following hypercalls (and sub operations) are supported on the
     86  1.1  cherry  * ARM platform. Other hypercalls should be considered
     87  1.1  cherry  * unavailable/unsupported.
     88  1.1  cherry  *
     89  1.1  cherry  *  HYPERVISOR_memory_op
     90  1.1  cherry  *   All generic sub-operations
     91  1.1  cherry  *
     92  1.1  cherry  *  HYPERVISOR_domctl
     93  1.1  cherry  *   All generic sub-operations, with the exception of:
     94  1.1  cherry  *    * XEN_DOMCTL_irq_permission (not yet implemented)
     95  1.1  cherry  *
     96  1.1  cherry  *  HYPERVISOR_sched_op
     97  1.1  cherry  *   All generic sub-operations, with the exception of:
     98  1.1  cherry  *    * SCHEDOP_block -- prefer wfi hardware instruction
     99  1.1  cherry  *
    100  1.1  cherry  *  HYPERVISOR_console_io
    101  1.1  cherry  *   All generic sub-operations
    102  1.1  cherry  *
    103  1.1  cherry  *  HYPERVISOR_xen_version
    104  1.1  cherry  *   All generic sub-operations
    105  1.1  cherry  *
    106  1.1  cherry  *  HYPERVISOR_event_channel_op
    107  1.1  cherry  *   All generic sub-operations
    108  1.1  cherry  *
    109  1.1  cherry  *  HYPERVISOR_physdev_op
    110  1.1  cherry  *   No sub-operations are currenty supported
    111  1.1  cherry  *
    112  1.1  cherry  *  HYPERVISOR_sysctl
    113  1.1  cherry  *   All generic sub-operations, with the exception of:
    114  1.1  cherry  *    * XEN_SYSCTL_page_offline_op
    115  1.1  cherry  *    * XEN_SYSCTL_get_pmstat
    116  1.1  cherry  *    * XEN_SYSCTL_pm_op
    117  1.1  cherry  *
    118  1.1  cherry  *  HYPERVISOR_hvm_op
    119  1.1  cherry  *   Exactly these sub-operations are supported:
    120  1.1  cherry  *    * HVMOP_set_param
    121  1.1  cherry  *    * HVMOP_get_param
    122  1.1  cherry  *
    123  1.1  cherry  *  HYPERVISOR_grant_table_op
    124  1.1  cherry  *   All generic sub-operations
    125  1.1  cherry  *
    126  1.1  cherry  *  HYPERVISOR_vcpu_op
    127  1.1  cherry  *   Exactly these sub-operations are supported:
    128  1.1  cherry  *    * VCPUOP_register_vcpu_info
    129  1.1  cherry  *    * VCPUOP_register_runstate_memory_area
    130  1.1  cherry  *
    131  1.1  cherry  *
    132  1.1  cherry  * Other notes on the ARM ABI:
    133  1.1  cherry  *
    134  1.1  cherry  * - struct start_info is not exported to ARM guests.
    135  1.1  cherry  *
    136  1.1  cherry  * - struct shared_info is mapped by ARM guests using the
    137  1.1  cherry  *   HYPERVISOR_memory_op sub-op XENMEM_add_to_physmap, passing
    138  1.1  cherry  *   XENMAPSPACE_shared_info as space parameter.
    139  1.1  cherry  *
    140  1.1  cherry  * - All the per-cpu struct vcpu_info are mapped by ARM guests using the
    141  1.1  cherry  *   HYPERVISOR_vcpu_op sub-op VCPUOP_register_vcpu_info, including cpu0
    142  1.1  cherry  *   struct vcpu_info.
    143  1.1  cherry  *
    144  1.1  cherry  * - The grant table is mapped using the HYPERVISOR_memory_op sub-op
    145  1.1  cherry  *   XENMEM_add_to_physmap, passing XENMAPSPACE_grant_table as space
    146  1.1  cherry  *   parameter. The memory range specified under the Xen compatible
    147  1.1  cherry  *   hypervisor node on device tree can be used as target gpfn for the
    148  1.1  cherry  *   mapping.
    149  1.1  cherry  *
    150  1.1  cherry  * - Xenstore is initialized by using the two hvm_params
    151  1.1  cherry  *   HVM_PARAM_STORE_PFN and HVM_PARAM_STORE_EVTCHN. They can be read
    152  1.1  cherry  *   with the HYPERVISOR_hvm_op sub-op HVMOP_get_param.
    153  1.1  cherry  *
    154  1.1  cherry  * - The paravirtualized console is initialized by using the two
    155  1.1  cherry  *   hvm_params HVM_PARAM_CONSOLE_PFN and HVM_PARAM_CONSOLE_EVTCHN. They
    156  1.1  cherry  *   can be read with the HYPERVISOR_hvm_op sub-op HVMOP_get_param.
    157  1.1  cherry  *
    158  1.1  cherry  * - Event channel notifications are delivered using the percpu GIC
    159  1.1  cherry  *   interrupt specified under the Xen compatible hypervisor node on
    160  1.1  cherry  *   device tree.
    161  1.1  cherry  *
    162  1.1  cherry  * - The device tree Xen compatible node is fully described under Linux
    163  1.1  cherry  *   at Documentation/devicetree/bindings/arm/xen.txt.
    164  1.1  cherry  */
    165  1.1  cherry 
    166  1.1  cherry #define XEN_HYPERCALL_TAG   0XEA1
    167  1.1  cherry 
    168  1.1  cherry #define  int64_aligned_t  int64_t __attribute__((aligned(8)))
    169  1.1  cherry #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
    170  1.1  cherry 
    171  1.1  cherry #ifndef __ASSEMBLY__
    172  1.1  cherry #define ___DEFINE_XEN_GUEST_HANDLE(name, type)                  \
    173  1.1  cherry     typedef union { type *p; unsigned long q; }                 \
    174  1.1  cherry         __guest_handle_ ## name;                                \
    175  1.1  cherry     typedef union { type *p; uint64_aligned_t q; }              \
    176  1.1  cherry         __guest_handle_64_ ## name
    177  1.1  cherry 
    178  1.1  cherry /*
    179  1.1  cherry  * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field
    180  1.1  cherry  * in a struct in memory. On ARM is always 8 bytes sizes and 8 bytes
    181  1.1  cherry  * aligned.
    182  1.1  cherry  * XEN_GUEST_HANDLE_PARAM represents a guest pointer, when passed as an
    183  1.1  cherry  * hypercall argument. It is 4 bytes on aarch32 and 8 bytes on aarch64.
    184  1.1  cherry  */
    185  1.1  cherry #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    186  1.1  cherry     ___DEFINE_XEN_GUEST_HANDLE(name, type);   \
    187  1.1  cherry     ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
    188  1.1  cherry #define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
    189  1.1  cherry #define __XEN_GUEST_HANDLE(name)        __guest_handle_64_ ## name
    190  1.1  cherry #define XEN_GUEST_HANDLE(name)          __XEN_GUEST_HANDLE(name)
    191  1.1  cherry #define XEN_GUEST_HANDLE_PARAM(name)    __guest_handle_ ## name
    192  1.1  cherry #define set_xen_guest_handle_raw(hnd, val)                  \
    193  1.1  cherry     do {                                                    \
    194  1.1  cherry         typeof(&(hnd)) _sxghr_tmp = &(hnd);                 \
    195  1.1  cherry         _sxghr_tmp->q = 0;                                  \
    196  1.1  cherry         _sxghr_tmp->p = val;                                \
    197  1.1  cherry     } while ( 0 )
    198  1.1  cherry #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val)
    199  1.1  cherry 
    200  1.1  cherry #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
    201  1.1  cherry /* Anonymous union includes both 32- and 64-bit names (e.g., r0/x0). */
    202  1.1  cherry # define __DECL_REG(n64, n32) union {          \
    203  1.1  cherry         uint64_t n64;                          \
    204  1.1  cherry         uint32_t n32;                          \
    205  1.1  cherry     }
    206  1.1  cherry #else
    207  1.1  cherry /* Non-gcc sources must always use the proper 64-bit name (e.g., x0). */
    208  1.1  cherry #define __DECL_REG(n64, n32) uint64_t n64
    209  1.1  cherry #endif
    210  1.1  cherry 
    211  1.1  cherry struct vcpu_guest_core_regs
    212  1.1  cherry {
    213  1.1  cherry     /*         Aarch64       Aarch32 */
    214  1.1  cherry     __DECL_REG(x0,           r0_usr);
    215  1.1  cherry     __DECL_REG(x1,           r1_usr);
    216  1.1  cherry     __DECL_REG(x2,           r2_usr);
    217  1.1  cherry     __DECL_REG(x3,           r3_usr);
    218  1.1  cherry     __DECL_REG(x4,           r4_usr);
    219  1.1  cherry     __DECL_REG(x5,           r5_usr);
    220  1.1  cherry     __DECL_REG(x6,           r6_usr);
    221  1.1  cherry     __DECL_REG(x7,           r7_usr);
    222  1.1  cherry     __DECL_REG(x8,           r8_usr);
    223  1.1  cherry     __DECL_REG(x9,           r9_usr);
    224  1.1  cherry     __DECL_REG(x10,          r10_usr);
    225  1.1  cherry     __DECL_REG(x11,          r11_usr);
    226  1.1  cherry     __DECL_REG(x12,          r12_usr);
    227  1.1  cherry 
    228  1.1  cherry     __DECL_REG(x13,          sp_usr);
    229  1.1  cherry     __DECL_REG(x14,          lr_usr);
    230  1.1  cherry 
    231  1.1  cherry     __DECL_REG(x15,          __unused_sp_hyp);
    232  1.1  cherry 
    233  1.1  cherry     __DECL_REG(x16,          lr_irq);
    234  1.1  cherry     __DECL_REG(x17,          sp_irq);
    235  1.1  cherry 
    236  1.1  cherry     __DECL_REG(x18,          lr_svc);
    237  1.1  cherry     __DECL_REG(x19,          sp_svc);
    238  1.1  cherry 
    239  1.1  cherry     __DECL_REG(x20,          lr_abt);
    240  1.1  cherry     __DECL_REG(x21,          sp_abt);
    241  1.1  cherry 
    242  1.1  cherry     __DECL_REG(x22,          lr_und);
    243  1.1  cherry     __DECL_REG(x23,          sp_und);
    244  1.1  cherry 
    245  1.1  cherry     __DECL_REG(x24,          r8_fiq);
    246  1.1  cherry     __DECL_REG(x25,          r9_fiq);
    247  1.1  cherry     __DECL_REG(x26,          r10_fiq);
    248  1.1  cherry     __DECL_REG(x27,          r11_fiq);
    249  1.1  cherry     __DECL_REG(x28,          r12_fiq);
    250  1.1  cherry 
    251  1.1  cherry     __DECL_REG(x29,          sp_fiq);
    252  1.1  cherry     __DECL_REG(x30,          lr_fiq);
    253  1.1  cherry 
    254  1.1  cherry     /* Return address and mode */
    255  1.1  cherry     __DECL_REG(pc64,         pc32);             /* ELR_EL2 */
    256  1.1  cherry     uint32_t cpsr;                              /* SPSR_EL2 */
    257  1.1  cherry 
    258  1.1  cherry     union {
    259  1.1  cherry         uint32_t spsr_el1;       /* AArch64 */
    260  1.1  cherry         uint32_t spsr_svc;       /* AArch32 */
    261  1.1  cherry     };
    262  1.1  cherry 
    263  1.1  cherry     /* AArch32 guests only */
    264  1.1  cherry     uint32_t spsr_fiq, spsr_irq, spsr_und, spsr_abt;
    265  1.1  cherry 
    266  1.1  cherry     /* AArch64 guests only */
    267  1.1  cherry     uint64_t sp_el0;
    268  1.1  cherry     uint64_t sp_el1, elr_el1;
    269  1.1  cherry };
    270  1.1  cherry typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t;
    271  1.1  cherry DEFINE_XEN_GUEST_HANDLE(vcpu_guest_core_regs_t);
    272  1.1  cherry 
    273  1.1  cherry #undef __DECL_REG
    274  1.1  cherry 
    275  1.1  cherry typedef uint64_t xen_pfn_t;
    276  1.1  cherry #define PRI_xen_pfn PRIx64
    277  1.1  cherry #define PRIu_xen_pfn PRIu64
    278  1.1  cherry 
    279  1.1  cherry /* Maximum number of virtual CPUs in legacy multi-processor guests. */
    280  1.1  cherry /* Only one. All other VCPUS must use VCPUOP_register_vcpu_info */
    281  1.1  cherry #define XEN_LEGACY_MAX_VCPUS 1
    282  1.1  cherry 
    283  1.1  cherry typedef uint64_t xen_ulong_t;
    284  1.1  cherry #define PRI_xen_ulong PRIx64
    285  1.1  cherry 
    286  1.1  cherry #if defined(__XEN__) || defined(__XEN_TOOLS__)
    287  1.1  cherry struct vcpu_guest_context {
    288  1.1  cherry #define _VGCF_online                   0
    289  1.1  cherry #define VGCF_online                    (1<<_VGCF_online)
    290  1.1  cherry     uint32_t flags;                         /* VGCF_* */
    291  1.1  cherry 
    292  1.1  cherry     struct vcpu_guest_core_regs user_regs;  /* Core CPU registers */
    293  1.1  cherry 
    294  1.1  cherry     uint32_t sctlr;
    295  1.1  cherry     uint64_t ttbcr, ttbr0, ttbr1;
    296  1.1  cherry };
    297  1.1  cherry typedef struct vcpu_guest_context vcpu_guest_context_t;
    298  1.1  cherry DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
    299  1.1  cherry 
    300  1.1  cherry /*
    301  1.1  cherry  * struct xen_arch_domainconfig's ABI is covered by
    302  1.1  cherry  * XEN_DOMCTL_INTERFACE_VERSION.
    303  1.1  cherry  */
    304  1.1  cherry #define XEN_DOMCTL_CONFIG_GIC_NATIVE    0
    305  1.1  cherry #define XEN_DOMCTL_CONFIG_GIC_V2        1
    306  1.1  cherry #define XEN_DOMCTL_CONFIG_GIC_V3        2
    307  1.1  cherry struct xen_arch_domainconfig {
    308  1.1  cherry     /* IN/OUT */
    309  1.1  cherry     uint8_t gic_version;
    310  1.1  cherry     /* IN */
    311  1.1  cherry     uint32_t nr_spis;
    312  1.1  cherry     /*
    313  1.1  cherry      * OUT
    314  1.1  cherry      * Based on the property clock-frequency in the DT timer node.
    315  1.1  cherry      * The property may be present when the bootloader/firmware doesn't
    316  1.1  cherry      * set correctly CNTFRQ which hold the timer frequency.
    317  1.1  cherry      *
    318  1.1  cherry      * As it's not possible to trap this register, we have to replicate
    319  1.1  cherry      * the value in the guest DT.
    320  1.1  cherry      *
    321  1.1  cherry      * = 0 => property not present
    322  1.1  cherry      * > 0 => Value of the property
    323  1.1  cherry      *
    324  1.1  cherry      */
    325  1.1  cherry     uint32_t clock_frequency;
    326  1.1  cherry };
    327  1.1  cherry #endif /* __XEN__ || __XEN_TOOLS__ */
    328  1.1  cherry 
    329  1.1  cherry struct arch_vcpu_info {
    330  1.1  cherry };
    331  1.1  cherry typedef struct arch_vcpu_info arch_vcpu_info_t;
    332  1.1  cherry 
    333  1.1  cherry struct arch_shared_info {
    334  1.1  cherry };
    335  1.1  cherry typedef struct arch_shared_info arch_shared_info_t;
    336  1.1  cherry typedef uint64_t xen_callback_t;
    337  1.1  cherry 
    338  1.1  cherry #endif
    339  1.1  cherry 
    340  1.1  cherry #if defined(__XEN__) || defined(__XEN_TOOLS__)
    341  1.1  cherry 
    342  1.1  cherry /* PSR bits (CPSR, SPSR) */
    343  1.1  cherry 
    344  1.1  cherry #define PSR_THUMB       (1<<5)        /* Thumb Mode enable */
    345  1.1  cherry #define PSR_FIQ_MASK    (1<<6)        /* Fast Interrupt mask */
    346  1.1  cherry #define PSR_IRQ_MASK    (1<<7)        /* Interrupt mask */
    347  1.1  cherry #define PSR_ABT_MASK    (1<<8)        /* Asynchronous Abort mask */
    348  1.1  cherry #define PSR_BIG_ENDIAN  (1<<9)        /* arm32: Big Endian Mode */
    349  1.1  cherry #define PSR_DBG_MASK    (1<<9)        /* arm64: Debug Exception mask */
    350  1.1  cherry #define PSR_IT_MASK     (0x0600fc00)  /* Thumb If-Then Mask */
    351  1.1  cherry #define PSR_JAZELLE     (1<<24)       /* Jazelle Mode */
    352  1.1  cherry 
    353  1.1  cherry /* 32 bit modes */
    354  1.1  cherry #define PSR_MODE_USR 0x10
    355  1.1  cherry #define PSR_MODE_FIQ 0x11
    356  1.1  cherry #define PSR_MODE_IRQ 0x12
    357  1.1  cherry #define PSR_MODE_SVC 0x13
    358  1.1  cherry #define PSR_MODE_MON 0x16
    359  1.1  cherry #define PSR_MODE_ABT 0x17
    360  1.1  cherry #define PSR_MODE_HYP 0x1a
    361  1.1  cherry #define PSR_MODE_UND 0x1b
    362  1.1  cherry #define PSR_MODE_SYS 0x1f
    363  1.1  cherry 
    364  1.1  cherry /* 64 bit modes */
    365  1.1  cherry #define PSR_MODE_BIT  0x10 /* Set iff AArch32 */
    366  1.1  cherry #define PSR_MODE_EL3h 0x0d
    367  1.1  cherry #define PSR_MODE_EL3t 0x0c
    368  1.1  cherry #define PSR_MODE_EL2h 0x09
    369  1.1  cherry #define PSR_MODE_EL2t 0x08
    370  1.1  cherry #define PSR_MODE_EL1h 0x05
    371  1.1  cherry #define PSR_MODE_EL1t 0x04
    372  1.1  cherry #define PSR_MODE_EL0t 0x00
    373  1.1  cherry 
    374  1.1  cherry #define PSR_GUEST32_INIT  (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_SVC)
    375  1.1  cherry #define PSR_GUEST64_INIT (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_EL1h)
    376  1.1  cherry 
    377  1.1  cherry #define SCTLR_GUEST_INIT    0x00c50078
    378  1.1  cherry 
    379  1.1  cherry /*
    380  1.1  cherry  * Virtual machine platform (memory layout, interrupts)
    381  1.1  cherry  *
    382  1.1  cherry  * These are defined for consistency between the tools and the
    383  1.1  cherry  * hypervisor. Guests must not rely on these hardcoded values but
    384  1.1  cherry  * should instead use the FDT.
    385  1.1  cherry  */
    386  1.1  cherry 
    387  1.1  cherry /* Physical Address Space */
    388  1.1  cherry 
    389  1.1  cherry /*
    390  1.1  cherry  * vGIC mappings: Only one set of mapping is used by the guest.
    391  1.1  cherry  * Therefore they can overlap.
    392  1.1  cherry  */
    393  1.1  cherry 
    394  1.1  cherry /* vGIC v2 mappings */
    395  1.1  cherry #define GUEST_GICD_BASE   xen_mk_ullong(0x03001000)
    396  1.1  cherry #define GUEST_GICD_SIZE   xen_mk_ullong(0x00001000)
    397  1.1  cherry #define GUEST_GICC_BASE   xen_mk_ullong(0x03002000)
    398  1.1  cherry #define GUEST_GICC_SIZE   xen_mk_ullong(0x00002000)
    399  1.1  cherry 
    400  1.1  cherry /* vGIC v3 mappings */
    401  1.1  cherry #define GUEST_GICV3_GICD_BASE      xen_mk_ullong(0x03001000)
    402  1.1  cherry #define GUEST_GICV3_GICD_SIZE      xen_mk_ullong(0x00010000)
    403  1.1  cherry 
    404  1.1  cherry #define GUEST_GICV3_RDIST_REGIONS  1
    405  1.1  cherry 
    406  1.1  cherry #define GUEST_GICV3_GICR0_BASE     xen_mk_ullong(0x03020000) /* vCPU0..127 */
    407  1.1  cherry #define GUEST_GICV3_GICR0_SIZE     xen_mk_ullong(0x01000000)
    408  1.1  cherry 
    409  1.1  cherry /* ACPI tables physical address */
    410  1.1  cherry #define GUEST_ACPI_BASE 0x20000000ULL
    411  1.1  cherry #define GUEST_ACPI_SIZE 0x02000000ULL
    412  1.1  cherry 
    413  1.1  cherry /* PL011 mappings */
    414  1.1  cherry #define GUEST_PL011_BASE    0x22000000ULL
    415  1.1  cherry #define GUEST_PL011_SIZE    0x00001000ULL
    416  1.1  cherry 
    417  1.1  cherry /*
    418  1.1  cherry  * 16MB == 4096 pages reserved for guest to use as a region to map its
    419  1.1  cherry  * grant table in.
    420  1.1  cherry  */
    421  1.1  cherry #define GUEST_GNTTAB_BASE xen_mk_ullong(0x38000000)
    422  1.1  cherry #define GUEST_GNTTAB_SIZE xen_mk_ullong(0x01000000)
    423  1.1  cherry 
    424  1.1  cherry #define GUEST_MAGIC_BASE  xen_mk_ullong(0x39000000)
    425  1.1  cherry #define GUEST_MAGIC_SIZE  xen_mk_ullong(0x01000000)
    426  1.1  cherry 
    427  1.1  cherry #define GUEST_RAM_BANKS   2
    428  1.1  cherry 
    429  1.1  cherry #define GUEST_RAM0_BASE   xen_mk_ullong(0x40000000) /* 3GB of low RAM @ 1GB */
    430  1.1  cherry #define GUEST_RAM0_SIZE   xen_mk_ullong(0xc0000000)
    431  1.1  cherry 
    432  1.1  cherry #define GUEST_RAM1_BASE   xen_mk_ullong(0x0200000000) /* 1016GB of RAM @ 8GB */
    433  1.1  cherry #define GUEST_RAM1_SIZE   xen_mk_ullong(0xfe00000000)
    434  1.1  cherry 
    435  1.1  cherry #define GUEST_RAM_BASE    GUEST_RAM0_BASE /* Lowest RAM address */
    436  1.1  cherry /* Largest amount of actual RAM, not including holes */
    437  1.1  cherry #define GUEST_RAM_MAX     (GUEST_RAM0_SIZE + GUEST_RAM1_SIZE)
    438  1.1  cherry /* Suitable for e.g. const uint64_t ramfoo[] = GUEST_RAM_BANK_FOOS; */
    439  1.1  cherry #define GUEST_RAM_BANK_BASES   { GUEST_RAM0_BASE, GUEST_RAM1_BASE }
    440  1.1  cherry #define GUEST_RAM_BANK_SIZES   { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE }
    441  1.1  cherry 
    442  1.1  cherry /* Current supported guest VCPUs */
    443  1.1  cherry #define GUEST_MAX_VCPUS 128
    444  1.1  cherry 
    445  1.1  cherry /* Interrupts */
    446  1.1  cherry #define GUEST_TIMER_VIRT_PPI    27
    447  1.1  cherry #define GUEST_TIMER_PHYS_S_PPI  29
    448  1.1  cherry #define GUEST_TIMER_PHYS_NS_PPI 30
    449  1.1  cherry #define GUEST_EVTCHN_PPI        31
    450  1.1  cherry 
    451  1.1  cherry #define GUEST_VPL011_SPI        32
    452  1.1  cherry 
    453  1.1  cherry /* PSCI functions */
    454  1.1  cherry #define PSCI_cpu_suspend 0
    455  1.1  cherry #define PSCI_cpu_off     1
    456  1.1  cherry #define PSCI_cpu_on      2
    457  1.1  cherry #define PSCI_migrate     3
    458  1.1  cherry 
    459  1.1  cherry #endif
    460  1.1  cherry 
    461  1.1  cherry #ifndef __ASSEMBLY__
    462  1.1  cherry /* Stub definition of PMU structure */
    463  1.1  cherry typedef struct xen_pmu_arch { uint8_t dummy; } xen_pmu_arch_t;
    464  1.1  cherry #endif
    465  1.1  cherry 
    466  1.1  cherry #endif /*  __XEN_PUBLIC_ARCH_ARM_H__ */
    467  1.1  cherry 
    468  1.1  cherry /*
    469  1.1  cherry  * Local variables:
    470  1.1  cherry  * mode: C
    471  1.1  cherry  * c-file-style: "BSD"
    472  1.1  cherry  * c-basic-offset: 4
    473  1.1  cherry  * tab-width: 4
    474  1.1  cherry  * indent-tabs-mode: nil
    475  1.1  cherry  * End:
    476  1.1  cherry  */
    477