target-arm queue
Subsystems (5)
Hi; here's a target-arm pullreq for rc2. All bug fixes, mostly arm but a few in the net subsystem.
thanks
-- PMM
The following changes since commit 2bfbe39d0fff8af881cffe2bab9b615e77807c35:
gitlab-ci: Switch the msys2 job to use ucrt (2026-11-23 09:13:18 -0800)
are available in the Git repository at:
https://gitlab.com/pm215/qemu.git tags/pull-target-arm-20261124
for you to fetch changes up to c020bf46966ae4dbbf82efbc4c5f3435a2fda42f:
hw/intc/arm_gicv5: Fix value of the IRS_DEVARCH register (2026-11-24 12:55:53 +0000)
----------------------------------------------------------------
target-arm queue:
* net/checksum.c: Correct handling of IP header length
* net/checksum: Correct handling of checksums when IP options present
* hw/ssi/aspeed_smc: Correct minimum_version_id in vmstate
* hw/net/rtl8139: Limit DMA transfers to plain memory
* hw/arm/bcm2838: Route system timer interrupts to GIC
* hw/intc/arm_gicv3_cpuif: Don't count a virtual EOI in EOImode 1
* target/arm: Handle "PMU disabled" in migration validate functions
* hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
* hw/intc/arm_gicv5: Fix value of the IRS_DEVARCH register
----------------------------------------------------------------
Fuad Tabba (1):
hw/intc/arm_gicv3_cpuif: Don't count a virtual EOI in EOImode 1
Jayesh Agarwal (1):
hw/arm/bcm2838: Route system timer interrupts to GIC
Peter Maydell (6):
net/checksum.c: Correct handling of IP header length net/checksum: Correct handling of checksums when IP options present hw/ssi/aspeed_smc: Correct minimum_version_id in vmstate hw/net/rtl8139: Limit DMA transfers to plain memory target/arm: Handle "PMU disabled" in migration validate functions hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
Zenghui Yu (1):
hw/intc/arm_gicv5: Fix value of the IRS_DEVARCH register
include/hw/arm/bcm2835_peripherals.h | 1 + include/hw/arm/bcm2838_peripherals.h | 4 ++ include/net/checksum.h | 2 +- hw/arm/bcm2835_peripherals.c | 33 +++++++----- hw/arm/bcm2838.c | 7 +++ hw/intc/arm_gicv3_cpuif.c | 5 +- hw/intc/arm_gicv5.c | 2 +- hw/net/rtl8139.c | 98 ++++++++++++++++++++++-------------- hw/ssi/aspeed_smc.c | 7 ++- hw/watchdog/wdt_imx2.c | 28 +++++++++-- net/checksum.c | 46 ++++++++++++----- target/arm/machine.c | 22 ++++++-- 12 files changed, 178 insertions(+), 77 deletions(-)
[PULL 1/9] net/checksum.c: Correct handling of IP header length
In net_checksum_calculate() we are careless about handling of the IP header length, in a way which can allow it to become negative for a suitably crafted packet. This bypasses the attempt to check that it's big enough, because in comparisons like
if (ip_len < sizeof(tcp_header))ip_len is converted to size_t and we do this as an unsigned comparison, so negative values of ip_len pass the check.
This results in net_checksum_tcpudp() attempting to checksum nearly 64K of memory (because it takes the length as a uint16_t), which will typically be a read off the end of a buffer resulting in a segfault. If the attacker is able to set up a situation where the read doesn't fault, it's possible for some callers that the 2-byte store of the updated checksum is an out-of-bounds write.
This code is used by at least xen-nic, virtio-net, and the COLOj filter-rewriter, all of which are in QEMU's security "virtualization use case", though the write is probably only exploitable for the filter-rewriter; otherwise it's just a theoretical "information leak to guest" of a 2-byte checksum of 64K of host RAM.
Improve the checking of lengths in this function:
* make the input length size_t as it is a buffer length
* use unsigned int for internal always-positive lengths, so comparisons are always unsigned-vs-unsigned
* check length before subtracting various header sizes, rather than afterwards
* check that the packet's IHL field reports a valid header length that's not larger than the packet itself
* check that the packet's total length field doesn't claim to be smaller than the header
All the callsites are already passing an unsigned value to this function, with the exception of those in ftgmac100.c and imx_fec.c. Those two pass an "int" value which can't ever be negative.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4720
Message-id: [email protected]
--- include/net/checksum.h | 2 +- net/checksum.c | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-)
include/net/checksum.h +1 -1
@@ -30,7 +30,7 @@ uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq);uint16_t net_checksum_finish (uint32_t sum);uint16_t net_checksum_tcpudp (uint16_t length,uint16_t proto,uint8_t *addrs,uint8_t *buf); -void net_checksum_calculate (void *data,int length,int csum_flag); +void net_checksum_calculate (void *data,size_t length,int csum_flag);static inline uint32_t net_checksum_add (int len,uint8_t *buf)
net/checksum.c +23 -9
@@ -57,9 +57,9 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,return net_checksum_finish (sum); } -void net_checksum_calculate (void *data,int length,int csum_flag) +void net_checksum_calculate (void *data,size_t length,int csum_flag) { -int mac_hdr_len, ip_len; +unsigned int mac_hdr_len, ip_len, ip_hdr_len;struct ip_header *ip;uint16_t csum;
@@ -94,23 +94,33 @@ void net_checksum_calculate(void *data, int length, int csum_flag)break ; } - length -= mac_hdr_len; -/* Now check we have an IP header (with an optional VLAN header) */ -if (length <sizeof (struct ip_header )) { +if (length < mac_hdr_len +sizeof (struct ip_header )) {return ; } + length -= mac_hdr_len; + ip = (struct ip_header *)((uint8_t *)data + mac_hdr_len);if (IP_HEADER_VERSION (ip) !=IP_HEADER_VERSION_4 ) {return ;/* not IPv4 */ } + ip_hdr_len =IP_HDR_GET_LEN (ip); + +if (ip_hdr_len <sizeof (struct ip_header ) || ip_hdr_len > length) { +/* +* Ignore packet with an invalidly short IHL, or which claims the +* IP header is larger than the buffer +*/ +return ; + } +/* Calculate IP checksum */ if (csum_flag &CSUM_IP ) {stw_he_p (&ip->ip_sum,0 ); - csum =net_raw_checksum ((uint8_t *)ip,IP_HDR_GET_LEN (ip)); + csum =net_raw_checksum ((uint8_t *)ip, ip_hdr_len);stw_be_p (&ip->ip_sum, csum); }
@@ -120,12 +130,16 @@ void net_checksum_calculate(void *data, int length, int csum_flag) ip_len =lduw_be_p (&ip->ip_len); -/* Last, check that we have enough data for the all IP frame */ -if (length < ip_len) { +/* +* Last, check that the packet's total length field doesn't +* imply a negative amount of data given the header length, +* and that it's not larger than the data buffer we have. +*/ +if (ip_len < ip_hdr_len || length < ip_len) {return ; } - ip_len -=IP_HDR_GET_LEN (ip); + ip_len -= ip_hdr_len;switch (ip->ip_p) {case IP_PROTO_TCP :
Signature · 1 line
2.43.0
[PULL 2/9] net/checksum: Correct handling of checksums when IP options present
In reply to Peter MaydellIn net_checksum_calculate() we calculate the position of the TCP or UDP header in the buffer with:
tcp_header *tcp = (tcp_header *)(ip + 1);
where ip is a 'struct ip_header' (and similarly for udp).
This only gives the correct location if the IP packet has no options and its header is the minimum length. Otherwise we will corrupt some part of the packet in writing the checksum word.
Fortunately packets with IP options are rare (and often get blocked by routers or firewalls), so this probably didn't often cause problems, and the incorrect offset we write to is always inside the packet, not out-of-bounds.
Use the IP header length value from the packet to locate the TCP or UDP header, instead of the fixed minimum size. While we're adjusting this code, make sure that we don't assign to the tcp_header or udp_header pointer until after we've made the length check that the buffer is big enough (the previous ordering of operations was harmless as we never used the resulting pointer, but not ideal).
This was mentioned in passing in issue #4791 (which is otherwise a duplicate of #4720).
Message-id: [email protected]
--- net/checksum.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/checksum.c +10 -4
@@ -62,6 +62,7 @@ void net_checksum_calculate(void *data, size_t length, int csum_flag)unsigned int mac_hdr_len, ip_len, ip_hdr_len;struct ip_header *ip;uint16_t csum; +void *ip_payload;/* * Note: We cannot assume "data" is aligned, so the all code uses
@@ -140,20 +141,23 @@ void net_checksum_calculate(void *data, size_t length, int csum_flag) } ip_len -= ip_hdr_len; + ip_payload = (uint8_t *)ip + ip_hdr_len;switch (ip->ip_p) {case IP_PROTO_TCP : { +tcp_header *tcp; +if (!(csum_flag &CSUM_TCP )) {return ; } -tcp_header *tcp = (tcp_header *)(ip +1 ); -if (ip_len <sizeof (tcp_header)) {return ; } + tcp = ip_payload; +/* Set csum to 0 */ stw_he_p (&tcp->th_sum,0 );
@@ -168,16 +172,18 @@ void net_checksum_calculate(void *data, size_t length, int csum_flag) }case IP_PROTO_UDP : { +udp_header *udp; +if (!(csum_flag &CSUM_UDP )) {return ; } -udp_header *udp = (udp_header *)(ip +1 ); -if (ip_len <sizeof (udp_header)) {return ; } + udp = ip_payload; +/* Set csum to 0 */ stw_he_p (&udp->uh_sum,0 );
Signature · 1 line
2.43.0
[PULL 5/9] hw/arm/bcm2838: Route system timer interrupts to GIC
In reply to Peter MaydellFrom: Jayesh Agarwal <[email protected]>
The system timer interrupts are only routed to the legacy interrupt controller and not to the GIC, so a guest using the GIC (software that relies on the system timer interrupts through the GIC, such as bare metal programs or hobby kernels) never receives them.
A qemu_irq connection follows one output, one input. So also wiring the timer to the GIC would replace its connection to the legacy controller.
Add a splitter per system-timer interrupt line so that each interrupt reaches both the legacy controller (output 0 of the splitters) and the GIC (output 1 of the splitters). The timer channel n goes to GIC SPI 64+n, so channels 0-3 go to SPIs 64-67.
Testing:
The raspi4b machine started in the qtest mode:
qemu-system-aarch64 -M raspi4b -display none -accel qtest -qtest stdio
Ran following commands:
irq_intercept_in /machine/soc/peripherals readl 0xfe003004 writel 0xfe00300c 1000 writel 0xfe003010 2000 writel 0xfe003014 3000 writel 0xfe003018 4000 clock_step 5000000 readl 0xfe003000
Before the fix:
clock_step 5000000
OK 5000000
readl 0xfe003000
OK 0x000000000000000fThe alarm fires correctly (status flag outputs 0xf), but no IRQ raise 64-67 reaches the GIC.
After the fix:
clock_step 5000000
IRQ raise 64
IRQ raise 65
IRQ raise 66
IRQ raise 67
OK 5000000
readl 0xfe003000
OK 0x000000000000000f
The alarm fires, and all the four channels reached GIC lines 64-67.
Message-id: [email protected]
--- include/hw/arm/bcm2835_peripherals.h | 1 + include/hw/arm/bcm2838_peripherals.h | 4 ++++ hw/arm/bcm2835_peripherals.c | 33 ++++++++++++++++++---------- hw/arm/bcm2838.c | 7 ++++++ 4 files changed, 33 insertions(+), 12 deletions(-)
include/hw/arm/bcm2835_peripherals.h +1 -0
@@ -54,6 +54,7 @@ struct BCMSocPeripheralBaseState {qemu_irq irq, fiq;BCM2835SystemTimerState systmr; +SplitIRQ systmr_irq_splitter[BCM2835_SYSTIMER_COUNT ];BCM2835MphiState mphi;UnimplementedDeviceState txp;UnimplementedDeviceState armtmr;
include/hw/arm/bcm2838_peripherals.h +4 -0
@@ -20,6 +20,10 @@/* SPI */ #define GIC_SPI_INTERRUPT_MBOX 33#define GIC_SPI_INTERRUPT_MPHI 40 +#define GIC_SPI_INTERRUPT_SYS_TIMER0 64 +#define GIC_SPI_INTERRUPT_SYS_TIMER1 65 +#define GIC_SPI_INTERRUPT_SYS_TIMER2 66 +#define GIC_SPI_INTERRUPT_SYS_TIMER3 67#define GIC_SPI_INTERRUPT_DWC2 73#define GIC_SPI_INTERRUPT_DMA_0 80#define GIC_SPI_INTERRUPT_DMA_6 86
hw/arm/bcm2835_peripherals.c +21 -12
@@ -95,6 +95,14 @@ static void raspi_peripherals_base_init(Object *obj)/* SYS Timer */ object_initialize_child (obj,"systimer" , &s->systmr,TYPE_BCM2835_SYSTIMER ); +/* +* One splitter per system-timer interrupt line so that each interrupt +* reaches both the legacy controller and the GIC. +*/ +for (int n =0 ; n <BCM2835_SYSTIMER_COUNT ; n++) { +object_initialize_child (obj,"systmr-irq-splitter[*]" , + &s->systmr_irq_splitter[n],TYPE_SPLIT_IRQ ); + }/* UART0 */ object_initialize_child (obj,"uart0" , &s->uart0,TYPE_PL011 );
@@ -304,18 +312,19 @@ void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp) }memory_region_add_subregion (&s->peri_mr,ST_OFFSET ,sysbus_mmio_get_region (SYS_BUS_DEVICE (&s->systmr),0 )); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->systmr),0 , -qdev_get_gpio_in_named (DEVICE (&s->ic),BCM2835_IC_GPU_IRQ , -INTERRUPT_TIMER0 )); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->systmr),1 , -qdev_get_gpio_in_named (DEVICE (&s->ic),BCM2835_IC_GPU_IRQ , -INTERRUPT_TIMER1 )); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->systmr),2 , -qdev_get_gpio_in_named (DEVICE (&s->ic),BCM2835_IC_GPU_IRQ , -INTERRUPT_TIMER2 )); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->systmr),3 , -qdev_get_gpio_in_named (DEVICE (&s->ic),BCM2835_IC_GPU_IRQ , -INTERRUPT_TIMER3 )); +for (n =0 ; n <BCM2835_SYSTIMER_COUNT ; n++) { +qdev_prop_set_uint32 (DEVICE (&s->systmr_irq_splitter[n]), +"num-lines" ,2 ); +if (!qdev_realize (DEVICE (&s->systmr_irq_splitter[n]),NULL , errp)) { +return ; + } +sysbus_connect_irq (SYS_BUS_DEVICE (&s->systmr), n, +qdev_get_gpio_in (DEVICE (&s->systmr_irq_splitter[n]),0 )); +qdev_connect_gpio_out (DEVICE (&s->systmr_irq_splitter[n]),0 , +qdev_get_gpio_in_named (DEVICE (&s->ic), +BCM2835_IC_GPU_IRQ , +INTERRUPT_TIMER0 + n)); + }/* UART0 */ qdev_prop_set_chr (DEVICE (&s->uart0),"chardev" ,serial_hd (0 ));
hw/arm/bcm2838.c +7 -0
@@ -192,6 +192,13 @@ static void bcm2838_realize(DeviceState *dev, Error **errp)qdev_connect_gpio_out (DEVICE (&ps_base->spi_irq_splitter),1 ,qdev_get_gpio_in (gicdev,GIC_SPI_INTERRUPT_SPI )); +/* Connect the system timer interrupts to the interrupt controller */ +for (int n =0 ; n <BCM2835_SYSTIMER_COUNT ; n++) { +int int_n =GIC_SPI_INTERRUPT_SYS_TIMER0 + n; +qdev_connect_gpio_out (DEVICE (&ps_base->systmr_irq_splitter[n]),1 , +qdev_get_gpio_in (gicdev, int_n)); + } +/* Connect VC mailbox to the interrupt controller */ sysbus_connect_irq (SYS_BUS_DEVICE (&ps_base->mboxes),0 ,qdev_get_gpio_in (gicdev,GIC_SPI_INTERRUPT_MBOX ));
Signature · 1 line
2.43.0
[PULL 4/9] hw/net/rtl8139: Limit DMA transfers to plain memory
In reply to Peter MaydellThere's no reason for the RTL8139 to be doing a DMA transfer to something that isn't memory, and allowing it can cause weird re-entrancy problems, such as a DMA to the PCI hot-unplug register causing the device to be deleted while it's halfway through doing something.
Replace the calls to pci_dma_read() and pci_dma_write() with local functions that are identical except that they pass a MemTxAttrs that forbids non-memory accesses.
This is the same approach we took to a similar problem with the hcd-xhci USB controller in commit 89e653b7736 (but differs from what we did for lsi53c895a in commit 4862d2c95104d).
The known trigger for this bug requires that you turned off ACPI hotplug on the QEMU commandline with
-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off
so most configurations won't run into it.
Message-id: [email protected]
--- hw/net/rtl8139.c | 98 +++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 38 deletions(-)
hw/net/rtl8139.c +60 -38
@@ -513,6 +513,28 @@ struct RTL8139State {int rtl8139_mmio_io_addr_dummy; }; +/* +* There's no reason for the RTL8139 to do DMA to something that +* isn't memory, and it can cause weird re-entrancy problems if e.g. +* a DMA write targets the PCI hot-unplug register for the device. +* Set memory=1 in the memory attributes to avoid that kind of thing. +*/ +static MemTxResult rtl8139_dma_write (PCIDevice *dev,dma_addr_t addr, +const void *buf,dma_addr_t len) +{ +const MemTxAttrs attrs = { .memory = true }; +return pci_dma_rw (dev, addr, (void *)buf, len, +DMA_DIRECTION_FROM_DEVICE , attrs); +} + +static inline MemTxResult rtl8139_dma_read (PCIDevice *dev,dma_addr_t addr, +void *buf,dma_addr_t len) +{ +const MemTxAttrs attrs = { .memory = true }; +return pci_dma_rw (dev, addr, buf, len, +DMA_DIRECTION_TO_DEVICE , attrs); +} +/* Writes tally counters to memory via DMA */ static void RTL8139TallyCounters_dma_write (RTL8139State *s,dma_addr_t tc_addr);
@@ -756,15 +778,15 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)if (size > wrapped) { -pci_dma_write (d, s->RxBuf + s->RxBufAddr, - buf, size-wrapped); +rtl8139_dma_write (d, s->RxBuf + s->RxBufAddr, + buf, size - wrapped); }/* reset buffer pointer */ s->RxBufAddr =0 ; -pci_dma_write (d, s->RxBuf + s->RxBufAddr, - buf + (size-wrapped), wrapped); +rtl8139_dma_write (d, s->RxBuf + s->RxBufAddr, + buf + (size - wrapped), wrapped); s->RxBufAddr = wrapped;
@@ -773,7 +795,7 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size) }/* non-wrapping path or overwrapping enabled */ -pci_dma_write (d, s->RxBuf + s->RxBufAddr, buf, size); +rtl8139_dma_write (d, s->RxBuf + s->RxBufAddr, buf, size); s->RxBufAddr += size; }
@@ -971,13 +993,13 @@ static ssize_t rtl8139_receive(NetClientState *nc,uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; -pci_dma_read (d, cplus_rx_ring_desc, &val,4 ); +rtl8139_dma_read (d, cplus_rx_ring_desc, &val,4 ); rxdw0 =le32_to_cpu (val); -pci_dma_read (d, cplus_rx_ring_desc+4 , &val,4 ); +rtl8139_dma_read (d, cplus_rx_ring_desc +4 , &val,4 ); rxdw1 =le32_to_cpu (val); -pci_dma_read (d, cplus_rx_ring_desc+8 , &val,4 ); +rtl8139_dma_read (d, cplus_rx_ring_desc +8 , &val,4 ); rxbufLO =le32_to_cpu (val); -pci_dma_read (d, cplus_rx_ring_desc+12 , &val,4 ); +rtl8139_dma_read (d, cplus_rx_ring_desc +12 , &val,4 ); rxbufHI =le32_to_cpu (val); DPRINTF("+++ C+ mode RX descriptor %d %08x %08x %08x %08x\n",
@@ -1040,12 +1062,12 @@ static ssize_t rtl8139_receive(NetClientState *nc,/* receive/copy to target memory */ if (dot1q_buf) { -pci_dma_write (d, rx_addr, buf,2 *ETH_ALEN ); -pci_dma_write (d, rx_addr +2 *ETH_ALEN , - buf +2 *ETH_ALEN +VLAN_HLEN , - size -2 *ETH_ALEN ); +rtl8139_dma_write (d, rx_addr, buf,2 *ETH_ALEN ); +rtl8139_dma_write (d, rx_addr +2 *ETH_ALEN , + buf +2 *ETH_ALEN +VLAN_HLEN , + size -2 *ETH_ALEN ); }else { -pci_dma_write (d, rx_addr, buf, size); +rtl8139_dma_write (d, rx_addr, buf, size); }if (s->CpCmd & CPlusRxChkSum)
@@ -1055,7 +1077,7 @@ static ssize_t rtl8139_receive(NetClientState *nc,/* write checksum */ val =cpu_to_le32 (crc32 (0 , buf, size_)); -pci_dma_write (d, rx_addr+size, (uint8_t *)&val,4 ); +rtl8139_dma_write (d, rx_addr + size, (uint8_t *)&val,4 );/* first segment of received packet flag */ #define CP_RX_STATUS_FS (1<<29)
@@ -1101,9 +1123,9 @@ static ssize_t rtl8139_receive(NetClientState *nc,/* update ring data */ val =cpu_to_le32 (rxdw0); -pci_dma_write (d, cplus_rx_ring_desc, (uint8_t *)&val,4 ); +rtl8139_dma_write (d, cplus_rx_ring_desc, (uint8_t *)&val,4 ); val =cpu_to_le32 (rxdw1); -pci_dma_write (d, cplus_rx_ring_desc+4 , (uint8_t *)&val,4 ); +rtl8139_dma_write (d, cplus_rx_ring_desc +4 , (uint8_t *)&val,4 );/* update tally counter */ ++s->tally_counters.RxOk;
@@ -1291,43 +1313,43 @@ static void RTL8139TallyCounters_dma_write(RTL8139State *s, dma_addr_t tc_addr)uint64_t val64; val64 =cpu_to_le64 (tally_counters->TxOk); -pci_dma_write (d, tc_addr +0 , (uint8_t *)&val64,8 ); +rtl8139_dma_write (d, tc_addr +0 , (uint8_t *)&val64,8 ); val64 =cpu_to_le64 (tally_counters->RxOk); -pci_dma_write (d, tc_addr +8 , (uint8_t *)&val64,8 ); +rtl8139_dma_write (d, tc_addr +8 , (uint8_t *)&val64,8 ); val64 =cpu_to_le64 (tally_counters->TxERR); -pci_dma_write (d, tc_addr +16 , (uint8_t *)&val64,8 ); +rtl8139_dma_write (d, tc_addr +16 , (uint8_t *)&val64,8 ); val32 =cpu_to_le32 (tally_counters->RxERR); -pci_dma_write (d, tc_addr +24 , (uint8_t *)&val32,4 ); +rtl8139_dma_write (d, tc_addr +24 , (uint8_t *)&val32,4 ); val16 =cpu_to_le16 (tally_counters->MissPkt); -pci_dma_write (d, tc_addr +28 , (uint8_t *)&val16,2 ); +rtl8139_dma_write (d, tc_addr +28 , (uint8_t *)&val16,2 ); val16 =cpu_to_le16 (tally_counters->FAE); -pci_dma_write (d, tc_addr +30 , (uint8_t *)&val16,2 ); +rtl8139_dma_write (d, tc_addr +30 , (uint8_t *)&val16,2 ); val32 =cpu_to_le32 (tally_counters->Tx1Col); -pci_dma_write (d, tc_addr +32 , (uint8_t *)&val32,4 ); +rtl8139_dma_write (d, tc_addr +32 , (uint8_t *)&val32,4 ); val32 =cpu_to_le32 (tally_counters->TxMCol); -pci_dma_write (d, tc_addr +36 , (uint8_t *)&val32,4 ); +rtl8139_dma_write (d, tc_addr +36 , (uint8_t *)&val32,4 ); val64 =cpu_to_le64 (tally_counters->RxOkPhy); -pci_dma_write (d, tc_addr +40 , (uint8_t *)&val64,8 ); +rtl8139_dma_write (d, tc_addr +40 , (uint8_t *)&val64,8 ); val64 =cpu_to_le64 (tally_counters->RxOkBrd); -pci_dma_write (d, tc_addr +48 , (uint8_t *)&val64,8 ); +rtl8139_dma_write (d, tc_addr +48 , (uint8_t *)&val64,8 ); val32 =cpu_to_le32 (tally_counters->RxOkMul); -pci_dma_write (d, tc_addr +56 , (uint8_t *)&val32,4 ); +rtl8139_dma_write (d, tc_addr +56 , (uint8_t *)&val32,4 ); val16 =cpu_to_le16 (tally_counters->TxAbt); -pci_dma_write (d, tc_addr +60 , (uint8_t *)&val16,2 ); +rtl8139_dma_write (d, tc_addr +60 , (uint8_t *)&val16,2 ); val16 =cpu_to_le16 (tally_counters->TxUndrn); -pci_dma_write (d, tc_addr +62 , (uint8_t *)&val16,2 ); +rtl8139_dma_write (d, tc_addr +62 , (uint8_t *)&val16,2 ); }static void rtl8139_ChipCmd_write (RTL8139State *s,uint32_t val)
@@ -1810,7 +1832,7 @@ static int rtl8139_transmit_one(RTL8139State *s, int descriptor)DPRINTF ("+++ transmit reading %d bytes from host memory at 0x%08x\n" , txsize, s->TxAddr[descriptor]); -pci_dma_read (d, s->TxAddr[descriptor], txbuffer, txsize); +rtl8139_dma_read (d, s->TxAddr[descriptor], txbuffer, txsize);/* Mark descriptor as transferred */ s->TxStatus[descriptor] |= TxHostOwns;
@@ -1886,13 +1908,13 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)uint32_t val, txdw0,txdw1,txbufLO,txbufHI; -pci_dma_read (d, cplus_tx_ring_desc, (uint8_t *)&val,4 ); +rtl8139_dma_read (d, cplus_tx_ring_desc, (uint8_t *)&val,4 ); txdw0 =le32_to_cpu (val); -pci_dma_read (d, cplus_tx_ring_desc+4 , (uint8_t *)&val,4 ); +rtl8139_dma_read (d, cplus_tx_ring_desc +4 , (uint8_t *)&val,4 ); txdw1 =le32_to_cpu (val); -pci_dma_read (d, cplus_tx_ring_desc+8 , (uint8_t *)&val,4 ); +rtl8139_dma_read (d, cplus_tx_ring_desc +8 , (uint8_t *)&val,4 ); txbufLO =le32_to_cpu (val); -pci_dma_read (d, cplus_tx_ring_desc+12 , (uint8_t *)&val,4 ); +rtl8139_dma_read (d, cplus_tx_ring_desc +12 , (uint8_t *)&val,4 ); txbufHI =le32_to_cpu (val); DPRINTF("+++ C+ mode TX descriptor %d %08x %08x %08x %08x\n", descriptor,
@@ -1986,8 +2008,8 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)DMA_ADDR_FMT " to offset %d\n" , txsize, tx_addr, s->cplus_txbuffer_offset); -pci_dma_read (d, tx_addr, - s->cplus_txbuffer + s->cplus_txbuffer_offset, txsize); +rtl8139_dma_read (d, tx_addr, + s->cplus_txbuffer + s->cplus_txbuffer_offset, txsize); s->cplus_txbuffer_offset += txsize;/* seek to next Rx descriptor */
@@ -2017,7 +2039,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)/* update ring data */ val =cpu_to_le32 (tx_status); -pci_dma_write (d, cplus_tx_ring_desc, (uint8_t *)&val,4 ); +rtl8139_dma_write (d, cplus_tx_ring_desc, (uint8_t *)&val,4 );/* Now decide if descriptor being processed is holding the last segment of packet */ if (txdw0 &CP_TX_LS )
Signature · 1 line
2.43.0
[PULL 3/9] hw/ssi/aspeed_smc: Correct minimum_version_id in vmstate
In reply to Peter MaydellIn commit 29139270d8ad70f2 we made an incompatible change to the migration state for the aspeed_smc device, and bumped the version_id and minimum_version_id: this is because we increased ASPEED_SMC_R_MAX and so the regs array is bigger.
However, the old vmstate was handling migration from a range of vmstate versions, with version_id = 3 and minimum_version_id = 1. The change to ASPEED_SMC_R_MAX is (intentionally) not compatible with any of those older versions, and so it should have moved minimum_version_id up to 4 (matching the new version_id), not merely increment it.
The effect of this is that trying a migration save on v11.1.3 and then a load on the current head of git fails in a confusing way ("Missing section footer for aspeed.smc") rather than clearly ("error while loading state for instance 0x0 of device 'aspeed.smc':
aspeed.smc: incoming version_id 3 is too old for local minimum version_id 5").
Since we now don't need to try to handle migration from versions 2 and 3 at all, we can drop the complications in the vmstate struct (an unused field, and field only present in version 3 and up). Clean these up and set the version_id and minimum_version_id to 5 accordingly.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4880
Message-id: [email protected]
--- hw/ssi/aspeed_smc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/ssi/aspeed_smc.c +3 -4
@@ -1218,12 +1218,11 @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)static const VMStateDescription vmstate_aspeed_smc = { .name ="aspeed.smc" , - .version_id =4 , - .minimum_version_id =2 , + .version_id =5 , + .minimum_version_id =5 , .fields = (const VMStateField []) {VMSTATE_UINT32_ARRAY (regs, AspeedSMCState,ASPEED_SMC_R_MAX ), -VMSTATE_UNUSED_V (2 ,2 ),/* was snoop_index/snoop_dummies */ -VMSTATE_BOOL_V (unselect, AspeedSMCState,3 ), +VMSTATE_BOOL (unselect, AspeedSMCState),VMSTATE_END_OF_LIST () } };
Signature · 1 line
2.43.0
[PULL 9/9] hw/intc/arm_gicv5: Fix value of the IRS_DEVARCH register
In reply to Peter MaydellFrom: Zenghui Yu <[email protected]>
The GICv5 spec says bits [31:21] of IRS_DEVARCH are 0x23b. We wrongly shifted it by 31 instead of 21, so guests read 0x80105a19 rather than 0x47705a19.
Message-id: [email protected]
--- hw/intc/arm_gicv5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gicv5.c +1 -1
@@ -318,7 +318,7 @@ FIELD(ICSR, HM, 5, 1) FIELD(ICSR, PRIORITY, 11, 5) FIELD(ICSR, IAFFID, 32, 16) -#define IRS_DEVARCH_VALUE ((0x23b << 31) | (0x1 << 20) | 0x5a19) +#define IRS_DEVARCH_VALUE ((0x23b << 21) | (0x1 << 20) | 0x5a19)static uint32_t gicv5_idreg (int regoffset) {
Signature · 1 line
2.43.0
[PULL 6/9] hw/intc/arm_gicv3_cpuif: Don't count a virtual EOI in EOImode 1
In reply to Peter MaydellFrom: Fuad Tabba <[email protected]>
icv_eoir_write() increments ICH_HCR_EL2.EOIcount for a virtual EOI with no matching list register, in either EOImode. The VirtualWriteEOIR0() and VirtualWriteEOIR1() pseudocode in the GICv3 architecture specification only does so in EOImode 0 (ICH_VMCR_EL2.VEOIM clear), since in EOImode 1 the DIR write increments EOIcount instead.
In EOImode 1 an interrupt with no list register is therefore counted twice, and KVM running under TCG deactivates an interrupt that its guest has yet to deactivate.
Increment EOIcount on EOIR only when EOImode is 0.
Message-id: [email protected]
--- hw/intc/arm_gicv3_cpuif.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/intc/arm_gicv3_cpuif.c +3 -2
@@ -1617,9 +1617,10 @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,if (idx <0 ) {/* * No valid list register corresponding to EOI ID; if this is a vLPI -* not in the list regs then do nothing; otherwise increment EOI count +* not in the list regs then do nothing; otherwise increment EOI count, +* unless drop and deactivate are split, when the DIR write does so. */ -if (irq <GICV3_LPI_INTID_START ) { +if (irq <GICV3_LPI_INTID_START && !icv_eoi_split (env, cs)) {icv_increment_eoicount (cs); } }else {
Signature · 1 line
2.43.0
[PULL 8/9] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
In reply to Peter MaydellThe wdt_imx2 device has optional support for pretimeouts, which are present on most i.MX SoCs but not on i.MX31. If the QOM property 'pretimeout-support' is not set to true then we don't create the ptimer associated with that feature. However, the migration vmstate unconditionally lists that ptimer, with the result that trying to save the vmstate of an i.MX31-based machine like "kzm" will hit an assertion.
Move the migration of 'itimer' into its own subsection which we only send when pretimeout support is enabled.
This bug has existed in the code for a long time, but it was hidden until commit d9abd0253be ("hw/watchdog/wdt_imx2: Remove redundant attributes)" because a bug in the VMSTATE_PTIMER() macro together with the fact that the vmstate_imx2_wdt version_id was 0 meant that we weren't trying to migrate the device's ptimers at all, and so we avoided the assertion (but didn't migrate correctly).
This is a migration compatibility break for this device, but it isn't used in any versioned machine types, and we've already decided to break compat on it this release cycle.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4876
Message-id: [email protected]
--- hw/watchdog/wdt_imx2.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
hw/watchdog/wdt_imx2.c +25 -3
@@ -221,13 +221,31 @@ static const MemoryRegionOps imx2_wdt_ops = { }, }; -static const VMStateDescription vmstate_imx2_wdt = { - .name ="imx2.wdt" , +static bool pretimeout_state_needed (void *opaque) +{ +/* The itimer is only present if pretimeout-support is enabled */ +IMX2WdtState *s = opaque; + +return s->pretimeout_support; +} + +static const VMStateDescription vmstate_imx2_wdt_pretimeout = { + .name ="imx2.wdt/pretimeout" , .version_id =1 , .minimum_version_id =1 , + .needed = pretimeout_state_needed, + .fields = (const VMStateField []) { +VMSTATE_PTIMER (itimer, IMX2WdtState), +VMSTATE_END_OF_LIST () + } +}; + +static const VMStateDescription vmstate_imx2_wdt = { + .name ="imx2.wdt" , + .version_id =2 , + .minimum_version_id =2 , .fields = (const VMStateField []) {VMSTATE_PTIMER (timer, IMX2WdtState), -VMSTATE_PTIMER (itimer, IMX2WdtState),VMSTATE_BOOL (wicr_locked, IMX2WdtState),VMSTATE_BOOL (wcr_locked, IMX2WdtState),VMSTATE_UINT16 (wcr, IMX2WdtState),
@@ -236,6 +254,10 @@ static const VMStateDescription vmstate_imx2_wdt = { VMSTATE_UINT16(wmcr, IMX2WdtState), VMSTATE_UINT16(wicr, IMX2WdtState),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription *const []) { + &vmstate_imx2_wdt_pretimeout, +NULL } };
Signature · 1 line
2.43.0
[PULL 7/9] target/arm: Handle "PMU disabled" in migration validate functions
In reply to Peter MaydellIn various test functions for VMSTATE_VALIDATE() fields, we check whether the migrated region number register is within bounds (i.e. less than the total number of configured regions). These tests fail spuriously if there are zero configured regions, because then "x < cpu->pmsav7_dregion" is always false.
When we allowed v6M CPUs to have PMSAv7 in commit 157f6c69edd06, this exposed a bug, because we now have a CPU which has PMSAv7 according to the pmsav7_needed() function but which is configured with 0 PMSA
regions: the Cortex-M0.
We could fix this by having pmsav7_needed() return false if there are 0 regions; however, the cpu/m-security vmstate struct does migration of the secure equivalents of these fields, and we also do a VMSTATE_VALIDATE that checks against the number of MPU regions there. Making those fields be migrated only if there is more than one region would be awkward (we'd need to pull them out into their own vmstate struct), and it's unnecessary -- migrating something that's all zeroes and not used isn't a problem.
So instead we relax the checks to handle the "no configured regions" case, insisting then that the rnr field in the CPU state (which should never be used) is zero.
Similarly, we adjust the check in sau_rnr_vmstate_validate against sau_sregion; this one is currently theoretical as all our CPUs which implement the Security Extension have at least one SAU region, but architecturally it is permitted to implemnt no SAU regions.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4905
Message-id: [email protected]
--- target/arm/machine.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
target/arm/machine.c +19 -3
@@ -593,7 +593,12 @@ static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id) {ARMCPU *cpu = opaque; -return cpu->env.pmsav7.rnr[M_REG_NS ] < cpu->pmsav7_dregion; +/* +* Check MPU_RNR in-bounds. If no MPU, we still migrate this field +* but number of regions == 0 and MPU_RNR is RAZ/WI so also 0 +*/ +return cpu->env.pmsav7.rnr[M_REG_NS ] < cpu->pmsav7_dregion || + (cpu->pmsav7_dregion ==0 && cpu->env.pmsav7.rnr[M_REG_NS ] ==0 ); }static const VMStateDescription vmstate_pmsav7 = {
@@ -693,14 +698,25 @@ static bool s_rnr_vmstate_validate(void *opaque, int version_id) {ARMCPU *cpu = opaque; -return cpu->env.pmsav7.rnr[M_REG_S ] < cpu->pmsav7_dregion; +/* +* Check MPU_RNR in-bounds. If no MPU, we still migrate this field +* but number of regions == 0 and MPU_RNR is RAZ/WI so also 0 +*/ +return cpu->env.pmsav7.rnr[M_REG_S ] < cpu->pmsav7_dregion || + (cpu->pmsav7_dregion ==0 && cpu->env.pmsav7.rnr[M_REG_S ] ==0 ); }static bool sau_rnr_vmstate_validate (void *opaque,int version_id) {ARMCPU *cpu = opaque; -return cpu->env.sau.rnr < cpu->sau_sregion; +/* +* Check SAU_RNR in-bounds. If no SAU regions are implemented, +* we still migrate this field, but number of regions == 0 and +* SAU_RNR is RAZ/WI so also 0 +*/ +return cpu->env.sau.rnr < cpu->sau_sregion || + (cpu->sau_sregion ==0 && cpu->env.sau.rnr ==0 ); }static bool m_security_needed (void *opaque)
Signature · 1 line
2.43.0
Richard Henderson
AppliedQuoted 18 lines · Peter Maydell
Hi; here's a target-arm pullreq for rc2. All bug fixes, mostly arm but a few in the net subsystem.
thanks
-- PMMThe following changes since commit
2bfbe39d0fff8af881cffe2bab9b615e77807c35:gitlab-ci: Switch the msys2 job to use ucrt (2026-11-23 09:13:18 -0800)are available in the Git repository at:
https://gitlab.com/pm215/qemu.git tags/pull-target-arm-20261124for you to fetch changes up to
c020bf46966ae4dbbf82efbc4c5f3435a2fda42f:hw/intc/arm_gicv5: Fix value of the IRS_DEVARCH register (2026-11-24 12:55:53 +0000)
Quoted 11 lines
----------------------------------------------------------------
target-arm queue:
*net/checksum.c: Correct handling of IP header length
* net/checksum: Correct handling of checksums when IP options present
* hw/ssi/aspeed_smc: Correctminimum_version_idin vmstate
* hw/net/rtl8139: Limit DMA transfers to plain memory
* hw/arm/bcm2838: Route system timer interrupts to GIC
* hw/intc/arm_gicv3_cpuif: Don't count a virtual EOI in EOImode 1
* target/arm: Handle "PMU disabled" in migration validate functions
* hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
* hw/intc/arm_gicv5: Fix value of theIRS_DEVARCHregister
Applied, thanks.
r~