Home | History | Annotate | Download | only in target-arm
      1 /*
      2  * KVM ARM ABI constant definitions
      3  *
      4  * Copyright (c) 2013 Linaro Limited
      5  *
      6  * Provide versions of KVM constant defines that can be used even
      7  * when CONFIG_KVM is not set and we don't have access to the
      8  * KVM headers. If CONFIG_KVM is set, we do a compile-time check
      9  * that we haven't got out of sync somehow.
     10  *
     11  * This work is licensed under the terms of the GNU GPL, version 2 or later.
     12  * See the COPYING file in the top-level directory.
     13  */
     14 #ifndef ARM_KVM_CONSTS_H
     15 #define ARM_KVM_CONSTS_H
     16 
     17 #ifdef CONFIG_KVM
     18 #include "qemu/compiler.h"
     19 #include <linux/kvm.h>
     20 
     21 #define MISMATCH_CHECK(X, Y) QEMU_BUILD_BUG_ON(X != Y)
     22 
     23 #else
     24 #define MISMATCH_CHECK(X, Y)
     25 #endif
     26 
     27 #define CP_REG_SIZE_SHIFT 52
     28 #define CP_REG_SIZE_MASK       0x00f0000000000000ULL
     29 #define CP_REG_SIZE_U32        0x0020000000000000ULL
     30 #define CP_REG_SIZE_U64        0x0030000000000000ULL
     31 #define CP_REG_ARM             0x4000000000000000ULL
     32 
     33 MISMATCH_CHECK(CP_REG_SIZE_SHIFT, KVM_REG_SIZE_SHIFT)
     34 MISMATCH_CHECK(CP_REG_SIZE_MASK, KVM_REG_SIZE_MASK)
     35 MISMATCH_CHECK(CP_REG_SIZE_U32, KVM_REG_SIZE_U32)
     36 MISMATCH_CHECK(CP_REG_SIZE_U64, KVM_REG_SIZE_U64)
     37 MISMATCH_CHECK(CP_REG_ARM, KVM_REG_ARM)
     38 
     39 #define PSCI_FN_BASE 0x95c1ba5e
     40 #define PSCI_FN(n) (PSCI_FN_BASE + (n))
     41 #define PSCI_FN_CPU_SUSPEND PSCI_FN(0)
     42 #define PSCI_FN_CPU_OFF PSCI_FN(1)
     43 #define PSCI_FN_CPU_ON PSCI_FN(2)
     44 #define PSCI_FN_MIGRATE PSCI_FN(3)
     45 
     46 MISMATCH_CHECK(PSCI_FN_CPU_SUSPEND, KVM_PSCI_FN_CPU_SUSPEND)
     47 MISMATCH_CHECK(PSCI_FN_CPU_OFF, KVM_PSCI_FN_CPU_OFF)
     48 MISMATCH_CHECK(PSCI_FN_CPU_ON, KVM_PSCI_FN_CPU_ON)
     49 MISMATCH_CHECK(PSCI_FN_MIGRATE, KVM_PSCI_FN_MIGRATE)
     50 
     51 #define QEMU_KVM_ARM_TARGET_CORTEX_A15 0
     52 
     53 /* There's no kernel define for this: sentinel value which
     54  * matches no KVM target value for either 64 or 32 bit
     55  */
     56 #define QEMU_KVM_ARM_TARGET_NONE UINT_MAX
     57 
     58 #ifndef TARGET_AARCH64
     59 MISMATCH_CHECK(QEMU_KVM_ARM_TARGET_CORTEX_A15, KVM_ARM_TARGET_CORTEX_A15)
     60 #endif
     61 
     62 #undef MISMATCH_CHECK
     63 
     64 #endif
     65