* [Stable-7.2.8 01/24] target/arm: Fix SME FMOPA (16-bit), BFMOPA
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 02/24] hw/ide/ahci: fix legacy software reset Michael Tokarev
` (22 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Richard Henderson, Philippe Mathieu-Daudé,
Peter Maydell, Michael Tokarev
From: Richard Henderson <richard.henderson@linaro.org>
Perform the loop increment unconditionally, not nested
within the predication.
Cc: qemu-stable@nongnu.org
Fixes: 3916841ac75 ("target/arm: Implement FMOPA, FMOPS (widening)")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1985
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231117193135.1180657-1-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 3efd8495735c69b863476e9003e624877382a72d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index 73dd838330..8856773635 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -1070,10 +1070,9 @@ void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn,
m = f16mop_adj_pair(m, pcol, 0);
*a = f16_dotadd(*a, n, m, &fpst_std, &fpst_odd);
-
- col += 4;
- pcol >>= 4;
}
+ col += 4;
+ pcol >>= 4;
} while (col & 15);
}
row += 4;
@@ -1106,10 +1105,9 @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn,
m = f16mop_adj_pair(m, pcol, 0);
*a = bfdotadd(*a, n, m);
-
- col += 4;
- pcol >>= 4;
}
+ col += 4;
+ pcol >>= 4;
} while (col & 15);
}
row += 4;
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 02/24] hw/ide/ahci: fix legacy software reset
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 01/24] target/arm: Fix SME FMOPA (16-bit), BFMOPA Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 03/24] net: Provide MemReentrancyGuard * to qemu_new_nic() Michael Tokarev
` (21 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Niklas Cassel, Marcin Juszkiewicz, Kevin Wolf,
Michael Tokarev
From: Niklas Cassel <niklas.cassel@wdc.com>
Legacy software contains a standard mechanism for generating a reset to a
Serial ATA device - setting the SRST (software reset) bit in the Device
Control register.
Serial ATA has a more robust mechanism called COMRESET, also referred to
as port reset. A port reset is the preferred mechanism for error
recovery and should be used in place of software reset.
Commit e2a5d9b3d9c3 ("hw/ide/ahci: simplify and document PxCI handling")
(mjt: 1e5ad6b06b1e in stable-7.2 series, v7.2.6)
improved the handling of PxCI, such that PxCI gets cleared after handling
a non-NCQ, or NCQ command (instead of incorrectly clearing PxCI after
receiving anything - even a FIS that failed to parse, which should NOT
clear PxCI, so that you can see which command slot that caused an error).
However, simply clearing PxCI after a non-NCQ, or NCQ command, is not
enough, we also need to clear PxCI when receiving a SRST in the Device
Control register.
A legacy software reset is performed by the host sending two H2D FISes,
the first H2D FIS asserts SRST, and the second H2D FIS deasserts SRST.
The first H2D FIS will not get a D2H reply, and requires the FIS to have
the C bit set to one, such that the HBA itself will clear the bit in PxCI.
The second H2D FIS will get a D2H reply once the diagnostic is completed.
The clearing of the bit in PxCI for this command should ideally be done
in ahci_init_d2h() (if it was a legacy software reset that caused the
reset (a COMRESET does not use a command slot)). However, since the reset
value for PxCI is 0, modify ahci_reset_port() to actually clear PxCI to 0,
that way we can avoid complex logic in ahci_init_d2h().
This fixes an issue for FreeBSD where the device would fail to reset.
The problem was not noticed in Linux, because Linux uses a COMRESET
instead of a legacy software reset by default.
Fixes: e2a5d9b3d9c3 ("hw/ide/ahci: simplify and document PxCI handling")
Reported-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Message-ID: <20231108222657.117984-1-nks@flawful.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit eabb921250666501ae78714b60090200b639fcfe)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: mention 1e5ad6b06b1e for stable-7.2)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index c5e79b6e6d..0167ab3680 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -622,9 +622,13 @@ static void ahci_init_d2h(AHCIDevice *ad)
return;
}
+ /*
+ * For simplicity, do not call ahci_clear_cmd_issue() for this
+ * ahci_write_fis_d2h(). (The reset value for PxCI is 0.)
+ */
if (ahci_write_fis_d2h(ad, true)) {
ad->init_d2h_sent = true;
- /* We're emulating receiving the first Reg H2D Fis from the device;
+ /* We're emulating receiving the first Reg D2H FIS from the device;
* Update the SIG register, but otherwise proceed as normal. */
pr->sig = ((uint32_t)ide_state->hcyl << 24) |
(ide_state->lcyl << 16) |
@@ -662,6 +666,7 @@ static void ahci_reset_port(AHCIState *s, int port)
pr->scr_act = 0;
pr->tfdata = 0x7F;
pr->sig = 0xFFFFFFFF;
+ pr->cmd_issue = 0;
d->busy_slot = -1;
d->init_d2h_sent = false;
@@ -1242,10 +1247,30 @@ static void handle_reg_h2d_fis(AHCIState *s, int port,
case STATE_RUN:
if (cmd_fis[15] & ATA_SRST) {
s->dev[port].port_state = STATE_RESET;
+ /*
+ * When setting SRST in the first H2D FIS in the reset sequence,
+ * the device does not send a D2H FIS. Host software thus has to
+ * set the "Clear Busy upon R_OK" bit such that PxCI (and BUSY)
+ * gets cleared. See AHCI 1.3.1, section 10.4.1 Software Reset.
+ */
+ if (opts & AHCI_CMD_CLR_BUSY) {
+ ahci_clear_cmd_issue(ad, slot);
+ }
}
break;
case STATE_RESET:
if (!(cmd_fis[15] & ATA_SRST)) {
+ /*
+ * When clearing SRST in the second H2D FIS in the reset
+ * sequence, the device will execute diagnostics. When this is
+ * done, the device will send a D2H FIS with the good status.
+ * See SATA 3.5a Gold, section 11.4 Software reset protocol.
+ *
+ * This D2H FIS is the first D2H FIS received from the device,
+ * and is received regardless if the reset was performed by a
+ * COMRESET or by setting and clearing the SRST bit. Therefore,
+ * the logic for this is found in ahci_init_d2h() and not here.
+ */
ahci_reset_port(s, port);
}
break;
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 03/24] net: Provide MemReentrancyGuard * to qemu_new_nic()
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 01/24] target/arm: Fix SME FMOPA (16-bit), BFMOPA Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 02/24] hw/ide/ahci: fix legacy software reset Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 04/24] net: Update MemReentrancyGuard for NIC Michael Tokarev
` (20 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Akihiko Odaki, Alexander Bulekov, Jason Wang,
Michael Tokarev
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Recently MemReentrancyGuard was added to DeviceState to record that the
device is engaging in I/O. The network device backend needs to update it
when delivering a packet to a device.
In preparation for such a change, add MemReentrancyGuard * as a
parameter of qemu_new_nic().
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 7d0fefdf81f5973334c344f6b8e1896c309dff66)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: fixup in hw/net/xen_nic.c due to lack of v8.1.0-2771-g25967ff69f
"hw/xen: update Xen PV NIC to XenDevice model"
and removed hw/net/igb.c bits)
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index c3fed5fcbe..1a6a79f5ae 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -824,7 +824,8 @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_allwinner_sun8i_emac_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
index ddddf35c45..b3d73143bf 100644
--- a/hw/net/allwinner_emac.c
+++ b/hw/net/allwinner_emac.c
@@ -453,7 +453,8 @@ static void aw_emac_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_aw_emac_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
fifo8_create(&s->rx_fifo, RX_FIFO_SIZE);
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 24b3a0ff66..cb61a76417 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1633,7 +1633,8 @@ static void gem_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_gem_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
if (s->jumbo_max_len > MAX_FRAME_SIZE) {
error_setg(errp, "jumbo-max-len is greater than %d",
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 45b954e46c..abfcc6f69f 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -943,7 +943,8 @@ static void dp8393x_realize(DeviceState *dev, Error **errp)
"dp8393x-regs", SONIC_REG_COUNT << s->it_shift);
s->nic = qemu_new_nic(&net_dp83932_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0dfdf47313..0a78ad3a58 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1735,7 +1735,8 @@ static void pci_e1000_realize(PCIDevice *pci_dev, Error **errp)
macaddr);
d->nic = qemu_new_nic(&net_e1000_info, &d->conf,
- object_get_typename(OBJECT(d)), dev->id, d);
+ object_get_typename(OBJECT(d)), dev->id,
+ &dev->mem_reentrancy_guard, d);
qemu_format_nic_info_str(qemu_get_queue(d->nic), macaddr);
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
index 7523e9f5d2..6573cc3cc3 100644
--- a/hw/net/e1000e.c
+++ b/hw/net/e1000e.c
@@ -319,7 +319,7 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr)
int i;
s->nic = qemu_new_nic(&net_e1000e_info, &s->conf,
- object_get_typename(OBJECT(s)), dev->id, s);
+ object_get_typename(OBJECT(s)), dev->id, &dev->mem_reentrancy_guard, s);
s->core.max_queue_num = s->conf.peers.queues ? s->conf.peers.queues - 1 : 0;
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 679f52f80f..871d9a0950 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1874,7 +1874,9 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
nic_reset(s);
s->nic = qemu_new_nic(&net_eepro100_info, &s->conf,
- object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s);
+ object_get_typename(OBJECT(pci_dev)),
+ pci_dev->qdev.id,
+ &pci_dev->qdev.mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
TRACE(OTHER, logout("%s\n", qemu_get_queue(s->nic)->info_str));
diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index 1b82aec794..ba57a978d1 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -618,7 +618,8 @@ static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_etraxfs_info, &s->conf,
- object_get_typename(OBJECT(s)), dev->id, s);
+ object_get_typename(OBJECT(s)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->phy.read = tdk_read;
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index b75d8e3dce..102ba69658 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -390,7 +390,8 @@ static void etsec_realize(DeviceState *dev, Error **errp)
eTSEC *etsec = ETSEC_COMMON(dev);
etsec->nic = qemu_new_nic(&net_etsec_info, &etsec->conf,
- object_get_typename(OBJECT(dev)), dev->id, etsec);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, etsec);
qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a);
etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_LEGACY);
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
index 83ef0a783e..346485ab49 100644
--- a/hw/net/ftgmac100.c
+++ b/hw/net/ftgmac100.c
@@ -1118,7 +1118,8 @@ static void ftgmac100_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_ftgmac100_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
index ec21e2699a..dc64246f75 100644
--- a/hw/net/i82596.c
+++ b/hw/net/i82596.c
@@ -743,7 +743,7 @@ void i82596_common_init(DeviceState *dev, I82596State *s, NetClientInfo *info)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
}
s->nic = qemu_new_nic(info, &s->conf, object_get_typename(OBJECT(dev)),
- dev->id, s);
+ dev->id, &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
if (USE_TIMER) {
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
index 8c11b237de..7eb2fef626 100644
--- a/hw/net/imx_fec.c
+++ b/hw/net/imx_fec.c
@@ -1318,7 +1318,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)
s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf,
object_get_typename(OBJECT(dev)),
- dev->id, s);
+ dev->id, &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index f1cba55967..00a6d82efb 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -1362,7 +1362,8 @@ static void lan9118_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_lan9118_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->eeprom[0] = 0xa5;
for (i = 0; i < 6; i++) {
diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 8aa27bd322..57dd49abea 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -643,7 +643,8 @@ static void mcf_fec_realize(DeviceState *dev, Error **errp)
mcf_fec_state *s = MCF_FEC_NET(dev);
s->nic = qemu_new_nic(&net_mcf_fec_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c
index 2ade72dea0..8e925de867 100644
--- a/hw/net/mipsnet.c
+++ b/hw/net/mipsnet.c
@@ -255,7 +255,8 @@ static void mipsnet_realize(DeviceState *dev, Error **errp)
sysbus_init_irq(sbd, &s->irq);
s->nic = qemu_new_nic(&net_mipsnet_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c
index db3a04deb1..145a5e46ab 100644
--- a/hw/net/msf2-emac.c
+++ b/hw/net/msf2-emac.c
@@ -530,7 +530,8 @@ static void msf2_emac_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_msf2_emac_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/mv88w8618_eth.c b/hw/net/mv88w8618_eth.c
index ef30b0d4a6..2185f1131a 100644
--- a/hw/net/mv88w8618_eth.c
+++ b/hw/net/mv88w8618_eth.c
@@ -350,7 +350,8 @@ static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
}
static const VMStateDescription mv88w8618_eth_vmsd = {
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index 6ced6775ff..a79f7fad1f 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -74,7 +74,8 @@ static void isa_ne2000_realizefn(DeviceState *dev, Error **errp)
ne2000_reset(s);
s->nic = qemu_new_nic(&net_ne2000_isa_info, &s->c,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
}
diff --git a/hw/net/ne2000-pci.c b/hw/net/ne2000-pci.c
index 9e5d10859a..4f8a699081 100644
--- a/hw/net/ne2000-pci.c
+++ b/hw/net/ne2000-pci.c
@@ -71,7 +71,8 @@ static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
object_get_typename(OBJECT(pci_dev)),
- pci_dev->qdev.id, s);
+ pci_dev->qdev.id,
+ &pci_dev->qdev.mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
}
diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c
index 7c86bb52e5..4bb4e7147d 100644
--- a/hw/net/npcm7xx_emc.c
+++ b/hw/net/npcm7xx_emc.c
@@ -803,7 +803,8 @@ static void npcm7xx_emc_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&emc->conf.macaddr);
emc->nic = qemu_new_nic(&net_npcm7xx_emc_info, &emc->conf,
- object_get_typename(OBJECT(dev)), dev->id, emc);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, emc);
qemu_format_nic_info_str(qemu_get_queue(emc->nic), emc->conf.macaddr.a);
}
diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
index 0b3dc3146e..f96d6ea2cc 100644
--- a/hw/net/opencores_eth.c
+++ b/hw/net/opencores_eth.c
@@ -732,7 +732,8 @@ static void sysbus_open_eth_realize(DeviceState *dev, Error **errp)
sysbus_init_irq(sbd, &s->irq);
s->nic = qemu_new_nic(&net_open_eth_info, &s->conf,
- object_get_typename(OBJECT(s)), dev->id, s);
+ object_get_typename(OBJECT(s)), dev->id,
+ &dev->mem_reentrancy_guard, s);
}
static void qdev_open_eth_reset(DeviceState *dev)
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index e63e524913..56c3d14ad6 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -1718,7 +1718,8 @@ void pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info)
s->poll_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pcnet_poll_timer, s);
qemu_macaddr_default_if_unset(&s->conf.macaddr);
- s->nic = qemu_new_nic(info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s);
+ s->nic = qemu_new_nic(info, &s->conf, object_get_typename(OBJECT(dev)),
+ dev->id, &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
/* Initialize the PROM */
diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
index cbeed65bd5..0d21948ada 100644
--- a/hw/net/rocker/rocker_fp.c
+++ b/hw/net/rocker/rocker_fp.c
@@ -241,8 +241,8 @@ FpPort *fp_port_alloc(Rocker *r, char *sw_name,
port->conf.bootindex = -1;
port->conf.peers = *peers;
- port->nic = qemu_new_nic(&fp_port_info, &port->conf,
- sw_name, NULL, port);
+ port->nic = qemu_new_nic(&fp_port_info, &port->conf, sw_name, NULL,
+ &DEVICE(r)->mem_reentrancy_guard, port);
qemu_format_nic_info_str(qemu_get_queue(port->nic),
port->conf.macaddr.a);
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index eb679d7c40..a4462af431 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3400,7 +3400,8 @@ static void pci_rtl8139_realize(PCIDevice *dev, Error **errp)
s->eeprom.contents[9] = s->conf.macaddr.a[4] | s->conf.macaddr.a[5] << 8;
s->nic = qemu_new_nic(&net_rtl8139_info, &s->conf,
- object_get_typename(OBJECT(dev)), d->id, s);
+ object_get_typename(OBJECT(dev)), d->id,
+ &d->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->cplus_txbuffer = NULL;
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index ad778cd8fc..4eda971ef3 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -783,7 +783,8 @@ static void smc91c111_realize(DeviceState *dev, Error **errp)
sysbus_init_irq(sbd, &s->irq);
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
/* ??? Save/restore. */
}
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index a6876a936d..475d5f3a34 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -325,7 +325,8 @@ static void spapr_vlan_realize(SpaprVioDevice *sdev, Error **errp)
memcpy(&dev->perm_mac.a, &dev->nicconf.macaddr.a, sizeof(dev->perm_mac.a));
dev->nic = qemu_new_nic(&net_spapr_vlan_info, &dev->nicconf,
- object_get_typename(OBJECT(sdev)), sdev->qdev.id, dev);
+ object_get_typename(OBJECT(sdev)), sdev->qdev.id,
+ &sdev->qdev.mem_reentrancy_guard, dev);
qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macaddr.a);
dev->rxp_timer = timer_new_us(QEMU_CLOCK_VIRTUAL, spapr_vlan_flush_rx_queue,
diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index 8dd60783d8..6768a6912f 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -492,7 +492,8 @@ static void stellaris_enet_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_stellaris_enet_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/sungem.c b/hw/net/sungem.c
index 3684a4d733..c12d44e9dc 100644
--- a/hw/net/sungem.c
+++ b/hw/net/sungem.c
@@ -1361,7 +1361,7 @@ static void sungem_realize(PCIDevice *pci_dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_sungem_info, &s->conf,
object_get_typename(OBJECT(dev)),
- dev->id, s);
+ dev->id, &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic),
s->conf.macaddr.a);
}
diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c
index fc34905f87..fa98528d71 100644
--- a/hw/net/sunhme.c
+++ b/hw/net/sunhme.c
@@ -892,7 +892,8 @@ static void sunhme_realize(PCIDevice *pci_dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_sunhme_info, &s->conf,
- object_get_typename(OBJECT(d)), d->id, s);
+ object_get_typename(OBJECT(d)), d->id,
+ &d->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index c2b3b1bdfa..956093abd7 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -983,7 +983,8 @@ static void pci_tulip_realize(PCIDevice *pci_dev, Error **errp)
s->nic = qemu_new_nic(&net_tulip_info, &s->c,
object_get_typename(OBJECT(pci_dev)),
- pci_dev->qdev.id, s);
+ pci_dev->qdev.id,
+ &pci_dev->qdev.mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
}
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1b10cdc127..06f35ac2d8 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3633,10 +3633,12 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
* Happen when virtio_net_set_netclient_name has been called.
*/
n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf,
- n->netclient_type, n->netclient_name, n);
+ n->netclient_type, n->netclient_name,
+ &dev->mem_reentrancy_guard, n);
} else {
n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf,
- object_get_typename(OBJECT(dev)), dev->id, n);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, n);
}
for (i = 0; i < n->max_queue_pairs; i++) {
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 399fc14129..e49b4a7a6c 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2083,7 +2083,7 @@ static void vmxnet3_net_init(VMXNET3State *s)
s->nic = qemu_new_nic(&net_vmxnet3_info, &s->conf,
object_get_typename(OBJECT(s)),
- d->id, s);
+ d->id, &d->mem_reentrancy_guard, s);
s->peer_has_vhdr = vmxnet3_peer_has_vnet_hdr(s);
s->tx_sop = true;
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index 7d92c2d022..1014e84518 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -294,7 +294,8 @@ static int net_init(struct XenLegacyDevice *xendev)
}
netdev->nic = qemu_new_nic(&net_xen_info, &netdev->conf,
- "xen", NULL, netdev);
+ "xen", NULL,
+ &xendev->qdev.mem_reentrancy_guard, netdev);
qemu_set_info_str(qemu_get_queue(netdev->nic),
"nic: xenbus vif macaddr=%s", netdev->mac);
diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 0ab6ae91aa..1f4f277d84 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -402,7 +402,8 @@ static void xgmac_enet_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_xgmac_enet_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->regs[XGMAC_ADDR_HIGH(0)] = (s->conf.macaddr.a[5] << 8) |
diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 990ff3a1c2..8a34243803 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -968,7 +968,8 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_xilinx_enet_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
tdk_init(&s->TEMAC.phy);
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
index 6e09f7e422..80cb869e22 100644
--- a/hw/net/xilinx_ethlite.c
+++ b/hw/net/xilinx_ethlite.c
@@ -235,7 +235,8 @@ static void xilinx_ethlite_realize(DeviceState *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_xilinx_ethlite_info, &s->conf,
- object_get_typename(OBJECT(dev)), dev->id, s);
+ object_get_typename(OBJECT(dev)), dev->id,
+ &dev->mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
}
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 5fff487ee5..2c33e36cad 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1386,7 +1386,8 @@ static void usb_net_realize(USBDevice *dev, Error **errp)
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,
- object_get_typename(OBJECT(s)), s->dev.qdev.id, s);
+ object_get_typename(OBJECT(s)), s->dev.qdev.id,
+ &s->dev.qdev.mem_reentrancy_guard, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
"%02x%02x%02x%02x%02x%02x",
diff --git a/include/net/net.h b/include/net/net.h
index dc20b31e9f..4f1b702f00 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -151,6 +151,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
NICConf *conf,
const char *model,
const char *name,
+ MemReentrancyGuard *reentrancy_guard,
void *opaque);
void qemu_del_nic(NICState *nic);
NetClientState *qemu_get_subqueue(NICState *nic, int queue_index);
diff --git a/net/net.c b/net/net.c
index 840ad9dca5..716a29f5a5 100644
--- a/net/net.c
+++ b/net/net.c
@@ -319,6 +319,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
NICConf *conf,
const char *model,
const char *name,
+ MemReentrancyGuard *reentrancy_guard,
void *opaque)
{
NetClientState **peers = conf->peers.ncs;
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 04/24] net: Update MemReentrancyGuard for NIC
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (2 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 03/24] net: Provide MemReentrancyGuard * to qemu_new_nic() Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 05/24] linux-user: Fix loaddr computation for some elf files Michael Tokarev
` (19 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Akihiko Odaki, Alexander Bulekov, Jason Wang,
Michael Tokarev
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Recently MemReentrancyGuard was added to DeviceState to record that the
device is engaging in I/O. The network device backend needs to update it
when delivering a packet to a device.
This implementation follows what bottom half does, but it does not add
a tracepoint for the case that the network device backend started
delivering a packet to a device which is already engaging in I/O. This
is because such reentrancy frequently happens for
qemu_flush_queued_packets() and is insignificant.
Fixes: CVE-2023-3019
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 9050f976e447444ea6ee2ba12c9f77e4b0dc54bc)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/include/net/net.h b/include/net/net.h
index 4f1b702f00..5a7c0e9ebf 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -118,6 +118,7 @@ struct NetClientState {
typedef struct NICState {
NetClientState *ncs;
NICConf *conf;
+ MemReentrancyGuard *reentrancy_guard;
void *opaque;
bool peer_deleted;
} NICState;
diff --git a/net/net.c b/net/net.c
index 716a29f5a5..c3391168f6 100644
--- a/net/net.c
+++ b/net/net.c
@@ -332,6 +332,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
nic = g_malloc0(info->size + sizeof(NetClientState) * queues);
nic->ncs = (void *)nic + info->size;
nic->conf = conf;
+ nic->reentrancy_guard = reentrancy_guard,
nic->opaque = opaque;
for (i = 0; i < queues; i++) {
@@ -787,6 +788,7 @@ static ssize_t qemu_deliver_packet_iov(NetClientState *sender,
int iovcnt,
void *opaque)
{
+ MemReentrancyGuard *owned_reentrancy_guard;
NetClientState *nc = opaque;
int ret;
@@ -799,12 +801,24 @@ static ssize_t qemu_deliver_packet_iov(NetClientState *sender,
return 0;
}
+ if (nc->info->type != NET_CLIENT_DRIVER_NIC ||
+ qemu_get_nic(nc)->reentrancy_guard->engaged_in_io) {
+ owned_reentrancy_guard = NULL;
+ } else {
+ owned_reentrancy_guard = qemu_get_nic(nc)->reentrancy_guard;
+ owned_reentrancy_guard->engaged_in_io = true;
+ }
+
if (nc->info->receive_iov && !(flags & QEMU_NET_PACKET_FLAG_RAW)) {
ret = nc->info->receive_iov(nc, iov, iovcnt);
} else {
ret = nc_sendv_compat(nc, iov, iovcnt, flags);
}
+ if (owned_reentrancy_guard) {
+ owned_reentrancy_guard->engaged_in_io = false;
+ }
+
if (ret == 0) {
nc->receive_disabled = 1;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 05/24] linux-user: Fix loaddr computation for some elf files
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (3 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 04/24] net: Update MemReentrancyGuard for NIC Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 06/24] tests/avocado: Replace assertEquals() for Python 3.12 compatibility Michael Tokarev
` (18 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Richard Henderson, Michael Tokarev
From: Richard Henderson <richard.henderson@linaro.org>
The file offset of the load segment is not relevant to the
low address, only the beginning of the virtual address page.
Cc: qemu-stable@nongnu.org
Fixes: a93934fecd4 ("elf: take phdr offset into account when calculating the program load address")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1952
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit 82d70a84c8ee42ef969a9cfddc0f5b30b16165f5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c2c095d383..87895847ec 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3001,7 +3001,7 @@ static void load_elf_image(const char *image_name, int image_fd,
for (i = 0; i < ehdr->e_phnum; ++i) {
struct elf_phdr *eppnt = phdr + i;
if (eppnt->p_type == PT_LOAD) {
- abi_ulong a = eppnt->p_vaddr - eppnt->p_offset;
+ abi_ulong a = eppnt->p_vaddr & TARGET_PAGE_MASK;
if (a < loaddr) {
loaddr = a;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 06/24] tests/avocado: Replace assertEquals() for Python 3.12 compatibility
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (4 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 05/24] linux-user: Fix loaddr computation for some elf files Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 07/24] tests/avocado: Replace assertRegexpMatches() " Michael Tokarev
` (17 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Thomas Huth, Philippe Mathieu-Daudé,
Michael Tokarev
From: Thomas Huth <thuth@redhat.com>
assertEquals() has been removed in Python 3.12 and should be replaced by
assertEqual(). See: https://docs.python.org/3.12/whatsnew/3.12.html#id3
Message-ID: <20231114134326.287242-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit 861f724d03e1748cda1c5b9ec8457a368590cbd5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: adjust context in pc_cpu_hotplug_props.py & cpu_queries.py for before
v8.1.0-1582-g684750ab4f "python/qemu: rename command() to cmd()")
diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index e10c47b5a7..8cad156aa0 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -1051,7 +1051,7 @@ and hypothetical example follows:
'human-monitor-command',
command_line='info version')
- self.assertEquals(first_res, second_res, third_res)
+ self.assertEqual(first_res, second_res, third_res)
At test "tear down", ``avocado_qemu.Test`` handles all the QEMUMachines
shutdown.
diff --git a/tests/avocado/cpu_queries.py b/tests/avocado/cpu_queries.py
index cf69f69b11..295642772e 100644
--- a/tests/avocado/cpu_queries.py
+++ b/tests/avocado/cpu_queries.py
@@ -31,4 +31,4 @@ def test(self):
for c in cpus:
model = {'name': c['name']}
e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
- self.assertEquals(e['model']['name'], c['name'])
+ self.assertEqual(e['model']['name'], c['name'])
diff --git a/tests/avocado/empty_cpu_model.py b/tests/avocado/empty_cpu_model.py
index 22f504418d..d906ef3d3c 100644
--- a/tests/avocado/empty_cpu_model.py
+++ b/tests/avocado/empty_cpu_model.py
@@ -15,5 +15,5 @@ def test(self):
self.vm.set_qmp_monitor(enabled=False)
self.vm.launch()
self.vm.wait()
- self.assertEquals(self.vm.exitcode(), 1, "QEMU exit code should be 1")
+ self.assertEqual(self.vm.exitcode(), 1, "QEMU exit code should be 1")
self.assertRegex(self.vm.get_log(), r'-cpu option cannot be empty')
diff --git a/tests/avocado/pc_cpu_hotplug_props.py b/tests/avocado/pc_cpu_hotplug_props.py
index 52b878188e..6100fb7760 100644
--- a/tests/avocado/pc_cpu_hotplug_props.py
+++ b/tests/avocado/pc_cpu_hotplug_props.py
@@ -32,4 +32,4 @@ def test_no_die_id(self):
self.vm.add_args('-smp', '1,sockets=2,cores=2,threads=2,maxcpus=8')
self.vm.add_args('-device', 'qemu64-x86_64-cpu,socket-id=1,core-id=0,thread-id=0')
self.vm.launch()
- self.assertEquals(len(self.vm.command('query-cpus-fast')), 2)
+ self.assertEqual(len(self.vm.command('query-cpus-fast')), 2)
diff --git a/tests/avocado/x86_cpu_model_versions.py b/tests/avocado/x86_cpu_model_versions.py
index a6edf74c1c..262d6a77fb 100644
--- a/tests/avocado/x86_cpu_model_versions.py
+++ b/tests/avocado/x86_cpu_model_versions.py
@@ -119,94 +119,95 @@ def test_4_1_alias(self):
self.assertFalse(cpus['Cascadelake-Server']['static'],
'unversioned Cascadelake-Server CPU model must not be static')
- self.assertEquals(cpus['Cascadelake-Server'].get('alias-of'), 'Cascadelake-Server-v1',
- 'Cascadelake-Server must be an alias of Cascadelake-Server-v1')
+ self.assertEqual(cpus['Cascadelake-Server'].get('alias-of'),
+ 'Cascadelake-Server-v1',
+ 'Cascadelake-Server must be an alias of Cascadelake-Server-v1')
self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
'Cascadelake-Server-v1 must not be an alias')
self.assertFalse(cpus['qemu64']['static'],
'unversioned qemu64 CPU model must not be static')
- self.assertEquals(cpus['qemu64'].get('alias-of'), 'qemu64-v1',
- 'qemu64 must be an alias of qemu64-v1')
+ self.assertEqual(cpus['qemu64'].get('alias-of'), 'qemu64-v1',
+ 'qemu64 must be an alias of qemu64-v1')
self.assertNotIn('alias-of', cpus['qemu64-v1'],
'qemu64-v1 must not be an alias')
self.validate_variant_aliases(cpus)
# On pc-*-4.1, -noTSX and -IBRS models should be aliases:
- self.assertEquals(cpus["Haswell"].get('alias-of'),
- "Haswell-v1",
+ self.assertEqual(cpus["Haswell"].get('alias-of'),
+ "Haswell-v1",
"Haswell must be an alias")
- self.assertEquals(cpus["Haswell-noTSX"].get('alias-of'),
- "Haswell-v2",
+ self.assertEqual(cpus["Haswell-noTSX"].get('alias-of'),
+ "Haswell-v2",
"Haswell-noTSX must be an alias")
- self.assertEquals(cpus["Haswell-IBRS"].get('alias-of'),
- "Haswell-v3",
+ self.assertEqual(cpus["Haswell-IBRS"].get('alias-of'),
+ "Haswell-v3",
"Haswell-IBRS must be an alias")
- self.assertEquals(cpus["Haswell-noTSX-IBRS"].get('alias-of'),
- "Haswell-v4",
+ self.assertEqual(cpus["Haswell-noTSX-IBRS"].get('alias-of'),
+ "Haswell-v4",
"Haswell-noTSX-IBRS must be an alias")
- self.assertEquals(cpus["Broadwell"].get('alias-of'),
- "Broadwell-v1",
+ self.assertEqual(cpus["Broadwell"].get('alias-of'),
+ "Broadwell-v1",
"Broadwell must be an alias")
- self.assertEquals(cpus["Broadwell-noTSX"].get('alias-of'),
- "Broadwell-v2",
+ self.assertEqual(cpus["Broadwell-noTSX"].get('alias-of'),
+ "Broadwell-v2",
"Broadwell-noTSX must be an alias")
- self.assertEquals(cpus["Broadwell-IBRS"].get('alias-of'),
- "Broadwell-v3",
+ self.assertEqual(cpus["Broadwell-IBRS"].get('alias-of'),
+ "Broadwell-v3",
"Broadwell-IBRS must be an alias")
- self.assertEquals(cpus["Broadwell-noTSX-IBRS"].get('alias-of'),
- "Broadwell-v4",
+ self.assertEqual(cpus["Broadwell-noTSX-IBRS"].get('alias-of'),
+ "Broadwell-v4",
"Broadwell-noTSX-IBRS must be an alias")
- self.assertEquals(cpus["Nehalem"].get('alias-of'),
- "Nehalem-v1",
+ self.assertEqual(cpus["Nehalem"].get('alias-of'),
+ "Nehalem-v1",
"Nehalem must be an alias")
- self.assertEquals(cpus["Nehalem-IBRS"].get('alias-of'),
- "Nehalem-v2",
+ self.assertEqual(cpus["Nehalem-IBRS"].get('alias-of'),
+ "Nehalem-v2",
"Nehalem-IBRS must be an alias")
- self.assertEquals(cpus["Westmere"].get('alias-of'),
- "Westmere-v1",
+ self.assertEqual(cpus["Westmere"].get('alias-of'),
+ "Westmere-v1",
"Westmere must be an alias")
- self.assertEquals(cpus["Westmere-IBRS"].get('alias-of'),
- "Westmere-v2",
+ self.assertEqual(cpus["Westmere-IBRS"].get('alias-of'),
+ "Westmere-v2",
"Westmere-IBRS must be an alias")
- self.assertEquals(cpus["SandyBridge"].get('alias-of'),
- "SandyBridge-v1",
+ self.assertEqual(cpus["SandyBridge"].get('alias-of'),
+ "SandyBridge-v1",
"SandyBridge must be an alias")
- self.assertEquals(cpus["SandyBridge-IBRS"].get('alias-of'),
- "SandyBridge-v2",
+ self.assertEqual(cpus["SandyBridge-IBRS"].get('alias-of'),
+ "SandyBridge-v2",
"SandyBridge-IBRS must be an alias")
- self.assertEquals(cpus["IvyBridge"].get('alias-of'),
- "IvyBridge-v1",
+ self.assertEqual(cpus["IvyBridge"].get('alias-of'),
+ "IvyBridge-v1",
"IvyBridge must be an alias")
- self.assertEquals(cpus["IvyBridge-IBRS"].get('alias-of'),
- "IvyBridge-v2",
+ self.assertEqual(cpus["IvyBridge-IBRS"].get('alias-of'),
+ "IvyBridge-v2",
"IvyBridge-IBRS must be an alias")
- self.assertEquals(cpus["Skylake-Client"].get('alias-of'),
- "Skylake-Client-v1",
+ self.assertEqual(cpus["Skylake-Client"].get('alias-of'),
+ "Skylake-Client-v1",
"Skylake-Client must be an alias")
- self.assertEquals(cpus["Skylake-Client-IBRS"].get('alias-of'),
- "Skylake-Client-v2",
+ self.assertEqual(cpus["Skylake-Client-IBRS"].get('alias-of'),
+ "Skylake-Client-v2",
"Skylake-Client-IBRS must be an alias")
- self.assertEquals(cpus["Skylake-Server"].get('alias-of'),
- "Skylake-Server-v1",
+ self.assertEqual(cpus["Skylake-Server"].get('alias-of'),
+ "Skylake-Server-v1",
"Skylake-Server must be an alias")
- self.assertEquals(cpus["Skylake-Server-IBRS"].get('alias-of'),
- "Skylake-Server-v2",
+ self.assertEqual(cpus["Skylake-Server-IBRS"].get('alias-of'),
+ "Skylake-Server-v2",
"Skylake-Server-IBRS must be an alias")
- self.assertEquals(cpus["EPYC"].get('alias-of'),
- "EPYC-v1",
+ self.assertEqual(cpus["EPYC"].get('alias-of'),
+ "EPYC-v1",
"EPYC must be an alias")
- self.assertEquals(cpus["EPYC-IBPB"].get('alias-of'),
- "EPYC-v2",
+ self.assertEqual(cpus["EPYC-IBPB"].get('alias-of'),
+ "EPYC-v2",
"EPYC-IBPB must be an alias")
self.validate_aliases(cpus)
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 07/24] tests/avocado: Replace assertRegexpMatches() for Python 3.12 compatibility
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (5 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 06/24] tests/avocado: Replace assertEquals() for Python 3.12 compatibility Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 08/24] target/arm: Set IL bit for pauth, SVE access, BTI trap syndromes Michael Tokarev
` (16 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Thomas Huth,
Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
assertRegexpMatches() has been removed in Python 3.12 and should be replaced by
assertRegex(). See: https://docs.python.org/3.12/whatsnew/3.12.html#id3
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231114144832.71612-1-philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit f0a663b4ced2bf315936c774c2b6ff398fce8905)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: adjust context for before v8.1.0-1582-g684750ab4f
"python/qemu: rename command() to cmd()")
diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index 8cad156aa0..98c26ecf18 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -990,7 +990,7 @@ class. Here's a simple usage example:
self.vm.launch()
res = self.vm.command('human-monitor-command',
command_line='info version')
- self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
+ self.assertRegex(res, r'^(\d+\.\d+\.\d)')
To execute your test, run:
diff --git a/tests/avocado/version.py b/tests/avocado/version.py
index ded7f039c1..5f88ff300b 100644
--- a/tests/avocado/version.py
+++ b/tests/avocado/version.py
@@ -21,4 +21,4 @@ def test_qmp_human_info_version(self):
self.vm.launch()
res = self.vm.command('human-monitor-command',
command_line='info version')
- self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
+ self.assertRegex(res, r'^(\d+\.\d+\.\d)')
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 08/24] target/arm: Set IL bit for pauth, SVE access, BTI trap syndromes
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (6 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 07/24] tests/avocado: Replace assertRegexpMatches() " Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 09/24] hw/virtio: Free VirtIOIOMMUPCI::vdev.reserved_regions[] on finalize() Michael Tokarev
` (15 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Peter Maydell, Richard Henderson, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
The syndrome register value always has an IL field at bit 25, which
is 0 for a trap on a 16 bit instruction, and 1 for a trap on a 32
bit instruction (or for exceptions which aren't traps on a known
instruction, like PC alignment faults). This means that our
syn_*() functions should always either take an is_16bit argument to
determine whether to set the IL bit, or else unconditionally set it.
We missed setting the IL bit for the syndrome for three kinds of trap:
* an SVE access exception
* a pointer authentication check failure
* a BTI (branch target identification) check failure
All of these traps are AArch64 only, and so the instruction causing
the trap is always 64 bit. This means we can unconditionally set
the IL bit in the syn_*() function.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20231120150121.3458408-1-peter.maydell@linaro.org
Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 11a3c4a286d5dc603582ea0a1fca62c2ec0a1aee)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
index 73df5e3793..15334a3d15 100644
--- a/target/arm/syndrome.h
+++ b/target/arm/syndrome.h
@@ -212,7 +212,7 @@ static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit)
static inline uint32_t syn_sve_access_trap(void)
{
- return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT;
+ return (EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL;
}
static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit)
@@ -223,12 +223,12 @@ static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit)
static inline uint32_t syn_pactrap(void)
{
- return EC_PACTRAP << ARM_EL_EC_SHIFT;
+ return (EC_PACTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL;
}
static inline uint32_t syn_btitrap(int btype)
{
- return (EC_BTITRAP << ARM_EL_EC_SHIFT) | btype;
+ return (EC_BTITRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | btype;
}
static inline uint32_t syn_bxjtrap(int cv, int cond, int rm)
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 09/24] hw/virtio: Free VirtIOIOMMUPCI::vdev.reserved_regions[] on finalize()
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (7 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 08/24] target/arm: Set IL bit for pauth, SVE access, BTI trap syndromes Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 10/24] hw/misc/mps2-scc: Free MPS2SCC::oscclk[] array " Michael Tokarev
` (14 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Eric Auger,
Peter Maydell, Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Commit 0be6bfac62 ("qdev: Implement variable length array properties")
added the DEFINE_PROP_ARRAY() macro with the following comment:
* It is the responsibility of the device deinit code to free the
* @_arrayfield memory.
Commit 8077b8e549 added:
DEFINE_PROP_ARRAY("reserved-regions", VirtIOIOMMUPCI,
vdev.nb_reserved_regions, vdev.reserved_regions,
qdev_prop_reserved_region, ReservedRegion),
but forgot to free the 'vdev.reserved_regions' array. Do it in the
instance_finalize() handler.
Cc: qemu-stable@nongnu.org
Fixes: 8077b8e549 ("virtio-iommu-pci: Add array of Interval properties") # v5.1.0+
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Message-id: 20231121174051.63038-3-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit c9a4aa06dfce0fde1e279e1ea0c1945582ec0d16)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: fixup hw/virtio/virtio-iommu-pci.c for before v8.1.0-2552-g41cc70cdf5,
"virtio-iommu: Rename reserved_regions into prop_resv_regions" -- so now
patch subject matches actual change again)
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
index 7ef2f9dcdb..eab6e1c793 100644
--- a/hw/virtio/virtio-iommu-pci.c
+++ b/hw/virtio/virtio-iommu-pci.c
@@ -95,10 +95,18 @@ static void virtio_iommu_pci_instance_init(Object *obj)
TYPE_VIRTIO_IOMMU);
}
+static void virtio_iommu_pci_instance_finalize(Object *obj)
+{
+ VirtIOIOMMUPCI *dev = VIRTIO_IOMMU_PCI(obj);
+
+ g_free(dev->vdev.reserved_regions);
+}
+
static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = {
.generic_name = TYPE_VIRTIO_IOMMU_PCI,
.instance_size = sizeof(VirtIOIOMMUPCI),
.instance_init = virtio_iommu_pci_instance_init,
+ .instance_finalize = virtio_iommu_pci_instance_finalize,
.class_init = virtio_iommu_pci_class_init,
};
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 10/24] hw/misc/mps2-scc: Free MPS2SCC::oscclk[] array on finalize()
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (8 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 09/24] hw/virtio: Free VirtIOIOMMUPCI::vdev.reserved_regions[] on finalize() Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 11/24] hw/nvram/xlnx-efuse: Free XlnxEFuse::ro_bits[] " Michael Tokarev
` (13 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Peter Maydell,
Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Commit 0be6bfac62 ("qdev: Implement variable length array properties")
added the DEFINE_PROP_ARRAY() macro with the following comment:
* It is the responsibility of the device deinit code to free the
* @_arrayfield memory.
Commit 4fb013afcc added:
DEFINE_PROP_ARRAY("oscclk", MPS2SCC, num_oscclk, oscclk_reset,
qdev_prop_uint32, uint32_t),
but forgot to free the 'oscclk_reset' array. Do it in the
instance_finalize() handler.
Cc: qemu-stable@nongnu.org
Fixes: 4fb013afcc ("hw/misc/mps2-scc: Support configurable number of OSCCLK values") # v6.0.0+
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231121174051.63038-4-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 896dd6ff7b9f2575f1a908a07f26a70b58d8b675)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
index b3b42a792c..fe5034db14 100644
--- a/hw/misc/mps2-scc.c
+++ b/hw/misc/mps2-scc.c
@@ -329,6 +329,13 @@ static void mps2_scc_realize(DeviceState *dev, Error **errp)
s->oscclk = g_new0(uint32_t, s->num_oscclk);
}
+static void mps2_scc_finalize(Object *obj)
+{
+ MPS2SCC *s = MPS2_SCC(obj);
+
+ g_free(s->oscclk_reset);
+}
+
static const VMStateDescription mps2_scc_vmstate = {
.name = "mps2-scc",
.version_id = 3,
@@ -385,6 +392,7 @@ static const TypeInfo mps2_scc_info = {
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(MPS2SCC),
.instance_init = mps2_scc_init,
+ .instance_finalize = mps2_scc_finalize,
.class_init = mps2_scc_class_init,
};
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 11/24] hw/nvram/xlnx-efuse: Free XlnxEFuse::ro_bits[] array on finalize()
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (9 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 10/24] hw/misc/mps2-scc: Free MPS2SCC::oscclk[] array " Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 12/24] hw/nvram/xlnx-efuse-ctrl: Free XlnxVersalEFuseCtrl[] "pg0-lock" array Michael Tokarev
` (12 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Peter Maydell,
Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Commit 0be6bfac62 ("qdev: Implement variable length array properties")
added the DEFINE_PROP_ARRAY() macro with the following comment:
* It is the responsibility of the device deinit code to free the
* @_arrayfield memory.
Commit 68fbcc344e added:
DEFINE_PROP_ARRAY("read-only", XlnxEFuse, ro_bits_cnt, ro_bits,
qdev_prop_uint32, uint32_t),
but forgot to free the 'ro_bits' array. Do it in the instance_finalize
handler.
Cc: qemu-stable@nongnu.org
Fixes: 68fbcc344e ("hw/nvram: Introduce Xilinx eFuse QOM") # v6.2.0+
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231121174051.63038-5-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 49b3e28b7bdfe771150d05c4b5860aa7854a4232)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
index fdfffaab99..aff5254129 100644
--- a/hw/nvram/xlnx-efuse.c
+++ b/hw/nvram/xlnx-efuse.c
@@ -217,6 +217,13 @@ static void efuse_realize(DeviceState *dev, Error **errp)
}
}
+static void efuse_finalize(Object *obj)
+{
+ XlnxEFuse *s = XLNX_EFUSE(obj);
+
+ g_free(s->ro_bits);
+}
+
static void efuse_prop_set_drive(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
@@ -273,6 +280,7 @@ static const TypeInfo efuse_info = {
.name = TYPE_XLNX_EFUSE,
.parent = TYPE_DEVICE,
.instance_size = sizeof(XlnxEFuse),
+ .instance_finalize = efuse_finalize,
.class_init = efuse_class_init,
};
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 12/24] hw/nvram/xlnx-efuse-ctrl: Free XlnxVersalEFuseCtrl[] "pg0-lock" array
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (10 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 11/24] hw/nvram/xlnx-efuse: Free XlnxEFuse::ro_bits[] " Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 13/24] hw/virtio: Add VirtioPCIDeviceTypeInfo::instance_finalize field Michael Tokarev
` (11 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Peter Maydell,
Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Commit 0be6bfac62 ("qdev: Implement variable length array properties")
added the DEFINE_PROP_ARRAY() macro with the following comment:
* It is the responsibility of the device deinit code to free the
* @_arrayfield memory.
Commit 9e4aa1fafe added:
DEFINE_PROP_ARRAY("pg0-lock",
XlnxVersalEFuseCtrl, extra_pg0_lock_n16,
extra_pg0_lock_spec, qdev_prop_uint16, uint16_t),
but forgot to free the 'extra_pg0_lock_spec' array. Do it in the
instance_finalize() handler.
Cc: qemu-stable@nongnu.org
Fixes: 9e4aa1fafe ("hw/nvram: Xilinx Versal eFuse device") # v6.2.0+
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231121174051.63038-6-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 4f10c66077e39969940d928077560665e155cac8)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c
index b35ba65ab5..2d2dc09526 100644
--- a/hw/nvram/xlnx-versal-efuse-ctrl.c
+++ b/hw/nvram/xlnx-versal-efuse-ctrl.c
@@ -725,6 +725,13 @@ static void efuse_ctrl_init(Object *obj)
sysbus_init_irq(sbd, &s->irq_efuse_imr);
}
+static void efuse_ctrl_finalize(Object *obj)
+{
+ XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj);
+
+ g_free(s->extra_pg0_lock_spec);
+}
+
static const VMStateDescription vmstate_efuse_ctrl = {
.name = TYPE_XLNX_VERSAL_EFUSE_CTRL,
.version_id = 1,
@@ -762,6 +769,7 @@ static const TypeInfo efuse_ctrl_info = {
.instance_size = sizeof(XlnxVersalEFuseCtrl),
.class_init = efuse_ctrl_class_init,
.instance_init = efuse_ctrl_init,
+ .instance_finalize = efuse_ctrl_finalize,
};
static void efuse_ctrl_register_types(void)
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 13/24] hw/virtio: Add VirtioPCIDeviceTypeInfo::instance_finalize field
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (11 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 12/24] hw/nvram/xlnx-efuse-ctrl: Free XlnxVersalEFuseCtrl[] "pg0-lock" array Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 14/24] vmdk: Don't corrupt desc file in vmdk_write_cid Michael Tokarev
` (10 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Peter Maydell,
Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
The VirtioPCIDeviceTypeInfo structure, added in commit a4ee4c8baa
("virtio: Helper for registering virtio device types") got extended
in commit 8ea90ee690 ("virtio: add class_size") with the @class_size
field. Do similarly with the @instance_finalize field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231121174051.63038-2-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 837053a7f491b445088eac647abe7f462c50f59a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 67e771c373..e5e74a7160 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2174,6 +2174,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t)
.parent = t->parent ? t->parent : TYPE_VIRTIO_PCI,
.instance_size = t->instance_size,
.instance_init = t->instance_init,
+ .instance_finalize = t->instance_finalize,
.class_size = t->class_size,
.abstract = true,
.interfaces = t->interfaces,
diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h
index 938799e8f6..c4676ff4d4 100644
--- a/include/hw/virtio/virtio-pci.h
+++ b/include/hw/virtio/virtio-pci.h
@@ -241,6 +241,7 @@ typedef struct VirtioPCIDeviceTypeInfo {
size_t instance_size;
size_t class_size;
void (*instance_init)(Object *obj);
+ void (*instance_finalize)(Object *obj);
void (*class_init)(ObjectClass *klass, void *data);
InterfaceInfo *interfaces;
} VirtioPCIDeviceTypeInfo;
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 14/24] vmdk: Don't corrupt desc file in vmdk_write_cid
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (12 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 13/24] hw/virtio: Add VirtioPCIDeviceTypeInfo::instance_finalize field Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 15/24] hw/mips/malta: Fix the malta machine on big endian hosts Michael Tokarev
` (9 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Fam Zheng, Kevin Wolf, Eric Blake, Michael Tokarev
From: Fam Zheng <fam@euphon.net>
If the text description file is larger than DESC_SIZE, we force the last
byte in the buffer to be 0 and write it out.
This results in a corruption.
Try to allocate a big buffer in this case.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1923
Signed-off-by: Fam Zheng <fam@euphon.net>
Message-ID: <20231124115654.3239137-1-fam@euphon.net>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 9fb7b350ba9816ebca8a7614fec486fd4269ab2d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: fixups in block/vmdk.c due to missing-in-7.2 v8.0.0-2084-g28944f99c4
"vmdk: mark more functions as coroutine_fns and GRAPH_RDLOCK")
diff --git a/block/vmdk.c b/block/vmdk.c
index 26376352b9..f8d3a13568 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -346,29 +346,41 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
BDRVVmdkState *s = bs->opaque;
int ret = 0;
- desc = g_malloc0(DESC_SIZE);
- tmp_desc = g_malloc0(DESC_SIZE);
- ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
+ size_t desc_buf_size;
+
+ if (s->desc_offset == 0) {
+ desc_buf_size = bdrv_getlength(bs->file->bs);
+ if (desc_buf_size > 16ULL << 20) {
+ error_report("VMDK description file too big");
+ return -EFBIG;
+ }
+ } else {
+ desc_buf_size = DESC_SIZE;
+ }
+
+ desc = g_malloc0(desc_buf_size);
+ tmp_desc = g_malloc0(desc_buf_size);
+ ret = bdrv_pread(bs->file, s->desc_offset, desc_buf_size, desc, 0);
if (ret < 0) {
goto out;
}
- desc[DESC_SIZE - 1] = '\0';
+ desc[desc_buf_size - 1] = '\0';
tmp_str = strstr(desc, "parentCID");
if (tmp_str == NULL) {
ret = -EINVAL;
goto out;
}
- pstrcpy(tmp_desc, DESC_SIZE, tmp_str);
+ pstrcpy(tmp_desc, desc_buf_size, tmp_str);
p_name = strstr(desc, "CID");
if (p_name != NULL) {
p_name += sizeof("CID");
- snprintf(p_name, DESC_SIZE - (p_name - desc), "%" PRIx32 "\n", cid);
- pstrcat(desc, DESC_SIZE, tmp_desc);
+ snprintf(p_name, desc_buf_size - (p_name - desc), "%" PRIx32 "\n", cid);
+ pstrcat(desc, desc_buf_size, tmp_desc);
}
- ret = bdrv_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc, 0);
+ ret = bdrv_pwrite_sync(bs->file, s->desc_offset, desc_buf_size, desc, 0);
out:
g_free(desc);
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
index e8be217e1f..9bcf1e7525 100755
--- a/tests/qemu-iotests/059
+++ b/tests/qemu-iotests/059
@@ -84,6 +84,8 @@ echo
echo "=== Testing big twoGbMaxExtentFlat ==="
_make_test_img -o "subformat=twoGbMaxExtentFlat" 1000G
_img_info --format-specific | _filter_img_info --format-specific
+$QEMU_IO -c "write 990G 512 -P 89" "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "read 990G 512 -P 89" "$TEST_IMG" | _filter_qemu_io
_cleanup_test_img
echo
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
index 2b83c0c8b6..275ee7c778 100644
--- a/tests/qemu-iotests/059.out
+++ b/tests/qemu-iotests/059.out
@@ -2032,6 +2032,10 @@ Format specific information:
virtual size: 2147483648
filename: TEST_DIR/t-f500.IMGFMT
format: FLAT
+wrote 512/512 bytes at offset 1063004405760
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 512/512 bytes at offset 1063004405760
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing malformed VMFS extent description line ===
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 15/24] hw/mips/malta: Fix the malta machine on big endian hosts
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (13 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 14/24] vmdk: Don't corrupt desc file in vmdk_write_cid Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 16/24] hw/audio/hda-codec: fix multiplication overflow Michael Tokarev
` (8 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Thomas Huth, Peter Maydell, Michael Tokarev
From: Thomas Huth <thuth@redhat.com>
Booting a Linux kernel with the malta machine is currently broken
on big endian hosts. The cpu_to_gt32 macro wants to byteswap a value
for little endian targets only, but uses the wrong way to do this:
cpu_to_[lb]e32 works the other way round on big endian hosts! Fix
it by using the same ways on both, big and little endian hosts.
Fixes: 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")
Cc: qemu-stable@nongnu.org
Message-Id: <20230330152613.232082-1-thuth@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit dc96009afd8cf2372fa1bbced0bcbcbb2c5d6f1b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: adjust context for before v7.2.0-677-g0e45355c5c)
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index c0a2e0ab04..da7c110b73 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -877,9 +877,9 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,
/* Bus endianess is always reversed */
#if TARGET_BIG_ENDIAN
-#define cpu_to_gt32 cpu_to_le32
+#define cpu_to_gt32(x) (x)
#else
-#define cpu_to_gt32 cpu_to_be32
+#define cpu_to_gt32(x) bswap32(x)
#endif
/* move GT64120 registers from 0x14000000 to 0x1be00000 */
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 16/24] hw/audio/hda-codec: fix multiplication overflow
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (14 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 15/24] hw/mips/malta: Fix the malta machine on big endian hosts Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 18/24] hw/acpi/erst: Do not ignore Error* in realize handler Michael Tokarev
` (7 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Volker Rümelin, M_O_Bz, Marc-André Lureau,
Michael S . Tsirkin, Michael Tokarev
From: Volker Rümelin <vr_qemu@t-online.de>
After a relatively short time, there is an multiplication overflow
when multiplying (now - buft_start) with hda_bytes_per_second().
While the uptime now - buft_start only overflows after 2**63 ns
= 292.27 years, this happens hda_bytes_per_second() times faster
with the multiplication. At 44100 samples/s * 2 channels
* 2 bytes/channel = 176400 bytes/s that is 14.52 hours. After the
multiplication overflow the affected audio stream stalls.
Replace the multiplication and following division with muldiv64()
to prevent a multiplication overflow.
Fixes: 280c1e1cdb ("audio/hda: create millisecond timers that handle IO")
Reported-by: M_O_Bz <m_o_bz@163.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20231105172552.8405-1-vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 74e8593e7e51d6b11ae9c56a3f4e7bb714bac4ec)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index feb8f9e2bb..0f66754b6a 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -22,6 +22,7 @@
#include "hw/qdev-properties.h"
#include "intel-hda.h"
#include "migration/vmstate.h"
+#include "qemu/host-utils.h"
#include "qemu/module.h"
#include "intel-hda-defs.h"
#include "audio/audio.h"
@@ -190,9 +191,9 @@ struct HDAAudioState {
bool use_timer;
};
-static inline int64_t hda_bytes_per_second(HDAAudioStream *st)
+static inline uint32_t hda_bytes_per_second(HDAAudioStream *st)
{
- return 2LL * st->as.nchannels * st->as.freq;
+ return 2 * (uint32_t)st->as.nchannels * (uint32_t)st->as.freq;
}
static inline void hda_timer_sync_adjust(HDAAudioStream *st, int64_t target_pos)
@@ -223,12 +224,18 @@ static void hda_audio_input_timer(void *opaque)
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- int64_t buft_start = st->buft_start;
+ int64_t uptime = now - st->buft_start;
int64_t wpos = st->wpos;
int64_t rpos = st->rpos;
+ int64_t wanted_rpos;
- int64_t wanted_rpos = hda_bytes_per_second(st) * (now - buft_start)
- / NANOSECONDS_PER_SECOND;
+ if (uptime <= 0) {
+ /* wanted_rpos <= 0 */
+ goto out_timer;
+ }
+
+ wanted_rpos = muldiv64(uptime, hda_bytes_per_second(st),
+ NANOSECONDS_PER_SECOND);
wanted_rpos &= -4; /* IMPORTANT! clip to frames */
if (wanted_rpos <= rpos) {
@@ -287,12 +294,18 @@ static void hda_audio_output_timer(void *opaque)
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- int64_t buft_start = st->buft_start;
+ int64_t uptime = now - st->buft_start;
int64_t wpos = st->wpos;
int64_t rpos = st->rpos;
+ int64_t wanted_wpos;
+
+ if (uptime <= 0) {
+ /* wanted_wpos <= 0 */
+ goto out_timer;
+ }
- int64_t wanted_wpos = hda_bytes_per_second(st) * (now - buft_start)
- / NANOSECONDS_PER_SECOND;
+ wanted_wpos = muldiv64(uptime, hda_bytes_per_second(st),
+ NANOSECONDS_PER_SECOND);
wanted_wpos &= -4; /* IMPORTANT! clip to frames */
if (wanted_wpos <= wpos) {
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 18/24] hw/acpi/erst: Do not ignore Error* in realize handler
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (15 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 16/24] hw/audio/hda-codec: fix multiplication overflow Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 19/24] msix: unset PCIDevice::msix_vector_poll_notifier in rollback Michael Tokarev
` (6 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Ani Sinha,
Michael S . Tsirkin, Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
erst_realizefn() passes @errp to functions without checking for
failure. If it runs into another failure, it trips error_setv()'s
assertion.
Use the ERRP_GUARD() macro and check *errp, as suggested in commit
ae7c80a7bd ("error: New macro ERRP_GUARD()").
Cc: qemu-stable@nongnu.org
Fixes: f7e26ffa59 ("ACPI ERST: support for ACPI ERST feature")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20231120130017.81286-1-philmd@linaro.org>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 20bc50137f3add52eb4788b420d717de27fed14b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c
index aefcc03ad6..2e057b1800 100644
--- a/hw/acpi/erst.c
+++ b/hw/acpi/erst.c
@@ -947,6 +947,7 @@ static const VMStateDescription erst_vmstate = {
static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
{
+ ERRP_GUARD();
ERSTDeviceState *s = ACPIERST(pci_dev);
trace_acpi_erst_realizefn_in();
@@ -964,9 +965,15 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
/* HostMemoryBackend size will be multiple of PAGE_SIZE */
s->storage_size = object_property_get_int(OBJECT(s->hostmem), "size", errp);
+ if (*errp) {
+ return;
+ }
/* Initialize backend storage and record_count */
check_erst_backend_storage(s, errp);
+ if (*errp) {
+ return;
+ }
/* BAR 0: Programming registers */
memory_region_init_io(&s->iomem_mr, OBJECT(pci_dev), &erst_reg_ops, s,
@@ -977,6 +984,9 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
memory_region_init_ram(&s->exchange_mr, OBJECT(pci_dev),
"erst.exchange",
le32_to_cpu(s->header->record_size), errp);
+ if (*errp) {
+ return;
+ }
pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
&s->exchange_mr);
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 19/24] msix: unset PCIDevice::msix_vector_poll_notifier in rollback
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (16 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 18/24] hw/acpi/erst: Do not ignore Error* in realize handler Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 20/24] ui/gtk-egl: Check EGLSurface before doing scanout Michael Tokarev
` (5 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Robert Hoo, Philippe Mathieu-Daudé,
Michael S . Tsirkin, Michael Tokarev
From: Robert Hoo <robert.hoo.linux@gmail.com>
In the rollback in msix_set_vector_notifiers(), original patch forgot to
undo msix_vector_poll_notifier pointer.
Fixes: bbef882cc193 ("msi: add API to get notified about pending bit poll")
Signed-off-by: Robert Hoo <robert.hoo.linux@gmail.com>
Message-Id: <20231113081349.1307-1-robert.hoo.linux@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 2d37fe9e5e61b04bddbed00dbb7436e61a01c115)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index 9e70fcd6fa..4b258566d4 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -639,6 +639,7 @@ undo:
}
dev->msix_vector_use_notifier = NULL;
dev->msix_vector_release_notifier = NULL;
+ dev->msix_vector_poll_notifier = NULL;
return ret;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 20/24] ui/gtk-egl: Check EGLSurface before doing scanout
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (17 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 19/24] msix: unset PCIDevice::msix_vector_poll_notifier in rollback Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 21/24] ui/gtk-egl: move function calls back to regular code path Michael Tokarev
` (4 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Antonio Caggiano, Marc-André Lureau,
Michael Tokarev
From: Antonio Caggiano <quic_acaggian@quicinc.com>
The first time gd_egl_scanout_texture() is called, there's a possibility
that the GTK drawing area might not be realized yet, in which case its
associated GdkWindow is NULL. This means gd_egl_init() was also skipped
and the EGLContext and EGLSurface stored in the VirtualGfxConsole are
not valid yet.
Continuing with the scanout in this conditions would result in hitting
an assert in libepoxy: "Couldn't find current GLX or EGL context".
A possible workaround is to just ignore the scanout request, giving the
the GTK drawing area some time to finish its realization. At that point,
the gd_egl_init() will succeed and the EGLContext and EGLSurface stored
in the VirtualGfxConsole will be valid.
Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20231016123215.2699269-1-quic_acaggian@quicinc.com>
(cherry picked from commit 6f189a08c1b0085808af1bfbf4567f0da193ecc1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 52c6246a33..17755b1185 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -234,12 +234,19 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
vc->gfx.h = h;
vc->gfx.y0_top = backing_y_0_top;
- eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
- vc->gfx.esurface, vc->gfx.ectx);
+ if (!vc->gfx.esurface) {
+ gd_egl_init(vc);
+ if (!vc->gfx.esurface) {
+ return;
+ }
- gtk_egl_set_scanout_mode(vc, true);
- egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
- backing_id, false);
+ eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+ vc->gfx.esurface, vc->gfx.ectx);
+
+ gtk_egl_set_scanout_mode(vc, true);
+ egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+ backing_id, false);
+ }
}
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 21/24] ui/gtk-egl: move function calls back to regular code path
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (18 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 20/24] ui/gtk-egl: Check EGLSurface before doing scanout Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 22/24] ui/vnc-clipboard: fix inflate_buffer Michael Tokarev
` (3 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Volker Rümelin, Marc-André Lureau,
Michael Tokarev
From: Volker Rümelin <vr_qemu@t-online.de>
Commit 6f189a08c1 ("ui/gtk-egl: Check EGLSurface before doing
scanout") introduced a regression when QEMU is running with a
virtio-gpu-gl-device on a host under X11. After the guest has
initialized the virtio-gpu-gl-device, the guest screen only
shows "Display output is not active.".
Commit 6f189a08c1 moved all function calls in
gd_egl_scanout_texture() to a code path which is only called
once after gd_egl_init() succeeds in gd_egl_scanout_texture().
Move all function calls in gd_egl_scanout_texture() back to
the regular code path so they get always called if one of the
gd_egl_init() calls was successful.
Fixes: 6f189a08c1 ("ui/gtk-egl: Check EGLSurface before doing scanout")
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20231111104020.26183-1-vr_qemu@t-online.de>
(cherry picked from commit 53a939f1bf8e4a3e38f9449fac44f572676966ad)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 17755b1185..7ff9f1648c 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -239,14 +239,14 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
if (!vc->gfx.esurface) {
return;
}
+ }
- eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
- vc->gfx.esurface, vc->gfx.ectx);
+ eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+ vc->gfx.esurface, vc->gfx.ectx);
- gtk_egl_set_scanout_mode(vc, true);
- egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
- backing_id, false);
- }
+ gtk_egl_set_scanout_mode(vc, true);
+ egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+ backing_id, false);
}
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 22/24] ui/vnc-clipboard: fix inflate_buffer
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (19 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 21/24] ui/gtk-egl: move function calls back to regular code path Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 23/24] target/arm: Disable SME if SVE is disabled Michael Tokarev
` (2 subsequent siblings)
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Fiona Ebner, Friedrich Weber, Marc-André Lureau,
Michael Tokarev
From: Fiona Ebner <f.ebner@proxmox.com>
Commit d921fea338 ("ui/vnc-clipboard: fix infinite loop in
inflate_buffer (CVE-2023-3255)") removed this hunk, but it is still
required, because it can happen that stream.avail_in becomes zero
before coming across a return value of Z_STREAM_END in the loop.
This fixes the host->guest direction of the clipboard with noVNC and
TigerVNC as clients.
Fixes: d921fea338 ("ui/vnc-clipboard: fix infinite loop in inflate_buffer (CVE-2023-3255)")
Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20231122125826.228189-1-f.ebner@proxmox.com>
(cherry picked from commit ebfbf394671163c14e2b24d98f3927a3151d1aff)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/vnc-clipboard.c b/ui/vnc-clipboard.c
index c759be3438..124b6fbd9c 100644
--- a/ui/vnc-clipboard.c
+++ b/ui/vnc-clipboard.c
@@ -69,6 +69,11 @@ static uint8_t *inflate_buffer(uint8_t *in, uint32_t in_len, uint32_t *size)
}
}
+ *size = stream.total_out;
+ inflateEnd(&stream);
+
+ return out;
+
err_end:
inflateEnd(&stream);
err:
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 23/24] target/arm: Disable SME if SVE is disabled
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (20 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 22/24] ui/vnc-clipboard: fix inflate_buffer Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 13:00 ` [Stable-7.2.8 24/24] system/memory: use ldn_he_p/stn_he_p Michael Tokarev
2023-12-13 16:01 ` [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Cole Robinson
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Peter Maydell, Richard Henderson, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
There is no architectural requirement that SME implies SVE, but
our implementation currently assumes it. (FEAT_SME_FA64 does
imply SVE.) So if you try to run a CPU with eg "-cpu max,sve=off"
you quickly run into an assert when the guest tries to write to
SMCR_EL1:
#6 0x00007ffff4b38e96 in __GI___assert_fail
(assertion=0x5555566e69cb "sm", file=0x5555566e5b24 "../../target/arm/helper.c", line=6865, function=0x5555566e82f0 <__PRETTY_FUNCTION__.31> "sve_vqm1_for_el_sm") at ./assert/assert.c:101
#7 0x0000555555ee33aa in sve_vqm1_for_el_sm (env=0x555557d291f0, el=2, sm=false) at ../../target/arm/helper.c:6865
#8 0x0000555555ee3407 in sve_vqm1_for_el (env=0x555557d291f0, el=2) at ../../target/arm/helper.c:6871
#9 0x0000555555ee3724 in smcr_write (env=0x555557d291f0, ri=0x555557da23b0, value=2147483663) at ../../target/arm/helper.c:6995
#10 0x0000555555fd1dba in helper_set_cp_reg64 (env=0x555557d291f0, rip=0x555557da23b0, value=2147483663) at ../../target/arm/tcg/op_helper.c:839
#11 0x00007fff60056781 in code_gen_buffer ()
Avoid this unsupported and slightly odd combination by
disabling SME when SVE is not present.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2005
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20231127173318.674758-1-peter.maydell@linaro.org
(cherry picked from commit f7767ca301796334f74b9b642b395a4bd3e3dbac)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 38d066c294..6cf7a33591 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1498,6 +1498,16 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
return;
}
+ /*
+ * FEAT_SME is not architecturally dependent on FEAT_SVE (unless
+ * FEAT_SME_FA64 is present). However our implementation currently
+ * assumes it, so if the user asked for sve=off then turn off SME also.
+ * (KVM doesn't currently support SME at all.)
+ */
+ if (cpu_isar_feature(aa64_sme, cpu) && !cpu_isar_feature(aa64_sve, cpu)) {
+ object_property_set_bool(OBJECT(cpu), "sme", false, &error_abort);
+ }
+
arm_cpu_sme_finalize(cpu, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Stable-7.2.8 24/24] system/memory: use ldn_he_p/stn_he_p
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (21 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 23/24] target/arm: Disable SME if SVE is disabled Michael Tokarev
@ 2023-12-13 13:00 ` Michael Tokarev
2023-12-13 16:01 ` [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Cole Robinson
23 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-13 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Patrick Venture, Chris Rauer, Peter Foley,
Philippe Mathieu-Daudé, David Hildenbrand, Michael Tokarev
From: Patrick Venture <venture@google.com>
Using direct pointer dereferencing can allow for unaligned accesses,
which was seen during execution with sanitizers enabled.
Cc: qemu-stable@nongnu.org
Reviewed-by: Chris Rauer <crauer@google.com>
Reviewed-by: Peter Foley <pefoley@google.com>
Signed-off-by: Patrick Venture <venture@google.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20231116163633.276671-1-venture@google.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit 2b8fe81b3c2e76d241510a9a85496d544e42f5ec)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 61569f8306..2b03596bc7 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1326,22 +1326,7 @@ static uint64_t memory_region_ram_device_read(void *opaque,
hwaddr addr, unsigned size)
{
MemoryRegion *mr = opaque;
- uint64_t data = (uint64_t)~0;
-
- switch (size) {
- case 1:
- data = *(uint8_t *)(mr->ram_block->host + addr);
- break;
- case 2:
- data = *(uint16_t *)(mr->ram_block->host + addr);
- break;
- case 4:
- data = *(uint32_t *)(mr->ram_block->host + addr);
- break;
- case 8:
- data = *(uint64_t *)(mr->ram_block->host + addr);
- break;
- }
+ uint64_t data = ldn_he_p(mr->ram_block->host + addr, size);
trace_memory_region_ram_device_read(get_cpu_index(), mr, addr, data, size);
@@ -1355,20 +1340,7 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr,
trace_memory_region_ram_device_write(get_cpu_index(), mr, addr, data, size);
- switch (size) {
- case 1:
- *(uint8_t *)(mr->ram_block->host + addr) = (uint8_t)data;
- break;
- case 2:
- *(uint16_t *)(mr->ram_block->host + addr) = (uint16_t)data;
- break;
- case 4:
- *(uint32_t *)(mr->ram_block->host + addr) = (uint32_t)data;
- break;
- case 8:
- *(uint64_t *)(mr->ram_block->host + addr) = data;
- break;
- }
+ stn_he_p(mr->ram_block->host + addr, size, data);
}
static const MemoryRegionOps ram_device_mem_ops = {
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23
2023-12-13 13:00 [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Michael Tokarev
` (22 preceding siblings ...)
2023-12-13 13:00 ` [Stable-7.2.8 24/24] system/memory: use ldn_he_p/stn_he_p Michael Tokarev
@ 2023-12-13 16:01 ` Cole Robinson
2023-12-14 8:14 ` Michael Tokarev
23 siblings, 1 reply; 26+ messages in thread
From: Cole Robinson @ 2023-12-13 16:01 UTC (permalink / raw)
To: Michael Tokarev, qemu-devel; +Cc: qemu-stable
On 12/13/23 8:00 AM, Michael Tokarev wrote:
> The following patches are queued for QEMU stable v7.2.8:
>
> https://gitlab.com/qemu-project/qemu/-/commits/staging-7.2
>
> Patch freeze is 2023-12-23, and the release is planned for 2023-12-25:
>
> https://wiki.qemu.org/Planning/7.2
>
> Please respond here or CC qemu-stable@nongnu.org on any additional patches
> you think should (or shouldn't) be included in the release.
>
> The changes which are staging for inclusion, with the original commit hash
> from master branch, are given below the bottom line.
>
We are carrying these 2 patches in fedora to fix test suite failures:
commit abe2c4bdb65e8dd9cb2f01c355baa394bf49a8af
Author: Eric Auger <eric.auger@redhat.com>
Date: Tue Feb 28 10:29:44 2023 +0100
test-vmstate: fix bad GTree usage, use-after-free
commit ae4b01b3497934849278b49f3dfd28420f75e300
Author: Richard W.M. Jones <rjones@redhat.com>
Date: Tue Feb 28 19:06:45 2023 +0000
tests: Ensure TAP version is printed before other messages
Thank you for your work on the stable releases!
- Cole
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23
2023-12-13 16:01 ` [Stable-7.2.8 00/24] Patch Round-up for stable 7.2.8, freeze on 2023-12-23 Cole Robinson
@ 2023-12-14 8:14 ` Michael Tokarev
0 siblings, 0 replies; 26+ messages in thread
From: Michael Tokarev @ 2023-12-14 8:14 UTC (permalink / raw)
To: Cole Robinson, qemu-devel; +Cc: qemu-stable
13.12.2023 19:01, Cole Robinson:
..
> We are carrying these 2 patches in fedora to fix test suite failures:
What are the test suite failures? On gitlab the testsuite of 7.2 is all
succeeds (except of a few unrelated issues like still-missing riscv64
debian chroot).
I do have a test failure though if I pick v8.2.0-rc1-26-g8d37a1425b
"target/arm: Handle overflow in calculation of next timer tick" to
7.2. This too seems unrelated.
> commit abe2c4bdb65e8dd9cb2f01c355baa394bf49a8af
> Author: Eric Auger <eric.auger@redhat.com>
> Date: Tue Feb 28 10:29:44 2023 +0100
>
> test-vmstate: fix bad GTree usage, use-after-free
Is this happens sporadically?
> commit ae4b01b3497934849278b49f3dfd28420f75e300
> Author: Richard W.M. Jones <rjones@redhat.com>
> Date: Tue Feb 28 19:06:45 2023 +0000
>
> tests: Ensure TAP version is printed before other messages
Ok. Lemme pick this up too.
Thank you for pointing this out!
/mjt
^ permalink raw reply [flat|nested] 26+ messages in thread