From d6c140a771d3be4ef677a3c3eeb7dbfa7fb30378 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Sat, 9 Aug 2014 16:05:51 +0200 Subject: apic: Fix reported DFR content IA-32 SDM, Figure 10-14: Bits 27:0 are reserved as 1. Fixes Jailhouse hypervisor start with in-kernel irqchips off. Signed-off-by: Jan Kiszka Signed-off-by: Michael Tokarev --- hw/intc/apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/intc/apic.c b/hw/intc/apic.c index ef19e5515c..03ff9e94f2 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -698,7 +698,7 @@ static uint32_t apic_mem_readl(void *opaque, hwaddr addr) val = s->log_dest << 24; break; case 0x0e: - val = s->dest_mode << 28; + val = (s->dest_mode << 28) | 0xfffffff; break; case 0x0f: val = s->spurious_vec; -- cgit v1.2.1 From ef9f7b587df5a896dc9f6d076f41a844db3d9761 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 11 Aug 2014 16:10:25 +0800 Subject: pci-host: update obsolete reference about piix_pci.c piix_pci.c has been renamed into piix.c at commit c0907c9e6417cb959dfd9ef6873221536ec91351 update the obsolete reference. Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- hw/isa/lpc_ich9.c | 2 +- hw/pci-host/pam.c | 2 +- hw/pci-host/q35.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'hw') diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index b846d81990..177023bcaf 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -7,7 +7,7 @@ * VA Linux Systems Japan K.K. * Copyright (C) 2012 Jason Baron * - * This is based on piix_pci.c, but heavily modified. + * This is based on piix.c, but heavily modified. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/hw/pci-host/pam.c b/hw/pci-host/pam.c index e1e95aabcd..6abee4fd55 100644 --- a/hw/pci-host/pam.c +++ b/hw/pci-host/pam.c @@ -6,7 +6,7 @@ * VA Linux Systems Japan K.K. * Copyright (c) 2012 Jason Baron * - * Split out from piix_pci.c + * Split out from piix.c * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index a0a3068dd5..37f228e77e 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -7,7 +7,7 @@ * VA Linux Systems Japan K.K. * Copyright (C) 2012 Jason Baron * - * This is based on piix_pci.c, but heavily modified. + * This is based on piix.c, but heavily modified. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal -- cgit v1.2.1 From 30dc600bbfe2c927440fd611d585d7a2acb42fbf Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 11 Aug 2014 16:10:26 +0800 Subject: pci-host: update uncorresponding description Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- hw/pci-host/pam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/pci-host/pam.c b/hw/pci-host/pam.c index 6abee4fd55..8272de3f28 100644 --- a/hw/pci-host/pam.c +++ b/hw/pci-host/pam.c @@ -1,5 +1,5 @@ /* - * QEMU i440FX/PIIX3 PCI Bridge Emulation + * QEMU Smram/pam logic implementation * * Copyright (c) 2006 Fabrice Bellard * Copyright (c) 2011 Isaku Yamahata -- cgit v1.2.1 From d0657b2aab6f2a342aae2897e41d10061a9a6992 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 11 Aug 2014 21:00:52 +0800 Subject: usb: don't use 'Yoda conditions' imitate nearby code about using '!value' or 'value == NULL' Signed-off-by: Gonglei Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/usb/dev-audio.c | 2 +- hw/usb/dev-mtp.c | 4 ++-- hw/usb/hcd-ehci.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'hw') diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index bfebfe90f3..7b9957b3c3 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -371,7 +371,7 @@ static void output_callback(void *opaque, int avail) return; } data = streambuf_get(&s->out.buf); - if (NULL == data) { + if (!data) { return; } AUD_write(s->out.voice, data, USBAUDIO_PACKET_SIZE); diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 384d4a5ac5..0820046906 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -832,7 +832,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c) return; } data_in = usb_mtp_get_object(s, c, o); - if (NULL == data_in) { + if (data_in == NULL) { usb_mtp_queue_result(s, RES_GENERAL_ERROR, c->trans, 0, 0, 0); return; @@ -851,7 +851,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c) return; } data_in = usb_mtp_get_partial_object(s, c, o); - if (NULL == data_in) { + if (data_in == NULL) { usb_mtp_queue_result(s, RES_GENERAL_ERROR, c->trans, 0, 0, 0); return; diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index a00a93c3eb..448e0073dd 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1596,7 +1596,7 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async) entry = ehci_get_fetch_addr(ehci, async); q = ehci_find_queue_by_qh(ehci, entry, async); - if (NULL == q) { + if (q == NULL) { q = ehci_alloc_queue(ehci, entry, async); } -- cgit v1.2.1 From 2ab5bf67b7c3fe20f1645dadddd28b1881a25c47 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 11 Aug 2014 21:00:53 +0800 Subject: audio: don't use 'Yoda conditions' imitate nearby code about using '!value' or 'value == NULL' Signed-off-by: Gonglei Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/audio/gus.c | 2 +- hw/audio/hda-codec.c | 3 ++- hw/audio/sb16.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'hw') diff --git a/hw/audio/gus.c b/hw/audio/gus.c index bba6840477..4a43ce7adf 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -212,7 +212,7 @@ static int GUS_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len) pos += copied; } - if (0 == ((mode >> 4) & 1)) { + if (((mode >> 4) & 1) == 0) { DMA_release_DREQ (s->emu.gusdma); } return dma_len; diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index cbcf521c5e..3c03ff5668 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -489,8 +489,9 @@ static int hda_audio_init(HDACodecDevice *hda, const struct desc_codec *desc) for (i = 0; i < a->desc->nnodes; i++) { node = a->desc->nodes + i; param = hda_codec_find_param(node, AC_PAR_AUDIO_WIDGET_CAP); - if (NULL == param) + if (param == NULL) { continue; + } type = (param->val & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; switch (type) { case AC_WID_AUD_OUT: diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 60c4b3b497..bda26d0123 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -928,7 +928,7 @@ static IO_WRITE_PROTO (dsp_write) /* if (s->highspeed) */ /* break; */ - if (0 == s->needed_bytes) { + if (s->needed_bytes == 0) { command (s, val); #if 0 if (0 == s->needed_bytes) { @@ -1212,7 +1212,7 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len) #endif if (till <= copy) { - if (0 == s->dma_auto) { + if (s->dma_auto == 0) { copy = till; } } @@ -1224,7 +1224,7 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len) if (s->left_till_irq <= 0) { s->mixer_regs[0x82] |= (nchan & 4) ? 2 : 1; qemu_irq_raise (s->pic); - if (0 == s->dma_auto) { + if (s->dma_auto == 0) { control (s, 0); speaker (s, 0); } -- cgit v1.2.1 From 337a3e5c7d3b5a5731f6e89f055e645ae6b9f40e Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 11 Aug 2014 21:00:54 +0800 Subject: isa-bus: don't use 'Yoda conditions' imitate nearby code about using '!value' or 'value == NULL' Signed-off-by: Gonglei Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/isa/isa-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index b28981bfde..cc85e538b1 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -50,7 +50,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io) fprintf(stderr, "Can't create a second ISA bus\n"); return NULL; } - if (NULL == dev) { + if (!dev) { dev = qdev_create(NULL, "isabus-bridge"); qdev_init_nofail(dev); } -- cgit v1.2.1 From f7472ca4053d43c32d675517c9159017ece5d7a9 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 11 Aug 2014 21:00:58 +0800 Subject: vmxnet3: don't use 'Yoda conditions' imitate nearby code about using '!value' or 'value == NULL' Signed-off-by: Gonglei Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/net/vmxnet3.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'hw') diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 77bea6f89f..588149d8b6 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1009,7 +1009,7 @@ vmxnet3_indicate_packet(VMXNET3State *s) vmxnet3_dump_rx_descr(&rxd); - if (0 != ready_rxcd_pa) { + if (ready_rxcd_pa != 0) { cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd)); } @@ -1020,7 +1020,7 @@ vmxnet3_indicate_packet(VMXNET3State *s) rxcd.gen = new_rxcd_gen; rxcd.rqID = RXQ_IDX + rx_ridx * s->rxq_num; - if (0 == bytes_left) { + if (bytes_left == 0) { vmxnet3_rx_update_descr(s->rx_pkt, &rxcd); } @@ -1038,16 +1038,16 @@ vmxnet3_indicate_packet(VMXNET3State *s) num_frags++; } - if (0 != ready_rxcd_pa) { + if (ready_rxcd_pa != 0) { rxcd.eop = 1; - rxcd.err = (0 != bytes_left); + rxcd.err = (bytes_left != 0); cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd)); /* Flush RX descriptor changes */ smp_wmb(); } - if (0 != new_rxcd_pa) { + if (new_rxcd_pa != 0) { vmxnet3_revert_rxc_descr(s, RXQ_IDX); } @@ -1190,8 +1190,8 @@ static void vmxnet3_update_mcast_filters(VMXNET3State *s) s->mcast_list_len = list_bytes / sizeof(s->mcast_list[0]); s->mcast_list = g_realloc(s->mcast_list, list_bytes); - if (NULL == s->mcast_list) { - if (0 == s->mcast_list_len) { + if (!s->mcast_list) { + if (s->mcast_list_len == 0) { VMW_CFPRN("Current multicast list is empty"); } else { VMW_ERPRN("Failed to allocate multicast list of %d elements", @@ -1667,7 +1667,7 @@ vmxnet3_io_bar1_write(void *opaque, * memory address. We save it to temp variable and set the * shared address only after we get the high part */ - if (0 == val) { + if (val == 0) { s->device_active = false; } s->temp_shared_guest_driver_memory = val; -- cgit v1.2.1 From c75f3c041aff0d6192049860a8f7b4db40ec0603 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Fri, 15 Aug 2014 01:14:36 -0700 Subject: ssi: xilinx_spi: Initialise CS GPIOs as NULL To properly indicate they are unconnected. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/ssi/xilinx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c index 207f47a1c0..620573caca 100644 --- a/hw/ssi/xilinx_spi.c +++ b/hw/ssi/xilinx_spi.c @@ -329,7 +329,7 @@ static int xilinx_spi_init(SysBusDevice *sbd) s->spi = ssi_create_bus(dev, "spi"); sysbus_init_irq(sbd, &s->irq); - s->cs_lines = g_new(qemu_irq, s->num_cs); + s->cs_lines = g_new0(qemu_irq, s->num_cs); ssi_auto_connect_slaves(dev, s->cs_lines, s->spi); for (i = 0; i < s->num_cs; ++i) { sysbus_init_irq(sbd, &s->cs_lines[i]); -- cgit v1.2.1 From aa2ac1dac3d27b412e2dba4cde38724446751344 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Fri, 15 Aug 2014 01:15:10 -0700 Subject: ppc: convert g_new(qemu_irq usages to g_new0 To indicate the IRQs are initially disconnected. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/intc/openpic.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'hw') diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index 028529e13d..7d1f3b9497 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -1627,7 +1627,7 @@ static void openpic_realize(DeviceState *dev, Error **errp) } for (i = 0; i < opp->nb_cpus; i++) { - opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB); + opp->dst[i].irqs = g_new0(qemu_irq, OPENPIC_OUTPUT_NB); for (j = 0; j < OPENPIC_OUTPUT_NB; j++) { sysbus_init_irq(d, &opp->dst[i].irqs[j]); } diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 1a5b30d3ce..16c85efab5 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -583,7 +583,7 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr, SysBusDevice *s; int i; - mpic = g_new(qemu_irq, 256); + mpic = g_new0(qemu_irq, 256); if (kvm_enabled()) { QemuOpts *machine_opts = qemu_get_machine_opts(); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index f5bccd2ad5..1ec4bb490b 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -346,7 +346,7 @@ static void ppc_core99_init(MachineState *machine) } } - pic = g_new(qemu_irq, 64); + pic = g_new0(qemu_irq, 64); dev = qdev_create(NULL, TYPE_OPENPIC); qdev_prop_set_uint32(dev, "model", OPENPIC_MODEL_RAVEN); -- cgit v1.2.1 From 8945c7f75419a8191f3e99b341f1a485b48af766 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Fri, 15 Aug 2014 01:15:44 -0700 Subject: intc: i8259: Convert Array allocation to g_new0 To be more array friendly and to indicate the IRQs are initially disconnected. Signed-off-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/intc/i8259.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index d0b0c52b97..a563b82c4e 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -472,7 +472,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq) ISADevice *isadev; int i; - irq_set = g_malloc(ISA_NUM_IRQS * sizeof(qemu_irq)); + irq_set = g_new0(qemu_irq, ISA_NUM_IRQS); isadev = i8259_init_chip(TYPE_I8259, bus, true); dev = DEVICE(isadev); -- cgit v1.2.1 From 2c145d7a73206afc576fea86514e892e11481dab Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Thu, 14 Aug 2014 15:29:12 +0800 Subject: l2cap: fix access to freed memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pointer 'ch' will be used in function 'l2cap_channel_open_req_msg' after it was previously freed in 'l2cap_channel_open'. Assigned it to NULL after it is freed. Reviewed-by: Alex Bennée Reviewed-by: Michael S. Tsirkin Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- hw/bt/l2cap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/bt/l2cap.c b/hw/bt/l2cap.c index 2301d6f87f..591e047781 100644 --- a/hw/bt/l2cap.c +++ b/hw/bt/l2cap.c @@ -429,7 +429,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap, status = L2CAP_CS_NO_INFO; } else { g_free(ch); - + ch = NULL; result = L2CAP_CR_NO_MEM; status = L2CAP_CS_NO_INFO; } -- cgit v1.2.1 From 5edbdbcdf882e4220adc7dbf433351077cd1fbbc Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Thu, 14 Aug 2014 15:29:15 +0800 Subject: ivshmem: check the value returned by fstat() The function fstat() may fail, so check its return value. Acked-by: Levente Kurusa Reviewed-by: Michael S. Tsirkin Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- hw/misc/ivshmem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 768e5288bc..2be4b86726 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -324,7 +324,11 @@ static int check_shm_size(IVShmemState *s, int fd) { struct stat buf; - fstat(fd, &buf); + if (fstat(fd, &buf) < 0) { + fprintf(stderr, "ivshmem: exiting: fstat on fd %d failed: %s\n", + fd, strerror(errno)); + return -1; + } if (s->ivshmem_size > buf.st_size) { fprintf(stderr, -- cgit v1.2.1