mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 12:23:53 -06:00
target/arm: kvm: require KVM_CAP_DEVICE_CTRL
The device control API was added in 2013, assume that it is present. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20241024113126.44343-1-pbonzini@redhat.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
361dfa9757
commit
84f298ea3e
3 changed files with 13 additions and 29 deletions
|
@ -547,17 +547,10 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
|
||||||
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true,
|
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
}
|
}
|
||||||
} else if (kvm_check_extension(kvm_state, KVM_CAP_DEVICE_CTRL)) {
|
} else {
|
||||||
error_setg_errno(errp, -ret, "error creating in-kernel VGIC");
|
error_setg_errno(errp, -ret, "error creating in-kernel VGIC");
|
||||||
error_append_hint(errp,
|
error_append_hint(errp,
|
||||||
"Perhaps the host CPU does not support GICv2?\n");
|
"Perhaps the host CPU does not support GICv2?\n");
|
||||||
} else if (ret != -ENODEV && ret != -ENOTSUP) {
|
|
||||||
/*
|
|
||||||
* Very ancient kernel without KVM_CAP_DEVICE_CTRL: assume that
|
|
||||||
* ENODEV or ENOTSUP mean "can't create GICv2 with KVM_CREATE_DEVICE",
|
|
||||||
* and that we will get a GICv2 via KVM_CREATE_IRQCHIP.
|
|
||||||
*/
|
|
||||||
error_setg_errno(errp, -ret, "error creating in-kernel VGIC");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "migration/blocker.h"
|
#include "migration/blocker.h"
|
||||||
|
|
||||||
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
||||||
|
KVM_CAP_INFO(DEVICE_CTRL),
|
||||||
KVM_CAP_LAST_INFO
|
KVM_CAP_LAST_INFO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -691,19 +692,11 @@ static void kvm_arm_set_device_addr(KVMDevice *kd)
|
||||||
{
|
{
|
||||||
struct kvm_device_attr *attr = &kd->kdattr;
|
struct kvm_device_attr *attr = &kd->kdattr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* If the device control API is available and we have a device fd on the
|
|
||||||
* KVMDevice struct, let's use the newer API
|
|
||||||
*/
|
|
||||||
if (kd->dev_fd >= 0) {
|
|
||||||
uint64_t addr = kd->kda.addr;
|
uint64_t addr = kd->kda.addr;
|
||||||
|
|
||||||
addr |= kd->kda_addr_ormask;
|
addr |= kd->kda_addr_ormask;
|
||||||
attr->addr = (uintptr_t)&addr;
|
attr->addr = (uintptr_t)&addr;
|
||||||
ret = kvm_device_ioctl(kd->dev_fd, KVM_SET_DEVICE_ATTR, attr);
|
ret = kvm_device_ioctl(kd->dev_fd, KVM_SET_DEVICE_ATTR, attr);
|
||||||
} else {
|
|
||||||
ret = kvm_vm_ioctl(kvm_state, KVM_ARM_SET_DEVICE_ADDR, &kd->kda);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Failed to set device address: %s\n",
|
fprintf(stderr, "Failed to set device address: %s\n",
|
||||||
|
|
|
@ -22,17 +22,15 @@
|
||||||
* @devid: the KVM device ID
|
* @devid: the KVM device ID
|
||||||
* @group: device control API group for setting addresses
|
* @group: device control API group for setting addresses
|
||||||
* @attr: device control API address type
|
* @attr: device control API address type
|
||||||
* @dev_fd: device control device file descriptor (or -1 if not supported)
|
* @dev_fd: device control device file descriptor
|
||||||
* @addr_ormask: value to be OR'ed with resolved address
|
* @addr_ormask: value to be OR'ed with resolved address
|
||||||
*
|
*
|
||||||
* Remember the memory region @mr, and when it is mapped by the
|
* Remember the memory region @mr, and when it is mapped by the machine
|
||||||
* machine model, tell the kernel that base address using the
|
* model, tell the kernel that base address using the device control API.
|
||||||
* KVM_ARM_SET_DEVICE_ADDRESS ioctl or the newer device control API. @devid
|
* @devid should be the ID of the device as defined by the arm-vgic device
|
||||||
* should be the ID of the device as defined by KVM_ARM_SET_DEVICE_ADDRESS or
|
* in the device control API. The machine model may map and unmap the device
|
||||||
* the arm-vgic device in the device control API.
|
* multiple times; the kernel will only be told the final address at the
|
||||||
* The machine model may map
|
* point where machine init is complete.
|
||||||
* and unmap the device multiple times; the kernel will only be told the final
|
|
||||||
* address at the point where machine init is complete.
|
|
||||||
*/
|
*/
|
||||||
void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
|
void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
|
||||||
uint64_t attr, int dev_fd, uint64_t addr_ormask);
|
uint64_t attr, int dev_fd, uint64_t addr_ormask);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue