Patch Round-up for stable 2.11.2, freeze on 2018-06-22
Subsystems (2)
PATCH 99/113 ahci: fix PxCI register race
In reply to Michael RothFrom: John Snow <[email protected]>
AHCI presently signals completion prior to the PxCI register being cleared to indicate completion. If a guest driver attempts to issue a new command in its IRQ handler, it might be surprised to learn there is still a command pending.
In the case of Windows 10's boot driver, it will actually poll the IRQ register hoping to find out when the command is done running -- which will never happen, as there isn't a command running.
Fix this: clear PxCI in ahci_cmd_done and not in the asynchronous BH. Because it now runs synchronously, we don't need to check if the command is actually done by spying on the ATA registers. We know it's done.
Message-id: [email protected]
--- hw/ide/ahci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
hw/ide/ahci.c +6 -7
@@ -533,13 +533,6 @@ static void ahci_check_cmd_bh(void *opaque)qemu_bh_delete (ad->check_bh); ad->check_bh =NULL ; -if ((ad->busy_slot !=-1 ) && - !(ad->port.ifs[0 ].status & (BUSY_STAT |DRQ_STAT ))) { -/* no longer busy */ - ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot); - ad->busy_slot =-1 ; - } -check_cmd (ad->hba, ad->port_no); }
@@ -1426,6 +1419,12 @@ static void ahci_cmd_done(IDEDMA *dma)trace_ahci_cmd_done (ad->hba, ad->port_no); +/* no longer busy */ +if (ad->busy_slot !=-1 ) { + ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot); + ad->busy_slot =-1 ; + } +/* update d2h status */ ahci_write_fis_d2h (ad);
Signature · 1 line
2.11.0
PATCH 100/113 arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
In reply to Michael RothFrom: Shannon Zhao <[email protected]>
While we skip the GIC_INTERNAL irqs, we don't change the register offset accordingly. This will overlap the GICR registers value and leave the last GIC_INTERNAL irq's registers out of update.
Fix this by skipping the registers banked by GICR.
Also for migration compatibility if the migration source (old version qemu) doesn't send gicd_no_migration_shift_bug = 1 to destination, then we shift the data of PPI to get the right data for SPI.
Message-id: [email protected]
--- hw/intc/arm_gicv3_common.c | 79 ++++++++++++++++++++++++++++++++++++++ hw/intc/arm_gicv3_kvm.c | 38 ++++++++++++++++++ include/hw/intc/arm_gicv3_common.h | 1 + 3 files changed, 118 insertions(+)
hw/intc/arm_gicv3_common.c +79 -0
@@ -27,6 +27,7 @@#include "hw/intc/arm_gicv3_common.h" #include "gicv3_internal.h" #include "hw/arm/linux-boot-if.h" +#include "sysemu/kvm.h" static int gicv3_pre_save (void *opaque) {
@@ -141,6 +142,79 @@ static const VMStateDescription vmstate_gicv3_cpu = { } }; +static int gicv3_gicd_no_migration_shift_bug_pre_load (void *opaque) +{ +GICv3State *cs = opaque; + +/* +* The gicd_no_migration_shift_bug flag is used for migration compatibility +* for old version QEMU which may have the GICD bmp shift bug under KVM mode. +* Strictly, what we want to know is whether the migration source is using +* KVM. Since we don't have any way to determine that, we look at whether the +* destination is using KVM; this is close enough because for the older QEMU +* versions with this bug KVM -> TCG migration didn't work anyway. If the +* source is a newer QEMU without this bug it will transmit the migration +* subsection which sets the flag to true; otherwise it will remain set to +* the value we select here. +*/ +if (kvm_enabled ()) { + cs->gicd_no_migration_shift_bug = false; + } + +return 0 ; +} + +static int gicv3_gicd_no_migration_shift_bug_post_load (void *opaque, +int version_id) +{ +GICv3State *cs = opaque; + +if (cs->gicd_no_migration_shift_bug) { +return 0 ; + } + +/* Older versions of QEMU had a bug in the handling of state save/restore +* to the KVM GICv3: they got the offset in the bitmap arrays wrong, +* so that instead of the data for external interrupts 32 and up +* starting at bit position 32 in the bitmap, it started at bit +* position 64. If we're receiving data from a QEMU with that bug, +* we must move the data down into the right place. +*/ +memmove (cs->group, (uint8_t *)cs->group +GIC_INTERNAL /8 , +sizeof (cs->group) -GIC_INTERNAL /8 ); +memmove (cs->grpmod, (uint8_t *)cs->grpmod +GIC_INTERNAL /8 , +sizeof (cs->grpmod) -GIC_INTERNAL /8 ); +memmove (cs->enabled, (uint8_t *)cs->enabled +GIC_INTERNAL /8 , +sizeof (cs->enabled) -GIC_INTERNAL /8 ); +memmove (cs->pending, (uint8_t *)cs->pending +GIC_INTERNAL /8 , +sizeof (cs->pending) -GIC_INTERNAL /8 ); +memmove (cs->active, (uint8_t *)cs->active +GIC_INTERNAL /8 , +sizeof (cs->active) -GIC_INTERNAL /8 ); +memmove (cs->edge_trigger, (uint8_t *)cs->edge_trigger +GIC_INTERNAL /8 , +sizeof (cs->edge_trigger) -GIC_INTERNAL /8 ); + +/* +* While this new version QEMU doesn't have this kind of bug as we fix it, +* so it needs to set the flag to true to indicate that and it's necessary +* for next migration to work from this new version QEMU. +*/ + cs->gicd_no_migration_shift_bug = true; + +return 0 ; +} + +const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = { + .name ="arm_gicv3/gicd_no_migration_shift_bug" , + .version_id =1 , + .minimum_version_id =1 , + .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load, + .post_load = gicv3_gicd_no_migration_shift_bug_post_load, + .fields = (VMStateField []) { +VMSTATE_BOOL (gicd_no_migration_shift_bug, GICv3State), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_gicv3 = { .name ="arm_gicv3" , .version_id =1 ,
@@ -165,6 +239,10 @@ static const VMStateDescription vmstate_gicv3 = { VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, GICv3State, num_cpu, vmstate_gicv3_cpu, GICv3CPUState),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription * []) { + &vmstate_gicv3_gicd_no_migration_shift_bug, +NULL } };
@@ -364,6 +442,7 @@ static void arm_gicv3_common_reset(DeviceState *dev)gicv3_gicd_group_set (s, i); } } + s->gicd_no_migration_shift_bug = true; } static void arm_gic_common_linux_init(ARMLinuxBootIf *obj,
hw/intc/arm_gicv3_kvm.c +38 -0
@@ -164,6 +164,14 @@ static void kvm_dist_get_edge_trigger(GICv3State *s, uint32_t offset,uint32_t reg;int irq; +/* For the KVM GICv3, affinity routing is always enabled, and the first 2 +* GICD_ICFGR<n> registers are always RAZ/WI. The corresponding +* functionality is replaced by GICR_ICFGR<n>. It doesn't need to sync +* them. So it should increase the offset to skip GIC_INTERNAL irqs. +* This matches the for_each_dist_irq_reg() macro which also skips the +* first GIC_INTERNAL irqs. +*/ + offset += (GIC_INTERNAL *2 ) /8 ;for_each_dist_irq_reg (irq, s->num_irq,2 ) {kvm_gicd_access (s, offset, ®, false); reg =half_unshuffle32 (reg >>1 );
@@ -181,6 +189,14 @@ static void kvm_dist_put_edge_trigger(GICv3State *s, uint32_t offset,uint32_t reg;int irq; +/* For the KVM GICv3, affinity routing is always enabled, and the first 2 +* GICD_ICFGR<n> registers are always RAZ/WI. The corresponding +* functionality is replaced by GICR_ICFGR<n>. It doesn't need to sync +* them. So it should increase the offset to skip GIC_INTERNAL irqs. +* This matches the for_each_dist_irq_reg() macro which also skips the +* first GIC_INTERNAL irqs. +*/ + offset += (GIC_INTERNAL *2 ) /8 ;for_each_dist_irq_reg (irq, s->num_irq,2 ) { reg = *gic_bmp_ptr32 (bmp, irq);if (irq %32 !=0 ) {
@@ -222,6 +238,15 @@ static void kvm_dist_getbmp(GICv3State *s, uint32_t offset, uint32_t *bmp)uint32_t reg;int irq; +/* For the KVM GICv3, affinity routing is always enabled, and the +* GICD_IGROUPR0/GICD_IGRPMODR0/GICD_ISENABLER0/GICD_ISPENDR0/ +* GICD_ISACTIVER0 registers are always RAZ/WI. The corresponding +* functionality is replaced by the GICR registers. It doesn't need to sync +* them. So it should increase the offset to skip GIC_INTERNAL irqs. +* This matches the for_each_dist_irq_reg() macro which also skips the +* first GIC_INTERNAL irqs. +*/ + offset += (GIC_INTERNAL *1 ) /8 ;for_each_dist_irq_reg (irq, s->num_irq,1 ) {kvm_gicd_access (s, offset, ®, false); *gic_bmp_ptr32 (bmp, irq) = reg;
@@ -235,6 +260,19 @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset,uint32_t reg;int irq; +/* For the KVM GICv3, affinity routing is always enabled, and the +* GICD_IGROUPR0/GICD_IGRPMODR0/GICD_ISENABLER0/GICD_ISPENDR0/ +* GICD_ISACTIVER0 registers are always RAZ/WI. The corresponding +* functionality is replaced by the GICR registers. It doesn't need to sync +* them. So it should increase the offset and clroffset to skip GIC_INTERNAL +* irqs. This matches the for_each_dist_irq_reg() macro which also skips the +* first GIC_INTERNAL irqs. +*/ + offset += (GIC_INTERNAL *1 ) /8 ; +if (clroffset !=0 ) { + clroffset += (GIC_INTERNAL *1 ) /8 ; + } +for_each_dist_irq_reg (irq, s->num_irq,1 ) {/* If this bitmap is a set/clear register pair, first write to the * clear-reg to clear all bits before using the set-reg to write
include/hw/intc/arm_gicv3_common.h +1 -0
@@ -217,6 +217,7 @@ struct GICv3State {uint32_t revision;bool security_extn;bool irq_reset_nonsecure; +bool gicd_no_migration_shift_bug;int dev_fd;/* kvm device fd if backed by kvm vgic support */ Error *migration_blocker;
Signature · 1 line
2.11.0
PATCH 9/113 spapr: use spapr->vsmt to compute VCPU ids
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Since the introduction of VSMT in 2.11, the spacing of VCPU ids between cores is controllable through a machine property instead of being only dictated by the SMT mode of the host:
cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i
Until recently, the machine code would try to change the SMT mode of the host to be equal to VSMT or exit. This allowed the rest of the code to assume that kvmppc_smt_threads() == spapr->vsmt is always true.
Recent commit "8904e5a75005 spapr: Adjust default VSMT value for better migration compatibility" relaxed the rule. If the VSMT mode cannot be set in KVM for some reasons, but the requested CPU topology is compatible with the current SMT mode, then we let the guest run with kvmppc_smt_threads() != spapr->vsmt.
This breaks quite a few places in the code, in particular when calculating DRC indexes.
This is what happens on a POWER host with subcores-per-core=2 (ie, supports up to SMT4) when passing the following topology:
-smp threads=4,maxcpus=16 \
-device host-spapr-cpu-core,core-id=4,id=core1 \
-device host-spapr-cpu-core,core-id=8,id=core2qemu-system-ppc64: warning: Failed to set KVM's VSMT mode to 8 (errno -22)
This is expected since KVM is limited to SMT4, but the guest is started anyway because this topology can run on SMT4 even with a VSMT8 spacing.
But when we look at the DT, things get nastier:
cpus {
...
ibm,drc-indexes = <0x4 0x10000000 0x10000004 0x10000008 0x1000000c>;This means that we have the following association:
CPU core device | DRC | VCPU id
-----------------+------------+---------
boot core | 0x10000000 | 0 core1 | 0x10000004 | 4 core2 | 0x10000008 | 8 core3 | 0x1000000c | 12
But since the spacing of VCPU ids is 8, the DRC for core1 points to a VCPU that doesn't exist, the DRC for core2 points to the first VCPU of core1 and and so on...
...
PowerPC,POWER8@0 {
...
ibm,my-drc-index = <0x10000000>;
...
};
PowerPC,POWER8@8 {
...
ibm,my-drc-index = <0x10000008>;
...
};
PowerPC,POWER8@10 {
...No ibm,my-drc-index property for this core since 0x10000010 doesn't exist in ibm,drc-indexes above.
...
};
};...
interrupt-controller {
...
ibm,interrupt-server-ranges = <0x0 0x10>;With a spacing of 8, the highest VCPU id for the given topology should be:
16 * 8 / 4 = 32 and not 16
...
linux,phandle = <0x7e7323b8>;
interrupt-controller;
};And CPU hot-plug/unplug is broken:
(qemu) device_del core1
pseries-hotplug-cpu: Cannot find CPU (drc index 10000004) to remove
(qemu) device_del core2
cpu 4 (hwid 8) Ready to die...
cpu 5 (hwid 9) Ready to die...
cpu 6 (hwid 10) Ready to die...
cpu 7 (hwid 11) Ready to die...
These are the VCPU ids of core1 actually
(qemu) device_add host-spapr-cpu-core,core-id=12,id=core3 (qemu) device_del core3
pseries-hotplug-cpu: Cannot find CPU (drc index 1000000c) to remove
This patches all the code in hw/ppc/spapr.c to assume the VSMT spacing when manipulating VCPU ids.
(cherry picked from commit 72194664c8a16b67865eb95054f984dd169cfa86)
--- hw/ppc/spapr.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
hw/ppc/spapr.c +10 -14
@@ -161,9 +161,9 @@ static void pre_2_10_vmstate_unregister_dummy_icp(int i) (void *)(uintptr_t) i); } -static inline int xics_max_server_number (void ) +static int xics_max_server_number (sPAPRMachineState *spapr) { -return DIV_ROUND_UP (max_cpus *kvmppc_smt_threads (), smp_threads); +return DIV_ROUND_UP (max_cpus * spapr->vsmt, smp_threads); }static void xics_system_init (MachineState *machine,int nr_irqs,Error **errp)
@@ -195,7 +195,7 @@ static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp)if (smc->pre_2_10_has_unused_icps) {int i; -for (i =0 ; i <xics_max_server_number (); i++) { +for (i =0 ; i <xics_max_server_number (spapr); i++) {/* Dummy entries get deregistered when real ICPState objects * are registered during CPU core hotplug. */
@@ -338,7 +338,6 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)int ret =0 , offset, cpus_offset;CPUState *cs;char cpu_model[32 ]; -int smt =kvmppc_smt_threads ();uint32_t pft_size_prop[] = {0 ,cpu_to_be32 (spapr->htab_shift)};CPU_FOREACH (cs) {
@@ -347,7 +346,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)int index =spapr_vcpu_id (cpu);int compat_smt =MIN (smp_threads,ppc_compat_max_threads (cpu)); -if ((index % smt) !=0 ) { +if (index % spapr->vsmt !=0 ) {continue ; }
@@ -614,7 +613,6 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)CPUState *cs;int cpus_offset;char *nodename; -int smt =kvmppc_smt_threads (); cpus_offset =fdt_add_subnode (fdt,0 ,"cpus" );_FDT (cpus_offset);
@@ -632,7 +630,7 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)DeviceClass *dc =DEVICE_GET_CLASS (cs);int offset; -if ((index % smt) !=0 ) { +if (index % spapr->vsmt !=0 ) {continue ; }
@@ -1105,7 +1103,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,_FDT (fdt_setprop_cell (fdt,0 ,"#size-cells" ,2 ));/* /interrupt controller */ -spapr_dt_xics (xics_max_server_number (), fdt,PHANDLE_XICP ); +spapr_dt_xics (xics_max_server_number (spapr), fdt,PHANDLE_XICP ); ret =spapr_populate_memory (spapr, fdt);if (ret <0 ) {
@@ -2198,7 +2196,6 @@ static void spapr_init_cpus(sPAPRMachineState *spapr)MachineState *machine =MACHINE (spapr);MachineClass *mc =MACHINE_GET_CLASS (machine);const char *type =spapr_get_cpu_core_type (machine->cpu_type); -int smt =kvmppc_smt_threads ();const CPUArchIdList *possible_cpus;int boot_cores_nr = smp_cpus / smp_threads;int i;
@@ -2233,7 +2230,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr)if (mc->has_hotpluggable_cpus) {spapr_dr_connector_new (OBJECT (spapr),TYPE_SPAPR_DRC_CPU , - (core_id / smp_threads) * smt); + (core_id / smp_threads) * spapr->vsmt); }if (i < boot_cores_nr) {
@@ -3262,10 +3259,10 @@ staticvoid spapr_core_unplug_request (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { +sPAPRMachineState *spapr =SPAPR_MACHINE (OBJECT (hotplug_dev));int index;sPAPRDRConnector *drc;CPUCore *cc =CPU_CORE (dev); -int smt =kvmppc_smt_threads ();if (!spapr_find_cpu_slot (MACHINE (hotplug_dev), cc->core_id, &index)) { error_setg(errp, "Unable to find CPU core with core-id: %d",
@@ -3277,7 +3274,7 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } - drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , index * smt); + drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , index * spapr->vsmt);g_assert (drc);spapr_drc_detach (drc);
@@ -3296,7 +3293,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,CPUState *cs =CPU (core->threads);sPAPRDRConnector *drc;Error *local_err =NULL ; -int smt =kvmppc_smt_threads ();CPUArchId *core_slot;int index;bool hotplugged =spapr_drc_hotplugged (dev);
@@ -3307,7 +3303,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, cc->core_id);return ; } - drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , index * smt); + drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , index * spapr->vsmt);g_assert (drc || !mc->has_hotpluggable_cpus);
Signature · 1 line
2.11.0
PATCH 101/113 block: Make bdrv_is_writable() public
In reply to Michael RothFrom: Max Reitz <[email protected]>
This is a useful function for the whole block layer, so make it public. At the same time, users outside of block.c probably do not need to make use of the reopen functionality, so rename the current function to bdrv_is_writable_after_reopen() create a new bdrv_is_writable() function that just passes NULL to it for the reopen queue.
Message-id: [email protected]
--- block.c | 17 ++++++++++++++--- include/block/block.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-)
block.c +14 -3
@@ -1596,13 +1596,24 @@ static int bdrv_reopen_get_flags(BlockReopenQueue *q, BlockDriverState *bs)/* Returns whether the image file can be written to after the reopen queue @q * has been successfully applied, or right now if @q is NULL. */ -static bool bdrv_is_writable (BlockDriverState *bs,BlockReopenQueue *q) +static bool bdrv_is_writable_after_reopen (BlockDriverState *bs, +BlockReopenQueue *q) {int flags =bdrv_reopen_get_flags (q, bs);return (flags & (BDRV_O_RDWR |BDRV_O_INACTIVE )) ==BDRV_O_RDWR ; } +/* +* Return whether the BDS can be written to. This is not necessarily +* the same as !bdrv_is_read_only(bs), as inactivated images may not +* be written to but do not count as read-only images. +*/ +bool bdrv_is_writable (BlockDriverState *bs) +{ +return bdrv_is_writable_after_reopen (bs,NULL ); +} + static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs, BdrvChild *c, const BdrvChildRole *role, BlockReopenQueue *reopen_queue,
@@ -1640,7 +1651,7 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,/* Write permissions never work with read-only images */ if ((cumulative_perms & (BLK_PERM_WRITE |BLK_PERM_WRITE_UNCHANGED )) && - !bdrv_is_writable (bs, q)) + !bdrv_is_writable_after_reopen (bs, q)) {error_setg (errp,"Block node is read-only" );return -EPERM ;
@@ -1930,7 +1941,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, &perm, &shared);/* Format drivers may touch metadata even if the guest doesn't write */ -if (bdrv_is_writable (bs, reopen_queue)) { +if (bdrv_is_writable_after_reopen (bs, reopen_queue)) { perm |=BLK_PERM_WRITE |BLK_PERM_RESIZE ; }
include/block/block.h +1 -0
@@ -437,6 +437,7 @@ bool bdrv_is_read_only(BlockDriverState *bs);int bdrv_can_set_read_only (BlockDriverState *bs,bool read_only,bool ignore_allow_rdw,Error **errp);int bdrv_set_read_only (BlockDriverState *bs,bool read_only,Error **errp); +bool bdrv_is_writable (BlockDriverState *bs);bool bdrv_is_sg (BlockDriverState *bs);bool bdrv_is_inserted (BlockDriverState *bs);void bdrv_lock_medium (BlockDriverState *bs,bool locked);
Signature · 1 line
2.11.0
PATCH 102/113 qcow2: Do not mark inactive images corrupt
In reply to Michael RothFrom: Max Reitz <[email protected]>
When signaling a corruption on a read-only image, qcow2 already makes fatal events non-fatal (i.e., they will not result in the image being closed, and the image header's corrupt flag will not be set). This is necessary because we cannot set the corrupt flag on read-only images, and it is possible because further corruption of read-only images is impossible.
Inactive images are effectively read-only, too, so we should do the same for them. bdrv_is_writable() can tell us whether an image can actually be written to, so use its result instead of !bs->read_only.
(Otherwise, the assert(!(bs->open_flags & BDRV_O_INACTIVE)) in bdrv_co_pwritev() will fail, crashing qemu.)
Message-id: [email protected]
--- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2.c +1 -1
@@ -4235,7 +4235,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,char *message;va_list ap; - fatal = fatal && !bs->read_only; + fatal = fatal &&bdrv_is_writable (bs);if (s->signaled_corruption && (!fatal || (s->incompatible_features &QCOW2_INCOMPAT_CORRUPT )))
Signature · 1 line
2.11.0
PATCH 103/113 iotests: Add case for a corrupted inactive image
In reply to Michael RothFrom: Max Reitz <[email protected]>
Message-id: [email protected]
--- tests/qemu-iotests/060 | 30 ++++++++++++++++++++++++++++++ tests/qemu-iotests/060.out | 14 ++++++++++++++ 2 files changed, 44 insertions(+)
tests/qemu-iotests/060 +30 -0
@@ -439,6 +439,36 @@ echo "{'execute': 'qmp_capabilities'} -drive if=none,node-name=drive,file="$TEST_IMG",driver=qcow2 \ | _filter_qmp | _filter_qemu_io +echo +echo "=== Testing incoming inactive corrupted image ===" +echo + +_make_test_img 64M +# Create an unaligned L1 entry, so qemu will signal a corruption when +# reading from the covered area +poke_file "$TEST_IMG" "$l1_offset" "\x00\x00\x00\x00\x2a\x2a\x2a\x2a" + +# Inactive images are effectively read-only images, so this should be a +# non-fatal corruption (which does not modify the image) +echo "{'execute': 'qmp_capabilities'} + {'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io drive \"read 0 512\"'}} + {'execute': 'quit'}" \ + | $QEMU -qmp stdio -nographic -nodefaults \ + -blockdev "{'node-name': 'drive', + 'driver': 'qcow2', + 'file': { + 'driver': 'file', + 'filename': '$TEST_IMG' + }}" \ + -incoming exec:'cat /dev/null' \ + 2>&1 \ + | _filter_qmp | _filter_qemu_io + +echo +# Image should not have been marked corrupt +_img_info --format-specific | grep 'corrupt:' + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/060.out +14 -0
@@ -411,4 +411,18 @@ write failed: Input/output error {"return": ""} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + +=== Testing incoming inactive corrupted image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +QMP_VERSION +{"return": {}} +qcow2: Image is corrupt: L2 table offset 0x2a2a2a00 unaligned (L1 index: 0); further non-fatal corruption events will be suppressed +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_IMAGE_CORRUPTED", "data": {"device": "", "msg": "L2 table offset 0x2a2a2a00 unaligned (L1 index: 0)", "node-name": "drive", "fatal": false}} +read failed: Input/output error +{"return": ""} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + + corrupt: false *** done
Signature · 1 line
2.11.0
PATCH 104/113 throttle: Fix crash on reopen
In reply to Michael RothFrom: Alberto Garcia <[email protected]>
The throttle block filter can be reopened, and with this it is possible to change the throttle group that the filter belongs to.
The way the code does that is the following:
- On throttle_reopen_prepare(): create a new ThrottleGroupMember and attach it to the new throttle group.
- On throttle_reopen_commit(): detach the old ThrottleGroupMember, delete it and replace it with the new one.
The problem with this is that by replacing the ThrottleGroupMember the previous value of io_limits_disabled is lost, causing an assertion failure in throttle_co_drain_end().
This problem can be reproduced by reopening a throttle node:
$QEMU -monitor stdio -object throttle-group,id=tg0,x-iops-total=1000 \ -blockdev node-name=hd0,driver=qcow2,file.driver=file,file.filename=hd.qcow2 \ -blockdev node-name=root,driver=throttle,throttle-group=tg0,file=hd0,read-only=on
(qemu) block_stream root
block/throttle.c:214: throttle_co_drain_end: Assertion `tgm->io_limits_disabled' failed.
Since we only want to change the throttle group on reopen there's no need to create a ThrottleGroupMember and discard the old one. It's easier if we simply detach it from its current group and attach it to the new one.
Message-id: [email protected]
--- block/throttle.c | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-)
block/throttle.c +33 -21
@@ -35,9 +35,12 @@ static QemuOptsList throttle_opts = { }, }; -static int throttle_configure_tgm (BlockDriverState *bs, -ThrottleGroupMember *tgm, -QDict *options,Error **errp) +/* +* If this function succeeds then the throttle group name is stored in +* @group and must be freed by the caller. +* If there's an error then @group remains unmodified. +*/ +static int throttle_parse_options (QDict *options,char **group,Error **errp) {int ret;const char *group_name;
@@ -62,8 +65,7 @@ static int throttle_configure_tgm(BlockDriverState *bs, goto fin; } -/* Register membership to group with name group_name */ -throttle_group_register_tgm (tgm, group_name,bdrv_get_aio_context (bs)); + *group =g_strdup (group_name); ret =0 ; fin:qemu_opts_del (opts);
@@ -74,6 +76,8 @@ static int throttle_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { ThrottleGroupMember *tgm = bs->opaque; +char *group; +int ret; bs->file =bdrv_open_child (NULL , options,"file" , bs, &child_file, false, errp);
@@ -83,7 +87,14 @@ static int throttle_open(BlockDriverState *bs, QDict *options, bs->supported_write_flags = bs->file->bs->supported_write_flags; bs->supported_zero_flags = bs->file->bs->supported_zero_flags; -return throttle_configure_tgm (bs, tgm, options, errp); + ret =throttle_parse_options (options, &group, errp); +if (ret ==0 ) { +/* Register membership to group with name group_name */ +throttle_group_register_tgm (tgm, group,bdrv_get_aio_context (bs)); +g_free (group); + } + +return ret; }static void throttle_close (BlockDriverState *bs)
@@ -159,35 +170,36 @@ static void throttle_attach_aio_context(BlockDriverState *bs,static int throttle_reopen_prepare (BDRVReopenState *reopen_state,BlockReopenQueue *queue,Error **errp) { -ThrottleGroupMember *tgm; +int ret; +char *group =NULL ;assert (reopen_state !=NULL );assert (reopen_state->bs !=NULL ); - reopen_state->opaque =g_new0 (ThrottleGroupMember,1 ); - tgm = reopen_state->opaque; - -return throttle_configure_tgm (reopen_state->bs, tgm, reopen_state->options, - errp); + ret =throttle_parse_options (reopen_state->options, &group, errp); + reopen_state->opaque = group; +return ret; }static void throttle_reopen_commit (BDRVReopenState *reopen_state) { -ThrottleGroupMember *old_tgm = reopen_state->bs->opaque; -ThrottleGroupMember *new_tgm = reopen_state->opaque; +BlockDriverState *bs = reopen_state->bs; +ThrottleGroupMember *tgm = bs->opaque; +char *group = reopen_state->opaque; + +assert (group); -throttle_group_unregister_tgm (old_tgm); -g_free (old_tgm); - reopen_state->bs->opaque = new_tgm; +if (strcmp (group,throttle_group_get_name (tgm))) { +throttle_group_unregister_tgm (tgm); +throttle_group_register_tgm (tgm, group,bdrv_get_aio_context (bs)); + } +g_free (reopen_state->opaque); reopen_state->opaque =NULL ; }static void throttle_reopen_abort (BDRVReopenState *reopen_state) { -ThrottleGroupMember *tgm = reopen_state->opaque; - -throttle_group_unregister_tgm (tgm); -g_free (tgm); +g_free (reopen_state->opaque); reopen_state->opaque =NULL ; }
Signature · 1 line
2.11.0
PATCH 106/113 i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639)
In reply to Michael RothFrom: Daniel P. Berrangé <[email protected]>
New microcode introduces the "Speculative Store Bypass Disable" CPUID feature bit. This needs to be exposed to guest OS to allow them to protect against CVE-2018-3639.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 2 +- target/i386/cpu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.c +1 -1
@@ -459,7 +459,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,"spec-ctrl" ,NULL , - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, "ssbd", }, .cpuid_eax =7 , .cpuid_needs_ecx = true, .cpuid_ecx = 0,
target/i386/cpu.h +1 -0
@@ -644,6 +644,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2)/* AVX512 Neural Network Instructions */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31)/* Speculative Store Bypass Disable */ #define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */
Signature · 1 line
2.11.0
PATCH 105/113 vga: fix region calculation
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
Typically the scanline length and the line offset are identical. But in case they are not our calculation for region_end is incorrect. Using line_offset is fine for all scanlines, except the last one where we have to use the actual scanline length.
Message-id: [email protected]
--- hw/display/vga.c | 2 ++ 1 file changed, 2 insertions(+)
hw/display/vga.c +2 -0
@@ -1489,6 +1489,8 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) region_start = (s->start_addr *4 ); region_end = region_start + (ram_addr_t )s->line_offset * height; + region_end += width * s->get_bpp (s) /8 ;/* scanline length */ + region_end -= s->line_offset;if (region_end > s->vbe_size) {/* wraps around (can happen with cirrus vbe modes) */ region_start =0 ;
Signature · 1 line
2.11.0
PATCH 107/113 i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
In reply to Michael RothFrom: Konrad Rzeszutek Wilk <[email protected]>
"Some AMD processors only support a non-architectural means of enabling speculative store bypass disable (SSBD). To allow a simplified view of this to a guest, an architectural definition has been created through a new CPUID bit, 0x80000008_EBX[25], and a new MSR, 0xc001011f. With this, a hypervisor can virtualize the existence of this definition and provide an architectural method for using SSBD to a guest.
Add the new CPUID feature, the new MSR and update the existing SSBD support to use this MSR when present." (from x86/speculation: Add virtualized speculative store bypass disable support in Linux).
Message-Id: <[email protected]>
Conflicts:
target/i386/kvm.c target/i386/machine.c
* drop context dep on b77146e9a
--- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++-- target/i386/machine.c | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-)
target/i386/cpu.h +2 -0
@@ -336,6 +336,7 @@#define MSR_IA32_FEATURE_CONTROL 0x0000003a#define MSR_TSC_ADJUST 0x0000003b#define MSR_IA32_SPEC_CTRL 0x48 +#define MSR_VIRT_SSBD 0xc001011f#define MSR_IA32_TSCDEADLINE 0x6e0#define FEATURE_CONTROL_LOCKED (1<<0)
@@ -1089,6 +1090,7 @@ typedef struct CPUX86State {uint32_t pkru;uint64_t spec_ctrl; +uint64_t virt_ssbd;/* End of state preserved by INIT (dummy marker). */ struct {} end_init_save;
target/i386/kvm.c +14 -2
@@ -92,6 +92,7 @@ static bool has_msr_hv_stimer;static bool has_msr_hv_frequencies;static bool has_msr_xss;static bool has_msr_spec_ctrl; +static bool has_msr_virt_ssbd;static bool has_msr_architectural_pmu;static uint32_t num_architectural_pmu_counters;
@@ -1148,6 +1149,9 @@ static int kvm_get_supported_msrs(KVMState *s)case MSR_IA32_SPEC_CTRL : has_msr_spec_ctrl = true;break ; +case MSR_VIRT_SSBD : + has_msr_virt_ssbd = true; +break ; } } }
@@ -1633,6 +1637,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)if (has_msr_spec_ctrl) {kvm_msr_entry_add (cpu,MSR_IA32_SPEC_CTRL , env->spec_ctrl); } +if (has_msr_virt_ssbd) { +kvm_msr_entry_add (cpu,MSR_VIRT_SSBD , env->virt_ssbd); + } +#ifdef TARGET_X86_64 if (lm_capable_kernel) {kvm_msr_entry_add (cpu,MSR_CSTAR , env->cstar);
@@ -2009,8 +2017,9 @@ static int kvm_get_msrs(X86CPU *cpu)if (has_msr_spec_ctrl) {kvm_msr_entry_add (cpu,MSR_IA32_SPEC_CTRL ,0 ); } - - +if (has_msr_virt_ssbd) { +kvm_msr_entry_add (cpu,MSR_VIRT_SSBD ,0 ); + }if (!env->tsc_valid) {kvm_msr_entry_add (cpu,MSR_IA32_TSC ,0 ); env->tsc_valid = !runstate_is_running ();
@@ -2361,6 +2370,9 @@ static int kvm_get_msrs(X86CPU *cpu)case MSR_IA32_SPEC_CTRL : env->spec_ctrl = msrs[i].data;break ; +case MSR_VIRT_SSBD : + env->virt_ssbd = msrs[i].data; +break ; } }
target/i386/machine.c +20 -0
@@ -837,6 +837,25 @@ static const VMStateDescription vmstate_spec_ctrl = { } }; +static bool virt_ssbd_needed (void *opaque) +{ +X86CPU *cpu = opaque; +CPUX86State *env = &cpu->env; + +return env->virt_ssbd !=0 ; +} + +static const VMStateDescription vmstate_msr_virt_ssbd = { + .name ="cpu/virt_ssbd" , + .version_id =1 , + .minimum_version_id =1 , + .needed = virt_ssbd_needed, + .fields = (VMStateField []){ +VMSTATE_UINT64 (env.virt_ssbd,X86CPU ), +VMSTATE_END_OF_LIST () + } +}; +VMStateDescription vmstate_x86_cpu = { .name ="cpu" , .version_id =12 ,
@@ -957,6 +976,7 @@ VMStateDescription vmstate_x86_cpu = {#endif &vmstate_spec_ctrl, &vmstate_mcg_ext_ctl, + &vmstate_msr_virt_ssbd, NULL } };
Signature · 1 line
2.11.0
PATCH 108/113 i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639)
In reply to Michael RothFrom: Konrad Rzeszutek Wilk <[email protected]>
AMD Zen expose the Intel equivalant to Speculative Store Bypass Disable via the 0x80000008_EBX[25] CPUID feature bit.
This needs to be exposed to guest OS to allow them to protect against CVE-2018-3639.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.c +1 -1
@@ -490,7 +490,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {"ibpb" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL , +NULL ,"virt-ssbd" ,NULL ,NULL , NULL, NULL, NULL, NULL, }, .cpuid_eax = 0x80000008,
Signature · 1 line
2.11.0
PATCH 109/113 tap: set vhostfd passed from qemu cli to non-blocking
In reply to Michael RothFrom: Brijesh Singh <[email protected]>
A guest boot hangs while probing the network interface when iommu_platform=on is used.
The following qemu cli hangs without this patch:
# $QEMU \
-netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=4 3<>/dev/tap67 4<>/dev/host-net \
-device virtio-net-pci,netdev=hostnet0,id=net0,iommu_platform=on,disable-legacy=on \
...
Commit: c471ad0e9bd46 (vhost_net: device IOTLB support) took care of setting vhostfd to non-blocking when QEMU opens /dev/host-net but if the fd is passed from qemu cli then we need to ensure that fd is set to non-blocking.
--- net/tap.c | 2 ++ 1 file changed, 2 insertions(+)
net/tap.c +2 -0
@@ -40,6 +40,7 @@#include "qemu-common.h" #include "qemu/cutils.h" #include "qemu/error-report.h" +#include "qemu/sockets.h" #include "net/tap.h"
@@ -689,6 +690,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,error_propagate (errp, err);return ; } +qemu_set_nonblock (vhostfd); }else { vhostfd =open ("/dev/vhost-net" ,O_RDWR );if (vhostfd <0 ) {
Signature · 1 line
2.11.0
PATCH 10/113 spapr: move VCPU calculation to core machine code
In reply to Michael RothFrom: Greg Kurz <[email protected]>
The VCPU ids are currently computed and assigned to each individual CPU threads in spapr_cpu_core_realize(). But the numbering logic of VCPU ids is actually a machine-level concept, and many places in hw/ppc/spapr.c also have to compute VCPU ids out of CPU indexes.
The current formula used in spapr_cpu_core_realize() is:
vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i
where:
cc->core_id is a multiple of smp_threads
cpu_index = cc->core_id + i
0 <= i < smp_threadsSo we have:
cpu_index % smp_threads == i
cc->core_id / smp_threads == cpu_index / smp_threadshence:
vcpu_id =
(cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads;This formula was used before VSMT at the time VCPU ids where computed at the target emulation level. It has the advantage of being useable to derive a VPCU id out of a CPU index only. It is fitted for all the places where the machine code has to compute a VCPU id.
This patch introduces an accessor to set the VCPU id in a PowerPCCPU object using the above formula. It is a first step to consolidate all the VCPU id logic in a single place.
--- hw/ppc/spapr.c | 19 +++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 9 ++------- include/hw/ppc/spapr.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-)
hw/ppc/spapr.c +19 -0
@@ -3647,6 +3647,25 @@ int spapr_vcpu_id(PowerPCCPU *cpu) } } +void spapr_set_vcpu_id (PowerPCCPU *cpu,int cpu_index,Error **errp) +{ +sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); +int vcpu_id; + + vcpu_id = + (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; + +if (kvm_enabled () && !kvm_vcpu_id_is_valid (vcpu_id)) { +error_setg (errp,"Can't create CPU with id %d in KVM" , vcpu_id); +error_append_hint (errp,"Adjust the number of cpus to %d " +"or try to raise the number of threads per core\n" , + vcpu_id * smp_threads / spapr->vsmt); +return ; + } + + cpu->vcpu_id = vcpu_id; +} +PowerPCCPU *spapr_find_cpu (int vcpu_id) {CPUState *cs;
hw/ppc/spapr_cpu_core.c +2 -7
@@ -176,13 +176,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) cs =CPU (obj); cpu =POWERPC_CPU (cs); cs->cpu_index = cc->core_id + i; - cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i; -if (kvm_enabled () && !kvm_vcpu_id_is_valid (cpu->vcpu_id)) { -error_setg (&local_err,"Can't create CPU with id %d in KVM" , - cpu->vcpu_id); -error_append_hint (&local_err,"Adjust the number of cpus to %d " -"or try to raise the number of threads per core\n" , - cpu->vcpu_id * smp_threads / spapr->vsmt); +spapr_set_vcpu_id (cpu, cs->cpu_index, &local_err); +if (local_err) { goto err; }
include/hw/ppc/spapr.h +1 -0
@@ -757,6 +757,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg);#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift))int spapr_vcpu_id (PowerPCCPU *cpu); +void spapr_set_vcpu_id (PowerPCCPU *cpu,int cpu_index,Error **errp);PowerPCCPU *spapr_find_cpu (int vcpu_id);int spapr_caps_pre_load (void *opaque);
Signature · 1 line
2.11.0
PATCH 110/113 vhost-user: delete net client if necessary
In reply to Michael RothFrom: linzhecheng <[email protected]>
As qemu_new_net_client create new ncs but error happens later, ncs will be left in global net_clients list and we can't use them any more, so we need to cleanup them.
Conflicts:
net/vhost-user.c
* drop functional dep on 4d0cf552
--- net/vhost-user.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/vhost-user.c +9 -2
@@ -296,7 +296,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, s =DO_UPCAST (VhostUserState, nc, nc);if (!qemu_chr_fe_init (&s->chr, chr, &err)) {error_report_err (err); -return -1 ; + goto err; } }
@@ -306,7 +306,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, do { if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) { error_report_err(err); - return -1; + goto err; } qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event, NULL, nc0->name, NULL,
@@ -316,6 +316,13 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,assert (s->vhost_net);return 0 ; + +err: +if (nc0) { +qemu_del_net_client (nc0); + } + +return -1 ; } static Chardev *net_vhost_claim_chardev(
Signature · 1 line
2.11.0
PATCH 111/113 qemu-img: Fix assert when mapping unaligned raw file
In reply to Michael RothFrom: Eric Blake <[email protected]>
Commit a290f085 exposed a latent bug in qemu-img map introduced during the conversion of block status to be byte-based. Earlier in commit 5e344dd8, the internal interface get_block_status() switched to take byte-based parameters, but still called a sector-based block layer function; as such, rounding was added in the lone caller to obey the contract. However, commit 237d78f8 changed get_block_status() to truly be byte-based, at which point rounding to sector boundaries can result in calling bdrv_block_status() with 'bytes == 0' (a coding error) when the boundary between data and a hole falls mid-sector (true for the past-EOF implicit hole present in POSIX files). Fix things by removing the rounding that is now no longer necessary.
See also https://bugzilla.redhat.com/1589738
--- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +1 -1
@@ -2826,7 +2826,7 @@ static int img_map(int argc, char **argv)int64_t n;/* Probe up to 1 GiB at a time. */ - n =QEMU_ALIGN_DOWN (MIN (1 <<30 , length - offset),BDRV_SECTOR_SIZE ); + n =MIN (1 <<30 , length - offset); ret =get_block_status (bs, offset, n, &next);if (ret <0 ) {
Signature · 1 line
2.11.0
PATCH 112/113 iotests: Add test 221 to catch qemu-img map regression
In reply to Michael RothFrom: Eric Blake <[email protected]>
Although qemu-img creates aligned files (by rounding up), it must also gracefully handle files that are not sector-aligned. Test that the bug fixed in the previous patch does not recur.
It's a bit annoying that we can see the (implicit) hole past the end of the file on to the next sector boundary, so if we ever reach the point where we report a byte-accurate size rather than our current behavior of always rounding up, this test will probably need a slight modification.
Conflicts:
tests/qemu-iotests/group
* drop context dep on tests not present in 2.11
--- tests/qemu-iotests/221 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/221.out | 16 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out
tests/qemu-iotests/221 new file +60 -0
@@ -0,0 +1,60 @@ +#!/bin/bash +# +# Test qemu-img vs. unaligned images +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto file +_supported_os Linux + +echo +echo "=== Check mapping of unaligned raw image ===" +echo + +_make_test_img 43009 # qemu-img create rounds size up +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +truncate --size=43009 "$TEST_IMG" # so we resize it and check again +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +$QEMU_IO -c 'w 43008 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +truncate --size=43009 "$TEST_IMG" # so we resize it and check again +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +# success, all done +echo '*** done' +rm -f $seq.full +status=0
tests/qemu-iotests/221.out new file +16 -0
@@ -0,0 +1,16 @@ +QA output created by 221 + +=== Check mapping of unaligned raw image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=43009 +[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +wrote 1/1 bytes at offset 43008 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +*** done
tests/qemu-iotests/group +1 -0
@@ -197,3 +197,4 @@ 197 rw auto quick 198 rw auto 200 rw auto +221 rw auto quick
Signature · 1 line
2.11.0
PATCH 113/113 arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked by GICR_IPRIORITYR
In reply to Michael RothFrom: Shannon Zhao <[email protected]>
While for_each_dist_irq_reg loop starts from GIC_INTERNAL, it forgot to offset the date array and index. This will overlap the GICR registers value and leave the last GIC_INTERNAL irq's registers out of update.
--- hw/intc/arm_gicv3_kvm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
hw/intc/arm_gicv3_kvm.c +16 -2
@@ -135,7 +135,14 @@ static void kvm_dist_get_priority(GICv3State *s, uint32_t offset, uint8_t *bmp)uint32_t reg, *field;int irq; - field = (uint32_t *)bmp; +/* For the KVM GICv3, affinity routing is always enabled, and the first 8 +* GICD_IPRIORITYR<n> registers are always RAZ/WI. The corresponding +* functionality is replaced by GICR_IPRIORITYR<n>. It doesn't need to +* sync them. So it needs to skip the field of GIC_INTERNAL irqs in bmp and +* offset. +*/ + field = (uint32_t *)(bmp +GIC_INTERNAL ); + offset += (GIC_INTERNAL *8 ) /8 ;for_each_dist_irq_reg (irq, s->num_irq,8 ) {kvm_gicd_access (s, offset, ®, false); *field = reg;
@@ -149,7 +156,14 @@ static void kvm_dist_put_priority(GICv3State *s, uint32_t offset, uint8_t *bmp)uint32_t reg, *field;int irq; - field = (uint32_t *)bmp; +/* For the KVM GICv3, affinity routing is always enabled, and the first 8 +* GICD_IPRIORITYR<n> registers are always RAZ/WI. The corresponding +* functionality is replaced by GICR_IPRIORITYR<n>. It doesn't need to +* sync them. So it needs to skip the field of GIC_INTERNAL irqs in bmp and +* offset. +*/ + field = (uint32_t *)(bmp +GIC_INTERNAL ); + offset += (GIC_INTERNAL *8 ) /8 ;for_each_dist_irq_reg (irq, s->num_irq,8 ) { reg = *field;kvm_gicd_access (s, offset, ®, true);
Signature · 1 line
2.11.0
PATCH 11/113 target/ppc: Clarify compat mode max_threads value
In reply to Michael RothFrom: David Gibson <[email protected]>
We recently had some discussions that were sidetracked for a while, because nearly everyone misapprehended the purpose of the 'max_threads' field in the compatiblity modes table. It's all about guest expectations, not host expectations or support (that's handled elsewhere).
In an attempt to avoid a repeat of that confusion, rename the field to 'max_vthreads' and add an explanatory comment.
--- hw/ppc/spapr.c | 4 ++-- target/ppc/compat.c | 25 +++++++++++++++++-------- target/ppc/cpu.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-)
hw/ppc/spapr.c +2 -2
@@ -344,7 +344,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)PowerPCCPU *cpu =POWERPC_CPU (cs);DeviceClass *dc =DEVICE_GET_CLASS (cs);int index =spapr_vcpu_id (cpu); -int compat_smt =MIN (smp_threads,ppc_compat_max_threads (cpu)); +int compat_smt =MIN (smp_threads,ppc_compat_max_vthreads (cpu));if (index % spapr->vsmt !=0 ) {continue ;
@@ -502,7 +502,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,size_t page_sizes_prop_size;uint32_t vcpus_per_socket = smp_threads * smp_cores;uint32_t pft_size_prop[] = {0 ,cpu_to_be32 (spapr->htab_shift)}; -int compat_smt =MIN (smp_threads,ppc_compat_max_threads (cpu)); +int compat_smt =MIN (smp_threads,ppc_compat_max_vthreads (cpu));sPAPRDRConnector *drc;int drc_index;uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ ];
target/ppc/compat.c +17 -8
@@ -32,7 +32,16 @@ typedef struct {uint32_t pvr;uint64_t pcr;uint64_t pcr_level; -int max_threads; + +/* +* Maximum allowed virtual threads per virtual core +* +* This is to stop older guests getting confused by seeing more +* threads than they think the cpu can support. Usually it's +* equal to the number of threads supported on bare metal +* hardware, but not always (see POWER9). +*/ +int max_vthreads; } CompatInfo;static const CompatInfo compat_table[] = {
@@ -45,28 +54,28 @@ static const CompatInfo compat_table[] = { .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05 | PCR_TM_DIS | PCR_VSX_DIS, .pcr_level = PCR_COMPAT_2_05, - .max_threads = 2, + .max_vthreads = 2, }, { /* POWER7, ISA2.06 */ .name = "power7", .pvr = CPU_POWERPC_LOGICAL_2_06, .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, .pcr_level = PCR_COMPAT_2_06, - .max_threads = 4, + .max_vthreads = 4, }, { .name = "power7+", .pvr = CPU_POWERPC_LOGICAL_2_06_PLUS, .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, .pcr_level = PCR_COMPAT_2_06, - .max_threads = 4, + .max_vthreads = 4, }, { /* POWER8, ISA2.07 */ .name = "power8", .pvr = CPU_POWERPC_LOGICAL_2_07, .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07, .pcr_level = PCR_COMPAT_2_07, - .max_threads = 8, + .max_vthreads = 8, }, { /* POWER9, ISA3.00 */ .name = "power9",
@@ -80,7 +89,7 @@ static const CompatInfo compat_table[] = {* confusing if half of the threads disappear from the guest * if it announces it's POWER9 aware at CAS time. */ - .max_threads = 8, + .max_vthreads = 8, }, };
@@ -192,14 +201,14 @@ void ppc_set_compat_all(uint32_t compat_pvr, Error **errp) } } -int ppc_compat_max_threads (PowerPCCPU *cpu) +int ppc_compat_max_vthreads (PowerPCCPU *cpu) {const CompatInfo *compat =compat_by_pvr (cpu->compat_pvr);int n_threads =CPU (cpu)->nr_threads;if (cpu->compat_pvr) {g_assert (compat); - n_threads =MIN (n_threads, compat->max_threads); + n_threads =MIN (n_threads, compat->max_vthreads); }return n_threads;
target/ppc/cpu.h +1 -1
@@ -1382,7 +1382,7 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp);#if !defined(CONFIG_USER_ONLY )void ppc_set_compat_all (uint32_t compat_pvr,Error **errp);#endif -int ppc_compat_max_threads (PowerPCCPU *cpu); +int ppc_compat_max_vthreads (PowerPCCPU *cpu);void ppc_compat_add_property (Object *obj,const char *name,uint32_t *compat_pvr,const char *basedesc,Error **errp);
Signature · 1 line
2.11.0
cover Patch Round-up for stable 2.11.2, freeze on 2018-06-22
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
The following changes since commit 7c1beb52ed86191d9e965444d934adaa2531710f:
Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
git://github.com/mdroth/qemu.git
for you to fetch changes up to acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked by GICR_IPRIORITYR (2018-06-16 07:47:00 -0500)
----------------------------------------------------------------
Alberto Garcia (2):
specs/qcow2: Fix documentation of the compressed cluster descriptor
throttle: Fix crash on reopen
Alexandro Sanchez Bach (1):
target/i386: Fix andn instruction
Brijesh Singh (1):
tap: set vhostfd passed from qemu cli to non-blocking
Cornelia Huck (4):
s390-ccw: force diag 308 subcode to unsigned long s390x/css: disabled subchannels cannot be status pending
virtio-ccw: common reset handler
s390x/ccw: make sure all ccw devices are properly reset
Daniel P. Berrangé (1):
i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639)
David Gibson (3):
spapr: Allow some cases where we can't set VSMT mode in the kernel
spapr: Adjust default VSMT value for better migration compatibility target/ppc: Clarify compat mode max_threads value
Eric Blake (4):
nbd: Honor server's advertised minimum block size nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE
qemu-img: Fix assert when mapping unaligned raw file
iotests: Add test 221 to catch qemu-img map regression
Fam Zheng (1):
raw: Check byte range uniformly
Geert Uytterhoeven (1):
device_tree: Increase FDT_MAX_SIZE to 1 MiB
Gerd Hoffmann (3):
sdl: workaround bug in sdl 2.0.8 headers
qxl: fix local renderer crash
vga: fix region calculation
Greg Kurz (12):
spapr: use spapr->vsmt to compute VCPU ids
spapr: move VCPU calculation to core machine code
spapr: rename spapr_vcpu_id() to spapr_get_vcpu_id()
spapr: consolidate the VCPU id numbering logic in a single place
spapr: fix missing CPU core nodes in DT when running with TCG
spapr: register dummy ICPs later
spapr: make pseries-2.11 the default machine type
virtio_net: flush uncompleted TX on reset
exec: fix memory leak in find_max_supported_pagesize()
vfio-ccw: fix memory leaks in vfio_ccw_realize() target/ppc: always set PPC_MEM_TLBIE in pre 2.8 migration hack
spapr: don't advertise radix GTSE if max-compat-cpu < power9
Henry Wertz (1):
tcg/arm: Fix memory barrier encoding
Jack Schwartz (4):
multiboot: bss_end_addr can be zero
multiboot: Remove unused variables from multiboot.c
multiboot: Use header names when displaying fields
multiboot: fprintf(stderr...) -> error_report()
Jan Kiszka (1):
hw/intc/arm_gicv3: Fix APxR<n> register dispatching
Jason Andryuk (1):
ccid: Fix dwProtocols advertisement of T=0
John Snow (1):
ahci: fix PxCI register race
John Thomson (1):
Fix libusb-1.0.22 deprecated libusb_set_debug with libusb_set_option
KONRAD Frederic (1):
sparc: fix leon3 casa instruction when MMU is disabled
Kevin Wolf (7):
rbd: Fix use after free in qemu_rbd_set_keypairs() error path
multiboot: Reject kernels exceeding the address space
multiboot: Check validity of mh_header_addr tests/multiboot: Test exit code for every qemu run tests/multiboot: Add tests for the a.out kludge tests/multiboot: Add .gitignore
gluster: Fix blockdev-add with server.N.type=unix
Konrad Rzeszutek Wilk (2):
i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639)
Laszlo Ersek (1):
pci-bridge/i82801b11: clear bridge registers on platform reset
Laurent Vivier (1):
spapr: set vsmt to MAX(8, smp_threads)
Mark Cave-Ayland (1):
loader: don't perform overlapping address check for memory region ROM images
Max Filippov (4):
target/xtensa: dump correct physical registers
linux-user: fix mmap/munmap/mprotect/mremap/shmat
linux-user: fix assertion in shmdt
linux-user: fix target_mprotect/target_munmap error return values
Max Reitz (10):
block/file-posix: Fix fully preallocated truncate
iotests: Test preallocated truncate of 2G image
qemu-img: Resolve relative backing paths in rebase
iotests: Add test for rebasing with relative paths
qemu-io: Use purely string blockdev options
qemu-img: Use only string options in img_open_opts
iotests: Add test for -U/force-share conflicts
block: Make bdrv_is_writable() public
qcow2: Do not mark inactive images corrupt
iotests: Add case for a corrupted inactive image
Michael Roth (1):
Merge remote-tracking branch 'gkurz/stable-2.11-staging' into stable-2.11-staging
Michael Walle (1):
lm32: take BQL before writing IP/IM register
Michal Privoznik (2):
qemu-pr-helper: Actually allow users to specify pidfile
console: Avoid segfault in screendump
Murilo Opsfelder Araujo (1):
block/ssh: fix possible segmentation fault when .desc is not null-terminated
Nia Alarie (1):
s390x/virtio: Convert virtio-ccw from *_exit to *_unrealize
Olaf Hering (1):
configure: recognize more rpmbuild macros
Paolo Bonzini (9):
memfd: fix configure test
openpic_kvm: drop address_space_to_flatview call
memory: inline some performance-sensitive accessors
address_space_write: address_space_to_flatview needs RCU lock
address_space_read: address_space_to_flatview needs RCU lock address_space_access_valid: address_space_to_flatview needs RCU lock
address_space_map: address_space_to_flatview needs RCU lock
address_space_rw: address_space_to_flatview needs RCU lock
memory: fix flatview_access_valid RCU read lock/unlock imbalance
Peter Lieven (1):
migration/block: reset dirty bitmap before read in bulk phase
Peter Maydell (3):
cpus.c: ensure running CPU recalculates icount deadlines on timer expiry hw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes target/arm: Implement v8M VLLDM and VLSTM
Peter Xu (9):
intel-iommu: send PSI always even if across PDEs
intel-iommu: remove IntelIOMMUNotifierNode
intel-iommu: add iommu lock
intel-iommu: only do page walk for MAP notifiers
intel-iommu: introduce vtd_page_walk_info
intel-iommu: pass in address space when page walk
intel-iommu: trace domain id during page walk
util: implement simple iova tree
intel-iommu: rework the page walk logic
Philippe Mathieu-Daudé (3):
hw/block/pflash_cfi: fix off-by-one error
qdev: rename typedef qdev_resetfn() -> DeviceReset()
qdev: add helpers to be more explicit when using abstract QOM parent functions
Prasad Singamsetty (2):
intel-iommu: Redefine macros to enable supporting 48 bit address width
intel-iommu: Extend address width to 48 bits
Richard Henderson (2):
tcg: Mark muluh_i64 and mulsh_i64 as 64-bit ops
tcg: Introduce tcg_set_insn_start_param
Shannon Zhao (3):
arm_gicv3_kvm: increase clroffset accordingly
arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked by GICR_IPRIORITYR
Stefan Berger (1):
tpm: Set the flags of the CMD_INIT command to 0
Thomas Huth (1):
pc-bios/s390-ccw: struct tpi_info must be declared as aligned(4)
Tiwei Bie (1):
virtio-balloon: unref the memory region before continuing
Victor Kamensky (1):
arm/translate-a64: treat DISAS_UPDATE as variant of DISAS_EXIT
Viktor Mihajlovski (1):
s390: Do not pass inofficial IPL type to the guest
linzhecheng (1):
vhost-user: delete net client if necessary
MAINTAINERS | 6 + block.c | 17 +- block/file-posix.c | 5 +- block/gluster.c | 21 +- block/nbd-client.c | 3 - block/nbd.c | 2 + block/qcow2.c | 2 +- block/raw-format.c | 64 +++-- block/rbd.c | 3 +- block/ssh.c | 1 + block/throttle.c | 54 ++-- configure | 5 +- cpus.c | 10 +- device_tree.c | 2 +- docs/interop/qcow2.txt | 16 +- exec.c | 92 ++++--- hw/block/pflash_cfi01.c | 10 +- hw/block/pflash_cfi02.c | 9 +- hw/char/cmsdk-apb-uart.c | 1 + hw/core/loader.c | 20 +- hw/core/qdev.c | 24 ++ hw/display/qxl-render.c | 3 +- hw/display/vga.c | 2 + hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 489 +++++++++++++++++++++++++++---------- hw/i386/intel_iommu_internal.h | 43 ++-- hw/i386/multiboot.c | 85 ++++--- hw/i386/trace-events | 5 +- hw/ide/ahci.c | 13 +- hw/intc/arm_gicv3_common.c | 79 ++++++ hw/intc/arm_gicv3_cpuif.c | 12 +- hw/intc/arm_gicv3_kvm.c | 57 ++++- hw/intc/openpic_kvm.c | 4 - hw/net/virtio-net.c | 11 + hw/pci-bridge/i82801b11.c | 1 + hw/ppc/spapr.c | 161 +++++++----- hw/ppc/spapr_caps.c | 5 + hw/ppc/spapr_cpu_core.c | 9 +- hw/s390x/ccw-device.c | 8 + hw/s390x/css.c | 8 + hw/s390x/virtio-ccw.c | 54 ++-- hw/s390x/virtio-ccw.h | 3 +- hw/tpm/tpm_emulator.c | 4 +- hw/usb/dev-smartcard-reader.c | 4 +- hw/usb/host-libusb.c | 4 + hw/vfio/ccw.c | 2 + hw/virtio/virtio-balloon.c | 1 + include/block/block.h | 1 + include/exec/cpu-all.h | 6 +- include/exec/cpu_ldst.h | 16 +- include/exec/memory-internal.h | 13 +- include/exec/memory.h | 45 ++-- include/hw/i386/intel_iommu.h | 26 +- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/ppc/spapr.h | 3 +- include/hw/qdev-core.h | 14 +- include/net/net.h | 1 + include/qemu/iova-tree.h | 134 ++++++++++ linux-user/mmap.c | 26 +- linux-user/syscall.c | 13 +- memory.c | 30 --- migration/block.c | 5 +- nbd/client.c | 14 +- net/net.c | 1 - net/tap.c | 2 + net/vhost-user.c | 11 +- pc-bios/s390-ccw/bootmap.c | 7 + pc-bios/s390-ccw/cio.h | 2 +- pc-bios/s390-ccw/iplb.h | 16 +- qemu-img.c | 29 ++- qemu-io.c | 4 +- scsi/qemu-pr-helper.c | 7 +- target/arm/translate-a64.c | 6 +- target/arm/translate.c | 17 +- target/arm/translate.h | 2 +- target/i386/cpu.c | 4 +- target/i386/cpu.h | 3 + target/i386/kvm.c | 16 +- target/i386/machine.c | 20 ++ target/i386/translate.c | 2 +- target/lm32/op_helper.c | 4 + target/ppc/compat.c | 25 +- target/ppc/cpu.h | 2 +- target/ppc/machine.c | 5 + target/sparc/translate.c | 5 + target/xtensa/translate.c | 1 + tcg/arm/tcg-target.inc.c | 4 +- tcg/tcg-opc.h | 4 +- tcg/tcg.h | 10 + tests/multiboot/.gitignore | 3 + tests/multiboot/Makefile | 22 +- tests/multiboot/aout_kludge.S | 138 +++++++++++ tests/multiboot/aout_kludge.out | 42 ++++ tests/multiboot/run_test.sh | 34 +-- tests/qemu-iotests/024 | 82 ++++++- tests/qemu-iotests/024.out | 30 +++ tests/qemu-iotests/060 | 30 +++ tests/qemu-iotests/060.out | 14 ++ tests/qemu-iotests/106 | 24 ++ tests/qemu-iotests/106.out | 10 + tests/qemu-iotests/153 | 17 ++ tests/qemu-iotests/153.out | 16 ++ tests/qemu-iotests/221 | 60 +++++ tests/qemu-iotests/221.out | 16 ++ tests/qemu-iotests/group | 1 + ui/console.c | 5 + util/Makefile.objs | 1 + util/iova-tree.c | 114 +++++++++ util/memfd.c | 4 +- 109 files changed, 2072 insertions(+), 585 deletions(-) create mode 100644 include/qemu/iova-tree.h create mode 100644 tests/multiboot/.gitignore create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out create mode 100644 util/iova-tree.c
PATCH 12/113 spapr: rename spapr_vcpu_id() to spapr_get_vcpu_id()
From: Greg Kurz <[email protected]>
The spapr_vcpu_id() function is an accessor actually. Let's rename it for symmetry with the recently added spapr_set_vcpu_id() helper.
The motivation behind this is that a later patch will consolidate the VCPU id formula in a function and spapr_vcpu_id looks like an appropriate name.
--- hw/ppc/spapr.c | 16 ++++++++-------- include/hw/ppc/spapr.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
hw/ppc/spapr.c +8 -8
@@ -210,7 +210,7 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,int i, ret =0 ;uint32_t servers_prop[smt_threads];uint32_t gservers_prop[smt_threads *2 ]; -int index =spapr_vcpu_id (cpu); +int index =spapr_get_vcpu_id (cpu);if (cpu->compat_pvr) { ret =fdt_setprop_cell (fdt, offset,"cpu-version" , cpu->compat_pvr);
@@ -239,7 +239,7 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,static int spapr_fixup_cpu_numa_dt (void *fdt,int offset,PowerPCCPU *cpu) { -int index =spapr_vcpu_id (cpu); +int index =spapr_get_vcpu_id (cpu);uint32_t associativity[] = {cpu_to_be32 (0x5 ),cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ),
@@ -343,7 +343,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)CPU_FOREACH (cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);DeviceClass *dc =DEVICE_GET_CLASS (cs); -int index =spapr_vcpu_id (cpu); +int index =spapr_get_vcpu_id (cpu);int compat_smt =MIN (smp_threads,ppc_compat_max_vthreads (cpu));if (index % spapr->vsmt !=0 ) {
@@ -492,7 +492,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,PowerPCCPU *cpu =POWERPC_CPU (cs);CPUPPCState *env = &cpu->env;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cs); -int index =spapr_vcpu_id (cpu); +int index =spapr_get_vcpu_id (cpu);uint32_t segs[] = {cpu_to_be32 (28 ),cpu_to_be32 (40 ),0xffffffff ,0xffffffff }; uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq()
@@ -626,7 +626,7 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)*/ CPU_FOREACH_REVERSE (cs) {PowerPCCPU *cpu =POWERPC_CPU (cs); -int index =spapr_vcpu_id (cpu); +int index =spapr_get_vcpu_id (cpu);DeviceClass *dc =DEVICE_GET_CLASS (cs);int offset;
@@ -3213,7 +3213,7 @@ static void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset, {PowerPCCPU *cpu =POWERPC_CPU (cs);DeviceClass *dc =DEVICE_GET_CLASS (cs); -int id =spapr_vcpu_id (cpu); +int id =spapr_get_vcpu_id (cpu);void *fdt;int offset, fdt_size;char *nodename;
@@ -3636,7 +3636,7 @@ static void spapr_pic_print_info(InterruptStatsProvider *obj,ics_pic_print_info (spapr->ics, mon); } -int spapr_vcpu_id (PowerPCCPU *cpu) +int spapr_get_vcpu_id (PowerPCCPU *cpu) {CPUState *cs =CPU (cpu);
@@ -3673,7 +3673,7 @@ PowerPCCPU *spapr_find_cpu(int vcpu_id)CPU_FOREACH (cs) {PowerPCCPU *cpu =POWERPC_CPU (cs); -if (spapr_vcpu_id (cpu) == vcpu_id) { +if (spapr_get_vcpu_id (cpu) == vcpu_id) {return cpu; } }
include/hw/ppc/spapr.h +1 -1
@@ -756,7 +756,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg);#define HTAB_SIZE (spapr) (1ULL << ((spapr)->htab_shift)) -int spapr_vcpu_id (PowerPCCPU *cpu); +int spapr_get_vcpu_id (PowerPCCPU *cpu);void spapr_set_vcpu_id (PowerPCCPU *cpu,int cpu_index,Error **errp);PowerPCCPU *spapr_find_cpu (int vcpu_id);
Signature · 1 line
2.11.0
PATCH 13/113 spapr: consolidate the VCPU id numbering logic in a single place
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Several places in the code need to calculate a VCPU id:
(cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads
(core_id / smp_threads) * spapr->vsmt (1 user)
index * spapr->vsmt (2 users)or guess that the VCPU id of a given VCPU is the first thread of a virtual core:
index % spapr->vsmt != 0
Even if the numbering logic isn't that complex, it is rather fragile to have these assumptions open-coded in several places. FWIW this was proved with recent issues related to VSMT.
This patch moves the VCPU id formula to a single function to be called everywhere the code needs to compute one. It also adds an helper to guess if a VCPU is the first thread of a VCORE.
--- hw/ppc/spapr.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
hw/ppc/spapr.c +23 -7
@@ -100,6 +100,21 @@#define PHANDLE_XICP 0x00001111 +/* These two functions implement the VCPU id numbering: one to compute them +* all and one to identify thread 0 of a VCORE. Any change to the first one +* is likely to have an impact on the second one, so let's keep them close. +*/ +static int spapr_vcpu_id (sPAPRMachineState *spapr,int cpu_index) +{ +return + (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; +} +static bool spapr_is_thread0_in_vcore (sPAPRMachineState *spapr, +PowerPCCPU *cpu) +{ +return spapr_get_vcpu_id (cpu) % spapr->vsmt ==0 ; +} +static ICSState *spapr_ics_create (sPAPRMachineState *spapr,const char *type_ics,int nr_irqs,Error **errp)
@@ -346,7 +361,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)int index =spapr_get_vcpu_id (cpu);int compat_smt =MIN (smp_threads,ppc_compat_max_vthreads (cpu)); -if (index % spapr->vsmt !=0 ) { +if (!spapr_is_thread0_in_vcore (spapr, cpu)) {continue ; }
@@ -630,7 +645,7 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)DeviceClass *dc =DEVICE_GET_CLASS (cs);int offset; -if (index % spapr->vsmt !=0 ) { +if (!spapr_is_thread0_in_vcore (spapr, cpu)) {continue ; }
@@ -2230,7 +2245,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr)if (mc->has_hotpluggable_cpus) {spapr_dr_connector_new (OBJECT (spapr),TYPE_SPAPR_DRC_CPU , - (core_id / smp_threads) * spapr->vsmt); +spapr_vcpu_id (spapr, core_id)); }if (i < boot_cores_nr) {
@@ -3274,7 +3289,8 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } - drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , index * spapr->vsmt); + drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , +spapr_vcpu_id (spapr, cc->core_id));g_assert (drc);spapr_drc_detach (drc);
@@ -3303,7 +3319,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, cc->core_id);return ; } - drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , index * spapr->vsmt); + drc =spapr_drc_by_id (TYPE_SPAPR_DRC_CPU , +spapr_vcpu_id (spapr, cc->core_id));g_assert (drc || !mc->has_hotpluggable_cpus);
@@ -3652,8 +3669,7 @@ void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp)sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());int vcpu_id; - vcpu_id = - (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; + vcpu_id =spapr_vcpu_id (spapr, cpu_index);if (kvm_enabled () && !kvm_vcpu_id_is_valid (vcpu_id)) {error_setg (errp,"Can't create CPU with id %d in KVM" , vcpu_id);
Signature · 1 line
2.11.0
PATCH 15/113 spapr: register dummy ICPs later
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Some older machine types create more ICPs than needed. We hence need to register up to xics_max_server_number() dummy ICPs to accomodate the migration of these machine types.
Recent VSMT rework changed xics_max_server_number() to return
DIV_ROUND_UP(max_cpus * spapr->vsmt, smp_threads)
instead of
DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(), smp_threads);
The change is okay but it requires spapr->vsmt to be set, which isn't the case with the current code. This causes the formula to return zero and we don't create dummy ICPs. This breaks migration of older guests as reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=1549087
The dummy ICP workaround doesn't really have a dependency on XICS itself. But it does depend on proper VCPU id numbering and it must be applied before creating vCPUs (ie, creating real ICPs). So this patch moves the workaround to spapr_init_cpus(), which already assumes VSMT to be set.
--- hw/ppc/spapr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
hw/ppc/spapr.c +12 -12
@@ -184,7 +184,6 @@ static int xics_max_server_number(sPAPRMachineState *spapr)static void xics_system_init (MachineState *machine,int nr_irqs,Error **errp) {sPAPRMachineState *spapr =SPAPR_MACHINE (machine); -sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine);if (kvm_enabled ()) { if (machine_kernel_irqchip_allowed(machine) &&
@@ -206,17 +205,6 @@ static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp)return ; } } - -if (smc->pre_2_10_has_unused_icps) { -int i; - -for (i =0 ; i <xics_max_server_number (spapr); i++) { -/* Dummy entries get deregistered when real ICPState objects -* are registered during CPU core hotplug. -*/ -pre_2_10_vmstate_register_dummy_icp (i); - } - } } static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
@@ -2210,6 +2198,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) {MachineState *machine =MACHINE (spapr);MachineClass *mc =MACHINE_GET_CLASS (machine); +sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine);const char *type =spapr_get_cpu_core_type (machine->cpu_type);const CPUArchIdList *possible_cpus;int boot_cores_nr = smp_cpus / smp_threads;
@@ -2240,6 +2229,17 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) boot_cores_nr = possible_cpus->len; } +if (smc->pre_2_10_has_unused_icps) { +int i; + +for (i =0 ; i <xics_max_server_number (spapr); i++) { +/* Dummy entries get deregistered when real ICPState objects +* are registered during CPU core hotplug. +*/ +pre_2_10_vmstate_register_dummy_icp (i); + } + } +for (i =0 ; i < possible_cpus->len; i++) {int core_id = i * smp_threads;
Signature · 1 line
2.11.0
PATCH 14/113 spapr: fix missing CPU core nodes in DT when running with TCG
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Commit 5d0fb1508e2d "spapr: consolidate the VCPU id numbering logic in a single place" introduced a helper to detect thread0 of a virtual core based on its VCPU id. This is used to create CPU core nodes in the DT, but it is broken in TCG.
$ qemu-system-ppc64 -nographic -accel tcg -machine dumpdtb=dtb.bin \
-smp cores=16,maxcpus=16,threads=1
$ dtc -f -O dts dtb.bin | grep POWER8
PowerPC,POWER8@0 {
PowerPC,POWER8@8 {instead of the expected 16 cores that we get with KVM:
$ dtc -f -O dts dtb.bin | grep POWER8
PowerPC,POWER8@0 {
PowerPC,POWER8@8 {
PowerPC,POWER8@10 {
PowerPC,POWER8@18 {
PowerPC,POWER8@20 {
PowerPC,POWER8@28 {
PowerPC,POWER8@30 {
PowerPC,POWER8@38 {
PowerPC,POWER8@40 {
PowerPC,POWER8@48 {
PowerPC,POWER8@50 {
PowerPC,POWER8@58 {
PowerPC,POWER8@60 {
PowerPC,POWER8@68 {
PowerPC,POWER8@70 {
PowerPC,POWER8@78 {This happens because spapr_get_vcpu_id() maps VCPU ids to cs->cpu_index in TCG mode. This confuses the code in spapr_is_thread0_in_vcore(), since it assumes thread0 VCPU ids to have a spapr->vsmt spacing.
spapr_get_vcpu_id(cpu) % spapr->vsmt == 0
Actually, there's no real reason to expose cs->cpu_index instead of the VCPU id, since we also generate it with TCG. Also we already set it explicitly in spapr_set_vcpu_id(), so there's no real reason either to call kvm_arch_vcpu_id() with KVM.
This patch unifies spapr_get_vcpu_id() to always return the computed VCPU id both in TCG and KVM. This is one step forward towards KVM<->TCG migration.
--- hw/ppc/spapr.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
hw/ppc/spapr.c +1 -7
@@ -3655,13 +3655,7 @@ static void spapr_pic_print_info(InterruptStatsProvider *obj,int spapr_get_vcpu_id (PowerPCCPU *cpu) { -CPUState *cs =CPU (cpu); - -if (kvm_enabled ()) { -return kvm_arch_vcpu_id (cs); - }else { -return cs->cpu_index; - } +return cpu->vcpu_id; }void spapr_set_vcpu_id (PowerPCCPU *cpu,int cpu_index,Error **errp)
Signature · 1 line
2.11.0
PATCH 16/113 spapr: make pseries-2.11 the default machine type
In reply to Michael RothFrom: Greg Kurz <[email protected]>
The spapr capability framework was introduced in QEMU 2.12. It allows to have an explicit control on how host features are exposed to the guest. This is especially needed to handle migration between hetero- geneous hosts (eg, POWER8 to POWER9). It is also used to expose fixes/ workarounds against speculative execution vulnerabilities to guests. The framework was hence backported to QEMU 2.11.1, especially these commits:
0fac4aa93074 spapr: Add pseries-2.12 machine type 9070f408f491 spapr: Treat Hardware Transactional Memory (HTM) as an
optional capability
0fac4aa93074 has the confusing effect of making pseries-2.12 the default machine type for QEMU 2.11.1, instead of the expected pseries-2.11. This patch changes the default machine back to pseries-2.11.
Unfortunately, 9070f408f491 enforces the HTM capability for pseries-2.11. This isn't supported by TCG and breaks 'make check'. So this patch also adds a hack to turn HTM off when using TCG.
--- hw/ppc/spapr.c | 4 ++-- hw/ppc/spapr_caps.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +2 -2
@@ -3820,7 +3820,7 @@ static void spapr_machine_2_12_class_options(MachineClass *mc)/* Defaults for the latest behaviour inherited from the base class */ } -DEFINE_SPAPR_MACHINE(2_12, "2.12", true); +DEFINE_SPAPR_MACHINE(2_12, "2.12", false);/* * pseries-2.11
@@ -3842,7 +3842,7 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); } -DEFINE_SPAPR_MACHINE(2_11, "2.11", false); +DEFINE_SPAPR_MACHINE(2_11, "2.11", true);/* * pseries-2.10
hw/ppc/spapr_caps.c +5 -0
@@ -285,6 +285,11 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, caps = smc->default_caps; +/* HACK for 2.11.2: fix make check */ +if (tcg_enabled ()) { + caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; + } +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_07 ,0 , spapr->max_compat_pvr)) { caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ;
Signature · 1 line
2.11.0
PATCH 17/113 nbd: Honor server's advertised minimum block size
In reply to Michael RothFrom: Eric Blake <[email protected]>
Commit 79ba8c98 (v2.7) changed the setting of request_alignment to occur only during bdrv_refresh_limits(), rather than at at bdrv_open() time; but at the time, NBD was unaffected, because it still used sector-based callbacks, so the block layer defaulted NBD to use 512 request_alignment.
Later, commit 70c4fb26 (also v2.7) changed NBD to use byte-based callbacks, without setting request_alignment. This resulted in NBD using request_alignment of 1, which works great when the server supports it (as is the case for qemu-nbd), but falls apart miserably if the server requires alignment (but only if qemu actually sends a sub-sector request; qemu-io can do it, but most qemu operations still perform on sectors or larger).
Even later, the NBD protocol was updated to document that clients should learn the server's minimum alignment during NBD_OPT_GO; and recommended that clients should assume a minimum size of 512 unless the server understands NBD_OPT_GO and replied with a smaller size. Commit 081dd1fe (v2.10) attempted to do that, by assigning request_alignment to whatever was learned from the server; but it has two flaws: the assignment is done during bdrv_open() so it gets unconditionally wiped out back to 1 during any later bdrv_refresh_limits(); and the code is not using a default of 512 when the server did not report a minimum size.
Fix these issues by moving the assignment to request_alignment to the right function, and by using a sane default when the server does not advertise a minimum size.
Message-Id: <[email protected]>
--- block/nbd-client.c | 3 --- block/nbd.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
block/nbd-client.c +0 -3
@@ -846,9 +846,6 @@ int nbd_client_init(BlockDriverState *bs,if (client->info.flags &NBD_FLAG_SEND_WRITE_ZEROES ) { bs->supported_zero_flags |=BDRV_REQ_MAY_UNMAP ; } -if (client->info.min_block > bs->bl.request_alignment) { - bs->bl.request_alignment = client->info.min_block; - }qemu_co_mutex_init (&client->send_mutex);qemu_co_queue_init (&client->free_sema);
block/nbd.c +2 -0
@@ -474,8 +474,10 @@ static int nbd_co_flush(BlockDriverState *bs)static void nbd_refresh_limits (BlockDriverState *bs,Error **errp) {NBDClientSession *s =nbd_get_client_session (bs); +uint32_t min = s->info.min_block;uint32_t max =MIN_NON_ZERO (NBD_MAX_BUFFER_SIZE , s->info.max_block); + bs->bl.request_alignment = min ? min :BDRV_SECTOR_SIZE ; bs->bl.max_pdiscard = max; bs->bl.max_pwrite_zeroes = max; bs->bl.max_transfer = max;
Signature · 1 line
2.11.0
PATCH 18/113 specs/qcow2: Fix documentation of the compressed cluster descriptor
In reply to Michael RothFrom: Alberto Garcia <[email protected]>
This patch fixes several mistakes in the documentation of the compressed cluster descriptor:
1) the documentation claims that the cluster descriptor contains the number of sectors used to store the compressed data, but what it actually contains is the number of sectors *minus one* or, in other words, the number of additional sectors after the first one.
2) the width of the fields is incorrectly specified. The number of bits used by each field is
x = 62 - (cluster_bits - 8) for the offset field
y = (cluster_bits - 8) for the size field
So the offset field's location is [0, x-1], not [0, x] as stated.
3) the size field does not contain the size of the compressed data, but rather the number of sectors where that data is stored. The compressed data starts at the exact point specified in the offset field and ends when there's enough data to produce a cluster of decompressed data. Both points can be in the middle of a sector, allowing several compressed clusters to be stored next to one another, sharing sectors if necessary.
--- docs/interop/qcow2.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
docs/interop/qcow2.txt +13 -3
@@ -426,10 +426,20 @@ Standard Cluster Descriptor: Compressed Clusters Descriptor (x = 62 - (cluster_bits - 8)): - Bit 0 - x: Host cluster offset. This is usually _not_ aligned to a - cluster boundary! + Bit 0 - x-1: Host cluster offset. This is usually _not_ aligned to a + cluster or sector boundary! - x+1 - 61: Compressed size of the images in sectors of 512 bytes + x - 61: Number of additional 512-byte sectors used for the + compressed data, beyond the sector containing the offset + in the previous field. Some of these sectors may reside + in the next contiguous host cluster. + + Note that the compressed data does not necessarily occupy + all of the bytes in the final sector; rather, decompression + stops when it has produced a cluster of data. + + Another compressed cluster may map to the tail of the final + sector used by this compressed cluster. If a cluster is unallocated, read requests shall read the data from the backing file (except if bit 0 in the Standard Cluster Descriptor is set). If there is
Signature · 1 line
2.11.0
PATCH 1/113 block/ssh: fix possible segmentation fault when .desc is not null-terminated
In reply to Michael RothFrom: Murilo Opsfelder Araujo <[email protected]>
This patch prevents a possible segmentation fault when .desc members are checked against NULL.
The ssh_runtime_opts was added by commit 8a6a80896d6af03b8ee0c17cdf37219eca2588a7 ("block/ssh: Use QemuOpts for runtime options").
This fix was inspired by
http://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg00883.html.
--- block/ssh.c | 1 + 1 file changed, 1 insertion(+)
block/ssh.c +1 -0
@@ -556,6 +556,7 @@ static QemuOptsList ssh_runtime_opts = { .type = QEMU_OPT_STRING, .help = "Defines how and what to check the host key against", }, + {/* end of list */ } }, };
Signature · 1 line
2.11.0
PATCH 19/113 rbd: Fix use after free in qemu_rbd_set_keypairs() error path
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
If we want to include the invalid option name in the error message, we can't free the string earlier than that.
--- block/rbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/rbd.c +2 -1
@@ -265,13 +265,14 @@ static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json, key =qstring_get_str (name); ret =rados_conf_set (cluster, key,qstring_get_str (value)); -QDECREF (name);QDECREF (value);if (ret <0 ) {error_setg_errno (errp, -ret,"invalid conf option %s" , key); +QDECREF (name); ret = -EINVAL ;break ; } +QDECREF (name); }QDECREF (keypairs);
Signature · 1 line
2.11.0
PATCH 20/113 tpm: Set the flags of the CMD_INIT command to 0
In reply to Michael RothFrom: Stefan Berger <[email protected]>
The flags of the CMD_INIT control channel command were not initialized properly. Fix this and set to 0.
--- hw/tpm/tpm_emulator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/tpm/tpm_emulator.c +3 -1
@@ -260,7 +260,9 @@ static int tpm_emulator_check_caps(TPMEmulator *tpm_emu)static int tpm_emulator_startup_tpm (TPMBackend *tb) {TPMEmulator *tpm_emu =TPM_EMULATOR (tb); -ptm_init init; +ptm_init init = { + .u.req.init_flags =0 , + };ptm_res res;DPRINTF ("%s" , __func__);
Signature · 1 line
2.11.0
PATCH 21/113 loader: don't perform overlapping address check for memory region ROM images
In reply to Michael RothFrom: Mark Cave-Ayland <[email protected]>
All memory region ROM images have a base address of 0 which causes the overlapping address check to fail if more than one memory region ROM image is present, or an existing ROM image is loaded at address 0.
Make sure that we ignore the overlapping address check in rom_check_and_register_reset() if this is a memory region ROM image. In particular this fixes the "rom: requested regions overlap" error on startup when trying to run qemu-system-sparc with a -kernel image since commit 7497638642: "tcx: switch to load_image_mr() and remove prom_addr hack".
--- hw/core/loader.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
hw/core/loader.c +11 -9
@@ -1104,20 +1104,22 @@ int rom_check_and_register_reset(void)if (rom->fw_file) {continue ; } -if ((addr > rom->addr) && (as == rom->as)) { -fprintf (stderr,"rom: requested regions overlap " -"(rom %s. free=0x" TARGET_FMT_plx -", addr=0x" TARGET_FMT_plx")\n" , - rom->name, addr, rom->addr); -return -1 ; +if (!rom->mr) { +if ((addr > rom->addr) && (as == rom->as)) { +fprintf (stderr,"rom: requested regions overlap " +"(rom %s. free=0x" TARGET_FMT_plx +", addr=0x" TARGET_FMT_plx")\n" , + rom->name, addr, rom->addr); +return -1 ; + } + addr = rom->addr; + addr += rom->romsize; + as = rom->as; } - addr = rom->addr; - addr += rom->romsize; section =memory_region_find (rom->mr ? rom->mr :get_system_memory (), rom->addr,1 ); rom->isrom =int128_nz (section.size) &&memory_region_is_rom (section.mr);memory_region_unref (section.mr); - as = rom->as; }qemu_register_reset (rom_reset,NULL ); roms_loaded =1 ;
Signature · 1 line
2.11.0
PATCH 22/113 target/xtensa: dump correct physical registers
In reply to Michael RothFrom: Max Filippov <[email protected]>
xtensa_cpu_dump_state outputs CPU physical registers as is, without synchronization from current window. That may result in different values printed for the current window and corresponding physical registers. Synchronize physical registers from window before dumping.
Conflicts:
target/xtensa/translate.c
* drop context dependencies
--- target/xtensa/translate.c | 1 + 1 file changed, 1 insertion(+)
target/xtensa/translate.c +1 -0
@@ -3288,6 +3288,7 @@ void xtensa_cpu_dump_state(CPUState *cs, FILE *f, (i % 4) == 3 ? '\n' : ' '); } +xtensa_sync_phys_from_window (env);cpu_fprintf (f,"\n" );for (i =0 ; i < env->config->nareg; ++i) {
Signature · 1 line
2.11.0
PATCH 23/113 linux-user: fix mmap/munmap/mprotect/mremap/shmat
In reply to Michael RothFrom: Max Filippov <[email protected]>
In linux-user QEMU that runs for a target with TARGET_ABI_BITS bigger than L1_MAP_ADDR_SPACE_BITS an assertion in page_set_flags fires when mmap, munmap, mprotect, mremap or shmat is called for an address outside the guest address space. mmap and mprotect should return ENOMEM in such case.
Change definition of GUEST_ADDR_MAX to always be the last valid guest address. Account for this change in open_self_maps.
Add macro guest_addr_valid that verifies if the guest address is valid. Add function guest_range_valid that verifies if address range is within guest address space and does not wrap around. Use that macro in mmap/munmap/mprotect/mremap/shmat for error checking.
Message-Id: <[email protected]>
--- include/exec/cpu-all.h | 6 +++++- include/exec/cpu_ldst.h | 16 +++++++--------- linux-user/mmap.c | 20 +++++++++++++++----- linux-user/syscall.c | 5 ++++- 4 files changed, 31 insertions(+), 16 deletions(-)
include/exec/cpu-all.h +5 -1
@@ -159,8 +159,12 @@ extern unsigned long guest_base;extern int have_guest_base;extern unsigned long reserved_va; -#define GUEST_ADDR_MAX (reserved_va ? reserved_va : \ +#if HOST_LONG_BITS <=TARGET_VIRT_ADDR_SPACE_BITS +#define GUEST_ADDR_MAX (~0ul) +#else +#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : \ (1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1) +#endif #else #include "exec/hwaddr.h"
include/exec/cpu_ldst.h +7 -9
@@ -51,15 +51,13 @@/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ #define g2h (x) ((void *)((unsigned long)(target_ulong)(x) + guest_base)) -#if HOST_LONG_BITS <=TARGET_VIRT_ADDR_SPACE_BITS -#define h2g_valid (x) 1 -#else -#define h2g_valid (x) ({ \ - unsigned long __guest = (unsigned long)(x) - guest_base; \ - (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \ - (!reserved_va || (__guest < reserved_va)); \ -}) -#endif +#define guest_addr_valid (x) ((x) <= GUEST_ADDR_MAX) +#define h2g_valid (x) guest_addr_valid((unsigned long)(x) - guest_base) + +static inline int guest_range_valid (unsigned long start,unsigned long len) +{ +return len -1 <=GUEST_ADDR_MAX && start <=GUEST_ADDR_MAX - len +1 ; +}#define h2g_nocheck (x) ({ \ unsigned long __ret = (unsigned long)(x) - guest_base; \
linux-user/mmap.c +15 -5
@@ -80,8 +80,9 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)return -EINVAL ; len =TARGET_PAGE_ALIGN (len); end = start + len; -if (end < start) -return -EINVAL ; +if (!guest_range_valid (start, len)) { +return -ENOMEM ; + } prot &=PROT_READ |PROT_WRITE |PROT_EXEC ;if (len ==0 )return 0 ;
@@ -481,8 +482,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,* It can fail only on 64-bit host with 32-bit target. * On any other target/host host mmap() handles this error correctly. */ -if ((unsigned long )start + len -1 > (abi_ulong) -1 ) { - errno =EINVAL ; +if (!guest_range_valid (start, len)) { + errno =ENOMEM ; goto fail; }
@@ -622,8 +623,10 @@ int target_munmap(abi_ulong start, abi_ulong len)if (start & ~TARGET_PAGE_MASK )return -EINVAL ; len =TARGET_PAGE_ALIGN (len); -if (len ==0 ) +if (len ==0 || !guest_range_valid (start, len)) {return -EINVAL ; + } +mmap_lock (); end = start + len; real_start = start & qemu_host_page_mask;
@@ -678,6 +681,13 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,int prot;void *host_addr; +if (!guest_range_valid (old_addr, old_size) || + ((flags &MREMAP_FIXED ) && + !guest_range_valid (new_addr, new_size))) { + errno =ENOMEM ; +return -1 ; + } +mmap_lock ();if (flags &MREMAP_FIXED ) {
linux-user/syscall.c +4 -1
@@ -4871,6 +4871,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env,return -TARGET_EINVAL ; } } +if (!guest_range_valid (shmaddr, shm_info.shm_segsz)) { +return -TARGET_EINVAL ; + }mmap_lock ();
@@ -7430,7 +7433,7 @@ static int open_self_maps(void *cpu_env, int fd) }if (h2g_valid (min)) {int flags =page_get_flags (h2g (min)); - max =h2g_valid (max -1 ) ? max : (uintptr_t )g2h (GUEST_ADDR_MAX ); + max =h2g_valid (max -1 ) ? max : (uintptr_t )g2h (GUEST_ADDR_MAX ) +1 ;if (page_check_range (h2g (min), max - min, flags) ==-1 ) {continue ; }
Signature · 1 line
2.11.0
PATCH 24/113 linux-user: fix assertion in shmdt
In reply to Michael RothFrom: Max Filippov <[email protected]>
shmdt fails to call mmap_lock/mmap_unlock around page_set_flags, resulting in the following assertion:
page_set_flags: Assertion `have_mmap_lock()' failed.
Wrap shmdt internals into mmap_lock/mmap_unlock.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/syscall.c +7 -1
@@ -4918,6 +4918,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env,static inline abi_long do_shmdt (abi_ulong shmaddr) {int i; +abi_long rv; + +mmap_lock ();for (i =0 ; i <N_SHM_REGIONS ; ++i) {if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) {
@@ -4926,8 +4929,11 @@ static inline abi_long do_shmdt(abi_ulong shmaddr)break ; } } + rv =get_errno (shmdt (g2h (shmaddr))); + +mmap_unlock (); -return get_errno (shmdt (g2h (shmaddr))); +return rv; }#ifdef TARGET_NR_ipc
Signature · 1 line
2.11.0
PATCH 25/113 linux-user: fix target_mprotect/target_munmap error return values
In reply to Michael RothFrom: Max Filippov <[email protected]>
target_mprotect/target_munmap return value goes through get_errno at the call site, thus the functions must either set errno to host error code and return -1 or return negative guest error code. Do the latter.
Message-Id: <[email protected]>
--- linux-user/mmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
linux-user/mmap.c +4 -4
@@ -77,11 +77,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)#endif if ((start & ~TARGET_PAGE_MASK ) !=0 ) -return -EINVAL ; +return -TARGET_EINVAL ; len =TARGET_PAGE_ALIGN (len); end = start + len;if (!guest_range_valid (start, len)) { -return -ENOMEM ; +return -TARGET_ENOMEM ; } prot &=PROT_READ |PROT_WRITE |PROT_EXEC ;if (len ==0 )
@@ -621,10 +621,10 @@ int target_munmap(abi_ulong start, abi_ulong len) start, len);#endif if (start & ~TARGET_PAGE_MASK ) -return -EINVAL ; +return -TARGET_EINVAL ; len =TARGET_PAGE_ALIGN (len);if (len ==0 || !guest_range_valid (start, len)) { -return -EINVAL ; +return -TARGET_EINVAL ; }mmap_lock ();
Signature · 1 line
2.11.0
PATCH 26/113 sparc: fix leon3 casa instruction when MMU is disabled
In reply to Michael RothFrom: KONRAD Frederic <[email protected]>
Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8:casa [..](10), .., .. (and probably others alternate space instructions) triggers a data access exception when the MMU is disabled.
When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU is disabled. Just keep mem_idx unchanged in this case so we passthrough the MMU when it is disabled.
--- target/sparc/translate.c | 5 +++++ 1 file changed, 5 insertions(+)
target/sparc/translate.c +5 -0
@@ -2093,6 +2093,11 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) type =GET_ASI_BFILL ;break ; } + +/* MMU_PHYS_IDX is used when the MMU is disabled to passthrough the +* permissions check in get_physical_address(..). +*/ + mem_idx = (dc->mem_idx ==MMU_PHYS_IDX ) ?MMU_PHYS_IDX : mem_idx; }else {gen_exception (dc,TT_PRIV_INSN ); type =GET_ASI_EXCP ;
Signature · 1 line
2.11.0
PATCH 27/113 openpic_kvm: drop address_space_to_flatview call
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
The MemoryListener is registered on address_space_memory, there is not much to assert. This currently works because the callback is invoked only once when the listener is registered, but section->fv is the _new_ FlatView, not the old one on later calls and that would break.
This confines address_space_to_flatview to exec.c and memory.c.
--- hw/intc/openpic_kvm.c | 4 ---- 1 file changed, 4 deletions(-)
hw/intc/openpic_kvm.c +0 -4
@@ -124,10 +124,6 @@ static void kvm_openpic_region_add(MemoryListener *listener,uint64_t reg_base;int ret; -if (section->fv !=address_space_to_flatview (&address_space_memory)) { -abort (); - } -/* Ignore events on regions that are not us */ if (section->mr != &opp->mem) {return ;
Signature · 1 line
2.11.0
PATCH 28/113 memory: inline some performance-sensitive accessors
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
These accessors are called from inlined functions, and the call sequence is much more expensive than just inlining the access. Move the struct declaration to memory-internal.h so that exec.c and memory.c can both use an inline function.
--- include/exec/memory-internal.h | 13 +++++++++---- include/exec/memory.h | 22 +++++++++++++++++++++- memory.c | 30 ------------------------------ 3 files changed, 30 insertions(+), 35 deletions(-)
include/exec/memory-internal.h +9 -4
@@ -20,7 +20,15 @@#define MEMORY_INTERNAL_H #ifndef CONFIG_USER_ONLY -typedef struct AddressSpaceDispatch AddressSpaceDispatch ; +static inline AddressSpaceDispatch *flatview_to_dispatch (FlatView *fv) +{ +return fv->dispatch; +} + +static inline AddressSpaceDispatch *address_space_to_dispatch (AddressSpace *as) +{ +return flatview_to_dispatch (address_space_to_flatview (as)); +}extern const MemoryRegionOps unassigned_mem_ops;
@@ -30,9 +38,6 @@ bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,void flatview_add_to_dispatch (FlatView *fv,MemoryRegionSection *section);AddressSpaceDispatch *address_space_dispatch_new (FlatView *fv);void address_space_dispatch_compact (AddressSpaceDispatch *d); - -AddressSpaceDispatch *address_space_to_dispatch (AddressSpace *as); -AddressSpaceDispatch *flatview_to_dispatch (FlatView *fv);void address_space_dispatch_free (AddressSpaceDispatch *d); void mtree_print_dispatch(fprintf_function mon, void *f,
include/exec/memory.h +21 -1
@@ -318,7 +318,27 @@ struct AddressSpace {QTAILQ_ENTRY (AddressSpace) address_spaces_link; }; -FlatView *address_space_to_flatview (AddressSpace *as); +typedef struct AddressSpaceDispatch AddressSpaceDispatch ; +typedef struct FlatRange FlatRange ; + +/* Flattened global view of current active memory hierarchy. Kept in sorted +* order. +*/ +struct FlatView { +struct rcu_head rcu; +unsigned ref; +FlatRange *ranges; +unsigned nr; +unsigned nr_allocated; +struct AddressSpaceDispatch *dispatch; +MemoryRegion *root; +}; + +static inline FlatView *address_space_to_flatview (AddressSpace *as) +{ +return atomic_rcu_read (&as->current_map); +} +/** * MemoryRegionSection: describes a fragment of a #MemoryRegion
memory.c +0 -30
@@ -210,8 +210,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a, && !memory_region_ioeventfd_before (b, a); } -typedef struct FlatRange FlatRange ; -/* Range of memory in the global map. Addresses are absolute. */ struct FlatRange {MemoryRegion *mr;
@@ -222,19 +220,6 @@ struct FlatRange {bool readonly; }; -/* Flattened global view of current active memory hierarchy. Kept in sorted -* order. -*/ -struct FlatView { -struct rcu_head rcu; -unsigned ref; -FlatRange *ranges; -unsigned nr; -unsigned nr_allocated; -struct AddressSpaceDispatch *dispatch; -MemoryRegion *root; -}; -typedef struct AddressSpaceOps AddressSpaceOps ;#define FOR_EACH_FLAT_RANGE (var, view) \
@@ -322,21 +307,6 @@ static void flatview_unref(FlatView *view) } } -FlatView *address_space_to_flatview (AddressSpace *as) -{ -return atomic_rcu_read (&as->current_map); -} - -AddressSpaceDispatch *flatview_to_dispatch (FlatView *fv) -{ -return fv->dispatch; -} - -AddressSpaceDispatch *address_space_to_dispatch (AddressSpace *as) -{ -return flatview_to_dispatch (address_space_to_flatview (as)); -} -static bool can_merge (FlatRange *r1,FlatRange *r2) {return int128_eq (addrrange_end (r1->addr), r2->addr.start)
Signature · 1 line
2.11.0
PATCH 29/113 address_space_write: address_space_to_flatview needs RCU lock
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
address_space_write is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_write to address_space_write.
--- exec.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
exec.c +22 -15
@@ -3005,6 +3005,7 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,return result; } +/* Called from RCU critical section. */ static MemTxResult flatview_write (FlatView *fv,hwaddr addr,MemTxAttrs attrs,const uint8_t *buf,int len) {
@@ -3013,25 +3014,14 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,MemoryRegion *mr;MemTxResult result =MEMTX_OK ; -if (len >0 ) { -rcu_read_lock (); - l = len; - mr =flatview_translate (fv, addr, &addr1, &l, true); - result =flatview_write_continue (fv, addr, attrs, buf, len, - addr1, l, mr); -rcu_read_unlock (); - } + l = len; + mr =flatview_translate (fv, addr, &addr1, &l, true); + result =flatview_write_continue (fv, addr, attrs, buf, len, + addr1, l, mr);return result; } -MemTxResult address_space_write (AddressSpace *as,hwaddr addr, -MemTxAttrs attrs, -const uint8_t *buf,int len) -{ -return flatview_write (address_space_to_flatview (as), addr, attrs, buf, len); -} -/* Called within RCU critical section. */ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, uint8_t *buf,
@@ -3140,6 +3130,23 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, addr, attrs, buf, len, is_write); } +MemTxResult address_space_write (AddressSpace *as,hwaddr addr, +MemTxAttrs attrs, +const uint8_t *buf,int len) +{ +MemTxResult result =MEMTX_OK ; +FlatView *fv; + +if (len >0 ) { +rcu_read_lock (); + fv =address_space_to_flatview (as); + result =flatview_write (fv, addr, attrs, buf, len); +rcu_read_unlock (); + } + +return result; +} +void cpu_physical_memory_rw (hwaddr addr,uint8_t *buf,int len,int is_write) {
Signature · 1 line
2.11.0
PATCH 2/113 pci-bridge/i82801b11: clear bridge registers on platform reset
In reply to Michael RothFrom: Laszlo Ersek <[email protected]>
The "i82801b11-bridge" device model is a descendant of "base-pci-bridge" (TYPE_PCI_BRIDGE). However, unlike other similar devices, such as
- pci-bridge,
- pcie-pci-bridge,
- PCIE Root Port,
- xio3130 switch upstream and downstream ports,
- dec-21154-p2p-bridge,
- pbm-bridge,
- xilinx-pcie-root,
"i82801b11-bridge" does not clear the bridge specific registers at platform reset.
This is a problem because devices on "i82801b11-bridge" continue to respond to config space cycles after platform reset, when addressed with the bus number that was previously programmed into the secondary bus number register of "i82801b11-bridge". This error breaks OVMF's search for extra (PXB) root buses, for example.
The device class reset method for "i82801b11-bridge" is currently NULL; set it directly to pci_bridge_reset(), like the last three bridge models in the above listing do.
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1541839
--- hw/pci-bridge/i82801b11.c | 1 + 1 file changed, 1 insertion(+)
hw/pci-bridge/i82801b11.c +1 -0
@@ -98,6 +98,7 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data) k->realize = i82801b11_bridge_realize; k->config_write = pci_bridge_write_config; dc->vmsd = &i82801b11_bridge_dev_vmstate; + dc->reset = pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); }
Signature · 1 line
2.11.0
PATCH 30/113 address_space_read: address_space_to_flatview needs RCU lock
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
address_space_read is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_read_full to address_space_read's constant size fast path and address_space_read_full.
--- exec.c | 38 +++++++++++++++++++++++++------------- include/exec/memory.h | 23 +++++++++-------------- 2 files changed, 34 insertions(+), 27 deletions(-)
exec.c +25 -13
@@ -2575,6 +2575,8 @@ static const MemoryRegionOps watch_mem_ops = { }, }; +static MemTxResult flatview_read (FlatView *fv,hwaddr addr, +MemTxAttrs attrs,uint8_t *buf,int len);static MemTxResult flatview_write (FlatView *fv,hwaddr addr,MemTxAttrs attrs,const uint8_t *buf,int len); static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
@@ -3092,24 +3094,18 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,return result; } -MemTxResult flatview_read_full (FlatView *fv,hwaddr addr, -MemTxAttrs attrs,uint8_t *buf,int len) +/* Called from RCU critical section. */ +static MemTxResult flatview_read (FlatView *fv,hwaddr addr, +MemTxAttrs attrs,uint8_t *buf,int len) {hwaddr l;hwaddr addr1;MemoryRegion *mr; -MemTxResult result =MEMTX_OK ; - -if (len >0 ) { -rcu_read_lock (); - l = len; - mr =flatview_translate (fv, addr, &addr1, &l, false); - result =flatview_read_continue (fv, addr, attrs, buf, len, - addr1, l, mr); -rcu_read_unlock (); - } -return result; + l = len; + mr =flatview_translate (fv, addr, &addr1, &l, false); +return flatview_read_continue (fv, addr, attrs, buf, len, + addr1, l, mr); } static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
@@ -3130,6 +3126,22 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, addr, attrs, buf, len, is_write); } +MemTxResult address_space_read_full (AddressSpace *as,hwaddr addr, +MemTxAttrs attrs,uint8_t *buf,int len) +{ +MemTxResult result =MEMTX_OK ; +FlatView *fv; + +if (len >0 ) { +rcu_read_lock (); + fv =address_space_to_flatview (as); + result =flatview_read (fv, addr, attrs, buf, len); +rcu_read_unlock (); + } + +return result; +} +MemTxResult address_space_write (AddressSpace *as,hwaddr addr,MemTxAttrs attrs,const uint8_t *buf,int len)
include/exec/memory.h +9 -14
@@ -1907,13 +1907,12 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,/* Internal functions, part of the implementation of address_space_read. */ +MemTxResult address_space_read_full (AddressSpace *as,hwaddr addr, +MemTxAttrs attrs,uint8_t *buf,int len);MemTxResult flatview_read_continue (FlatView *fv,hwaddr addr,MemTxAttrs attrs,uint8_t *buf,int len,hwaddr addr1,hwaddr l,MemoryRegion *mr); - -MemTxResult flatview_read_full (FlatView *fv,hwaddr addr, -MemTxAttrs attrs,uint8_t *buf,int len);void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);static inline bool memory_access_is_direct (MemoryRegion *mr,bool is_write)
@@ -1932,7 +1931,7 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)* * Return a MemTxResult indicating whether the operation succeeded * or failed (eg unassigned memory, device rejected the transaction, -* IOMMU fault). +* IOMMU fault). Called within RCU critical section. * * @as: #AddressSpace to be accessed * @addr: address within that address space
@@ -1940,17 +1939,20 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)* @buf: buffer with the data transferred */ static inline __attribute__((__always_inline__)) -MemTxResult flatview_read (FlatView *fv,hwaddr addr,MemTxAttrs attrs, -uint8_t *buf,int len) +MemTxResult address_space_read (AddressSpace *as,hwaddr addr, +MemTxAttrs attrs,uint8_t *buf, +int len) {MemTxResult result =MEMTX_OK ;hwaddr l, addr1;void *ptr;MemoryRegion *mr; +FlatView *fv;if (__builtin_constant_p (len)) {if (len) {rcu_read_lock (); + fv =address_space_to_flatview (as); l = len; mr =flatview_translate (fv, addr, &addr1, &l, false);if (len == l &&memory_access_is_direct (mr, false)) {
@@ -1963,18 +1965,11 @@ MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs,rcu_read_unlock (); } }else { - result =flatview_read_full (fv, addr, attrs, buf, len); + result =address_space_read_full (as, addr, attrs, buf, len); }return result; } -static inline MemTxResult address_space_read (AddressSpace *as,hwaddr addr, -MemTxAttrs attrs,uint8_t *buf, -int len) -{ -return flatview_read (address_space_to_flatview (as), addr, attrs, buf, len); -} -/** * address_space_read_cached: read from a cached RAM region *
Signature · 1 line
2.11.0
PATCH 31/113 address_space_access_valid: address_space_to_flatview needs RCU lock
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
address_space_access_valid is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_access_valid to address_space_access_valid.
--- exec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
exec.c +8 -4
@@ -3322,7 +3322,6 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,MemoryRegion *mr;hwaddr l, xlat; -rcu_read_lock ();while (len >0 ) { l = len; mr =flatview_translate (fv, addr, &xlat, &l, is_write);
@@ -3337,15 +3336,20 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, len -= l; addr += l; } -rcu_read_unlock ();return true; }bool address_space_access_valid (AddressSpace *as,hwaddr addr,int len,bool is_write) { -return flatview_access_valid (address_space_to_flatview (as), - addr, len, is_write); +FlatView *fv; +bool result; + +rcu_read_lock (); + fv =address_space_to_flatview (as); + result =flatview_access_valid (fv, addr, len, is_write); +rcu_read_unlock (); +return result; } static hwaddr
Signature · 1 line
2.11.0
PATCH 32/113 address_space_map: address_space_to_flatview needs RCU lock
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
address_space_map is calling address_space_to_flatview but it can be called outside the RCU lock. The function itself is calling rcu_read_lock/rcu_read_unlock, just in the wrong place, so the fix is easy.
--- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
exec.c +2 -1
@@ -3395,7 +3395,7 @@ void *address_space_map(AddressSpace *as,hwaddr l, xlat;MemoryRegion *mr;void *ptr; -FlatView *fv =address_space_to_flatview (as); +FlatView *fv;if (len ==0 ) {return NULL ;
@@ -3403,6 +3403,7 @@ void *address_space_map(AddressSpace *as, l = len;rcu_read_lock (); + fv =address_space_to_flatview (as); mr =flatview_translate (fv, addr, &xlat, &l, is_write);if (!memory_access_is_direct (mr, is_write)) {
Signature · 1 line
2.11.0
PATCH 33/113 address_space_rw: address_space_to_flatview needs RCU lock
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
address_space_rw is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, transform flatview_rw into address_space_rw, since flatview_rw is otherwise unused.
--- exec.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
exec.c +10 -18
@@ -3108,24 +3108,6 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, addr1, l, mr); } -static MemTxResult flatview_rw (FlatView *fv,hwaddr addr,MemTxAttrs attrs, -uint8_t *buf,int len,bool is_write) -{ -if (is_write) { -return flatview_write (fv, addr, attrs, (uint8_t *)buf, len); - }else { -return flatview_read (fv, addr, attrs, (uint8_t *)buf, len); - } -} - -MemTxResult address_space_rw (AddressSpace *as,hwaddr addr, -MemTxAttrs attrs,uint8_t *buf, -int len,bool is_write) -{ -return flatview_rw (address_space_to_flatview (as), - addr, attrs, buf, len, is_write); -} -MemTxResult address_space_read_full (AddressSpace *as,hwaddr addr,MemTxAttrs attrs,uint8_t *buf,int len) {
@@ -3159,6 +3141,16 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr,return result; } +MemTxResult address_space_rw (AddressSpace *as,hwaddr addr,MemTxAttrs attrs, +uint8_t *buf,int len,bool is_write) +{ +if (is_write) { +return address_space_write (as, addr, attrs, buf, len); + }else { +return address_space_read_full (as, addr, attrs, buf, len); + } +} +void cpu_physical_memory_rw (hwaddr addr,uint8_t *buf,int len,int is_write) {
Signature · 1 line
2.11.0
PATCH 35/113 migration/block: reset dirty bitmap before read in bulk phase
In reply to Michael RothFrom: Peter Lieven <[email protected]>
Reset the dirty bitmap before reading to make sure we don't miss any new data.
Message-Id: <[email protected]>
--- migration/block.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
migration/block.c +2 -3
@@ -331,11 +331,10 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds)*/ qemu_mutex_lock_iothread ();aio_context_acquire (blk_get_aio_context (bmds->blk)); - blk->aiocb =blk_aio_preadv (bb, cur_sector *BDRV_SECTOR_SIZE , &blk->qiov, -0 , blk_mig_read_cb, blk); -bdrv_reset_dirty_bitmap (bmds->dirty_bitmap, cur_sector *BDRV_SECTOR_SIZE , nr_sectors *BDRV_SECTOR_SIZE ); + blk->aiocb =blk_aio_preadv (bb, cur_sector *BDRV_SECTOR_SIZE , &blk->qiov, +0 , blk_mig_read_cb, blk);aio_context_release (blk_get_aio_context (bmds->blk));qemu_mutex_unlock_iothread ();
Signature · 1 line
2.11.0
PATCH 34/113 memory: fix flatview_access_valid RCU read lock/unlock imbalance
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Message-id: [email protected]
--- exec.c | 1 - 1 file changed, 1 deletion(-)
exec.c +0 -1
@@ -3320,7 +3320,6 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,if (!memory_access_is_direct (mr, is_write)) { l =memory_access_size (mr, l, addr);if (!memory_region_access_valid (mr, xlat, l, is_write)) { -rcu_read_unlock ();return false; } }
Signature · 1 line
2.11.0
PATCH 36/113 multiboot: bss_end_addr can be zero
In reply to Michael RothFrom: Jack Schwartz <[email protected]>
The multiboot spec (https://www.gnu.org/software/grub/manual/multiboot/),
section 3.1.3, allows for bss_end_addr to be zero.
A zero bss_end_addr signifies there is no .bss section.
--- hw/i386/multiboot.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
hw/i386/multiboot.c +10 -8
@@ -233,12 +233,6 @@ int load_multiboot(FWCfgState *fw_cfg, mh_entry_addr =ldl_p (header+i+28 );if (mh_load_end_addr) { -if (mh_bss_end_addr < mh_load_addr) { -fprintf (stderr,"invalid mh_bss_end_addr address\n" ); -exit (1 ); - } - mb_kernel_size = mh_bss_end_addr - mh_load_addr; -if (mh_load_end_addr < mh_load_addr) {fprintf (stderr,"invalid mh_load_end_addr address\n" );exit (1 );
@@ -249,8 +243,16 @@ int load_multiboot(FWCfgState *fw_cfg,fprintf (stderr,"invalid kernel_file_size\n" );exit (1 ); } - mb_kernel_size = kernel_file_size - mb_kernel_text_offset; - mb_load_size = mb_kernel_size; + mb_load_size = kernel_file_size - mb_kernel_text_offset; + } +if (mh_bss_end_addr) { +if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { +fprintf (stderr,"invalid mh_bss_end_addr address\n" ); +exit (1 ); + } + mb_kernel_size = mh_bss_end_addr - mh_load_addr; + }else { + mb_kernel_size = mb_load_size; }/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE.
Signature · 1 line
2.11.0
PATCH 37/113 multiboot: Remove unused variables from multiboot.c
In reply to Michael RothFrom: Jack Schwartz <[email protected]>
Remove unused variables: mh_mode_type, mh_width, mh_height, mh_depth
--- hw/i386/multiboot.c | 6 ------ 1 file changed, 6 deletions(-)
hw/i386/multiboot.c +0 -6
@@ -255,12 +255,6 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } -/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. -uint32_t mh_mode_type = ldl_p(header+i+32); -uint32_t mh_width = ldl_p(header+i+36); -uint32_t mh_height = ldl_p(header+i+40); -uint32_t mh_depth = ldl_p(header+i+44); */ -mb_debug ("multiboot: mh_header_addr = %#x\n" , mh_header_addr);mb_debug ("multiboot: mh_load_addr = %#x\n" , mh_load_addr);mb_debug ("multiboot: mh_load_end_addr = %#x\n" , mh_load_end_addr);
Signature · 1 line
2.11.0
PATCH 38/113 multiboot: Use header names when displaying fields
In reply to Michael RothFrom: Jack Schwartz <[email protected]>
Refer to field names when displaying fields in printf and debug statements.
--- hw/i386/multiboot.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
hw/i386/multiboot.c +8 -8
@@ -224,7 +224,7 @@ int load_multiboot(FWCfgState *fw_cfg, mh_load_addr =ldl_p (header+i+16 );if (mh_header_addr < mh_load_addr) { -fprintf (stderr,"invalid mh_load_addr address\n" ); +fprintf (stderr,"invalid load_addr address\n" );exit (1 ); }
@@ -234,7 +234,7 @@ int load_multiboot(FWCfgState *fw_cfg,if (mh_load_end_addr) {if (mh_load_end_addr < mh_load_addr) { -fprintf (stderr,"invalid mh_load_end_addr address\n" ); +fprintf (stderr,"invalid load_end_addr address\n" );exit (1 ); } mb_load_size = mh_load_end_addr - mh_load_addr;
@@ -247,7 +247,7 @@ int load_multiboot(FWCfgState *fw_cfg, }if (mh_bss_end_addr) {if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { -fprintf (stderr,"invalid mh_bss_end_addr address\n" ); +fprintf (stderr,"invalid bss_end_addr address\n" );exit (1 ); } mb_kernel_size = mh_bss_end_addr - mh_load_addr;
@@ -255,10 +255,10 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } -mb_debug ("multiboot: mh_header_addr = %#x\n" , mh_header_addr); -mb_debug ("multiboot: mh_load_addr = %#x\n" , mh_load_addr); -mb_debug ("multiboot: mh_load_end_addr = %#x\n" , mh_load_end_addr); -mb_debug ("multiboot: mh_bss_end_addr = %#x\n" , mh_bss_end_addr); +mb_debug ("multiboot: header_addr = %#x\n" , mh_header_addr); +mb_debug ("multiboot: load_addr = %#x\n" , mh_load_addr); +mb_debug ("multiboot: load_end_addr = %#x\n" , mh_load_end_addr); +mb_debug ("multiboot: bss_end_addr = %#x\n" , mh_bss_end_addr);mb_debug ("qemu: loading multiboot kernel (%#x bytes) at %#x\n" , mb_load_size, mh_load_addr);
@@ -361,7 +361,7 @@ int load_multiboot(FWCfgState *fw_cfg,stl_p (bootinfo +MBI_BOOT_DEVICE ,0x8000ffff );/* XXX: use the -boot switch? */ stl_p (bootinfo +MBI_MMAP_ADDR ,ADDR_E820_MAP ); -mb_debug ("multiboot: mh_entry_addr = %#x\n" , mh_entry_addr); +mb_debug ("multiboot: entry_addr = %#x\n" , mh_entry_addr);mb_debug (" mb_buf_phys = " TARGET_FMT_plx"\n" , mbs.mb_buf_phys);mb_debug (" mod_start = " TARGET_FMT_plx"\n" , mbs.mb_buf_phys + mbs.offset_mods);mb_debug (" mb_mods_count = %d\n" , mbs.mb_mods_count);
Signature · 1 line
2.11.0
PATCH 39/113 multiboot: fprintf(stderr...) -> error_report()
In reply to Michael RothFrom: Jack Schwartz <[email protected]>
Change all fprintf(stderr...) calls in hw/i386/multiboot.c to call error_report() instead, including the mb_debug macro. Remove the "\n" from strings passed to all modified calls, since error_report() appends one.
--- hw/i386/multiboot.c | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-)
hw/i386/multiboot.c +29 -26
@@ -31,12 +31,13 @@#include "hw/loader.h" #include "elf.h" #include "sysemu/sysemu.h" +#include "qemu/error-report.h" /* Show multiboot debug output */ //#define DEBUG_MULTIBOOT #ifdef DEBUG_MULTIBOOT -#define mb_debug(a...) fprintf(stderr, ## a) +#define mb_debug(a...) error_report(a)#else #define mb_debug(a...)#endif
@@ -137,7 +138,7 @@ static void mb_add_mod(MultibootState *s,stl_p (p +MB_MOD_END , end);stl_p (p +MB_MOD_CMDLINE , cmdline_phys); -mb_debug ("mod%02d: " TARGET_FMT_plx" - " TARGET_FMT_plx"\n" , +mb_debug ("mod%02d: " TARGET_FMT_plx" - " TARGET_FMT_plx, s->mb_mods_count, start, end); s->mb_mods_count++;
@@ -179,12 +180,12 @@ int load_multiboot(FWCfgState *fw_cfg,if (!is_multiboot)return 0 ;/* no multiboot */ -mb_debug ("qemu: I believe we found a multiboot image!\n" ); +mb_debug ("qemu: I believe we found a multiboot image!" );memset (bootinfo,0 ,sizeof (bootinfo));memset (&mbs,0 ,sizeof (mbs));if (flags &0x00000004 ) {/* MULTIBOOT_HEADER_HAS_VBE */ -fprintf (stderr,"qemu: multiboot knows VBE. we don't.\n" ); +error_report ("qemu: multiboot knows VBE. we don't." ); }if (!(flags &0x00010000 )) {/* MULTIBOOT_HEADER_HAS_ADDR */ uint64_t elf_entry;
@@ -193,7 +194,7 @@ int load_multiboot(FWCfgState *fw_cfg,fclose (f);if (((struct elf64_hdr *)header)->e_machine ==EM_X86_64 ) { -fprintf (stderr,"Cannot load x86-64 image, give a 32bit one.\n" ); +error_report ("Cannot load x86-64 image, give a 32bit one." );exit (1 ); }
@@ -201,7 +202,7 @@ int load_multiboot(FWCfgState *fw_cfg, &elf_low, &elf_high,0 ,I386_ELF_MACHINE , 0, 0);if (kernel_size <0 ) { -fprintf (stderr,"Error while loading elf kernel\n" ); +error_report ("Error while loading elf kernel" );exit (1 ); } mh_load_addr = elf_low;
@@ -210,12 +211,13 @@ int load_multiboot(FWCfgState *fw_cfg, mbs.mb_buf =g_malloc (mb_kernel_size);if (rom_copy (mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) { -fprintf (stderr,"Error while fetching elf kernel from rom\n" ); +error_report ("Error while fetching elf kernel from rom" );exit (1 ); } -mb_debug ("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n" , - mb_kernel_size, (size_t )mh_entry_addr); +mb_debug ("qemu: loading multiboot-elf kernel " +"(%#x bytes) with entry %#zx" , + mb_kernel_size, (size_t )mh_entry_addr); }else {/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ uint32_t mh_header_addr =ldl_p (header+i+12 );
@@ -224,7 +226,7 @@ int load_multiboot(FWCfgState *fw_cfg, mh_load_addr =ldl_p (header+i+16 );if (mh_header_addr < mh_load_addr) { -fprintf (stderr,"invalid load_addr address\n" ); +error_report ("invalid load_addr address" );exit (1 ); }
@@ -234,20 +236,20 @@ int load_multiboot(FWCfgState *fw_cfg,if (mh_load_end_addr) {if (mh_load_end_addr < mh_load_addr) { -fprintf (stderr,"invalid load_end_addr address\n" ); +error_report ("invalid load_end_addr address" );exit (1 ); } mb_load_size = mh_load_end_addr - mh_load_addr; }else {if (kernel_file_size < mb_kernel_text_offset) { -fprintf (stderr,"invalid kernel_file_size\n" ); +error_report ("invalid kernel_file_size" );exit (1 ); } mb_load_size = kernel_file_size - mb_kernel_text_offset; }if (mh_bss_end_addr) {if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { -fprintf (stderr,"invalid bss_end_addr address\n" ); +error_report ("invalid bss_end_addr address" );exit (1 ); } mb_kernel_size = mh_bss_end_addr - mh_load_addr;
@@ -255,17 +257,17 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } -mb_debug ("multiboot: header_addr = %#x\n" , mh_header_addr); -mb_debug ("multiboot: load_addr = %#x\n" , mh_load_addr); -mb_debug ("multiboot: load_end_addr = %#x\n" , mh_load_end_addr); -mb_debug ("multiboot: bss_end_addr = %#x\n" , mh_bss_end_addr); -mb_debug ("qemu: loading multiboot kernel (%#x bytes) at %#x\n" , +mb_debug ("multiboot: header_addr = %#x" , mh_header_addr); +mb_debug ("multiboot: load_addr = %#x" , mh_load_addr); +mb_debug ("multiboot: load_end_addr = %#x" , mh_load_end_addr); +mb_debug ("multiboot: bss_end_addr = %#x" , mh_bss_end_addr); +mb_debug ("qemu: loading multiboot kernel (%#x bytes) at %#x" , mb_load_size, mh_load_addr); mbs.mb_buf =g_malloc (mb_kernel_size);fseek (f, mb_kernel_text_offset,SEEK_SET );if (fread (mbs.mb_buf,1 , mb_load_size, f) != mb_load_size) { -fprintf (stderr,"fread() failed\n" ); +error_report ("fread() failed" );exit (1 ); }memset (mbs.mb_buf + mb_load_size,0 , mb_kernel_size - mb_load_size);
@@ -319,10 +321,10 @@ int load_multiboot(FWCfgState *fw_cfg,hwaddr c =mb_add_cmdline (&mbs, tmpbuf);if ((next_space =strchr (tmpbuf,' ' ))) *next_space ='\0' ; -mb_debug ("multiboot loading module: %s\n" , tmpbuf); +mb_debug ("multiboot loading module: %s" , tmpbuf); mb_mod_length =get_image_size (tmpbuf);if (mb_mod_length <0 ) { -fprintf (stderr,"Failed to open file '%s'\n" , tmpbuf); +error_report ("Failed to open file '%s'" , tmpbuf);exit (1 ); }
@@ -333,7 +335,7 @@ int load_multiboot(FWCfgState *fw_cfg,mb_add_mod (&mbs, mbs.mb_buf_phys + offs, mbs.mb_buf_phys + offs + mb_mod_length, c); -mb_debug ("mod_start: %p\nmod_end: %p\n cmdline: " TARGET_FMT_plx"\n" , +mb_debug ("mod_start: %p\nmod_end: %p\n cmdline: " TARGET_FMT_plx, (char *)mbs.mb_buf + offs, (char *)mbs.mb_buf + offs + mb_mod_length, c); initrd_filename = next_initrd+1 ;
@@ -361,10 +363,11 @@ int load_multiboot(FWCfgState *fw_cfg,stl_p (bootinfo +MBI_BOOT_DEVICE ,0x8000ffff );/* XXX: use the -boot switch? */ stl_p (bootinfo +MBI_MMAP_ADDR ,ADDR_E820_MAP ); -mb_debug ("multiboot: entry_addr = %#x\n" , mh_entry_addr); -mb_debug (" mb_buf_phys = " TARGET_FMT_plx"\n" , mbs.mb_buf_phys); -mb_debug (" mod_start = " TARGET_FMT_plx"\n" , mbs.mb_buf_phys + mbs.offset_mods); -mb_debug (" mb_mods_count = %d\n" , mbs.mb_mods_count); +mb_debug ("multiboot: entry_addr = %#x" , mh_entry_addr); +mb_debug (" mb_buf_phys = " TARGET_FMT_plx, mbs.mb_buf_phys); +mb_debug (" mod_start = " TARGET_FMT_plx, + mbs.mb_buf_phys + mbs.offset_mods); +mb_debug (" mb_mods_count = %d" , mbs.mb_mods_count);/* save bootinfo off the stack */ mb_bootinfo_data =g_memdup (bootinfo,sizeof (bootinfo));
Signature · 1 line
2.11.0
PATCH 3/113 virtio-balloon: unref the memory region before continuing
In reply to Michael RothFrom: Tiwei Bie <[email protected]>
--- hw/virtio/virtio-balloon.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio-balloon.c +1 -0
@@ -234,6 +234,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) memory_region_is_rom(section.mr) || memory_region_is_romd(section.mr)) {trace_virtio_balloon_bad_addr (pa); +memory_region_unref (section.mr);continue ; }
Signature · 1 line
2.11.0
PATCH 40/113 multiboot: Reject kernels exceeding the address space
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
The code path where mh_load_end_addr is non-zero in the Multiboot header checks that mh_load_end_addr >= mh_load_addr and so mb_load_size is checked. However, mb_load_size is not checked when calculated from the file size, when mh_load_end_addr is 0.
If the kernel binary size is larger than can fit in the address space after load_addr, we ended up with a kernel_size that is smaller than load_size, which means that we read the file into a too small buffer.
Add a check to reject kernel files with such Multiboot headers.
--- hw/i386/multiboot.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/multiboot.c +4 -0
@@ -247,6 +247,10 @@ int load_multiboot(FWCfgState *fw_cfg, } mb_load_size = kernel_file_size - mb_kernel_text_offset; } +if (mb_load_size >UINT32_MAX - mh_load_addr) { +error_report ("kernel does not fit in address space" ); +exit (1 ); + }if (mh_bss_end_addr) {if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) {error_report ("invalid bss_end_addr address" );
Signature · 1 line
2.11.0
PATCH 41/113 multiboot: Check validity of mh_header_addr
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
I couldn't find a case where this prevents something bad from happening that isn't already caught by other checks, but let's err on the safe side and check that mh_header_addr is as expected.
--- hw/i386/multiboot.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/multiboot.c +4 -0
@@ -229,6 +229,10 @@ int load_multiboot(FWCfgState *fw_cfg,error_report ("invalid load_addr address" );exit (1 ); } +if (mh_header_addr - mh_load_addr > i) { +error_report ("invalid header_addr address" ); +exit (1 ); + }uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr);uint32_t mb_load_size =0 ;
Signature · 1 line
2.11.0
PATCH 42/113 tests/multiboot: Test exit code for every qemu run
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
Testing the exit code only once after a whole group of tests has completed is not enough, it catches errors only in the very last qemu invocation. We need to have the check after each qemu run.
The logging and diff with the reference output is still done once per group to keep things more managable. This is not a problem because the log file accumulates the output of all runs.
--- tests/multiboot/run_test.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
tests/multiboot/run_test.sh +12 -12
@@ -38,6 +38,17 @@ run_qemu() { ret=$? cat test.out >> test.log + + debugexit=$((ret & 0x1)) + ret=$((ret >> 1)) + + if [ $debugexit != 1 ]; then + printf %b "\e[31m ?? \e[0m $kernel $* (no debugexit used, exit code $ret)\n" + pass=0 + elif [ $ret != 0 ]; then + printf %b "\e[31mFAIL\e[0m $kernel $* (exit code $ret)\n" + pass=0 + fi } mmap() {
@@ -61,19 +72,8 @@ make all for t in mmap modules; do echo > test.log - $t - - debugexit=$((ret & 0x1)) - ret=$((ret >> 1)) pass=1 - - if [ $debugexit != 1 ]; then - printf %b "\e[31m ?? \e[0m $t (no debugexit used, exit code $ret)\n" - pass=0 - elif [ $ret != 0 ]; then - printf %b "\e[31mFAIL\e[0m $t (exit code $ret)\n" - pass=0 - fi + $t if ! diff $t.out test.log > /dev/null 2>&1; then printf %b "\e[31mFAIL\e[0m $t (output difference)\n"
Signature · 1 line
2.11.0
PATCH 43/113 tests/multiboot: Add tests for the a.out kludge
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
--- tests/multiboot/Makefile | 22 +++++-- tests/multiboot/aout_kludge.S | 138 ++++++++++++++++++++++++++++++++++++++++ tests/multiboot/aout_kludge.out | 42 ++++++++++++ tests/multiboot/run_test.sh | 10 ++- 4 files changed, 204 insertions(+), 8 deletions(-) create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out
tests/multiboot/Makefile +16 -6
@@ -3,16 +3,26 @@ CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin ASFLAGS=-m32 LD=ld -LDFLAGS=-melf_i386 -T link.ld +LDFLAGS_ELF=-melf_i386 -T link.ld +LDFLAGS_BIN=-melf_i386 -T link.ld --oformat=binary LIBS=$(shell $(CC) $(CCFLAGS) -print-libgcc-file-name) -all: mmap.elf modules.elf +AOUT_KLUDGE_BIN=$(foreach x,$(shell seq 1 9),aout_kludge_$x.bin) -mmap.elf: start.o mmap.o libc.o - $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) +all: mmap.elf modules.elf $(AOUT_KLUDGE_BIN) -modules.elf: start.o modules.o libc.o - $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) +mmap.elf: start.o mmap.o libc.o link.ld + $(LD) $(LDFLAGS_ELF) -o $@ $^ $(LIBS) + +modules.elf: start.o modules.o libc.o link.ld + $(LD) $(LDFLAGS_ELF) -o $@ $^ $(LIBS) + +aout_kludge_%.bin: aout_kludge_%.o link.ld + $(LD) $(LDFLAGS_BIN) -o $@ $^ $(LIBS) + +.PRECIOUS: aout_kludge_%.o +aout_kludge_%.o: aout_kludge.S + $(CC) $(ASFLAGS) -DSCENARIO=$* -c -o $@ $^ %.o: %.c $(CC) $(CCFLAGS) -c -o $@ $^
tests/multiboot/aout_kludge.S new file +138 -0
138 lines not on this page · raw message
tests/multiboot/aout_kludge.out new file +42 -0
42 lines not on this page · raw message
tests/multiboot/run_test.sh +8 -2
@@ -34,7 +34,7 @@ run_qemu() { -device isa-debugcon,chardev=stdio \ -chardev file,path=test.out,id=stdio \ -device isa-debug-exit,iobase=0xf4,iosize=0x4 \ - "$@" + "$@" >> test.log 2>&1 ret=$? cat test.out >> test.log
@@ -67,9 +67,15 @@ modules() { run_qemu modules.elf -initrd "module.txt,module.txt argument,module.txt" } +aout_kludge() { + for i in $(seq 1 9); do + run_qemu aout_kludge_$i.bin + done +} + make all -for t in mmap modules; do +for t in mmap modules aout_kludge; do echo > test.log pass=1
Signature · 1 line
2.11.0
PATCH 44/113 tests/multiboot: Add .gitignore
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
--- tests/multiboot/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/multiboot/.gitignore
tests/multiboot/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +*.bin +*.elf +test.out
Signature · 1 line
2.11.0
PATCH 45/113 arm/translate-a64: treat DISAS_UPDATE as variant of DISAS_EXIT
In reply to Michael RothFrom: Victor Kamensky <[email protected]>
In OE project 4.15 linux kernel boot hang was observed under single cpu aarch64 qemu. Kernel code was in a loop waiting for vtimer arrival, spinning in TC generated blocks, while interrupt was pending unprocessed. This happened because when qemu tried to handle vtimer interrupt target had interrupts disabled, as result flag indicating TCG exit, cpu->icount_decr.u16.high, was cleared but arm_cpu_exec_interrupt function did not call arm_cpu_do_interrupt to process interrupt. Later when target reenabled interrupts, it happened without exit into main loop, so following code that waited for result of interrupt execution run in infinite loop.
To solve the problem instructions that operate on CPU sys state (i.e enable/disable interrupt), and marked as DISAS_UPDATE, should be considered as DISAS_EXIT variant, and should be forced to exit back to main loop so qemu will have a chance processing pending CPU state updates, including pending interrupts.
This change brings consistency with how DISAS_UPDATE is treated in aarch32 case.
Message-id: [email protected]
--- target/arm/translate-a64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/arm/translate-a64.c +3 -3
@@ -11384,12 +11384,12 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)case DISAS_UPDATE :gen_a64_set_pc_im (dc->pc);/* fall through */ -case DISAS_JUMP : -tcg_gen_lookup_and_goto_ptr (); -break ;case DISAS_EXIT :tcg_gen_exit_tb (0 );break ; +case DISAS_JUMP : +tcg_gen_lookup_and_goto_ptr (); +break ;case DISAS_NORETURN :case DISAS_SWI :break ;
Signature · 1 line
2.11.0
PATCH 46/113 virtio_net: flush uncompleted TX on reset
In reply to Michael RothFrom: Greg Kurz <[email protected]>
If the backend could not transmit a packet right away for some reason, the packet is queued for asynchronous sending. The corresponding vq element is tracked in the async_tx.elem field of the VirtIONetQueue, for later freeing when the transmission is complete.
If a reset happens before completion, virtio_net_tx_complete() will push async_tx.elem back to the guest anyway, and we end up with the inuse flag of the vq being equal to -1. The next call to virtqueue_pop() is then likely to fail with "Virtqueue size exceeded".
This can be reproduced easily by starting a guest with an hubport backend that is not connected to a functional network, eg,
-device virtio-net-pci,netdev=hub0 -netdev hubport,id=hub0,hubid=0
and no other -netdev hubport,hubid=0 on the command line.
The appropriate fix is to ensure that such an asynchronous transmission cannot survive a device reset. So for all queues, we first try to send the packet again, and eventually we purge it if the backend still could not deliver it.
--- hw/net/virtio-net.c | 11 +++++++++++ include/net/net.h | 1 + net/net.c | 1 - 3 files changed, 12 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +11 -0
@@ -422,6 +422,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)static void virtio_net_reset (VirtIODevice *vdev) {VirtIONet *n =VIRTIO_NET (vdev); +int i;/* Reset back to compatibility mode */ n->promisc =1 ;
@@ -445,6 +446,16 @@ static void virtio_net_reset(VirtIODevice *vdev)memcpy (&n->mac[0 ], &n->nic->conf->macaddr,sizeof (n->mac));qemu_format_nic_info_str (qemu_get_queue (n->nic), n->mac);memset (n->vlans,0 ,MAX_VLAN >>3 ); + +/* Flush any async TX */ +for (i =0 ; i < n->max_queues; i++) { +NetClientState *nc =qemu_get_subqueue (n->nic, i); + +if (nc->peer) { +qemu_flush_or_purge_queued_packets (nc->peer, true); +assert (!virtio_net_get_subqueue (nc)->async_tx.elem); + } + } }static void peer_test_vnet_hdr (VirtIONet *n)
include/net/net.h +1 -0
@@ -156,6 +156,7 @@ ssize_t qemu_send_packet_async(NetClientState *nc, const uint8_t *buf, int size, NetPacketSent *sent_cb);void qemu_purge_queued_packets (NetClientState *nc);void qemu_flush_queued_packets (NetClientState *nc); +void qemu_flush_or_purge_queued_packets (NetClientState *nc,bool purge);void qemu_format_nic_info_str (NetClientState *nc,uint8_t macaddr[6 ]);bool qemu_has_ufo (NetClientState *nc);bool qemu_has_vnet_hdr (NetClientState *nc);
net/net.c +0 -1
@@ -612,7 +612,6 @@ void qemu_purge_queued_packets(NetClientState *nc)qemu_net_queue_purge (nc->peer->incoming_queue, nc); } -static void qemu_flush_or_purge_queued_packets (NetClientState *nc,bool purge) { nc->receive_disabled =0 ;
Signature · 1 line
2.11.0
PATCH 47/113 qemu-pr-helper: Actually allow users to specify pidfile
In reply to Michael RothFrom: Michal Privoznik <[email protected]>
Due to wrong specification of arguments to getopt_long() any attempt to set pidfile resulted in:
1) the default to be leaked
2) the @pidfile variable to be set to NULL (because optarg is NULL without this patch).
Message-Id: <6f10cd53d361a395aa0e85a9311ec4e9a8fc11e5.1521868451.git.mprivozn@redhat.com>
--- scsi/qemu-pr-helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
scsi/qemu-pr-helper.c +4 -3
@@ -903,12 +903,12 @@ static int drop_privileges(void)int main (int argc,char **argv) { -const char *sopt ="hVk:fdT:u:g:vq" ; +const char *sopt ="hVk:f:dT:u:g:vq" ;struct option lopt[] = { {"help" , no_argument,NULL ,'h' }, {"version" , no_argument,NULL ,'V' }, {"socket" , required_argument,NULL ,'k' }, - {"pidfile" , no_argument,NULL ,'f' }, + {"pidfile" , required_argument,NULL ,'f' }, {"daemon" , no_argument,NULL ,'d' }, {"trace" , required_argument,NULL ,'T' }, {"user" , required_argument,NULL ,'u' },
@@ -952,7 +952,8 @@ int main(int argc, char **argv) }break ;case 'f' : - pidfile = optarg; +g_free (pidfile); + pidfile =g_strdup (optarg);break ;#ifdef CONFIG_LIBCAP case 'u' : {
Signature · 1 line
2.11.0
PATCH 49/113 iotests: Test preallocated truncate of 2G image
In reply to Michael RothFrom: Max Reitz <[email protected]>
Message-id: [email protected]
--- tests/qemu-iotests/106 | 24 ++++++++++++++++++++++++ tests/qemu-iotests/106.out | 10 ++++++++++ 2 files changed, 34 insertions(+)
tests/qemu-iotests/106 +24 -0
@@ -86,6 +86,30 @@ for growth_mode in falloc full off; do $QEMU_IMG resize -f "$IMGFMT" --shrink --preallocation=$growth_mode "$TEST_IMG" -${GROWTH_SIZE}K done +echo +echo '=== Testing image growth on 2G empty image ===' + +for growth_mode in falloc full; do + echo + echo "--- growth_mode=$growth_mode ---" + + # Maybe we want to do an lseek() to the end of the file before the + # preallocation; if the file has a length of 2 GB, that would + # return an integer that overflows to negative when put into a + # plain int. We should use the correct type for the result, and + # this tests we do. + + _make_test_img 2G + $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K + + actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size') + actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/') + + if [ $actual_size -lt $GROWTH_SIZE ]; then + echo "ERROR: Image should have at least ${GROWTH_SIZE}K, but has ${actual_size}K" + fi +done + # success, all done echo '*** done' rm -f $seq.full
tests/qemu-iotests/106.out +10 -0
@@ -47,4 +47,14 @@ qemu-img: Preallocation can only be used for growing images --- growth_mode=off --- Image resized. + +=== Testing image growth on 2G empty image === + +--- growth_mode=falloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 +Image resized. + +--- growth_mode=full --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 +Image resized. *** done
Signature · 1 line
2.11.0
PATCH 48/113 block/file-posix: Fix fully preallocated truncate
In reply to Michael RothFrom: Max Reitz <[email protected]>
Storing the lseek() result in an int results in it overflowing when the file is at least 2 GB big. Then, we have a 50 % chance of the result being "negative" and thus thinking an error occurred when actually everything went just fine.
So we should use the correct type for storing the result: off_t.
Message-id: [email protected]
--- block/file-posix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
block/file-posix.c +3 -2
@@ -1694,6 +1694,7 @@ static int raw_regular_truncate(int fd, int64_t offset, PreallocMode prealloc,case PREALLOC_MODE_FULL : {int64_t num =0 , left = offset - current_length; +off_t seek_result;/* * Knowing the final size from the beginning could allow the file
@@ -1708,8 +1709,8 @@ static int raw_regular_truncate(int fd, int64_t offset, PreallocMode prealloc, buf =g_malloc0 (65536 ); - result =lseek (fd, current_length,SEEK_SET ); -if (result <0 ) { + seek_result =lseek (fd, current_length,SEEK_SET ); +if (seek_result <0 ) { result = -errno;error_setg_errno (errp, -result,"Failed to seek to the old end of file" );
Signature · 1 line
2.11.0
PATCH 50/113 tcg: Mark muluh_i64 and mulsh_i64 as 64-bit ops
In reply to Michael RothFrom: Richard Henderson <[email protected]>
Failure to do so results in the tcg optimizer sign-extending any constant fold from 32-bits. This turns out to be visible in the RISC-V testsuite using a host that emits these opcodes (e.g. any non-x86_64).
--- tcg/tcg-opc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tcg/tcg-opc.h +2 -2
@@ -182,8 +182,8 @@ DEF(add2_i64, 2, 4, 0, IMPL64 | IMPL(TCG_TARGET_HAS_add2_i64)) DEF(sub2_i64, 2, 4, 0, IMPL64 | IMPL(TCG_TARGET_HAS_sub2_i64)) DEF(mulu2_i64, 2, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_mulu2_i64)) DEF(muls2_i64, 2, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_muls2_i64)) -DEF(muluh_i64, 1, 2, 0, IMPL(TCG_TARGET_HAS_muluh_i64)) -DEF(mulsh_i64, 1, 2, 0, IMPL(TCG_TARGET_HAS_mulsh_i64)) +DEF(muluh_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_muluh_i64)) +DEF(mulsh_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_mulsh_i64))#define TLADDR_ARGS (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? 1 : 2)#define DATA64_ARGS (TCG_TARGET_REG_BITS == 64 ? 1 : 2)
Signature · 1 line
2.11.0
PATCH 4/113 memfd: fix configure test
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Recent glibc added memfd_create in sys/mman.h. This conflicts with the definition in util/memfd.c:
/builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration
Fix the configure test, and remove the sys/memfd.h inclusion since the file actually does not exist---it is a typo in the memfd_create(2) man page.
--- configure | 2 +- util/memfd.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-)
configure +1 -1
@@ -3920,7 +3920,7 @@ fi # check if memfd is supported memfd=no cat > $TMPC << EOF -#include <sys/memfd.h> +#include <sys/mman.h> int main(void) {
util/memfd.c +1 -3
@@ -31,9 +31,7 @@#include "qemu/memfd.h" -#ifdef CONFIG_MEMFD -#include <sys/memfd.h> -#elif definedCONFIG_LINUX +#if definedCONFIG_LINUX && !definedCONFIG_MEMFD #include <sys/syscall.h> #include <asm/unistd.h>
Signature · 1 line
2.11.0
PATCH 51/113 target/i386: Fix andn instruction
In reply to Michael RothFrom: Alexandro Sanchez Bach <[email protected]>
In commit 7073fbada733c8d10992f00772c9b9299d740e9b, the andn instruction was implemented via tcg_gen_andc but passes the operands in the wrong order:
- X86 defines andn dest,src1,src2 as: dest = ~src1 & src2
- TCG defines andc dest,src1,src2 as: dest = src1 & ~src2
The following simple test shows the issue:
#include <stdio.h>
#include <stdint.h>
int main(void) {
uint32_t ret = 0;
__asm (
"mov $0xFF00, %%ecx\n"
"mov $0x0F0F, %%eax\n"
"andn %%ecx, %%eax, %%ecx\n"
"mov %%ecx, %0\n"
: "=r" (ret));
printf("%08X\n", ret);
return 0;
}This patch fixes the problem by simply swapping the order of the two last arguments in tcg_gen_andc_tl.
--- target/i386/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/translate.c +1 -1
@@ -3803,7 +3803,7 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, } ot =mo_64_32 (s->dflag);gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,0 ); -tcg_gen_andc_tl (cpu_T0, cpu_regs[s->vex_v], cpu_T0); +tcg_gen_andc_tl (cpu_T0, cpu_T0, cpu_regs[s->vex_v]);gen_op_mov_reg_v (ot, reg, cpu_T0);gen_op_update1_cc ();set_cc_op (s,CC_OP_LOGICB + ot);
Signature · 1 line
2.11.0
PATCH 52/113 exec: fix memory leak in find_max_supported_pagesize()
In reply to Michael RothFrom: Greg Kurz <[email protected]>
The string returned by object_property_get_str() is dynamically allocated.
Message-Id: <[email protected]>
--- exec.c | 1 + 1 file changed, 1 insertion(+)
exec.c +1 -0
@@ -1455,6 +1455,7 @@ static int find_max_supported_pagesize(Object *obj, void *opaque) mem_path =object_property_get_str (obj,"mem-path" ,NULL );if (mem_path) {long hpsize =qemu_mempath_getpagesize (mem_path); +g_free (mem_path);if (hpsize < *hpsize_min) { *hpsize_min = hpsize; }
Signature · 1 line
2.11.0
PATCH 53/113 gluster: Fix blockdev-add with server.N.type=unix
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.
Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.
https://bugzilla.redhat.com/show_bug.cgi?id=1545155
Message-id: [email protected]
--- block/gluster.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
block/gluster.c +17 -4
@@ -164,7 +164,12 @@ static QemuOptsList runtime_unix_opts = { { .name = GLUSTER_OPT_SOCKET, .type = QEMU_OPT_STRING, - .help = "socket file path)", + .help = "socket file path (legacy)", + }, + { + .name = GLUSTER_OPT_PATH, + .type = QEMU_OPT_STRING, + .help = "socket file path (QAPI)", }, {/* end of list */ } },
@@ -612,10 +617,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, goto out; } - ptr =qemu_opt_get (opts,GLUSTER_OPT_SOCKET ); + ptr =qemu_opt_get (opts,GLUSTER_OPT_PATH ); +if (!ptr) { + ptr =qemu_opt_get (opts,GLUSTER_OPT_SOCKET ); + }else if (qemu_opt_get (opts,GLUSTER_OPT_SOCKET )) { +error_setg (&local_err, +"Conflicting parameters 'path' and 'socket'" ); +error_append_hint (&local_err,GERR_INDEX_HINT , i); + goto out; + }if (!ptr) {error_setg (&local_err,QERR_MISSING_PARAMETER , -GLUSTER_OPT_SOCKET ); +GLUSTER_OPT_PATH );error_append_hint (&local_err,GERR_INDEX_HINT , i); goto out; }
@@ -680,7 +693,7 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,"file.server.0.host=1.2.3.4," "file.server.0.port=24007," "file.server.1.transport=unix," -"file.server.1.socket=/var/run/glusterd.socket ..." +"file.server.1.path=/var/run/glusterd.socket ..." "\n"); errno = -ret;return NULL ;
Signature · 1 line
2.11.0
PATCH 54/113 cpus.c: ensure running CPU recalculates icount deadlines on timer expiry
In reply to Michael RothFrom: Peter Maydell <[email protected]>
When we run in TCG icount mode, we calculate the number of instructions to execute using tcg_get_icount_limit(), which ensures that we stop execution at the next timer deadline. However there is a bug where currently we do not recalculate that limit if the guest reprograms a timer so that the next deadline moves closer, and so we will continue execution until the original limit and fire the timer later than we should.
Fix this bug in qemu_timer_notify_cb(): if we are currently running a VCPU in icount mode, we simply need to kick it out of the main loop and back to tcg_cpu_exec(), where it will recalculate the icount limit. If we are not currently running a VCPU, then we retain the existing logic for waking up a halted CPU.
Message-id: [email protected]
--- cpus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
cpus.c +9 -1
@@ -843,11 +843,19 @@ void qemu_timer_notify_cb(void *opaque, QEMUClockType type)return ; } -if (!qemu_in_vcpu_thread () && first_cpu) { +if (qemu_in_vcpu_thread ()) { +/* A CPU is currently running; kick it back out to the +* tcg_cpu_exec() loop so it will recalculate its +* icount deadline immediately. +*/ +qemu_cpu_kick (current_cpu); + }else if (first_cpu) {/* qemu_cpu_kick is not enough to kick a halted CPU out of * qemu_tcg_wait_io_event. async_run_on_cpu, instead, * causes cpu_thread_is_idle to return false. This way, * handle_icount_deadline can run. +* If we have no CPUs at all for some reason, we don't +* need to do anything. */ async_run_on_cpu (first_cpu, do_nothing,RUN_ON_CPU_NULL ); }
Signature · 1 line
2.11.0
PATCH 56/113 hw/block/pflash_cfi: fix off-by-one error
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
ASAN reported:
hw/block/pflash_cfi02.c:245:33: runtime error: index 82 out of bounds for type 'uint8_t [82]'
Since the 'cfi_len' member is not used, remove it to keep the code safer.
--- hw/block/pflash_cfi01.c | 10 ++++------ hw/block/pflash_cfi02.c | 9 ++++----- 2 files changed, 8 insertions(+), 11 deletions(-)
hw/block/pflash_cfi01.c +4 -6
@@ -90,7 +90,6 @@ struct pflash_t {uint16_t ident1;uint16_t ident2;uint16_t ident3; -uint8_t cfi_len;uint8_t cfi_table[0x52 ];uint64_t counter;unsigned int writeblock_size;
@@ -153,7 +152,7 @@ static uint32_t pflash_cfi_query(pflash_t *pfl, hwaddr offset) boff = offset >> (ctz32 (pfl->bank_width) +ctz32 (pfl->max_device_width) -ctz32 (pfl->device_width)); -if (boff > pfl->cfi_len) { +if (boff >=sizeof (pfl->cfi_table)) {return 0 ; }/* Now we will construct the CFI response generated by a single
@@ -385,10 +384,10 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, boff = boff >>2 ; } -if (boff > pfl->cfi_len) { - ret =0 ; - }else { +if (boff <sizeof (pfl->cfi_table)) { ret = pfl->cfi_table[boff]; + }else { + ret =0 ; } }else {/* If we have a read larger than the bank_width, combine multiple
@@ -791,7 +790,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) pfl->cmd =0 ; pfl->status =0 ;/* Hardcoded CFI table */ - pfl->cfi_len =0x52 ;/* Standard "QRY" string */ pfl->cfi_table[0x10 ] ='Q' ; pfl->cfi_table[0x11 ] ='R' ;
hw/block/pflash_cfi02.c +4 -5
@@ -83,7 +83,6 @@ struct pflash_t {uint16_t ident3;uint16_t unlock_addr0;uint16_t unlock_addr1; -uint8_t cfi_len;uint8_t cfi_table[0x52 ];QEMUTimer *timer;/* The device replicates the flash memory across its memory space. Emulate
@@ -235,10 +234,11 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset,break ;case 0x98 :/* CFI query mode */ -if (boff > pfl->cfi_len) - ret =0 ; -else +if (boff <sizeof (pfl->cfi_table)) { ret = pfl->cfi_table[boff]; + }else { + ret =0 ; + }break ; }
@@ -663,7 +663,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp) pfl->cmd =0 ; pfl->status =0 ;/* Hardcoded CFI table (mostly from SG29 Spansion flash) */ - pfl->cfi_len =0x52 ;/* Standard "QRY" string */ pfl->cfi_table[0x10 ] ='Q' ; pfl->cfi_table[0x11 ] ='R' ;
Signature · 1 line
2.11.0
PATCH 55/113 vfio-ccw: fix memory leaks in vfio_ccw_realize()
In reply to Michael RothFrom: Greg Kurz <[email protected]>
If the subchannel is already attached or if vfio_get_device() fails, the code jumps to the 'out_device_err' label and doesn't free the string it has just allocated.
The code should be reworked so that vcdev->vdev.name only gets set when the device has been attached, and freed when it is about to be detached. This could be achieved with the addition of a vfio_ccw_get_device() function that would be the counterpart of vfio_put_device(). But this is a more elaborate cleanup that should be done in a follow-up. For now, let's just add calls to g_free() on the buggy error paths.
Message-Id: <152311222681.203086.8874800175539040298.stgit@bahia>
--- hw/vfio/ccw.c | 2 ++ 1 file changed, 2 insertions(+)
hw/vfio/ccw.c +2 -0
@@ -357,11 +357,13 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)if (strcmp (vbasedev->name, vcdev->vdev.name) ==0 ) {error_setg (&err,"vfio: subchannel %s has already been attached" , vcdev->vdev.name); +g_free (vcdev->vdev.name); goto out_device_err; } }if (vfio_get_device (group, cdev->mdevid, &vcdev->vdev, &err)) { +g_free (vcdev->vdev.name); goto out_device_err; }
Signature · 1 line
2.11.0
PATCH 57/113 tcg: Introduce tcg_set_insn_start_param
In reply to Michael RothFrom: Richard Henderson <[email protected]>
The parameters for tcg_gen_insn_start are target_ulong, which may be split into two TCGArg parameters for storage in the opcode on 32-bit hosts.
Fixes the ARM target and its direct use of tcg_set_insn_param, which would set the wrong argument in the 64-on-32 case.
Message-id: [email protected]
Conflicts:
target/arm/translate.h
tcg/tcg.h
* rework to avoid functional dependency on 15fa08f
--- target/arm/translate.h | 2 +- tcg/tcg.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
target/arm/translate.h +1 -1
@@ -118,7 +118,7 @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)/* We check and clear insn_start_idx to catch multiple updates. */ assert (s->insn_start_idx !=0 ); -tcg_set_insn_param (s->insn_start_idx,2 , syn); +tcg_set_insn_start_param (s->insn_start_idx,2 , syn); s->insn_start_idx =0 ; }
tcg/tcg.h +10 -0
@@ -783,6 +783,16 @@ static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) tcg_ctx->gen_op_buf[op_idx].args[arg] = v; } +static inline void tcg_set_insn_start_param (int op_idx,int arg,target_ulong v) +{ +#if TARGET_LONG_BITS <=TCG_TARGET_REG_BITS +tcg_set_insn_param (op_idx, arg, v); +#else +tcg_set_insn_param (op_idx, arg *2 , v); +tcg_set_insn_param (op_idx, arg *2 +1 , v >>32 ); +#endif +} +/* The number of opcodes emitted so far. */ static inline int tcg_op_buf_count (void ) {
Signature · 1 line
2.11.0
PATCH 59/113 device_tree: Increase FDT_MAX_SIZE to 1 MiB
In reply to Michael RothFrom: Geert Uytterhoeven <[email protected]>
It is not uncommon for a contemporary FDT to be larger than 64 KiB, leading to failures loading the device tree from sysfs:
qemu-system-aarch64: qemu_fdt_setprop: Couldn't set ...: FDT_ERR_NOSPACE
Hence increase the limit to 1 MiB, like on PPC.
For reference, the largest arm64 DTB created from the Linux sources is ca. 75 KiB large (100 KiB when built with symbols/fixup support).
Message-id: [email protected]
--- device_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
device_tree.c +1 -1
@@ -29,7 +29,7 @@#include <libfdt.h> -#define FDT_MAX_SIZE 0x10000 +#define FDT_MAX_SIZE 0x100000void *create_device_tree (int *sizep) {
Signature · 1 line
2.11.0
PATCH 58/113 hw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes
In reply to Michael RothFrom: Peter Maydell <[email protected]>
The CMSDK APB UART INTSTATUS register bits are all write-one-to-clear. We were getting this correct for the TXO and RXO bits (which need special casing because their state lives in the STATE register), but had forgotten to handle the normal bits for RX and TX which we do store in our s->intstatus field.
Perform the W1C operation on the bits in s->intstatus too.
Message-id: [email protected]
--- hw/char/cmsdk-apb-uart.c | 1 + 1 file changed, 1 insertion(+)
hw/char/cmsdk-apb-uart.c +1 -0
@@ -274,6 +274,7 @@ static void uart_write(void *opaque, hwaddr offset, uint64_t value,* is then reflected into the intstatus value by the update function). */ s->state &= ~(value & (R_INTSTATUS_TXO_MASK |R_INTSTATUS_RXO_MASK )); + s->intstatus &= ~value;cmsdk_apb_uart_update (s);break ;case A_BAUDDIV :
Signature · 1 line
2.11.0
PATCH 60/113 ccid: Fix dwProtocols advertisement of T=0
In reply to Michael RothFrom: Jason Andryuk <[email protected]>
Commit d7d218ef02d87c637d20d64da8f575d434ff6f78 attempted to change dwProtocols to only advertise support for T=0 and not T=1. The change was incorrect as it changed 0x00000003 to 0x00010000.
lsusb -v in a linux guest shows:
"dwProtocols 65536 (Invalid values detected)", though the
smart card could still be accessed. Windows 7 does not detect inserted smart cards and logs the the following Error in the Event Logs:
Source: Smart Card Service
Event ID: 610
Smart Card Reader 'QEMU QEMU USB CCID 0' rejected IOCTL SET_PROTOCOL:
Incorrect function. If this error persists, your smart card or reader may not be functioning correctly
Command Header: 03 00 00 00
Setting to 0x00000001 fixes the Windows issue.
Message-id: [email protected]
--- hw/usb/dev-smartcard-reader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/dev-smartcard-reader.c +2 -2
@@ -329,8 +329,8 @@ static const uint8_t qemu_ccid_descriptor[] = {*/ 0x07 ,/* u8 bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 - 1.8 */ -0x00 ,0x00 ,/* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/ -0x01 ,0x00 ,/* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */ +0x01 ,0x00 ,/* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/ +0x00 ,0x00 ,/* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */ /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */ 0xa0 ,0x0f ,0x00 ,0x00 , /* u32 dwMaximumClock; */
Signature · 1 line
2.11.0
PATCH 5/113 sdl: workaround bug in sdl 2.0.8 headers
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892087
Message-id: [email protected]
--- configure | 1 + 1 file changed, 1 insertion(+)
configure +1 -0
@@ -2788,6 +2788,7 @@ if test "$sdl" != "no" ; then int main( void ) { return SDL_Init (SDL_INIT_VIDEO); } EOF sdl_cflags=$($sdlconfig --cflags 2>/dev/null) + sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug if test "$static" = "yes" ; then if $pkg_config $sdlname --exists; then sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
Signature · 1 line
2.11.0
PATCH 61/113 nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE
In reply to Michael RothFrom: Eric Blake <[email protected]>
A missing space makes for poor error messages, and sizes can't go negative. Also, we missed diagnosing a server that sends a maximum block size less than the minimum.
Message-Id: <[email protected]>
--- nbd/client.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
nbd/client.c +10 -4
@@ -435,8 +435,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname, }be32_to_cpus (&info->min_block);if (!is_power_of_2 (info->min_block)) { -error_setg (errp,"server minimum block size %" PRId32 -"is not a power of two" , info->min_block); +error_setg (errp,"server minimum block size %" PRIu32 +" is not a power of two" , info->min_block);nbd_send_opt_abort (ioc);return -1 ; }
@@ -450,8 +450,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,be32_to_cpus (&info->opt_block);if (!is_power_of_2 (info->opt_block) || info->opt_block < info->min_block) { -error_setg (errp,"server preferred block size %" PRId32 -"is not valid" , info->opt_block); +error_setg (errp,"server preferred block size %" PRIu32 +" is not valid" , info->opt_block);nbd_send_opt_abort (ioc);return -1 ; }
@@ -462,6 +462,12 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname,return -1 ; }be32_to_cpus (&info->max_block); +if (info->max_block < info->min_block) { +error_setg (errp,"server maximum block size %" PRIu32 +" is not valid" , info->max_block); +nbd_send_opt_abort (ioc); +return -1 ; + }trace_nbd_opt_go_info_block_size (info->min_block, info->opt_block, info->max_block);break ;
Signature · 1 line
2.11.0
PATCH 62/113 s390: Do not pass inofficial IPL type to the guest
In reply to Michael RothFrom: Viktor Mihajlovski <[email protected]>
IPL over a virtio-scsi device requires special handling not available in the real architecture. For this purpose the IPL type 0xFF has been chosen as means of communication between QEMU and the pc-bios. However, a guest OS could be confused by seeing an unknown IPL type.
This change sets the IPL parameter type to 0x02 (CCW) to prevent this. Pre-existing Linux has looked up the IPL parameters only in the case of FCP IPL. This means that the behavior should stay the same even if Linux checks for the IPL type unconditionally.
Message-Id: <[email protected]>
--- pc-bios/s390-ccw/bootmap.c | 7 +++++++ pc-bios/s390-ccw/iplb.h | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/bootmap.c +7 -0
@@ -50,6 +50,13 @@ static void jump_to_IPL_code(uint64_t address) {/* store the subsystem information _after_ the bootmap was loaded */ write_subsystem_identification (); + +/* prevent unknown IPL types in the guest */ +if (iplb.pbt ==S390_IPL_TYPE_QEMU_SCSI ) { + iplb.pbt =S390_IPL_TYPE_CCW ; +set_iplb (&iplb); + } +/* * The IPL PSW is at address 0. We also must not overwrite the * content of non-BIOS memory after we loaded the guest, so we
pc-bios/s390-ccw/iplb.h +13 -2
@@ -77,16 +77,27 @@ extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));#define S390_IPL_TYPE_CCW 0x02#define S390_IPL_TYPE_QEMU_SCSI 0xff -static inline bool store_iplb (IplParameterBlock *iplb) +static inline bool manage_iplb (IplParameterBlock *iplb,bool store) { register unsigned long addr asm("0") = (unsigned long) iplb; register unsigned long rc asm("1") = 0; asmvolatile ("diag %0,%2,0x308\n" :"+d" (addr),"+d" (rc) - :"d" (6 ) + :"d" (store ?6 :5 ) :"memory" ,"cc" );return rc ==0x01 ; } + +static inline bool store_iplb (IplParameterBlock *iplb) +{ +return manage_iplb (iplb, true); +} + +static inline bool set_iplb (IplParameterBlock *iplb) +{ +return manage_iplb (iplb, false); +} +#endif /* IPLB_H */
Signature · 1 line
2.11.0
PATCH 63/113 s390-ccw: force diag 308 subcode to unsigned long
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
We currently pass an integer as the subcode parameter. However, the upper bits of the register containing the subcode need to be 0, which is not guaranteed unless we explicitly specify the subcode to be an unsigned long value.
--- pc-bios/s390-ccw/iplb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
pc-bios/s390-ccw/iplb.h +2 -1
@@ -81,10 +81,11 @@ static inline bool manage_iplb(IplParameterBlock *iplb, bool store) { register unsigned long addr asm("0") = (unsigned long) iplb; register unsigned long rc asm("1") = 0; +unsigned long subcode = store ?6 :5 ; asmvolatile ("diag %0,%2,0x308\n" :"+d" (addr),"+d" (rc) - :"d" (store ?6 :5 ) + :"d" (subcode) :"memory" ,"cc" );return rc ==0x01 ; }
Signature · 1 line
2.11.0
PATCH 64/113 tcg/arm: Fix memory barrier encoding
In reply to Michael RothFrom: Henry Wertz <[email protected]>
I found with qemu 2.11.x or newer that I would get an illegal instruction error running some Intel binaries on my ARM chromebook. On investigation, I found it was quitting on memory barriers.
qemu instruction:
mb $0x31
was translating as:0x604050cc: 5bf07ff5 blpl #0x600250a8
After patch it gives:0x604050cc: f57ff05b dmb ish
In short, I found INSN_DMB_ISH (memory barrier for ARMv7) appeared to be correct based on online docs, but due to some endian-related shenanigans it had to be byte-swapped to suit qemu; it appears INSN_DMB_MCR (memory barrier for ARMv6) also should be byte swapped (and this patch does so). I have not checked for correctness of aarch64's barrier instruction.
--- tcg/arm/tcg-target.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tcg/arm/tcg-target.inc.c +2 -2
@@ -159,8 +159,8 @@ typedef enum {INSN_STRD_IMM =0x004000f0 ,INSN_STRD_REG =0x000000f0 , -INSN_DMB_ISH =0x5bf07ff5 , -INSN_DMB_MCR =0xba0f07ee , +INSN_DMB_ISH =0xf57ff05b , +INSN_DMB_MCR =0xee070fba ,/* Architected nop introduced in v6k. */ /* ??? This is an MSR (imm) 0,0,0 insn. Anyone know if this
Signature · 1 line
2.11.0
PATCH 65/113 target/arm: Implement v8M VLLDM and VLSTM
In reply to Michael RothFrom: Peter Maydell <[email protected]>
For v8M the instructions VLLDM and VLSTM support lazy saving and restoring of the secure floating-point registers. Even if the floating point extension is not implemented, these instructions must act as NOPs in Secure state, so they can be used as part of the secure-to-nonsecure call sequence.
Message-id: [email protected]
--- target/arm/translate.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
target/arm/translate.c +16 -1
@@ -10511,8 +10511,23 @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn)/* Coprocessor. */ if (arm_dc_feature (s,ARM_FEATURE_M )) {/* We don't currently implement M profile FP support, -* so this entire space should give a NOCP fault. +* so this entire space should give a NOCP fault, with +* the exception of the v8M VLLDM and VLSTM insns, which +* must be NOPs in Secure state and UNDEF in Nonsecure state. */ +if (arm_dc_feature (s,ARM_FEATURE_V8 ) && + (insn &0xffa00f00 ) ==0xec200a00 ) { +/* 0b1110_1100_0x1x_xxxx_xxxx_1010_xxxx_xxxx +* - VLLDM, VLSTM +* We choose to UNDEF if the RAZ bits are non-zero. +*/ +if (!s->v8m_secure || (insn &0x0040f0ff )) { + goto illegal_op; + } +/* Just NOP since FP support is not implemented */ +break ; + } +/* All other insns: NOCP */ gen_exception_insn (s,4 ,EXCP_NOCP ,syn_uncategorized (),default_exception_el (s));break ;
Signature · 1 line
2.11.0
PATCH 66/113 target/ppc: always set PPC_MEM_TLBIE in pre 2.8 migration hack
In reply to Michael RothFrom: Greg Kurz <[email protected]>
The pseries-2.7 and older machine types require CPUPPCState::insns_flags to be strictly equal between source and destination. This checking is abusive and breaks migration of KVM guests when the host CPU models are different, even if they are compatible enough to allow the guest to run transparently. This buggy behaviour was fixed for pseries-2.8 and we added some hacks to allow backward migration of older machine types. These hacks assume that the CPU belongs to the POWER8 family, which was true for most KVM based setup we cared about at the time. But now POWER9 systems are coming, and backward migration of pre 2.8 guests running in POWER8 architected mode from a POWER9 host to a POWER8 host is broken:
qemu-system-ppc64: error while loading state for instance 0x0 of device
'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument
This happens because POWER9 doesn't set PPC_MEM_TLBIE in insns_flags, while POWER8 does. Let's force PPC_MEM_TLBIE in the migration hack to fix the issue. This is an acceptable hack because these old machine types only support CPU models that do set PPC_MEM_TLBIE.
--- target/ppc/machine.c | 5 +++++ 1 file changed, 5 insertions(+)
target/ppc/machine.c +5 -0
@@ -192,6 +192,11 @@ static int cpu_pre_save(void *opaque)if (cpu->pre_2_8_migration) { cpu->mig_msr_mask = env->msr_mask; cpu->mig_insns_flags = env->insns_flags & insns_compat_mask; +/* CPU models supported by old machines all have PPC_MEM_TLBIE, +* so we set it unconditionally to allow backward migration from +* a POWER9 host to a POWER8 host. +*/ + cpu->mig_insns_flags |=PPC_MEM_TLBIE ; cpu->mig_insns_flags2 = env->insns_flags2 & insns_compat_mask2; cpu->mig_nb_BATs = env->nb_BATs; }
Signature · 1 line
2.11.0
PATCH 67/113 spapr: don't advertise radix GTSE if max-compat-cpu < power9
In reply to Michael RothFrom: Greg Kurz <[email protected]>
On a POWER9 host, if a guest runs in pre POWER9 compat mode, it necessarily uses the hash MMU mode. In this case, we shouldn't advertise radix GTSE in the ibm,arch-vec-5-platform-support DT property as the current code does. The first reason is that it doesn't make sense, and the second one is that causes the CAS-negotiated options subsection to be migrated. This breaks backward migration to QEMU 2.7 and older versions on POWER8 hosts:
qemu-system-ppc64: error while loading state for instance 0x0 of device
'spapr'
qemu-system-ppc64: load of migration failed: No such file or directory
This patch hence initialize CPUs a bit earlier so that we can check the requested compat mode, and don't set OV5_MMU_RADIX_GTSE for power8 and older.
--- hw/ppc/spapr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
hw/ppc/spapr.c +10 -5
@@ -2356,6 +2356,7 @@ static void ppc_spapr_init(MachineState *machine)long load_limit, fw_size;char *filename;Error *resize_hpt_err =NULL ; +PowerPCCPU *first_ppc_cpu; msi_nonbroken = true;
@@ -2448,11 +2449,6 @@ static void ppc_spapr_init(MachineState *machine) }spapr_ovec_set (spapr->ov5,OV5_FORM1_AFFINITY ); -if (!kvm_enabled () ||kvmppc_has_cap_mmu_radix ()) { -/* KVM and TCG always allow GTSE with radix... */ -spapr_ovec_set (spapr->ov5,OV5_MMU_RADIX_GTSE ); - } -/* ... but not with hash (currently). */ /* advertise support for dedicated HP event source to guests */ if (spapr->use_hotplug_event_source) {
@@ -2469,6 +2465,15 @@ static void ppc_spapr_init(MachineState *machine)spapr_init_cpus (spapr); + first_ppc_cpu =POWERPC_CPU (first_cpu); +if ((!kvm_enabled () ||kvmppc_has_cap_mmu_radix ()) && +ppc_check_compat (first_ppc_cpu,CPU_POWERPC_LOGICAL_3_00 ,0 , + spapr->max_compat_pvr)) { +/* KVM and TCG always allow GTSE with radix... */ +spapr_ovec_set (spapr->ov5,OV5_MMU_RADIX_GTSE ); + } +/* ... but not with hash (currently). */ +if (kvm_enabled ()) {/* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */ kvmppc_enable_logical_ci_hcalls ();
Signature · 1 line
2.11.0
PATCH 68/113 qxl: fix local renderer crash
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
Make sure we only ask the spice local renderer for display updates in case we have a valid primary surface. Without that spice is confused and throws errors in case a display update request (triggered by screendump for example) happens in parallel to a mode switch and hits the race window where the old primary surface is gone and the new isn't establisted yet.
Message-id: [email protected]
--- hw/display/qxl-render.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/display/qxl-render.c +2 -1
@@ -169,7 +169,8 @@ void qxl_render_update(PCIQXLDevice *qxl)qemu_mutex_lock (&qxl->ssd.lock); -if (!runstate_is_running () || !qxl->guest_primary.commands) { +if (!runstate_is_running () || !qxl->guest_primary.commands || + qxl->mode ==QXL_MODE_UNDEFINED ) {qxl_render_update_area_unlocked (qxl);qemu_mutex_unlock (&qxl->ssd.lock);return ;
Signature · 1 line
2.11.0
PATCH 69/113 configure: recognize more rpmbuild macros
In reply to Michael RothFrom: Olaf Hering <[email protected]>
Extend the list of recognized, but ignored options from rpms %configure macro. This fixes build on hosts running SUSE Linux.
Message-Id: <[email protected]>
--- configure | 2 ++ 1 file changed, 2 insertions(+)
configure +2 -0
@@ -930,6 +930,8 @@ for opt do ;; --firmwarepath=*) firmwarepath="$optarg" ;; + --host=*|--build=*|\ + --disable-dependency-tracking|\ --sbindir=*|--sharedstatedir=*|\ --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\ --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
Signature · 1 line
2.11.0
PATCH 70/113 qemu-img: Resolve relative backing paths in rebase
In reply to Michael RothFrom: Max Reitz <[email protected]>
Currently, rebase interprets a relative path for the new backing image as follows:
(1) Open the new backing image with the given relative path (thus relative to qemu-img's working directory).
(2) Write it directly into the overlay's backing path field (thus relative to the overlay).
If the overlay is not in qemu-img's working directory, both will be different interpretations, which may either lead to an error somewhere (either rebase fails because it cannot open the new backing image, or your overlay becomes unusable because its backing path does not point to a file), or, even worse, it may result in your rebase being performed for a different backing file than what your overlay will point to after the rebase.
Fix this by interpreting the target backing path as relative to the overlay, like qemu-img does everywhere else.
Message-id: [email protected]
--- qemu-img.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
qemu-img.c +22 -1
@@ -3190,6 +3190,9 @@ static int img_rebase(int argc, char **argv) }if (out_baseimg[0 ]) { +const char *overlay_filename; +char *out_real_path; + options =qdict_new ();if (out_basefmt) {qdict_put_str (options,"driver" , out_basefmt);
@@ -3198,8 +3201,26 @@ static int img_rebase(int argc, char **argv)qdict_put_bool (options,BDRV_OPT_FORCE_SHARE , true); } - blk_new_backing =blk_new_open (out_baseimg,NULL , + overlay_filename = bs->exact_filename[0 ] ? bs->exact_filename + : bs->filename; + out_real_path =g_malloc (PATH_MAX ); + +bdrv_get_full_backing_filename_from_filename (overlay_filename, + out_baseimg, + out_real_path, +PATH_MAX , + &local_err); +if (local_err) { +error_reportf_err (local_err, +"Could not resolve backing filename: " ); + ret =-1 ; +g_free (out_real_path); + goto out; + } + + blk_new_backing =blk_new_open (out_real_path,NULL , options, src_flags, &local_err); +g_free (out_real_path);if (!blk_new_backing) { error_reportf_err(local_err, "Could not open new backing file '%s': ",
Signature · 1 line
2.11.0
PATCH 6/113 spapr: Allow some cases where we can't set VSMT mode in the kernel
In reply to Michael RothFrom: David Gibson <[email protected]>
At present if we require a vsmt mode that's not equal to the kernel's default, and the kernel doesn't let us change it (e.g. because it's an old kernel without support) then we always fail.
But in fact we can cope with the kernel having a different vsmt as long as
a) it's >= the actual number of vthreads/vcore (so that guest threads that are supposed to be on the same core act like it)
b) it's a submultiple of the requested vsmt mode (so that guest threads spaced by the vsmt value will act like they're on different cores)
Allowing this case gives us a bit more freedom to adjust the vsmt behaviour without breaking existing cases.
--- hw/ppc/spapr.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
hw/ppc/spapr.c +19 -7
@@ -2291,17 +2291,29 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)if (kvm_enabled () && (spapr->vsmt != kvm_smt)) { ret =kvmppc_set_smt_threads (spapr->vsmt);if (ret) { +/* Looks like KVM isn't able to change VSMT mode */ error_setg (&local_err,"Failed to set KVM's VSMT mode to %d (errno %d)" , spapr->vsmt, ret); -if (!vsmt_user) { -error_append_hint (&local_err,"On PPC, a VM with %d threads/" -"core on a host with %d threads/core requires " -" the use of VSMT mode %d.\n" , - smp_threads, kvm_smt, spapr->vsmt); +/* We can live with that if the default one is big enough +* for the number of threads, and a submultiple of the one +* we want. In this case we'll waste some vcpu ids, but +* behaviour will be correct */ +if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) ==0 )) { +warn_report_err (local_err); + local_err =NULL ; + goto out; + }else { +if (!vsmt_user) { +error_append_hint (&local_err, +"On PPC, a VM with %d threads/core" +" on a host with %d threads/core" +" requires the use of VSMT mode %d.\n" , + smp_threads, kvm_smt, spapr->vsmt); + } +kvmppc_hint_smt_possible (&local_err); + goto out; } -kvmppc_hint_smt_possible (&local_err); - goto out; } }/* else TCG: nothing to do currently */
Signature · 1 line
2.11.0
PATCH 71/113 iotests: Add test for rebasing with relative paths
In reply to Michael RothFrom: Max Reitz <[email protected]>
Message-id: [email protected]
--- tests/qemu-iotests/024 | 82 ++++++++++++++++++++++++++++++++++++++++++++-- tests/qemu-iotests/024.out | 30 +++++++++++++++++ 2 files changed, 109 insertions(+), 3 deletions(-)
tests/qemu-iotests/024 +79 -3
@@ -29,9 +29,14 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_DIR/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/t.$IMGFMT.base_new" + _cleanup_test_img + rm -f "$TEST_DIR/t.$IMGFMT.base_old" + rm -f "$TEST_DIR/t.$IMGFMT.base_new" + + rm -f "$TEST_DIR/subdir/t.$IMGFMT" + rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" + rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" + rmdir "$TEST_DIR/subdir" 2> /dev/null } trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -123,6 +128,77 @@ io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00 io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11 io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00 +echo +echo "=== Test rebase in a subdirectory of the working directory ===" +echo + +# Clean up the old images beforehand so they do not interfere with +# this test +_cleanup + +mkdir "$TEST_DIR/subdir" + +# Relative to the overlay +BASE_OLD_OREL="t.$IMGFMT.base_old" +BASE_NEW_OREL="t.$IMGFMT.base_new" + +# Relative to $TEST_DIR (which is going to be our working directory) +OVERLAY_WREL="subdir/t.$IMGFMT" + +BASE_OLD="$TEST_DIR/subdir/$BASE_OLD_OREL" +BASE_NEW="$TEST_DIR/subdir/$BASE_NEW_OREL" +OVERLAY="$TEST_DIR/$OVERLAY_WREL" + +# Test done here: +# +# Backing (old): 11 11 -- 11 +# Backing (new): -- 22 22 11 +# Overlay: -- -- -- -- +# +# Rebasing works, we have verified that above. Here, we just want to +# see that rebasing is done for the correct target backing file. + +TEST_IMG=$BASE_OLD _make_test_img 1M +TEST_IMG=$BASE_NEW _make_test_img 1M +TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD_OREL" 1M + +echo + +$QEMU_IO "$BASE_OLD" \ + -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ + -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \ + | _filter_qemu_io + +$QEMU_IO "$BASE_NEW" \ + -c "write -P 0x22 $((1 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ + -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \ + | _filter_qemu_io + +echo + +pushd "$TEST_DIR" >/dev/null +$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" "$OVERLAY_WREL" +popd >/dev/null + +# Verify the backing path is correct +TEST_IMG=$OVERLAY _img_info | grep '^backing file' + +echo + +# Verify the data is correct +$QEMU_IO "$OVERLAY" \ + -c "read -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x11 $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x00 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x11 $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + | _filter_qemu_io + +echo + +# Verify that cluster #3 is not allocated (because it is the same in +# $BASE_OLD and $BASE_NEW) +$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map + # success, all done echo "*** done"
tests/qemu-iotests/024.out +30 -0
@@ -141,4 +141,34 @@ read 65536/65536 bytes at offset 917504 === IO: pattern 0x00 read 65536/65536 bytes at offset 983040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=== Test rebase in a subdirectory of the working directory === + +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=IMGFMT size=1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=IMGFMT size=1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=t.IMGFMT.base_old + +wrote 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 65536 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +backing file: t.IMGFMT.base_new (actual path: TEST_DIR/subdir/t.IMGFMT.base_new) + +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 131072 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Offset Length File +0 0x30000 TEST_DIR/subdir/t.IMGFMT +0x30000 0x10000 TEST_DIR/subdir/t.IMGFMT.base_new *** done
Signature · 1 line
2.11.0
PATCH 72/113 qemu-io: Use purely string blockdev options
In reply to Michael RothFrom: Max Reitz <[email protected]>
Currently, qemu-io only uses string-valued blockdev options (as all are converted directly from QemuOpts) -- with one exception: -U adds the force-share option as a boolean. This in itself is already a bit questionable, but a real issue is that it also assumes the value already existing in the options QDict would be a boolean, which is wrong.
That has the following effect:
$ ./qemu-io -r -U --image-opts \
driver=file,filename=/dev/null,force-share=off
[1] 15200 segmentation fault (core dumped) ./qemu-io -r -U
--image-opts driver=file,filename=/dev/null,force-share=offSince @opts is converted from QemuOpts, the value must be a string, and we have to compare it as such. Consequently, it makes sense to also set it as a string instead of a boolean.
Message-id: [email protected]
--- qemu-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qemu-io.c +2 -2
@@ -71,12 +71,12 @@ static int openfile(char *name, int flags, bool writethrough, bool force_share, opts =qdict_new (); }if (qdict_haskey (opts,BDRV_OPT_FORCE_SHARE ) - && !qdict_get_bool (opts,BDRV_OPT_FORCE_SHARE )) { + &&strcmp (qdict_get_str (opts,BDRV_OPT_FORCE_SHARE ),"on" )) {error_report ("-U conflicts with image options" );QDECREF (opts);return 1 ; } -qdict_put_bool (opts,BDRV_OPT_FORCE_SHARE , true); +qdict_put_str (opts,BDRV_OPT_FORCE_SHARE ,"on" ); } qemuio_blk =blk_new_open (name,NULL , opts, flags, &local_err);if (!qemuio_blk) {
Signature · 1 line
2.11.0
PATCH 73/113 qemu-img: Use only string options in img_open_opts
In reply to Michael RothFrom: Max Reitz <[email protected]>
img_open_opts() takes a QemuOpts and converts them to a QDict, so all values therein are strings. Then it may try to call qdict_get_bool(), however, which will fail with a segmentation fault every time:
$ ./qemu-img info -U --image-opts \
driver=file,filename=/dev/null,force-share=off
[1] 27869 segmentation fault (core dumped) ./qemu-img info -U
--image-opts driver=file,filename=/dev/null,force-share=offFix this by using qdict_get_str() and comparing the value as a string. Also, when adding a force-share value to the QDict, add it as a string so it fits the rest of the dict.
Message-id: [email protected]
--- qemu-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qemu-img.c +2 -2
@@ -276,12 +276,12 @@ static BlockBackend *img_open_opts(const char *optstr, options =qemu_opts_to_qdict (opts,NULL );if (force_share) {if (qdict_haskey (options,BDRV_OPT_FORCE_SHARE ) - && !qdict_get_bool (options,BDRV_OPT_FORCE_SHARE )) { + &&strcmp (qdict_get_str (options,BDRV_OPT_FORCE_SHARE ),"on" )) {error_report ("--force-share/-U conflicts with image options" );QDECREF (options);return NULL ; } -qdict_put_bool (options,BDRV_OPT_FORCE_SHARE , true); +qdict_put_str (options,BDRV_OPT_FORCE_SHARE ,"on" ); } blk =blk_new_open (NULL ,NULL , options, flags, &local_err);if (!blk) {
Signature · 1 line
2.11.0
PATCH 74/113 iotests: Add test for -U/force-share conflicts
In reply to Michael RothFrom: Max Reitz <[email protected]>
Message-id: [email protected]
--- tests/qemu-iotests/153 | 17 +++++++++++++++++ tests/qemu-iotests/153.out | 16 ++++++++++++++++ 2 files changed, 33 insertions(+)
tests/qemu-iotests/153 +17 -0
@@ -228,6 +228,23 @@ _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' _cleanup_qemu +echo +echo "== Detecting -U and force-share conflicts ==" + +echo +echo 'No conflict:' +$QEMU_IMG info -U --image-opts driver=null-co,force-share=on +echo +echo 'Conflict:' +$QEMU_IMG info -U --image-opts driver=null-co,force-share=off + +echo +echo 'No conflict:' +$QEMU_IO -c 'open -r -U -o driver=null-co,force-share=on' +echo +echo 'Conflict:' +$QEMU_IO -c 'open -r -U -o driver=null-co,force-share=off' + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/153.out +16 -0
@@ -393,4 +393,20 @@ Is another process using the image? Closing the other _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 + +== Detecting -U and force-share conflicts == + +No conflict: +image: null-co:// +file format: null-co +virtual size: 1.0G (1073741824 bytes) +disk size: unavailable + +Conflict: +qemu-img: --force-share/-U conflicts with image options + +No conflict: + +Conflict: +-U conflicts with image options *** done
Signature · 1 line
2.11.0
PATCH 75/113 lm32: take BQL before writing IP/IM register
In reply to Michael RothFrom: Michael Walle <[email protected]>
Writing to these registers may raise an interrupt request. Actually, this prevents the milkymist board from starting.
--- target/lm32/op_helper.c | 4 ++++ 1 file changed, 4 insertions(+)
target/lm32/op_helper.c +4 -0
@@ -102,12 +102,16 @@ void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc)void HELPER (wcsr_im )(CPULM32State *env,uint32_t im) { +qemu_mutex_lock_iothread ();lm32_pic_set_im (env->pic_state, im); +qemu_mutex_unlock_iothread (); }void HELPER (wcsr_ip )(CPULM32State *env,uint32_t im) { +qemu_mutex_lock_iothread ();lm32_pic_set_ip (env->pic_state, im); +qemu_mutex_unlock_iothread (); }void HELPER (wcsr_jtx )(CPULM32State *env,uint32_t jtx)
Signature · 1 line
2.11.0
PATCH 76/113 raw: Check byte range uniformly
In reply to Michael RothFrom: Fam Zheng <[email protected]>
We don't verify the request range against s->size in the I/O callbacks except for raw_co_pwritev. This is inconsistent (especially for raw_co_pwrite_zeroes and raw_co_pdiscard), so fix them, in the meanwhile make the helper reusable by the coming new callbacks.
Note that in most cases the block layer already verifies the request byte range against our reported image length, before invoking the driver callbacks. The exception is during image creating, after blk_set_allow_write_beyond_eof(blk, true) is called. But in that case, the requests are not directly from the user or guest. So there is no visible behavior change in adding the check code.
The int64_t -> uint64_t inconsistency, as shown by the type casting, is pre-existing due to the interface.
Message-id: [email protected]
--- block/raw-format.c | 64 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 25 deletions(-)
block/raw-format.c +39 -25
@@ -167,16 +167,37 @@ static void raw_reopen_abort(BDRVReopenState *state) state->opaque =NULL ; } +/* Check and adjust the offset, against 'offset' and 'size' options. */ +static inline int raw_adjust_offset (BlockDriverState *bs,uint64_t *offset, +uint64_t bytes,bool is_write) +{ +BDRVRawState *s = bs->opaque; + +if (s->has_size && (*offset > s->size || bytes > (s->size - *offset))) { +/* There's not enough space for the write, or the read request is +* out-of-range. Don't read/write anything to prevent leaking out of +* the size specified in options. */ +return is_write ? -ENOSPC : -EINVAL ;; + } + +if (*offset >INT64_MAX - s->offset) { +return -EINVAL ; + } + *offset += s->offset; + +return 0 ; +} + static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offset,uint64_t bytes,QEMUIOVector *qiov,int flags) { -BDRVRawState *s = bs->opaque; +int ret; -if (offset >UINT64_MAX - s->offset) { -return -EINVAL ; + ret =raw_adjust_offset (bs, &offset, bytes, false); +if (ret) { +return ret; } - offset += s->offset;BLKDBG_EVENT (bs->file,BLKDBG_READ_AIO );return bdrv_co_preadv (bs->file, offset, bytes, qiov, flags);
@@ -186,23 +207,11 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVRawState *s = bs->opaque; void *buf = NULL;BlockDriver *drv;QEMUIOVector local_qiov;int ret; -if (s->has_size && (offset > s->size || bytes > (s->size - offset))) { -/* There's not enough space for the data. Don't write anything and just -* fail to prevent leaking out of the size specified in options. */ -return -ENOSPC ; - } - -if (offset >UINT64_MAX - s->offset) { - ret = -EINVAL ; - goto fail; - } -if (bs->probed && offset <BLOCK_PROBE_BUF_SIZE && bytes) {/* Handling partial writes would be a pain - so we just * require that guests have 512-byte request alignment if
@@ -237,7 +246,10 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, qiov = &local_qiov; } - offset += s->offset; + ret =raw_adjust_offset (bs, &offset, bytes, true); +if (ret) { + goto fail; + }BLKDBG_EVENT (bs->file,BLKDBG_WRITE_AIO ); ret =bdrv_co_pwritev (bs->file, offset, bytes, qiov, flags);
@@ -267,22 +279,24 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags) { - BDRVRawState *s = bs->opaque; -if (offset >UINT64_MAX - s->offset) { -return -EINVAL ; + int ret; + + ret =raw_adjust_offset (bs, (uint64_t *)&offset, bytes, true); +if (ret) { +return ret; } - offset += s->offset;return bdrv_co_pwrite_zeroes (bs->file, offset, bytes, flags); } static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs,int64_t offset,int bytes) { -BDRVRawState *s = bs->opaque; -if (offset >UINT64_MAX - s->offset) { -return -EINVAL ; +int ret; + + ret =raw_adjust_offset (bs, (uint64_t *)&offset, bytes, true); +if (ret) { +return ret; } - offset += s->offset;return bdrv_co_pdiscard (bs->file->bs, offset, bytes); }
Signature · 1 line
2.11.0
PATCH 77/113 s390x/css: disabled subchannels cannot be status pending
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
The 3270 code will try to post an attention interrupt when the 3270 emulator (e.g. x3270) attaches. If the guest has not yet enabled the subchannel for the 3270 device, we will present a spurious cc 1 (status pending) when it uses msch on it later on, e.g. when trying to enable the subchannel.
To fix this, just don't do anything in css_conditional_io_interrupt() if the subchannel is not enabled. The 3270 code will work fine with that, and the other user of this function (virtio-ccw) never attempts to post an interrupt for a disabled device to begin with.
--- hw/s390x/css.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/s390x/css.c +8 -0
@@ -618,6 +618,14 @@ void css_inject_io_interrupt(SubchDev *sch)void css_conditional_io_interrupt (SubchDev *sch) {/* +* If the subchannel is not enabled, it is not made status pending +* (see PoP p. 16-17, "Status Control"). +*/ +if (!(sch->curr_status.pmcw.flags &PMCW_FLAGS_MASK_ENA )) { +return ; + } + +/* * If the subchannel is not currently status pending, make it pending * with alert status. */
Signature · 1 line
2.11.0
PATCH 78/113 pc-bios/s390-ccw: struct tpi_info must be declared as aligned(4)
In reply to Michael RothFrom: Thomas Huth <[email protected]>
I've run into a compilation error today with the current version of GCC 8:
In file included from s390-ccw.h:49,
from main.c:12:
cio.h:128:1: error: alignment 1 of 'struct tpi_info' is less than 4 [-Werror=packed-not-aligned]
} __attribute__ ((packed));
^
cc1: all warnings being treated as errors
Since the struct tpi_info contains an element ("struct subchannel_id schid") which is marked as aligned(4), we've got to mark the struct tpi_info as aligned(4), too.
Message-Id: <[email protected]>
--- pc-bios/s390-ccw/cio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pc-bios/s390-ccw/cio.h +1 -1
@@ -125,7 +125,7 @@ struct tpi_info { __u32 reserved3 : 12; __u32 int_type : 3; __u32 reserved4 : 12; -} __attribute__ ((packed)); +} __attribute__ ((packed, aligned(4)));/* channel command word (type 1) */ struct ccw1 {
Signature · 1 line
2.11.0
PATCH 79/113 qdev: rename typedef qdev_resetfn() -> DeviceReset()
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
following the DeviceRealize and DeviceUnrealize typedefs, this unify a bit the new QOM API.
Message-Id: <[email protected]>
*prereq for 0c53057adb
--- include/hw/qdev-core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/hw/qdev-core.h +2 -2
@@ -32,9 +32,9 @@ typedef enum DeviceCategory {typedef int (*qdev_initfn )(DeviceState *dev);typedef int (*qdev_event )(DeviceState *dev); -typedef void (*qdev_resetfn )(DeviceState *dev);typedef void (*DeviceRealize )(DeviceState *dev,Error **errp);typedef void (*DeviceUnrealize )(DeviceState *dev,Error **errp); +typedef void (*DeviceReset )(DeviceState *dev);typedef void (*BusRealize )(BusState *bus,Error **errp);typedef void (*BusUnrealize )(BusState *bus,Error **errp);
@@ -117,7 +117,7 @@ typedef struct DeviceClass {bool hotpluggable;/* callbacks */ -void (*reset)(DeviceState *dev); +DeviceReset reset;DeviceRealize realize;DeviceUnrealize unrealize;
Signature · 1 line
2.11.0
PATCH 80/113 qdev: add helpers to be more explicit when using abstract QOM parent functions
In reply to Michael RothFrom: Philippe Mathieu-Daudé <[email protected]>
QOM API learning curve is quite hard, in particular when devices inherit from abstract parent.
To be more explicit about when a device class change the parent hooks, add few helpers hoping a device class_init() will be easier to understand.
Message-Id: <[email protected]>
*prereq for 0c53057adb
--- hw/core/qdev.c | 24 ++++++++++++++++++++++++ include/hw/qdev-core.h | 10 ++++++++++ 2 files changed, 34 insertions(+)
hw/core/qdev.c +24 -0
@@ -1140,6 +1140,30 @@ static void device_class_init(ObjectClass *class, void *data) dc->user_creatable = true; } +void device_class_set_parent_reset (DeviceClass *dc, +DeviceReset dev_reset, +DeviceReset *parent_reset) +{ + *parent_reset = dc->reset; + dc->reset = dev_reset; +} + +void device_class_set_parent_realize (DeviceClass *dc, +DeviceRealize dev_realize, +DeviceRealize *parent_realize) +{ + *parent_realize = dc->realize; + dc->realize = dev_realize; +} + +void device_class_set_parent_unrealize (DeviceClass *dc, +DeviceUnrealize dev_unrealize, +DeviceUnrealize *parent_unrealize) +{ + *parent_unrealize = dc->unrealize; + dc->unrealize = dev_unrealize; +} +void device_reset (DeviceState *dev) {DeviceClass *klass =DEVICE_GET_CLASS (dev);
include/hw/qdev-core.h +10 -0
@@ -381,6 +381,16 @@ void qdev_machine_init(void);*/ void device_reset (DeviceState *dev); +void device_class_set_parent_reset (DeviceClass *dc, +DeviceReset dev_reset, +DeviceReset *parent_reset); +void device_class_set_parent_realize (DeviceClass *dc, +DeviceRealize dev_realize, +DeviceRealize *parent_realize); +void device_class_set_parent_unrealize (DeviceClass *dc, +DeviceUnrealize dev_unrealize, +DeviceUnrealize *parent_unrealize); +const struct VMStateDescription *qdev_get_vmsd (DeviceState *dev);const char *qdev_fw_name (DeviceState *dev);
Signature · 1 line
2.11.0
PATCH 7/113 spapr: Adjust default VSMT value for better migration compatibility
In reply to Michael RothFrom: David Gibson <[email protected]>
fa98fbfc "PC: KVM: Support machine option to set VSMT mode" introduced the "vsmt" parameter for the pseries machine type, which controls the spacing of the vcpu ids of thread 0 for each virtual core. This was done to bring some consistency and stability to how that was done, while still allowing backwards compatibility for migration and otherwise.
The default value we used for vsmt was set to the max of the host's advertised default number of threads and the number of vthreads per vcore in the guest. This was done to continue running without extra parameters on older KVM versions which don't allow the VSMT value to be changed.
Unfortunately, even that smaller than before leakage of host configuration into guest visible configuration still breaks things. Specifically a guest with 4 (or less) vthread/vcore will get a different vsmt value when running on a POWER8 (vsmt==8) and POWER9 (vsmt==4) host. That means the vcpu ids don't line up so you can't migrate between them, though you should be able to.
Long term we really want to make vsmt == smp_threads for sufficiently new machine types. However, that means that qemu will then require a sufficiently recent KVM (one which supports changing VSMT) - that's still not widely enough deployed to be really comfortable to do.
In the meantime we need some default that will work as often as possible. This patch changes that default to 8 in all circumstances. This does change guest visible behaviour (including for existing machine versions) for many cases - just not the most common/important case.
Following is case by case justification for why this is still the least worst option. Note that any of the old behaviours can still be duplicated after this patch, it's just that it requires manual intervention by setting the vsmt property on the command line.
KVM HV on POWER8 host:
This is the overwhelmingly common case in production setups, and is unchanged by design. POWER8 hosts will advertise a default VSMT mode of 8, and > 8 vthreads/vcore isn't permitted
KVM HV on POWER7 host:
Will break, but POWER7s allowing KVM were never released to the public.
KVM HV on POWER9 host:
Not yet released to the public, breaking this now will reduce other breakage later.
KVM HV on PowerPC 970:
Will theoretically break it, but it was barely supported to begin with and already required various user visible hacks to work. Also so old that I just don't care.
TCG:
This is the nastiest one; it means migration of TCG guests (without manual vsmt setting) will break. Since TCG is rarely used in production I think this is worth it for the other benefits. It does also remove one more barrier to TCG<->KVM migration which could be interesting for debugging applications.
KVM PR:
As with TCG, this will break migration of existing configurations, without adding extra manual vsmt options. As with TCG, it is rare in production so I think the benefits outweigh breakages.
--- hw/ppc/spapr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +8 -3
@@ -2282,9 +2282,14 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp) }/* In this case, spapr->vsmt has been set by the command line */ }else { -/* Choose a VSMT mode that may be higher than necessary but is -* likely to be compatible with hosts that don't have VSMT. */ - spapr->vsmt =MAX (kvm_smt, smp_threads); +/* +* Default VSMT value is tricky, because we need it to be as +* consistent as possible (for migration), but this requires +* changing it for at least some existing cases. We pick 8 as +* the value that we'd get with KVM on POWER8, the +* overwhelmingly common case in production systems. +*/ + spapr->vsmt =8 ; }/* KVM: If necessary, set the SMT mode: */
Signature · 1 line
2.11.0
PATCH 81/113 s390x/virtio: Convert virtio-ccw from *_exit to *_unrealize
In reply to Michael RothFrom: Nia Alarie <[email protected]>
Message-Id: <[email protected]>
*prereq for 0c53057adb
--- hw/s390x/virtio-ccw.c | 34 +++++++++++++++++----------------- hw/s390x/virtio-ccw.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-)
hw/s390x/virtio-ccw.c +17 -17
@@ -751,7 +751,7 @@ out_err:g_free (sch); } -static int virtio_ccw_exit (VirtioCcwDevice *dev) +static void virtio_ccw_unrealize (VirtioCcwDevice *dev,Error **errp) {CcwDevice *ccw_dev =CCW_DEVICE (dev);SubchDev *sch = ccw_dev->sch;
@@ -759,12 +759,12 @@ static int virtio_ccw_exit(VirtioCcwDevice *dev)if (sch) {css_subch_assign (sch->cssid, sch->ssid, sch->schid, sch->devno,NULL );g_free (sch); + ccw_dev->sch =NULL ; }if (dev->indicators) {release_indicator (&dev->routes.adapter, dev->indicators); dev->indicators =NULL ; } -return 0 ; }static void virtio_ccw_net_realize (VirtioCcwDevice *ccw_dev,Error **errp)
@@ -1343,7 +1343,7 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_net_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_net_properties;set_bit (DEVICE_CATEGORY_NETWORK , dc->categories);
@@ -1371,7 +1371,7 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_blk_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_blk_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories);
@@ -1399,7 +1399,7 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_serial_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_serial_properties;set_bit (DEVICE_CATEGORY_INPUT , dc->categories);
@@ -1427,7 +1427,7 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_balloon_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_balloon_properties;set_bit (DEVICE_CATEGORY_MISC , dc->categories);
@@ -1455,7 +1455,7 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_scsi_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_scsi_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories);
@@ -1482,7 +1482,7 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = vhost_ccw_scsi_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = vhost_ccw_scsi_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories);
@@ -1519,7 +1519,7 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_rng_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_rng_properties;set_bit (DEVICE_CATEGORY_MISC , dc->categories);
@@ -1557,7 +1557,7 @@ static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_crypto_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_crypto_properties;set_bit (DEVICE_CATEGORY_MISC , dc->categories);
@@ -1595,7 +1595,7 @@ static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_gpu_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_gpu_properties; dc->hotpluggable = false;
@@ -1624,7 +1624,7 @@ static void virtio_ccw_input_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = virtio_ccw_input_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_input_properties;set_bit (DEVICE_CATEGORY_INPUT , dc->categories);
@@ -1704,12 +1704,12 @@ static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp)virtio_ccw_device_realize (_dev, errp); } -static int virtio_ccw_busdev_exit (DeviceState *dev) +static void virtio_ccw_busdev_unrealize (DeviceState *dev,Error **errp) {VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;VirtIOCCWDeviceClass *_info =VIRTIO_CCW_DEVICE_GET_CLASS (dev); -return _info->exit (_dev); + _info->unrealize (_dev, errp); } static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev,
@@ -1727,7 +1727,7 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) k->unplug = virtio_ccw_busdev_unplug; dc->realize = virtio_ccw_busdev_realize; - dc->exit = virtio_ccw_busdev_exit; + dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type =TYPE_VIRTUAL_CSS_BUS ; }
@@ -1803,7 +1803,7 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; k->realize = virtio_ccw_9p_realize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_9p_properties;
@@ -1852,7 +1852,7 @@ static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data)VirtIOCCWDeviceClass *k =VIRTIO_CCW_DEVICE_CLASS (klass); k->realize = vhost_vsock_ccw_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->props = vhost_vsock_ccw_properties; dc->reset = virtio_ccw_reset;
hw/s390x/virtio-ccw.h +1 -1
@@ -76,7 +76,7 @@ typedef struct VirtioCcwDevice VirtioCcwDevice;typedef struct VirtIOCCWDeviceClass {CCWDeviceClass parent_class;void (*realize)(VirtioCcwDevice *dev,Error **errp); -int (*exit)(VirtioCcwDevice *dev); +void (*unrealize)(VirtioCcwDevice *dev,Error **errp); }VirtIOCCWDeviceClass ;/* Performance improves when virtqueue kick processing is decoupled from the
Signature · 1 line
2.11.0
PATCH 82/113 virtio-ccw: common reset handler
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
All the different virtio ccw devices use the same reset handler, so let's move setting it into the base virtio ccw device class.
--- hw/s390x/virtio-ccw.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
hw/s390x/virtio-ccw.c +1 -12
@@ -1344,7 +1344,6 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_net_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_net_properties;set_bit (DEVICE_CATEGORY_NETWORK , dc->categories); }
@@ -1372,7 +1371,6 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_blk_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_blk_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }
@@ -1400,7 +1398,6 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_serial_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_serial_properties;set_bit (DEVICE_CATEGORY_INPUT , dc->categories); }
@@ -1428,7 +1425,6 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_balloon_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_balloon_properties;set_bit (DEVICE_CATEGORY_MISC , dc->categories); }
@@ -1456,7 +1452,6 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_scsi_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_scsi_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }
@@ -1483,7 +1478,6 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) k->realize = vhost_ccw_scsi_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = vhost_ccw_scsi_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }
@@ -1520,7 +1514,6 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_rng_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_rng_properties;set_bit (DEVICE_CATEGORY_MISC , dc->categories); }
@@ -1558,7 +1551,6 @@ static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_crypto_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_crypto_properties;set_bit (DEVICE_CATEGORY_MISC , dc->categories); }
@@ -1596,7 +1588,6 @@ static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_gpu_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_gpu_properties; dc->hotpluggable = false;set_bit (DEVICE_CATEGORY_DISPLAY , dc->categories);
@@ -1625,7 +1616,6 @@ static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_input_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_input_properties;set_bit (DEVICE_CATEGORY_INPUT , dc->categories); }
@@ -1729,6 +1719,7 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) dc->realize = virtio_ccw_busdev_realize; dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type =TYPE_VIRTUAL_CSS_BUS ; + dc->reset = virtio_ccw_reset; }static const TypeInfo virtio_ccw_device_info = {
@@ -1805,7 +1796,6 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) k->unrealize = virtio_ccw_unrealize; k->realize = virtio_ccw_9p_realize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_9p_properties;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }
@@ -1855,7 +1845,6 @@ static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data) k->unrealize = virtio_ccw_unrealize;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->props = vhost_vsock_ccw_properties; - dc->reset = virtio_ccw_reset; }static void vhost_vsock_ccw_instance_init (Object *obj)
Signature · 1 line
2.11.0
PATCH 83/113 s390x/ccw: make sure all ccw devices are properly reset
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
Thomas reported that the subchannel for a 3270 device that ended up in a broken state (status pending even though not enabled) did not get out of that state even after a reboot (which involves a subsytem reset). The reason for this is that the 3270 device did not define a reset handler.
Let's fix this by introducing a base reset handler (set up for all ccw devices) that resets the subchannel and have virtio-ccw call its virtio-specific reset procedure in addition to that.
--- hw/s390x/ccw-device.c | 8 ++++++++ hw/s390x/virtio-ccw.c | 9 ++++++--- hw/s390x/virtio-ccw.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-)
hw/s390x/ccw-device.c +8 -0
@@ -40,6 +40,13 @@ static Property ccw_device_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void ccw_device_reset (DeviceState *d) +{ +CcwDevice *ccw_dev =CCW_DEVICE (d); + +css_reset_sch (ccw_dev->sch); +} +static void ccw_device_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -48,6 +55,7 @@ static void ccw_device_class_init(ObjectClass *klass, void *data) k->realize = ccw_device_realize; k->refill_ids = ccw_device_refill_ids; dc->props = ccw_device_properties; + dc->reset = ccw_device_reset; }const VMStateDescription vmstate_ccw_dev = {
hw/s390x/virtio-ccw.c +6 -3
@@ -1057,10 +1057,12 @@ static void virtio_ccw_reset(DeviceState *d) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d);VirtIODevice *vdev =virtio_bus_get_device (&dev->bus); -CcwDevice *ccw_dev =CCW_DEVICE (d); +VirtIOCCWDeviceClass *vdc =VIRTIO_CCW_DEVICE_GET_CLASS (dev);virtio_ccw_reset_virtio (dev, vdev); -css_reset_sch (ccw_dev->sch); +if (vdc->parent_reset) { + vdc->parent_reset (d); + } }static void virtio_ccw_vmstate_change (DeviceState *d,bool running)
@@ -1714,12 +1716,13 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);CCWDeviceClass *k =CCW_DEVICE_CLASS (dc); +VirtIOCCWDeviceClass *vdc =VIRTIO_CCW_DEVICE_CLASS (klass); k->unplug = virtio_ccw_busdev_unplug; dc->realize = virtio_ccw_busdev_realize; dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type =TYPE_VIRTUAL_CSS_BUS ; - dc->reset = virtio_ccw_reset; +device_class_set_parent_reset (dc, virtio_ccw_reset, &vdc->parent_reset); }static const TypeInfo virtio_ccw_device_info = {
hw/s390x/virtio-ccw.h +1 -0
@@ -77,6 +77,7 @@ typedef struct VirtIOCCWDeviceClass {CCWDeviceClass parent_class;void (*realize)(VirtioCcwDevice *dev,Error **errp);void (*unrealize)(VirtioCcwDevice *dev,Error **errp); +void (*parent_reset)(DeviceState *dev); } VirtIOCCWDeviceClass;/* Performance improves when virtqueue kick processing is decoupled from the
Signature · 1 line
2.11.0
PATCH 84/113 console: Avoid segfault in screendump
In reply to Michael RothFrom: Michal Privoznik <[email protected]>
After f771c5440e04626f1 it is possible to select device and head which to take screendump from. And even though we check if provided head number falls within range, it may still happen that the console has no surface yet leading to SIGSEGV:
qemu.git $ ./x86_64-softmmu/qemu-system-x86_64 \
-qmp stdio \
-device virtio-vga,id=video0,max_outputs=4 {"execute":"qmp_capabilities"}
{"execute":"screendump", "arguments":{"filename":"/tmp/screen.ppm", "device":"video0", "head":1}} Segmentation fault
#0 0x00005628249dda88 in ppm_save (filename=0x56282826cbc0 "/tmp/screen.ppm", ds=0x0, errp=0x7fff52a6fae0) at ui/console.c:304 #1 0x00005628249ddd9b in qmp_screendump (filename=0x56282826cbc0 "/tmp/screen.ppm", has_device=true, device=0x5628276902d0 "video0", has_head=true, head=1, errp=0x7fff52a6fae0) at ui/console.c:375 #2 0x00005628247740df in qmp_marshal_screendump (args=0x562828265e00, ret=0x7fff52a6fb68, errp=0x7fff52a6fb60) at qapi/qapi-commands-ui.c:110
Here, @ds from frame #0 (or @surface from frame #1) is dereferenced at the very beginning of ppm_save(). And because it's NULL crash happens.
Message-id: cb05bb1909daa6ba62145c0194aafa05a14ed3d1.1526569138.git.mprivozn@redhat.com
--- ui/console.c | 5 +++++ 1 file changed, 5 insertions(+)
ui/console.c +5 -0
@@ -354,6 +354,11 @@ void qmp_screendump(const char *filename, Error **errp)graphic_hw_update (con); surface =qemu_console_surface (con); +if (!surface) { +error_setg (errp,"no surface" ); +return ; + } +ppm_save (filename, surface, errp); }
Signature · 1 line
2.11.0
PATCH 85/113 hw/intc/arm_gicv3: Fix APxR<n> register dispatching
In reply to Michael RothFrom: Jan Kiszka <[email protected]>
There was a nasty flip in identifying which register group an access is targeting. The issue caused spuriously raised priorities of the guest when handing CPUs over in the Jailhouse hypervisor.
Message-id: [email protected]
--- hw/intc/arm_gicv3_cpuif.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/intc/arm_gicv3_cpuif.c +6 -6
@@ -431,7 +431,7 @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) {GICv3CPUState *cs =icc_cs_from_env (env);int regno = ri->opc2 &3 ; -int grp = ri->crm &1 ?GICV3_G0 :GICV3_G1NS ; +int grp = (ri->crm &1 ) ?GICV3_G1NS :GICV3_G0 ;uint64_t value = cs->ich_apr[grp][regno];trace_gicv3_icv_ap_read (ri->crm &1 , regno,gicv3_redist_affid (cs), value);
@@ -443,7 +443,7 @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, {GICv3CPUState *cs =icc_cs_from_env (env);int regno = ri->opc2 &3 ; -int grp = ri->crm &1 ?GICV3_G0 :GICV3_G1NS ; +int grp = (ri->crm &1 ) ?GICV3_G1NS :GICV3_G0 ;trace_gicv3_icv_ap_write (ri->crm &1 , regno,gicv3_redist_affid (cs), value);
@@ -1465,7 +1465,7 @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)uint64_t value;int regno = ri->opc2 &3 ; -int grp = ri->crm &1 ?GICV3_G0 :GICV3_G1 ; +int grp = (ri->crm &1 ) ?GICV3_G1 :GICV3_G0 ;if (icv_access (env, grp ==GICV3_G0 ?HCR_FMO :HCR_IMO )) {return icv_ap_read (env, ri);
@@ -1487,7 +1487,7 @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,GICv3CPUState *cs =icc_cs_from_env (env);int regno = ri->opc2 &3 ; -int grp = ri->crm &1 ?GICV3_G0 :GICV3_G1 ; +int grp = (ri->crm &1 ) ?GICV3_G1 :GICV3_G0 ;if (icv_access (env, grp ==GICV3_G0 ?HCR_FMO :HCR_IMO )) {icv_ap_write (env, ri, value);
@@ -2296,7 +2296,7 @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) {GICv3CPUState *cs =icc_cs_from_env (env);int regno = ri->opc2 &3 ; -int grp = ri->crm &1 ?GICV3_G0 :GICV3_G1NS ; +int grp = (ri->crm &1 ) ?GICV3_G1NS :GICV3_G0 ;uint64_t value; value = cs->ich_apr[grp][regno];
@@ -2309,7 +2309,7 @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, {GICv3CPUState *cs =icc_cs_from_env (env);int regno = ri->opc2 &3 ; -int grp = ri->crm &1 ?GICV3_G0 :GICV3_G1NS ; +int grp = (ri->crm &1 ) ?GICV3_G1NS :GICV3_G0 ;trace_gicv3_ich_ap_write (ri->crm &1 , regno,gicv3_redist_affid (cs), value);
Signature · 1 line
2.11.0
PATCH 86/113 intel-iommu: Redefine macros to enable supporting 48 bit address width
In reply to Michael RothFrom: Prasad Singamsetty <[email protected]>
The current implementation of Intel IOMMU code only supports 39 bits host/iova address width so number of macros use hard coded values based on that. This patch is to redefine them so they can be used with variable address widths. This patch doesn't add any new functionality but enables adding support for 48 bit address width.
--- hw/i386/intel_iommu.c | 54 ++++++++++++++++++++++++------------------ hw/i386/intel_iommu_internal.h | 34 +++++++++++++++++++------- include/hw/i386/intel_iommu.h | 6 +++-- 3 files changed, 61 insertions(+), 33 deletions(-)
hw/i386/intel_iommu.c +31 -23
@@ -523,7 +523,7 @@ static inline dma_addr_t vtd_ce_get_slpt_base(VTDContextEntry *ce)static inline uint64_t vtd_get_slpte_addr (uint64_t slpte) { -return slpte &VTD_SL_PT_BASE_ADDR_MASK ; +return slpte &VTD_SL_PT_BASE_ADDR_MASK (VTD_HOST_ADDRESS_WIDTH ); }/* Whether the pte indicates the address of the page frame */
@@ -624,19 +624,12 @@ static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce)return !(iova & ~(vtd_iova_limit (ce) -1 )); } -static const uint64_t vtd_paging_entry_rsvd_field[] = { - [0 ] = ~0ULL , -/* For not large page */ - [1 ] =0x800ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), - [2 ] =0x800ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), - [3 ] =0x800ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), - [4 ] =0x880ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), -/* For large page */ - [5 ] =0x800ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), - [6 ] =0x1ff800ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), - [7 ] =0x3ffff800ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), - [8 ] =0x880ULL | ~(VTD_HAW_MASK |VTD_SL_IGN_COM ), -}; +/* +* Rsvd field masks for spte: +* Index [1] to [4] 4k pages +* Index [5] to [8] large pages +*/ +static uint64_t vtd_paging_entry_rsvd_field[9 ];static bool vtd_slpte_nonzero_rsvd (uint64_t slpte,uint32_t level) {
@@ -874,7 +867,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,return -VTD_FR_ROOT_ENTRY_P ; } -if (re.rsvd || (re.val &VTD_ROOT_ENTRY_RSVD )) { +if (re.rsvd || (re.val &VTD_ROOT_ENTRY_RSVD (VTD_HOST_ADDRESS_WIDTH ))) {trace_vtd_re_invalid (re.rsvd, re.val);return -VTD_FR_ROOT_ENTRY_RSVD ; }
@@ -891,7 +884,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, }if ((ce->hi &VTD_CONTEXT_ENTRY_RSVD_HI ) || - (ce->lo &VTD_CONTEXT_ENTRY_RSVD_LO )) { + (ce->lo &VTD_CONTEXT_ENTRY_RSVD_LO (VTD_HOST_ADDRESS_WIDTH ))) {trace_vtd_ce_invalid (ce->hi, ce->lo);return -VTD_FR_CONTEXT_ENTRY_RSVD ; }
@@ -1207,7 +1200,7 @@ static void vtd_root_table_setup(IntelIOMMUState *s) { s->root =vtd_get_quad_raw (s,DMAR_RTADDR_REG ); s->root_extended = s->root &VTD_RTADDR_RTT ; - s->root &=VTD_RTADDR_ADDR_MASK ; + s->root &=VTD_RTADDR_ADDR_MASK (VTD_HOST_ADDRESS_WIDTH );trace_vtd_reg_dmar_root (s->root, s->root_extended); }
@@ -1223,7 +1216,7 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s)uint64_t value =0 ; value =vtd_get_quad_raw (s,DMAR_IRTA_REG ); s->intr_size =1UL << ((value &VTD_IRTA_SIZE_MASK ) +1 ); - s->intr_root = value &VTD_IRTA_ADDR_MASK ; + s->intr_root = value &VTD_IRTA_ADDR_MASK (VTD_HOST_ADDRESS_WIDTH ); s->intr_eime = value &VTD_IRTA_EIME ;/* Notify global invalidation */
@@ -1479,7 +1472,7 @@ static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en)trace_vtd_inv_qi_enable (en);if (en) { - s->iq = iqa_val &VTD_IQA_IQA_MASK ; + s->iq = iqa_val &VTD_IQA_IQA_MASK (VTD_HOST_ADDRESS_WIDTH );/* 2^(x+8) entries */ s->iq_size =1UL << ((iqa_val &VTD_IQA_QS ) +8 ); s->qi_enabled = true;
@@ -2772,12 +2765,12 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)* VT-d spec), otherwise we need to consider overflow of 64 bits. */ -if (end >VTD_ADDRESS_SIZE ) { +if (end >VTD_ADDRESS_SIZE (VTD_HOST_ADDRESS_WIDTH )) {/* * Don't need to unmap regions that is bigger than the whole * VT-d supported address space size */ - end =VTD_ADDRESS_SIZE ; + end =VTD_ADDRESS_SIZE (VTD_HOST_ADDRESS_WIDTH ); }assert (start <= end);
@@ -2866,6 +2859,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)static void vtd_init (IntelIOMMUState *s) {X86IOMMUState *x86_iommu =X86_IOMMU_DEVICE (s); +uint8_t aw_bits =VTD_HOST_ADDRESS_WIDTH ;memset (s->csr,0 ,DMAR_REG_SIZE );memset (s->wmask,0 ,DMAR_REG_SIZE );
@@ -2882,10 +2876,24 @@ static void vtd_init(IntelIOMMUState *s) s->qi_enabled = false; s->iq_last_desc_type =VTD_INV_DESC_NONE ; s->next_frcd_reg =0 ; - s->cap =VTD_CAP_FRO |VTD_CAP_NFR |VTD_CAP_ND |VTD_CAP_MGAW | -VTD_CAP_SAGAW |VTD_CAP_MAMV |VTD_CAP_PSI |VTD_CAP_SLLPS ; + s->cap =VTD_CAP_FRO |VTD_CAP_NFR |VTD_CAP_ND | +VTD_CAP_MAMV |VTD_CAP_PSI |VTD_CAP_SLLPS | + VTD_CAP_SAGAW_39bit |VTD_CAP_MGAW (VTD_HOST_ADDRESS_WIDTH ); s->ecap =VTD_ECAP_QI |VTD_ECAP_IRO ; +/* +* Rsvd field masks for spte +*/ + vtd_paging_entry_rsvd_field[0 ] = ~0ULL ; + vtd_paging_entry_rsvd_field[1 ] =VTD_SPTE_PAGE_L1_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[2 ] =VTD_SPTE_PAGE_L2_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[3 ] =VTD_SPTE_PAGE_L3_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[4 ] =VTD_SPTE_PAGE_L4_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[5 ] =VTD_SPTE_LPAGE_L1_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[6 ] =VTD_SPTE_LPAGE_L2_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[7 ] =VTD_SPTE_LPAGE_L3_RSVD_MASK (aw_bits); + vtd_paging_entry_rsvd_field[8 ] =VTD_SPTE_LPAGE_L4_RSVD_MASK (aw_bits); +if (x86_iommu->intr_supported) { s->ecap |=VTD_ECAP_IR |VTD_ECAP_MHMV ;if (s->intr_eim ==ON_OFF_AUTO_ON ) {
hw/i386/intel_iommu_internal.h +26 -8
@@ -172,10 +172,10 @@/* RTADDR_REG */ #define VTD_RTADDR_RTT (1ULL << 11) -#define VTD_RTADDR_ADDR_MASK (VTD_HAW_MASK ^ 0xfffULL) +#define VTD_RTADDR_ADDR_MASK (aw) (VTD_HAW_MASK(aw) ^ 0xfffULL)/* IRTA_REG */ -#define VTD_IRTA_ADDR_MASK (VTD_HAW_MASK ^ 0xfffULL) +#define VTD_IRTA_ADDR_MASK (aw) (VTD_HAW_MASK(aw) ^ 0xfffULL)#define VTD_IRTA_EIME (1ULL << 11)#define VTD_IRTA_SIZE_MASK (0xfULL)
@@ -198,8 +198,8 @@#define VTD_DOMAIN_ID_MASK ((1UL << VTD_DOMAIN_ID_SHIFT) - 1)#define VTD_CAP_ND (((VTD_DOMAIN_ID_SHIFT - 4) / 2) & 7ULL)#define VTD_MGAW 39/* Maximum Guest Address Width */ -#define VTD_ADDRESS_SIZE (1ULL << VTD_MGAW) -#define VTD_CAP_MGAW (((VTD_MGAW - 1) & 0x3fULL) << 16) +#define VTD_ADDRESS_SIZE (aw) (1ULL << (aw)) +#define VTD_CAP_MGAW (aw) ((((aw) - 1) & 0x3fULL) << 16)#define VTD_MAMV 18ULL#define VTD_CAP_MAMV (VTD_MAMV << 48)#define VTD_CAP_PSI (1ULL << 39)
@@ -219,7 +219,7 @@#define VTD_IQT_QT (val) (((val) >> 4) & 0x7fffULL)/* IQA_REG */ -#define VTD_IQA_IQA_MASK (VTD_HAW_MASK ^ 0xfffULL) +#define VTD_IQA_IQA_MASK (aw) (VTD_HAW_MASK(aw) ^ 0xfffULL)#define VTD_IQA_QS 0x7ULL/* IQH_REG */
@@ -373,6 +373,24 @@ typedef union VTDInvDesc VTDInvDesc;#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8 +/* Rsvd field masks for spte */ +#define VTD_SPTE_PAGE_L1_RSVD_MASK (aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_PAGE_L2_RSVD_MASK (aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_PAGE_L3_RSVD_MASK (aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_PAGE_L4_RSVD_MASK (aw) \ + (0x880ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L1_RSVD_MASK (aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L2_RSVD_MASK (aw) \ + (0x1ff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L3_RSVD_MASK (aw) \ + (0x3ffff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L4_RSVD_MASK (aw) \ + (0x880ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +/* Information about page-selective IOTLB invalidate */ struct VTDIOTLBPageInvInfo {uint16_t domain_id;
@@ -403,7 +421,7 @@ typedef struct VTDRootEntry VTDRootEntry;#define VTD_ROOT_ENTRY_CTP (~0xfffULL)#define VTD_ROOT_ENTRY_NR (VTD_PAGE_SIZE / sizeof(VTDRootEntry)) -#define VTD_ROOT_ENTRY_RSVD (0xffeULL | ~VTD_HAW_MASK) +#define VTD_ROOT_ENTRY_RSVD (aw) (0xffeULL | ~VTD_HAW_MASK(aw))/* Masks for struct VTDContextEntry */ /* lo */
@@ -415,7 +433,7 @@ typedef struct VTDRootEntry VTDRootEntry;#define VTD_CONTEXT_TT_PASS_THROUGH (2ULL << 2)/* Second Level Page Translation Pointer*/ #define VTD_CONTEXT_ENTRY_SLPTPTR (~0xfffULL) -#define VTD_CONTEXT_ENTRY_RSVD_LO (0xff0ULL | ~VTD_HAW_MASK) +#define VTD_CONTEXT_ENTRY_RSVD_LO (aw) (0xff0ULL | ~VTD_HAW_MASK(aw))/* hi */ #define VTD_CONTEXT_ENTRY_AW 7ULL/* Adjusted guest-address-width */ #define VTD_CONTEXT_ENTRY_DID (val) (((val) >> 8) & VTD_DOMAIN_ID_MASK)
@@ -439,7 +457,7 @@ typedef struct VTDRootEntry VTDRootEntry;#define VTD_SL_RW_MASK 3ULL#define VTD_SL_R 1ULL#define VTD_SL_W (1ULL << 1) -#define VTD_SL_PT_BASE_ADDR_MASK (~(VTD_PAGE_SIZE - 1) & VTD_HAW_MASK) +#define VTD_SL_PT_BASE_ADDR_MASK (aw) (~(VTD_PAGE_SIZE - 1) & VTD_HAW_MASK(aw))#define VTD_SL_IGN_COM 0xbff0000000000000ULL#endif
include/hw/i386/intel_iommu.h +4 -2
@@ -46,8 +46,10 @@#define VTD_SID_TO_DEVFN (sid) ((sid) & 0xff)#define DMAR_REG_SIZE 0x230 -#define VTD_HOST_ADDRESS_WIDTH 39 -#define VTD_HAW_MASK ((1ULL << VTD_HOST_ADDRESS_WIDTH) - 1) +#define VTD_HOST_AW_39BIT 39 +#define VTD_HOST_AW_48BIT 48 +#define VTD_HOST_ADDRESS_WIDTH VTD_HOST_AW_39BIT +#define VTD_HAW_MASK (aw) ((1ULL << (aw)) - 1)#define DMAR_REPORT_F_INTR (1)
Signature · 1 line
2.11.0
PATCH 87/113 intel-iommu: Extend address width to 48 bits
In reply to Michael RothFrom: Prasad Singamsetty <[email protected]>
The current implementation of Intel IOMMU code only supports 39 bits iova address width. This patch provides a new parameter (x-aw-bits) for intel-iommu to extend its address width to 48 bits but keeping the default the same (39 bits). The reason for not changing the default is to avoid potential compatibility problems with live migration of intel-iommu enabled QEMU guest. The only valid values for 'x-aw-bits' parameter are 39 and 48.
After enabling larger address width (48), we should be able to map larger iova addresses in the guest. For example, a QEMU guest that is configured with large memory ( >=1TB ). To check whether 48 bits aw is enabled, we can grep in the guest dmesg output with line:
"DMAR: Host address width 48".
--- hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 101 ++++++++++++++++++++++++----------------- hw/i386/intel_iommu_internal.h | 9 ++-- include/hw/i386/intel_iommu.h | 1 + 4 files changed, 65 insertions(+), 49 deletions(-)
hw/i386/acpi-build.c +2 -1
@@ -2460,6 +2460,7 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker)AcpiDmarDeviceScope *scope =NULL ;/* Root complex IOAPIC use one path[0] only */ size_t ioapic_scope_size =sizeof (*scope) +sizeof (scope->path[0 ]); +IntelIOMMUState *intel_iommu =INTEL_IOMMU_DEVICE (iommu);assert (iommu);if (iommu->intr_supported) {
@@ -2467,7 +2468,7 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker) } dmar =acpi_data_push (table_data,sizeof (*dmar)); - dmar->host_address_width =VTD_HOST_ADDRESS_WIDTH -1 ; + dmar->host_address_width = intel_iommu->aw_bits -1 ; dmar->flags = dmar_flags;/* DMAR Remapping Hardware Unit Definition structure */
hw/i386/intel_iommu.c +59 -42
292 lines not on this page · raw message
hw/i386/intel_iommu_internal.h +3 -6
@@ -131,7 +131,7 @@#define VTD_TLB_DID (val) (((val) >> 32) & VTD_DOMAIN_ID_MASK)/* IVA_REG */ -#define VTD_IVA_ADDR (val) ((val) & ~0xfffULL & ((1ULL << VTD_MGAW) - 1)) +#define VTD_IVA_ADDR (val) ((val) & ~0xfffULL)#define VTD_IVA_AM (val) ((val) & 0x3fULL)/* GCMD_REG */
@@ -197,7 +197,6 @@#define VTD_DOMAIN_ID_SHIFT 16/* 16-bit domain id for 64K domains */ #define VTD_DOMAIN_ID_MASK ((1UL << VTD_DOMAIN_ID_SHIFT) - 1)#define VTD_CAP_ND (((VTD_DOMAIN_ID_SHIFT - 4) / 2) & 7ULL) -#define VTD_MGAW 39/* Maximum Guest Address Width */ #define VTD_ADDRESS_SIZE (aw) (1ULL << (aw))#define VTD_CAP_MGAW (aw) ((((aw) - 1) & 0x3fULL) << 16)#define VTD_MAMV 18ULL
@@ -213,7 +212,6 @@#define VTD_CAP_SAGAW_39bit (0x2ULL << VTD_CAP_SAGAW_SHIFT)/* 48-bit AGAW, 4-level page-table */ #define VTD_CAP_SAGAW_48bit (0x4ULL << VTD_CAP_SAGAW_SHIFT) -#define VTD_CAP_SAGAW VTD_CAP_SAGAW_39bit/* IQT_REG */ #define VTD_IQT_QT (val) (((val) >> 4) & 0x7fffULL)
@@ -252,7 +250,7 @@#define VTD_FRCD_SID_MASK 0xffffULL#define VTD_FRCD_SID (val) ((val) & VTD_FRCD_SID_MASK)/* For the low 64-bit of 128-bit */ -#define VTD_FRCD_FI (val) ((val) & (((1ULL << VTD_MGAW) - 1) ^ 0xfffULL)) +#define VTD_FRCD_FI (val) ((val) & ~0xfffULL)/* DMA Remapping Fault Conditions */ typedef enum VTDFaultReason {
@@ -360,8 +358,7 @@ typedef union VTDInvDesc VTDInvDesc;#define VTD_INV_DESC_IOTLB_DOMAIN (2ULL << 4)#define VTD_INV_DESC_IOTLB_PAGE (3ULL << 4)#define VTD_INV_DESC_IOTLB_DID (val) (((val) >> 16) & VTD_DOMAIN_ID_MASK) -#define VTD_INV_DESC_IOTLB_ADDR (val) ((val) & ~0xfffULL & \ - ((1ULL << VTD_MGAW) - 1)) +#define VTD_INV_DESC_IOTLB_ADDR (val) ((val) & ~0xfffULL)#define VTD_INV_DESC_IOTLB_AM (val) ((val) & 0x3fULL)#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000ff00ULL#define VTD_INV_DESC_IOTLB_RSVD_HI 0xf80ULL
include/hw/i386/intel_iommu.h +1 -0
@@ -304,6 +304,7 @@ struct IntelIOMMUState {bool intr_eime;/* Extended interrupt mode enabled */ OnOffAuto intr_eim;/* Toggle for EIM cabability */ bool buggy_eim;/* Force buggy EIM unless eim=off */ +uint8_t aw_bits;/* Host/IOVA address width (in bits) */ };/* Find the VTD Address space associated with the given bus pointer,
Signature · 1 line
2.11.0
PATCH 88/113 intel-iommu: send PSI always even if across PDEs
In reply to Michael RothFrom: Peter Xu <[email protected]>
SECURITY IMPLICATION: without this patch, any guest with both assigned device and a vIOMMU might encounter stale IO page mappings even if guest has already unmapped the page, which may lead to guest memory corruption. The stale mappings will only be limited to the guest's own memory range, so it should not affect the host memory or other guests on the host.
During IOVA page table walking, there is a special case when the PSI covers one whole PDE (Page Directory Entry, which contains 512 Page Table Entries) or more. In the past, we skip that entry and we don't notify the IOMMU notifiers. This is not correct. We should send UNMAP notification to registered UNMAP notifiers in this case.
For UNMAP only notifiers, this might cause IOTLBs cached in the devices even if they were already invalid. For MAP/UNMAP notifiers like vfio-pci, this will cause stale page mappings.
This special case doesn't trigger often, but it is very easy to be triggered by nested device assignments, since in that case we'll possibly map the whole L2 guest RAM region into the device's IOVA address space (several GBs at least), which is far bigger than normal kernel driver usages of the device (tens of MBs normally).
Without this patch applied to L1 QEMU, nested device assignment to L2 guests will dump some errors like:
qemu-system-x86_64: VFIO_MAP_DMA: -17
qemu-system-x86_64: vfio_dma_map(0x557305420c30, 0xad000, 0x1000,
0x7f89a920d000) = -17 (File exists)
--- hw/i386/intel_iommu.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-)
hw/i386/intel_iommu.c +30 -12
@@ -722,6 +722,15 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,typedef int (*vtd_page_walk_hook )(IOMMUTLBEntry *entry,void *private); +static int vtd_page_walk_one (IOMMUTLBEntry *entry,int level, +vtd_page_walk_hook hook_fn,void *private) +{ +assert (hook_fn); +trace_vtd_page_walk_one (level, entry->iova, entry->translated_addr, + entry->addr_mask, entry->perm); +return hook_fn (entry, private); +} +/** * vtd_page_walk_level - walk over specific level for IOVA range *
@@ -781,28 +790,37 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,*/ entry_valid = read_cur | write_cur; + entry.target_as = &address_space_memory; + entry.iova = iova & subpage_mask; + entry.perm =IOMMU_ACCESS_FLAG (read_cur, write_cur); + entry.addr_mask = ~subpage_mask; +if (vtd_is_last_slpte (slpte, level)) { - entry.target_as = &address_space_memory; - entry.iova = iova & subpage_mask;/* NOTE: this is only meaningful if entry_valid == true */ entry.translated_addr =vtd_get_slpte_addr (slpte, aw); - entry.addr_mask = ~subpage_mask; - entry.perm =IOMMU_ACCESS_FLAG (read_cur, write_cur);if (!entry_valid && !notify_unmap) {trace_vtd_page_walk_skip_perm (iova, iova_next); goto next; } -trace_vtd_page_walk_one (level, entry.iova, entry.translated_addr, - entry.addr_mask, entry.perm); -if (hook_fn) { - ret =hook_fn (&entry, private); -if (ret <0 ) { -return ret; - } + ret =vtd_page_walk_one (&entry, level, hook_fn, private); +if (ret <0 ) { +return ret; } }else {if (!entry_valid) { -trace_vtd_page_walk_skip_perm (iova, iova_next); +if (notify_unmap) { +/* +* The whole entry is invalid; unmap it all. +* Translated address is meaningless, zero it. +*/ + entry.translated_addr =0x0 ; + ret =vtd_page_walk_one (&entry, level, hook_fn, private); +if (ret <0 ) { +return ret; + } + }else { +trace_vtd_page_walk_skip_perm (iova, iova_next); + } goto next; } ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw), iova,
Signature · 1 line
2.11.0
PATCH 89/113 intel-iommu: remove IntelIOMMUNotifierNode
In reply to Michael RothFrom: Peter Xu <[email protected]>
That is not really necessary. Removing that node struct and put the list entry directly into VTDAddressSpace. It simplfies the code a lot. Since at it, rename the old notifiers_list into vtd_as_with_notifiers.
--- hw/i386/intel_iommu.c | 41 +++++++++++------------------------------ include/hw/i386/intel_iommu.h | 9 ++------- 2 files changed, 13 insertions(+), 37 deletions(-)
hw/i386/intel_iommu.c +11 -30
@@ -1248,10 +1248,10 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s)static void vtd_iommu_replay_all (IntelIOMMUState *s) { -IntelIOMMUNotifierNode *node; +VTDAddressSpace *vtd_as; - QLIST_FOREACH(node, &s->notifiers_list, next) { -memory_region_iommu_replay_all (&node->vtd_as->iommu); + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { +memory_region_iommu_replay_all (&vtd_as->iommu); } }
@@ -1372,7 +1372,6 @@ static void vtd_iotlb_global_invalidate(IntelIOMMUState *s)static void vtd_iotlb_domain_invalidate (IntelIOMMUState *s,uint16_t domain_id) { -IntelIOMMUNotifierNode *node;VTDContextEntry ce;VTDAddressSpace *vtd_as;
@@ -1381,8 +1380,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)g_hash_table_foreach_remove (s->iotlb, vtd_hash_remove_by_domain, &domain_id); - QLIST_FOREACH(node, &s->notifiers_list, next) { - vtd_as = node->vtd_as; + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) {if (!vtd_dev_to_context_entry (s,pci_bus_num (vtd_as->bus), vtd_as->devfn, &ce) && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) {
@@ -1402,12 +1400,11 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, uint16_t domain_id, hwaddr addr, uint8_t am) { - IntelIOMMUNotifierNode *node; + VTDAddressSpace *vtd_as;VTDContextEntry ce;int ret; - QLIST_FOREACH(node, &(s->notifiers_list), next) { -VTDAddressSpace *vtd_as = node->vtd_as; + QLIST_FOREACH(vtd_as, &(s->vtd_as_with_notifiers), next) { ret =vtd_dev_to_context_entry (s,pci_bus_num (vtd_as->bus), vtd_as->devfn, &ce);if (!ret && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) {
@@ -2337,8 +2334,6 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, {VTDAddressSpace *vtd_as =container_of (iommu, VTDAddressSpace, iommu);IntelIOMMUState *s = vtd_as->iommu_state; -IntelIOMMUNotifierNode *node =NULL ; -IntelIOMMUNotifierNode *next_node =NULL ;if (!s->caching_mode && new &IOMMU_NOTIFIER_MAP ) { error_report("We need to set cache_mode=1 for intel-iommu to enable "
@@ -2347,21 +2342,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, }if (old ==IOMMU_NOTIFIER_NONE ) { - node =g_malloc0 (sizeof (*node)); - node->vtd_as = vtd_as; -QLIST_INSERT_HEAD (&s->notifiers_list, node, next); -return ; - } - -/* update notifier node with new flags */ - QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { -if (node->vtd_as == vtd_as) { -if (new ==IOMMU_NOTIFIER_NONE ) { -QLIST_REMOVE (node, next); -g_free (node); - } -return ; - } +QLIST_INSERT_HEAD (&s->vtd_as_with_notifiers, vtd_as, next); + }else if (new ==IOMMU_NOTIFIER_NONE ) { +QLIST_REMOVE (vtd_as, next); } }
@@ -2831,12 +2814,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)static void vtd_address_space_unmap_all (IntelIOMMUState *s) { -IntelIOMMUNotifierNode *node;VTDAddressSpace *vtd_as;IOMMUNotifier *n; - QLIST_FOREACH(node, &s->notifiers_list, next) { - vtd_as = node->vtd_as; + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { IOMMU_NOTIFIER_FOREACH(n, &vtd_as->iommu) {vtd_address_space_unmap (vtd_as, n); }
@@ -3090,7 +3071,7 @@ static void vtd_realize(DeviceState *dev, Error **errp)return ; } -QLIST_INIT (&s->notifiers_list); +QLIST_INIT (&s->vtd_as_with_notifiers);memset (s->vtd_as_by_bus_num,0 ,sizeof (s->vtd_as_by_bus_num));memory_region_init_io (&s->csrmem,OBJECT (s), &vtd_mem_ops, s,"intel_iommu" ,DMAR_REG_SIZE );
include/hw/i386/intel_iommu.h +2 -7
@@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress ;typedef struct VTDIrq VTDIrq ;typedef struct VTD_MSIMessage VTD_MSIMessage ; -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode ;/* Context-Entry */ struct VTDContextEntry {
@@ -93,6 +92,7 @@ struct VTDAddressSpace {MemoryRegion iommu_ir;/* Interrupt region: 0xfeeXXXXX */ IntelIOMMUState *iommu_state;VTDContextCacheEntry context_cache_entry; +QLIST_ENTRY (VTDAddressSpace) next; };struct VTDBus {
@@ -253,11 +253,6 @@ struct VTD_MSIMessage {/* When IR is enabled, all MSI/MSI-X data bits should be zero */ #define VTD_IR_MSI_DATA (0) -struct IntelIOMMUNotifierNode { -VTDAddressSpace *vtd_as; -QLIST_ENTRY (IntelIOMMUNotifierNode) next; -}; -/* The iommu (DMAR) device state struct */ struct IntelIOMMUState {X86IOMMUState x86_iommu;
@@ -295,7 +290,7 @@ struct IntelIOMMUState {GHashTable *vtd_as_by_busptr;/* VTDBus objects indexed by PCIBus* reference */ VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX ];/* VTDBus objects indexed by bus number */ /* list of registered notifiers */ - QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list; + QLIST_HEAD(, VTDAddressSpace) vtd_as_with_notifiers;/* interrupt remapping */ bool intr_enabled;/* Whether guest enabled IR */
Signature · 1 line
2.11.0
PATCH 90/113 intel-iommu: add iommu lock
In reply to Michael RothFrom: Peter Xu <[email protected]>
SECURITY IMPLICATION: this patch fixes a potential race when multiple threads access the IOMMU IOTLB cache.
Add a per-iommu big lock to protect IOMMU status. Currently the only thing to be protected is the IOTLB/context cache, since that can be accessed even without BQL, e.g., in IO dataplane.
Note that we don't need to protect device page tables since that's fully controlled by the guest kernel. However there is still possibility that malicious drivers will program the device to not obey the rule. In that case QEMU can't really do anything useful, instead the guest itself will be responsible for all uncertainties.
--- hw/i386/intel_iommu.c | 56 ++++++++++++++++++++++++++++++++++++------- include/hw/i386/intel_iommu.h | 6 +++++ 2 files changed, 53 insertions(+), 9 deletions(-)
hw/i386/intel_iommu.c +47 -9
@@ -128,6 +128,16 @@ static uint64_t vtd_set_clear_mask_quad(IntelIOMMUState *s, hwaddr addr,return new_val; } +static inline void vtd_iommu_lock (IntelIOMMUState *s) +{ +qemu_mutex_lock (&s->iommu_lock); +} + +static inline void vtd_iommu_unlock (IntelIOMMUState *s) +{ +qemu_mutex_unlock (&s->iommu_lock); +} +/* GHashTable functions */ static gboolean vtd_uint64_equal (gconstpointer v1,gconstpointer v2) {
@@ -172,9 +182,9 @@ static gboolean vtd_hash_remove_by_page(gpointer key, gpointer value, }/* Reset all the gen of VTDAddressSpace to zero and set the gen of -* IntelIOMMUState to 1. +* IntelIOMMUState to 1. Must be called with IOMMU lock held. */ -static void vtd_reset_context_cache (IntelIOMMUState *s) +static void vtd_reset_context_cache_locked (IntelIOMMUState *s) {VTDAddressSpace *vtd_as;VTDBus *vtd_bus;
@@ -197,12 +207,20 @@ static void vtd_reset_context_cache(IntelIOMMUState *s) s->context_cache_gen =1 ; } -static void vtd_reset_iotlb (IntelIOMMUState *s) +/* Must be called with IOMMU lock held. */ +static void vtd_reset_iotlb_locked (IntelIOMMUState *s) {assert (s->iotlb);g_hash_table_remove_all (s->iotlb); } +static void vtd_reset_iotlb (IntelIOMMUState *s) +{ +vtd_iommu_lock (s); +vtd_reset_iotlb_locked (s); +vtd_iommu_unlock (s); +} +static uint64_t vtd_get_iotlb_key (uint64_t gfn,uint16_t source_id,uint32_t level) {
@@ -215,6 +233,7 @@ static uint64_t vtd_get_iotlb_gfn(hwaddr addr, uint32_t level)return (addr &vtd_slpt_level_page_mask (level)) >>VTD_PAGE_SHIFT_4K ; } +/* Must be called with IOMMU lock held */ static VTDIOTLBEntry *vtd_lookup_iotlb (IntelIOMMUState *s,uint16_t source_id,hwaddr addr) {
@@ -235,6 +254,7 @@ out:return entry; } +/* Must be with IOMMU lock held */ static void vtd_update_iotlb (IntelIOMMUState *s,uint16_t source_id,uint16_t domain_id,hwaddr addr,uint64_t slpte,uint8_t access_flags,uint32_t level)
@@ -246,7 +266,7 @@ static void vtd_update_iotlb(IntelIOMMUState *s, uint16_t source_id,trace_vtd_iotlb_page_update (source_id, addr, slpte, domain_id);if (g_hash_table_size (s->iotlb) >=VTD_IOTLB_MAX_SIZE ) {trace_vtd_iotlb_reset ("iotlb exceeds size limit" ); -vtd_reset_iotlb (s); +vtd_reset_iotlb_locked (s); } entry->gfn = gfn;
@@ -1106,7 +1126,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,IntelIOMMUState *s = vtd_as->iommu_state;VTDContextEntry ce;uint8_t bus_num =pci_bus_num (bus); -VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry; +VTDContextCacheEntry *cc_entry;uint64_t slpte, page_mask;uint32_t level;uint16_t source_id =vtd_make_source_id (bus_num, devfn);
@@ -1123,6 +1143,10 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,*/ assert (!vtd_is_interrupt_addr (addr)); +vtd_iommu_lock (s); + + cc_entry = &vtd_as->context_cache_entry; +/* Try to fetch slpte form IOTLB */ iotlb_entry =vtd_lookup_iotlb (s, source_id, addr);if (iotlb_entry) {
@@ -1182,7 +1206,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,* IOMMU region can be swapped back. */ vtd_pt_enable_fast_path (s, source_id); - +vtd_iommu_unlock (s);return true; }
@@ -1203,6 +1227,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,vtd_update_iotlb (s, source_id,VTD_CONTEXT_ENTRY_DID (ce.hi), addr, slpte, access_flags, level); out: +vtd_iommu_unlock (s); entry->iova = addr & page_mask; entry->translated_addr =vtd_get_slpte_addr (slpte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask;
@@ -1210,6 +1235,7 @@ out:return true; error: +vtd_iommu_unlock (s); entry->iova =0 ; entry->translated_addr =0 ; entry->addr_mask =0 ;
@@ -1258,10 +1284,13 @@ static void vtd_iommu_replay_all(IntelIOMMUState *s)static void vtd_context_global_invalidate (IntelIOMMUState *s) {trace_vtd_inv_desc_cc_global (); +/* Protects context cache */ +vtd_iommu_lock (s); s->context_cache_gen++;if (s->context_cache_gen ==VTD_CONTEXT_CACHE_GEN_MAX ) { -vtd_reset_context_cache (s); +vtd_reset_context_cache_locked (s); } +vtd_iommu_unlock (s);vtd_switch_address_space_all (s);/* * From VT-d spec 6.5.2.1, a global context entry invalidation
@@ -1313,7 +1342,9 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {trace_vtd_inv_desc_cc_device (bus_n,VTD_PCI_SLOT (devfn_it),VTD_PCI_FUNC (devfn_it)); +vtd_iommu_lock (s); vtd_as->context_cache_entry.context_cache_gen =0 ; +vtd_iommu_unlock (s);/* * Do switch address space when needed, in case if the * device passthrough bit is switched.
@@ -1377,8 +1408,10 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)trace_vtd_inv_desc_iotlb_domain (domain_id); +vtd_iommu_lock (s);g_hash_table_foreach_remove (s->iotlb, vtd_hash_remove_by_domain, &domain_id); +vtd_iommu_unlock (s); QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),
@@ -1426,7 +1459,9 @@ static void vtd_iotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, info.domain_id = domain_id; info.addr = addr; info.mask = ~((1 << am) -1 ); +vtd_iommu_lock (s);g_hash_table_foreach_remove (s->iotlb, vtd_hash_remove_by_page, &info); +vtd_iommu_unlock (s);vtd_iotlb_page_invalidate_notify (s, domain_id, addr, am); }
@@ -2922,8 +2957,10 @@ static void vtd_init(IntelIOMMUState *s) s->cap |=VTD_CAP_CM ; } -vtd_reset_context_cache (s); -vtd_reset_iotlb (s); +vtd_iommu_lock (s); +vtd_reset_context_cache_locked (s); +vtd_reset_iotlb_locked (s); +vtd_iommu_unlock (s);/* Define registers with default values and bit semantics */ vtd_define_long (s,DMAR_VER_REG ,0x10UL ,0 ,0 );
@@ -3072,6 +3109,7 @@ static void vtd_realize(DeviceState *dev, Error **errp) }QLIST_INIT (&s->vtd_as_with_notifiers); +qemu_mutex_init (&s->iommu_lock);memset (s->vtd_as_by_bus_num,0 ,sizeof (s->vtd_as_by_bus_num));memory_region_init_io (&s->csrmem,OBJECT (s), &vtd_mem_ops, s,"intel_iommu" ,DMAR_REG_SIZE );
include/hw/i386/intel_iommu.h +6 -0
@@ -300,6 +300,12 @@ struct IntelIOMMUState {OnOffAuto intr_eim;/* Toggle for EIM cabability */ bool buggy_eim;/* Force buggy EIM unless eim=off */ uint8_t aw_bits;/* Host/IOVA address width (in bits) */ + +/* +* Protects IOMMU states in general. Currently it protects the +* per-IOMMU IOTLB cache, and context entry cache in VTDAddressSpace. +*/ +QemuMutex iommu_lock; };/* Find the VTD Address space associated with the given bus pointer,
Signature · 1 line
2.11.0
PATCH 8/113 spapr: set vsmt to MAX(8, smp_threads)
In reply to Michael RothFrom: Laurent Vivier <[email protected]>
We ignore silently the value of smp_threads when we set the default VSMT value, and if smp_threads is greater than VSMT kernel is going into trouble later.
("spapr: Adjust default VSMT value for better migration compatibility")
--- hw/ppc/spapr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
@@ -2289,7 +2289,7 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)* the value that we'd get with KVM on POWER8, the * overwhelmingly common case in production systems. */ - spapr->vsmt =8 ; + spapr->vsmt =MAX (8 , smp_threads); }/* KVM: If necessary, set the SMT mode: */
Signature · 1 line
2.11.0
PATCH 91/113 intel-iommu: only do page walk for MAP notifiers
In reply to Michael RothFrom: Peter Xu <[email protected]>
For UNMAP-only IOMMU notifiers, we don't need to walk the page tables. Fasten that procedure by skipping the page table walk. That should boost performance for UNMAP-only notifiers like vhost.
--- hw/i386/intel_iommu.c | 44 ++++++++++++++++++++++++++++++++++++++----- include/hw/i386/intel_iommu.h | 2 ++ 2 files changed, 41 insertions(+), 5 deletions(-)
hw/i386/intel_iommu.c +39 -5
@@ -138,6 +138,12 @@ static inline void vtd_iommu_unlock(IntelIOMMUState *s)qemu_mutex_unlock (&s->iommu_lock); } +/* Whether the address space needs to notify new mappings */ +static inline gboolean vtd_as_has_map_notifier (VTDAddressSpace *as) +{ +return as->notifier_flags &IOMMU_NOTIFIER_MAP ; +} +/* GHashTable functions */ static gboolean vtd_uint64_equal (gconstpointer v1,gconstpointer v2) {
@@ -1436,14 +1442,36 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,VTDAddressSpace *vtd_as;VTDContextEntry ce;int ret; +hwaddr size = (1 << am) *VTD_PAGE_SIZE ; QLIST_FOREACH(vtd_as, &(s->vtd_as_with_notifiers), next) { ret =vtd_dev_to_context_entry (s,pci_bus_num (vtd_as->bus), vtd_as->devfn, &ce);if (!ret && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) { -vtd_page_walk (&ce, addr, addr + (1 << am) *VTD_PAGE_SIZE , - vtd_page_invalidate_notify_hook, - (void *)&vtd_as->iommu, true, s->aw_bits); +if (vtd_as_has_map_notifier (vtd_as)) { +/* +* As long as we have MAP notifications registered in +* any of our IOMMU notifiers, we need to sync the +* shadow page table. +*/ +vtd_page_walk (&ce, addr, addr + size, + vtd_page_invalidate_notify_hook, + (void *)&vtd_as->iommu, true, s->aw_bits); + }else { +/* +* For UNMAP-only notifiers, we don't need to walk the +* page tables. We just deliver the PSI down to +* invalidate caches. +*/ +IOMMUTLBEntry entry = { + .target_as = &address_space_memory, + .iova = addr, + .translated_addr =0 , + .addr_mask = size -1 , + .perm =IOMMU_NONE , + }; +memory_region_notify_iommu (&vtd_as->iommu, entry); + } } } }
@@ -2376,6 +2404,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,exit (1 ); } +/* Update per-address-space notifier flags */ + vtd_as->notifier_flags = new; +if (old ==IOMMU_NOTIFIER_NONE ) {QLIST_INSERT_HEAD (&s->vtd_as_with_notifiers, vtd_as, next); }else if (new ==IOMMU_NOTIFIER_NONE ) {
@@ -2884,8 +2915,11 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)PCI_FUNC (vtd_as->devfn),VTD_CONTEXT_ENTRY_DID (ce.hi), ce.hi, ce.lo); -vtd_page_walk (&ce,0 , ~0ULL , vtd_replay_hook, (void *)n, false, - s->aw_bits); +if (vtd_as_has_map_notifier (vtd_as)) { +/* This is required only for MAP typed notifiers */ +vtd_page_walk (&ce,0 , ~0ULL , vtd_replay_hook, (void *)n, false, + s->aw_bits); + } }else {trace_vtd_replay_ce_invalid (bus_n,PCI_SLOT (vtd_as->devfn),PCI_FUNC (vtd_as->devfn));
include/hw/i386/intel_iommu.h +2 -0
@@ -93,6 +93,8 @@ struct VTDAddressSpace {IntelIOMMUState *iommu_state;VTDContextCacheEntry context_cache_entry;QLIST_ENTRY (VTDAddressSpace) next; +/* Superset of notifier flags that this address space has */ +IOMMUNotifierFlag notifier_flags; };struct VTDBus {
Signature · 1 line
2.11.0
PATCH 92/113 intel-iommu: introduce vtd_page_walk_info
In reply to Michael RothFrom: Peter Xu <[email protected]>
During the recursive page walking of IOVA page tables, some stack variables are constant variables and never changed during the whole page walking procedure. Isolate them into a struct so that we don't need to pass those contants down the stack every time and multiple times.
--- hw/i386/intel_iommu.c | 84 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 32 deletions(-)
hw/i386/intel_iommu.c +52 -32
@@ -748,9 +748,27 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,typedef int (*vtd_page_walk_hook )(IOMMUTLBEntry *entry,void *private); +/** +* Constant information used during page walking +* +* @hook_fn: hook func to be called when detected page +* @private: private data to be passed into hook func +* @notify_unmap: whether we should notify invalid entries +* @aw: maximum address width +*/ +typedef struct { +vtd_page_walk_hook hook_fn; +void *private; +bool notify_unmap; +uint8_t aw; +}vtd_page_walk_info ; +static int vtd_page_walk_one (IOMMUTLBEntry *entry,int level, -vtd_page_walk_hook hook_fn,void *private) +vtd_page_walk_info *info) { +vtd_page_walk_hook hook_fn = info->hook_fn; +void *private = info->private; +assert (hook_fn);trace_vtd_page_walk_one (level, entry->iova, entry->translated_addr, entry->addr_mask, entry->perm);
@@ -763,17 +781,13 @@ static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level,* @addr: base GPA addr to start the walk * @start: IOVA range start address * @end: IOVA range end address (start <= addr < end) -* @hook_fn: hook func to be called when detected page -* @private: private data to be passed into hook func * @read: whether parent level has read permission * @write: whether parent level has write permission -* @notify_unmap: whether we should notify invalid entries -* @aw: maximum address width +* @info: constant information for the page walk */ static int vtd_page_walk_level (dma_addr_t addr,uint64_t start, -uint64_t end,vtd_page_walk_hook hook_fn, -void *private,uint32_t level,bool read, -bool write,bool notify_unmap,uint8_t aw) +uint64_t end,uint32_t level,bool read, +bool write,vtd_page_walk_info *info) {bool read_cur, write_cur, entry_valid;uint32_t offset;
@@ -823,24 +837,24 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,if (vtd_is_last_slpte (slpte, level)) {/* NOTE: this is only meaningful if entry_valid == true */ - entry.translated_addr =vtd_get_slpte_addr (slpte, aw); -if (!entry_valid && !notify_unmap) { + entry.translated_addr =vtd_get_slpte_addr (slpte, info->aw); +if (!entry_valid && !info->notify_unmap) {trace_vtd_page_walk_skip_perm (iova, iova_next); goto next; } - ret =vtd_page_walk_one (&entry, level, hook_fn, private); + ret =vtd_page_walk_one (&entry, level, info);if (ret <0 ) {return ret; } }else {if (!entry_valid) { -if (notify_unmap) { +if (info->notify_unmap) {/* * The whole entry is invalid; unmap it all. * Translated address is meaningless, zero it. */ entry.translated_addr =0x0 ; - ret =vtd_page_walk_one (&entry, level, hook_fn, private); + ret =vtd_page_walk_one (&entry, level, info);if (ret <0 ) {return ret; }
@@ -849,10 +863,9 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, } goto next; } - ret =vtd_page_walk_level (vtd_get_slpte_addr (slpte, aw), iova, -MIN (iova_next, end), hook_fn, private, - level -1 , read_cur, write_cur, - notify_unmap, aw); + ret =vtd_page_walk_level (vtd_get_slpte_addr (slpte, info->aw), + iova,MIN (iova_next, end), level -1 , + read_cur, write_cur, info);if (ret <0 ) {return ret; }
@@ -871,28 +884,24 @@ next:* @ce: context entry to walk upon * @start: IOVA address to start the walk * @end: IOVA range end address (start <= addr < end) -* @hook_fn: the hook that to be called for each detected area -* @private: private data for the hook function -* @aw: maximum address width +* @info: page walking information struct */ static int vtd_page_walk (VTDContextEntry *ce,uint64_t start,uint64_t end, -vtd_page_walk_hook hook_fn,void *private, -bool notify_unmap,uint8_t aw) +vtd_page_walk_info *info) {dma_addr_t addr =vtd_ce_get_slpt_base (ce);uint32_t level =vtd_ce_get_level (ce); -if (!vtd_iova_range_check (start, ce, aw)) { +if (!vtd_iova_range_check (start, ce, info->aw)) {return -VTD_FR_ADDR_BEYOND_MGAW ; } -if (!vtd_iova_range_check (end, ce, aw)) { +if (!vtd_iova_range_check (end, ce, info->aw)) {/* Fix end so that it reaches the maximum */ - end =vtd_iova_limit (ce, aw); + end =vtd_iova_limit (ce, info->aw); } -return vtd_page_walk_level (addr, start, end, hook_fn, private, - level, true, true, notify_unmap, aw); +return vtd_page_walk_level (addr, start, end, level, true, true, info); }/* Map a device to its corresponding domain (context-entry) */
@@ -1449,14 +1458,19 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, vtd_as->devfn, &ce);if (!ret && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) {if (vtd_as_has_map_notifier (vtd_as)) { +vtd_page_walk_info info = { + .hook_fn = vtd_page_invalidate_notify_hook, + .private = (void *)&vtd_as->iommu, + .notify_unmap = true, + .aw = s->aw_bits, + }; +/* * As long as we have MAP notifications registered in * any of our IOMMU notifiers, we need to sync the * shadow page table. */ -vtd_page_walk (&ce, addr, addr + size, - vtd_page_invalidate_notify_hook, - (void *)&vtd_as->iommu, true, s->aw_bits); +vtd_page_walk (&ce, addr, addr + size, &info); }else {/* * For UNMAP-only notifiers, we don't need to walk the
@@ -2917,8 +2931,14 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) ce.hi, ce.lo);if (vtd_as_has_map_notifier (vtd_as)) {/* This is required only for MAP typed notifiers */ -vtd_page_walk (&ce,0 , ~0ULL , vtd_replay_hook, (void *)n, false, - s->aw_bits); +vtd_page_walk_info info = { + .hook_fn = vtd_replay_hook, + .private = (void *)n, + .notify_unmap = false, + .aw = s->aw_bits, + }; + +vtd_page_walk (&ce,0 , ~0ULL , &info); } }else { trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn),
Signature · 1 line
2.11.0
PATCH 93/113 intel-iommu: pass in address space when page walk
In reply to Michael RothFrom: Peter Xu <[email protected]>
We pass in the VTDAddressSpace too. It'll be used in the follow up patches.
--- hw/i386/intel_iommu.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/intel_iommu.c +4 -0
@@ -754,9 +754,11 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);* @hook_fn: hook func to be called when detected page * @private: private data to be passed into hook func * @notify_unmap: whether we should notify invalid entries +* @as: VT-d address space of the device * @aw: maximum address width */ typedef struct { + VTDAddressSpace *as; vtd_page_walk_hook hook_fn; void *private; bool notify_unmap;
@@ -1463,6 +1465,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .private = (void *)&vtd_as->iommu, .notify_unmap = true, .aw = s->aw_bits, + .as = vtd_as, };/*
@@ -2936,6 +2939,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .private = (void *)n, .notify_unmap = false, .aw = s->aw_bits, + .as = vtd_as, };vtd_page_walk (&ce,0 , ~0ULL , &info);
Signature · 1 line
2.11.0
PATCH 94/113 intel-iommu: trace domain id during page walk
In reply to Michael RothFrom: Peter Xu <[email protected]>
This patch only modifies the trace points.
Previously we were tracing page walk levels. They are redundant since we have page mask (size) already. Now we trace something much more useful which is the domain ID of the page walking. That can be very useful when we trace more than one devices on the same system, so that we can know which map is for which domain.
--- hw/i386/intel_iommu.c | 16 ++++++++++------ hw/i386/trace-events | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-)
hw/i386/intel_iommu.c +10 -6
@@ -756,6 +756,7 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);* @notify_unmap: whether we should notify invalid entries * @as: VT-d address space of the device * @aw: maximum address width +* @domain: domain ID of the page walk */ typedef struct { VTDAddressSpace *as;
@@ -763,17 +764,18 @@ typedef struct {void *private;bool notify_unmap;uint8_t aw; +uint16_t domain_id; } vtd_page_walk_info; -static int vtd_page_walk_one (IOMMUTLBEntry *entry,int level, -vtd_page_walk_info *info) +static int vtd_page_walk_one (IOMMUTLBEntry *entry,vtd_page_walk_info *info) {vtd_page_walk_hook hook_fn = info->hook_fn;void *private = info->private;assert (hook_fn); -trace_vtd_page_walk_one (level, entry->iova, entry->translated_addr, - entry->addr_mask, entry->perm); +trace_vtd_page_walk_one (info->domain_id, entry->iova, + entry->translated_addr, entry->addr_mask, + entry->perm);return hook_fn (entry, private); }
@@ -844,7 +846,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,trace_vtd_page_walk_skip_perm (iova, iova_next); goto next; } - ret =vtd_page_walk_one (&entry, level, info); + ret =vtd_page_walk_one (&entry, info);if (ret <0 ) {return ret; }
@@ -856,7 +858,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,* Translated address is meaningless, zero it. */ entry.translated_addr =0x0 ; - ret =vtd_page_walk_one (&entry, level, info); + ret =vtd_page_walk_one (&entry, info);if (ret <0 ) {return ret; }
@@ -1466,6 +1468,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .notify_unmap = true, .aw = s->aw_bits, .as = vtd_as, + .domain_id = domain_id, };/*
@@ -2940,6 +2943,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .notify_unmap = false, .aw = s->aw_bits, .as = vtd_as, + .domain_id = VTD_CONTEXT_ENTRY_DID(ce.hi), };vtd_page_walk (&ce,0 , ~0ULL , &info);
hw/i386/trace-events +1 -1
@@ -39,7 +39,7 @@ vtd_fault_disabled(void) "Fault processing disabled for context entry" vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 -vtd_page_walk_one(uint32_t level, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "detected page level 0x%"PRIx32" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set"
Signature · 1 line
2.11.0
PATCH 95/113 util: implement simple iova tree
In reply to Michael RothFrom: Peter Xu <[email protected]>
Introduce a simplest iova tree implementation based on GTree.
Conflicts:
util/Makefile.objs
* drop context dep
--- MAINTAINERS | 6 +++ include/qemu/iova-tree.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++ util/Makefile.objs | 1 + util/iova-tree.c | 114 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 255 insertions(+) create mode 100644 include/qemu/iova-tree.h create mode 100644 util/iova-tree.c
MAINTAINERS +6 -0
@@ -1680,6 +1680,12 @@ F: include/sysemu/replay.h F: docs/replay.txt F: stubs/replay.c +IOVA Tree +M: Peter Xu <[email protected]> +S: Maintained +F: include/qemu/iova-tree.h +F: util/iova-tree.c + Usermode Emulation ------------------ Overall
include/qemu/iova-tree.h new file +134 -0
134 lines not on this page · raw message
util/Makefile.objs +1 -0
@@ -46,3 +46,4 @@ util-obj-y += qht.o util-obj-y += range.o util-obj-y += stats64.o util-obj-y += systemd.o +util-obj-y += iova-tree.o
util/iova-tree.c new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 97/113 arm_gicv3_kvm: increase clroffset accordingly
In reply to Michael RothFrom: Shannon Zhao <[email protected]>
It forgot to increase clroffset during the loop. So it only clear the first 4 bytes.
Message-id: [email protected]
--- hw/intc/arm_gicv3_kvm.c | 1 + 1 file changed, 1 insertion(+)
hw/intc/arm_gicv3_kvm.c +1 -0
@@ -243,6 +243,7 @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset,if (clroffset !=0 ) { reg =0 ;kvm_gicd_access (s, clroffset, ®, true); + clroffset +=4 ; } reg = *gic_bmp_ptr32 (bmp, irq);kvm_gicd_access (s, offset, ®, true);
Signature · 1 line
2.11.0
PATCH 96/113 intel-iommu: rework the page walk logic
In reply to Michael RothFrom: Peter Xu <[email protected]>
This patch fixes a potential small window that the DMA page table might be incomplete or invalid when the guest sends domain/context invalidations to a device. This can cause random DMA errors for assigned devices.
This is a major change to the VT-d shadow page walking logic. It includes but is not limited to:
- For each VTDAddressSpace, now we maintain what IOVA ranges we have mapped and what we have not. With that information, now we only send MAP or UNMAP when necessary. Say, we don't send MAP notifies if we know we have already mapped the range, meanwhile we don't send UNMAP notifies if we know we never mapped the range at all.
- Introduce vtd_sync_shadow_page_table[_range] APIs so that we can call in any places to resync the shadow page table for a device.
- When we receive domain/context invalidation, we should not really run the replay logic, instead we use the new sync shadow page table API to resync the whole shadow page table without unmapping the whole region. After this change, we'll only do the page walk once for each domain invalidations (before this, it can be multiple, depending on number of notifiers per address space).
While at it, the page walking logic is also refactored to be simpler.
--- hw/i386/intel_iommu.c | 213 ++++++++++++++++++++++++++++++------------ hw/i386/trace-events | 3 +- include/hw/i386/intel_iommu.h | 2 + 3 files changed, 159 insertions(+), 59 deletions(-)
hw/i386/intel_iommu.c +155 -58
@@ -769,10 +769,77 @@ typedef struct {static int vtd_page_walk_one (IOMMUTLBEntry *entry,vtd_page_walk_info *info) { +VTDAddressSpace *as = info->as;vtd_page_walk_hook hook_fn = info->hook_fn;void *private = info->private; +DMAMap target = { + .iova = entry->iova, + .size = entry->addr_mask, + .translated_addr = entry->translated_addr, + .perm = entry->perm, + }; +DMAMap *mapped =iova_tree_find (as->iova_tree, &target); + +if (entry->perm ==IOMMU_NONE && !info->notify_unmap) { +trace_vtd_page_walk_one_skip_unmap (entry->iova, entry->addr_mask); +return 0 ; + }assert (hook_fn); + +/* Update local IOVA mapped ranges */ +if (entry->perm) { +if (mapped) { +/* If it's exactly the same translation, skip */ +if (!memcmp (mapped, &target,sizeof (target))) { +trace_vtd_page_walk_one_skip_map (entry->iova, entry->addr_mask, + entry->translated_addr); +return 0 ; + }else { +/* +* Translation changed. Normally this should not +* happen, but it can happen when with buggy guest +* OSes. Note that there will be a small window that +* we don't have map at all. But that's the best +* effort we can do. The ideal way to emulate this is +* atomically modify the PTE to follow what has +* changed, but we can't. One example is that vfio +* driver only has VFIO_IOMMU_[UN]MAP_DMA but no +* interface to modify a mapping (meanwhile it seems +* meaningless to even provide one). Anyway, let's +* mark this as a TODO in case one day we'll have +* a better solution. +*/ +IOMMUAccessFlags cache_perm = entry->perm; +int ret; + +/* Emulate an UNMAP */ + entry->perm =IOMMU_NONE ; +trace_vtd_page_walk_one (info->domain_id, + entry->iova, + entry->translated_addr, + entry->addr_mask, + entry->perm); + ret =hook_fn (entry, private); +if (ret) { +return ret; + } +/* Drop any existing mapping */ +iova_tree_remove (as->iova_tree, &target); +/* Recover the correct permission */ + entry->perm = cache_perm; + } + } +iova_tree_insert (as->iova_tree, &target); + }else { +if (!mapped) { +/* Skip since we didn't map this range at all */ +trace_vtd_page_walk_one_skip_unmap (entry->iova, entry->addr_mask); +return 0 ; + } +iova_tree_remove (as->iova_tree, &target); + } +trace_vtd_page_walk_one (info->domain_id, entry->iova, entry->translated_addr, entry->addr_mask, entry->perm);
@@ -834,45 +901,34 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,*/ entry_valid = read_cur | write_cur; - entry.target_as = &address_space_memory; - entry.iova = iova & subpage_mask; - entry.perm =IOMMU_ACCESS_FLAG (read_cur, write_cur); - entry.addr_mask = ~subpage_mask; - -if (vtd_is_last_slpte (slpte, level)) { -/* NOTE: this is only meaningful if entry_valid == true */ - entry.translated_addr =vtd_get_slpte_addr (slpte, info->aw); -if (!entry_valid && !info->notify_unmap) { -trace_vtd_page_walk_skip_perm (iova, iova_next); - goto next; - } - ret =vtd_page_walk_one (&entry, info); -if (ret <0 ) { -return ret; - } - }else { -if (!entry_valid) { -if (info->notify_unmap) { -/* -* The whole entry is invalid; unmap it all. -* Translated address is meaningless, zero it. -*/ - entry.translated_addr =0x0 ; - ret =vtd_page_walk_one (&entry, info); -if (ret <0 ) { -return ret; - } - }else { -trace_vtd_page_walk_skip_perm (iova, iova_next); - } - goto next; - } +if (!vtd_is_last_slpte (slpte, level) && entry_valid) { +/* +* This is a valid PDE (or even bigger than PDE). We need +* to walk one further level. +*/ ret =vtd_page_walk_level (vtd_get_slpte_addr (slpte, info->aw), iova,MIN (iova_next, end), level -1 , read_cur, write_cur, info); -if (ret <0 ) { -return ret; - } + }else { +/* +* This means we are either: +* +* (1) the real page entry (either 4K page, or huge page) +* (2) the whole range is invalid +* +* In either case, we send an IOTLB notification down. +*/ + entry.target_as = &address_space_memory; + entry.iova = iova & subpage_mask; + entry.perm =IOMMU_ACCESS_FLAG (read_cur, write_cur); + entry.addr_mask = ~subpage_mask; +/* NOTE: this is only meaningful if entry_valid == true */ + entry.translated_addr =vtd_get_slpte_addr (slpte, info->aw); + ret =vtd_page_walk_one (&entry, info); + } + +if (ret <0 ) { +return ret; } next:
@@ -964,6 +1020,58 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,return 0 ; } +static int vtd_sync_shadow_page_hook (IOMMUTLBEntry *entry, +void *private) +{ +memory_region_notify_iommu ((IOMMUMemoryRegion *)private, *entry); +return 0 ; +} + +/* If context entry is NULL, we'll try to fetch it on our own. */ +static int vtd_sync_shadow_page_table_range (VTDAddressSpace *vtd_as, +VTDContextEntry *ce, +hwaddr addr,hwaddr size) +{ +IntelIOMMUState *s = vtd_as->iommu_state; +vtd_page_walk_info info = { + .hook_fn = vtd_sync_shadow_page_hook, + .private = (void *)&vtd_as->iommu, + .notify_unmap = true, + .aw = s->aw_bits, + .as = vtd_as, + }; +VTDContextEntry ce_cache; +int ret; + +if (ce) { +/* If the caller provided context entry, use it */ + ce_cache = *ce; + }else { +/* If the caller didn't provide ce, try to fetch */ + ret =vtd_dev_to_context_entry (s,pci_bus_num (vtd_as->bus), + vtd_as->devfn, &ce_cache); +if (ret) { +/* +* This should not really happen, but in case it happens, +* we just skip the sync for this time. After all we even +* don't have the root table pointer! +*/ +trace_vtd_err ("Detected invalid context entry when " +"trying to sync shadow page table" ); +return 0 ; + } + } + + info.domain_id =VTD_CONTEXT_ENTRY_DID (ce_cache.hi); + +return vtd_page_walk (&ce_cache, addr, addr + size, &info); +} + +static int vtd_sync_shadow_page_table (VTDAddressSpace *vtd_as) +{ +return vtd_sync_shadow_page_table_range (vtd_as,NULL ,0 ,UINT64_MAX ); +} +/* * Fetch translation type for specific device. Returns <0 if error * happens, otherwise return the shifted type to check against
@@ -1296,7 +1404,7 @@ static void vtd_iommu_replay_all(IntelIOMMUState *s)VTDAddressSpace *vtd_as; QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { -memory_region_iommu_replay_all (&vtd_as->iommu); +vtd_sync_shadow_page_table (vtd_as); } }
@@ -1371,14 +1479,13 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,vtd_switch_address_space (vtd_as);/* * So a device is moving out of (or moving into) a -* domain, a replay() suites here to notify all the -* IOMMU_NOTIFIER_MAP registers about this change. +* domain, resync the shadow page table. * This won't bring bad even if we have no such * notifier registered - the IOMMU notification * framework will skip MAP notifications if that * happened. */ -memory_region_iommu_replay_all (&vtd_as->iommu); +vtd_sync_shadow_page_table (vtd_as); } } }
@@ -1436,18 +1543,11 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)if (!vtd_dev_to_context_entry (s,pci_bus_num (vtd_as->bus), vtd_as->devfn, &ce) && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) { -memory_region_iommu_replay_all (&vtd_as->iommu); +vtd_sync_shadow_page_table (vtd_as); } } } -static int vtd_page_invalidate_notify_hook (IOMMUTLBEntry *entry, -void *private) -{ -memory_region_notify_iommu ((IOMMUMemoryRegion *)private, *entry); -return 0 ; -} -static void vtd_iotlb_page_invalidate_notify (IntelIOMMUState *s,uint16_t domain_id,hwaddr addr,uint8_t am)
@@ -1462,21 +1562,12 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, vtd_as->devfn, &ce);if (!ret && domain_id ==VTD_CONTEXT_ENTRY_DID (ce.hi)) {if (vtd_as_has_map_notifier (vtd_as)) { -vtd_page_walk_info info = { - .hook_fn = vtd_page_invalidate_notify_hook, - .private = (void *)&vtd_as->iommu, - .notify_unmap = true, - .aw = s->aw_bits, - .as = vtd_as, - .domain_id = domain_id, - }; -/* * As long as we have MAP notifications registered in * any of our IOMMU notifiers, we need to sync the * shadow page table. */ -vtd_page_walk (&ce, addr, addr + size, &info); +vtd_sync_shadow_page_table_range (vtd_as, &ce, addr, size); }else {/* * For UNMAP-only notifiers, we don't need to walk the
@@ -2799,6 +2890,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) vtd_dev_as->devfn = (uint8_t )devfn; vtd_dev_as->iommu_state = s; vtd_dev_as->context_cache_entry.context_cache_gen =0 ; + vtd_dev_as->iova_tree =iova_tree_new ();/* * Memory region relationships looks like (Address range shows
@@ -2851,6 +2943,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)hwaddr start = n->start;hwaddr end = n->end;IntelIOMMUState *s = as->iommu_state; +DMAMap map;/* * Note: all the codes in this function has a assumption that IOVA
@@ -2895,6 +2988,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)VTD_PCI_FUNC (as->devfn), entry.iova, size); + map.iova = entry.iova; + map.size = entry.addr_mask; +iova_tree_remove (as->iova_tree, &map); +memory_region_notify_one (n, &entry); }
hw/i386/trace-events +2 -1
@@ -40,8 +40,9 @@ vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint6 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one_skip_map(uint64_t iova, uint64_t mask, uint64_t translated) "iova 0x%"PRIx64" mask 0x%"PRIx64" translated 0x%"PRIx64 +vtd_page_walk_one_skip_unmap(uint64_t iova, uint64_t mask) "iova 0x%"PRIx64" mask 0x%"PRIx64 vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" -vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set" vtd_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)" vtd_as_unmap_whole(uint8_t bus, uint8_t slot, uint8_t fn, uint64_t iova, uint64_t size) "Device %02x:%02x.%x start 0x%"PRIx64" size 0x%"PRIx64
include/hw/i386/intel_iommu.h +2 -0
@@ -27,6 +27,7 @@#include "hw/i386/ioapic.h" #include "hw/pci/msi.h" #include "hw/sysbus.h" +#include "qemu/iova-tree.h" #define TYPE_INTEL_IOMMU_DEVICE "intel-iommu"#define INTEL_IOMMU_DEVICE (obj) \
@@ -95,6 +96,7 @@ struct VTDAddressSpace {QLIST_ENTRY (VTDAddressSpace) next;/* Superset of notifier flags that this address space has */ IOMMUNotifierFlag notifier_flags; +IOVATree *iova_tree;/* Traces mapped IOVA ranges */ };struct VTDBus {
Signature · 1 line
2.11.0
PATCH 98/113 Fix libusb-1.0.22 deprecated libusb_set_debug with libusb_set_option
In reply to Michael RothFrom: John Thomson <[email protected]>
libusb-1.0.22 marked libusb_set_debug deprecated
it is replaced withlibusb_set_option(libusb_context, LIBUSB_OPTION_LOG_LEVEL, libusb_log_level);
details here: https://github.com/libusb/libusb/commit/539f22e2fd916558d11ab9a66f10f461c5593168
Warning here:
CC hw/usb/host-libusb.o
/builds/xen/src/qemu-xen/hw/usb/host-libusb.c: In function 'usb_host_init':
/builds/xen/src/qemu-xen/hw/usb/host-libusb.c:250:5: error: 'libusb_set_debug' is deprecated: Use libusb_set_option instead [-Werror=deprecated-declarations]
libusb_set_debug(ctx, loglevel);
^~~~~~~~~~~~~~~~
In file included from /builds/xen/src/qemu-xen/hw/usb/host-libusb.c:40:0:
/usr/include/libusb-1.0/libusb.h:1300:18: note: declared here
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
^~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make: *** [/builds/xen/src/qemu-xen/rules.mak:66: hw/usb/host-libusb.o] Error 1
make: Leaving directory '/builds/xen/src/xen/tools/qemu-xen-build'
Message-id: [email protected]
--- hw/usb/host-libusb.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/usb/host-libusb.c +4 -0
@@ -247,7 +247,11 @@ static int usb_host_init(void)if (rc !=0 ) {return -1 ; } +#if LIBUSB_API_VERSION >=0x01000106 +libusb_set_option (ctx,LIBUSB_OPTION_LOG_LEVEL , loglevel); +#else libusb_set_debug (ctx, loglevel); +#endif #ifdef CONFIG_WIN32 /* FIXME: add support for Windows. */ #else
Signature · 1 line
2.11.0
Quoted 23 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
Quoted 7 lines
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Hi Michael,
as this series includes some s390-ccw bios patches, it needs a rebuild of the s390-ccw bios as well, probably on top of your stable branch. (IIRC we have extra patches on master, so you probably don't want to cherry-pick the latest rebuild from there.). Let me know if one of us should provide a rebuild.
Quoted 4 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Hi Mike,
Please add the following commit to fix backward migration to QEMU 2.7 and older:
aef19c04bf88 spapr: don't migrate "spapr_option_vector_ov5_cas" to pre 2.8 machines
Cheers,
--
Greg
Quoted 340 lines
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Alberto Garcia (2):
specs/qcow2: Fix documentation of the compressed cluster descriptor
throttle: Fix crash on reopenAlexandro Sanchez Bach (1):
target/i386: Fix andn instructionBrijesh Singh (1):
tap: set vhostfd passed from qemu cli to non-blockingCornelia Huck (4):
s390-ccw: force diag 308 subcode to unsigned long s390x/css: disabled subchannels cannot be status pending
virtio-ccw: common reset handler
s390x/ccw: make sure all ccw devices are properly resetDaniel P. Berrangé (1):
i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639)David Gibson (3):
spapr: Allow some cases where we can't set VSMT mode in the kernel
spapr: Adjust default VSMT value for better migration compatibility target/ppc: Clarify compat modemax_threadsvalueEric Blake (4):
nbd: Honor server's advertised minimum block size nbd/client: Fix error messages duringNBD_INFO_BLOCK_SIZE
qemu-img: Fix assert when mapping unaligned raw file
iotests: Add test 221 to catch qemu-img map regressionFam Zheng (1):
raw: Check byte range uniformlyGeert Uytterhoeven (1):
device_tree: IncreaseFDT_MAX_SIZEto 1 MiBGerd Hoffmann (3):
sdl: workaround bug in sdl 2.0.8 headers
qxl: fix local renderer crash
vga: fix region calculationGreg Kurz (12):
spapr: usespapr->vsmtto compute VCPU ids
spapr: move VCPU calculation to core machine code
spapr: renamespapr_vcpu_id()tospapr_get_vcpu_id()
spapr: consolidate the VCPU id numbering logic in a single place
spapr: fix missing CPU core nodes in DT when running with TCG
spapr: register dummy ICPs later
spapr: make pseries-2.11 the default machine type
virtio_net: flush uncompleted TX on reset
exec: fix memory leak infind_max_supported_pagesize()
vfio-ccw: fix memory leaks invfio_ccw_realize()target/ppc: always setPPC_MEM_TLBIEin pre 2.8 migration hack
spapr: don't advertise radix GTSE if max-compat-cpu < power9Henry Wertz (1):
tcg/arm: Fix memory barrier encodingJack Schwartz (4):
multiboot:bss_end_addrcan be zero
multiboot: Remove unused variables frommultiboot.c
multiboot: Use header names when displaying fields
multiboot: fprintf(stderr...) ->error_report()Jan Kiszka (1):
hw/intc/arm_gicv3: Fix APxR<n> register dispatchingJason Andryuk (1):
ccid: Fix dwProtocols advertisement of T=0John Snow (1):
ahci: fix PxCI register raceJohn Thomson (1):
Fix libusb-1.0.22 deprecatedlibusb_set_debugwithlibusb_set_optionKONRAD Frederic (1):
sparc: fix leon3 casa instruction when MMU is disabledKevin Wolf (7):
rbd: Fix use after free inqemu_rbd_set_keypairs()error path
multiboot: Reject kernels exceeding the address space
multiboot: Check validity ofmh_header_addrtests/multiboot: Test exit code for every qemu run tests/multiboot: Add tests for the a.out kludge tests/multiboot: Add .gitignore
gluster: Fix blockdev-add with server.N.type=unixKonrad Rzeszutek Wilk (2):
i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639)Laszlo Ersek (1):
pci-bridge/i82801b11: clear bridge registers on platform resetLaurent Vivier (1):
spapr: set vsmt toMAX(8, smp_threads)Mark Cave-Ayland (1):
loader: don't perform overlapping address check for memory region ROM imagesMax Filippov (4):
target/xtensa: dump correct physical registers
linux-user: fix mmap/munmap/mprotect/mremap/shmat
linux-user: fix assertion in shmdt
linux-user: fix target_mprotect/target_munmap error return valuesMax Reitz (10):
block/file-posix: Fix fully preallocated truncate
iotests: Test preallocated truncate of 2G image
qemu-img: Resolve relative backing paths in rebase
iotests: Add test for rebasing with relative paths
qemu-io: Use purely string blockdev options
qemu-img: Use only string options inimg_open_opts
iotests: Add test for -U/force-share conflicts
block: Makebdrv_is_writable()public
qcow2: Do not mark inactive images corrupt
iotests: Add case for a corrupted inactive imageMichael Roth (1):
Merge remote-tracking branch 'gkurz/stable-2.11-staging' into stable-2.11-stagingMichael Walle (1):
lm32: take BQL before writing IP/IM registerMichal Privoznik (2):
qemu-pr-helper: Actually allow users to specify pidfile
console: Avoid segfault in screendumpMurilo Opsfelder Araujo (1):
block/ssh: fix possible segmentation fault when .desc is not null-terminatedNia Alarie (1):
s390x/virtio: Convert virtio-ccw from *_exit to *_unrealizeOlaf Hering (1):
configure: recognize more rpmbuild macrosPaolo Bonzini (9):
memfd: fix configure test
openpic_kvm: dropaddress_space_to_flatviewcall
memory: inline some performance-sensitive accessors
address_space_write:address_space_to_flatviewneeds RCU lock
address_space_read:address_space_to_flatviewneeds RCU lockaddress_space_access_valid:address_space_to_flatviewneeds RCU lock
address_space_map:address_space_to_flatviewneeds RCU lock
address_space_rw:address_space_to_flatviewneeds RCU lock
memory: fixflatview_access_validRCU read lock/unlock imbalancePeter Lieven (1):
migration/block: reset dirty bitmap before read in bulk phasePeter Maydell (3):
cpus.c: ensure running CPU recalculates icount deadlines on timer expiryhw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes target/arm: Implement v8M VLLDM and VLSTMPeter Xu (9):
intel-iommu: send PSI always even if across PDEs
intel-iommu: remove IntelIOMMUNotifierNode
intel-iommu: add iommu lock
intel-iommu: only do page walk for MAP notifiers
intel-iommu: introducevtd_page_walk_info
intel-iommu: pass in address space when page walk
intel-iommu: trace domain id during page walk
util: implement simple iova tree
intel-iommu: rework the page walk logicPhilippe Mathieu-Daudé (3):
hw/block/pflash_cfi: fix off-by-one error
qdev: rename typedefqdev_resetfn()->DeviceReset()
qdev: add helpers to be more explicit when using abstract QOM parent functionsPrasad Singamsetty (2):
intel-iommu: Redefine macros to enable supporting 48 bit address width
intel-iommu: Extend address width to 48 bitsRichard Henderson (2):
tcg: Markmuluh_i64andmulsh_i64as 64-bit ops
tcg: Introducetcg_set_insn_start_paramShannon Zhao (3):
arm_gicv3_kvm: increase clroffset accordingly
arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYRStefan Berger (1):
tpm: Set the flags of theCMD_INITcommand to 0Thomas Huth (1):
pc-bios/s390-ccw: structtpi_infomust be declared as aligned(4)Tiwei Bie (1):
virtio-balloon: unref the memory region before continuingVictor Kamensky (1):
arm/translate-a64: treatDISAS_UPDATEas variant ofDISAS_EXITViktor Mihajlovski (1):
s390: Do not pass inofficial IPL type to the guestlinzhecheng (1):
vhost-user: delete net client if necessaryMAINTAINERS | 6 + block.c | 17 +- block/file-posix.c | 5 +- block/gluster.c | 21 +- block/nbd-client.c | 3 - block/nbd.c | 2 + block/qcow2.c | 2 +- block/raw-format.c | 64 +++-- block/rbd.c | 3 +- block/ssh.c | 1 + block/throttle.c | 54 ++-- configure | 5 +- cpus.c | 10 +- device_tree.c | 2 +- docs/interop/qcow2.txt | 16 +- exec.c | 92 ++++--- hw/block/pflash_cfi01.c | 10 +- hw/block/pflash_cfi02.c | 9 +- hw/char/cmsdk-apb-uart.c | 1 + hw/core/loader.c | 20 +- hw/core/qdev.c | 24 ++ hw/display/qxl-render.c | 3 +- hw/display/vga.c | 2 + hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 489 +++++++++++++++++++++++++++---------- hw/i386/intel_iommu_internal.h | 43 ++-- hw/i386/multiboot.c | 85 ++++--- hw/i386/trace-events | 5 +- hw/ide/ahci.c | 13 +- hw/intc/arm_gicv3_common.c | 79 ++++++ hw/intc/arm_gicv3_cpuif.c | 12 +- hw/intc/arm_gicv3_kvm.c | 57 ++++- hw/intc/openpic_kvm.c | 4 - hw/net/virtio-net.c | 11 + hw/pci-bridge/i82801b11.c | 1 + hw/ppc/spapr.c | 161 +++++++----- hw/ppc/spapr_caps.c | 5 + hw/ppc/spapr_cpu_core.c | 9 +- hw/s390x/ccw-device.c | 8 + hw/s390x/css.c | 8 + hw/s390x/virtio-ccw.c | 54 ++-- hw/s390x/virtio-ccw.h | 3 +- hw/tpm/tpm_emulator.c | 4 +- hw/usb/dev-smartcard-reader.c | 4 +- hw/usb/host-libusb.c | 4 + hw/vfio/ccw.c | 2 + hw/virtio/virtio-balloon.c | 1 + include/block/block.h | 1 + include/exec/cpu-all.h | 6 +- include/exec/cpu_ldst.h | 16 +- include/exec/memory-internal.h | 13 +- include/exec/memory.h | 45 ++-- include/hw/i386/intel_iommu.h | 26 +- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/ppc/spapr.h | 3 +- include/hw/qdev-core.h | 14 +- include/net/net.h | 1 + include/qemu/iova-tree.h | 134 ++++++++++ linux-user/mmap.c | 26 +- linux-user/syscall.c | 13 +- memory.c | 30 --- migration/block.c | 5 +- nbd/client.c | 14 +- net/net.c | 1 - net/tap.c | 2 + net/vhost-user.c | 11 +- pc-bios/s390-ccw/bootmap.c | 7 + pc-bios/s390-ccw/cio.h | 2 +- pc-bios/s390-ccw/iplb.h | 16 +- qemu-img.c | 29 ++- qemu-io.c | 4 +- scsi/qemu-pr-helper.c | 7 +- target/arm/translate-a64.c | 6 +- target/arm/translate.c | 17 +- target/arm/translate.h | 2 +- target/i386/cpu.c | 4 +- target/i386/cpu.h | 3 + target/i386/kvm.c | 16 +- target/i386/machine.c | 20 ++ target/i386/translate.c | 2 +- target/lm32/op_helper.c | 4 + target/ppc/compat.c | 25 +- target/ppc/cpu.h | 2 +- target/ppc/machine.c | 5 + target/sparc/translate.c | 5 + target/xtensa/translate.c | 1 + tcg/arm/tcg-target.inc.c | 4 +- tcg/tcg-opc.h | 4 +- tcg/tcg.h | 10 + tests/multiboot/.gitignore | 3 + tests/multiboot/Makefile | 22 +- tests/multiboot/aout_kludge.S | 138 +++++++++++ tests/multiboot/aout_kludge.out | 42 ++++ tests/multiboot/run_test.sh | 34 +-- tests/qemu-iotests/024 | 82 ++++++- tests/qemu-iotests/024.out | 30 +++ tests/qemu-iotests/060 | 30 +++ tests/qemu-iotests/060.out | 14 ++ tests/qemu-iotests/106 | 24 ++ tests/qemu-iotests/106.out | 10 + tests/qemu-iotests/153 | 17 ++ tests/qemu-iotests/153.out | 16 ++ tests/qemu-iotests/221 | 60 +++++ tests/qemu-iotests/221.out | 16 ++ tests/qemu-iotests/group | 1 + ui/console.c | 5 + util/Makefile.objs | 1 + util/iova-tree.c | 114 +++++++++ util/memfd.c | 4 +- 109 files changed, 2072 insertions(+), 585 deletions(-) create mode 100644 include/qemu/iova-tree.h create mode 100644 tests/multiboot/.gitignore create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out create mode 100644 util/iova-tree.c
Quoted 6 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 9 lines
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Thanks!
Extra patches we are carrying in Fedora 28:
commit f7a5376d4b667cf6c83c1d640e32d22456d7b5ee
Author: Daniel P. Berrange <[email protected]> Date: Tue Jan 16 13:42:10 2018 +0000
qapi: ensure stable sort ordering when checking QAPI entities
commit 057ad0b46992e3ec4ce29b9103162aa3c683f347
Author: Daniel P. Berrangé <[email protected]> Date: Wed Feb 28 14:04:38 2018 +0000
crypto: ensure we use a predictable TLS priority setting
Thanks,
Cole
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
For openSUSE Leap 15's qemu package, based on v2.11.1, we also add these patches:
commit bb223055b9b327ec66e1f6d2fbaebaee0b8f3dbe
Author: Christian Borntraeger <[email protected]> Date: Mon Dec 11 13:21:46 2017 +0100
s390-ccw-virtio: allow for systems larger that 7.999TB
commit 05b71fb207ab7f016e067bd2a40fc0804362eb74
Author: Marc-André Lureau <[email protected]> Date: Mon Jan 29 19:33:04 2018 +0100
tpm: lookup cancel path under tpm device class
Bruce
Quoting Cornelia Huck (2018-06-19 02:42:48)
Quoted 34 lines
Quoted 23 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
Quoted 7 lines
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Quoted 8 lines
Hi Michael,
as this series includes some s390-ccw bios patches, it needs a rebuild of the s390-ccw bios as well, probably on top of your stable branch. (IIRC we have extra patches on master, so you probably don't want to cherry-pick the latest rebuild from there.). Let me know if one of us should provide a rebuild.
Thanks Cornelia, I hadn't realized that. I think rebuild from one of the maintainers would definitely be preferable. We'd also want the corresponding patches for pc-bios/s390-ccw reflected in the 2.11.x tree. If you or another maintainer could put together a branch with those I can merge those in directly.
Quoting Greg Kurz (2018-06-19 06:56:36)
Quoted 17 lines
Quoted 4 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Quoted 6 lines
Hi Mike,
Please add the following commit to fix backward migration to QEMU 2.7 and older:
aef19c04bf88spapr: don't migrate "spapr_option_vector_ov5_cas" to pre 2.8 machines
Do we still need this if we don't have the following patch?
commit a324d6f166970f8f6a82c61ffd2356fbda81c8f4
Author: Bharata B Rao <[email protected]>
AuthorDate: Thu Apr 19 12:17:35 2018 +0530
Commit: David Gibson <[email protected]>
CommitDate: Fri Apr 27 18:05:23 2018 +1000
spapr: Support ibm,dynamic-memory-v2 property
If so that one isn't part of 2.11.x. I have the patch tagged for 2.12.1 though.
Quoted 347 lines
Cheers,
--
GregQuoted 340 lines
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Alberto Garcia (2):
specs/qcow2: Fix documentation of the compressed cluster descriptor
throttle: Fix crash on reopenAlexandro Sanchez Bach (1):
target/i386: Fix andn instructionBrijesh Singh (1):
tap: set vhostfd passed from qemu cli to non-blockingCornelia Huck (4):
s390-ccw: force diag 308 subcode to unsigned long s390x/css: disabled subchannels cannot be status pending
virtio-ccw: common reset handler
s390x/ccw: make sure all ccw devices are properly resetDaniel P. Berrangé (1):
i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639)David Gibson (3):
spapr: Allow some cases where we can't set VSMT mode in the kernel
spapr: Adjust default VSMT value for better migration compatibility target/ppc: Clarify compat modemax_threadsvalueEric Blake (4):
nbd: Honor server's advertised minimum block size nbd/client: Fix error messages duringNBD_INFO_BLOCK_SIZE
qemu-img: Fix assert when mapping unaligned raw file
iotests: Add test 221 to catch qemu-img map regressionFam Zheng (1):
raw: Check byte range uniformlyGeert Uytterhoeven (1):
device_tree: IncreaseFDT_MAX_SIZEto 1 MiBGerd Hoffmann (3):
sdl: workaround bug in sdl 2.0.8 headers
qxl: fix local renderer crash
vga: fix region calculationGreg Kurz (12):
spapr: usespapr->vsmtto compute VCPU ids
spapr: move VCPU calculation to core machine code
spapr: renamespapr_vcpu_id()tospapr_get_vcpu_id()
spapr: consolidate the VCPU id numbering logic in a single place
spapr: fix missing CPU core nodes in DT when running with TCG
spapr: register dummy ICPs later
spapr: make pseries-2.11 the default machine type
virtio_net: flush uncompleted TX on reset
exec: fix memory leak infind_max_supported_pagesize()
vfio-ccw: fix memory leaks invfio_ccw_realize()target/ppc: always setPPC_MEM_TLBIEin pre 2.8 migration hack
spapr: don't advertise radix GTSE if max-compat-cpu < power9Henry Wertz (1):
tcg/arm: Fix memory barrier encodingJack Schwartz (4):
multiboot:bss_end_addrcan be zero
multiboot: Remove unused variables frommultiboot.c
multiboot: Use header names when displaying fields
multiboot: fprintf(stderr...) ->error_report()Jan Kiszka (1):
hw/intc/arm_gicv3: Fix APxR<n> register dispatchingJason Andryuk (1):
ccid: Fix dwProtocols advertisement of T=0John Snow (1):
ahci: fix PxCI register raceJohn Thomson (1):
Fix libusb-1.0.22 deprecatedlibusb_set_debugwithlibusb_set_optionKONRAD Frederic (1):
sparc: fix leon3 casa instruction when MMU is disabledKevin Wolf (7):
rbd: Fix use after free inqemu_rbd_set_keypairs()error path
multiboot: Reject kernels exceeding the address space
multiboot: Check validity ofmh_header_addrtests/multiboot: Test exit code for every qemu run tests/multiboot: Add tests for the a.out kludge tests/multiboot: Add .gitignore
gluster: Fix blockdev-add with server.N.type=unixKonrad Rzeszutek Wilk (2):
i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639)Laszlo Ersek (1):
pci-bridge/i82801b11: clear bridge registers on platform resetLaurent Vivier (1):
spapr: set vsmt toMAX(8, smp_threads)Mark Cave-Ayland (1):
loader: don't perform overlapping address check for memory region ROM imagesMax Filippov (4):
target/xtensa: dump correct physical registers
linux-user: fix mmap/munmap/mprotect/mremap/shmat
linux-user: fix assertion in shmdt
linux-user: fix target_mprotect/target_munmap error return valuesMax Reitz (10):
block/file-posix: Fix fully preallocated truncate
iotests: Test preallocated truncate of 2G image
qemu-img: Resolve relative backing paths in rebase
iotests: Add test for rebasing with relative paths
qemu-io: Use purely string blockdev options
qemu-img: Use only string options inimg_open_opts
iotests: Add test for -U/force-share conflicts
block: Makebdrv_is_writable()public
qcow2: Do not mark inactive images corrupt
iotests: Add case for a corrupted inactive imageMichael Roth (1):
Merge remote-tracking branch 'gkurz/stable-2.11-staging' into stable-2.11-stagingMichael Walle (1):
lm32: take BQL before writing IP/IM registerMichal Privoznik (2):
qemu-pr-helper: Actually allow users to specify pidfile
console: Avoid segfault in screendumpMurilo Opsfelder Araujo (1):
block/ssh: fix possible segmentation fault when .desc is not null-terminatedNia Alarie (1):
s390x/virtio: Convert virtio-ccw from *_exit to *_unrealizeOlaf Hering (1):
configure: recognize more rpmbuild macrosPaolo Bonzini (9):
memfd: fix configure test
openpic_kvm: dropaddress_space_to_flatviewcall
memory: inline some performance-sensitive accessors
address_space_write:address_space_to_flatviewneeds RCU lock
address_space_read:address_space_to_flatviewneeds RCU lockaddress_space_access_valid:address_space_to_flatviewneeds RCU lock
address_space_map:address_space_to_flatviewneeds RCU lock
address_space_rw:address_space_to_flatviewneeds RCU lock
memory: fixflatview_access_validRCU read lock/unlock imbalancePeter Lieven (1):
migration/block: reset dirty bitmap before read in bulk phasePeter Maydell (3):
cpus.c: ensure running CPU recalculates icount deadlines on timer expiryhw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes target/arm: Implement v8M VLLDM and VLSTMPeter Xu (9):
intel-iommu: send PSI always even if across PDEs
intel-iommu: remove IntelIOMMUNotifierNode
intel-iommu: add iommu lock
intel-iommu: only do page walk for MAP notifiers
intel-iommu: introducevtd_page_walk_info
intel-iommu: pass in address space when page walk
intel-iommu: trace domain id during page walk
util: implement simple iova tree
intel-iommu: rework the page walk logicPhilippe Mathieu-Daudé (3):
hw/block/pflash_cfi: fix off-by-one error
qdev: rename typedefqdev_resetfn()->DeviceReset()
qdev: add helpers to be more explicit when using abstract QOM parent functionsPrasad Singamsetty (2):
intel-iommu: Redefine macros to enable supporting 48 bit address width
intel-iommu: Extend address width to 48 bitsRichard Henderson (2):
tcg: Markmuluh_i64andmulsh_i64as 64-bit ops
tcg: Introducetcg_set_insn_start_paramShannon Zhao (3):
arm_gicv3_kvm: increase clroffset accordingly
arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYRStefan Berger (1):
tpm: Set the flags of theCMD_INITcommand to 0Thomas Huth (1):
pc-bios/s390-ccw: structtpi_infomust be declared as aligned(4)Tiwei Bie (1):
virtio-balloon: unref the memory region before continuingVictor Kamensky (1):
arm/translate-a64: treatDISAS_UPDATEas variant ofDISAS_EXITViktor Mihajlovski (1):
s390: Do not pass inofficial IPL type to the guestlinzhecheng (1):
vhost-user: delete net client if necessaryMAINTAINERS | 6 + block.c | 17 +- block/file-posix.c | 5 +- block/gluster.c | 21 +- block/nbd-client.c | 3 - block/nbd.c | 2 + block/qcow2.c | 2 +- block/raw-format.c | 64 +++-- block/rbd.c | 3 +- block/ssh.c | 1 + block/throttle.c | 54 ++-- configure | 5 +- cpus.c | 10 +- device_tree.c | 2 +- docs/interop/qcow2.txt | 16 +- exec.c | 92 ++++--- hw/block/pflash_cfi01.c | 10 +- hw/block/pflash_cfi02.c | 9 +- hw/char/cmsdk-apb-uart.c | 1 + hw/core/loader.c | 20 +- hw/core/qdev.c | 24 ++ hw/display/qxl-render.c | 3 +- hw/display/vga.c | 2 + hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 489 +++++++++++++++++++++++++++---------- hw/i386/intel_iommu_internal.h | 43 ++-- hw/i386/multiboot.c | 85 ++++--- hw/i386/trace-events | 5 +- hw/ide/ahci.c | 13 +- hw/intc/arm_gicv3_common.c | 79 ++++++ hw/intc/arm_gicv3_cpuif.c | 12 +- hw/intc/arm_gicv3_kvm.c | 57 ++++- hw/intc/openpic_kvm.c | 4 - hw/net/virtio-net.c | 11 + hw/pci-bridge/i82801b11.c | 1 + hw/ppc/spapr.c | 161 +++++++----- hw/ppc/spapr_caps.c | 5 + hw/ppc/spapr_cpu_core.c | 9 +- hw/s390x/ccw-device.c | 8 + hw/s390x/css.c | 8 + hw/s390x/virtio-ccw.c | 54 ++-- hw/s390x/virtio-ccw.h | 3 +- hw/tpm/tpm_emulator.c | 4 +- hw/usb/dev-smartcard-reader.c | 4 +- hw/usb/host-libusb.c | 4 + hw/vfio/ccw.c | 2 + hw/virtio/virtio-balloon.c | 1 + include/block/block.h | 1 + include/exec/cpu-all.h | 6 +- include/exec/cpu_ldst.h | 16 +- include/exec/memory-internal.h | 13 +- include/exec/memory.h | 45 ++-- include/hw/i386/intel_iommu.h | 26 +- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/ppc/spapr.h | 3 +- include/hw/qdev-core.h | 14 +- include/net/net.h | 1 + include/qemu/iova-tree.h | 134 ++++++++++ linux-user/mmap.c | 26 +- linux-user/syscall.c | 13 +- memory.c | 30 --- migration/block.c | 5 +- nbd/client.c | 14 +- net/net.c | 1 - net/tap.c | 2 + net/vhost-user.c | 11 +- pc-bios/s390-ccw/bootmap.c | 7 + pc-bios/s390-ccw/cio.h | 2 +- pc-bios/s390-ccw/iplb.h | 16 +- qemu-img.c | 29 ++- qemu-io.c | 4 +- scsi/qemu-pr-helper.c | 7 +- target/arm/translate-a64.c | 6 +- target/arm/translate.c | 17 +- target/arm/translate.h | 2 +- target/i386/cpu.c | 4 +- target/i386/cpu.h | 3 + target/i386/kvm.c | 16 +- target/i386/machine.c | 20 ++ target/i386/translate.c | 2 +- target/lm32/op_helper.c | 4 + target/ppc/compat.c | 25 +- target/ppc/cpu.h | 2 +- target/ppc/machine.c | 5 + target/sparc/translate.c | 5 + target/xtensa/translate.c | 1 + tcg/arm/tcg-target.inc.c | 4 +- tcg/tcg-opc.h | 4 +- tcg/tcg.h | 10 + tests/multiboot/.gitignore | 3 + tests/multiboot/Makefile | 22 +- tests/multiboot/aout_kludge.S | 138 +++++++++++ tests/multiboot/aout_kludge.out | 42 ++++ tests/multiboot/run_test.sh | 34 +-- tests/qemu-iotests/024 | 82 ++++++- tests/qemu-iotests/024.out | 30 +++ tests/qemu-iotests/060 | 30 +++ tests/qemu-iotests/060.out | 14 ++ tests/qemu-iotests/106 | 24 ++ tests/qemu-iotests/106.out | 10 + tests/qemu-iotests/153 | 17 ++ tests/qemu-iotests/153.out | 16 ++ tests/qemu-iotests/221 | 60 +++++ tests/qemu-iotests/221.out | 16 ++ tests/qemu-iotests/group | 1 + ui/console.c | 5 + util/Makefile.objs | 1 + util/iova-tree.c | 114 +++++++++ util/memfd.c | 4 +- 109 files changed, 2072 insertions(+), 585 deletions(-) create mode 100644 include/qemu/iova-tree.h create mode 100644 tests/multiboot/.gitignore create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out create mode 100644 util/iova-tree.c
Quoting Michael Roth (2018-06-18 20:41:26)
Quoted 4 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 8 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
The following additional patches have been queued for 2.11.2:
tpm: lookup cancel path under tpm device class (Marc-André Lureau)
tpm-passthrough: don't save guessed cancel_path in options (Marc-André Lureau)
s390-ccw-virtio: allow for systems larger that 7.999TB (Christian Borntraeger)
crypto: ensure we use a predictable TLS priority setting (Daniel P. Berrangé)
qapi: ensure stable sort ordering when checking QAPI entities (Daniel P. Berrange)
https://github.com/mdroth/qemu/commits/stable-2.11-staging
Thank you everyone for the suggestions.
Quoted 340 lines
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Alberto Garcia (2):
specs/qcow2: Fix documentation of the compressed cluster descriptor
throttle: Fix crash on reopenAlexandro Sanchez Bach (1):
target/i386: Fix andn instructionBrijesh Singh (1):
tap: set vhostfd passed from qemu cli to non-blockingCornelia Huck (4):
s390-ccw: force diag 308 subcode to unsigned long s390x/css: disabled subchannels cannot be status pending
virtio-ccw: common reset handler
s390x/ccw: make sure all ccw devices are properly resetDaniel P. Berrangé (1):
i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639)David Gibson (3):
spapr: Allow some cases where we can't set VSMT mode in the kernel
spapr: Adjust default VSMT value for better migration compatibility target/ppc: Clarify compat modemax_threadsvalueEric Blake (4):
nbd: Honor server's advertised minimum block size nbd/client: Fix error messages duringNBD_INFO_BLOCK_SIZE
qemu-img: Fix assert when mapping unaligned raw file
iotests: Add test 221 to catch qemu-img map regressionFam Zheng (1):
raw: Check byte range uniformlyGeert Uytterhoeven (1):
device_tree: IncreaseFDT_MAX_SIZEto 1 MiBGerd Hoffmann (3):
sdl: workaround bug in sdl 2.0.8 headers
qxl: fix local renderer crash
vga: fix region calculationGreg Kurz (12):
spapr: usespapr->vsmtto compute VCPU ids
spapr: move VCPU calculation to core machine code
spapr: renamespapr_vcpu_id()tospapr_get_vcpu_id()
spapr: consolidate the VCPU id numbering logic in a single place
spapr: fix missing CPU core nodes in DT when running with TCG
spapr: register dummy ICPs later
spapr: make pseries-2.11 the default machine type
virtio_net: flush uncompleted TX on reset
exec: fix memory leak infind_max_supported_pagesize()
vfio-ccw: fix memory leaks invfio_ccw_realize()target/ppc: always setPPC_MEM_TLBIEin pre 2.8 migration hack
spapr: don't advertise radix GTSE if max-compat-cpu < power9Henry Wertz (1):
tcg/arm: Fix memory barrier encodingJack Schwartz (4):
multiboot:bss_end_addrcan be zero
multiboot: Remove unused variables frommultiboot.c
multiboot: Use header names when displaying fields
multiboot: fprintf(stderr...) ->error_report()Jan Kiszka (1):
hw/intc/arm_gicv3: Fix APxR<n> register dispatchingJason Andryuk (1):
ccid: Fix dwProtocols advertisement of T=0John Snow (1):
ahci: fix PxCI register raceJohn Thomson (1):
Fix libusb-1.0.22 deprecatedlibusb_set_debugwithlibusb_set_optionKONRAD Frederic (1):
sparc: fix leon3 casa instruction when MMU is disabledKevin Wolf (7):
rbd: Fix use after free inqemu_rbd_set_keypairs()error path
multiboot: Reject kernels exceeding the address space
multiboot: Check validity ofmh_header_addrtests/multiboot: Test exit code for every qemu run tests/multiboot: Add tests for the a.out kludge tests/multiboot: Add .gitignore
gluster: Fix blockdev-add with server.N.type=unixKonrad Rzeszutek Wilk (2):
i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639)Laszlo Ersek (1):
pci-bridge/i82801b11: clear bridge registers on platform resetLaurent Vivier (1):
spapr: set vsmt toMAX(8, smp_threads)Mark Cave-Ayland (1):
loader: don't perform overlapping address check for memory region ROM imagesMax Filippov (4):
target/xtensa: dump correct physical registers
linux-user: fix mmap/munmap/mprotect/mremap/shmat
linux-user: fix assertion in shmdt
linux-user: fix target_mprotect/target_munmap error return valuesMax Reitz (10):
block/file-posix: Fix fully preallocated truncate
iotests: Test preallocated truncate of 2G image
qemu-img: Resolve relative backing paths in rebase
iotests: Add test for rebasing with relative paths
qemu-io: Use purely string blockdev options
qemu-img: Use only string options inimg_open_opts
iotests: Add test for -U/force-share conflicts
block: Makebdrv_is_writable()public
qcow2: Do not mark inactive images corrupt
iotests: Add case for a corrupted inactive imageMichael Roth (1):
Merge remote-tracking branch 'gkurz/stable-2.11-staging' into stable-2.11-stagingMichael Walle (1):
lm32: take BQL before writing IP/IM registerMichal Privoznik (2):
qemu-pr-helper: Actually allow users to specify pidfile
console: Avoid segfault in screendumpMurilo Opsfelder Araujo (1):
block/ssh: fix possible segmentation fault when .desc is not null-terminatedNia Alarie (1):
s390x/virtio: Convert virtio-ccw from *_exit to *_unrealizeOlaf Hering (1):
configure: recognize more rpmbuild macrosPaolo Bonzini (9):
memfd: fix configure test
openpic_kvm: dropaddress_space_to_flatviewcall
memory: inline some performance-sensitive accessors
address_space_write:address_space_to_flatviewneeds RCU lock
address_space_read:address_space_to_flatviewneeds RCU lockaddress_space_access_valid:address_space_to_flatviewneeds RCU lock
address_space_map:address_space_to_flatviewneeds RCU lock
address_space_rw:address_space_to_flatviewneeds RCU lock
memory: fixflatview_access_validRCU read lock/unlock imbalancePeter Lieven (1):
migration/block: reset dirty bitmap before read in bulk phasePeter Maydell (3):
cpus.c: ensure running CPU recalculates icount deadlines on timer expiryhw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes target/arm: Implement v8M VLLDM and VLSTMPeter Xu (9):
intel-iommu: send PSI always even if across PDEs
intel-iommu: remove IntelIOMMUNotifierNode
intel-iommu: add iommu lock
intel-iommu: only do page walk for MAP notifiers
intel-iommu: introducevtd_page_walk_info
intel-iommu: pass in address space when page walk
intel-iommu: trace domain id during page walk
util: implement simple iova tree
intel-iommu: rework the page walk logicPhilippe Mathieu-Daudé (3):
hw/block/pflash_cfi: fix off-by-one error
qdev: rename typedefqdev_resetfn()->DeviceReset()
qdev: add helpers to be more explicit when using abstract QOM parent functionsPrasad Singamsetty (2):
intel-iommu: Redefine macros to enable supporting 48 bit address width
intel-iommu: Extend address width to 48 bitsRichard Henderson (2):
tcg: Markmuluh_i64andmulsh_i64as 64-bit ops
tcg: Introducetcg_set_insn_start_paramShannon Zhao (3):
arm_gicv3_kvm: increase clroffset accordingly
arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYRStefan Berger (1):
tpm: Set the flags of theCMD_INITcommand to 0Thomas Huth (1):
pc-bios/s390-ccw: structtpi_infomust be declared as aligned(4)Tiwei Bie (1):
virtio-balloon: unref the memory region before continuingVictor Kamensky (1):
arm/translate-a64: treatDISAS_UPDATEas variant ofDISAS_EXITViktor Mihajlovski (1):
s390: Do not pass inofficial IPL type to the guestlinzhecheng (1):
vhost-user: delete net client if necessaryMAINTAINERS | 6 + block.c | 17 +- block/file-posix.c | 5 +- block/gluster.c | 21 +- block/nbd-client.c | 3 - block/nbd.c | 2 + block/qcow2.c | 2 +- block/raw-format.c | 64 +++-- block/rbd.c | 3 +- block/ssh.c | 1 + block/throttle.c | 54 ++-- configure | 5 +- cpus.c | 10 +- device_tree.c | 2 +- docs/interop/qcow2.txt | 16 +- exec.c | 92 ++++--- hw/block/pflash_cfi01.c | 10 +- hw/block/pflash_cfi02.c | 9 +- hw/char/cmsdk-apb-uart.c | 1 + hw/core/loader.c | 20 +- hw/core/qdev.c | 24 ++ hw/display/qxl-render.c | 3 +- hw/display/vga.c | 2 + hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 489 +++++++++++++++++++++++++++---------- hw/i386/intel_iommu_internal.h | 43 ++-- hw/i386/multiboot.c | 85 ++++--- hw/i386/trace-events | 5 +- hw/ide/ahci.c | 13 +- hw/intc/arm_gicv3_common.c | 79 ++++++ hw/intc/arm_gicv3_cpuif.c | 12 +- hw/intc/arm_gicv3_kvm.c | 57 ++++- hw/intc/openpic_kvm.c | 4 - hw/net/virtio-net.c | 11 + hw/pci-bridge/i82801b11.c | 1 + hw/ppc/spapr.c | 161 +++++++----- hw/ppc/spapr_caps.c | 5 + hw/ppc/spapr_cpu_core.c | 9 +- hw/s390x/ccw-device.c | 8 + hw/s390x/css.c | 8 + hw/s390x/virtio-ccw.c | 54 ++-- hw/s390x/virtio-ccw.h | 3 +- hw/tpm/tpm_emulator.c | 4 +- hw/usb/dev-smartcard-reader.c | 4 +- hw/usb/host-libusb.c | 4 + hw/vfio/ccw.c | 2 + hw/virtio/virtio-balloon.c | 1 + include/block/block.h | 1 + include/exec/cpu-all.h | 6 +- include/exec/cpu_ldst.h | 16 +- include/exec/memory-internal.h | 13 +- include/exec/memory.h | 45 ++-- include/hw/i386/intel_iommu.h | 26 +- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/ppc/spapr.h | 3 +- include/hw/qdev-core.h | 14 +- include/net/net.h | 1 + include/qemu/iova-tree.h | 134 ++++++++++ linux-user/mmap.c | 26 +- linux-user/syscall.c | 13 +- memory.c | 30 --- migration/block.c | 5 +- nbd/client.c | 14 +- net/net.c | 1 - net/tap.c | 2 + net/vhost-user.c | 11 +- pc-bios/s390-ccw/bootmap.c | 7 + pc-bios/s390-ccw/cio.h | 2 +- pc-bios/s390-ccw/iplb.h | 16 +- qemu-img.c | 29 ++- qemu-io.c | 4 +- scsi/qemu-pr-helper.c | 7 +- target/arm/translate-a64.c | 6 +- target/arm/translate.c | 17 +- target/arm/translate.h | 2 +- target/i386/cpu.c | 4 +- target/i386/cpu.h | 3 + target/i386/kvm.c | 16 +- target/i386/machine.c | 20 ++ target/i386/translate.c | 2 +- target/lm32/op_helper.c | 4 + target/ppc/compat.c | 25 +- target/ppc/cpu.h | 2 +- target/ppc/machine.c | 5 + target/sparc/translate.c | 5 + target/xtensa/translate.c | 1 + tcg/arm/tcg-target.inc.c | 4 +- tcg/tcg-opc.h | 4 +- tcg/tcg.h | 10 + tests/multiboot/.gitignore | 3 + tests/multiboot/Makefile | 22 +- tests/multiboot/aout_kludge.S | 138 +++++++++++ tests/multiboot/aout_kludge.out | 42 ++++ tests/multiboot/run_test.sh | 34 +-- tests/qemu-iotests/024 | 82 ++++++- tests/qemu-iotests/024.out | 30 +++ tests/qemu-iotests/060 | 30 +++ tests/qemu-iotests/060.out | 14 ++ tests/qemu-iotests/106 | 24 ++ tests/qemu-iotests/106.out | 10 + tests/qemu-iotests/153 | 17 ++ tests/qemu-iotests/153.out | 16 ++ tests/qemu-iotests/221 | 60 +++++ tests/qemu-iotests/221.out | 16 ++ tests/qemu-iotests/group | 1 + ui/console.c | 5 + util/Makefile.objs | 1 + util/iova-tree.c | 114 +++++++++ util/memfd.c | 4 +- 109 files changed, 2072 insertions(+), 585 deletions(-) create mode 100644 include/qemu/iova-tree.h create mode 100644 tests/multiboot/.gitignore create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out create mode 100644 util/iova-tree.c
Quoting Michael Roth (2018-06-20 15:41:24)
Quoted 44 lines
Quoting Cornelia Huck (2018-06-19 02:42:48)
Quoted 34 lines
Quoted 23 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
Quoted 7 lines
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Quoted 8 lines
Hi Michael,
as this series includes some s390-ccw bios patches, it needs a rebuild of the s390-ccw bios as well, probably on top of your stable branch. (IIRC we have extra patches on master, so you probably don't want to cherry-pick the latest rebuild from there.). Let me know if one of us should provide a rebuild.
Quoted 3 lines
Thanks Cornelia, I hadn't realized that. I think rebuild from one of the maintainers would definitely be preferable. We'd also want the corresponding patches for pc-bios/s390-ccw reflected in the 2.11.x tree.
Er, sorry was a bit confused. I suppose that part is covered already if there's no additional patches needed in the rebuild other than what's in 2.11.x already.
Quoted 2 lines
another maintainer could put together a branch with those I can merge those in directly.
Quoted 45 lines · On Wed, 20 Jun 2018 16:55:05 -0500 Michael Roth <[email protected]>…
Quoting Michael Roth (2018-06-20 15:41:24)
Quoted 44 lines
Quoting Cornelia Huck (2018-06-19 02:42:48)
Quoted 42 lines
Quoted 23 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
Quoted 7 lines
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Hi Michael,
as this series includes some s390-ccw bios patches, it needs a rebuild of the s390-ccw bios as well, probably on top of your stable branch. (IIRC we have extra patches on master, so you probably don't want to cherry-pick the latest rebuild from there.). Let me know if one of us should provide a rebuild.
Quoted 7 lines
Quoted 3 lines
Thanks Cornelia, I hadn't realized that. I think rebuild from one of the maintainers would definitely be preferable. We'd also want the corresponding patches for pc-bios/s390-ccw reflected in the 2.11.x tree.
Er, sorry was a bit confused. I suppose that part is covered already if there's no additional patches needed in the rebuild other than what's in 2.11.x already.
Yes, this should be all AFAICS.
Quoted 5 lines
Quoted 4 lines
another maintainer could put together a branch with those I can merge those in directly.
The following changes since commit 1e13e7d93b93885d8a27fd18ec8a4b865a70e2ea:
tpm: lookup cancel path under tpm device class (2018-06-20 20:45:08 -0500)
are available in the Git repository at:
git://github.com/cohuck/qemu tags/s390x-20180621-211-stable
for you to fetch changes up to 728d6c602ea9fc9cfc4a2fcafb2553a1f4f400b6:
pc-bios/s390-ccw.img: update image for stable (2018-06-21 04:22:15 -0400)
----------------------------------------------------------------
update s390-ccw.img for stable
----------------------------------------------------------------
Cornelia Huck (1):
pc-bios/s390-ccw.img: update image for stable
pc-bios/s390-ccw.img | Bin 26416 -> 26416 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
(or just cherry-pick from git://github.com/cohuck/qemu for-2.11-stable)
Hi Michael,
Quoted 16 lines · Michael Roth
Quoting Michael Roth (2018-06-18 20:41:26)
Quoted 4 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 8 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
The following additional patches have been queued for 2.11.2:
Quoted 7 lines
tpm: lookup cancel path under tpm device class (Marc-André Lureau)
tpm-passthrough: don't save guessedcancel_pathin options (Marc-André Lureau)
s390-ccw-virtio: allow for systems larger that 7.999TB (Christian Borntraeger)
crypto: ensure we use a predictable TLS priority setting (Daniel P. Berrangé)
qapi: ensure stable sort ordering when checking QAPI entities (Daniel P. Berrange)
I also noticed these:
9005774b27 gdbstub: fix off-by-one in gdb_handle_packet() bf78fb1c1b usb: correctly handle Zero Length Packets 62713a2e50 usb/dev-mtp: Fix use of uninitialized values
Regards,
Phil.
Quoted 33 lines · On Wed, 20 Jun 2018 15:29:42 -0500 Michael Roth <[email protected]>…
Quoting Greg Kurz (2018-06-19 06:56:36)
Quoted 17 lines
Quoted 4 lines · On Mon, 18 Jun 2018 20:41:26 -0500 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.2:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2018-06-22:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Quoted 6 lines
Hi Mike,
Please add the following commit to fix backward migration to QEMU 2.7 and older:
aef19c04bf88spapr: don't migrate "spapr_option_vector_ov5_cas" to pre 2.8 machinesDo we still need this if we don't have the following patch?
commit
a324d6f166970f8f6a82c61ffd2356fbda81c8f4
Author: Bharata B Rao <[email protected]>
AuthorDate: Thu Apr 19 12:17:35 2018 +0530
Commit: David Gibson <[email protected]>
CommitDate: Fri Apr 27 18:05:23 2018 +1000
Quoted 5 lines
spapr: Support ibm,dynamic-memory-v2 property
If so that one isn't part of 2.11.x. I have the patch tagged for 2.12.1 though.
Oh, you're right. We're good then :)
Quoted 348 lines
Quoted 347 lines
Cheers,
--
GregQuoted 340 lines
Thanks!
----------------------------------------------------------------
The following changes since commit
7c1beb52ed86191d9e965444d934adaa2531710f:Update version for 2.11.1 release (2018-02-14 14:41:05 -0600)
are available in the git repository at:
git://github.com/mdroth/qemu.gitfor you to fetch changes up to
acb3571f90885a2e206044b3bdc8d1dd2a0389c0:
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYR(2018-06-16 07:47:00 -0500)----------------------------------------------------------------
Alberto Garcia (2):
specs/qcow2: Fix documentation of the compressed cluster descriptor
throttle: Fix crash on reopenAlexandro Sanchez Bach (1):
target/i386: Fix andn instructionBrijesh Singh (1):
tap: set vhostfd passed from qemu cli to non-blockingCornelia Huck (4):
s390-ccw: force diag 308 subcode to unsigned long s390x/css: disabled subchannels cannot be status pending
virtio-ccw: common reset handler
s390x/ccw: make sure all ccw devices are properly resetDaniel P. Berrangé (1):
i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639)David Gibson (3):
spapr: Allow some cases where we can't set VSMT mode in the kernel
spapr: Adjust default VSMT value for better migration compatibility target/ppc: Clarify compat modemax_threadsvalueEric Blake (4):
nbd: Honor server's advertised minimum block size nbd/client: Fix error messages duringNBD_INFO_BLOCK_SIZE
qemu-img: Fix assert when mapping unaligned raw file
iotests: Add test 221 to catch qemu-img map regressionFam Zheng (1):
raw: Check byte range uniformlyGeert Uytterhoeven (1):
device_tree: IncreaseFDT_MAX_SIZEto 1 MiBGerd Hoffmann (3):
sdl: workaround bug in sdl 2.0.8 headers
qxl: fix local renderer crash
vga: fix region calculationGreg Kurz (12):
spapr: usespapr->vsmtto compute VCPU ids
spapr: move VCPU calculation to core machine code
spapr: renamespapr_vcpu_id()tospapr_get_vcpu_id()
spapr: consolidate the VCPU id numbering logic in a single place
spapr: fix missing CPU core nodes in DT when running with TCG
spapr: register dummy ICPs later
spapr: make pseries-2.11 the default machine type
virtio_net: flush uncompleted TX on reset
exec: fix memory leak infind_max_supported_pagesize()
vfio-ccw: fix memory leaks invfio_ccw_realize()target/ppc: always setPPC_MEM_TLBIEin pre 2.8 migration hack
spapr: don't advertise radix GTSE if max-compat-cpu < power9Henry Wertz (1):
tcg/arm: Fix memory barrier encodingJack Schwartz (4):
multiboot:bss_end_addrcan be zero
multiboot: Remove unused variables frommultiboot.c
multiboot: Use header names when displaying fields
multiboot: fprintf(stderr...) ->error_report()Jan Kiszka (1):
hw/intc/arm_gicv3: Fix APxR<n> register dispatchingJason Andryuk (1):
ccid: Fix dwProtocols advertisement of T=0John Snow (1):
ahci: fix PxCI register raceJohn Thomson (1):
Fix libusb-1.0.22 deprecatedlibusb_set_debugwithlibusb_set_optionKONRAD Frederic (1):
sparc: fix leon3 casa instruction when MMU is disabledKevin Wolf (7):
rbd: Fix use after free inqemu_rbd_set_keypairs()error path
multiboot: Reject kernels exceeding the address space
multiboot: Check validity ofmh_header_addrtests/multiboot: Test exit code for every qemu run tests/multiboot: Add tests for the a.out kludge tests/multiboot: Add .gitignore
gluster: Fix blockdev-add with server.N.type=unixKonrad Rzeszutek Wilk (2):
i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639)
i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639)Laszlo Ersek (1):
pci-bridge/i82801b11: clear bridge registers on platform resetLaurent Vivier (1):
spapr: set vsmt toMAX(8, smp_threads)Mark Cave-Ayland (1):
loader: don't perform overlapping address check for memory region ROM imagesMax Filippov (4):
target/xtensa: dump correct physical registers
linux-user: fix mmap/munmap/mprotect/mremap/shmat
linux-user: fix assertion in shmdt
linux-user: fix target_mprotect/target_munmap error return valuesMax Reitz (10):
block/file-posix: Fix fully preallocated truncate
iotests: Test preallocated truncate of 2G image
qemu-img: Resolve relative backing paths in rebase
iotests: Add test for rebasing with relative paths
qemu-io: Use purely string blockdev options
qemu-img: Use only string options inimg_open_opts
iotests: Add test for -U/force-share conflicts
block: Makebdrv_is_writable()public
qcow2: Do not mark inactive images corrupt
iotests: Add case for a corrupted inactive imageMichael Roth (1):
Merge remote-tracking branch 'gkurz/stable-2.11-staging' into stable-2.11-stagingMichael Walle (1):
lm32: take BQL before writing IP/IM registerMichal Privoznik (2):
qemu-pr-helper: Actually allow users to specify pidfile
console: Avoid segfault in screendumpMurilo Opsfelder Araujo (1):
block/ssh: fix possible segmentation fault when .desc is not null-terminatedNia Alarie (1):
s390x/virtio: Convert virtio-ccw from *_exit to *_unrealizeOlaf Hering (1):
configure: recognize more rpmbuild macrosPaolo Bonzini (9):
memfd: fix configure test
openpic_kvm: dropaddress_space_to_flatviewcall
memory: inline some performance-sensitive accessors
address_space_write:address_space_to_flatviewneeds RCU lock
address_space_read:address_space_to_flatviewneeds RCU lockaddress_space_access_valid:address_space_to_flatviewneeds RCU lock
address_space_map:address_space_to_flatviewneeds RCU lock
address_space_rw:address_space_to_flatviewneeds RCU lock
memory: fixflatview_access_validRCU read lock/unlock imbalancePeter Lieven (1):
migration/block: reset dirty bitmap before read in bulk phasePeter Maydell (3):
cpus.c: ensure running CPU recalculates icount deadlines on timer expiryhw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes target/arm: Implement v8M VLLDM and VLSTMPeter Xu (9):
intel-iommu: send PSI always even if across PDEs
intel-iommu: remove IntelIOMMUNotifierNode
intel-iommu: add iommu lock
intel-iommu: only do page walk for MAP notifiers
intel-iommu: introducevtd_page_walk_info
intel-iommu: pass in address space when page walk
intel-iommu: trace domain id during page walk
util: implement simple iova tree
intel-iommu: rework the page walk logicPhilippe Mathieu-Daudé (3):
hw/block/pflash_cfi: fix off-by-one error
qdev: rename typedefqdev_resetfn()->DeviceReset()
qdev: add helpers to be more explicit when using abstract QOM parent functionsPrasad Singamsetty (2):
intel-iommu: Redefine macros to enable supporting 48 bit address width
intel-iommu: Extend address width to 48 bitsRichard Henderson (2):
tcg: Markmuluh_i64andmulsh_i64as 64-bit ops
tcg: Introducetcg_set_insn_start_paramShannon Zhao (3):
arm_gicv3_kvm: increase clroffset accordingly
arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked byGICR_IPRIORITYRStefan Berger (1):
tpm: Set the flags of theCMD_INITcommand to 0Thomas Huth (1):
pc-bios/s390-ccw: structtpi_infomust be declared as aligned(4)Tiwei Bie (1):
virtio-balloon: unref the memory region before continuingVictor Kamensky (1):
arm/translate-a64: treatDISAS_UPDATEas variant ofDISAS_EXITViktor Mihajlovski (1):
s390: Do not pass inofficial IPL type to the guestlinzhecheng (1):
vhost-user: delete net client if necessaryMAINTAINERS | 6 + block.c | 17 +- block/file-posix.c | 5 +- block/gluster.c | 21 +- block/nbd-client.c | 3 - block/nbd.c | 2 + block/qcow2.c | 2 +- block/raw-format.c | 64 +++-- block/rbd.c | 3 +- block/ssh.c | 1 + block/throttle.c | 54 ++-- configure | 5 +- cpus.c | 10 +- device_tree.c | 2 +- docs/interop/qcow2.txt | 16 +- exec.c | 92 ++++--- hw/block/pflash_cfi01.c | 10 +- hw/block/pflash_cfi02.c | 9 +- hw/char/cmsdk-apb-uart.c | 1 + hw/core/loader.c | 20 +- hw/core/qdev.c | 24 ++ hw/display/qxl-render.c | 3 +- hw/display/vga.c | 2 + hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 489 +++++++++++++++++++++++++++---------- hw/i386/intel_iommu_internal.h | 43 ++-- hw/i386/multiboot.c | 85 ++++--- hw/i386/trace-events | 5 +- hw/ide/ahci.c | 13 +- hw/intc/arm_gicv3_common.c | 79 ++++++ hw/intc/arm_gicv3_cpuif.c | 12 +- hw/intc/arm_gicv3_kvm.c | 57 ++++- hw/intc/openpic_kvm.c | 4 - hw/net/virtio-net.c | 11 + hw/pci-bridge/i82801b11.c | 1 + hw/ppc/spapr.c | 161 +++++++----- hw/ppc/spapr_caps.c | 5 + hw/ppc/spapr_cpu_core.c | 9 +- hw/s390x/ccw-device.c | 8 + hw/s390x/css.c | 8 + hw/s390x/virtio-ccw.c | 54 ++-- hw/s390x/virtio-ccw.h | 3 +- hw/tpm/tpm_emulator.c | 4 +- hw/usb/dev-smartcard-reader.c | 4 +- hw/usb/host-libusb.c | 4 + hw/vfio/ccw.c | 2 + hw/virtio/virtio-balloon.c | 1 + include/block/block.h | 1 + include/exec/cpu-all.h | 6 +- include/exec/cpu_ldst.h | 16 +- include/exec/memory-internal.h | 13 +- include/exec/memory.h | 45 ++-- include/hw/i386/intel_iommu.h | 26 +- include/hw/intc/arm_gicv3_common.h | 1 + include/hw/ppc/spapr.h | 3 +- include/hw/qdev-core.h | 14 +- include/net/net.h | 1 + include/qemu/iova-tree.h | 134 ++++++++++ linux-user/mmap.c | 26 +- linux-user/syscall.c | 13 +- memory.c | 30 --- migration/block.c | 5 +- nbd/client.c | 14 +- net/net.c | 1 - net/tap.c | 2 + net/vhost-user.c | 11 +- pc-bios/s390-ccw/bootmap.c | 7 + pc-bios/s390-ccw/cio.h | 2 +- pc-bios/s390-ccw/iplb.h | 16 +- qemu-img.c | 29 ++- qemu-io.c | 4 +- scsi/qemu-pr-helper.c | 7 +- target/arm/translate-a64.c | 6 +- target/arm/translate.c | 17 +- target/arm/translate.h | 2 +- target/i386/cpu.c | 4 +- target/i386/cpu.h | 3 + target/i386/kvm.c | 16 +- target/i386/machine.c | 20 ++ target/i386/translate.c | 2 +- target/lm32/op_helper.c | 4 + target/ppc/compat.c | 25 +- target/ppc/cpu.h | 2 +- target/ppc/machine.c | 5 + target/sparc/translate.c | 5 + target/xtensa/translate.c | 1 + tcg/arm/tcg-target.inc.c | 4 +- tcg/tcg-opc.h | 4 +- tcg/tcg.h | 10 + tests/multiboot/.gitignore | 3 + tests/multiboot/Makefile | 22 +- tests/multiboot/aout_kludge.S | 138 +++++++++++ tests/multiboot/aout_kludge.out | 42 ++++ tests/multiboot/run_test.sh | 34 +-- tests/qemu-iotests/024 | 82 ++++++- tests/qemu-iotests/024.out | 30 +++ tests/qemu-iotests/060 | 30 +++ tests/qemu-iotests/060.out | 14 ++ tests/qemu-iotests/106 | 24 ++ tests/qemu-iotests/106.out | 10 + tests/qemu-iotests/153 | 17 ++ tests/qemu-iotests/153.out | 16 ++ tests/qemu-iotests/221 | 60 +++++ tests/qemu-iotests/221.out | 16 ++ tests/qemu-iotests/group | 1 + ui/console.c | 5 + util/Makefile.objs | 1 + util/iova-tree.c | 114 +++++++++ util/memfd.c | 4 +- 109 files changed, 2072 insertions(+), 585 deletions(-) create mode 100644 include/qemu/iova-tree.h create mode 100644 tests/multiboot/.gitignore create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out create mode 100644 util/iova-tree.c