2013-03-05 04:34:42 +04:00
|
|
|
/*
|
|
|
|
* QEMU KVM support -- ARM specific functions.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Linaro Limited
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_KVM_ARM_H
|
|
|
|
#define QEMU_KVM_ARM_H
|
|
|
|
|
|
|
|
#include "sysemu/kvm.h"
|
|
|
|
#include "exec/memory.h"
|
2016-10-04 15:28:08 +03:00
|
|
|
#include "qemu/error-report.h"
|
2013-03-05 04:34:42 +04:00
|
|
|
|
2020-03-11 16:16:16 +03:00
|
|
|
#define KVM_ARM_VGIC_V2 (1 << 0)
|
|
|
|
#define KVM_ARM_VGIC_V3 (1 << 1)
|
|
|
|
|
2014-06-19 21:06:26 +04:00
|
|
|
/**
|
|
|
|
* kvm_arm_vcpu_init:
|
|
|
|
* @cs: CPUState
|
|
|
|
*
|
|
|
|
* Initialize (or reinitialize) the VCPU by invoking the
|
|
|
|
* KVM_ARM_VCPU_INIT ioctl with the CPU type and feature
|
|
|
|
* bitmask specified in the CPUState.
|
|
|
|
*
|
|
|
|
* Returns: 0 if success else < 0 error code
|
|
|
|
*/
|
|
|
|
int kvm_arm_vcpu_init(CPUState *cs);
|
|
|
|
|
2019-10-31 17:27:31 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_vcpu_finalize:
|
2019-10-31 17:27:31 +03:00
|
|
|
* @cs: CPUState
|
2020-01-30 19:02:05 +03:00
|
|
|
* @feature: feature to finalize
|
2019-10-31 17:27:31 +03:00
|
|
|
*
|
|
|
|
* Finalizes the configuration of the specified VCPU feature by
|
|
|
|
* invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring
|
|
|
|
* this are documented in the "KVM_ARM_VCPU_FINALIZE" section of
|
|
|
|
* KVM's API documentation.
|
|
|
|
*
|
|
|
|
* Returns: 0 if success else < 0 error code
|
|
|
|
*/
|
|
|
|
int kvm_arm_vcpu_finalize(CPUState *cs, int feature);
|
|
|
|
|
2013-03-05 04:34:42 +04:00
|
|
|
/**
|
|
|
|
* kvm_arm_register_device:
|
|
|
|
* @mr: memory region for this device
|
|
|
|
* @devid: the KVM device ID
|
2014-02-26 21:20:00 +04:00
|
|
|
* @group: device control API group for setting addresses
|
|
|
|
* @attr: device control API address type
|
|
|
|
* @dev_fd: device control device file descriptor (or -1 if not supported)
|
2018-06-22 15:28:35 +03:00
|
|
|
* @addr_ormask: value to be OR'ed with resolved address
|
2013-03-05 04:34:42 +04:00
|
|
|
*
|
|
|
|
* Remember the memory region @mr, and when it is mapped by the
|
|
|
|
* machine model, tell the kernel that base address using the
|
2014-02-26 21:20:00 +04:00
|
|
|
* KVM_ARM_SET_DEVICE_ADDRESS ioctl or the newer device control API. @devid
|
|
|
|
* should be the ID of the device as defined by KVM_ARM_SET_DEVICE_ADDRESS or
|
|
|
|
* the arm-vgic device in the device control API.
|
|
|
|
* The machine model may map
|
|
|
|
* and unmap the device multiple times; the kernel will only be told the final
|
|
|
|
* address at the point where machine init is complete.
|
2013-03-05 04:34:42 +04:00
|
|
|
*/
|
2014-02-26 21:20:00 +04:00
|
|
|
void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
|
2018-06-22 15:28:35 +03:00
|
|
|
uint64_t attr, int dev_fd, uint64_t addr_ormask);
|
2013-03-05 04:34:42 +04:00
|
|
|
|
2014-12-11 15:07:53 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_init_cpreg_list:
|
2018-10-08 16:55:02 +03:00
|
|
|
* @cpu: ARMCPU
|
2014-12-11 15:07:53 +03:00
|
|
|
*
|
2018-10-08 16:55:02 +03:00
|
|
|
* Initialize the ARMCPU cpreg list according to the kernel's
|
2014-12-11 15:07:53 +03:00
|
|
|
* definition of what CPU registers it knows about (and throw away
|
|
|
|
* the previous TCG-created cpreg list).
|
|
|
|
*
|
|
|
|
* Returns: 0 if success, else < 0 error code
|
|
|
|
*/
|
|
|
|
int kvm_arm_init_cpreg_list(ARMCPU *cpu);
|
|
|
|
|
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_reg_syncs_via_cpreg_list:
|
|
|
|
* @regidx: KVM register index
|
2014-12-11 15:07:53 +03:00
|
|
|
*
|
|
|
|
* Return true if this KVM register should be synchronized via the
|
|
|
|
* cpreg list of arbitrary system registers, false if it is synchronized
|
|
|
|
* by hand using code in kvm_arch_get/put_registers().
|
|
|
|
*/
|
|
|
|
bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx);
|
|
|
|
|
2015-07-21 13:18:45 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_cpreg_level:
|
|
|
|
* @regidx: KVM register index
|
2015-07-21 13:18:45 +03:00
|
|
|
*
|
|
|
|
* Return the level of this coprocessor/system register. Return value is
|
|
|
|
* either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STATE.
|
|
|
|
*/
|
|
|
|
int kvm_arm_cpreg_level(uint64_t regidx);
|
|
|
|
|
2013-06-25 21:16:07 +04:00
|
|
|
/**
|
|
|
|
* write_list_to_kvmstate:
|
|
|
|
* @cpu: ARMCPU
|
2015-07-21 13:18:45 +03:00
|
|
|
* @level: the state level to sync
|
2013-06-25 21:16:07 +04:00
|
|
|
*
|
|
|
|
* For each register listed in the ARMCPU cpreg_indexes list, write
|
|
|
|
* its value from the cpreg_values list into the kernel (via ioctl).
|
|
|
|
* This updates KVM's working data structures from TCG data or
|
|
|
|
* from incoming migration state.
|
|
|
|
*
|
|
|
|
* Returns: true if all register values were updated correctly,
|
|
|
|
* false if some register was unknown to the kernel or could not
|
|
|
|
* be written (eg constant register with the wrong value).
|
|
|
|
* Note that we do not stop early on failure -- we will attempt
|
|
|
|
* writing all registers in the list.
|
|
|
|
*/
|
2015-07-21 13:18:45 +03:00
|
|
|
bool write_list_to_kvmstate(ARMCPU *cpu, int level);
|
2013-06-25 21:16:07 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* write_kvmstate_to_list:
|
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* For each register listed in the ARMCPU cpreg_indexes list, write
|
|
|
|
* its value from the kernel into the cpreg_values list. This is used to
|
|
|
|
* copy info from KVM's working data structures into TCG or
|
|
|
|
* for outbound migration.
|
|
|
|
*
|
|
|
|
* Returns: true if all register values were read correctly,
|
|
|
|
* false if some register was unknown or could not be read.
|
|
|
|
* Note that we do not stop early on failure -- we will attempt
|
|
|
|
* reading all registers in the list.
|
|
|
|
*/
|
|
|
|
bool write_kvmstate_to_list(ARMCPU *cpu);
|
|
|
|
|
2020-01-30 19:02:06 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_cpu_pre_save:
|
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* Called after write_kvmstate_to_list() from cpu_pre_save() to update
|
|
|
|
* the cpreg list with KVM CPU state.
|
|
|
|
*/
|
|
|
|
void kvm_arm_cpu_pre_save(ARMCPU *cpu);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_arm_cpu_post_load:
|
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* Called from cpu_post_load() to update KVM CPU state from the cpreg list.
|
|
|
|
*/
|
|
|
|
void kvm_arm_cpu_post_load(ARMCPU *cpu);
|
|
|
|
|
2013-03-20 16:11:56 +04:00
|
|
|
/**
|
|
|
|
* kvm_arm_reset_vcpu:
|
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* Called at reset time to kernel registers to their initial values.
|
|
|
|
*/
|
|
|
|
void kvm_arm_reset_vcpu(ARMCPU *cpu);
|
|
|
|
|
2018-10-24 09:50:16 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_init_serror_injection:
|
|
|
|
* @cs: CPUState
|
|
|
|
*
|
|
|
|
* Check whether KVM can set guest SError syndrome.
|
|
|
|
*/
|
|
|
|
void kvm_arm_init_serror_injection(CPUState *cs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_get_vcpu_events:
|
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* Get VCPU related state from kvm.
|
2020-01-30 19:02:05 +03:00
|
|
|
*
|
|
|
|
* Returns: 0 if success else < 0 error code
|
2018-10-24 09:50:16 +03:00
|
|
|
*/
|
|
|
|
int kvm_get_vcpu_events(ARMCPU *cpu);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_put_vcpu_events:
|
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* Put VCPU related state to kvm.
|
2020-01-30 19:02:05 +03:00
|
|
|
*
|
|
|
|
* Returns: 0 if success else < 0 error code
|
2018-10-24 09:50:16 +03:00
|
|
|
*/
|
|
|
|
int kvm_put_vcpu_events(ARMCPU *cpu);
|
|
|
|
|
2013-11-22 21:17:17 +04:00
|
|
|
#ifdef CONFIG_KVM
|
|
|
|
/**
|
|
|
|
* 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
|
2016-03-30 19:27:24 +03:00
|
|
|
* know the PREFERRED_TARGET ioctl. Passing NULL is the same as passing
|
|
|
|
* an empty array.
|
2013-11-22 21:17:17 +04:00
|
|
|
* @fdarray: filled in with kvmfd, vmfd, cpufd file descriptors in that order
|
2016-03-30 19:27:24 +03:00
|
|
|
* @init: filled in with the necessary values for creating a host
|
|
|
|
* vcpu. If NULL is provided, will not init the vCPU (though the cpufd
|
|
|
|
* will still be set up).
|
2013-11-22 21:17:17 +04:00
|
|
|
*
|
|
|
|
* Create a scratch vcpu in its own VM of the type preferred by the host
|
|
|
|
* kernel (as would be used for '-cpu host'), for purposes of probing it
|
|
|
|
* for capabilities.
|
|
|
|
*
|
|
|
|
* 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,
|
|
|
|
struct kvm_vcpu_init *init);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_arm_destroy_scratch_host_vcpu:
|
|
|
|
* @fdarray: array of fds as set up by kvm_arm_create_scratch_host_vcpu
|
|
|
|
*
|
|
|
|
* Tear down the scratch vcpu created by kvm_arm_create_scratch_host_vcpu.
|
|
|
|
*/
|
|
|
|
void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);
|
|
|
|
|
|
|
|
#define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU
|
|
|
|
|
2018-03-09 20:09:44 +03:00
|
|
|
/**
|
|
|
|
* ARMHostCPUFeatures: information about the host CPU (identified
|
|
|
|
* by asking the host kernel)
|
|
|
|
*/
|
|
|
|
typedef struct ARMHostCPUFeatures {
|
2018-11-19 18:29:07 +03:00
|
|
|
ARMISARegisters isar;
|
2013-11-22 21:17:17 +04:00
|
|
|
uint64_t features;
|
|
|
|
uint32_t target;
|
|
|
|
const char *dtb_compatible;
|
2018-03-09 20:09:44 +03:00
|
|
|
} ARMHostCPUFeatures;
|
2013-11-22 21:17:17 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_arm_get_host_cpu_features:
|
2020-01-30 19:02:05 +03:00
|
|
|
* @ahcf: ARMHostCPUClass to fill in
|
2013-11-22 21:17:17 +04:00
|
|
|
*
|
|
|
|
* Probe the capabilities of the host kernel's preferred CPU and fill
|
|
|
|
* in the ARMHostCPUClass struct accordingly.
|
2020-01-30 19:02:05 +03:00
|
|
|
*
|
|
|
|
* Returns true on success and false otherwise.
|
2013-11-22 21:17:17 +04:00
|
|
|
*/
|
2018-03-09 20:09:44 +03:00
|
|
|
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf);
|
2013-11-22 21:17:17 +04:00
|
|
|
|
2019-10-31 17:27:33 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_sve_get_vls:
|
|
|
|
* @cs: CPUState
|
|
|
|
* @map: bitmap to fill in
|
|
|
|
*
|
|
|
|
* Get all the SVE vector lengths supported by the KVM host, setting
|
|
|
|
* the bits corresponding to their length in quadwords minus one
|
|
|
|
* (vq - 1) in @map up to ARM_MAX_VQ.
|
|
|
|
*/
|
|
|
|
void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map);
|
|
|
|
|
2018-03-09 20:09:44 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_set_cpu_features_from_host:
|
|
|
|
* @cpu: ARMCPU to set the features for
|
|
|
|
*
|
|
|
|
* Set up the ARMCPU struct fields up to match the information probed
|
|
|
|
* from the host CPU.
|
|
|
|
*/
|
|
|
|
void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
|
2015-04-01 19:57:30 +03:00
|
|
|
|
2020-01-30 19:02:06 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_add_vcpu_properties:
|
|
|
|
* @obj: The CPU object to add the properties to
|
|
|
|
*
|
|
|
|
* Add all KVM specific CPU properties to the CPU object. These
|
|
|
|
* are the CPU properties with "kvm-" prefixed names.
|
|
|
|
*/
|
|
|
|
void kvm_arm_add_vcpu_properties(Object *obj);
|
|
|
|
|
2019-08-02 15:25:26 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_aarch32_supported:
|
|
|
|
*
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
* Returns: true if KVM can enable AArch32 mode
|
2019-08-02 15:25:26 +03:00
|
|
|
* and false otherwise.
|
|
|
|
*/
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
bool kvm_arm_aarch32_supported(void);
|
2019-08-02 15:25:26 +03:00
|
|
|
|
2019-08-02 15:25:27 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_pmu_supported:
|
2019-08-02 15:25:27 +03:00
|
|
|
*
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
* Returns: true if KVM can enable the PMU
|
2019-08-02 15:25:27 +03:00
|
|
|
* and false otherwise.
|
|
|
|
*/
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
bool kvm_arm_pmu_supported(void);
|
2019-08-02 15:25:27 +03:00
|
|
|
|
2019-10-31 17:27:31 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_sve_supported:
|
2019-10-31 17:27:31 +03:00
|
|
|
*
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
* Returns true if KVM can enable SVE and false otherwise.
|
2019-10-31 17:27:31 +03:00
|
|
|
*/
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
bool kvm_arm_sve_supported(void);
|
2019-10-31 17:27:31 +03:00
|
|
|
|
2019-03-04 13:13:34 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_get_max_vm_ipa_size:
|
2019-03-04 13:13:34 +03:00
|
|
|
* @ms: Machine state handle
|
2020-01-30 19:02:05 +03:00
|
|
|
*
|
|
|
|
* Returns the number of bits in the IPA address space supported by KVM
|
2019-03-04 13:13:34 +03:00
|
|
|
*/
|
|
|
|
int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
|
|
|
|
|
2015-04-01 19:57:30 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_sync_mpstate_to_kvm:
|
2015-04-01 19:57:30 +03:00
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* If supported set the KVM MP_STATE based on QEMU's model.
|
2020-01-30 19:02:05 +03:00
|
|
|
*
|
|
|
|
* Returns 0 on success and -1 on failure.
|
2015-04-01 19:57:30 +03:00
|
|
|
*/
|
|
|
|
int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
|
|
|
|
|
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* kvm_arm_sync_mpstate_to_qemu:
|
2015-04-01 19:57:30 +03:00
|
|
|
* @cpu: ARMCPU
|
|
|
|
*
|
|
|
|
* If supported get the MP_STATE from KVM and store in QEMU's model.
|
2020-01-30 19:02:05 +03:00
|
|
|
*
|
|
|
|
* Returns 0 on success and aborts on failure.
|
2015-04-01 19:57:30 +03:00
|
|
|
*/
|
|
|
|
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
|
|
|
|
|
2020-01-30 19:02:06 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_get_virtual_time:
|
|
|
|
* @cs: CPUState
|
|
|
|
*
|
|
|
|
* Gets the VCPU's virtual counter and stores it in the KVM CPU state.
|
|
|
|
*/
|
|
|
|
void kvm_arm_get_virtual_time(CPUState *cs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_arm_put_virtual_time:
|
|
|
|
* @cs: CPUState
|
|
|
|
*
|
|
|
|
* Sets the VCPU's virtual counter to the value stored in the KVM CPU state.
|
|
|
|
*/
|
|
|
|
void kvm_arm_put_virtual_time(CPUState *cs);
|
|
|
|
|
|
|
|
void kvm_arm_vm_state_change(void *opaque, int running, RunState state);
|
|
|
|
|
2015-09-24 03:29:37 +03:00
|
|
|
int kvm_arm_vgic_probe(void);
|
|
|
|
|
2017-09-04 17:21:54 +03:00
|
|
|
void kvm_arm_pmu_set_irq(CPUState *cs, int irq);
|
|
|
|
void kvm_arm_pmu_init(CPUState *cs);
|
2019-10-03 18:46:39 +03:00
|
|
|
int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
|
2016-06-14 17:59:12 +03:00
|
|
|
|
2015-09-24 03:29:37 +03:00
|
|
|
#else
|
|
|
|
|
2018-03-09 20:09:44 +03:00
|
|
|
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
|
|
|
|
{
|
2020-01-30 19:02:05 +03:00
|
|
|
/*
|
|
|
|
* This should never actually be called in the "not KVM" case,
|
2018-03-09 20:09:44 +03:00
|
|
|
* but set up the fields to indicate an error anyway.
|
|
|
|
*/
|
|
|
|
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
|
|
|
|
cpu->host_cpu_probe_failed = true;
|
|
|
|
}
|
|
|
|
|
2020-01-30 19:02:06 +03:00
|
|
|
static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
|
|
|
|
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
static inline bool kvm_arm_aarch32_supported(void)
|
2019-08-02 15:25:26 +03:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
static inline bool kvm_arm_pmu_supported(void)
|
2019-08-02 15:25:27 +03:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
target/arm: Check supported KVM features globally (not per vCPU)
Since commit d70c996df23f, when enabling the PMU we get:
$ qemu-system-aarch64 -cpu host,pmu=on -M virt,accel=kvm,gic-version=3
Segmentation fault (core dumped)
Thread 1 "qemu-system-aar" received signal SIGSEGV, Segmentation fault.
0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
2588 ret = ioctl(s->fd, type, arg);
(gdb) bt
#0 0x0000aaaaaae356d0 in kvm_ioctl (s=0x0, type=44547) at accel/kvm/kvm-all.c:2588
#1 0x0000aaaaaae31568 in kvm_check_extension (s=0x0, extension=126) at accel/kvm/kvm-all.c:916
#2 0x0000aaaaaafce254 in kvm_arm_pmu_supported (cpu=0xaaaaac214ab0) at target/arm/kvm.c:213
#3 0x0000aaaaaafc0f94 in arm_set_pmu (obj=0xaaaaac214ab0, value=true, errp=0xffffffffe438) at target/arm/cpu.c:1111
#4 0x0000aaaaab5533ac in property_set_bool (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", opaque=0xaaaaac222730, errp=0xffffffffe438) at qom/object.c:2170
#5 0x0000aaaaab5512f0 in object_property_set (obj=0xaaaaac214ab0, v=0xaaaaac223a80, name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1328
#6 0x0000aaaaab551e10 in object_property_parse (obj=0xaaaaac214ab0, string=0xaaaaac11b4c0 "on", name=0xaaaaac11a970 "pmu", errp=0xffffffffe438) at qom/object.c:1561
#7 0x0000aaaaab54ee8c in object_apply_global_props (obj=0xaaaaac214ab0, props=0xaaaaac018e20, errp=0xaaaaabd6fd88 <error_fatal>) at qom/object.c:407
#8 0x0000aaaaab1dd5a4 in qdev_prop_set_globals (dev=0xaaaaac214ab0) at hw/core/qdev-properties.c:1218
#9 0x0000aaaaab1d9fac in device_post_init (obj=0xaaaaac214ab0) at hw/core/qdev.c:1050
...
#15 0x0000aaaaab54f310 in object_initialize_with_type (obj=0xaaaaac214ab0, size=52208, type=0xaaaaabe237f0) at qom/object.c:512
#16 0x0000aaaaab54fa24 in object_new_with_type (type=0xaaaaabe237f0) at qom/object.c:687
#17 0x0000aaaaab54fa80 in object_new (typename=0xaaaaabe23970 "host-arm-cpu") at qom/object.c:702
#18 0x0000aaaaaaf04a74 in machvirt_init (machine=0xaaaaac0a8550) at hw/arm/virt.c:1770
#19 0x0000aaaaab1e8720 in machine_run_board_init (machine=0xaaaaac0a8550) at hw/core/machine.c:1138
#20 0x0000aaaaaaf95394 in qemu_init (argc=5, argv=0xffffffffea58, envp=0xffffffffea88) at softmmu/vl.c:4348
#21 0x0000aaaaaada3f74 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at softmmu/main.c:48
This is because in frame #2, cpu->kvm_state is still NULL
(the vCPU is not yet realized).
KVM has a hard requirement of all cores supporting the same
feature set. We only need to check if the accelerator supports
a feature, not each vCPU individually.
Fix by removing the 'CPUState *cpu' argument from the
kvm_arm_<FEATURE>_supported() functions.
Fixes: d70c996df23f ('Use CPUState::kvm_state in kvm_arm_pmu_supported')
Reported-by: Haibo Xu <haibo.xu@linaro.org>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-06-23 12:06:22 +03:00
|
|
|
static inline bool kvm_arm_sve_supported(void)
|
2019-10-31 17:27:31 +03:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-04 13:13:34 +03:00
|
|
|
static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
|
|
|
|
{
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2015-09-24 03:29:37 +03:00
|
|
|
static inline int kvm_arm_vgic_probe(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-04 17:21:54 +03:00
|
|
|
static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {}
|
|
|
|
static inline void kvm_arm_pmu_init(CPUState *cs) {}
|
2016-06-14 17:59:12 +03:00
|
|
|
|
2019-10-31 17:27:33 +03:00
|
|
|
static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {}
|
2020-01-30 19:02:06 +03:00
|
|
|
|
|
|
|
static inline void kvm_arm_get_virtual_time(CPUState *cs) {}
|
|
|
|
static inline void kvm_arm_put_virtual_time(CPUState *cs) {}
|
2013-11-22 21:17:17 +04:00
|
|
|
#endif
|
|
|
|
|
2015-08-13 13:26:21 +03:00
|
|
|
static inline const char *gic_class_name(void)
|
|
|
|
{
|
|
|
|
return kvm_irqchip_in_kernel() ? "kvm-arm-gic" : "arm_gic";
|
|
|
|
}
|
|
|
|
|
2015-09-24 03:29:37 +03:00
|
|
|
/**
|
|
|
|
* gicv3_class_name
|
|
|
|
*
|
|
|
|
* Return name of GICv3 class to use depending on whether KVM acceleration is
|
|
|
|
* in use. May throw an error if the chosen implementation is not available.
|
|
|
|
*
|
|
|
|
* Returns: class name to use
|
|
|
|
*/
|
2016-10-04 15:28:08 +03:00
|
|
|
static inline const char *gicv3_class_name(void)
|
|
|
|
{
|
|
|
|
if (kvm_irqchip_in_kernel()) {
|
|
|
|
#ifdef TARGET_AARCH64
|
|
|
|
return "kvm-arm-gicv3";
|
|
|
|
#else
|
|
|
|
error_report("KVM GICv3 acceleration is not supported on this "
|
|
|
|
"platform");
|
|
|
|
exit(1);
|
|
|
|
#endif
|
|
|
|
} else {
|
2018-02-01 23:53:07 +03:00
|
|
|
if (kvm_enabled()) {
|
|
|
|
error_report("Userspace GICv3 is not supported with KVM");
|
|
|
|
exit(1);
|
|
|
|
}
|
2016-10-04 15:28:08 +03:00
|
|
|
return "arm-gicv3";
|
|
|
|
}
|
|
|
|
}
|
2015-09-24 03:29:37 +03:00
|
|
|
|
2015-12-17 16:37:15 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_handle_debug:
|
|
|
|
* @cs: CPUState
|
|
|
|
* @debug_exit: debug part of the KVM exit structure
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the debug exception was handled.
|
|
|
|
*/
|
|
|
|
bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit);
|
|
|
|
|
2015-12-17 16:37:15 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_hw_debug_active:
|
|
|
|
* @cs: CPU State
|
|
|
|
*
|
|
|
|
* Return: TRUE if any hardware breakpoints in use.
|
|
|
|
*/
|
|
|
|
bool kvm_arm_hw_debug_active(CPUState *cs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* kvm_arm_copy_hw_debug_data:
|
|
|
|
* @ptr: kvm_guest_debug_arch structure
|
|
|
|
*
|
|
|
|
* Copy the architecture specific debug registers into the
|
|
|
|
* kvm_guest_debug ioctl structure.
|
|
|
|
*/
|
|
|
|
struct kvm_guest_debug_arch;
|
|
|
|
void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
|
|
|
|
|
2020-07-03 18:59:42 +03:00
|
|
|
/**
|
|
|
|
* kvm_arm_verify_ext_dabt_pending:
|
|
|
|
* @cs: CPUState
|
|
|
|
*
|
|
|
|
* Verify the fault status code wrt the Ext DABT injection
|
|
|
|
*
|
|
|
|
* Returns: true if the fault status code is as expected, false otherwise
|
|
|
|
*/
|
|
|
|
bool kvm_arm_verify_ext_dabt_pending(CPUState *cs);
|
|
|
|
|
2016-10-04 15:28:08 +03:00
|
|
|
/**
|
2020-01-30 19:02:05 +03:00
|
|
|
* its_class_name:
|
2016-10-04 15:28:08 +03:00
|
|
|
*
|
|
|
|
* Return the ITS class name to use depending on whether KVM acceleration
|
|
|
|
* and KVM CAP_SIGNAL_MSI are supported
|
|
|
|
*
|
|
|
|
* Returns: class name to use or NULL
|
|
|
|
*/
|
|
|
|
static inline const char *its_class_name(void)
|
|
|
|
{
|
|
|
|
if (kvm_irqchip_in_kernel()) {
|
|
|
|
/* KVM implementation requires this capability */
|
|
|
|
return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL;
|
|
|
|
} else {
|
|
|
|
/* Software emulation is not implemented yet */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-05 04:34:42 +04:00
|
|
|
#endif
|