Skip to content

Commit 05c93cb

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Initialize HCR_EL2
Initialize HCR_EL2 such that EL2&0 is considered 'InHost', allowing the use of (mostly) unmodified EL1 selftests at EL2. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 7ae44d1 commit 05c93cb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tools/testing/selftests/kvm/lib/arm64/processor.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ void aarch64_vcpu_setup(struct kvm_vcpu *vcpu, struct kvm_vcpu_init *init)
369369
vcpu_set_reg(vcpu, ctxt_reg_alias(vcpu, SYS_MAIR_EL1), DEFAULT_MAIR_EL1);
370370
vcpu_set_reg(vcpu, ctxt_reg_alias(vcpu, SYS_TTBR0_EL1), ttbr0_el1);
371371
vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_TPIDR_EL1), vcpu->id);
372+
373+
if (!vcpu_has_el2(vcpu))
374+
return;
375+
376+
vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_HCR_EL2),
377+
HCR_EL2_RW | HCR_EL2_TGE | HCR_EL2_E2H);
372378
}
373379

374380
void vcpu_arch_dump(FILE *stream, struct kvm_vcpu *vcpu, uint8_t indent)

0 commit comments

Comments
 (0)