Patch Round-up for stable 8.0.1, frozen on 2023-05-27
v3 cover Patch Round-up for stable 8.0.1, frozen on 2023-05-27
The following patches are queued for QEMU stable v8.0.1:
https://gitlab.com/qemu-project/qemu/-/commits/staging-8.0
Patch freeze is 2023-05-27, and the release is planned for 2023-05-29:
https://wiki.qemu.org/Planning/8.0
Please respond here or CC [email protected] 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.
Thanks!
/mjt
--------------------------------------
01* 3f9c41c5df96 Paolo Bonzini:
vnc: avoid underflow when accessing user-provided address
02* 72497cff896f Yang Zhong:
target/i386: Change wrong XFRM value in SGX CPUID leaf
03* 542fd43d7932 Axel Heider:
hw/timer/imx_epit: don't shadow variable
04* 25d758175dfb Axel Heider:
hw/timer/imx_epit: fix limit check
05* 0f689cf5ada4 Igor Mammedov:
acpi: pcihp: allow repeating hot-unplug requests
06* 8c1e8fb2e7fc Wang Liang:
block/monitor: Fix crash when executing HMP commit
07* c1654c3e37c3 Alex Bennée:
qemu-options: finesse the recommendations around -blockdev
08* ac64ebbecf80 Peter Maydell:
docs/about/deprecated.rst: Add "since 7.1" tag to dtb-kaslr-seed deprecation
09* ad5c6ddea327 Akihiko Odaki:
target/arm: Initialize debug capabilities only once
10* d565f58b3842 Peter Maydell:
hw/net/msf2-emac: Don't modify descriptor in-place in emac_store_desc()
11* 0fe43f0abf19 Cédric Le Goater:
hw/arm/boot: Make write_bootloader() public as arm_write_bootloader()
12* 902bba549fc3 Cédric Le Goater:
hw/arm/aspeed: Use arm_write_bootloader() to write the bootloader
13* 0acbdb4c4ab6 Peter Maydell:
hw/arm/raspi: Use arm_write_bootloader() to write boot code
14* 2c5fa0778c3b Peter Maydell:
hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit()
15* 7f3a3d3dc433 Peter Maydell:
target/arm: Define and use new load_cpu_field_low32()
16* 3e20d90824c2 Peter Maydell:
hw/sd/allwinner-sdhost: Correctly byteswap descriptor fields
17* a4ae17e5ec51 Peter Maydell:
hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields
18* de79b52604e4 Stefan Hajnoczi:
block/export: call blk_set_dev_ops(blk, NULL, NULL)
19* 1098cc3fcf95 Shivaprasad G Bhat:
softfloat: Fix the incorrect computation in float32_exp2
20* ef709860ea12 Paolo Bonzini:
meson: leave unnecessary modules out of the build
21* e2626874a326 Kevin Wolf:
block: Fix use after free in blockdev_mark_auto_del()
22* da4afaff074e Kevin Wolf:
block: Consistently call bdrv_activate() outside coroutine
23* b2ab5f545fa1 Kevin Wolf:
block: bdrv/blk_co_unref() for calls in coroutine context
24* 0c7d204f50c3 Kevin Wolf:
block: Don't call no_coroutine_fns in qmp_block_resize()
25* df3ac6da476e LIU Zhiwei:
target/riscv: Fix itrigger when icount is used
26* eae04c4c131a Bin Meng:
target/riscv: Restore the predicate() NULL check behavior
27* 9136f661c727 Jonathan Cameron:
hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset()
28* 8c313254e61e Richard Henderson:
accel/tcg: Fix atomic_mmu_lookup for reads
29* fcc0b0418fff Peter Maydell:
target/arm: Fix handling of SW and NSW bits for stage 2 walks
30* cd22a0f520f4 Peter Maydell:
ui: Fix pixel colour channel order for PNG screenshots
31* 478dccbb99db Peter Maydell:
target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check
32* d66ba6dc1cce Cédric Le Goater:
async: Suppress GCC13 false positive in aio_bh_poll()
33* 6a5d81b17201 Shivaprasad G Bhat:
tcg: ppc64: Fix mask generation for vextractdm
34* e8ecdfeb30f0 Ilya Leoshkevich:
target/s390x: Fix EXECUTE of relative branches
35* 970641de0190 Ilya Leoshkevich:
s390x/tcg: Fix LDER instruction format
36* 92e667f6fd58 Jason Andryuk:
9pfs/xen: Fix segfault on shutdown
37* 988998503bc6 Richard Henderson:
tcg/i386: Set P_REXW in tcg_out_addi_ptr
38* 88693ab2a53f Claudio Imbrenda:
s390x/pv: Fix spurious warning with asynchronous teardown
39* 80bd81cadd12 Claudio Imbrenda:
util/async-teardown: wire up query-command-line-options
40* c70bb9a771d4 Lizhi Yang:
docs/about/emulation: fix typo
41* 3217b84f3cd8 Alex Bennée:
tests/docker: bump the xtensa base to debian:11-slim
42* a0f8d2701b20 Daniil Kovalev:
linux-user: Fix mips fp64 executables loading
43* 1e35d327890b Michael Tokarev:
linux-user: fix getgroups/setgroups allocations
44* 403d18ae3842 Eric Blake:
migration: Handle block device inactivation failures better
45* 5d39f44d7ac5 Eric Blake:
migration: Minor control flow simplification
46* 6dab4c93ecfa Eric Blake:
migration: Attempt disk reactivation in more failure scenarios
47* a6771f2f5cbf Richard Henderson:
target/arm: Fix vd == vm overlap in sve_ldff1_z
48* 9bd634b2f5e2 Paolo Bonzini:
scsi-generic: fix buffer overflow on block limits inquiry
49* 2b55e479e6fc Paolo Bonzini:
target/i386: fix operand size for VCOMI/VUCOMI instructions
50* 056d649007bc Xinyu Li:
target/i386: fix avx2 instructions vzeroall and vpermdq
51* 5d410557dea4 Hawkins Jiawei:
vhost: fix possible wrap in SVQ descriptor ring
52* 5ed3dabe57dd Leonardo Bras:
hw/pci: Disable PCI_ERR_UNCOR_MASK register for machine type < 8.0
53* 1fac00f70b32 Eugenio Pérez:
virtio-net: not enable vq reset feature unconditionally
54* 3e69908907f8 Mauro Matteo Cascella:
virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
55* 6d740fb01b9f Stefan Hajnoczi:
aio-posix: do not nest poll handlers
56* 844a12a63e12 Stefan Hajnoczi:
tested: add test for nested aio_poll() in poll handlers
57* 58a2e3f5c37b Stefan Hajnoczi:
block: compile out assert_bdrv_graph_readable() by default
58* 80fc5d260002 Kevin Wolf:
graph-lock: Disable locking for now
59* 7c1f51bf38de Kevin Wolf:
nbd/server: Fix drained_poll to wake coroutine in right AioContext
60 8d689f6aae8b [email protected]:
e1000e: Fix tx/rx counters
61 f3f9b726afba Akihiko Odaki:
e1000x: Fix BPRC and MPRC
62 ed447c60b341 Akihiko Odaki:
igb: Fix Rx packet type encoding
63 e209716749cd Akihiko Odaki:
igb: Do not require CTRL.VME for tx VLAN tagging
64 f0b1df5c4502 Akihiko Odaki:
igb: Clear IMS bits when committing ICR access
65 2f0fa232b8c3 Akihiko Odaki:
net/net_rx_pkt: Use iovec for net_rx_pkt_set_protocols()
66 310a128eae12 Akihiko Odaki:
e1000e: Always copy ethernet header
67 dc9ef1bf4548 Akihiko Odaki:
igb: Always copy ethernet header
68 792676c16515 Stefan Hajnoczi:
rtl8139: fix large_send_mss divide-by-zero
69 dbdea0dbfe2c Akihiko Odaki:
util/vfio-helpers: Use g_file_read_link()
70 6301460ce9f5 Paolo Bonzini:
usb/ohci: Set pad to 0 after frame update
71 b987718bbb1d Thomas Huth:
hw/scsi/lsi53c895a: Fix reentrancy issues in the LSI controller (CVE-2023-0330)
72 a37531f2381c Igor Mammedov:
machine: do not crash if default RAM backend name has been stolen
73 0bfd14149b24 Paolo Bonzini:
virtio: qmp: fix memory leak
(commit(s) marked with * were in previous series and are not resent)
PATCH 60/73 e1000e: Fix tx/rx counters
From: "[email protected]" <[email protected]>
The bytes and packets counter registers are cleared on read.
Copying the "total counter" registers to the "good counter" registers has side effects.
If the "total" register is never read by the OS, it only gets incremented. This leads to exponential growth of the "good" register.
This commit increments the counters individually to avoid this.
hw/net/e1000.c +2 -3
@@ -637,9 +637,8 @@ xmit_seg(E1000State *s)e1000x_inc_reg_if_not_full (s->mac_reg,TPT );e1000x_grow_8reg_if_not_full (s->mac_reg,TOTL , s->tx.size +4 ); - s->mac_reg[GPTC ] = s->mac_reg[TPT ]; - s->mac_reg[GOTCL ] = s->mac_reg[TOTL ]; - s->mac_reg[GOTCH ] = s->mac_reg[TOTH ]; +e1000x_inc_reg_if_not_full (s->mac_reg,GPTC ); +e1000x_grow_8reg_if_not_full (s->mac_reg,GOTCL , s->tx.size +4 ); } static void
hw/net/e1000e_core.c +2 -3
@@ -711,9 +711,8 @@ e1000e_on_tx_done_update_stats(E1000ECore *core, struct NetTxPkt *tx_pkt)g_assert_not_reached (); } - core->mac[GPTC ] = core->mac[TPT ]; - core->mac[GOTCL ] = core->mac[TOTL ]; - core->mac[GOTCH ] = core->mac[TOTH ]; +e1000x_inc_reg_if_not_full (core->mac,GPTC ); +e1000x_grow_8reg_if_not_full (core->mac,GOTCL , tot_len); } static void
hw/net/e1000x_common.c +2 -3
@@ -220,15 +220,14 @@ e1000x_update_rx_total_stats(uint32_t *mac,e1000x_increase_size_stats (mac, PRCregs, data_fcs_size);e1000x_inc_reg_if_not_full (mac,TPR ); - mac[GPRC ] = mac[TPR ]; +e1000x_inc_reg_if_not_full (mac,GPRC );/* TOR - Total Octets Received: * This register includes bytes received in a packet from the <Destination * Address> field through the <CRC> field, inclusively. * Always include FCS length (4) in size. */ e1000x_grow_8reg_if_not_full (mac,TORL , data_size +4 ); - mac[GORCL ] = mac[TORL ]; - mac[GORCH ] = mac[TORH ]; +e1000x_grow_8reg_if_not_full (mac,GORCL , data_size +4 ); }void
hw/net/igb_core.c +2 -3
@@ -538,9 +538,8 @@ igb_on_tx_done_update_stats(IGBCore *core, struct NetTxPkt *tx_pkt, int qn)g_assert_not_reached (); } - core->mac[GPTC ] = core->mac[TPT ]; - core->mac[GOTCL ] = core->mac[TOTL ]; - core->mac[GOTCH ] = core->mac[TOTH ]; +e1000x_inc_reg_if_not_full (core->mac,GPTC ); +e1000x_grow_8reg_if_not_full (core->mac,GOTCL , tot_len);if (core->mac[MRQC ] &1 ) {uint16_t pool = qn %IGB_NUM_VM_POOLS ;
Signature · 1 line
2.39.2
PATCH 61/73 e1000x: Fix BPRC and MPRC
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
Before this change, e1000 and the common code updated BPRC and MPRC depending on the matched filter, but e1000e and igb decided to update those counters by deriving the packet type independently. This inconsistency caused a multicast packet to be counted twice.
Updating BPRC and MPRC depending on are fundamentally flawed anyway as a filter can be used for different types of packets. For example, it is possible to filter broadcast packets with MTA.
Always determine what counters to update by inspecting the packets.
hw/net/e1000.c +3 -3
@@ -826,12 +826,10 @@ receive_filter(E1000State *s, const uint8_t *buf, int size) }if (ismcast && (rctl &E1000_RCTL_MPE )) {/* promiscuous mcast */ -e1000x_inc_reg_if_not_full (s->mac_reg,MPRC );return 1 ; }if (isbcast && (rctl &E1000_RCTL_BAM )) {/* broadcast enabled */ -e1000x_inc_reg_if_not_full (s->mac_reg,BPRC );return 1 ; }
@@ -922,6 +920,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)size_t desc_offset;size_t desc_size;size_t total_size; +eth_pkt_types_e pkt_type;if (!e1000x_hw_rx_enabled (s->mac_reg)) {return -1 ;
@@ -971,6 +970,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) size -=4 ; } + pkt_type =get_eth_packet_type (PKT_GET_ETH_HDR (filter_buf)); rdh_start = s->mac_reg[RDH ]; desc_offset =0 ; total_size = size +e1000x_fcs_len (s->mac_reg);
@@ -1036,7 +1036,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) } }while (desc_offset < total_size); -e1000x_update_rx_total_stats (s->mac_reg, size, total_size); +e1000x_update_rx_total_stats (s->mac_reg, pkt_type, size, total_size); n =E1000_ICS_RXT0 ;if ((rdt = s->mac_reg[RDT ]) < s->mac_reg[RDH ])
hw/net/e1000e_core.c +3 -17
@@ -1487,24 +1487,10 @@ e1000e_write_to_rx_buffers(E1000ECore *core, }static void -e1000e_update_rx_stats (E1000ECore *core, -size_t data_size, -size_t data_fcs_size) +e1000e_update_rx_stats (E1000ECore *core,size_t pkt_size,size_t pkt_fcs_size) { -e1000x_update_rx_total_stats (core->mac, data_size, data_fcs_size); - -switch (net_rx_pkt_get_packet_type (core->rx_pkt)) { -case ETH_PKT_BCAST : -e1000x_inc_reg_if_not_full (core->mac,BPRC ); -break ; - -case ETH_PKT_MCAST : -e1000x_inc_reg_if_not_full (core->mac,MPRC ); -break ; - -default : -break ; - } +eth_pkt_types_e pkt_type =net_rx_pkt_get_packet_type (core->rx_pkt); +e1000x_update_rx_total_stats (core->mac, pkt_type, pkt_size, pkt_fcs_size); } static inline bool
hw/net/e1000x_common.c +19 -6
@@ -80,7 +80,6 @@ bool e1000x_rx_group_filter(uint32_t *mac, const uint8_t *buf) f = mta_shift[(rctl >>E1000_RCTL_MO_SHIFT ) &3 ]; f = (((buf[5 ] <<8 ) | buf[4 ]) >> f) &0xfff ;if (mac[MTA + (f >>5 )] & (1 << (f &0x1f ))) { -e1000x_inc_reg_if_not_full (mac,MPRC );return true; }
@@ -212,13 +211,14 @@ e1000x_rxbufsize(uint32_t rctl)void e1000x_update_rx_total_stats (uint32_t *mac, -size_t data_size, -size_t data_fcs_size) +eth_pkt_types_e pkt_type, +size_t pkt_size, +size_t pkt_fcs_size) {static const int PRCregs[6 ] = {PRC64 ,PRC127 ,PRC255 ,PRC511 ,PRC1023 ,PRC1522 }; -e1000x_increase_size_stats (mac, PRCregs, data_fcs_size); +e1000x_increase_size_stats (mac, PRCregs, pkt_fcs_size);e1000x_inc_reg_if_not_full (mac,TPR );e1000x_inc_reg_if_not_full (mac,GPRC );/* TOR - Total Octets Received:
@@ -226,8 +226,21 @@ e1000x_update_rx_total_stats(uint32_t *mac,* Address> field through the <CRC> field, inclusively. * Always include FCS length (4) in size. */ -e1000x_grow_8reg_if_not_full (mac,TORL , data_size +4 ); -e1000x_grow_8reg_if_not_full (mac,GORCL , data_size +4 ); +e1000x_grow_8reg_if_not_full (mac,TORL , pkt_size +4 ); +e1000x_grow_8reg_if_not_full (mac,GORCL , pkt_size +4 ); + +switch (pkt_type) { +case ETH_PKT_BCAST : +e1000x_inc_reg_if_not_full (mac,BPRC ); +break ; + +case ETH_PKT_MCAST : +e1000x_inc_reg_if_not_full (mac,MPRC ); +break ; + +default : +break ; + } }void
hw/net/e1000x_common.h +3 -2
@@ -91,8 +91,9 @@ e1000x_update_regs_on_link_up(uint32_t *mac, uint16_t *phy) }void e1000x_update_rx_total_stats (uint32_t *mac, -size_t data_size, -size_t data_fcs_size); +eth_pkt_types_e pkt_type, +size_t pkt_size, +size_t pkt_fcs_size); void e1000x_core_prepare_eeprom(uint16_t *eeprom, const uint16_t *templ,
hw/net/igb_core.c +5 -17
@@ -1437,29 +1437,17 @@ igb_write_to_rx_buffers(IGBCore *core,static void igb_update_rx_stats (IGBCore *core,const E1000E_RingInfo *rxi, -size_t data_size,size_t data_fcs_size) +size_t pkt_size,size_t pkt_fcs_size) { -e1000x_update_rx_total_stats (core->mac, data_size, data_fcs_size); - -switch (net_rx_pkt_get_packet_type (core->rx_pkt)) { -case ETH_PKT_BCAST : -e1000x_inc_reg_if_not_full (core->mac,BPRC ); -break ; - -case ETH_PKT_MCAST : -e1000x_inc_reg_if_not_full (core->mac,MPRC ); -break ; - -default : -break ; - } +eth_pkt_types_e pkt_type =net_rx_pkt_get_packet_type (core->rx_pkt); +e1000x_update_rx_total_stats (core->mac, pkt_type, pkt_size, pkt_fcs_size);if (core->mac[MRQC ] &1 ) {uint16_t pool = rxi->idx %IGB_NUM_VM_POOLS ; - core->mac[PVFGORC0 + (pool *64 )] += data_size +4 ; + core->mac[PVFGORC0 + (pool *64 )] += pkt_size +4 ; core->mac[PVFGPRC0 + (pool *64 )]++; -if (net_rx_pkt_get_packet_type (core->rx_pkt) ==ETH_PKT_MCAST ) { +if (pkt_type ==ETH_PKT_MCAST ) { core->mac[PVFMPRC0 + (pool *64 )]++; } }
Signature · 1 line
2.39.2
PATCH 62/73 igb: Fix Rx packet type encoding
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
igb's advanced descriptor uses a packet type encoding different from one used in e1000e's extended descriptor. Fix the logic to encode Rx packet type accordingly.
hw/net/igb_core.c +19 -19
@@ -1226,7 +1226,6 @@ igb_build_rx_metadata(IGBCore *core,struct virtio_net_hdr *vhdr;bool hasip4, hasip6;EthL4HdrProto l4hdr_proto; -uint32_t pkt_type; *status_flags =E1000_RXD_STAT_DD ;
@@ -1265,28 +1264,29 @@ igb_build_rx_metadata(IGBCore *core,trace_e1000e_rx_metadata_ack (); } -if (hasip6 && (core->mac[RFCTL ] &E1000_RFCTL_IPV6_DIS )) { -trace_e1000e_rx_metadata_ipv6_filtering_disabled (); - pkt_type =E1000_RXD_PKT_MAC ; - }else if (l4hdr_proto ==ETH_L4_HDR_PROTO_TCP || - l4hdr_proto ==ETH_L4_HDR_PROTO_UDP ) { - pkt_type = hasip4 ?E1000_RXD_PKT_IP4_XDP :E1000_RXD_PKT_IP6_XDP ; - }else if (hasip4 || hasip6) { - pkt_type = hasip4 ?E1000_RXD_PKT_IP4 :E1000_RXD_PKT_IP6 ; - }else { - pkt_type =E1000_RXD_PKT_MAC ; - } +if (pkt_info) { + *pkt_info = rss_info->enabled ? rss_info->type :0 ; -trace_e1000e_rx_metadata_pkt_type (pkt_type); +if (hasip4) { + *pkt_info |=E1000_ADVRXD_PKT_IP4 ; + } -if (pkt_info) { -if (rss_info->enabled) { - *pkt_info = rss_info->type; +if (hasip6) { + *pkt_info |=E1000_ADVRXD_PKT_IP6 ; } - *pkt_info |= (pkt_type <<4 ); - }else { - *status_flags |=E1000_RXD_PKT_TYPE (pkt_type); +switch (l4hdr_proto) { +case ETH_L4_HDR_PROTO_TCP : + *pkt_info |=E1000_ADVRXD_PKT_TCP ; +break ; + +case ETH_L4_HDR_PROTO_UDP : + *pkt_info |=E1000_ADVRXD_PKT_UDP ; +break ; + +default : +break ; + } }if (hdr_info) {
hw/net/igb_regs.h +5 -0
@@ -641,6 +641,11 @@ union e1000_adv_rx_desc {#define E1000_STATUS_NUM_VFS_SHIFT 14 +#define E1000_ADVRXD_PKT_IP4 BIT(4) +#define E1000_ADVRXD_PKT_IP6 BIT(6) +#define E1000_ADVRXD_PKT_TCP BIT(8) +#define E1000_ADVRXD_PKT_UDP BIT(9) +static inline uint8_t igb_ivar_entry_rx (uint8_t i) {return i <8 ? i *4 : (i -8 ) *4 +2 ;
Signature · 1 line
2.39.2
PATCH 63/73 igb: Do not require CTRL.VME for tx VLAN tagging
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
While the datasheet of e1000e says it checks CTRL.VME for tx VLAN tagging, igb's datasheet has no such statements. It also says for "CTRL.VLE":
Quoted 2 lines
This register only affects the VLAN Strip in Rx it does not have any influence in the Tx path in the 82576.
(Appendix A. Changes from the 82575)
There is no "CTRL.VLE" so it is more likely that it is a mistake of CTRL.VME.
hw/net/igb_core.c +1 -1
@@ -402,7 +402,7 @@ igb_tx_insert_vlan(IGBCore *core, uint16_t qn, struct igb_tx *tx, } } -if (insert_vlan &&e1000x_vlan_enabled (core->mac)) { +if (insert_vlan) {net_tx_pkt_setup_vlan_header_ex (tx->tx_pkt, vlan, core->mac[VET ] &0xffff ); }
Signature · 1 line
2.39.2
PATCH 64/73 igb: Clear IMS bits when committing ICR access
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
The datasheet says contradicting statements regarding ICR accesses so it is not reliable to determine the behavior of ICR accesses. However, e1000e does clear IMS bits when reading ICR accesses and Linux also expects ICR accesses will clear IMS bits according to:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/intel/igb/igb_main.c?h=v6.2#n8048
hw/net/igb_core.c +4 -4
@@ -2451,16 +2451,16 @@ igb_set_ims(IGBCore *core, int index, uint32_t val)static void igb_commit_icr (IGBCore *core) {/* -* If GPIE.NSICR = 0, then the copy of IAM to IMS will occur only if at +* If GPIE.NSICR = 0, then the clear of IMS will occur only if at * least one bit is set in the IMS and there is a true interrupt as * reflected in ICR.INTA. */ if ((core->mac[GPIE ] &E1000_GPIE_NSICR ) || (core->mac[IMS ] && (core->mac[ICR ] &E1000_ICR_INT_ASSERTED ))) { -igb_set_ims (core,IMS , core->mac[IAM ]); - }else { -igb_update_interrupt_state (core); +igb_clear_ims_bits (core, core->mac[IAM ]); } + +igb_update_interrupt_state (core); }static void igb_set_icr (IGBCore *core,int index,uint32_t val)
Signature · 1 line
2.39.2
PATCH 65/73 net/net_rx_pkt: Use iovec for net_rx_pkt_set_protocols()
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
igb does not properly ensure the buffer passed to net_rx_pkt_set_protocols() is contiguous for the entire L2/L3/L4 header. Allow it to pass scattered data to net_rx_pkt_set_protocols().
hw/net/igb_core.c +1 -1
@@ -1649,7 +1649,7 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt, ehdr =PKT_GET_ETH_HDR (filter_buf);net_rx_pkt_set_packet_type (core->rx_pkt,get_eth_packet_type (ehdr)); -net_rx_pkt_set_protocols (core->rx_pkt, filter_buf, size); +net_rx_pkt_set_protocols (core->rx_pkt, iov, iovcnt, iov_ofs); queues =igb_receive_assign (core, ehdr, size, &rss_info, external_tx);if (!queues) {
hw/net/net_rx_pkt.c +5 -9
@@ -103,7 +103,7 @@ net_rx_pkt_pull_data(struct NetRxPkt *pkt, iov, iovcnt, ploff, pkt->tot_len); } -eth_get_protocols (pkt->vec, pkt->vec_len, &pkt->hasip4, &pkt->hasip6, +eth_get_protocols (pkt->vec, pkt->vec_len,0 , &pkt->hasip4, &pkt->hasip6, &pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off, &pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_info);
@@ -186,17 +186,13 @@ size_t net_rx_pkt_get_total_len(struct NetRxPkt *pkt)return pkt->tot_len; } -void net_rx_pkt_set_protocols (struct NetRxPkt *pkt,const void *data, -size_t len) +void net_rx_pkt_set_protocols (struct NetRxPkt *pkt, +const struct iovec *iov,size_t iovcnt, +size_t iovoff) { -const struct iovec iov = { - .iov_base = (void *)data, - .iov_len = len - }; -assert (pkt); -eth_get_protocols (&iov,1 , &pkt->hasip4, &pkt->hasip6, +eth_get_protocols (iov, iovcnt, iovoff, &pkt->hasip4, &pkt->hasip6, &pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off, &pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_info); }
hw/net/net_rx_pkt.h +6 -4
@@ -55,12 +55,14 @@ size_t net_rx_pkt_get_total_len(struct NetRxPkt *pkt);* parse and set packet analysis results * * @pkt: packet -* @data: pointer to the data buffer to be parsed -* @len: data length +* @iov: received data scatter-gather list +* @iovcnt: number of elements in iov +* @iovoff: data start offset in the iov * */ -void net_rx_pkt_set_protocols (struct NetRxPkt *pkt,const void *data, -size_t len); +void net_rx_pkt_set_protocols (struct NetRxPkt *pkt, +const struct iovec *iov,size_t iovcnt, +size_t iovoff);/** * fetches packet analysis results
hw/net/virtio-net.c +5 -2
@@ -1834,9 +1834,12 @@ static int virtio_net_process_rss(NetClientState *nc, const uint8_t *buf, VIRTIO_NET_HASH_REPORT_UDPv6, VIRTIO_NET_HASH_REPORT_UDPv6_EX }; +struct iovec iov = { + .iov_base = (void *)buf, + .iov_len = size + }; -net_rx_pkt_set_protocols (pkt, buf + n->host_hdr_len, - size - n->host_hdr_len); +net_rx_pkt_set_protocols (pkt, &iov,1 , n->host_hdr_len);net_rx_pkt_get_protocols (pkt, &hasip4, &hasip6, &l4hdr_proto); net_hash_type =virtio_net_get_hash_type (hasip4, hasip6, l4hdr_proto, n->rss_data.hash_types);
hw/net/vmxnet3.c +6 -1
@@ -2001,7 +2001,12 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size) get_eth_packet_type(PKT_GET_ETH_HDR(buf)));if (vmxnet3_rx_filter_may_indicate (s, buf, size)) { -net_rx_pkt_set_protocols (s->rx_pkt, buf, size); +struct iovec iov = { + .iov_base = (void *)buf, + .iov_len = size + }; + +net_rx_pkt_set_protocols (s->rx_pkt, &iov,1 ,0 );vmxnet3_rx_need_csum_calculate (s->rx_pkt, buf, size);net_rx_pkt_attach_data (s->rx_pkt, buf, size, s->rx_vlan_stripping); bytes_indicated =vmxnet3_indicate_packet (s) ? size :-1 ;
include/net/eth.h +3 -3
@@ -312,10 +312,10 @@ eth_get_l2_hdr_length(const void *p) }static inline uint32_t -eth_get_l2_hdr_length_iov (const struct iovec *iov,int iovcnt) +eth_get_l2_hdr_length_iov (const struct iovec *iov,size_t iovcnt,size_t iovoff) {uint8_t p[sizeof (struct eth_header ) +sizeof (struct vlan_header )]; -size_t copied =iov_to_buf (iov, iovcnt,0 , p,ARRAY_SIZE (p)); +size_t copied =iov_to_buf (iov, iovcnt, iovoff, p,ARRAY_SIZE (p));if (copied <ARRAY_SIZE (p)) {return copied;
@@ -397,7 +397,7 @@ typedef struct eth_l4_hdr_info_st {bool has_tcp_data; } eth_l4_hdr_info; -void eth_get_protocols(const struct iovec *iov, int iovcnt, +void eth_get_protocols(const struct iovec *iov, size_t iovcnt, size_t iovoff, bool *hasip4, bool *hasip6, size_t *l3hdr_off, size_t *l4hdr_off,
net/eth.c +8 -10
@@ -136,7 +136,7 @@ _eth_tcp_has_data(bool is_ip4,return l4len >TCP_HEADER_DATA_OFFSET (tcp); } -void eth_get_protocols(const struct iovec *iov, int iovcnt, +void eth_get_protocols(const struct iovec *iov, size_t iovcnt, size_t iovoff, bool *hasip4, bool *hasip6, size_t *l3hdr_off, size_t *l4hdr_off,
@@ -147,26 +147,24 @@ void eth_get_protocols(const struct iovec *iov, int iovcnt, {int proto;bool fragment = false; -size_t l2hdr_len =eth_get_l2_hdr_length_iov (iov, iovcnt);size_t input_size =iov_size (iov, iovcnt);size_t copied;uint8_t ip_p; *hasip4 = *hasip6 = false; + *l3hdr_off = iovoff +eth_get_l2_hdr_length_iov (iov, iovcnt, iovoff); l4hdr_info->proto =ETH_L4_HDR_PROTO_INVALID ; - proto =eth_get_l3_proto (iov, iovcnt, l2hdr_len); - - *l3hdr_off = l2hdr_len; + proto =eth_get_l3_proto (iov, iovcnt, *l3hdr_off);if (proto ==ETH_P_IP ) {struct ip_header *iphdr = &ip4hdr_info->ip4_hdr; -if (input_size < l2hdr_len) { +if (input_size < *l3hdr_off) {return ; } - copied =iov_to_buf (iov, iovcnt, l2hdr_len, iphdr,sizeof (*iphdr)); + copied =iov_to_buf (iov, iovcnt, *l3hdr_off, iphdr,sizeof (*iphdr));if (copied <sizeof (*iphdr) ||IP_HEADER_VERSION (iphdr) !=IP_HEADER_VERSION_4 ) {return ;
@@ -175,17 +173,17 @@ void eth_get_protocols(const struct iovec *iov, int iovcnt, *hasip4 = true; ip_p = iphdr->ip_p; ip4hdr_info->fragment =IP4_IS_FRAGMENT (iphdr); - *l4hdr_off = l2hdr_len +IP_HDR_GET_LEN (iphdr); + *l4hdr_off = *l3hdr_off +IP_HDR_GET_LEN (iphdr); fragment = ip4hdr_info->fragment; }else if (proto ==ETH_P_IPV6 ) { -if (!eth_parse_ipv6_hdr (iov, iovcnt, l2hdr_len, ip6hdr_info)) { +if (!eth_parse_ipv6_hdr (iov, iovcnt, *l3hdr_off, ip6hdr_info)) {return ; } *hasip6 = true; ip_p = ip6hdr_info->l4proto; - *l4hdr_off = l2hdr_len + ip6hdr_info->full_hdr_len; + *l4hdr_off = *l3hdr_off + ip6hdr_info->full_hdr_len; fragment = ip6hdr_info->fragment; }else {return ;
Signature · 1 line
2.39.2
PATCH 66/73 e1000e: Always copy ethernet header
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
e1000e_receive_internal() used to check the iov length to determine copy the iovs to a contiguous buffer, but the check is flawed in two ways:
- It does not ensure that iovcnt > 0.
- It does not take virtio-net header into consideration.
The size of this copy is just 18 octets, which can be even less than the code size required for checks. This (wrong) optimization is probably not worth so just remove it.
hw/net/e1000e_core.c +10 -16
@@ -1685,12 +1685,9 @@ static ssize_t e1000e_receive_internal(E1000ECore *core, const struct iovec *iov, int iovcnt, bool has_vnet) { -static const int maximum_ethernet_hdr_len = (ETH_HLEN +4 ); -uint32_t n =0 ; -uint8_t min_buf[ETH_ZLEN ]; +uint8_t buf[ETH_ZLEN ];struct iovec min_iov; -uint8_t *filter_buf;size_t size, orig_size;size_t iov_ofs =0 ;E1000E_RxRing rxr;
@@ -1713,24 +1710,21 @@ e1000e_receive_internal(E1000ECore *core, const struct iovec *iov, int iovcnt,net_rx_pkt_unset_vhdr (core->rx_pkt); } - filter_buf = iov->iov_base + iov_ofs; orig_size =iov_size (iov, iovcnt); size = orig_size - iov_ofs;/* Pad to minimum Ethernet frame length */ -if (size <sizeof (min_buf)) { -iov_to_buf (iov, iovcnt, iov_ofs, min_buf, size); -memset (&min_buf[size],0 ,sizeof (min_buf) - size); +if (size <sizeof (buf)) { +iov_to_buf (iov, iovcnt, iov_ofs, buf, size); +memset (&buf[size],0 ,sizeof (buf) - size);e1000x_inc_reg_if_not_full (core->mac,RUC ); - min_iov.iov_base = filter_buf = min_buf; - min_iov.iov_len = size =sizeof (min_buf); + min_iov.iov_base = buf; + min_iov.iov_len = size =sizeof (buf); iovcnt =1 ; iov = &min_iov; iov_ofs =0 ; - }else if (iov->iov_len < maximum_ethernet_hdr_len) { -/* This is very unlikely, but may happen. */ -iov_to_buf (iov, iovcnt, iov_ofs, min_buf, maximum_ethernet_hdr_len); - filter_buf = min_buf; + }else { +iov_to_buf (iov, iovcnt, iov_ofs, buf,ETH_HLEN +4 ); }/* Discard oversized packets if !LPE and !SBP. */
@@ -1739,9 +1733,9 @@ e1000e_receive_internal(E1000ECore *core, const struct iovec *iov, int iovcnt, }net_rx_pkt_set_packet_type (core->rx_pkt, -get_eth_packet_type (PKT_GET_ETH_HDR (filter_buf))); +get_eth_packet_type (PKT_GET_ETH_HDR (buf))); -if (!e1000e_receive_filter (core, filter_buf, size)) { +if (!e1000e_receive_filter (core, buf, size)) {trace_e1000e_rx_flt_dropped ();return orig_size; }
Signature · 1 line
2.39.2
PATCH 67/73 igb: Always copy ethernet header
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
igb_receive_internal() used to check the iov length to determine copy the iovs to a contiguous buffer, but the check is flawed in two ways:
- It does not ensure that iovcnt > 0.
- It does not take virtio-net header into consideration.
The size of this copy is just 22 octets, which can be even less than the code size required for checks. This (wrong) optimization is probably not worth so just remove it. Removing this also allows igb to assume aligned accesses for the ethernet header.
hw/net/igb_core.c +23 -20
@@ -67,6 +67,11 @@ typedef struct IGBTxPktVmdqCallbackContext {NetClientState *nc; } IGBTxPktVmdqCallbackContext; +typedef struct L2Header { +struct eth_header eth; +struct vlan_header vlan; +}L2Header ; +static ssize_t igb_receive_internal (IGBCore *core,const struct iovec *iov,int iovcnt,bool has_vnet,bool *external_tx);
@@ -960,15 +965,16 @@ igb_rx_is_oversized(IGBCore *core, uint16_t qn, size_t size)return size > (lpe ? max_ethernet_lpe_size : max_ethernet_vlan_size); } -static uint16_t igb_receive_assign (IGBCore *core,const struct eth_header *ehdr, +static uint16_t igb_receive_assign (IGBCore *core,const L2Header *l2_header,size_t size,E1000E_RSSInfo *rss_info,bool *external_tx) {static const int ta_shift[] = {4 ,3 ,2 ,0 }; +const struct eth_header *ehdr = &l2_header->eth;uint32_t f, ra[2 ], *macp, rctl = core->mac[RCTL ];uint16_t queues =0 ;uint16_t oversized =0 ; -uint16_t vid =lduw_be_p (&PKT_GET_VLAN_HDR (ehdr)->h_tci) &VLAN_VID_MASK ; +uint16_t vid =be16_to_cpu (l2_header->vlan.h_tci) &VLAN_VID_MASK ;bool accepted = false;int i;
@@ -1589,14 +1595,13 @@ static ssize_t igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt, bool has_vnet, bool *external_tx) { -static const int maximum_ethernet_hdr_len = (ETH_HLEN +4 ); -uint16_t queues =0 ;uint32_t n =0 ; -uint8_t min_buf[ETH_ZLEN ]; +union { +L2Header l2_header; +uint8_t octets[ETH_ZLEN ]; + } buf;struct iovec min_iov; -struct eth_header *ehdr; -uint8_t *filter_buf;size_t size, orig_size;size_t iov_ofs =0 ;E1000E_RxRing rxr;
@@ -1622,24 +1627,21 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt,net_rx_pkt_unset_vhdr (core->rx_pkt); } - filter_buf = iov->iov_base + iov_ofs; orig_size =iov_size (iov, iovcnt); size = orig_size - iov_ofs;/* Pad to minimum Ethernet frame length */ -if (size <sizeof (min_buf)) { -iov_to_buf (iov, iovcnt, iov_ofs, min_buf, size); -memset (&min_buf[size],0 ,sizeof (min_buf) - size); +if (size <sizeof (buf)) { +iov_to_buf (iov, iovcnt, iov_ofs, &buf, size); +memset (&buf.octets[size],0 ,sizeof (buf) - size);e1000x_inc_reg_if_not_full (core->mac,RUC ); - min_iov.iov_base = filter_buf = min_buf; - min_iov.iov_len = size =sizeof (min_buf); + min_iov.iov_base = &buf; + min_iov.iov_len = size =sizeof (buf); iovcnt =1 ; iov = &min_iov; iov_ofs =0 ; - }else if (iov->iov_len < maximum_ethernet_hdr_len) { -/* This is very unlikely, but may happen. */ -iov_to_buf (iov, iovcnt, iov_ofs, min_buf, maximum_ethernet_hdr_len); - filter_buf = min_buf; + }else { +iov_to_buf (iov, iovcnt, iov_ofs, &buf,sizeof (buf.l2_header)); }/* Discard oversized packets if !LPE and !SBP. */
@@ -1647,11 +1649,12 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt,return orig_size; } - ehdr =PKT_GET_ETH_HDR (filter_buf); -net_rx_pkt_set_packet_type (core->rx_pkt,get_eth_packet_type (ehdr)); +net_rx_pkt_set_packet_type (core->rx_pkt, +get_eth_packet_type (&buf.l2_header.eth));net_rx_pkt_set_protocols (core->rx_pkt, iov, iovcnt, iov_ofs); - queues =igb_receive_assign (core, ehdr, size, &rss_info, external_tx); + queues =igb_receive_assign (core, &buf.l2_header, size, + &rss_info, external_tx);if (!queues) {trace_e1000e_rx_flt_dropped ();return orig_size;
Signature · 1 line
2.39.2
PATCH 68/73 rtl8139: fix large_send_mss divide-by-zero
In reply to Michael TokarevFrom: Stefan Hajnoczi <[email protected]>
If the driver sets large_send_mss to 0 then a divide-by-zero occurs. Even if the division wasn't a problem, the for loop that emits MSS-sized packets would never terminate.
Solve these issues by skipping offloading when large_send_mss=0.
This issue was found by OSS-Fuzz as part of Alexander Bulekov's device fuzzing work. The reproducer is:
$ cat << EOF | ./qemu-system-i386 -display none -machine accel=qtest, -m \ 512M,slots=1,maxmem=0xffff000000000000 -machine q35 -nodefaults -device \ rtl8139,netdev=net0 -netdev user,id=net0 -device \ pc-dimm,id=nv1,memdev=mem1,addr=0xb800a64602800000 -object \ memory-backend-ram,id=mem1,size=2M -qtest stdio outl 0xcf8 0x80000814 outl 0xcfc 0xe0000000 outl 0xcf8 0x80000804 outw 0xcfc 0x06 write 0xe0000037 0x1 0x04 write 0xe00000e0 0x2 0x01 write 0x1 0x1 0x04 write 0x3 0x1 0x98 write 0xa 0x1 0x8c write 0xb 0x1 0x02 write 0xc 0x1 0x46 write 0xd 0x1 0xa6 write 0xf 0x1 0xb8 write 0xb800a646028c000c 0x1 0x08 write 0xb800a646028c000e 0x1 0x47 write 0xb800a646028c0010 0x1 0x02 write 0xb800a646028c0017 0x1 0x06 write 0xb800a646028c0036 0x1 0x80 write 0xe00000d9 0x1 0x40 EOF
hw/net/rtl8139.c +3 -0
@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)int large_send_mss = (txdw0 >>CP_TC_LGSEN_MSS_SHIFT ) &CP_TC_LGSEN_MSS_MASK ; +if (large_send_mss ==0 ) { + goto skip_offload; + } DPRINTF("+++ C+ mode offloaded task TSO IP data %d " "frame data %d specified MSS=%d\n",
Signature · 1 line
2.39.2
PATCH 69/73 util/vfio-helpers: Use g_file_read_link()
In reply to Michael TokarevFrom: Akihiko Odaki <[email protected]>
When _FORTIFY_SOURCE=2, glibc version is 2.35, and GCC version is 12.1.0, the compiler complains as follows:
In file included from /usr/include/features.h:490,
from /usr/include/bits/libc-header-start.h:33,
from /usr/include/stdint.h:26,
from /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/include/stdint.h:9,
from /home/alarm/q/var/qemu/include/qemu/osdep.h:94,
from ../util/vfio-helpers.c:13:
In function 'readlink',
inlined from 'sysfs_find_group_file' at ../util/vfio-helpers.c:116:9,
inlined from 'qemu_vfio_init_pci' at ../util/vfio-helpers.c:326:18,
inlined from 'qemu_vfio_open_pci' at ../util/vfio-helpers.c:517:9:
/usr/include/bits/unistd.h:119:10: error: argument 2 is null but the corresponding size argument 3 value is 4095 [-Werror=nonnull]
119 | return __glibc_fortify (readlink, __len, sizeof (char),
| ^~~~~~~~~~~~~~~This error implies the allocated buffer can be NULL. Use g_file_read_link(), which allocates buffer automatically to avoid the error.
util/vfio-helpers.c +5 -3
@@ -106,15 +106,17 @@ struct QEMUVFIOState {*/ static char *sysfs_find_group_file (const char *device,Error **errp) { +g_autoptr (GError) gerr =NULL ;char *sysfs_link;char *sysfs_group;char *p;char *path =NULL ; sysfs_link =g_strdup_printf ("/sys/bus/pci/devices/%s/iommu_group" , device); - sysfs_group =g_malloc0 (PATH_MAX ); -if (readlink (sysfs_link, sysfs_group,PATH_MAX -1 ) ==-1 ) { -error_setg_errno (errp, errno,"Failed to find iommu group sysfs path" ); + sysfs_group =g_file_read_link (sysfs_link, &gerr); +if (gerr) { +error_setg (errp,"Failed to find iommu group sysfs path: %s" , + gerr->message); goto out; } p =strrchr (sysfs_group,'/' );
Signature · 1 line
2.39.2
PATCH 70/73 usb/ohci: Set pad to 0 after frame update
In reply to Michael TokarevFrom: Paolo Bonzini <[email protected]>
When the OHCI controller's framenumber is incremented, HccaPad1 register should be set to zero (Ref OHCI Spec 4.4)
ReactOS uses hccaPad1 to determine if the OHCI hardware is running, consequently it fails this check in current qemu master.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1048
hw/usb/hcd-ohci.c +2 -0
@@ -1239,6 +1239,8 @@ static void ohci_frame_boundary(void *opaque)/* Increment frame number and take care of endianness. */ ohci->frame_number = (ohci->frame_number +1 ) &0xffff ; hcca.frame =cpu_to_le16 (ohci->frame_number); +/* When the HC updates frame number, set pad to 0. Ref OHCI Spec 4.4.1*/ + hcca.pad =0 ;if (ohci->done_count ==0 && !(ohci->intr_status &OHCI_INTR_WD )) {if (!ohci->done) {
Signature · 1 line
2.39.2
PATCH 71/73 hw/scsi/lsi53c895a: Fix reentrancy issues in the LSI controller (CVE-2023-0330)
In reply to Michael TokarevFrom: Thomas Huth <[email protected]>
We cannot use the generic reentrancy guard in the LSI code, so we have to manually prevent endless reentrancy here. The problematic lsi_execute_script() function has already a way to detect whether too many instructions have been executed - we just have to slightly change the logic here that it also takes into account if the function has been called too often in a reentrant way.
The code in fuzz-lsi53c895a-test.c has been taken from an earlier patch by Mauro Matteo Cascella.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1563
Message-Id: <[email protected]>
hw/scsi/lsi53c895a.c +17 -6
@@ -1134,15 +1134,24 @@ static void lsi_execute_script(LSIState *s)uint32_t addr, addr_high;int opcode;int insn_processed =0 ; +static int reentrancy_level; + + reentrancy_level++; s->istat1 |=LSI_ISTAT1_SRUN ; again: -if (++insn_processed >LSI_MAX_INSN ) { -/* Some windows drivers make the device spin waiting for a memory -location to change. If we have been executed a lot of code then -assume this is the case and force an unexpected device disconnect. -This is apparently sufficient to beat the drivers into submission. -*/ +/* +* Some windows drivers make the device spin waiting for a memory location +* to change. If we have executed more than LSI_MAX_INSN instructions then +* assume this is the case and force an unexpected device disconnect. This +* is apparently sufficient to beat the drivers into submission. +* +* Another issue (CVE-2023-0330) can occur if the script is programmed to +* trigger itself again and again. Avoid this problem by stopping after +* being called multiple times in a reentrant way (8 is an arbitrary value +* which should be enough for all valid use cases). +*/ +if (++insn_processed >LSI_MAX_INSN || reentrancy_level >8 ) {if (!(s->sien0 &LSI_SIST0_UDC )) {qemu_log_mask (LOG_GUEST_ERROR ,"lsi_scsi: inf. loop with UDC masked" );
@@ -1596,6 +1605,8 @@ again: } }trace_lsi_execute_script_stop (); + + reentrancy_level--; }static uint8_t lsi_reg_readb (LSIState *s,int offset)
tests/qtest/fuzz-lsi53c895a-test.c +33 -0
@@ -8,6 +8,36 @@#include "qemu/osdep.h" #include "libqtest.h" +/* +* This used to trigger a DMA reentrancy issue +* leading to memory corruption bugs like stack +* overflow or use-after-free +* https://gitlab.com/qemu-project/qemu/-/issues/1563 +*/ +static void test_lsi_dma_reentrancy (void ) +{ +QTestState *s; + + s =qtest_init ("-M q35 -m 512M -nodefaults " +"-blockdev driver=null-co,node-name=null0 " +"-device lsi53c810 -device scsi-cd,drive=null0" ); + +qtest_outl (s,0xcf8 ,0x80000804 );/* PCI Command Register */ +qtest_outw (s,0xcfc ,0x7 );/* Enables accesses */ +qtest_outl (s,0xcf8 ,0x80000814 );/* Memory Bar 1 */ +qtest_outl (s,0xcfc ,0xff100000 );/* Set MMIO Address*/ +qtest_outl (s,0xcf8 ,0x80000818 );/* Memory Bar 2 */ +qtest_outl (s,0xcfc ,0xff000000 );/* Set RAM Address*/ +qtest_writel (s,0xff000000 ,0xc0000024 ); +qtest_writel (s,0xff000114 ,0x00000080 ); +qtest_writel (s,0xff00012c ,0xff000000 ); +qtest_writel (s,0xff000004 ,0xff000114 ); +qtest_writel (s,0xff000008 ,0xff100014 ); +qtest_writel (s,0xff10002f ,0x000000ff ); + +qtest_quit (s); +} +/* * This used to trigger a UAF in lsi_do_msgout() * https://gitlab.com/qemu-project/qemu/-/issues/972
@@ -124,5 +154,8 @@ int main(int argc, char **argv)qtest_add_func ("fuzz/lsi53c895a/lsi_do_msgout_cancel_req" , test_lsi_do_msgout_cancel_req); +qtest_add_func ("fuzz/lsi53c895a/lsi_dma_reentrancy" , + test_lsi_dma_reentrancy); +return g_test_run (); }
Signature · 1 line
2.39.2
PATCH 72/73 machine: do not crash if default RAM backend name has been stolen
In reply to Michael TokarevFrom: Igor Mammedov <[email protected]>
QEMU aborts when default RAM backend should be used (i.e. no explicit '-machine memory-backend=' specified) but user has created an object which 'id' equals to default RAM backend name used by board.
$QEMU -machine pc \
-object memory-backend-ram,id=pc.ram,size=4294967296 Actual results:
QEMU 7.2.0 monitor - type 'help' for more information
(qemu) Unexpected error in object_property_try_add() at ../qom/object.c:1239:
qemu-kvm: attempt to add duplicate property 'pc.ram' to object (type 'container') Aborted (core dumped)
Instead of abort, check for the conflicting 'id' and exit with an error, suggesting how to remedy the issue.
Message-Id: <[email protected]>
hw/core/machine.c +8 -0
@@ -1333,6 +1333,14 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error * } }else if (machine_class->default_ram_id && machine->ram_size &&numa_uses_legacy_mem ()) { +if (object_property_find (object_get_objects_root (), + machine_class->default_ram_id)) { +error_setg (errp,"object name '%s' is reserved for the default" +" RAM backend, it can't be used for any other purposes." +" Change the object's 'id' to something else" , + machine_class->default_ram_id); +return ; + }if (!create_default_memdev (current_machine, mem_path, errp)) {return ; }
Signature · 1 line
2.39.2
PATCH 73/73 virtio: qmp: fix memory leak
In reply to Michael TokarevFrom: Paolo Bonzini <[email protected]>
The VirtioInfoList is already allocated by QAPI_LIST_PREPEND and need not be allocated by the caller.
Fixes Coverity CID 1508724.
hw/virtio/virtio-qmp.c +5 -6
@@ -666,7 +666,7 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bitmap)VirtioInfoList *qmp_x_query_virtio (Error **errp) {VirtioInfoList *list =NULL ; -VirtioInfoList *node; +VirtioInfo *node;VirtIODevice *vdev; QTAILQ_FOREACH(vdev, &virtio_list, next) {
@@ -680,11 +680,10 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp)if (!strncmp (is_realized->str,"false" ,4 )) {QTAILQ_REMOVE (&virtio_list, vdev, next); }else { - node =g_new0 (VirtioInfoList,1 ); - node->value =g_new (VirtioInfo,1 ); - node->value->path =g_strdup (dev->canonical_path); - node->value->name =g_strdup (vdev->name); -QAPI_LIST_PREPEND (list, node->value); + node =g_new (VirtioInfo,1 ); + node->path =g_strdup (dev->canonical_path); + node->name =g_strdup (vdev->name); +QAPI_LIST_PREPEND (list, node); }g_string_free (is_realized, true); }
Signature · 1 line
2.39.2