Skip to content

Commit b7787e6

Browse files
chazyMarc Zyngier
authored andcommitted
KVM: arm64: Cleanup __activate_traps and __deactive_traps for VHE and non-VHE
To make the code more readable and to avoid the overhead of a function call, let's get rid of a pair of the alternative function selectors and explicitly call the VHE and non-VHE functions using the has_vhe() static key based selector instead, telling the compiler to try to inline the static function if it can. Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent a246562 commit b7787e6

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void __hyp_text __deactivate_traps_common(void)
8686
write_sysreg(0, pmuserenr_el0);
8787
}
8888

89-
static void __hyp_text __activate_traps_vhe(struct kvm_vcpu *vcpu)
89+
static void activate_traps_vhe(struct kvm_vcpu *vcpu)
9090
{
9191
u64 val;
9292

@@ -109,10 +109,6 @@ static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu)
109109
write_sysreg(val, cptr_el2);
110110
}
111111

112-
static hyp_alternate_select(__activate_traps_arch,
113-
__activate_traps_nvhe, __activate_traps_vhe,
114-
ARM64_HAS_VIRT_HOST_EXTN);
115-
116112
static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
117113
{
118114
u64 hcr = vcpu->arch.hcr_el2;
@@ -123,10 +119,13 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
123119
write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2);
124120

125121
__activate_traps_fpsimd32(vcpu);
126-
__activate_traps_arch()(vcpu);
122+
if (has_vhe())
123+
activate_traps_vhe(vcpu);
124+
else
125+
__activate_traps_nvhe(vcpu);
127126
}
128127

129-
static void __hyp_text __deactivate_traps_vhe(void)
128+
static void deactivate_traps_vhe(void)
130129
{
131130
extern char vectors[]; /* kernel exception vectors */
132131
write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
@@ -148,10 +147,6 @@ static void __hyp_text __deactivate_traps_nvhe(void)
148147
write_sysreg(CPTR_EL2_DEFAULT, cptr_el2);
149148
}
150149

151-
static hyp_alternate_select(__deactivate_traps_arch,
152-
__deactivate_traps_nvhe, __deactivate_traps_vhe,
153-
ARM64_HAS_VIRT_HOST_EXTN);
154-
155150
static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
156151
{
157152
/*
@@ -163,7 +158,10 @@ static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
163158
if (vcpu->arch.hcr_el2 & HCR_VSE)
164159
vcpu->arch.hcr_el2 = read_sysreg(hcr_el2);
165160

166-
__deactivate_traps_arch()();
161+
if (has_vhe())
162+
deactivate_traps_vhe();
163+
else
164+
__deactivate_traps_nvhe();
167165
}
168166

169167
void activate_traps_vhe_load(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)