diff options
Diffstat (limited to 'target/arm/kvm_arm.h')
-rw-r--r-- | target/arm/kvm_arm.h | 125 |
1 files changed, 43 insertions, 82 deletions
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 05c3de8..6a9b637 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -12,6 +12,7 @@ #define QEMU_KVM_ARM_H #include "system/kvm.h" +#include "target/arm/cpu-qom.h" #define KVM_ARM_VGIC_V2 (1 << 0) #define KVM_ARM_VGIC_V3 (1 << 1) @@ -83,8 +84,10 @@ void kvm_arm_cpu_pre_save(ARMCPU *cpu); * @cpu: ARMCPU * * Called from cpu_post_load() to update KVM CPU state from the cpreg list. + * + * Returns: true on success, or false if write_list_to_kvmstate failed. */ -void kvm_arm_cpu_post_load(ARMCPU *cpu); +bool kvm_arm_cpu_post_load(ARMCPU *cpu); /** * kvm_arm_reset_vcpu: @@ -94,13 +97,9 @@ void kvm_arm_cpu_post_load(ARMCPU *cpu); */ void kvm_arm_reset_vcpu(ARMCPU *cpu); -#ifdef CONFIG_KVM +struct kvm_vcpu_init; /** * kvm_arm_create_scratch_host_vcpu: - * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with - * QEMU_KVM_ARM_TARGET_NONE) to try as fallback if the kernel does not - * know the PREFERRED_TARGET ioctl. Passing NULL is the same as passing - * an empty array. * @fdarray: filled in with kvmfd, vmfd, cpufd file descriptors in that order * @init: filled in with the necessary values for creating a host * vcpu. If NULL is provided, will not init the vCPU (though the cpufd @@ -113,8 +112,7 @@ void kvm_arm_reset_vcpu(ARMCPU *cpu); * Returns: true on success (and fdarray and init are filled in), * false on failure (and fdarray and init are not valid). */ -bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, - int *fdarray, +bool kvm_arm_create_scratch_host_vcpu(int *fdarray, struct kvm_vcpu_init *init); /** @@ -163,6 +161,14 @@ void kvm_arm_add_vcpu_properties(ARMCPU *cpu); */ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp); +/* + * These "is some KVM subfeature enabled?" functions may be called + * when KVM support is not present, including in the user-mode + * emulators. The kvm-stub.c file is only built into the system + * emulators, so for user-mode emulation we provide "always false" + * stubs here. + */ +#ifndef CONFIG_USER_ONLY /** * kvm_arm_aarch32_supported: * @@ -194,39 +200,13 @@ bool kvm_arm_sve_supported(void); bool kvm_arm_mte_supported(void); /** - * kvm_arm_get_max_vm_ipa_size: - * @ms: Machine state handle - * @fixed_ipa: True when the IPA limit is fixed at 40. This is the case - * for legacy KVM. + * kvm_arm_el2_supported: * - * Returns the number of bits in the IPA address space supported by KVM + * Returns true if KVM can enable EL2 and false otherwise. */ -int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); - -int kvm_arm_vgic_probe(void); - -void kvm_arm_pmu_init(ARMCPU *cpu); -void kvm_arm_pmu_set_irq(ARMCPU *cpu, int irq); - -/** - * kvm_arm_pvtime_init: - * @cpu: ARMCPU - * @ipa: Per-vcpu guest physical base address of the pvtime structures - * - * Initializes PVTIME for the VCPU, setting the PVTIME IPA to @ipa. - */ -void kvm_arm_pvtime_init(ARMCPU *cpu, uint64_t ipa); - -int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); - -void kvm_arm_enable_mte(Object *cpuobj, Error **errp); - +bool kvm_arm_el2_supported(void); #else -/* - * It's safe to call these functions without KVM support. - * They should either do nothing or return "not supported". - */ static inline bool kvm_arm_aarch32_supported(void) { return false; @@ -247,59 +227,40 @@ static inline bool kvm_arm_mte_supported(void) 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(ARMCPU *cpu) -{ - g_assert_not_reached(); -} - -static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa) -{ - g_assert_not_reached(); -} - -static inline int kvm_arm_vgic_probe(void) +static inline bool kvm_arm_el2_supported(void) { - g_assert_not_reached(); + return false; } +#endif -static inline void kvm_arm_pmu_set_irq(ARMCPU *cpu, int irq) -{ - g_assert_not_reached(); -} +/** + * kvm_arm_get_max_vm_ipa_size: + * @ms: Machine state handle + * @fixed_ipa: True when the IPA limit is fixed at 40. This is the case + * for legacy KVM. + * + * Returns the number of bits in the IPA address space supported by KVM + */ +int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); -static inline void kvm_arm_pmu_init(ARMCPU *cpu) -{ - g_assert_not_reached(); -} +int kvm_arm_vgic_probe(void); -static inline void kvm_arm_pvtime_init(ARMCPU *cpu, uint64_t ipa) -{ - g_assert_not_reached(); -} +void kvm_arm_pmu_init(ARMCPU *cpu); +void kvm_arm_pmu_set_irq(ARMCPU *cpu, int irq); -static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) -{ - g_assert_not_reached(); -} +/** + * kvm_arm_pvtime_init: + * @cpu: ARMCPU + * @ipa: Per-vcpu guest physical base address of the pvtime structures + * + * Initializes PVTIME for the VCPU, setting the PVTIME IPA to @ipa. + */ +void kvm_arm_pvtime_init(ARMCPU *cpu, uint64_t ipa); -static inline uint32_t kvm_arm_sve_get_vls(ARMCPU *cpu) -{ - g_assert_not_reached(); -} +int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); -static inline void kvm_arm_enable_mte(Object *cpuobj, Error **errp) -{ - g_assert_not_reached(); -} +void kvm_arm_enable_mte(Object *cpuobj, Error **errp); -#endif +void arm_cpu_kvm_set_irq(void *arm_cpu, int irq, int level); #endif |