Commit 066daa8d authored by Fuad Tabba's avatar Fuad Tabba Committed by Oliver Upton
Browse files

KVM: arm64: Initialize HCRX_EL2 traps in pKVM



Initialize and set the traps controlled by the HCRX_EL2 in pKVM.

Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
Signed-off-by: default avatarFuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20250314111832.4137161-3-tabba@google.com


Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
parent 44f979bf
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -166,8 +166,13 @@ static int pkvm_vcpu_init_traps(struct pkvm_hyp_vcpu *hyp_vcpu)

	pkvm_vcpu_reset_hcr(vcpu);

	if ((!pkvm_hyp_vcpu_is_protected(hyp_vcpu)))
	if ((!pkvm_hyp_vcpu_is_protected(hyp_vcpu))) {
		struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;

		/* Trust the host for non-protected vcpu features. */
		vcpu->arch.hcrx_el2 = host_vcpu->arch.hcrx_el2;
		return 0;
	}

	ret = pkvm_check_pvm_cpu_features(vcpu);
	if (ret)
@@ -175,6 +180,7 @@ static int pkvm_vcpu_init_traps(struct pkvm_hyp_vcpu *hyp_vcpu)

	pvm_init_traps_hcr(vcpu);
	pvm_init_traps_mdcr(vcpu);
	vcpu_set_hcrx(vcpu);

	return 0;
}