18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2012 - Virtual Open Systems and Columbia University 48c2ecf20Sopenharmony_ci * Author: Christoffer Dall <c.dall@virtualopensystems.com> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 78c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License, version 2, as 88c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 118c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 128c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138c2ecf20Sopenharmony_ci * GNU General Public License for more details. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 168c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software 178c2ecf20Sopenharmony_ci * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#ifndef __ARM_KVM_H__ 218c2ecf20Sopenharmony_ci#define __ARM_KVM_H__ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <linux/types.h> 248c2ecf20Sopenharmony_ci#include <linux/psci.h> 258c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define __KVM_HAVE_GUEST_DEBUG 288c2ecf20Sopenharmony_ci#define __KVM_HAVE_IRQ_LINE 298c2ecf20Sopenharmony_ci#define __KVM_HAVE_READONLY_MEM 308c2ecf20Sopenharmony_ci#define __KVM_HAVE_VCPU_EVENTS 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define KVM_REG_SIZE(id) \ 358c2ecf20Sopenharmony_ci (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* Valid for svc_regs, abt_regs, und_regs, irq_regs in struct kvm_regs */ 388c2ecf20Sopenharmony_ci#define KVM_ARM_SVC_sp svc_regs[0] 398c2ecf20Sopenharmony_ci#define KVM_ARM_SVC_lr svc_regs[1] 408c2ecf20Sopenharmony_ci#define KVM_ARM_SVC_spsr svc_regs[2] 418c2ecf20Sopenharmony_ci#define KVM_ARM_ABT_sp abt_regs[0] 428c2ecf20Sopenharmony_ci#define KVM_ARM_ABT_lr abt_regs[1] 438c2ecf20Sopenharmony_ci#define KVM_ARM_ABT_spsr abt_regs[2] 448c2ecf20Sopenharmony_ci#define KVM_ARM_UND_sp und_regs[0] 458c2ecf20Sopenharmony_ci#define KVM_ARM_UND_lr und_regs[1] 468c2ecf20Sopenharmony_ci#define KVM_ARM_UND_spsr und_regs[2] 478c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_sp irq_regs[0] 488c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_lr irq_regs[1] 498c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_spsr irq_regs[2] 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* Valid only for fiq_regs in struct kvm_regs */ 528c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_r8 fiq_regs[0] 538c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_r9 fiq_regs[1] 548c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_r10 fiq_regs[2] 558c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_fp fiq_regs[3] 568c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_ip fiq_regs[4] 578c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_sp fiq_regs[5] 588c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_lr fiq_regs[6] 598c2ecf20Sopenharmony_ci#define KVM_ARM_FIQ_spsr fiq_regs[7] 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistruct kvm_regs { 628c2ecf20Sopenharmony_ci struct pt_regs usr_regs; /* R0_usr - R14_usr, PC, CPSR */ 638c2ecf20Sopenharmony_ci unsigned long svc_regs[3]; /* SP_svc, LR_svc, SPSR_svc */ 648c2ecf20Sopenharmony_ci unsigned long abt_regs[3]; /* SP_abt, LR_abt, SPSR_abt */ 658c2ecf20Sopenharmony_ci unsigned long und_regs[3]; /* SP_und, LR_und, SPSR_und */ 668c2ecf20Sopenharmony_ci unsigned long irq_regs[3]; /* SP_irq, LR_irq, SPSR_irq */ 678c2ecf20Sopenharmony_ci unsigned long fiq_regs[8]; /* R8_fiq - R14_fiq, SPSR_fiq */ 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* Supported Processor Types */ 718c2ecf20Sopenharmony_ci#define KVM_ARM_TARGET_CORTEX_A15 0 728c2ecf20Sopenharmony_ci#define KVM_ARM_TARGET_CORTEX_A7 1 738c2ecf20Sopenharmony_ci#define KVM_ARM_NUM_TARGETS 2 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */ 768c2ecf20Sopenharmony_ci#define KVM_ARM_DEVICE_TYPE_SHIFT 0 778c2ecf20Sopenharmony_ci#define KVM_ARM_DEVICE_TYPE_MASK (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT) 788c2ecf20Sopenharmony_ci#define KVM_ARM_DEVICE_ID_SHIFT 16 798c2ecf20Sopenharmony_ci#define KVM_ARM_DEVICE_ID_MASK (0xffff << KVM_ARM_DEVICE_ID_SHIFT) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* Supported device IDs */ 828c2ecf20Sopenharmony_ci#define KVM_ARM_DEVICE_VGIC_V2 0 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* Supported VGIC address types */ 858c2ecf20Sopenharmony_ci#define KVM_VGIC_V2_ADDR_TYPE_DIST 0 868c2ecf20Sopenharmony_ci#define KVM_VGIC_V2_ADDR_TYPE_CPU 1 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define KVM_VGIC_V2_DIST_SIZE 0x1000 898c2ecf20Sopenharmony_ci#define KVM_VGIC_V2_CPU_SIZE 0x2000 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Supported VGICv3 address types */ 928c2ecf20Sopenharmony_ci#define KVM_VGIC_V3_ADDR_TYPE_DIST 2 938c2ecf20Sopenharmony_ci#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 948c2ecf20Sopenharmony_ci#define KVM_VGIC_ITS_ADDR_TYPE 4 958c2ecf20Sopenharmony_ci#define KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION 5 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define KVM_VGIC_V3_DIST_SIZE SZ_64K 988c2ecf20Sopenharmony_ci#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K) 998c2ecf20Sopenharmony_ci#define KVM_VGIC_V3_ITS_SIZE (2 * SZ_64K) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_POWER_OFF 0 /* CPU is started in OFF state */ 1028c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_PSCI_0_2 1 /* CPU uses PSCI v0.2 */ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistruct kvm_vcpu_init { 1058c2ecf20Sopenharmony_ci __u32 target; 1068c2ecf20Sopenharmony_ci __u32 features[7]; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct kvm_sregs { 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistruct kvm_fpu { 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct kvm_guest_debug_arch { 1168c2ecf20Sopenharmony_ci}; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cistruct kvm_debug_exit_arch { 1198c2ecf20Sopenharmony_ci}; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_cistruct kvm_sync_regs { 1228c2ecf20Sopenharmony_ci /* Used with KVM_CAP_ARM_USER_IRQ */ 1238c2ecf20Sopenharmony_ci __u64 device_irq_level; 1248c2ecf20Sopenharmony_ci}; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cistruct kvm_arch_memory_slot { 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/* for KVM_GET/SET_VCPU_EVENTS */ 1308c2ecf20Sopenharmony_cistruct kvm_vcpu_events { 1318c2ecf20Sopenharmony_ci struct { 1328c2ecf20Sopenharmony_ci __u8 serror_pending; 1338c2ecf20Sopenharmony_ci __u8 serror_has_esr; 1348c2ecf20Sopenharmony_ci __u8 ext_dabt_pending; 1358c2ecf20Sopenharmony_ci /* Align it to 8 bytes */ 1368c2ecf20Sopenharmony_ci __u8 pad[5]; 1378c2ecf20Sopenharmony_ci __u64 serror_esr; 1388c2ecf20Sopenharmony_ci } exception; 1398c2ecf20Sopenharmony_ci __u32 reserved[12]; 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci/* If you need to interpret the index values, here is the key: */ 1438c2ecf20Sopenharmony_ci#define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000 1448c2ecf20Sopenharmony_ci#define KVM_REG_ARM_COPROC_SHIFT 16 1458c2ecf20Sopenharmony_ci#define KVM_REG_ARM_32_OPC2_MASK 0x0000000000000007 1468c2ecf20Sopenharmony_ci#define KVM_REG_ARM_32_OPC2_SHIFT 0 1478c2ecf20Sopenharmony_ci#define KVM_REG_ARM_OPC1_MASK 0x0000000000000078 1488c2ecf20Sopenharmony_ci#define KVM_REG_ARM_OPC1_SHIFT 3 1498c2ecf20Sopenharmony_ci#define KVM_REG_ARM_CRM_MASK 0x0000000000000780 1508c2ecf20Sopenharmony_ci#define KVM_REG_ARM_CRM_SHIFT 7 1518c2ecf20Sopenharmony_ci#define KVM_REG_ARM_32_CRN_MASK 0x0000000000007800 1528c2ecf20Sopenharmony_ci#define KVM_REG_ARM_32_CRN_SHIFT 11 1538c2ecf20Sopenharmony_ci/* 1548c2ecf20Sopenharmony_ci * For KVM currently all guest registers are nonsecure, but we reserve a bit 1558c2ecf20Sopenharmony_ci * in the encoding to distinguish secure from nonsecure for AArch32 system 1568c2ecf20Sopenharmony_ci * registers that are banked by security. This is 1 for the secure banked 1578c2ecf20Sopenharmony_ci * register, and 0 for the nonsecure banked register or if the register is 1588c2ecf20Sopenharmony_ci * not banked by security. 1598c2ecf20Sopenharmony_ci */ 1608c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SECURE_MASK 0x0000000010000000 1618c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SECURE_SHIFT 28 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci#define ARM_CP15_REG_SHIFT_MASK(x,n) \ 1648c2ecf20Sopenharmony_ci (((x) << KVM_REG_ARM_ ## n ## _SHIFT) & KVM_REG_ARM_ ## n ## _MASK) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci#define __ARM_CP15_REG(op1,crn,crm,op2) \ 1678c2ecf20Sopenharmony_ci (KVM_REG_ARM | (15 << KVM_REG_ARM_COPROC_SHIFT) | \ 1688c2ecf20Sopenharmony_ci ARM_CP15_REG_SHIFT_MASK(op1, OPC1) | \ 1698c2ecf20Sopenharmony_ci ARM_CP15_REG_SHIFT_MASK(crn, 32_CRN) | \ 1708c2ecf20Sopenharmony_ci ARM_CP15_REG_SHIFT_MASK(crm, CRM) | \ 1718c2ecf20Sopenharmony_ci ARM_CP15_REG_SHIFT_MASK(op2, 32_OPC2)) 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci#define ARM_CP15_REG32(...) (__ARM_CP15_REG(__VA_ARGS__) | KVM_REG_SIZE_U32) 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci#define __ARM_CP15_REG64(op1,crm) \ 1768c2ecf20Sopenharmony_ci (__ARM_CP15_REG(op1, 0, crm, 0) | KVM_REG_SIZE_U64) 1778c2ecf20Sopenharmony_ci#define ARM_CP15_REG64(...) __ARM_CP15_REG64(__VA_ARGS__) 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* PL1 Physical Timer Registers */ 1808c2ecf20Sopenharmony_ci#define KVM_REG_ARM_PTIMER_CTL ARM_CP15_REG32(0, 14, 2, 1) 1818c2ecf20Sopenharmony_ci#define KVM_REG_ARM_PTIMER_CNT ARM_CP15_REG64(0, 14) 1828c2ecf20Sopenharmony_ci#define KVM_REG_ARM_PTIMER_CVAL ARM_CP15_REG64(2, 14) 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci/* Virtual Timer Registers */ 1858c2ecf20Sopenharmony_ci#define KVM_REG_ARM_TIMER_CTL ARM_CP15_REG32(0, 14, 3, 1) 1868c2ecf20Sopenharmony_ci#define KVM_REG_ARM_TIMER_CNT ARM_CP15_REG64(1, 14) 1878c2ecf20Sopenharmony_ci#define KVM_REG_ARM_TIMER_CVAL ARM_CP15_REG64(3, 14) 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/* Normal registers are mapped as coprocessor 16. */ 1908c2ecf20Sopenharmony_ci#define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT) 1918c2ecf20Sopenharmony_ci#define KVM_REG_ARM_CORE_REG(name) (offsetof(struct kvm_regs, name) / 4) 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci/* Some registers need more space to represent values. */ 1948c2ecf20Sopenharmony_ci#define KVM_REG_ARM_DEMUX (0x0011 << KVM_REG_ARM_COPROC_SHIFT) 1958c2ecf20Sopenharmony_ci#define KVM_REG_ARM_DEMUX_ID_MASK 0x000000000000FF00 1968c2ecf20Sopenharmony_ci#define KVM_REG_ARM_DEMUX_ID_SHIFT 8 1978c2ecf20Sopenharmony_ci#define KVM_REG_ARM_DEMUX_ID_CCSIDR (0x00 << KVM_REG_ARM_DEMUX_ID_SHIFT) 1988c2ecf20Sopenharmony_ci#define KVM_REG_ARM_DEMUX_VAL_MASK 0x00000000000000FF 1998c2ecf20Sopenharmony_ci#define KVM_REG_ARM_DEMUX_VAL_SHIFT 0 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* VFP registers: we could overload CP10 like ARM does, but that's ugly. */ 2028c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP (0x0012 << KVM_REG_ARM_COPROC_SHIFT) 2038c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_MASK 0x000000000000FFFF 2048c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_BASE_REG 0x0 2058c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_FPSID 0x1000 2068c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_FPSCR 0x1001 2078c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_MVFR1 0x1006 2088c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_MVFR0 0x1007 2098c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_FPEXC 0x1008 2108c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_FPINST 0x1009 2118c2ecf20Sopenharmony_ci#define KVM_REG_ARM_VFP_FPINST2 0x100A 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci/* KVM-as-firmware specific pseudo-registers */ 2148c2ecf20Sopenharmony_ci#define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT) 2158c2ecf20Sopenharmony_ci#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM | KVM_REG_SIZE_U64 | \ 2168c2ecf20Sopenharmony_ci KVM_REG_ARM_FW | ((r) & 0xffff)) 2178c2ecf20Sopenharmony_ci#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) 2188c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1 KVM_REG_ARM_FW_REG(1) 2198c2ecf20Sopenharmony_ci /* Higher values mean better protection. */ 2208c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL 0 2218c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL 1 2228c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED 2 2238c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2 KVM_REG_ARM_FW_REG(2) 2248c2ecf20Sopenharmony_ci /* Higher values mean better protection. */ 2258c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL 0 2268c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN 1 2278c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL 2 2288c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED 3 2298c2ecf20Sopenharmony_ci#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED (1U << 4) 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci/* Device Control API: ARM VGIC */ 2328c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_ADDR 0 2338c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 2348c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_CPU_REGS 2 2358c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_CPUID_SHIFT 32 2368c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_CPUID_MASK (0xffULL << KVM_DEV_ARM_VGIC_CPUID_SHIFT) 2378c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_V3_MPIDR_SHIFT 32 2388c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_V3_MPIDR_MASK \ 2398c2ecf20Sopenharmony_ci (0xffffffffULL << KVM_DEV_ARM_VGIC_V3_MPIDR_SHIFT) 2408c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_OFFSET_SHIFT 0 2418c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT) 2428c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_SYSREG_INSTR_MASK (0xffff) 2438c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_NR_IRQS 3 2448c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_CTRL 4 2458c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_REDIST_REGS 5 2468c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6 2478c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO 7 2488c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8 2498c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10 2508c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \ 2518c2ecf20Sopenharmony_ci (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT) 2528c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_LINE_LEVEL_INTID_MASK 0x3ff 2538c2ecf20Sopenharmony_ci#define VGIC_LEVEL_INFO_LINE_LEVEL 0 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci/* Device Control API on vcpu fd */ 2568c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_PMU_V3_CTRL 0 2578c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_PMU_V3_IRQ 0 2588c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_PMU_V3_INIT 1 2598c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_TIMER_CTRL 1 2608c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0 2618c2ecf20Sopenharmony_ci#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_CTRL_INIT 0 2648c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_ITS_SAVE_TABLES 1 2658c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_ITS_RESTORE_TABLES 2 2668c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3 2678c2ecf20Sopenharmony_ci#define KVM_DEV_ARM_ITS_CTRL_RESET 4 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci/* KVM_IRQ_LINE irq field index values */ 2708c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_VCPU2_SHIFT 28 2718c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_VCPU2_MASK 0xf 2728c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_TYPE_SHIFT 24 2738c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_TYPE_MASK 0xf 2748c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_VCPU_SHIFT 16 2758c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_VCPU_MASK 0xff 2768c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_NUM_SHIFT 0 2778c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_NUM_MASK 0xffff 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci/* irq_type field */ 2808c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_TYPE_CPU 0 2818c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_TYPE_SPI 1 2828c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_TYPE_PPI 2 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci/* out-of-kernel GIC cpu interrupt injection irq_number field */ 2858c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_CPU_IRQ 0 2868c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_CPU_FIQ 1 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci/* 2898c2ecf20Sopenharmony_ci * This used to hold the highest supported SPI, but it is now obsolete 2908c2ecf20Sopenharmony_ci * and only here to provide source code level compatibility with older 2918c2ecf20Sopenharmony_ci * userland. The highest SPI number can be set via KVM_DEV_ARM_VGIC_GRP_NR_IRQS. 2928c2ecf20Sopenharmony_ci */ 2938c2ecf20Sopenharmony_ci#ifndef __KERNEL__ 2948c2ecf20Sopenharmony_ci#define KVM_ARM_IRQ_GIC_MAX 127 2958c2ecf20Sopenharmony_ci#endif 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci/* One single KVM irqchip, ie. the VGIC */ 2988c2ecf20Sopenharmony_ci#define KVM_NR_IRQCHIPS 1 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci/* PSCI interface */ 3018c2ecf20Sopenharmony_ci#define KVM_PSCI_FN_BASE 0x95c1ba5e 3028c2ecf20Sopenharmony_ci#define KVM_PSCI_FN(n) (KVM_PSCI_FN_BASE + (n)) 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci#define KVM_PSCI_FN_CPU_SUSPEND KVM_PSCI_FN(0) 3058c2ecf20Sopenharmony_ci#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1) 3068c2ecf20Sopenharmony_ci#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2) 3078c2ecf20Sopenharmony_ci#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci#define KVM_PSCI_RET_SUCCESS PSCI_RET_SUCCESS 3108c2ecf20Sopenharmony_ci#define KVM_PSCI_RET_NI PSCI_RET_NOT_SUPPORTED 3118c2ecf20Sopenharmony_ci#define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS 3128c2ecf20Sopenharmony_ci#define KVM_PSCI_RET_DENIED PSCI_RET_DENIED 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci#endif /* __ARM_KVM_H__ */ 315