Skip to content

Commit cd49622

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Track value of cptr_el2 in struct kvm_vcpu_arch
Track the baseline guest value for cptr_el2 in struct kvm_vcpu_arch, similar to the other registers that control traps. Use this value when setting cptr_el2 for the guest. Currently this value is unchanged (CPTR_EL2_DEFAULT), but future patches will set trapping bits based on features supported for the guest. No functional change intended. Acked-by: Will Deacon <[email protected]> Signed-off-by: Fuad Tabba <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 12849ba commit cd49622

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ struct kvm_vcpu_arch {
290290
/* Values of trap registers for the guest. */
291291
u64 hcr_el2;
292292
u64 mdcr_el2;
293+
u64 cptr_el2;
293294

294295
/* Values of trap registers for the host before guest entry. */
295296
u64 mdcr_el2_host;

arch/arm64/kvm/arm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,7 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
11041104
}
11051105

11061106
vcpu_reset_hcr(vcpu);
1107+
vcpu->arch.cptr_el2 = CPTR_EL2_DEFAULT;
11071108

11081109
/*
11091110
* Handle the "start in power-off" case.

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
4141
___activate_traps(vcpu);
4242
__activate_traps_common(vcpu);
4343

44-
val = CPTR_EL2_DEFAULT;
44+
val = vcpu->arch.cptr_el2;
4545
val |= CPTR_EL2_TTA | CPTR_EL2_TAM;
4646
if (!update_fp_enabled(vcpu)) {
4747
val |= CPTR_EL2_TFP | CPTR_EL2_TZ;

0 commit comments

Comments
 (0)