target/arm/kvm: Make uncalled stubs explicitly unreachable
When we compile without KVM support !defined(CONFIG_KVM) we generate stubs for functions that the linker will still encounter. Sometimes these stubs can be executed safely and are placed in paths where they get executed with or without KVM. Other functions should never be called without KVM. Those functions should be guarded by kvm_enabled(), but should also be robust to refactoring mistakes. Putting a g_assert_not_reached() in the function should help. Additionally, the g_assert_not_reached() calls may actually help the linker remove some code. We remove the stubs for kvm_arm_get/put_virtual_time(), as they aren't necessary at all - the only caller is in kvm.c Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Andrew Jones <drjones@redhat.com> Message-id: 20201001061718.101915-3-drjones@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
94c7fefcb4
commit
281a3c330e
@ -344,18 +344,10 @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
|
/*
|
||||||
{
|
* It's safe to call these functions without KVM support.
|
||||||
/*
|
* They should either do nothing or return "not supported".
|
||||||
* This should never actually be called in the "not KVM" case,
|
*/
|
||||||
* but set up the fields to indicate an error anyway.
|
|
||||||
*/
|
|
||||||
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
|
|
||||||
cpu->host_cpu_probe_failed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
|
|
||||||
|
|
||||||
static inline bool kvm_arm_aarch32_supported(void)
|
static inline bool kvm_arm_aarch32_supported(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -371,23 +363,44 @@ static inline bool kvm_arm_sve_supported(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions should never actually be called without KVM support.
|
||||||
|
*/
|
||||||
|
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
|
||||||
|
{
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void kvm_arm_add_vcpu_properties(Object *obj)
|
||||||
|
{
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
|
static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
|
||||||
{
|
{
|
||||||
return -ENOENT;
|
g_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int kvm_arm_vgic_probe(void)
|
static inline int kvm_arm_vgic_probe(void)
|
||||||
{
|
{
|
||||||
return 0;
|
g_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {}
|
static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq)
|
||||||
static inline void kvm_arm_pmu_init(CPUState *cs) {}
|
{
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {}
|
static inline void kvm_arm_pmu_init(CPUState *cs)
|
||||||
|
{
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
|
||||||
|
{
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
static inline void kvm_arm_get_virtual_time(CPUState *cs) {}
|
|
||||||
static inline void kvm_arm_put_virtual_time(CPUState *cs) {}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline const char *gic_class_name(void)
|
static inline const char *gic_class_name(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user