mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* Compilation fix for KVM (Alex) * SMM fix (Dmitry) * VFIO error reporting (Eric) * win32 fixes and workarounds (Marc-André) * qemu-pr-helper crash bugfix (Maxim) * Memory leak fixes (myself) * VMX features (myself) * Record-replay deadlock (Pavel) * i386 CPUID bits (Sebastian) * kconfig tweak (Thomas) * Valgrind fix (Thomas) * Autoconverge test (Yury) # gpg: Signature made Fri 04 Oct 2019 17:57:48 BST # gpg: using RSA key BFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (29 commits) target/i386/kvm: Silence warning from Valgrind about uninitialized bytes target/i386: work around KVM_GET_MSRS bug for secondary execution controls target/i386: add VMX features vmxcap: correct the name of the variables target/i386: add VMX definitions target/i386: expand feature words to 64 bits target/i386: introduce generic feature dependency mechanism target/i386: handle filtered_features in a new function mark_unavailable_features tests/docker: only enable ubsan for test-clang win32: work around main-loop busy loop on socket/fd event tests: skip serial test on windows util: WSAEWOULDBLOCK on connect should map to EINPROGRESS Fix wrong behavior of cpu_memory_rw_debug() function in SMM memory: allow memory_region_register_iommu_notifier() to fail vfio: Turn the container error into an Error handle i386: Add CPUID bit for CLZERO and XSAVEERPTR docker: test-debug: disable LeakSanitizer lm32: do not leak memory on object_new/object_unref cris: do not leak struct cris_disasm_data mips: fix memory leaks in board initialization ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+3
-3
@@ -712,11 +712,11 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
|
||||
KVMState *s = kvm_state;
|
||||
uint64_t start, size, offset, count;
|
||||
KVMSlot *mem;
|
||||
int ret, i;
|
||||
int ret = 0, i;
|
||||
|
||||
if (!s->manual_dirty_log_protect) {
|
||||
/* No need to do explicit clear */
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
start = section->offset_within_address_space;
|
||||
@@ -724,7 +724,7 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
|
||||
|
||||
if (!size) {
|
||||
/* Nothing more we can do... */
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
kvm_slots_lock(kml);
|
||||
|
||||
+29
-30
@@ -1294,24 +1294,17 @@ static int cris_constraint
|
||||
/* Parse disassembler options and store state in info. FIXME: For the
|
||||
time being, we abuse static variables. */
|
||||
|
||||
static bfd_boolean
|
||||
cris_parse_disassembler_options (disassemble_info *info,
|
||||
static void
|
||||
cris_parse_disassembler_options (struct cris_disasm_data *disdata,
|
||||
char *disassembler_options,
|
||||
enum cris_disass_family distype)
|
||||
{
|
||||
struct cris_disasm_data *disdata;
|
||||
|
||||
info->private_data = calloc (1, sizeof (struct cris_disasm_data));
|
||||
disdata = (struct cris_disasm_data *) info->private_data;
|
||||
if (disdata == NULL)
|
||||
return false;
|
||||
|
||||
/* Default true. */
|
||||
disdata->trace_case
|
||||
= (info->disassembler_options == NULL
|
||||
|| (strcmp (info->disassembler_options, "nocase") != 0));
|
||||
= (disassembler_options == NULL
|
||||
|| (strcmp (disassembler_options, "nocase") != 0));
|
||||
|
||||
disdata->distype = distype;
|
||||
return true;
|
||||
}
|
||||
|
||||
static const struct cris_spec_reg *
|
||||
@@ -2736,9 +2729,10 @@ static int
|
||||
print_insn_cris_with_register_prefix (bfd_vma vma,
|
||||
disassemble_info *info)
|
||||
{
|
||||
if (info->private_data == NULL
|
||||
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
|
||||
return -1;
|
||||
struct cris_disasm_data disdata;
|
||||
info->private_data = &disdata;
|
||||
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||
cris_dis_v0_v10);
|
||||
return print_insn_cris_generic (vma, info, true);
|
||||
}
|
||||
/* Disassemble, prefixing register names with `$'. CRIS v32. */
|
||||
@@ -2747,9 +2741,10 @@ static int
|
||||
print_insn_crisv32_with_register_prefix (bfd_vma vma,
|
||||
disassemble_info *info)
|
||||
{
|
||||
if (info->private_data == NULL
|
||||
&& !cris_parse_disassembler_options (info, cris_dis_v32))
|
||||
return -1;
|
||||
struct cris_disasm_data disdata;
|
||||
info->private_data = &disdata;
|
||||
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||
cris_dis_v32);
|
||||
return print_insn_cris_generic (vma, info, true);
|
||||
}
|
||||
|
||||
@@ -2761,9 +2756,10 @@ static int
|
||||
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
|
||||
disassemble_info *info)
|
||||
{
|
||||
if (info->private_data == NULL
|
||||
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
|
||||
return -1;
|
||||
struct cris_disasm_data disdata;
|
||||
info->private_data = &disdata;
|
||||
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||
cris_dis_common_v10_v32);
|
||||
return print_insn_cris_generic (vma, info, true);
|
||||
}
|
||||
|
||||
@@ -2773,9 +2769,10 @@ static int
|
||||
print_insn_cris_without_register_prefix (bfd_vma vma,
|
||||
disassemble_info *info)
|
||||
{
|
||||
if (info->private_data == NULL
|
||||
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
|
||||
return -1;
|
||||
struct cris_disasm_data disdata;
|
||||
info->private_data = &disdata;
|
||||
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||
cris_dis_v0_v10);
|
||||
return print_insn_cris_generic (vma, info, false);
|
||||
}
|
||||
|
||||
@@ -2785,9 +2782,10 @@ static int
|
||||
print_insn_crisv32_without_register_prefix (bfd_vma vma,
|
||||
disassemble_info *info)
|
||||
{
|
||||
if (info->private_data == NULL
|
||||
&& !cris_parse_disassembler_options (info, cris_dis_v32))
|
||||
return -1;
|
||||
struct cris_disasm_data disdata;
|
||||
info->private_data = &disdata;
|
||||
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||
cris_dis_v32);
|
||||
return print_insn_cris_generic (vma, info, false);
|
||||
}
|
||||
|
||||
@@ -2798,9 +2796,10 @@ static int
|
||||
print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
|
||||
disassemble_info *info)
|
||||
{
|
||||
if (info->private_data == NULL
|
||||
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
|
||||
return -1;
|
||||
struct cris_disasm_data disdata;
|
||||
info->private_data = &disdata;
|
||||
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||
cris_dis_common_v10_v32);
|
||||
return print_insn_cris_generic (vma, info, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -660,7 +660,8 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
|
||||
*/
|
||||
MemoryRegion *mr = MEMORY_REGION(iommu_mr);
|
||||
TCGIOMMUNotifier *notifier;
|
||||
int i;
|
||||
Error *err = NULL;
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < cpu->iommu_notifiers->len; i++) {
|
||||
notifier = g_array_index(cpu->iommu_notifiers, TCGIOMMUNotifier *, i);
|
||||
@@ -689,7 +690,12 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
|
||||
0,
|
||||
HWADDR_MAX,
|
||||
iommu_idx);
|
||||
memory_region_register_iommu_notifier(notifier->mr, ¬ifier->n);
|
||||
ret = memory_region_register_iommu_notifier(notifier->mr, ¬ifier->n,
|
||||
&err);
|
||||
if (ret) {
|
||||
error_report_err(err);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!notifier->active) {
|
||||
@@ -2959,8 +2965,17 @@ static void tcg_log_global_after_sync(MemoryListener *listener)
|
||||
* by pushing the migration thread's memory read after the vCPU thread has
|
||||
* written the memory.
|
||||
*/
|
||||
cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
|
||||
run_on_cpu(cpuas->cpu, do_nothing, RUN_ON_CPU_NULL);
|
||||
if (replay_mode == REPLAY_MODE_NONE) {
|
||||
/*
|
||||
* VGA can make calls to this function while updating the screen.
|
||||
* In record/replay mode this causes a deadlock, because
|
||||
* run_on_cpu waits for rr mutex. Therefore no races are possible
|
||||
* in this case and no need for making run_on_cpu when
|
||||
* record/replay is not enabled.
|
||||
*/
|
||||
cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
|
||||
run_on_cpu(cpuas->cpu, do_nothing, RUN_ON_CPU_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void tcg_commit(MemoryListener *listener)
|
||||
|
||||
+10
-8
@@ -1469,20 +1469,21 @@ static void smmuv3_class_init(ObjectClass *klass, void *data)
|
||||
dc->realize = smmu_realize;
|
||||
}
|
||||
|
||||
static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new)
|
||||
static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new,
|
||||
Error **errp)
|
||||
{
|
||||
SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu);
|
||||
SMMUv3State *s3 = sdev->smmu;
|
||||
SMMUState *s = &(s3->smmu_state);
|
||||
|
||||
if (new & IOMMU_NOTIFIER_MAP) {
|
||||
int bus_num = pci_bus_num(sdev->bus);
|
||||
PCIDevice *pcidev = pci_find_device(sdev->bus, bus_num, sdev->devfn);
|
||||
|
||||
warn_report("SMMUv3 does not support notification on MAP: "
|
||||
"device %s will not function properly", pcidev->name);
|
||||
error_setg(errp,
|
||||
"device %02x.%02x.%x requires iommu MAP notifier which is "
|
||||
"not currently supported", pci_bus_num(sdev->bus),
|
||||
PCI_SLOT(sdev->devfn), PCI_FUNC(sdev->devfn));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (old == IOMMU_NOTIFIER_NONE) {
|
||||
@@ -1492,6 +1493,7 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
|
||||
QLIST_REMOVE(sdev, next);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
|
||||
|
||||
@@ -485,6 +485,7 @@ PCIBus *dino_init(MemoryRegion *addr_space,
|
||||
memory_region_init_alias(&s->pci_mem_alias[i], OBJECT(s),
|
||||
name, &s->pci_mem, addr,
|
||||
DINO_MEM_CHUNK_SIZE);
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
/* Set up PCI view of memory: Bus master address space. */
|
||||
|
||||
+3
-1
@@ -78,13 +78,15 @@ static void machine_hppa_init(MachineState *machine)
|
||||
|
||||
/* Create CPUs. */
|
||||
for (i = 0; i < smp_cpus; i++) {
|
||||
char *name = g_strdup_printf("cpu%ld-io-eir", i);
|
||||
cpu[i] = HPPA_CPU(cpu_create(machine->cpu_type));
|
||||
|
||||
cpu_region = g_new(MemoryRegion, 1);
|
||||
memory_region_init_io(cpu_region, OBJECT(cpu[i]), &hppa_io_eir_ops,
|
||||
cpu[i], g_strdup_printf("cpu%ld-io-eir", i), 4);
|
||||
cpu[i], name, 4);
|
||||
memory_region_add_subregion(addr_space, CPU_HPA + i * 0x1000,
|
||||
cpu_region);
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
/* Limit main memory. */
|
||||
|
||||
+10
-7
@@ -1466,18 +1466,21 @@ static const MemoryRegionOps mmio_mem_ops = {
|
||||
}
|
||||
};
|
||||
|
||||
static void amdvi_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new)
|
||||
static int amdvi_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new,
|
||||
Error **errp)
|
||||
{
|
||||
AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
|
||||
|
||||
if (new & IOMMU_NOTIFIER_MAP) {
|
||||
error_report("device %02x.%02x.%x requires iommu notifier which is not "
|
||||
"currently supported", as->bus_num, PCI_SLOT(as->devfn),
|
||||
PCI_FUNC(as->devfn));
|
||||
exit(1);
|
||||
error_setg(errp,
|
||||
"device %02x.%02x.%x requires iommu notifier which is not "
|
||||
"currently supported", as->bus_num, PCI_SLOT(as->devfn),
|
||||
PCI_FUNC(as->devfn));
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void amdvi_init(AMDVIState *s)
|
||||
|
||||
@@ -2929,9 +2929,10 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
|
||||
return iotlb;
|
||||
}
|
||||
|
||||
static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new)
|
||||
static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new,
|
||||
Error **errp)
|
||||
{
|
||||
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
|
||||
IntelIOMMUState *s = vtd_as->iommu_state;
|
||||
@@ -2944,6 +2945,7 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
} else if (new == IOMMU_NOTIFIER_NONE) {
|
||||
QLIST_REMOVE(vtd_as, next);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vtd_post_load(void *opaque, int version_id)
|
||||
|
||||
@@ -300,6 +300,7 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp)
|
||||
d->bmdma[i].bus = &d->bus[i];
|
||||
ide_register_restart_cb(&d->bus[i]);
|
||||
}
|
||||
g_free(irq);
|
||||
|
||||
vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
|
||||
qemu_register_reset(cmd646_reset, d);
|
||||
|
||||
+7
-3
@@ -13,9 +13,13 @@ config I82378
|
||||
select MC146818RTC
|
||||
select PCSPK
|
||||
|
||||
config PC87312
|
||||
config ISA_SUPERIO
|
||||
bool
|
||||
select ISA_BUS
|
||||
|
||||
config PC87312
|
||||
bool
|
||||
select ISA_SUPERIO
|
||||
select I8259
|
||||
select I8254
|
||||
select I8257
|
||||
@@ -34,14 +38,14 @@ config PIIX4
|
||||
|
||||
config VT82C686
|
||||
bool
|
||||
select ISA_BUS
|
||||
select ISA_SUPERIO
|
||||
select ACPI_SMBUS
|
||||
select SERIAL_ISA
|
||||
select FDC
|
||||
|
||||
config SMC37C669
|
||||
bool
|
||||
select ISA_BUS
|
||||
select ISA_SUPERIO
|
||||
select SERIAL_ISA
|
||||
select PARALLEL
|
||||
select FDC
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
common-obj-$(CONFIG_ISA_BUS) += isa-bus.o
|
||||
common-obj-$(CONFIG_ISA_BUS) += isa-superio.o
|
||||
common-obj-$(CONFIG_ISA_SUPERIO) += isa-superio.o
|
||||
common-obj-$(CONFIG_APM) += apm.o
|
||||
common-obj-$(CONFIG_I82378) += i82378.o
|
||||
common-obj-$(CONFIG_PC87312) += pc87312.o
|
||||
|
||||
@@ -273,6 +273,8 @@ static void mcf5208evb_init(MachineState *machine)
|
||||
0xfc030000, pic + 36);
|
||||
}
|
||||
|
||||
g_free(pic);
|
||||
|
||||
/* 0xfc000000 SCM. */
|
||||
/* 0xfc004000 XBS. */
|
||||
/* 0xfc008000 FlexBus CS. */
|
||||
|
||||
@@ -100,6 +100,7 @@ static int microblaze_load_dtb(hwaddr addr,
|
||||
}
|
||||
|
||||
cpu_physical_memory_write(addr, fdt, fdt_size);
|
||||
g_free(fdt);
|
||||
return fdt_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ config R4K
|
||||
|
||||
config MALTA
|
||||
bool
|
||||
select ISA_SUPERIO
|
||||
|
||||
config MIPSSIM
|
||||
bool
|
||||
|
||||
@@ -81,6 +81,7 @@ void cpu_mips_irq_init_cpu(MIPSCPU *cpu)
|
||||
for (i = 0; i < 8; i++) {
|
||||
env->irq[i] = qi[i];
|
||||
}
|
||||
g_free(qi);
|
||||
}
|
||||
|
||||
void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level)
|
||||
|
||||
@@ -362,6 +362,8 @@ static void mips_jazz_init(MachineState *machine,
|
||||
|
||||
/* LED indicator */
|
||||
sysbus_create_simple("jazz-led", 0x8000f000, NULL);
|
||||
|
||||
g_free(dmas);
|
||||
}
|
||||
|
||||
static
|
||||
|
||||
@@ -205,9 +205,10 @@ static int spapr_tce_get_attr(IOMMUMemoryRegion *iommu,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new)
|
||||
static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
IOMMUNotifierFlag old,
|
||||
IOMMUNotifierFlag new,
|
||||
Error **errp)
|
||||
{
|
||||
struct SpaprTceTable *tbl = container_of(iommu, SpaprTceTable, iommu);
|
||||
|
||||
@@ -216,6 +217,7 @@ static void spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
||||
} else if (old != IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_NONE) {
|
||||
spapr_tce_set_need_vfio(tbl, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spapr_tce_table_post_load(void *opaque, int version_id)
|
||||
|
||||
@@ -186,9 +186,6 @@ static void lm32_timer_init(Object *obj)
|
||||
|
||||
sysbus_init_irq(dev, &s->irq);
|
||||
|
||||
s->bh = qemu_bh_new(timer_hit, s);
|
||||
s->ptimer = ptimer_init(s->bh, PTIMER_POLICY_DEFAULT);
|
||||
|
||||
memory_region_init_io(&s->iomem, obj, &timer_ops, s,
|
||||
"timer", R_MAX * 4);
|
||||
sysbus_init_mmio(dev, &s->iomem);
|
||||
@@ -198,6 +195,9 @@ static void lm32_timer_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
LM32TimerState *s = LM32_TIMER(dev);
|
||||
|
||||
s->bh = qemu_bh_new(timer_hit, s);
|
||||
s->ptimer = ptimer_init(s->bh, PTIMER_POLICY_DEFAULT);
|
||||
|
||||
ptimer_set_freq(s->ptimer, s->freq_hz);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,11 +283,6 @@ static void milkymist_sysctl_init(Object *obj)
|
||||
sysbus_init_irq(dev, &s->timer0_irq);
|
||||
sysbus_init_irq(dev, &s->timer1_irq);
|
||||
|
||||
s->bh0 = qemu_bh_new(timer0_hit, s);
|
||||
s->bh1 = qemu_bh_new(timer1_hit, s);
|
||||
s->ptimer0 = ptimer_init(s->bh0, PTIMER_POLICY_DEFAULT);
|
||||
s->ptimer1 = ptimer_init(s->bh1, PTIMER_POLICY_DEFAULT);
|
||||
|
||||
memory_region_init_io(&s->regs_region, obj, &sysctl_mmio_ops, s,
|
||||
"milkymist-sysctl", R_MAX * 4);
|
||||
sysbus_init_mmio(dev, &s->regs_region);
|
||||
@@ -297,6 +292,11 @@ static void milkymist_sysctl_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev);
|
||||
|
||||
s->bh0 = qemu_bh_new(timer0_hit, s);
|
||||
s->bh1 = qemu_bh_new(timer1_hit, s);
|
||||
s->ptimer0 = ptimer_init(s->bh0, PTIMER_POLICY_DEFAULT);
|
||||
s->ptimer1 = ptimer_init(s->bh1, PTIMER_POLICY_DEFAULT);
|
||||
|
||||
ptimer_set_freq(s->ptimer0, s->freq_hz);
|
||||
ptimer_set_freq(s->ptimer1, s->freq_hz);
|
||||
}
|
||||
|
||||
+35
-17
@@ -509,6 +509,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||
int ret;
|
||||
VFIOHostDMAWindow *hostwin;
|
||||
bool hostwin_found;
|
||||
Error *err = NULL;
|
||||
|
||||
if (vfio_listener_skipped_section(section)) {
|
||||
trace_vfio_listener_region_add_skip(
|
||||
@@ -543,13 +544,20 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||
hostwin->max_iova - hostwin->min_iova + 1,
|
||||
section->offset_within_address_space,
|
||||
int128_get64(section->size))) {
|
||||
ret = -1;
|
||||
error_setg(&err,
|
||||
"region [0x%"PRIx64",0x%"PRIx64"] overlaps with existing"
|
||||
"host DMA window [0x%"PRIx64",0x%"PRIx64"]",
|
||||
section->offset_within_address_space,
|
||||
section->offset_within_address_space +
|
||||
int128_get64(section->size) - 1,
|
||||
hostwin->min_iova, hostwin->max_iova);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
ret = vfio_spapr_create_window(container, section, &pgsize);
|
||||
if (ret) {
|
||||
error_setg_errno(&err, -ret, "Failed to create SPAPR window");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -594,10 +602,8 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||
}
|
||||
|
||||
if (!hostwin_found) {
|
||||
error_report("vfio: IOMMU container %p can't map guest IOVA region"
|
||||
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx,
|
||||
container, iova, end);
|
||||
ret = -EFAULT;
|
||||
error_setg(&err, "Container %p can't map guest IOVA region"
|
||||
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -630,9 +636,14 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||
section->offset_within_region,
|
||||
int128_get64(llend),
|
||||
iommu_idx);
|
||||
QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
|
||||
|
||||
memory_region_register_iommu_notifier(section->mr, &giommu->n);
|
||||
ret = memory_region_register_iommu_notifier(section->mr, &giommu->n,
|
||||
&err);
|
||||
if (ret) {
|
||||
g_free(giommu);
|
||||
goto fail;
|
||||
}
|
||||
QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
|
||||
memory_region_iommu_replay(giommu->iommu, &giommu->n);
|
||||
|
||||
return;
|
||||
@@ -664,11 +675,12 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
||||
ret = vfio_dma_map(container, iova, int128_get64(llsize),
|
||||
vaddr, section->readonly);
|
||||
if (ret) {
|
||||
error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
||||
"0x%"HWADDR_PRIx", %p) = %d (%m)",
|
||||
container, iova, int128_get64(llsize), vaddr, ret);
|
||||
error_setg(&err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
||||
"0x%"HWADDR_PRIx", %p) = %d (%m)",
|
||||
container, iova, int128_get64(llsize), vaddr, ret);
|
||||
if (memory_region_is_ram_device(section->mr)) {
|
||||
/* Allow unexpected mappings not to be fatal for RAM devices */
|
||||
error_report_err(err);
|
||||
return;
|
||||
}
|
||||
goto fail;
|
||||
@@ -688,9 +700,14 @@ fail:
|
||||
*/
|
||||
if (!container->initialized) {
|
||||
if (!container->error) {
|
||||
container->error = ret;
|
||||
error_propagate_prepend(&container->error, err,
|
||||
"Region %s: ",
|
||||
memory_region_name(section->mr));
|
||||
} else {
|
||||
error_free(err);
|
||||
}
|
||||
} else {
|
||||
error_report_err(err);
|
||||
hw_error("vfio: DMA mapping failed, unable to continue");
|
||||
}
|
||||
}
|
||||
@@ -1251,6 +1268,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||
container = g_malloc0(sizeof(*container));
|
||||
container->space = space;
|
||||
container->fd = fd;
|
||||
container->error = NULL;
|
||||
QLIST_INIT(&container->giommu_list);
|
||||
QLIST_INIT(&container->hostwin_list);
|
||||
|
||||
@@ -1308,9 +1326,9 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||
&address_space_memory);
|
||||
if (container->error) {
|
||||
memory_listener_unregister(&container->prereg_listener);
|
||||
ret = container->error;
|
||||
error_setg(errp,
|
||||
"RAM memory listener initialization failed for container");
|
||||
ret = -1;
|
||||
error_propagate_prepend(errp, container->error,
|
||||
"RAM memory listener initialization failed: ");
|
||||
goto free_container_exit;
|
||||
}
|
||||
}
|
||||
@@ -1365,9 +1383,9 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||
memory_listener_register(&container->listener, container->space->as);
|
||||
|
||||
if (container->error) {
|
||||
ret = container->error;
|
||||
error_setg_errno(errp, -ret,
|
||||
"memory listener initialization failed for container");
|
||||
ret = -1;
|
||||
error_propagate_prepend(errp, container->error,
|
||||
"memory listener initialization failed: ");
|
||||
goto listener_release_exit;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user