Skip to content

Commit d53a4c8

Browse files
committed
Merge tag 'kvmarm-fixes-5.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm fixes for 5.4, take #1 - Remove the now obsolete hyp_alternate_select construct - Fix the TRACE_INCLUDE_PATH macro in the vgic code
2 parents 24c29b7 + aac60f1 commit d53a4c8

File tree

4 files changed

+25
-54
lines changed

4 files changed

+25
-54
lines changed

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,6 @@
4747
#define read_sysreg_el2(r) read_sysreg_elx(r, _EL2, _EL1)
4848
#define write_sysreg_el2(v,r) write_sysreg_elx(v, r, _EL2, _EL1)
4949

50-
/**
51-
* hyp_alternate_select - Generates patchable code sequences that are
52-
* used to switch between two implementations of a function, depending
53-
* on the availability of a feature.
54-
*
55-
* @fname: a symbol name that will be defined as a function returning a
56-
* function pointer whose type will match @orig and @alt
57-
* @orig: A pointer to the default function, as returned by @fname when
58-
* @cond doesn't hold
59-
* @alt: A pointer to the alternate function, as returned by @fname
60-
* when @cond holds
61-
* @cond: a CPU feature (as described in asm/cpufeature.h)
62-
*/
63-
#define hyp_alternate_select(fname, orig, alt, cond) \
64-
typeof(orig) * __hyp_text fname(void) \
65-
{ \
66-
typeof(alt) *val = orig; \
67-
asm volatile(ALTERNATIVE("nop \n", \
68-
"mov %0, %1 \n", \
69-
cond) \
70-
: "+r" (val) : "r" (alt)); \
71-
return val; \
72-
}
73-
7450
int __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu);
7551

7652
void __vgic_v3_save_state(struct kvm_vcpu *vcpu);

arch/arm64/kvm/hyp/switch.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,6 @@ static void __hyp_text __hyp_vgic_restore_state(struct kvm_vcpu *vcpu)
229229
}
230230
}
231231

232-
static bool __hyp_text __true_value(void)
233-
{
234-
return true;
235-
}
236-
237-
static bool __hyp_text __false_value(void)
238-
{
239-
return false;
240-
}
241-
242-
static hyp_alternate_select(__check_arm_834220,
243-
__false_value, __true_value,
244-
ARM64_WORKAROUND_834220);
245-
246232
static bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar)
247233
{
248234
u64 par, tmp;
@@ -298,7 +284,8 @@ static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu)
298284
* resolve the IPA using the AT instruction.
299285
*/
300286
if (!(esr & ESR_ELx_S1PTW) &&
301-
(__check_arm_834220()() || (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) {
287+
(cpus_have_const_cap(ARM64_WORKAROUND_834220) ||
288+
(esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) {
302289
if (!__translate_far_to_hpfar(far, &hpfar))
303290
return false;
304291
} else {

arch/arm64/kvm/hyp/tlb.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ static void __hyp_text __tlb_switch_to_guest_nvhe(struct kvm *kvm,
6767
isb();
6868
}
6969

70-
static hyp_alternate_select(__tlb_switch_to_guest,
71-
__tlb_switch_to_guest_nvhe,
72-
__tlb_switch_to_guest_vhe,
73-
ARM64_HAS_VIRT_HOST_EXTN);
70+
static void __hyp_text __tlb_switch_to_guest(struct kvm *kvm,
71+
struct tlb_inv_context *cxt)
72+
{
73+
if (has_vhe())
74+
__tlb_switch_to_guest_vhe(kvm, cxt);
75+
else
76+
__tlb_switch_to_guest_nvhe(kvm, cxt);
77+
}
7478

7579
static void __hyp_text __tlb_switch_to_host_vhe(struct kvm *kvm,
7680
struct tlb_inv_context *cxt)
@@ -98,10 +102,14 @@ static void __hyp_text __tlb_switch_to_host_nvhe(struct kvm *kvm,
98102
write_sysreg(0, vttbr_el2);
99103
}
100104

101-
static hyp_alternate_select(__tlb_switch_to_host,
102-
__tlb_switch_to_host_nvhe,
103-
__tlb_switch_to_host_vhe,
104-
ARM64_HAS_VIRT_HOST_EXTN);
105+
static void __hyp_text __tlb_switch_to_host(struct kvm *kvm,
106+
struct tlb_inv_context *cxt)
107+
{
108+
if (has_vhe())
109+
__tlb_switch_to_host_vhe(kvm, cxt);
110+
else
111+
__tlb_switch_to_host_nvhe(kvm, cxt);
112+
}
105113

106114
void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
107115
{
@@ -111,7 +119,7 @@ void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
111119

112120
/* Switch to requested VMID */
113121
kvm = kern_hyp_va(kvm);
114-
__tlb_switch_to_guest()(kvm, &cxt);
122+
__tlb_switch_to_guest(kvm, &cxt);
115123

116124
/*
117125
* We could do so much better if we had the VA as well.
@@ -154,7 +162,7 @@ void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
154162
if (!has_vhe() && icache_is_vpipt())
155163
__flush_icache_all();
156164

157-
__tlb_switch_to_host()(kvm, &cxt);
165+
__tlb_switch_to_host(kvm, &cxt);
158166
}
159167

160168
void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm)
@@ -165,13 +173,13 @@ void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm)
165173

166174
/* Switch to requested VMID */
167175
kvm = kern_hyp_va(kvm);
168-
__tlb_switch_to_guest()(kvm, &cxt);
176+
__tlb_switch_to_guest(kvm, &cxt);
169177

170178
__tlbi(vmalls12e1is);
171179
dsb(ish);
172180
isb();
173181

174-
__tlb_switch_to_host()(kvm, &cxt);
182+
__tlb_switch_to_host(kvm, &cxt);
175183
}
176184

177185
void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu)
@@ -180,13 +188,13 @@ void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu)
180188
struct tlb_inv_context cxt;
181189

182190
/* Switch to requested VMID */
183-
__tlb_switch_to_guest()(kvm, &cxt);
191+
__tlb_switch_to_guest(kvm, &cxt);
184192

185193
__tlbi(vmalle1);
186194
dsb(nsh);
187195
isb();
188196

189-
__tlb_switch_to_host()(kvm, &cxt);
197+
__tlb_switch_to_host(kvm, &cxt);
190198
}
191199

192200
void __hyp_text __kvm_flush_vm_context(void)

virt/kvm/arm/vgic/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TRACE_EVENT(vgic_update_irq_pending,
3030
#endif /* _TRACE_VGIC_H */
3131

3232
#undef TRACE_INCLUDE_PATH
33-
#define TRACE_INCLUDE_PATH ../../../virt/kvm/arm/vgic
33+
#define TRACE_INCLUDE_PATH ../../virt/kvm/arm/vgic
3434
#undef TRACE_INCLUDE_FILE
3535
#define TRACE_INCLUDE_FILE trace
3636

0 commit comments

Comments
 (0)