mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00

- Ignore writes to CNTP_CTL_EL0 on HVF ARM (Alexander) - Add '-d invalid_mem' logging option (Zoltan) - Create QOM containers explicitly (Peter) - Rename sysemu/ -> system/ (Philippe) - Re-orderning of include/exec/ headers (Philippe) Move a lot of declarations from these legacy mixed bag headers: . "exec/cpu-all.h" . "exec/cpu-common.h" . "exec/cpu-defs.h" . "exec/exec-all.h" . "exec/translate-all" to these more specific ones: . "exec/page-protection.h" . "exec/translation-block.h" . "user/cpu_loop.h" . "user/guest-host.h" . "user/page-protection.h" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmdlnyAACgkQ4+MsLN6t wN6mBw//QFWi7CrU+bb8KMM53kOU9C507tjn99LLGFb5or73/umDsw6eo/b8DHBt KIwGLgATel42oojKfNKavtAzLK5rOrywpboPDpa3SNeF1onW+99NGJ52LQUqIX6K A6bS0fPdGG9ZzEuPpbjDXlp++0yhDcdSgZsS42fEsT7Dyj5gzJYlqpqhiXGqpsn8 4Y0UMxSL21K3HEexlzw2hsoOBFA3tUm2ujNDhNkt8QASr85yQVLCypABJnuoe/// 5Ojl5wTBeDwhANET0rhwHK8eIYaNboiM9fHopJYhvyw1bz6yAu9jQwzF/MrL3s/r xa4OBHBy5mq2hQV9Shcl3UfCQdk/vDaYaWpgzJGX8stgMGYfnfej1SIl8haJIfcl VMX8/jEFdYbjhO4AeGRYcBzWjEJymkDJZoiSWp2NuEDi6jqIW+7yW1q0Rnlg9lay ShAqLK5Pv4zUw3t0Jy3qv9KSW8sbs6PQxtzXjk8p97rTf76BJ2pF8sv1tVzmsidP 9L92Hv5O34IqzBu2oATOUZYJk89YGmTIUSLkpT7asJZpBLwNM2qLp5jO00WVU0Sd +kAn324guYPkko/TVnjC/AY7CMu55EOtD9NU35k3mUAnxXT9oDUeL4NlYtfgrJx6 x1Nzr2FkS68+wlPAFKNSSU5lTjsjNaFM0bIJ4LCNtenJVP+SnRo= =cjz8 -----END PGP SIGNATURE----- Merge tag 'exec-20241220' of https://github.com/philmd/qemu into staging Accel & Exec patch queue - Ignore writes to CNTP_CTL_EL0 on HVF ARM (Alexander) - Add '-d invalid_mem' logging option (Zoltan) - Create QOM containers explicitly (Peter) - Rename sysemu/ -> system/ (Philippe) - Re-orderning of include/exec/ headers (Philippe) Move a lot of declarations from these legacy mixed bag headers: . "exec/cpu-all.h" . "exec/cpu-common.h" . "exec/cpu-defs.h" . "exec/exec-all.h" . "exec/translate-all" to these more specific ones: . "exec/page-protection.h" . "exec/translation-block.h" . "user/cpu_loop.h" . "user/guest-host.h" . "user/page-protection.h" # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmdlnyAACgkQ4+MsLN6t # wN6mBw//QFWi7CrU+bb8KMM53kOU9C507tjn99LLGFb5or73/umDsw6eo/b8DHBt # KIwGLgATel42oojKfNKavtAzLK5rOrywpboPDpa3SNeF1onW+99NGJ52LQUqIX6K # A6bS0fPdGG9ZzEuPpbjDXlp++0yhDcdSgZsS42fEsT7Dyj5gzJYlqpqhiXGqpsn8 # 4Y0UMxSL21K3HEexlzw2hsoOBFA3tUm2ujNDhNkt8QASr85yQVLCypABJnuoe/// # 5Ojl5wTBeDwhANET0rhwHK8eIYaNboiM9fHopJYhvyw1bz6yAu9jQwzF/MrL3s/r # xa4OBHBy5mq2hQV9Shcl3UfCQdk/vDaYaWpgzJGX8stgMGYfnfej1SIl8haJIfcl # VMX8/jEFdYbjhO4AeGRYcBzWjEJymkDJZoiSWp2NuEDi6jqIW+7yW1q0Rnlg9lay # ShAqLK5Pv4zUw3t0Jy3qv9KSW8sbs6PQxtzXjk8p97rTf76BJ2pF8sv1tVzmsidP # 9L92Hv5O34IqzBu2oATOUZYJk89YGmTIUSLkpT7asJZpBLwNM2qLp5jO00WVU0Sd # +kAn324guYPkko/TVnjC/AY7CMu55EOtD9NU35k3mUAnxXT9oDUeL4NlYtfgrJx6 # x1Nzr2FkS68+wlPAFKNSSU5lTjsjNaFM0bIJ4LCNtenJVP+SnRo= # =cjz8 # -----END PGP SIGNATURE----- # gpg: Signature made Fri 20 Dec 2024 11:45:20 EST # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * tag 'exec-20241220' of https://github.com/philmd/qemu: (59 commits) util/qemu-timer: fix indentation meson: Do not define CONFIG_DEVICES on user emulation system/accel-ops: Remove unnecessary 'exec/cpu-common.h' header system/numa: Remove unnecessary 'exec/cpu-common.h' header hw/xen: Remove unnecessary 'exec/cpu-common.h' header target/mips: Drop left-over comment about Jazz machine target/mips: Remove tswap() calls in semihosting uhi_fstat_cb() target/xtensa: Remove tswap() calls in semihosting simcall() helper accel/tcg: Un-inline translator_is_same_page() accel/tcg: Include missing 'exec/translation-block.h' header accel/tcg: Move tcg_cflags_has/set() to 'exec/translation-block.h' accel/tcg: Restrict curr_cflags() declaration to 'internal-common.h' qemu/coroutine: Include missing 'qemu/atomic.h' header exec/translation-block: Include missing 'qemu/atomic.h' header accel/tcg: Declare cpu_loop_exit_requested() in 'exec/cpu-common.h' exec/cpu-all: Include 'cpu.h' earlier so MMU_USER_IDX is always defined target/sparc: Move sparc_restore_state_to_opc() to cpu.c target/sparc: Uninline cpu_get_tb_cpu_state() target/loongarch: Declare loongarch_cpu_dump_state() locally user: Move various declarations out of 'exec/exec-all.h' ... Conflicts: hw/char/riscv_htif.c hw/intc/riscv_aplic.c target/s390x/cpu.c Apply sysemu header path changes to not in the pull request. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
271 lines
8.9 KiB
C
271 lines
8.9 KiB
C
/*
|
|
* KVM-based ITS implementation for a GICv3-based system
|
|
*
|
|
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
|
|
* Written by Pavel Fedin <p.fedin@samsung.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qapi/error.h"
|
|
#include "qemu/module.h"
|
|
#include "qemu/error-report.h"
|
|
#include "hw/intc/arm_gicv3_its_common.h"
|
|
#include "hw/qdev-properties.h"
|
|
#include "system/runstate.h"
|
|
#include "system/kvm.h"
|
|
#include "kvm_arm.h"
|
|
#include "migration/blocker.h"
|
|
#include "qom/object.h"
|
|
|
|
#define TYPE_KVM_ARM_ITS "arm-its-kvm"
|
|
typedef struct KVMARMITSClass KVMARMITSClass;
|
|
/* This is reusing the GICv3ITSState typedef from ARM_GICV3_ITS_COMMON */
|
|
DECLARE_OBJ_CHECKERS(GICv3ITSState, KVMARMITSClass,
|
|
KVM_ARM_ITS, TYPE_KVM_ARM_ITS)
|
|
|
|
struct KVMARMITSClass {
|
|
GICv3ITSCommonClass parent_class;
|
|
ResettablePhases parent_phases;
|
|
};
|
|
|
|
|
|
static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid)
|
|
{
|
|
struct kvm_msi msi;
|
|
|
|
if (unlikely(!s->translater_gpa_known)) {
|
|
MemoryRegion *mr = &s->iomem_its_translation;
|
|
MemoryRegionSection mrs;
|
|
|
|
mrs = memory_region_find(mr, 0, 1);
|
|
memory_region_unref(mrs.mr);
|
|
s->gits_translater_gpa = mrs.offset_within_address_space + 0x40;
|
|
s->translater_gpa_known = true;
|
|
}
|
|
|
|
msi.address_lo = extract64(s->gits_translater_gpa, 0, 32);
|
|
msi.address_hi = extract64(s->gits_translater_gpa, 32, 32);
|
|
msi.data = le32_to_cpu(value);
|
|
msi.flags = KVM_MSI_VALID_DEVID;
|
|
msi.devid = devid;
|
|
memset(msi.pad, 0, sizeof(msi.pad));
|
|
|
|
return kvm_vm_ioctl(kvm_state, KVM_SIGNAL_MSI, &msi);
|
|
}
|
|
|
|
/**
|
|
* vm_change_state_handler - VM change state callback aiming at flushing
|
|
* ITS tables into guest RAM
|
|
*
|
|
* The tables get flushed to guest RAM whenever the VM gets stopped.
|
|
*/
|
|
static void vm_change_state_handler(void *opaque, bool running,
|
|
RunState state)
|
|
{
|
|
GICv3ITSState *s = (GICv3ITSState *)opaque;
|
|
Error *err = NULL;
|
|
|
|
if (running) {
|
|
return;
|
|
}
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
|
|
KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err);
|
|
if (err) {
|
|
error_report_err(err);
|
|
}
|
|
}
|
|
|
|
static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
|
|
|
|
s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_ITS, false);
|
|
if (s->dev_fd < 0) {
|
|
error_setg_errno(errp, -s->dev_fd, "error creating in-kernel ITS");
|
|
return;
|
|
}
|
|
|
|
/* explicit init of the ITS */
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
|
|
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort);
|
|
|
|
/* register the base address */
|
|
kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
|
|
KVM_VGIC_ITS_ADDR_TYPE, s->dev_fd, 0);
|
|
|
|
gicv3_add_its(s->gicv3, dev);
|
|
|
|
gicv3_its_init_mmio(s, NULL, NULL);
|
|
|
|
if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CTLR)) {
|
|
error_setg(&s->migration_blocker, "This operating system kernel "
|
|
"does not support vITS migration");
|
|
if (migrate_add_blocker(&s->migration_blocker, errp) < 0) {
|
|
return;
|
|
}
|
|
} else {
|
|
qemu_add_vm_change_state_handler(vm_change_state_handler, s);
|
|
}
|
|
|
|
kvm_msi_use_devid = true;
|
|
kvm_gsi_direct_mapping = false;
|
|
kvm_msi_via_irqfd_allowed = true;
|
|
}
|
|
|
|
/**
|
|
* kvm_arm_its_pre_save - handles the saving of ITS registers.
|
|
* ITS tables are flushed into guest RAM separately and earlier,
|
|
* through the VM change state handler, since at the moment pre_save()
|
|
* is called, the guest RAM has already been saved.
|
|
*/
|
|
static void kvm_arm_its_pre_save(GICv3ITSState *s)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_BASER + i * 8, &s->baser[i], false,
|
|
&error_abort);
|
|
}
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CTLR, &s->ctlr, false, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CBASER, &s->cbaser, false, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CREADR, &s->creadr, false, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CWRITER, &s->cwriter, false, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_IIDR, &s->iidr, false, &error_abort);
|
|
}
|
|
|
|
/**
|
|
* kvm_arm_its_post_load - Restore both the ITS registers and tables
|
|
*/
|
|
static void kvm_arm_its_post_load(GICv3ITSState *s)
|
|
{
|
|
int i;
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_IIDR, &s->iidr, true, &error_abort);
|
|
|
|
/*
|
|
* must be written before GITS_CREADR since GITS_CBASER write
|
|
* access resets GITS_CREADR.
|
|
*/
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CBASER, &s->cbaser, true, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CREADR, &s->creadr, true, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CWRITER, &s->cwriter, true, &error_abort);
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_BASER + i * 8, &s->baser[i], true,
|
|
&error_abort);
|
|
}
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
|
|
KVM_DEV_ARM_ITS_RESTORE_TABLES, NULL, true,
|
|
&error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CTLR, &s->ctlr, true, &error_abort);
|
|
}
|
|
|
|
static void kvm_arm_its_reset_hold(Object *obj, ResetType type)
|
|
{
|
|
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
|
|
KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
|
|
int i;
|
|
|
|
if (c->parent_phases.hold) {
|
|
c->parent_phases.hold(obj, type);
|
|
}
|
|
|
|
if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
|
|
KVM_DEV_ARM_ITS_CTRL_RESET)) {
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
|
|
KVM_DEV_ARM_ITS_CTRL_RESET, NULL, true, &error_abort);
|
|
return;
|
|
}
|
|
|
|
warn_report("ITS KVM: full reset is not supported by the host kernel");
|
|
|
|
if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CTLR)) {
|
|
return;
|
|
}
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CTLR, &s->ctlr, true, &error_abort);
|
|
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_CBASER, &s->cbaser, true, &error_abort);
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
|
GITS_BASER + i * 8, &s->baser[i], true,
|
|
&error_abort);
|
|
}
|
|
}
|
|
|
|
static const Property kvm_arm_its_props[] = {
|
|
DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "kvm-arm-gicv3",
|
|
GICv3State *),
|
|
};
|
|
|
|
static void kvm_arm_its_class_init(ObjectClass *klass, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
ResettableClass *rc = RESETTABLE_CLASS(klass);
|
|
GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass);
|
|
KVMARMITSClass *ic = KVM_ARM_ITS_CLASS(klass);
|
|
|
|
dc->realize = kvm_arm_its_realize;
|
|
device_class_set_props(dc, kvm_arm_its_props);
|
|
resettable_class_set_parent_phases(rc, NULL, kvm_arm_its_reset_hold, NULL,
|
|
&ic->parent_phases);
|
|
icc->send_msi = kvm_its_send_msi;
|
|
icc->pre_save = kvm_arm_its_pre_save;
|
|
icc->post_load = kvm_arm_its_post_load;
|
|
}
|
|
|
|
static const TypeInfo kvm_arm_its_info = {
|
|
.name = TYPE_KVM_ARM_ITS,
|
|
.parent = TYPE_ARM_GICV3_ITS_COMMON,
|
|
.instance_size = sizeof(GICv3ITSState),
|
|
.class_init = kvm_arm_its_class_init,
|
|
.class_size = sizeof(KVMARMITSClass),
|
|
};
|
|
|
|
static void kvm_arm_its_register_types(void)
|
|
{
|
|
type_register_static(&kvm_arm_its_info);
|
|
}
|
|
|
|
type_init(kvm_arm_its_register_types)
|