mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 15:12:45 +07:00
342cd0ab0e
Sets up KVM code to handle all exceptions taken to Hyp mode. When the kernel is booted in Hyp mode, calling an hvc instruction with r0 pointing to the new vectors, the HVBAR is changed to the the vector pointers. This allows subsystems (like KVM here) to execute code in Hyp-mode with the MMU disabled. We initialize other Hyp-mode registers and enables the MMU for Hyp-mode from the id-mapped hyp initialization code. Afterwards, the HVBAR is changed to point to KVM Hyp vectors used to catch guest faults and to switch to Hyp mode to perform a world-switch into a KVM guest. Also provides memory mapping code to map required code pages, data structures, and I/O regions accessed in Hyp mode at the same virtual address as the host kernel virtual addresses, but which conforms to the architectural requirements for translations in Hyp mode. This interface is added in arch/arm/kvm/arm_mmu.c and comprises: - create_hyp_mappings(from, to); - create_hyp_io_mappings(from, to, phys_addr); - free_hyp_pmds(); Reviewed-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
79 lines
2.9 KiB
C
79 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2012 - Virtual Open Systems and Columbia University
|
|
* Author: Christoffer Dall <c.dall@virtualopensystems.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License, version 2, as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __ARM_KVM_ASM_H__
|
|
#define __ARM_KVM_ASM_H__
|
|
|
|
/* 0 is reserved as an invalid value. */
|
|
#define c0_MPIDR 1 /* MultiProcessor ID Register */
|
|
#define c0_CSSELR 2 /* Cache Size Selection Register */
|
|
#define c1_SCTLR 3 /* System Control Register */
|
|
#define c1_ACTLR 4 /* Auxilliary Control Register */
|
|
#define c1_CPACR 5 /* Coprocessor Access Control */
|
|
#define c2_TTBR0 6 /* Translation Table Base Register 0 */
|
|
#define c2_TTBR0_high 7 /* TTBR0 top 32 bits */
|
|
#define c2_TTBR1 8 /* Translation Table Base Register 1 */
|
|
#define c2_TTBR1_high 9 /* TTBR1 top 32 bits */
|
|
#define c2_TTBCR 10 /* Translation Table Base Control R. */
|
|
#define c3_DACR 11 /* Domain Access Control Register */
|
|
#define c5_DFSR 12 /* Data Fault Status Register */
|
|
#define c5_IFSR 13 /* Instruction Fault Status Register */
|
|
#define c5_ADFSR 14 /* Auxilary Data Fault Status R */
|
|
#define c5_AIFSR 15 /* Auxilary Instrunction Fault Status R */
|
|
#define c6_DFAR 16 /* Data Fault Address Register */
|
|
#define c6_IFAR 17 /* Instruction Fault Address Register */
|
|
#define c9_L2CTLR 18 /* Cortex A15 L2 Control Register */
|
|
#define c10_PRRR 19 /* Primary Region Remap Register */
|
|
#define c10_NMRR 20 /* Normal Memory Remap Register */
|
|
#define c12_VBAR 21 /* Vector Base Address Register */
|
|
#define c13_CID 22 /* Context ID Register */
|
|
#define c13_TID_URW 23 /* Thread ID, User R/W */
|
|
#define c13_TID_URO 24 /* Thread ID, User R/O */
|
|
#define c13_TID_PRIV 25 /* Thread ID, Privileged */
|
|
#define NR_CP15_REGS 26 /* Number of regs (incl. invalid) */
|
|
|
|
#define ARM_EXCEPTION_RESET 0
|
|
#define ARM_EXCEPTION_UNDEFINED 1
|
|
#define ARM_EXCEPTION_SOFTWARE 2
|
|
#define ARM_EXCEPTION_PREF_ABORT 3
|
|
#define ARM_EXCEPTION_DATA_ABORT 4
|
|
#define ARM_EXCEPTION_IRQ 5
|
|
#define ARM_EXCEPTION_FIQ 6
|
|
#define ARM_EXCEPTION_HVC 7
|
|
|
|
#ifndef __ASSEMBLY__
|
|
struct kvm_vcpu;
|
|
|
|
extern char __kvm_hyp_init[];
|
|
extern char __kvm_hyp_init_end[];
|
|
|
|
extern char __kvm_hyp_exit[];
|
|
extern char __kvm_hyp_exit_end[];
|
|
|
|
extern char __kvm_hyp_vector[];
|
|
|
|
extern char __kvm_hyp_code_start[];
|
|
extern char __kvm_hyp_code_end[];
|
|
|
|
extern void __kvm_flush_vm_context(void);
|
|
|
|
extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
|
|
#endif
|
|
|
|
#endif /* __ARM_KVM_ASM_H__ */
|