Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/locore.S
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | mp_virtdone: | ||||
tlbi vmalle1 | tlbi vmalle1 | ||||
dsb sy | dsb sy | ||||
isb | isb | ||||
b init_secondary | b init_secondary | ||||
END(mpentry) | END(mpentry) | ||||
#endif | #endif | ||||
.align 3 | |||||
.globl _C_LABEL(hypmode_enabled) | |||||
_C_LABEL(hypmode_enabled): | |||||
.zero 8 | |||||
/* | /* | ||||
* If we are started in EL2, configure the required hypervisor | * If we are started in EL2, configure the required hypervisor | ||||
* registers and drop to EL1. | * registers and drop to EL1. | ||||
*/ | */ | ||||
LENTRY(drop_to_el1) | LENTRY(drop_to_el1) | ||||
mrs x23, CurrentEL | mrs x23, CurrentEL | ||||
lsr x23, x23, #2 | lsr x23, x23, #2 | ||||
cmp x23, #0x2 | cmp x23, #0x2 | ||||
b.eq 1f | b.eq 1f | ||||
ret | ret | ||||
1: | 1: | ||||
/* | |||||
* If the MMU is active, then it is using a page table where VA == PA. | |||||
* But the page table won't have entries for the hypervisor EL2 | |||||
* initialization code which is loaded into memory with the vmm module. | |||||
* | |||||
* So we disable the MMU in EL2 to make the vmm hypervisor code run | |||||
* successfully. | |||||
*/ | |||||
dsb sy | |||||
mrs x2, sctlr_el2 | |||||
bic x2, x2, SCTLR_M | |||||
msr sctlr_el2, x2 | |||||
isb | |||||
/* Configure the Hypervisor */ | /* Configure the Hypervisor */ | ||||
mov x2, #(HCR_RW) | mov x2, #(HCR_RW & ~HCR_HCD) | ||||
msr hcr_el2, x2 | msr hcr_el2, x2 | ||||
/* Load the Virtualization Process ID Register */ | /* Load the Virtualization Process ID Register */ | ||||
mrs x2, midr_el1 | mrs x2, midr_el1 | ||||
msr vpidr_el2, x2 | msr vpidr_el2, x2 | ||||
/* Load the Virtualization Multiprocess ID Register */ | /* Load the Virtualization Multiprocess ID Register */ | ||||
mrs x2, mpidr_el1 | mrs x2, mpidr_el1 | ||||
Show All 14 Lines | 1: | ||||
mrs x2, cnthctl_el2 | mrs x2, cnthctl_el2 | ||||
orr x2, x2, #(CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN) | orr x2, x2, #(CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN) | ||||
msr cnthctl_el2, x2 | msr cnthctl_el2, x2 | ||||
/* Set the counter offset to a known value */ | /* Set the counter offset to a known value */ | ||||
msr cntvoff_el2, xzr | msr cntvoff_el2, xzr | ||||
/* Hypervisor trap functions */ | /* Hypervisor trap functions */ | ||||
adrp x2, hyp_vectors | adrp x2, hyp_stub_vectors | ||||
add x2, x2, :lo12:hyp_vectors | |||||
msr vbar_el2, x2 | msr vbar_el2, x2 | ||||
/* Use the host VTTBR_EL2 to tell the host and the guests apart */ | |||||
mov x2, #VTTBR_HOST | |||||
msr vttbr_el2, x2 | |||||
/* Mark hypervisor mode as enabled */ | |||||
mov x1, #1 | |||||
adr x2, hypmode_enabled | |||||
str x1, [x2] | |||||
mov x2, #(PSR_F | PSR_I | PSR_A | PSR_D | PSR_M_EL1h) | mov x2, #(PSR_F | PSR_I | PSR_A | PSR_D | PSR_M_EL1h) | ||||
msr spsr_el2, x2 | msr spsr_el2, x2 | ||||
/* Configure GICv3 CPU interface */ | /* Configure GICv3 CPU interface */ | ||||
mrs x2, id_aa64pfr0_el1 | mrs x2, id_aa64pfr0_el1 | ||||
/* Extract GIC bits from the register */ | /* Extract GIC bits from the register */ | ||||
ubfx x2, x2, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_BITS | ubfx x2, x2, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_BITS | ||||
/* GIC[3:0] == 0001 - GIC CPU interface via special regs. supported */ | /* GIC[3:0] == 0001 - GIC CPU interface via special regs. supported */ | ||||
Show All 12 Lines | 2: | ||||
eret | eret | ||||
.align 3 | .align 3 | ||||
.Lsctlr_res1: | .Lsctlr_res1: | ||||
.quad SCTLR_RES1 | .quad SCTLR_RES1 | ||||
LEND(drop_to_el1) | LEND(drop_to_el1) | ||||
hcr: | |||||
/* Make sure the HVC instruction is not disabled */ | |||||
.quad (HCR_RW & ~HCR_HCD) | |||||
#define VECT_EMPTY \ | #define VECT_EMPTY \ | ||||
.align 7; \ | .align 7; \ | ||||
1: b 1b | 1: b 1b | ||||
.align 11 | .align 11 | ||||
hyp_vectors: | hyp_vectors: | ||||
VECT_EMPTY /* Synchronous EL2t */ | VECT_EMPTY /* Synchronous EL2t */ | ||||
VECT_EMPTY /* IRQ EL2t */ | VECT_EMPTY /* IRQ EL2t */ | ||||
▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | |||||
sctlr_clear: | sctlr_clear: | ||||
/* Bits to clear */ | /* Bits to clear */ | ||||
.quad (SCTLR_EE | SCTLR_EOE | SCTLR_IESB | SCTLR_WXN | SCTLR_UMA | \ | .quad (SCTLR_EE | SCTLR_EOE | SCTLR_IESB | SCTLR_WXN | SCTLR_UMA | \ | ||||
SCTLR_ITD | SCTLR_A) | SCTLR_ITD | SCTLR_A) | ||||
LEND(start_mmu) | LEND(start_mmu) | ||||
ENTRY(abort) | ENTRY(abort) | ||||
b abort | b abort | ||||
.align 12 /* 4KiB aligned */ | |||||
END(abort) | END(abort) | ||||
.align 3 | .align 3 | ||||
init_pt_va: | init_pt_va: | ||||
.quad pagetable /* XXX: Keep page tables VA */ | .quad pagetable /* XXX: Keep page tables VA */ | ||||
.section .init_pagetable, "aw", %nobits | .section .init_pagetable, "aw", %nobits | ||||
.align PAGE_SHIFT | .align PAGE_SHIFT | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |