14f8d6632SMarc Zyngier /* 24f8d6632SMarc Zyngier * Copyright (C) 2012,2013 - ARM Ltd 34f8d6632SMarc Zyngier * Author: Marc Zyngier <marc.zyngier@arm.com> 44f8d6632SMarc Zyngier * 54f8d6632SMarc Zyngier * Derived from arch/arm/include/asm/kvm_host.h: 64f8d6632SMarc Zyngier * Copyright (C) 2012 - Virtual Open Systems and Columbia University 74f8d6632SMarc Zyngier * Author: Christoffer Dall <c.dall@virtualopensystems.com> 84f8d6632SMarc Zyngier * 94f8d6632SMarc Zyngier * This program is free software; you can redistribute it and/or modify 104f8d6632SMarc Zyngier * it under the terms of the GNU General Public License version 2 as 114f8d6632SMarc Zyngier * published by the Free Software Foundation. 124f8d6632SMarc Zyngier * 134f8d6632SMarc Zyngier * This program is distributed in the hope that it will be useful, 144f8d6632SMarc Zyngier * but WITHOUT ANY WARRANTY; without even the implied warranty of 154f8d6632SMarc Zyngier * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 164f8d6632SMarc Zyngier * GNU General Public License for more details. 174f8d6632SMarc Zyngier * 184f8d6632SMarc Zyngier * You should have received a copy of the GNU General Public License 194f8d6632SMarc Zyngier * along with this program. If not, see <http://www.gnu.org/licenses/>. 204f8d6632SMarc Zyngier */ 214f8d6632SMarc Zyngier 224f8d6632SMarc Zyngier #ifndef __ARM64_KVM_HOST_H__ 234f8d6632SMarc Zyngier #define __ARM64_KVM_HOST_H__ 244f8d6632SMarc Zyngier 2565647300SPaolo Bonzini #include <linux/types.h> 2665647300SPaolo Bonzini #include <linux/kvm_types.h> 274f8d6632SMarc Zyngier #include <asm/kvm.h> 283a3604bcSMarc Zyngier #include <asm/kvm_asm.h> 294f8d6632SMarc Zyngier #include <asm/kvm_mmio.h> 30ad882137SMarc Zyngier #include <asm/kvm_perf_event.h> 314f8d6632SMarc Zyngier 32c1426e4cSEric Auger #define __KVM_HAVE_ARCH_INTC_INITIALIZED 33c1426e4cSEric Auger 344f8d6632SMarc Zyngier #define KVM_USER_MEM_SLOTS 32 354f8d6632SMarc Zyngier #define KVM_PRIVATE_MEM_SLOTS 4 364f8d6632SMarc Zyngier #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 37920552b2SDavid Hildenbrand #define KVM_HALT_POLL_NS_DEFAULT 500000 384f8d6632SMarc Zyngier 394f8d6632SMarc Zyngier #include <kvm/arm_vgic.h> 404f8d6632SMarc Zyngier #include <kvm/arm_arch_timer.h> 4104fe4726SShannon Zhao #include <kvm/arm_pmu.h> 424f8d6632SMarc Zyngier 43ef748917SMing Lei #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS 44ef748917SMing Lei 45808e7381SShannon Zhao #define KVM_VCPU_MAX_FEATURES 4 464f8d6632SMarc Zyngier 476951e48bSWill Deacon int __attribute_const__ kvm_target_cpu(void); 484f8d6632SMarc Zyngier int kvm_reset_vcpu(struct kvm_vcpu *vcpu); 494f8d6632SMarc Zyngier int kvm_arch_dev_ioctl_check_extension(long ext); 504f8d6632SMarc Zyngier 514f8d6632SMarc Zyngier struct kvm_arch { 524f8d6632SMarc Zyngier /* The VMID generation used for the virt. memory system */ 534f8d6632SMarc Zyngier u64 vmid_gen; 544f8d6632SMarc Zyngier u32 vmid; 554f8d6632SMarc Zyngier 564f8d6632SMarc Zyngier /* 1-level 2nd stage table and lock */ 574f8d6632SMarc Zyngier spinlock_t pgd_lock; 584f8d6632SMarc Zyngier pgd_t *pgd; 594f8d6632SMarc Zyngier 604f8d6632SMarc Zyngier /* VTTBR value associated with above pgd and vmid */ 614f8d6632SMarc Zyngier u64 vttbr; 624f8d6632SMarc Zyngier 633caa2d8cSAndre Przywara /* The maximum number of vCPUs depends on the used GIC model */ 643caa2d8cSAndre Przywara int max_vcpus; 653caa2d8cSAndre Przywara 664f8d6632SMarc Zyngier /* Interrupt controller */ 674f8d6632SMarc Zyngier struct vgic_dist vgic; 684f8d6632SMarc Zyngier 694f8d6632SMarc Zyngier /* Timer */ 704f8d6632SMarc Zyngier struct arch_timer_kvm timer; 714f8d6632SMarc Zyngier }; 724f8d6632SMarc Zyngier 734f8d6632SMarc Zyngier #define KVM_NR_MEM_OBJS 40 744f8d6632SMarc Zyngier 754f8d6632SMarc Zyngier /* 764f8d6632SMarc Zyngier * We don't want allocation failures within the mmu code, so we preallocate 774f8d6632SMarc Zyngier * enough memory for a single page fault in a cache. 784f8d6632SMarc Zyngier */ 794f8d6632SMarc Zyngier struct kvm_mmu_memory_cache { 804f8d6632SMarc Zyngier int nobjs; 814f8d6632SMarc Zyngier void *objects[KVM_NR_MEM_OBJS]; 824f8d6632SMarc Zyngier }; 834f8d6632SMarc Zyngier 844f8d6632SMarc Zyngier struct kvm_vcpu_fault_info { 854f8d6632SMarc Zyngier u32 esr_el2; /* Hyp Syndrom Register */ 864f8d6632SMarc Zyngier u64 far_el2; /* Hyp Fault Address Register */ 874f8d6632SMarc Zyngier u64 hpfar_el2; /* Hyp IPA Fault Address Register */ 884f8d6632SMarc Zyngier }; 894f8d6632SMarc Zyngier 909d8415d6SMarc Zyngier /* 919d8415d6SMarc Zyngier * 0 is reserved as an invalid value. 929d8415d6SMarc Zyngier * Order should be kept in sync with the save/restore code. 939d8415d6SMarc Zyngier */ 949d8415d6SMarc Zyngier enum vcpu_sysreg { 959d8415d6SMarc Zyngier __INVALID_SYSREG__, 969d8415d6SMarc Zyngier MPIDR_EL1, /* MultiProcessor Affinity Register */ 979d8415d6SMarc Zyngier CSSELR_EL1, /* Cache Size Selection Register */ 989d8415d6SMarc Zyngier SCTLR_EL1, /* System Control Register */ 999d8415d6SMarc Zyngier ACTLR_EL1, /* Auxiliary Control Register */ 1009d8415d6SMarc Zyngier CPACR_EL1, /* Coprocessor Access Control */ 1019d8415d6SMarc Zyngier TTBR0_EL1, /* Translation Table Base Register 0 */ 1029d8415d6SMarc Zyngier TTBR1_EL1, /* Translation Table Base Register 1 */ 1039d8415d6SMarc Zyngier TCR_EL1, /* Translation Control Register */ 1049d8415d6SMarc Zyngier ESR_EL1, /* Exception Syndrome Register */ 1059d8415d6SMarc Zyngier AFSR0_EL1, /* Auxilary Fault Status Register 0 */ 1069d8415d6SMarc Zyngier AFSR1_EL1, /* Auxilary Fault Status Register 1 */ 1079d8415d6SMarc Zyngier FAR_EL1, /* Fault Address Register */ 1089d8415d6SMarc Zyngier MAIR_EL1, /* Memory Attribute Indirection Register */ 1099d8415d6SMarc Zyngier VBAR_EL1, /* Vector Base Address Register */ 1109d8415d6SMarc Zyngier CONTEXTIDR_EL1, /* Context ID Register */ 1119d8415d6SMarc Zyngier TPIDR_EL0, /* Thread ID, User R/W */ 1129d8415d6SMarc Zyngier TPIDRRO_EL0, /* Thread ID, User R/O */ 1139d8415d6SMarc Zyngier TPIDR_EL1, /* Thread ID, Privileged */ 1149d8415d6SMarc Zyngier AMAIR_EL1, /* Aux Memory Attribute Indirection Register */ 1159d8415d6SMarc Zyngier CNTKCTL_EL1, /* Timer Control Register (EL1) */ 1169d8415d6SMarc Zyngier PAR_EL1, /* Physical Address Register */ 1179d8415d6SMarc Zyngier MDSCR_EL1, /* Monitor Debug System Control Register */ 1189d8415d6SMarc Zyngier MDCCINT_EL1, /* Monitor Debug Comms Channel Interrupt Enable Reg */ 1199d8415d6SMarc Zyngier 120ab946834SShannon Zhao /* Performance Monitors Registers */ 121ab946834SShannon Zhao PMCR_EL0, /* Control Register */ 1223965c3ceSShannon Zhao PMSELR_EL0, /* Event Counter Selection Register */ 123051ff581SShannon Zhao PMEVCNTR0_EL0, /* Event Counter Register (0-30) */ 124051ff581SShannon Zhao PMEVCNTR30_EL0 = PMEVCNTR0_EL0 + 30, 125051ff581SShannon Zhao PMCCNTR_EL0, /* Cycle Counter Register */ 1269feb21acSShannon Zhao PMEVTYPER0_EL0, /* Event Type Register (0-30) */ 1279feb21acSShannon Zhao PMEVTYPER30_EL0 = PMEVTYPER0_EL0 + 30, 1289feb21acSShannon Zhao PMCCFILTR_EL0, /* Cycle Count Filter Register */ 12996b0eebcSShannon Zhao PMCNTENSET_EL0, /* Count Enable Set Register */ 1309db52c78SShannon Zhao PMINTENSET_EL1, /* Interrupt Enable Set Register */ 13176d883c4SShannon Zhao PMOVSSET_EL0, /* Overflow Flag Status Set Register */ 1327a0adc70SShannon Zhao PMSWINC_EL0, /* Software Increment Register */ 133d692b8adSShannon Zhao PMUSERENR_EL0, /* User Enable Register */ 134ab946834SShannon Zhao 1359d8415d6SMarc Zyngier /* 32bit specific registers. Keep them at the end of the range */ 1369d8415d6SMarc Zyngier DACR32_EL2, /* Domain Access Control Register */ 1379d8415d6SMarc Zyngier IFSR32_EL2, /* Instruction Fault Status Register */ 1389d8415d6SMarc Zyngier FPEXC32_EL2, /* Floating-Point Exception Control Register */ 1399d8415d6SMarc Zyngier DBGVCR32_EL2, /* Debug Vector Catch Register */ 1409d8415d6SMarc Zyngier 1419d8415d6SMarc Zyngier NR_SYS_REGS /* Nothing after this line! */ 1429d8415d6SMarc Zyngier }; 1439d8415d6SMarc Zyngier 1449d8415d6SMarc Zyngier /* 32bit mapping */ 1459d8415d6SMarc Zyngier #define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */ 1469d8415d6SMarc Zyngier #define c0_CSSELR (CSSELR_EL1 * 2)/* Cache Size Selection Register */ 1479d8415d6SMarc Zyngier #define c1_SCTLR (SCTLR_EL1 * 2) /* System Control Register */ 1489d8415d6SMarc Zyngier #define c1_ACTLR (ACTLR_EL1 * 2) /* Auxiliary Control Register */ 1499d8415d6SMarc Zyngier #define c1_CPACR (CPACR_EL1 * 2) /* Coprocessor Access Control */ 1509d8415d6SMarc Zyngier #define c2_TTBR0 (TTBR0_EL1 * 2) /* Translation Table Base Register 0 */ 1519d8415d6SMarc Zyngier #define c2_TTBR0_high (c2_TTBR0 + 1) /* TTBR0 top 32 bits */ 1529d8415d6SMarc Zyngier #define c2_TTBR1 (TTBR1_EL1 * 2) /* Translation Table Base Register 1 */ 1539d8415d6SMarc Zyngier #define c2_TTBR1_high (c2_TTBR1 + 1) /* TTBR1 top 32 bits */ 1549d8415d6SMarc Zyngier #define c2_TTBCR (TCR_EL1 * 2) /* Translation Table Base Control R. */ 1559d8415d6SMarc Zyngier #define c3_DACR (DACR32_EL2 * 2)/* Domain Access Control Register */ 1569d8415d6SMarc Zyngier #define c5_DFSR (ESR_EL1 * 2) /* Data Fault Status Register */ 1579d8415d6SMarc Zyngier #define c5_IFSR (IFSR32_EL2 * 2)/* Instruction Fault Status Register */ 1589d8415d6SMarc Zyngier #define c5_ADFSR (AFSR0_EL1 * 2) /* Auxiliary Data Fault Status R */ 1599d8415d6SMarc Zyngier #define c5_AIFSR (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */ 1609d8415d6SMarc Zyngier #define c6_DFAR (FAR_EL1 * 2) /* Data Fault Address Register */ 1619d8415d6SMarc Zyngier #define c6_IFAR (c6_DFAR + 1) /* Instruction Fault Address Register */ 1629d8415d6SMarc Zyngier #define c7_PAR (PAR_EL1 * 2) /* Physical Address Register */ 1639d8415d6SMarc Zyngier #define c7_PAR_high (c7_PAR + 1) /* PAR top 32 bits */ 1649d8415d6SMarc Zyngier #define c10_PRRR (MAIR_EL1 * 2) /* Primary Region Remap Register */ 1659d8415d6SMarc Zyngier #define c10_NMRR (c10_PRRR + 1) /* Normal Memory Remap Register */ 1669d8415d6SMarc Zyngier #define c12_VBAR (VBAR_EL1 * 2) /* Vector Base Address Register */ 1679d8415d6SMarc Zyngier #define c13_CID (CONTEXTIDR_EL1 * 2) /* Context ID Register */ 1689d8415d6SMarc Zyngier #define c13_TID_URW (TPIDR_EL0 * 2) /* Thread ID, User R/W */ 1699d8415d6SMarc Zyngier #define c13_TID_URO (TPIDRRO_EL0 * 2)/* Thread ID, User R/O */ 1709d8415d6SMarc Zyngier #define c13_TID_PRIV (TPIDR_EL1 * 2) /* Thread ID, Privileged */ 1719d8415d6SMarc Zyngier #define c10_AMAIR0 (AMAIR_EL1 * 2) /* Aux Memory Attr Indirection Reg */ 1729d8415d6SMarc Zyngier #define c10_AMAIR1 (c10_AMAIR0 + 1)/* Aux Memory Attr Indirection Reg */ 1739d8415d6SMarc Zyngier #define c14_CNTKCTL (CNTKCTL_EL1 * 2) /* Timer Control Register (PL1) */ 1749d8415d6SMarc Zyngier 1759d8415d6SMarc Zyngier #define cp14_DBGDSCRext (MDSCR_EL1 * 2) 1769d8415d6SMarc Zyngier #define cp14_DBGBCR0 (DBGBCR0_EL1 * 2) 1779d8415d6SMarc Zyngier #define cp14_DBGBVR0 (DBGBVR0_EL1 * 2) 1789d8415d6SMarc Zyngier #define cp14_DBGBXVR0 (cp14_DBGBVR0 + 1) 1799d8415d6SMarc Zyngier #define cp14_DBGWCR0 (DBGWCR0_EL1 * 2) 1809d8415d6SMarc Zyngier #define cp14_DBGWVR0 (DBGWVR0_EL1 * 2) 1819d8415d6SMarc Zyngier #define cp14_DBGDCCINT (MDCCINT_EL1 * 2) 1829d8415d6SMarc Zyngier 1839d8415d6SMarc Zyngier #define NR_COPRO_REGS (NR_SYS_REGS * 2) 1849d8415d6SMarc Zyngier 1854f8d6632SMarc Zyngier struct kvm_cpu_context { 1864f8d6632SMarc Zyngier struct kvm_regs gp_regs; 18740033a61SMarc Zyngier union { 1884f8d6632SMarc Zyngier u64 sys_regs[NR_SYS_REGS]; 18972564016SMarc Zyngier u32 copro[NR_COPRO_REGS]; 19040033a61SMarc Zyngier }; 1914f8d6632SMarc Zyngier }; 1924f8d6632SMarc Zyngier 1934f8d6632SMarc Zyngier typedef struct kvm_cpu_context kvm_cpu_context_t; 1944f8d6632SMarc Zyngier 1954f8d6632SMarc Zyngier struct kvm_vcpu_arch { 1964f8d6632SMarc Zyngier struct kvm_cpu_context ctxt; 1974f8d6632SMarc Zyngier 1984f8d6632SMarc Zyngier /* HYP configuration */ 1994f8d6632SMarc Zyngier u64 hcr_el2; 20056c7f5e7SAlex Bennée u32 mdcr_el2; 2014f8d6632SMarc Zyngier 2024f8d6632SMarc Zyngier /* Exception Information */ 2034f8d6632SMarc Zyngier struct kvm_vcpu_fault_info fault; 2044f8d6632SMarc Zyngier 20584e690bfSAlex Bennée /* Guest debug state */ 2060c557ed4SMarc Zyngier u64 debug_flags; 2070c557ed4SMarc Zyngier 20884e690bfSAlex Bennée /* 20984e690bfSAlex Bennée * We maintain more than a single set of debug registers to support 21084e690bfSAlex Bennée * debugging the guest from the host and to maintain separate host and 21184e690bfSAlex Bennée * guest state during world switches. vcpu_debug_state are the debug 21284e690bfSAlex Bennée * registers of the vcpu as the guest sees them. host_debug_state are 213834bf887SAlex Bennée * the host registers which are saved and restored during 214834bf887SAlex Bennée * world switches. external_debug_state contains the debug 215834bf887SAlex Bennée * values we want to debug the guest. This is set via the 216834bf887SAlex Bennée * KVM_SET_GUEST_DEBUG ioctl. 21784e690bfSAlex Bennée * 21884e690bfSAlex Bennée * debug_ptr points to the set of debug registers that should be loaded 21984e690bfSAlex Bennée * onto the hardware when running the guest. 22084e690bfSAlex Bennée */ 22184e690bfSAlex Bennée struct kvm_guest_debug_arch *debug_ptr; 22284e690bfSAlex Bennée struct kvm_guest_debug_arch vcpu_debug_state; 223834bf887SAlex Bennée struct kvm_guest_debug_arch external_debug_state; 22484e690bfSAlex Bennée 2254f8d6632SMarc Zyngier /* Pointer to host CPU context */ 2264f8d6632SMarc Zyngier kvm_cpu_context_t *host_cpu_context; 22784e690bfSAlex Bennée struct kvm_guest_debug_arch host_debug_state; 2284f8d6632SMarc Zyngier 2294f8d6632SMarc Zyngier /* VGIC state */ 2304f8d6632SMarc Zyngier struct vgic_cpu vgic_cpu; 2314f8d6632SMarc Zyngier struct arch_timer_cpu timer_cpu; 23204fe4726SShannon Zhao struct kvm_pmu pmu; 2334f8d6632SMarc Zyngier 2344f8d6632SMarc Zyngier /* 2354f8d6632SMarc Zyngier * Anything that is not used directly from assembly code goes 2364f8d6632SMarc Zyngier * here. 2374f8d6632SMarc Zyngier */ 2384f8d6632SMarc Zyngier 239337b99bfSAlex Bennée /* 240337b99bfSAlex Bennée * Guest registers we preserve during guest debugging. 241337b99bfSAlex Bennée * 242337b99bfSAlex Bennée * These shadow registers are updated by the kvm_handle_sys_reg 243337b99bfSAlex Bennée * trap handler if the guest accesses or updates them while we 244337b99bfSAlex Bennée * are using guest debug. 245337b99bfSAlex Bennée */ 246337b99bfSAlex Bennée struct { 247337b99bfSAlex Bennée u32 mdscr_el1; 248337b99bfSAlex Bennée } guest_debug_preserved; 249337b99bfSAlex Bennée 2503781528eSEric Auger /* vcpu power-off state */ 2513781528eSEric Auger bool power_off; 2524f8d6632SMarc Zyngier 2533b92830aSEric Auger /* Don't run the guest (internal implementation need) */ 2543b92830aSEric Auger bool pause; 2553b92830aSEric Auger 2564f8d6632SMarc Zyngier /* IO related fields */ 2574f8d6632SMarc Zyngier struct kvm_decode mmio_decode; 2584f8d6632SMarc Zyngier 2594f8d6632SMarc Zyngier /* Interrupt related fields */ 2604f8d6632SMarc Zyngier u64 irq_lines; /* IRQ and FIQ levels */ 2614f8d6632SMarc Zyngier 2624f8d6632SMarc Zyngier /* Cache some mmu pages needed inside spinlock regions */ 2634f8d6632SMarc Zyngier struct kvm_mmu_memory_cache mmu_page_cache; 2644f8d6632SMarc Zyngier 2654f8d6632SMarc Zyngier /* Target CPU and feature flags */ 2666c8c0c4dSChen Gang int target; 2674f8d6632SMarc Zyngier DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES); 2684f8d6632SMarc Zyngier 2694f8d6632SMarc Zyngier /* Detect first run of a vcpu */ 2704f8d6632SMarc Zyngier bool has_run_once; 2714f8d6632SMarc Zyngier }; 2724f8d6632SMarc Zyngier 2734f8d6632SMarc Zyngier #define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs) 2744f8d6632SMarc Zyngier #define vcpu_sys_reg(v,r) ((v)->arch.ctxt.sys_regs[(r)]) 27572564016SMarc Zyngier /* 27672564016SMarc Zyngier * CP14 and CP15 live in the same array, as they are backed by the 27772564016SMarc Zyngier * same system registers. 27872564016SMarc Zyngier */ 27972564016SMarc Zyngier #define vcpu_cp14(v,r) ((v)->arch.ctxt.copro[(r)]) 28072564016SMarc Zyngier #define vcpu_cp15(v,r) ((v)->arch.ctxt.copro[(r)]) 2814f8d6632SMarc Zyngier 282f0a3eaffSVictor Kamensky #ifdef CONFIG_CPU_BIG_ENDIAN 283dedf97e8SMarc Zyngier #define vcpu_cp15_64_high(v,r) vcpu_cp15((v),(r)) 284dedf97e8SMarc Zyngier #define vcpu_cp15_64_low(v,r) vcpu_cp15((v),(r) + 1) 285f0a3eaffSVictor Kamensky #else 286dedf97e8SMarc Zyngier #define vcpu_cp15_64_high(v,r) vcpu_cp15((v),(r) + 1) 287dedf97e8SMarc Zyngier #define vcpu_cp15_64_low(v,r) vcpu_cp15((v),(r)) 288f0a3eaffSVictor Kamensky #endif 289f0a3eaffSVictor Kamensky 2904f8d6632SMarc Zyngier struct kvm_vm_stat { 2914f8d6632SMarc Zyngier u32 remote_tlb_flush; 2924f8d6632SMarc Zyngier }; 2934f8d6632SMarc Zyngier 2944f8d6632SMarc Zyngier struct kvm_vcpu_stat { 295f7819512SPaolo Bonzini u32 halt_successful_poll; 29662bea5bfSPaolo Bonzini u32 halt_attempted_poll; 2974f8d6632SMarc Zyngier u32 halt_wakeup; 298b19e6892SAmit Tomar u32 hvc_exit_stat; 299b19e6892SAmit Tomar u64 wfe_exit_stat; 300b19e6892SAmit Tomar u64 wfi_exit_stat; 301b19e6892SAmit Tomar u64 mmio_exit_user; 302b19e6892SAmit Tomar u64 mmio_exit_kernel; 303b19e6892SAmit Tomar u64 exits; 3044f8d6632SMarc Zyngier }; 3054f8d6632SMarc Zyngier 306473bdc0eSAnup Patel int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init); 3074f8d6632SMarc Zyngier unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); 3084f8d6632SMarc Zyngier int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); 3094f8d6632SMarc Zyngier int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); 3104f8d6632SMarc Zyngier int kvm_arm_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); 3114f8d6632SMarc Zyngier 3124f8d6632SMarc Zyngier #define KVM_ARCH_WANT_MMU_NOTIFIER 3134f8d6632SMarc Zyngier int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); 3144f8d6632SMarc Zyngier int kvm_unmap_hva_range(struct kvm *kvm, 3154f8d6632SMarc Zyngier unsigned long start, unsigned long end); 3164f8d6632SMarc Zyngier void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); 31735307b9aSMarc Zyngier int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end); 31835307b9aSMarc Zyngier int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); 3194f8d6632SMarc Zyngier 3204f8d6632SMarc Zyngier /* We do not have shadow page tables, hence the empty hooks */ 321fe71557aSTang Chen static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm, 322fe71557aSTang Chen unsigned long address) 323fe71557aSTang Chen { 324fe71557aSTang Chen } 325fe71557aSTang Chen 3264f8d6632SMarc Zyngier struct kvm_vcpu *kvm_arm_get_running_vcpu(void); 3274000be42SWill Deacon struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void); 3284f8d6632SMarc Zyngier 3294f8d6632SMarc Zyngier u64 kvm_call_hyp(void *hypfn, ...); 330cf5d3188SChristoffer Dall void force_vm_exit(const cpumask_t *mask); 3318199ed0eSMario Smarduch void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); 3324f8d6632SMarc Zyngier 3334f8d6632SMarc Zyngier int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, 3344f8d6632SMarc Zyngier int exception_index); 3354f8d6632SMarc Zyngier 3364f8d6632SMarc Zyngier int kvm_perf_init(void); 3374f8d6632SMarc Zyngier int kvm_perf_teardown(void); 3384f8d6632SMarc Zyngier 3394429fc64SAndre Przywara struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); 3404429fc64SAndre Przywara 341092bd143SMarc Zyngier static inline void __cpu_init_hyp_mode(phys_addr_t boot_pgd_ptr, 342092bd143SMarc Zyngier phys_addr_t pgd_ptr, 343092bd143SMarc Zyngier unsigned long hyp_stack_ptr, 344092bd143SMarc Zyngier unsigned long vector_ptr) 345092bd143SMarc Zyngier { 346092bd143SMarc Zyngier /* 347092bd143SMarc Zyngier * Call initialization code, and switch to the full blown 348092bd143SMarc Zyngier * HYP code. 349092bd143SMarc Zyngier */ 350092bd143SMarc Zyngier kvm_call_hyp((void *)boot_pgd_ptr, pgd_ptr, 351092bd143SMarc Zyngier hyp_stack_ptr, vector_ptr); 352092bd143SMarc Zyngier } 353092bd143SMarc Zyngier 35413a34e06SRadim Krčmář static inline void kvm_arch_hardware_disable(void) {} 3550865e636SRadim Krčmář static inline void kvm_arch_hardware_unsetup(void) {} 3560865e636SRadim Krčmář static inline void kvm_arch_sync_events(struct kvm *kvm) {} 3570865e636SRadim Krčmář static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} 3580865e636SRadim Krčmář static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {} 3590865e636SRadim Krčmář 36056c7f5e7SAlex Bennée void kvm_arm_init_debug(void); 36156c7f5e7SAlex Bennée void kvm_arm_setup_debug(struct kvm_vcpu *vcpu); 36256c7f5e7SAlex Bennée void kvm_arm_clear_debug(struct kvm_vcpu *vcpu); 36384e690bfSAlex Bennée void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu); 364bb0c70bcSShannon Zhao int kvm_arm_vcpu_arch_set_attr(struct kvm_vcpu *vcpu, 365bb0c70bcSShannon Zhao struct kvm_device_attr *attr); 366bb0c70bcSShannon Zhao int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu, 367bb0c70bcSShannon Zhao struct kvm_device_attr *attr); 368bb0c70bcSShannon Zhao int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu, 369bb0c70bcSShannon Zhao struct kvm_device_attr *attr); 37056c7f5e7SAlex Bennée 37121a4179cSMarc Zyngier /* #define kvm_call_hyp(f, ...) __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__) */ 37221a4179cSMarc Zyngier 37321a4179cSMarc Zyngier static inline void __cpu_init_stage2(void) 37421a4179cSMarc Zyngier { 37521a4179cSMarc Zyngier kvm_call_hyp(__init_stage2_translation); 37621a4179cSMarc Zyngier } 37721a4179cSMarc Zyngier 3784f8d6632SMarc Zyngier #endif /* __ARM64_KVM_HOST_H__ */ 379