From 6ab57a6b80be45372d7f3dd58e9776549d0ce9cf Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Mon, 26 May 2014 01:37:47 -0700 Subject: net: cadence_gem: Fix Tx descriptor update The local variable "desc" was being used to read-modify-write the first descriptor (of a multi-desc packet) upon packet completion. desc however continues to be used by the code as the current descriptor. Give this first desc RMW it's own local variable to avoid trampling. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/net/cadence_gem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index a26861e2ae..5335db874f 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -911,14 +911,16 @@ static void gem_transmit(GemState *s) /* Last descriptor for this packet; hand the whole thing off */ if (tx_desc_get_last(desc)) { + unsigned desc_first[2]; + /* Modify the 1st descriptor of this packet to be owned by * the processor. */ - cpu_physical_memory_read(s->tx_desc_addr, - (uint8_t *)&desc[0], sizeof(desc)); - tx_desc_set_used(desc); - cpu_physical_memory_write(s->tx_desc_addr, - (uint8_t *)&desc[0], sizeof(desc)); + cpu_physical_memory_read(s->tx_desc_addr, (uint8_t *)desc_first, + sizeof(desc_first)); + tx_desc_set_used(desc_first); + cpu_physical_memory_write(s->tx_desc_addr, (uint8_t *)desc_first, + sizeof(desc_first)); /* Advance the hardare current descriptor past this packet */ if (tx_desc_get_wrap(desc)) { s->tx_desc_addr = s->regs[GEM_TXQBASE]; -- cgit v1.2.3 From fa15286a758eb036258bffae2b6c128e2a477cc3 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Mon, 26 May 2014 01:38:21 -0700 Subject: net: cadence_gem: Add Tx descriptor fetch printf Add a debug printf for TX descriptor fetching. This is helpful to anyone needing to debug TX ring buffer traversal. It is also now consistent with the RX code which has a similar printf. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/net/cadence_gem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 5335db874f..cfb696a733 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -880,6 +880,8 @@ static void gem_transmit(GemState *s) /* read current descriptor */ packet_desc_addr = s->tx_desc_addr; + + DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); /* Handle all descriptors owned by hardware */ @@ -962,6 +964,7 @@ static void gem_transmit(GemState *s) } else { packet_desc_addr += 8; } + DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); } -- cgit v1.2.3 From 3048ed6aac8bd7622e1f9c82ebe83f819b5d6b75 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Mon, 26 May 2014 01:38:55 -0700 Subject: net: cadence_gem: Comment spelling sweep Fix some typos in comments. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/net/cadence_gem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index cfb696a733..fe40b4eca1 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -50,7 +50,7 @@ #define GEM_IER (0x00000028/4) /* Interrupt Enable reg */ #define GEM_IDR (0x0000002C/4) /* Interrupt Disable reg */ #define GEM_IMR (0x00000030/4) /* Interrupt Mask reg */ -#define GEM_PHYMNTNC (0x00000034/4) /* Phy Maintaince reg */ +#define GEM_PHYMNTNC (0x00000034/4) /* Phy Maintenance reg */ #define GEM_RXPAUSE (0x00000038/4) /* RX Pause Time reg */ #define GEM_TXPAUSE (0x0000003C/4) /* TX Pause Time reg */ #define GEM_TXPARTIALSF (0x00000040/4) /* TX Partial Store and Forward */ @@ -150,7 +150,7 @@ #define GEM_NWCTRL_LOCALLOOP 0x00000002 /* Local Loopback */ #define GEM_NWCFG_STRIP_FCS 0x00020000 /* Strip FCS field */ -#define GEM_NWCFG_LERR_DISC 0x00010000 /* Discard RX frames with lenth err */ +#define GEM_NWCFG_LERR_DISC 0x00010000 /* Discard RX frames with len err */ #define GEM_NWCFG_BUFF_OFST_M 0x0000C000 /* Receive buffer offset mask */ #define GEM_NWCFG_BUFF_OFST_S 14 /* Receive buffer offset shift */ #define GEM_NWCFG_UCAST_HASH 0x00000080 /* accept unicast if hash match */ @@ -397,7 +397,7 @@ static const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; */ static void gem_init_register_masks(GemState *s) { - /* Mask of register bits which are read only*/ + /* Mask of register bits which are read only */ memset(&s->regs_ro[0], 0, sizeof(s->regs_ro)); s->regs_ro[GEM_NWCTRL] = 0xFFF80000; s->regs_ro[GEM_NWSTATUS] = 0xFFFFFFFF; @@ -719,7 +719,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) unsigned crc_val; /* The application wants the FCS field, which QEMU does not provide. - * We must try and caclculate one. + * We must try and calculate one. */ memcpy(rxbuf, buf, size); @@ -871,7 +871,7 @@ static void gem_transmit(GemState *s) DB_PRINT("\n"); - /* The packet we will hand off to qemu. + /* The packet we will hand off to QEMU. * Packets scattered across multiple descriptors are gathered to this * one contiguous buffer first. */ @@ -923,7 +923,7 @@ static void gem_transmit(GemState *s) tx_desc_set_used(desc_first); cpu_physical_memory_write(s->tx_desc_addr, (uint8_t *)desc_first, sizeof(desc_first)); - /* Advance the hardare current descriptor past this packet */ + /* Advance the hardware current descriptor past this packet */ if (tx_desc_get_wrap(desc)) { s->tx_desc_addr = s->regs[GEM_TXQBASE]; } else { -- cgit v1.2.3 From ef18c2f54ee6ac3df3e8617958bcdb53ee9e8e06 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Mon, 26 May 2014 01:39:29 -0700 Subject: net: cadence_gem: Remove &desc[0] usages Just use desc instead. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/net/cadence_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index fe40b4eca1..de26609c9d 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -883,7 +883,7 @@ static void gem_transmit(GemState *s) DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, - (uint8_t *)&desc[0], sizeof(desc)); + (uint8_t *)desc, sizeof(desc)); /* Handle all descriptors owned by hardware */ while (tx_desc_get_used(desc) == 0) { @@ -966,7 +966,7 @@ static void gem_transmit(GemState *s) } DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, - (uint8_t *)&desc[0], sizeof(desc)); + (uint8_t *)desc, sizeof(desc)); } if (tx_desc_get_used(desc)) { -- cgit v1.2.3 From 2a802aaf635e9700942a04f698bce9e476c207e2 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 27 May 2014 16:15:20 +0400 Subject: qtest: fix hex2nib for capital characters Signed-off-by: Sergey Fedorov Reviewed-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael Tokarev --- qtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtest.c b/qtest.c index f9695a8ff6..04a6dc1f0f 100644 --- a/qtest.c +++ b/qtest.c @@ -148,7 +148,7 @@ static int hex2nib(char ch) } else if (ch >= 'a' && ch <= 'f') { return 10 + (ch - 'a'); } else if (ch >= 'A' && ch <= 'F') { - return 10 + (ch - 'a'); + return 10 + (ch - 'A'); } else { return -1; } -- cgit v1.2.3 From 49bba868df17aebf7525a5c8f21c451abe3dcdc8 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 29 May 2014 11:59:26 +0100 Subject: slirp: Remove unused zero_ethaddr[] variable The zero_ethaddr[] array is never used; delete it. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- slirp/slirp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 60280361e6..35f819afb7 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -37,8 +37,6 @@ static const uint8_t special_ethaddr[ETH_ALEN] = { 0x52, 0x55, 0x00, 0x00, 0x00, 0x00 }; -static const uint8_t zero_ethaddr[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; - u_int curtime; static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances = -- cgit v1.2.3 From 831f4d27b6b7a5af89e82af5975de98bd19bd18c Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 29 May 2014 12:01:49 +0100 Subject: hw/i386/pc.c: Remove unused parallel_io and parallel_irq variables The variables parallel_io and parallel_irq are unused; delete them. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/i386/pc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e6369d5be6..32d163288c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -922,9 +922,6 @@ static const int ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360, 0x280, 0x380 }; static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 }; -static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc }; -static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 }; - void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd) { static int nb_ne2k = 0; -- cgit v1.2.3 From 71795856881e037e0f0384b556c5b65f211662ad Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 3 Jun 2014 18:29:01 +0100 Subject: hw/sd/sd.c: Drop unused sd_acmd_type[] array Drop the sd_acmd_type[] array: it is never used. (The equivalent sd_cmd_type[] array for normal commands is used to identify those commands whose argument includes the card address in the top 16 bits; but for app commands the card address is passed with the APP_CMD prefix, not with the argument to the app command itself.) Signed-off-by: Peter Maydell Reviewed-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/sd/sd.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4502ad143d..5efe8c1af7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -151,17 +151,6 @@ static const sd_cmd_type_t sd_cmd_type[64] = { sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, }; -static const sd_cmd_type_t sd_acmd_type[64] = { - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_ac, sd_none, - sd_none, sd_none, sd_none, sd_none, sd_none, sd_adtc, sd_none, sd_none, - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_adtc, sd_ac, - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, - sd_none, sd_bcr, sd_ac, sd_none, sd_none, sd_none, sd_none, sd_none, - sd_none, sd_none, sd_none, sd_adtc, sd_none, sd_none, sd_none, sd_none, - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, -}; - static const int sd_cmd_class[64] = { 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, -- cgit v1.2.3 From f9b5426fd50a60d9fda2c061c24f60537666e9af Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 17:48:03 +0100 Subject: util/qemu-sockets.c: Avoid unused variable warnings The 'on' variable is never used, and 'off' is only used if IPV6_V6ONLY is defined; delete 'on' and move 'off' to the point where it is used. This avoids warnings from clang 3.4. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- util/qemu-sockets.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 627e60931a..e3d29eebb8 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -30,8 +30,6 @@ # define AI_ADDRCONFIG 0 #endif -static const int on=1, off=0; - /* used temporarily until all users are converted to QemuOpts */ QemuOptsList socket_optslist = { .name = "socket", @@ -159,6 +157,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) #ifdef IPV6_V6ONLY if (e->ai_family == PF_INET6) { /* listen on both ipv4 and ipv6 */ + const int off = 0; qemu_setsockopt(slisten, IPPROTO_IPV6, IPV6_V6ONLY, &off, sizeof(off)); } -- cgit v1.2.3 From a1fa7992a90658d803b8abaf182440c36c460d51 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 17:48:59 +0100 Subject: hw/dma/xilinx_axidma: Remove unused stream_halted() function The stream_halted() function is never used; remove it. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/dma/xilinx_axidma.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c index cc90eb5110..ee60d3ff39 100644 --- a/hw/dma/xilinx_axidma.c +++ b/hw/dma/xilinx_axidma.c @@ -157,11 +157,6 @@ static inline int stream_running(struct Stream *s) return s->regs[R_DMACR] & DMACR_RUNSTOP; } -static inline int stream_halted(struct Stream *s) -{ - return s->regs[R_DMASR] & DMASR_HALTED; -} - static inline int stream_idle(struct Stream *s) { return !!(s->regs[R_DMASR] & DMASR_IDLE); -- cgit v1.2.3 From c1d75727931e30da1b2c28887f21278812cae57c Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 17:50:22 +0100 Subject: hw/intc/openpic: Remove unused function IRQ_testbit() The IRQ_testbit() function is never used; remove it. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/intc/openpic.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index 17136c9333..08e0e19c59 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -311,11 +311,6 @@ static inline void IRQ_resetbit(IRQQueue *q, int n_IRQ) clear_bit(n_IRQ, q->queue); } -static inline int IRQ_testbit(IRQQueue *q, int n_IRQ) -{ - return test_bit(n_IRQ, q->queue); -} - static void IRQ_check(OpenPICState *opp, IRQQueue *q) { int irq = -1; -- cgit v1.2.3 From f46b9cc71ca69907d7e0b75eae669ed747f375b0 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 17:51:11 +0100 Subject: hw/isa/pc87312: Remove unused function is_parallel_epp() The function is_parallel_epp() is unused; remove it. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/isa/pc87312.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c index b352b491ac..9327c53132 100644 --- a/hw/isa/pc87312.c +++ b/hw/isa/pc87312.c @@ -86,11 +86,6 @@ static inline uint32_t get_parallel_irq(PC87312State *s) } } -static inline bool is_parallel_epp(PC87312State *s) -{ - return s->regs[REG_PTR] & PTR_EPP_MODE; -} - /* UARTs */ -- cgit v1.2.3 From e3a17ef6cc8034b6a453014746c34b41435c3345 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 18:04:55 +0100 Subject: target-i386/translate.c: Remove unused tcg_gen_lshift() The function tcg_gen_lshift() is unused; remove it. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- target-i386/translate.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 2359787b42..6fcd8245d2 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -1506,14 +1506,6 @@ static void gen_shift_rm_im(DisasContext *s, TCGMemOp ot, int op1, int op2, } } -static inline void tcg_gen_lshift(TCGv ret, TCGv arg1, target_long arg2) -{ - if (arg2 >= 0) - tcg_gen_shli_tl(ret, arg1, arg2); - else - tcg_gen_shri_tl(ret, arg1, -arg2); -} - static void gen_rot_rm_T1(DisasContext *s, TCGMemOp ot, int op1, int is_right) { target_ulong mask = (ot == MO_64 ? 0x3f : 0x1f); -- cgit v1.2.3 From 029ad4bcf31384783dce9896b2fc5349d9c13a9f Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 18:05:26 +0100 Subject: hw/misc/milkymist-softusb: Remove unused softusb_{read, write}_pmem() The functions softusb_read_pmem() and softusb_write_pmem() are unused; remove them. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/input/milkymist-softusb.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/hw/input/milkymist-softusb.c b/hw/input/milkymist-softusb.c index 53ba71410d..1b4b8d441a 100644 --- a/hw/input/milkymist-softusb.c +++ b/hw/input/milkymist-softusb.c @@ -156,31 +156,6 @@ static inline void softusb_write_dmem(MilkymistSoftUsbState *s, memcpy(s->dmem_ptr + offset, buf, len); } -static inline void softusb_read_pmem(MilkymistSoftUsbState *s, - uint32_t offset, uint8_t *buf, uint32_t len) -{ - if (offset + len >= s->pmem_size) { - error_report("milkymist_softusb: read pmem out of bounds " - "at offset 0x%x, len %d", offset, len); - memset(buf, 0, len); - return; - } - - memcpy(buf, s->pmem_ptr + offset, len); -} - -static inline void softusb_write_pmem(MilkymistSoftUsbState *s, - uint32_t offset, uint8_t *buf, uint32_t len) -{ - if (offset + len >= s->pmem_size) { - error_report("milkymist_softusb: write pmem out of bounds " - "at offset 0x%x, len %d", offset, len); - return; - } - - memcpy(s->pmem_ptr + offset, buf, len); -} - static void softusb_mouse_changed(MilkymistSoftUsbState *s) { uint8_t m; -- cgit v1.2.3 From fc4bde9025c07a2ef96d498f5d675d3ec044b00a Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 3 Jun 2014 18:59:21 +0100 Subject: target-microblaze: Delete unused sign_extend() function The sign_extend() function is unused; delete it. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Signed-off-by: Michael Tokarev --- target-microblaze/translate.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index c422bdc718..03ea15803b 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -99,19 +99,6 @@ static const char *special_regnames[] = "sr16", "sr17", "sr18" }; -/* Sign extend at translation time. */ -static inline int sign_extend(unsigned int val, unsigned int width) -{ - int sval; - - /* LSL. */ - val <<= 31 - width; - sval = val; - /* ASR. */ - sval >>= 31 - width; - return sval; -} - static inline void t_sync_flags(DisasContext *dc) { /* Synch the tb dependent flags between translator and runtime. */ -- cgit v1.2.3 From 89218c218f906b7384c2b365fc8bdc33b1452cbc Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 7 Jun 2014 17:53:11 +0100 Subject: hw/net/ne2000-isa: Register vmstate struct The ne2000-isa device defines a VMState struct for migration, but we forgot to actually register it. Correct this deficiency by setting dc->vmsd. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/net/ne2000-isa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c index c660e58335..0a14f6d1cd 100644 --- a/hw/net/ne2000-isa.c +++ b/hw/net/ne2000-isa.c @@ -98,6 +98,7 @@ static void isa_ne2000_class_initfn(ObjectClass *klass, void *data) dc->realize = isa_ne2000_realizefn; dc->props = ne2000_isa_properties; + dc->vmsd = &vmstate_isa_ne2000; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); } -- cgit v1.2.3 From d1180c1e57c8ea5acb6a472c07eebf371f5c282c Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 7 Jun 2014 20:54:42 +0200 Subject: apb: Fix compiler warnings (large constants) Both constants need more than 32 bit. Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/pci-host/apb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c index 1497008258..6fa2723449 100644 --- a/hw/pci-host/apb.c +++ b/hw/pci-host/apb.c @@ -99,8 +99,8 @@ do { printf("IOMMU: " fmt , ## __VA_ARGS__); } while (0) #define IOMMU_TTE_DATA_SIZE (1ULL << 61) #define IOMMU_TTE_DATA_W (1ULL << 1) -#define IOMMU_TTE_PHYS_MASK_8K 0x1ffffffe000 -#define IOMMU_TTE_PHYS_MASK_64K 0x1ffffff8000 +#define IOMMU_TTE_PHYS_MASK_8K 0x1ffffffe000ULL +#define IOMMU_TTE_PHYS_MASK_64K 0x1ffffff8000ULL #define IOMMU_TSB_8K_OFFSET_MASK_8M 0x00000000007fe000ULL #define IOMMU_TSB_8K_OFFSET_MASK_16M 0x0000000000ffe000ULL -- cgit v1.2.3 From 6998b6c11b4e8ca5e3c3e6bdbdf07a4f747d5d37 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 6 Jun 2014 16:06:52 +0200 Subject: vdi: remove double conversion This should be a problem when running on big-endian machines. Signed-off-by: Paolo Bonzini Reviewed-by: Benoit Canet Reviewed-by: Stefan Weil Signed-off-by: Michael Tokarev --- block/vdi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/vdi.c b/block/vdi.c index 27737af555..1b2be1af7b 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -239,7 +239,6 @@ static void vdi_header_to_le(VdiHeader *header) cpu_to_le32s(&header->block_extra); cpu_to_le32s(&header->blocks_in_image); cpu_to_le32s(&header->blocks_allocated); - cpu_to_le32s(&header->blocks_allocated); uuid_convert(header->uuid_image); uuid_convert(header->uuid_last_snap); uuid_convert(header->uuid_link); -- cgit v1.2.3 From a10678b08ecf87ef0b73426a876679178b392bcc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 4 Jun 2014 18:00:28 +0200 Subject: smbios: use g_free directly on NULL pointers No need to wrap it with an if. Signed-off-by: Paolo Bonzini Reviewed-by: Benoit Canet Signed-off-by: Michael Tokarev --- hw/i386/smbios.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index b3bedde8b9..e3fa1b2fc1 100644 --- a/hw/i386/smbios.c +++ b/hw/i386/smbios.c @@ -745,11 +745,6 @@ void smbios_set_cpuid(uint32_t version, uint32_t features) field = value; \ } -#define G_FREE_UNLESS_NULL(ptr) \ - if (ptr != NULL) { \ - g_free(ptr); \ - } - void smbios_set_defaults(const char *manufacturer, const char *product, const char *version, bool legacy_mode) { @@ -758,7 +753,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product, /* drop unwanted version of command-line file blob(s) */ if (smbios_legacy) { - G_FREE_UNLESS_NULL(smbios_tables); + g_free(smbios_tables); /* in legacy mode, also complain if fields were given for types > 1 */ if (find_next_bit(have_fields_bitmap, SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) { @@ -767,7 +762,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product, exit(1); } } else { - G_FREE_UNLESS_NULL(smbios_entries); + g_free(smbios_entries); } SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer); -- cgit v1.2.3 From 6b1dd54b6a4652a3a1e15a4beacd3be554a9ade1 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 6 Jun 2014 15:21:25 +0200 Subject: cpu/x86: correctly set errors in x86_cpu_parse_featurestr Because of the "goto out", the contents of local_err are leaked and lost. Signed-off-by: Paolo Bonzini Signed-off-by: Michael Tokarev --- target-i386/cpu.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index dde052cc42..8983457e23 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1688,8 +1688,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, numvalue = strtoul(val, &err, 0); if (!*val || *err) { - error_setg(&local_err, "bad numerical value %s", val); - goto out; + error_setg(errp, "bad numerical value %s", val); + return; } if (numvalue < 0x80000000) { error_report("xlevel value shall always be >= 0x80000000" @@ -1706,8 +1706,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, tsc_freq = strtosz_suffix_unit(val, &err, STRTOSZ_DEFSUFFIX_B, 1000); if (tsc_freq < 0 || *err) { - error_setg(&local_err, "bad numerical value %s", val); - goto out; + error_setg(errp, "bad numerical value %s", val); + return; } snprintf(num, sizeof(num), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), num, "tsc-frequency", @@ -1718,8 +1718,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, char num[32]; numvalue = strtoul(val, &err, 0); if (!*val || *err) { - error_setg(&local_err, "bad numerical value %s", val); - goto out; + error_setg(errp, "bad numerical value %s", val); + return; } if (numvalue < min) { error_report("hv-spinlocks value shall always be >= 0x%x" @@ -1738,7 +1738,7 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, } if (local_err) { error_propagate(errp, local_err); - goto out; + return; } featurestr = strtok(NULL, ","); } @@ -1758,9 +1758,6 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM]; env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM]; env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX]; - -out: - return; } /* generate a composite string into buf of all cpuid names in featureset -- cgit v1.2.3 From ec15993d9d7ea7108101f068c9929a62be29dc67 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 6 Jun 2014 18:32:08 +0200 Subject: libcacard: Drop superfluous conditionals around g_free() Signed-off-by: Markus Armbruster Signed-off-by: Michael Tokarev --- libcacard/cac.c | 14 ++++---------- libcacard/card_7816.c | 12 +++--------- libcacard/vcard.c | 10 +++------- libcacard/vcard_emul_nss.c | 4 +--- libcacard/vreader.c | 4 +--- 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/libcacard/cac.c b/libcacard/cac.c index 0a0163d3eb..ae8c3784b9 100644 --- a/libcacard/cac.c +++ b/libcacard/cac.c @@ -100,10 +100,8 @@ cac_applet_pki_reset(VCard *card, int channel) pki_applet = &(applet_private->u.pki_data); pki_applet->cert_buffer = NULL; - if (pki_applet->sign_buffer) { - g_free(pki_applet->sign_buffer); - pki_applet->sign_buffer = NULL; - } + g_free(pki_applet->sign_buffer); + pki_applet->sign_buffer = NULL; pki_applet->cert_buffer_len = 0; pki_applet->sign_buffer_len = 0; return VCARD_DONE; @@ -285,12 +283,8 @@ cac_delete_pki_applet_private(VCardAppletPrivate *applet_private) return; } pki_applet_data = &(applet_private->u.pki_data); - if (pki_applet_data->cert != NULL) { - g_free(pki_applet_data->cert); - } - if (pki_applet_data->sign_buffer != NULL) { - g_free(pki_applet_data->sign_buffer); - } + g_free(pki_applet_data->cert); + g_free(pki_applet_data->sign_buffer); if (pki_applet_data->key != NULL) { vcard_emul_delete_key(pki_applet_data->key); } diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c index a54f880390..814fa1662f 100644 --- a/libcacard/card_7816.c +++ b/libcacard/card_7816.c @@ -172,16 +172,12 @@ vcard_response_delete(VCardResponse *response) switch (response->b_type) { case VCARD_MALLOC: /* everything was malloc'ed */ - if (response->b_data) { - g_free(response->b_data); - } + g_free(response->b_data); g_free(response); break; case VCARD_MALLOC_DATA: /* only the data buffer was malloc'ed */ - if (response->b_data) { - g_free(response->b_data); - } + g_free(response->b_data); break; case VCARD_MALLOC_STRUCT: /* only the structure was malloc'ed */ @@ -358,9 +354,7 @@ vcard_apdu_delete(VCardAPDU *apdu) if (apdu == NULL) { return; } - if (apdu->a_data) { - g_free(apdu->a_data); - } + g_free(apdu->a_data); g_free(apdu); } diff --git a/libcacard/vcard.c b/libcacard/vcard.c index 6aaf085ecc..bf342aaf6d 100644 --- a/libcacard/vcard.c +++ b/libcacard/vcard.c @@ -51,9 +51,7 @@ vcard_buffer_response_delete(VCardBufferResponse *buffer_response) if (buffer_response == NULL) { return; } - if (buffer_response->buffer) { - g_free(buffer_response->buffer); - } + g_free(buffer_response->buffer); g_free(buffer_response); } @@ -121,10 +119,8 @@ vcard_delete_applet(VCardApplet *applet) applet->applet_private_free(applet->applet_private); applet->applet_private = NULL; } - if (applet->aid) { - g_free(applet->aid); - applet->aid = NULL; - } + g_free(applet->aid); + applet->aid = NULL; g_free(applet); } diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index cefc38333f..f1bba57c2f 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -471,9 +471,7 @@ vreader_emul_delete(VReaderEmul *vreader_emul) if (vreader_emul->slot) { PK11_FreeSlot(vreader_emul->slot); } - if (vreader_emul->type_params) { - g_free(vreader_emul->type_params); - } + g_free(vreader_emul->type_params); g_free(vreader_emul); } diff --git a/libcacard/vreader.c b/libcacard/vreader.c index d2a9b7df41..ffa05b6ca5 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -155,9 +155,7 @@ vreader_free(VReader *reader) if (reader->card) { vcard_free(reader->card); } - if (reader->name) { - g_free(reader->name); - } + g_free(reader->name); if (reader->reader_private_free) { reader->reader_private_free(reader->reader_private); } -- cgit v1.2.3 From fec0da9cbf6b357e046cac4295185610399dcbb8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 6 Jun 2014 21:30:32 +0200 Subject: libcacard: Clean up dead stores before g_free() Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- libcacard/vcard.c | 4 ---- libcacard/vreader.c | 2 -- 2 files changed, 6 deletions(-) diff --git a/libcacard/vcard.c b/libcacard/vcard.c index bf342aaf6d..87ad5166a8 100644 --- a/libcacard/vcard.c +++ b/libcacard/vcard.c @@ -117,10 +117,8 @@ vcard_delete_applet(VCardApplet *applet) } if (applet->applet_private_free) { applet->applet_private_free(applet->applet_private); - applet->applet_private = NULL; } g_free(applet->aid); - applet->aid = NULL; g_free(applet); } @@ -174,8 +172,6 @@ vcard_free(VCard *vcard) } if (vcard->vcard_private_free) { (*vcard->vcard_private_free)(vcard->vcard_private); - vcard->vcard_private_free = 0; - vcard->vcard_private = 0; } for (current_applet = vcard->applet_list; current_applet; current_applet = next_applet) { diff --git a/libcacard/vreader.c b/libcacard/vreader.c index ffa05b6ca5..9f42f0fe21 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -343,8 +343,6 @@ vreader_list_delete(VReaderList *list) next_entry = vreader_list_get_next(current_entry); vreader_list_entry_delete(current_entry); } - list->head = NULL; - list->tail = NULL; g_free(list); } -- cgit v1.2.3 From 4380be0e997284159e634100d2f5ec87f944d74d Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Mon, 2 Jun 2014 20:16:55 +0800 Subject: migration: Plug memory leak in migrate-set-cache-size command We call g_free() after cache_fini() in migration_end(), but we don't call it after cache_fini() in xbzrle_cache_resize(), leaking the memory. cache_init() and cache_fini() are a pair. Since cache_init() allocates the cache, let cache_fini() free it. This plugs the leak. Signed-off-by: Chen Gang Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Michael Tokarev --- arch_init.c | 1 - page_cache.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index 9f1a174d3a..23044c1d12 100644 --- a/arch_init.c +++ b/arch_init.c @@ -739,7 +739,6 @@ static void migration_end(void) XBZRLE_cache_lock(); if (XBZRLE.cache) { cache_fini(XBZRLE.cache); - g_free(XBZRLE.cache); g_free(XBZRLE.encoded_buf); g_free(XBZRLE.current_buf); XBZRLE.cache = NULL; diff --git a/page_cache.c b/page_cache.c index b033681a93..89bb1ec3a0 100644 --- a/page_cache.c +++ b/page_cache.c @@ -109,6 +109,7 @@ void cache_fini(PageCache *cache) g_free(cache->page_cache); cache->page_cache = NULL; + g_free(cache); } static size_t cache_get_cache_pos(const PageCache *cache, -- cgit v1.2.3 From e2bb4ae74687c06a256d8058e340295c7a084fe4 Mon Sep 17 00:00:00 2001 From: Nicolas Owens Date: Sun, 8 Jun 2014 22:19:17 -0700 Subject: hw: vmware_vga: don't return cursorx when the driver asks for cursory register hello qemu-*@nongnu.org, this is my first contribution. apologies if something is incorrect. this patch fixes vmware_vga.c so that it actually returns the cursory register when asked for, instead of cursorx. Signed-off-by: Nicolas Owens Signed-off-by: Michael Tokarev --- hw/display/vmware_vga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 9ba47e6c63..ab54b6fc58 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -863,7 +863,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) break; case SVGA_REG_CURSOR_Y: - ret = s->cursor.x; + ret = s->cursor.y; break; case SVGA_REG_CURSOR_ON: -- cgit v1.2.3 From 1a2858995d283ddad4a745460d1cc770a9b93fc1 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Tue, 10 Jun 2014 19:56:27 +0400 Subject: virtio.c: fix error message Suggested-by: Peter Maydell Signed-off-by: Michael Tokarev --- hw/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3557c178f1..a07ae8ad91 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -440,7 +440,7 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr, len = sg[i].iov_len; sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write); if (sg[i].iov_base == NULL || len != sg[i].iov_len) { - error_report("virtio: trying to map MMIO memory"); + error_report("virtio: error trying to map MMIO memory"); exit(1); } } -- cgit v1.2.3