[Qemu-devel] [Bug 1278977] Re: qemu-system-sparc64 crash when initializing disk

2014-08-24 Thread Mark Cave-Ayland
HI Waldemar,

Glad that you now have something that works for you.

I've tried to reproduce your virtio hang this morning with multiple 100%
CPU and "find / -name 'foo'" processes running but I can't seem to get
virtio to hang on my system here.

Since this is the second report I've had of this problem, I'd be
interested to try and get a backtrace from a debug-enabled qemu build if
possible. Would you be willing to contact me directly with a temporary
account on your system so I can try and get a backtrace from a hung
qemu?


Many thanks,

Mark.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1278977

Title:
  qemu-system-sparc64 crash when initializing disk

Status in QEMU:
  New

Bug description:
  Hi,

  I try to boot up Linux for SPARC64 in qemu-system-sparc64 (qemu 1.7.0). A 
self compiled kernel with initramfs as piggyback boots up fine.
  (http://www.openadk.org/qemu-sparc64-initramfs-piggyback-kernel)
  When trying to use a disk image I get following trace:
  qemu-system-sparc64 -nographic -kernel 
/home/wbx/openadk/bin/qemu_sparc64_eglibc/qemu-sparc64-archive-kernel 
qemu-sparc64.img -append "root=/dev/sda1" 
  [   43.520705] ata1.00: ATA-7: QEMU HARDDISK, 1.7.0, max UDMA/100
  [   43.792734] ata1.00: 1048576 sectors, multi 16: LBA48 
  [   44.100768] ata1.00: configured for UDMA/33
  [   44.316791] scsi 0:0:0:0: Direct-Access ATA  QEMU HARDDISK1.7. 
PQ: 0 ANSI: 5
  [   44.724835] sd 0:0:0:0: [sda] 1048576 512-byte logical blocks: (536 MB/512 
MiB)
  [   45.172883] ata2.00: ATAPI: QEMU DVD-ROM, 1.7.0, max UDMA/100
  [   45.508920] ata2.00: configured for UDMA/33
  [   45.752946] scsi 1:0:0:0: CD-ROMQEMU QEMU DVD-ROM 1.7. 
PQ: 0 ANSI: 5
  [   46.309006] sd 0:0:0:0: [sda] Write Protect is off
  [   46.737053] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, 
doesn't support DPO or FUA
  qemu: fatal: Trap 0x0032 while trap level (5) >= MAXTL (5), Error state
  pc: 004055dc  npc: 004055e0
  %g0-3:  0200 f80006a3f170 0200
  %g4-7: f5000464  f80006a3c000 f500
  %o0-3: f80006a10140 f80006a10160 f80006900010 06a6c000 
  %o4-7: 0002 03e7 f80006a3e1c1 00593988 
  %l0-3:  00ff 2000 0001 
  %l4-7:  f80006a0d980 0001 c0004000 
  %i0-3:  ff00 0001 0001 
  %i4-7: f80006a11d50 f80006a1 f80006a3e271 00582444 
  %f00:     
  %f08:     
  %f16:  076e072707740720 0773077507700770 076f077207740720 07440750074f0720
  %f24:  076f077207200746 0755074107200720 0720072007200720 0720072007200720
  %f32:  0720072007200720 0720072007200720 0720072007200720 0720072007200720
  %f40:  0720072007200720 0720072007200720 0720072007200720 0720072007200720
  %f48:  0720072007200720 0755074107200720 0720072007200720 0720072007200720
  %f56:  0720072007200720 0720072007200720 0720072007200720 0720072007200720
  pstate: 0015 ccr: 00 (icc:  xcc: ) asi: 80 tl: 5 pil: e
  cansave: 4 canrestore: 2 otherwin: 0 wstate: 0 cleanwin: 7 cwp: 4
  fsr:  y:  fprs: 

  Aborted

  Same happens when starting up Debian/wheezy 7.4 for sparc64:
  qemu-system-sparc64 -nographic -kernel vmlinuz -initrd initrd.gz qemu.img
  [  102.943129] eth0: RealTek RTL-8029 found at 0x1fe02000400, IRQ 6, 
52:54:00:12:34:56.
  [  105.143367] scsi0 : pata_cmd64x
  [  105.667424] scsi1 : pata_cmd64x
  [  106.003460] ata1: PATA max UDMA/33 cmd 0x1fe02000500 ctl 0x1fe02000580 
bmdma 0x1fe02000700 irq 7
  [  106.871554] ata2: PATA max UDMA/33 cmd 0x1fe02000600 ctl 0x1fe02000680 
bmdma 0x1fe02000708 irq 7
  [  108.247703] ata1.00: ATA-7: QEMU HARDDISK, 1.7.0, max UDMA/100
  [  108.775760] ata1.00: 1048576 sectors, multi 16: LBA48 
  [  109.399827] ata1.00: configured for UDMA/33
  [  109.815872] scsi 0:0:0:0: Direct-Access ATA  QEMU HARDDISK1.7. 
PQ: 0 ANSI: 5
  [  111.004001] ata2.00: ATAPI: QEMU DVD-ROM, 1.7.0, max UDMA/100
  [  111.608066] ata2.00: configured for UDMA/33
  [  112.040113] scsi 1:0:0:0: CD-ROMQEMU QEMU DVD-ROM 1.7. 
PQ: 0 ANSI: 5
  [  114.344362] sd 0:0:0:0: [sda] 1048576 512-byte logical blocks: (536 MB/512 
MiB)
  qemu: fatal: Trap 0x0032 while trap level (5) >= MAXTL (5), Error state
  pc: 004055bc  npc: 004055c0
  %g0-3:  0200 f80007e6bd10 0200
  %g4-7: f5000464  f80005d34000 f500
  %o0-3: f80005f68148 f80005f68180 000c 0001 
  %o4-7: f80005d4b889 000

Re: [Qemu-devel] [PATCH v2 for-2.1] po: Fix Makefile rules for in-tree builds without configuration

2014-08-24 Thread Michael Tokarev
Applied to -trivial, thank you!

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH] linux-user: fix file descriptor leaks

2014-08-24 Thread Michael Tokarev
Applied to -trivial, thank you!

/mjt



[Qemu-devel] [Bug 1359243] Re: [BSOD 0xc000000d] Can't boot windows with qemu

2014-08-24 Thread Michael Tokarev
This might be due to old(ish) seabios you're using.  It should be 1.7.5
version, not 1.7.4.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1359243

Title:
  [BSOD 0xc00d] Can't boot windows with qemu

Status in QEMU:
  New

Bug description:
  Upgrading to latest qemu I found my VM unusable: tried windows
  8.1/7/WinPE with the same result: BSOD on boot with code error:
  0xc00d (please, look at screenshot in attachment).

  Command running VM:
  sudo qemu-system-x86_64 -m 4096 /var/lib/libvirt/images/win8.img (also with 
'-machine accel=kvm')
  Linux: 3.15.10 x86_64
  Kubuntu 14.04.1
  qemu: 2.1.1 (from ppa:jacob/virtualisation)
  qemu-kvm: 2.1.1 (from ppa:jacob/virtualisation)
  CPU: Intel C2Q9450

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1359243/+subscriptions



Re: [Qemu-devel] [Qemu-trivial] [PATCH] libdecnumber: Fix warnings from smatch (missing static, boolean operations)

2014-08-24 Thread Michael Tokarev
Applied to -trivial, thank you!

But I've a small concern - should we really do this on "external" sources,
and divirge from upstream needlessly?

Thanks,

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH] IDE: MMIO IDE device control should be little endian

2014-08-24 Thread Michael Tokarev
22.08.2014 12:52, Valentin Manea wrote:
> Set the IDE MMIO memory type to little endian. The ATA specs identify
> words part of the control commands encoded as little endian.
> While this has no impact on little endian systems, it's required for big
> endian systems(eg OpenRisc).

While the patch itself is simple, I'm not sure it is "trivial enough".
And you didn't Cc neither qemu-devel@ nor the IDE subsystem "odd fixer"
maintainers (kwolf@ and stefanha@).  I'm not applying this for now to
trivial tree.

Thanks,

/mjt

> Signed-off-by: Valentin Manea 
> ---
>  hw/ide/mmio.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
> index 01c1d0e..334c8cc 100644
> --- a/hw/ide/mmio.c
> +++ b/hw/ide/mmio.c
> @@ -82,7 +82,7 @@ static void mmio_ide_write(void *opaque, hwaddr addr,
>  static const MemoryRegionOps mmio_ide_ops = {
>  .read = mmio_ide_read,
>  .write = mmio_ide_write,
> -.endianness = DEVICE_NATIVE_ENDIAN,
> +.endianness = DEVICE_LITTLE_ENDIAN,
>  };
> 
>  static uint64_t mmio_ide_status_read(void *opaque, hwaddr addr,
> @@ -102,7 +102,7 @@ static void mmio_ide_cmd_write(void *opaque, hwaddr
> addr,
>  static const MemoryRegionOps mmio_ide_cs_ops = {
>  .read = mmio_ide_status_read,
>  .write = mmio_ide_cmd_write,
> -.endianness = DEVICE_NATIVE_ENDIAN,
> +.endianness = DEVICE_LITTLE_ENDIAN,
>  };
> 
>  static const VMStateDescription vmstate_ide_mmio = {
> 




Re: [Qemu-devel] [Qemu-trivial] [PATCH] libdecnumber: Fix warnings from smatch (missing static, boolean operations)

2014-08-24 Thread Stefan Weil

Am 24.08.2014 11:21, schrieb Michael Tokarev:

Applied to -trivial, thank you!

But I've a small concern - should we really do this on "external" sources,
and divirge from upstream needlessly?

Thanks,

/mjt


In general, I agree. In this case, the code was part of gcc, and newer 
versions of gcc use GPL 3 which is incompatible with QEMU, so I assume 
that the code in QEMU is no longer available from a maintained upstream.


Stefan





Re: [Qemu-devel] [PATCH v4 0/8] intel-iommu: introduce Intel IOMMU (VT-d) emulation to q35 chipset

2014-08-24 Thread Michael S. Tsirkin
On Sat, Aug 16, 2014 at 01:55:36PM +0800, Le Tan wrote:
> Hi,
> 
> These patches are intended to introduce Intel IOMMU (VT-d) emulation to q35
> chipset. The major job in these patches is to add support for emulating Intel
> IOMMU according to the VT-d specification, including basic responses to CSRs
> accesses, the logics of DMAR (DMA remapping) and DMA memory address
> translations.

I applied these patches, thanks!

> Features implemented for now are:
> 1. Response to important CSRs accesses;
> 2. DMAR (DMA remapping) without PASID support;
> 3. Primary fault logging;
> 4. Support both register-based and queued invalidation for IOTLB and context
>cache invalidation;
> 5. Add DMAR table to ACPI tables to expose VT-d to BIOS;
> 6. Add "-machine iommu=on|off" option to enable/disable VT-d;
> 7. Only one DMAR unit for all the devices of PCI Segment 0;
> 8. Context-cache and IOTLB.
> 
> Testing:
> 1. L1 guest with Linux with intel_iommu=on can interact with VT-d and boot
> smoothly, and there exists information about VT-d in the log of kernel;
> 2. Run L1 with VT-d, L2 guest with Linux can boot smoothly withou PCI device
> passthrough;
> 3. Run L1 with VT-d and "-soundhw ac97 (QEMU_AUDIO_DRV=alsa)", then assign the
> sound card to L2; L2 can boot smoothly with legacy PCI assignment and I can
> hear the music played in L2 from the host speakers;
> 4. Jailhouse hypervisor can run smoothly (tested by Jan).
> 5. Run L1 with VT-d and e1000 network card, then assign e1000 to L2; L2 will 
> be
> STUCK when booting. This still remains unsolved now. As far as I know, I 
> suppose
> that the L2 crashes when doing e1000_probe(). The QEMU of L1 will dump
> something with "KVM: entry failed, hardware error 0x0", and the KVM of host
> will print "nested_vmx_exit_handled failed vm entry 7". Unlike assigning the
> sound card, after being assigned to L2, there is no translation entry of e1000
> through VT-d, which I think means that e1000 doesn't issue any DMA access 
> during
> the boot of L2. Sometimes the kernel of L2 will print "divide error" during
> booting. Maybe it results from the lack of reset mechanism.
> 6. VFIO is tested and is similar to legacy pci assignment.
> 
> TODO:
> 1. Fix the bug of legacy PCI assignment;
> 2. Add unit test for DMAR ACPI table;
> 3. Add support for PCIE-to-PCIE bridge.
> 
> Changes since v3:
> *address reviewing suggestions given by Jan and Michael
> -implement Context-cache and IOTLB
> -remove 'inline' keyword from most functions
> -rename all the functions with prefix vtd_
> -clean up constant definitions
> 
> Changes since v2:
> *address reviewing suggestions given by Jan
> -add support for primary fault logging
> -add support for queued invalidation
> 
> Changes since v1:
> *address reviewing suggestions given by Michael, Paolo, Stefan and Jan
> -split intel_iommu.h to include/hw/i386/intel_iommu.h and
>  hw/i386/intel_iommu_internal.h
> -change the copyright information
> -change D() to VTD_DPRINTF()
> -remove dead code
> -rename constant definitions with consistent prefix VTD_
> -rename some struct definitions according to QEMU standard
> -rename some CSRs access functions
> -use endian-save functions to access CSRs
> -change machine option to "iommu=on|off"
> 
> Thanks very much!
> 
> Git trees:
> https://github.com/tamlok/qemu
> 
> Le Tan (8):
>   iommu: add is_write as a parameter to the translate function of
> MemoryRegionIOMMUOps
>   intel-iommu: introduce Intel IOMMU (VT-d) emulation
>   intel-iommu: add DMAR table to ACPI tables
>   intel-iommu: add Intel IOMMU emulation to q35 and add a machine option
> "iommu" as a switch
>   intel-iommu: fix coding style issues around in q35.c and machine.c
>   intel-iommu: add supports for queued invalidation interface
>   intel-iommu: add context-cache to cache context-entry
>   intel-iommu: add IOTLB using hash table
> 
>  exec.c |2 +-
>  hw/alpha/typhoon.c |3 +-
>  hw/core/machine.c  |   27 +-
>  hw/i386/Makefile.objs  |1 +
>  hw/i386/acpi-build.c   |   39 +
>  hw/i386/acpi-defs.h|   40 +
>  hw/i386/intel_iommu.c  | 1963 
> 
>  hw/i386/intel_iommu_internal.h |  389 
>  hw/pci-host/apb.c  |3 +-
>  hw/pci-host/q35.c  |   58 +-
>  hw/ppc/spapr_iommu.c   |3 +-
>  include/exec/memory.h  |2 +-
>  include/hw/boards.h|1 +
>  include/hw/i386/intel_iommu.h  |  120 +++
>  include/hw/pci-host/q35.h  |2 +
>  qemu-options.hx|5 +-
>  vl.c   |4 +
>  17 files changed, 2648 insertions(+), 14 deletions(-)
>  create mode 100644 hw/i386/intel_iommu.c
>  create mode 100644 hw/i386/intel_iommu_internal.h
>  create mode 100644 include/hw/i386/intel_iommu.h
> 
> -- 
> 1.9.1



Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

2014-08-24 Thread Michael S. Tsirkin
On Fri, Aug 22, 2014 at 09:06:20AM +0800, Chen, Tiejun wrote:
> On 2014/8/22 0:16, Konrad Rzeszutek Wilk wrote:
> >On Thu, Aug 21, 2014 at 09:28:28AM +0800, Tiejun Chen wrote:
> >>Currenjly this ISA bridge should be fixed at 1f.0, and pass the
> >
> >Currently
> 
> Fixed.
> 
> >
> >>real vendor/device ids as the driver expect.
> >
> >Could you add a bit more description to this patch please? Explain
> >the rationale, etc.
> 
> So rephrase as follows:
> 
> xen:i386:pc_piix: create isa bridge specific to IGD passthrough
> 
> Currently IGD drivers always need to access PCH by 1f.0,

OK

> and
> identify PCH type with its own real vendor/device ids. This type
> value help driver initialize correctly.

instead: PCH vendor/device id is used to identify the card.

> >>
> >>Signed-off-by: Tiejun Chen 
> >>---
> >>  hw/i386/pc_piix.c | 24 +++-
> >>  1 file changed, 23 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> >>index 7710724..b131fa3 100644
> >>--- a/hw/i386/pc_piix.c
> >>+++ b/hw/i386/pc_piix.c
> >>@@ -50,7 +50,8 @@
> >>  #include "cpu.h"
> >>  #include "qemu/error-report.h"
> >>  #ifdef CONFIG_XEN
> >>-#  include 
> >>+#include 
> >>+#include 
> >>  #endif
> >>
> >>  #define MAX_IDE_BUS 2
> >>@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
> >>  }
> >>  }
> >>
> >>+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
> >>+{
> >>+struct PCIDevice *dev;
> >>+XenHostPCIDevice hdev;
> >>+int r = 0;
> >>+
> >>+/* This shoudl be fixed at 1f.0 then pass vendor/device ids.
> >
> >should
> >
> >However I would remove the comment as it does not add anything extra
> >to the function. It is pretty clear what it is doing.
> >
> >What would help is if you said:
> >
> >Must be fixed at 1f.0 because .. bla blah
> 
> Like the patch description, so what about this,
> 
> /* Currently IGD drivers always need to access PCH by 1f.0, and
>  * identify PCH type with its own real vendor/device ids.
>  */
> 
> Thanks
> Tiejun
> 
> >
> >>+ */
> >>+dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
> >>+"xen-igd-passthrough-isa-bridge");
> >>+if (dev) {
> >>+r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
> >>+if (!r) {
> >>+pci_config_set_vendor_id(dev->config, hdev.vendor_id);
> >>+pci_config_set_device_id(dev->config, hdev.device_id);

Can you, instead, implement the reverse logic, probing
the card and supplying the correct device id for PCH?

> >>+} else
> >>+fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge 
> >>failed\n");
> >>+}
> >>+}
> >>+
> >>  static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
> >>  {
> >>  PCIBus *bus;
> >>@@ -472,6 +493,7 @@ static void 
> >>xen_igd_passthrough_pc_hvm_init(MachineState *machine)
> >>  bus = pci_find_primary_bus();
> >>  if (bus != NULL) {
> >>  pci_create_simple(bus, -1, "xen-platform");
> >>+xen_igd_passthrough_isa_bridge_create(bus);
> >>  }
> >>  }
> >>  #endif
> >>--
> >>1.9.1
> >>
> >>
> >>___
> >>Xen-devel mailing list
> >>xen-de...@lists.xen.org
> >>http://lists.xen.org/xen-devel
> >



Re: [Qemu-devel] [PATCH RESEND 0/2] Fix leaks on object_property_add_str() setters

2014-08-24 Thread Michael S. Tsirkin

Are these appropriate for 2.1.1?
Add Cc stable?

On Fri, Aug 22, 2014 at 04:35:24PM -0300, Eduardo Habkost wrote:
> Ping? Who can apply these?
> 
> On Wed, Aug 06, 2014 at 03:18:19PM -0300, Eduardo Habkost wrote:
> > Resending two patches from the previous series which were not applied yet.
> > 
> > 
> > Eduardo Habkost (2):
> >   rng-egd: Free old chr_name value before setting new one
> >   hw/machine: Free old values of string properties
> > 
> >  backends/rng-egd.c | 1 +
> >  hw/core/machine.c  | 8 
> >  2 files changed, 9 insertions(+)
> > 
> > -- 
> > 1.9.3
> > 
> > 
> 
> -- 
> Eduardo



Re: [Qemu-devel] [PATCH] vmxnet3: Pad short frames to minimum size (60 bytes)

2014-08-24 Thread Michael Tokarev
20.08.2014 16:27, Ben Draper wrote:
> When running VMware ESXi under qemu-kvm the guest discards frames
> that are too short. Short ARP Requests will be dropped, this prevents
> guests on the same bridge as VMware ESXi from communicating. This patch
> simply adds the padding on the network device itself.

I'm not sure it is "trivial enough", so to say.  Do we have a maintainer
for vmxnet?  It's been written and updated several times by vmware (Daynix)
people, maybe they can comment on this somehow?  I mean, if we don't have
a maintainer for this device, it is okay to go to -trivial, but maybe it's
a good idea to try to reach the author(s) first?  (Adding Cc).

Especially since this change is only required in certain cases, not
generally.

Thanks,

/mjt

> Signed-off-by: Ben Draper 
> ---
>  hw/net/vmxnet3.c |   10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
> index 791321f..f246fa1 100644
> --- a/hw/net/vmxnet3.c
> +++ b/hw/net/vmxnet3.c
> @@ -34,6 +34,7 @@
>  
>  #define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1
>  #define VMXNET3_MSIX_BAR_SIZE 0x2000
> +#define MIN_BUF_SIZE 60
>  
>  #define VMXNET3_BAR0_IDX  (0)
>  #define VMXNET3_BAR1_IDX  (1)
> @@ -1871,12 +1872,21 @@ vmxnet3_receive(NetClientState *nc, const uint8_t 
> *buf, size_t size)
>  {
>  VMXNET3State *s = qemu_get_nic_opaque(nc);
>  size_t bytes_indicated;
> +uint8_t min_buf[MIN_BUF_SIZE];
>  
>  if (!vmxnet3_can_receive(nc)) {
>  VMW_PKPRN("Cannot receive now");
>  return -1;
>  }
>  
> +/* Pad to minimum Ethernet frame length */
> +if (size < sizeof(min_buf)) {
> +memcpy(min_buf, buf, size);
> +memset(&min_buf[size], 0, sizeof(min_buf) - size);
> +buf = min_buf;
> +size = sizeof(min_buf);
> +}
> +
>  if (s->peer_has_vhdr) {
>  vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
>  buf += sizeof(struct virtio_net_hdr);
> 




Re: [Qemu-devel] [PATCH] vmxnet3: Pad short frames to minimum size (60 bytes)

2014-08-24 Thread Dmitry Fleytman

On Aug 24, 2014, at 15:06 PM, Michael Tokarev  wrote:

> 20.08.2014 16:27, Ben Draper wrote:
>> When running VMware ESXi under qemu-kvm the guest discards frames
>> that are too short. Short ARP Requests will be dropped, this prevents
>> guests on the same bridge as VMware ESXi from communicating. This patch
>> simply adds the padding on the network device itself.
> 
> I'm not sure it is "trivial enough", so to say.  Do we have a maintainer
> for vmxnet?  It's been written and updated several times by vmware (Daynix)
> people, maybe they can comment on this somehow?  I mean, if we don't have
> a maintainer for this device, it is okay to go to -trivial, but maybe it's
> a good idea to try to reach the author(s) first?  (Adding Cc).
> 
> Especially since this change is only required in certain cases, not
> generally.


Hi Michael,

I’m the maintainer of vmxnet3/pvscsi devices in QEMU. Thanks for CC’ing me.

I think this patch is correct and needed.

As we saw a few times already on different operating systems,
vmware drivers expect short packets to be padded as required
by corresponding RFC. Therefore this patch fixes a real bug.

Reviewed-by: Dmitry Fleytman 

> 
> Thanks,
> 
> /mjt
> 
>> Signed-off-by: Ben Draper 
>> ---
>> hw/net/vmxnet3.c |   10 ++
>> 1 file changed, 10 insertions(+)
>> 
>> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
>> index 791321f..f246fa1 100644
>> --- a/hw/net/vmxnet3.c
>> +++ b/hw/net/vmxnet3.c
>> @@ -34,6 +34,7 @@
>> 
>> #define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1
>> #define VMXNET3_MSIX_BAR_SIZE 0x2000
>> +#define MIN_BUF_SIZE 60
>> 
>> #define VMXNET3_BAR0_IDX  (0)
>> #define VMXNET3_BAR1_IDX  (1)
>> @@ -1871,12 +1872,21 @@ vmxnet3_receive(NetClientState *nc, const uint8_t 
>> *buf, size_t size)
>> {
>> VMXNET3State *s = qemu_get_nic_opaque(nc);
>> size_t bytes_indicated;
>> +uint8_t min_buf[MIN_BUF_SIZE];
>> 
>> if (!vmxnet3_can_receive(nc)) {
>> VMW_PKPRN("Cannot receive now");
>> return -1;
>> }
>> 
>> +/* Pad to minimum Ethernet frame length */
>> +if (size < sizeof(min_buf)) {
>> +memcpy(min_buf, buf, size);
>> +memset(&min_buf[size], 0, sizeof(min_buf) - size);
>> +buf = min_buf;
>> +size = sizeof(min_buf);
>> +}
>> +
>> if (s->peer_has_vhdr) {
>> vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
>> buf += sizeof(struct virtio_net_hdr);
>> 
> 




Re: [Qemu-devel] [PATCH] vmxnet3: Pad short frames to minimum size (60 bytes)

2014-08-24 Thread Michael Tokarev
24.08.2014 16:28, Dmitry Fleytman wrote:

> Hi Michael,
> 
> I’m the maintainer of vmxnet3/pvscsi devices in QEMU. Thanks for CC’ing me.

Maybe you can add yourself to MAINTAINERS file as well? :)
I dunno if that's actually needed, but at least this should
stop "strain" patches like this to be sent to -trivial alone... ;)

> I think this patch is correct and needed.
> 
> As we saw a few times already on different operating systems,
> vmware drivers expect short packets to be padded as required
> by corresponding RFC. Therefore this patch fixes a real bug.

Okay, since there's no entry for vmxnet in MAINTAINERS, and with
your blessing, and since this is a rather specific device which
is not in common use, I'll apply it to -trivial, for now, unless
you want to pick it up and send a pull request for it.

Given your description, I think it should be Cc: qemu-stable@.

> Reviewed-by: Dmitry Fleytman 

Thanks,

/mjt



Re: [Qemu-devel] [question] which version of seabios is best for qemu-2.0.0?

2014-08-24 Thread Michael Tokarev
12.08.2014 15:14, Zhang Haoyu wrote:
>  Hi all,
> 
> We choose qemu-2.0.0 as distribution, and which version of seabios is best 
> for qemu-2.0.0 ?

qemu comes with bundled seabios, which works best with this version of qemu.
For qemu 2.0, you may use seabios 1.7.4 or 1.7.5 (while 2.1 requires at least 
1.7.5).

/mjt



Re: [Qemu-devel] [PATCH v1 5/5] Netduino: Add the Netduino Plus 2 Machine Model

2014-08-24 Thread Peter Crosthwaite
On Sun, Aug 24, 2014 at 10:14 AM, Alistair Francis  wrote:
> This patch adds the Netduion Plus 2 machine to QEMU.
>
> Signed-off-by: Alistair Francis 
> ---
>  hw/arm/Makefile.objs   |   2 +-
>  hw/arm/netduinoplus2.c | 202 
> +
>  2 files changed, 203 insertions(+), 1 deletion(-)
>  create mode 100644 hw/arm/netduinoplus2.c
>
> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
> index 6088e53..616f1ae 100644
> --- a/hw/arm/Makefile.objs
> +++ b/hw/arm/Makefile.objs
> @@ -2,7 +2,7 @@ obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o
>  obj-$(CONFIG_DIGIC) += digic_boards.o
>  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
>  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
> -obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
> +obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o 
> netduinoplus2.o
>
>  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
>  obj-$(CONFIG_DIGIC) += digic.o
> diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c
> new file mode 100644
> index 000..32acac5
> --- /dev/null
> +++ b/hw/arm/netduinoplus2.c
> @@ -0,0 +1,202 @@
> +/*
> + * Netduino Plus 2 Machine Model
> + *
> + * Copyright (c) 2014 Alistair Francis 
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "hw/sysbus.h"
> +#include "hw/ssi.h"
> +#include "hw/arm/arm.h"
> +#include "hw/devices.h"
> +#include "qemu/timer.h"
> +#include "net/net.h"
> +#include "elf.h"
> +#include "hw/loader.h"
> +#include "hw/boards.h"
> +#include "exec/address-spaces.h"
> +#include "qemu/error-report.h"
> +#include "sysemu/qtest.h"
> +
> +#define FLASH_BASE_ADDRESS 0x0800
> +#define FLASH_SIZE (1024 * 1024)
> +#define SRAM_BASE_ADDRESS 0x2000
> +#define SRAM_SIZE (192 * 1024)
> +
> +typedef struct ARMV7MResetArgs {
> +ARMCPU *cpu;
> +uint32_t reset_sp;
> +uint32_t reset_pc;
> +} ARMV7MResetArgs;
> +
> +static void armv7m_reset(void *opaque)
> +{
> +ARMV7MResetArgs *args = opaque;
> +
> +cpu_reset(CPU(args->cpu));
> +
> +args->cpu->env.regs[13] = args->reset_sp & 0xFFFC;
> +args->cpu->env.thumb = args->reset_pc & 1;
> +args->cpu->env.regs[15] = args->reset_pc & ~1;
> +}
> +
> +static void netduinoplus2_init(MachineState *machine)
> +{
> +static const uint32_t gpio_addr[] = { 0x4002, 0x40020400, 0x40020800,
> +0x40020C00, 0x40021000, 0x40021400, 0x40021800, 0x40021C00,
> +0x40022000, 0x40022400, 0x40022800 };
> +static const uint8_t gpio_letters[] = { 'a', 'b', 'c',
> +'d', 'e', 'f', 'g', 'h',
> +'i', 'j', 'k' };
> +static const uint32_t tim2_5_addr[] = { 0x4000, 0x4400,
> +0x4800, 0x4C00 };
> +static const uint32_t usart_addr[] = { 0x40011000, 0x40004400,
> +0x40004800, 0x40004C00, 0x40005000, 0x40011400, 0x40007800,
> +0x40007C00 };
> +const char *kernel_filename = machine->kernel_filename;
> +
> +static const int tim2_5_irq[] = {28, 29, 30, 50};
> +static const int usart_irq[] = {37, 38, 39, 52, 53, 71, 82, 83};
> +
> +MemoryRegion *address_space_mem = get_system_memory();

system_memory. address_space is a miselading name for a MR.

> +MemoryRegion *sram = g_new(MemoryRegion, 1);
> +MemoryRegion *flash = g_new(MemoryRegion, 1);
> +MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
> +MemoryRegion *hack = g_new(MemoryRegion, 1);
> +ARMV7MResetArgs reset_args;
> +
> +qemu_irq pic[96];
> +ARMCPU *cpu;
> +CPUARMState *env;
> +DeviceState *nvic;
> +DeviceState *gpio;
> +SysBusDevice *busdev;
> +
> +int image_size;
> +uint64_t entry;
> +uint64_t lowaddr;
> +int i;
> +int big_endian = 0;
> +
> +/* The Netduinio Plus 2 uses a Cortex-M4, while QEMU currently supports
> + * the Cortex-M3, 

Re: [Qemu-devel] [PATCH] vmxnet3: Pad short frames to minimum size (60 bytes)

2014-08-24 Thread Dmitry Fleytman

On Aug 24, 2014, at 16:10 PM, Michael Tokarev  wrote:

> 24.08.2014 16:28, Dmitry Fleytman wrote:
> 
>> Hi Michael,
>> 
>> I’m the maintainer of vmxnet3/pvscsi devices in QEMU. Thanks for CC’ing me.
> 
> Maybe you can add yourself to MAINTAINERS file as well? :)

Yes, this should be done.
How we do this? Should I send a patch for MAINTAINETRS?


> I dunno if that's actually needed, but at least this should
> stop "strain" patches like this to be sent to -trivial alone... ;)
> 
>> I think this patch is correct and needed.
>> 
>> As we saw a few times already on different operating systems,
>> vmware drivers expect short packets to be padded as required
>> by corresponding RFC. Therefore this patch fixes a real bug.
> 
> Okay, since there's no entry for vmxnet in MAINTAINERS, and with
> your blessing, and since this is a rather specific device which
> is not in common use, I'll apply it to -trivial, for now, unless
> you want to pick it up and send a pull request for it.


-trivial is good enough for this patch.

> 
> Given your description, I think it should be Cc: qemu-stable@.
> 
>> Reviewed-by: Dmitry Fleytman 
> 
> Thanks,
> 
> /mjt




[Qemu-devel] [PULL 09/11] linux-user: fix file descriptor leaks

2014-08-24 Thread Michael Tokarev
From: zhanghailiang 

Handle variable "fd_orig" going out of scope leaks the handle.

Signed-off-by: zhanghailiang 
Reviewed-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 linux-user/syscall.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7ff7c21..8fe9df7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5167,6 +5167,7 @@ static int open_self_cmdline(void *cpu_env, int fd)
 
 if (word_skipped) {
 if (write(fd, cp_buf, nb_read) != nb_read) {
+close(fd_orig);
 return -1;
 }
 }
-- 
1.7.10.4




[Qemu-devel] [PULL 03/11] tests/bios-tables-test: check the value returned by fopen()

2014-08-24 Thread Michael Tokarev
From: zhanghailiang 

The function fopen() may fail, so check its return value.

Signed-off-by: zhanghailiang 
Signed-off-by: Li Liu 
Reviewed-by: Alex Bennée 
Signed-off-by: Michael Tokarev 
---
 tests/bios-tables-test.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 045eb27..602932b 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -790,6 +790,11 @@ int main(int argc, char *argv[])
 const char *arch = qtest_get_arch();
 FILE *f = fopen(disk, "w");
 int ret;
+
+if (!f) {
+fprintf(stderr, "Couldn't open \"%s\": %s", disk, strerror(errno));
+return 1;
+}
 fwrite(boot_sector, 1, sizeof boot_sector, f);
 fclose(f);
 
-- 
1.7.10.4




[Qemu-devel] [PULL 06/11] configure: no need to mkdir QMP

2014-08-24 Thread Michael Tokarev
From: Liming Wang 

commit 7537fe04 QMP: QMP/ -> docs/qmp/

Above commit has moved last QMP files to docs/qmp and it's not necessary
to create QMP directory. So remove it from configure.

Signed-off-by: Liming Wang 
Signed-off-by: Michael Tokarev 
---
 configure |4 
 1 file changed, 4 deletions(-)

diff --git a/configure b/configure
index c4e47e1..2063cf6 100755
--- a/configure
+++ b/configure
@@ -5372,10 +5372,6 @@ for rom in seabios vgabios ; do
 echo "LD=$ld" >> $config_mak
 done
 
-if test "$docs" = "yes" ; then
-  mkdir -p QMP
-fi
-
 # set up qemu-iotests in this build directory
 iotests_common_env="tests/qemu-iotests/common.env"
 iotests_check="tests/qemu-iotests/check"
-- 
1.7.10.4




[Qemu-devel] [PULL 10/11] libdecnumber: Fix warnings from smatch (missing static, boolean operations)

2014-08-24 Thread Michael Tokarev
From: Stefan Weil 

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 libdecnumber/decNumber.c |   21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index a30632f..58211e7 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -5275,8 +5275,8 @@ static decNumber * decMultiplyOp(decNumber *res, const 
decNumber *lhs,
 /* 4. The working precisions for the static buffers are twice the */
 /*obvious size to allow for calls from decNumberPower.   */
 /* -- */
-decNumber * decExpOp(decNumber *res, const decNumber *rhs,
-decContext *set, uInt *status) {
+static decNumber *decExpOp(decNumber *res, const decNumber *rhs,
+   decContext *set, uInt *status) {
   uInt ignore=0;  /* working status */
   Int h;  /* adjusted exponent for 0. */
   Int p;  /* working precision */
@@ -5563,7 +5563,8 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
 /*  where x is truncated (NB) into the range 10 through 99,  */
 /*  and then c = k>>2 and e = k&3.   */
 /* -- */
-const uShort LNnn[90]={9016,  8652,  8316,  8008,  7724,  7456, 7208,
+static const uShort LNnn[90] = {
+  9016,  8652,  8316,  8008,  7724,  7456,  7208,
   6972, 6748,  6540,  6340,  6148,  5968,  5792,  5628,  5464,  5312,
   5164, 5020,  4884,  4748,  4620,  4496,  4376,  4256,  4144,  4032,
  39233, 38181, 37157, 36157, 35181, 34229, 33297, 32389, 31501, 30629,
@@ -5635,8 +5636,8 @@ const uShort LNnn[90]={9016,  8652,  8316,  8008,  7724,  
7456,7208,
 /* 5. The static buffers are larger than might be expected to allow   */
 /*for calls from decNumberPower. */
 /* -- */
-decNumber * decLnOp(decNumber *res, const decNumber *rhs,
-   decContext *set, uInt *status) {
+static decNumber *decLnOp(decNumber *res, const decNumber *rhs,
+  decContext *set, uInt *status) {
   uInt ignore=0;  /* working status accumulator */
   uInt needbytes; /* for space calculations */
   Int residue;/* rounding residue */
@@ -6052,9 +6053,9 @@ static decNumber * decQuantizeOp(decNumber *res, const 
decNumber *lhs,
 /* The emphasis here is on speed for common cases, and avoiding  */
 /* coefficient comparison if possible.   */
 /* -- */
-decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
-const decNumber *rhs, decContext *set,
-Flag op, uInt *status) {
+static decNumber *decCompareOp(decNumber *res, const decNumber *lhs,
+   const decNumber *rhs, decContext *set,
+   Flag op, uInt *status) {
   #if DECSUBSET
   decNumber *alloclhs=NULL;   /* non-NULL if rounded lhs allocated */
   decNumber *allocrhs=NULL;   /* .., rhs */
@@ -6086,11 +6087,11 @@ decNumber * decCompareOp(decNumber *res, const 
decNumber *lhs,
 
 /* If total ordering then handle differing signs 'up front' */
 if (op==COMPTOTAL) {   /* total ordering */
-  if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) {
+  if (decNumberIsNegative(lhs) && !decNumberIsNegative(rhs)) {
result=-1;
break;
}
-  if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {
+  if (!decNumberIsNegative(lhs) && decNumberIsNegative(rhs)) {
result=+1;
break;
}
-- 
1.7.10.4




[Qemu-devel] [PULL 02/11] tcg: dump op count into qemu log

2014-08-24 Thread Michael Tokarev
From: zhanghailiang 

fopen() may fail and it does not check its return vaule here,
it is better to dump op count to the normal log file.

Signed-off-by: Li Liu 
Signed-off-by: zhanghailiang 
Signed-off-by: Michael Tokarev 
---
 tcg/tcg.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tcg/tcg.c b/tcg/tcg.c
index c068990..7a84b87 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2404,12 +2404,10 @@ static int64_t tcg_table_op_count[NB_OPS];
 static void dump_op_count(void)
 {
 int i;
-FILE *f;
-f = fopen("/tmp/op.log", "w");
+
 for(i = INDEX_op_end; i < NB_OPS; i++) {
-fprintf(f, "%s %" PRId64 "\n", tcg_op_defs[i].name, 
tcg_table_op_count[i]);
+qemu_log("%s %" PRId64 "\n", tcg_op_defs[i].name, 
tcg_table_op_count[i]);
 }
-fclose(f);
 }
 #endif
 
-- 
1.7.10.4




[Qemu-devel] [PULL 00/11] Trivial patches for 2014-08-24

2014-08-24 Thread Michael Tokarev
This time, we've a bunch of trivial stuff all over, including a series from
zhanghailiang, some minor fixes from Stefan Weil and Peter Crosthwaite,
and also a bugfix for a rare device - vmxnet3 - reviewed by the author.

Please consider pulling/applying.

Thanks,

/mjt

The following changes since commit 33886ebeec0c0ff6253a49253fae0db44c9ed0f3:

  Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging 
(2014-08-22 16:12:51 +0100)

are available in the git repository at:

  git://git.corpit.ru/qemu.git tags/trivial-patches-2014-08-24

for you to fetch changes up to 40a87c6c9b11ef9c14e0301f76abf0eb2582f08e:

  vmxnet3: Pad short frames to minimum size (60 bytes) (2014-08-24 17:11:08 
+0400)


trivial patches for 2014-08-24


Ben Draper (1):
  vmxnet3: Pad short frames to minimum size (60 bytes)

Liming Wang (1):
  configure: no need to mkdir QMP

Peter Crosthwaite (2):
  microblaze: ml605: Get rid of ddr_base variable
  dma: axidma: Variablise repeated s->streams[i] sub-expr

Stefan Weil (2):
  po: Fix Makefile rules for in-tree builds without configuration
  libdecnumber: Fix warnings from smatch (missing static, boolean 
operations)

zhanghailiang (5):
  util/path: Use the GLib memory allocation routines
  tcg: dump op count into qemu log
  tests/bios-tables-test: check the value returned by fopen()
  slirp/misc: Use the GLib memory allocation APIs
  linux-user: fix file descriptor leaks

 configure   |4 
 hw/dma/xilinx_axidma.c  |   10 ++
 hw/microblaze/petalogix_ml605_mmu.c |5 ++---
 hw/net/vmxnet3.c|   10 ++
 libdecnumber/decNumber.c|   21 +++--
 linux-user/syscall.c|1 +
 po/Makefile |7 +--
 slirp/misc.c|   20 +++-
 slirp/misc.h|4 
 slirp/slirp_config.h|3 ---
 tcg/tcg.c   |6 ++
 tests/bios-tables-test.c|5 +
 util/path.c |   10 +-
 13 files changed, 50 insertions(+), 56 deletions(-)



[Qemu-devel] [PATCH v2 0/4] q35: Minor fixes/enhancements to improve usability of root ports

2014-08-24 Thread Knut Omang
These are some minor fixes necessary to be able to operate ARI capable devices
in PCIe root ports on a q35 machine, using command line options like this:

 -device ioh3420,slot=0,id=pcie_port.0
 -device ioh3420,slot=1,id=pcie_port.1
 -device ,bus=pcie_port.0
 -device ,bus=pcie_port.1

Changes since v1:
  Removed "ioh3420: Provide a unique bus name and an interrupt mapping function"
as it is no longer necessary.
  Added rename of ari -> arifwd for clarity and removal of obsolete init 
function
  (separate patches)
  Use the renamed functions in ioh3420.

Knut Omang (4):
  pcie: Fix incorrect write to the ari capability next function field
  pcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*
  ioh3420: Remove obsoleted, unused ioh3420_init function
  ioh3420: Enable ARI forwarding

 hw/pci-bridge/ioh3420.c| 27 +++
 hw/pci-bridge/xio3130_downstream.c |  4 ++--
 hw/pci/pcie.c  | 13 +++--
 include/hw/pci/pcie.h  |  7 ---
 4 files changed, 16 insertions(+), 35 deletions(-)

-- 
1.9.0




[Qemu-devel] [PATCH v2 2/4] pcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*

2014-08-24 Thread Knut Omang
Rename helper functions to make a clearer distinction between
the PCIe capability/control register feature ARI forwarding and a
device that supports the ARI feature via an ARI extended PCIe capability.

Signed-off-by: Knut Omang 
---
 hw/pci-bridge/ioh3420.c|  1 +
 hw/pci-bridge/xio3130_downstream.c |  4 ++--
 hw/pci/pcie.c  | 11 ++-
 include/hw/pci/pcie.h  |  7 ---
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index 7cd87fc..aed2bf1 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -118,6 +118,7 @@ static int ioh3420_initfn(PCIDevice *d)
 if (rc < 0) {
 goto err_msi;
 }
+
 pcie_cap_deverr_init(d);
 pcie_cap_slot_init(d, s->slot);
 pcie_chassis_create(s->chassis);
diff --git a/hw/pci-bridge/xio3130_downstream.c 
b/hw/pci-bridge/xio3130_downstream.c
index 51f20d7..b3a6479 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -50,7 +50,7 @@ static void xio3130_downstream_reset(DeviceState *qdev)
 
 pcie_cap_deverr_reset(d);
 pcie_cap_slot_reset(d);
-pcie_cap_ari_reset(d);
+pcie_cap_arifwd_reset(d);
 pci_bridge_reset(qdev);
 }
 
@@ -91,7 +91,7 @@ static int xio3130_downstream_initfn(PCIDevice *d)
 if (rc < 0) {
 goto err_pcie_cap;
 }
-pcie_cap_ari_init(d);
+pcie_cap_arifwd_init(d);
 rc = pcie_aer_init(d, XIO3130_AER_OFFSET);
 if (rc < 0) {
 goto err;
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index de0e967..6cb6e0c 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -497,9 +497,10 @@ void pcie_cap_flr_write_config(PCIDevice *dev,
 }
 }
 
-/* Alternative Routing-ID Interpretation (ARI) */
-/* ari forwarding support for down stream port */
-void pcie_cap_ari_init(PCIDevice *dev)
+/* Alternative Routing-ID Interpretation (ARI)
+ * forwarding support for root and downstream ports 
+ */
+void pcie_cap_arifwd_init(PCIDevice *dev)
 {
 uint32_t pos = dev->exp.exp_cap;
 pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_DEVCAP2,
@@ -508,13 +509,13 @@ void pcie_cap_ari_init(PCIDevice *dev)
PCI_EXP_DEVCTL2_ARI);
 }
 
-void pcie_cap_ari_reset(PCIDevice *dev)
+void pcie_cap_arifwd_reset(PCIDevice *dev)
 {
 uint8_t *devctl2 = dev->config + dev->exp.exp_cap + PCI_EXP_DEVCTL2;
 pci_long_test_and_clear_mask(devctl2, PCI_EXP_DEVCTL2_ARI);
 }
 
-bool pcie_cap_is_ari_enabled(const PCIDevice *dev)
+bool pcie_cap_is_arifwd_enabled(const PCIDevice *dev)
 {
 if (!pci_is_express(dev)) {
 return false;
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index 7fe81f3..d139d58 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -103,9 +103,10 @@ void pcie_cap_flr_init(PCIDevice *dev);
 void pcie_cap_flr_write_config(PCIDevice *dev,
uint32_t addr, uint32_t val, int len);
 
-void pcie_cap_ari_init(PCIDevice *dev);
-void pcie_cap_ari_reset(PCIDevice *dev);
-bool pcie_cap_is_ari_enabled(const PCIDevice *dev);
+/* ARI forwarding capability and control */
+void pcie_cap_arifwd_init(PCIDevice *dev);
+void pcie_cap_arifwd_reset(PCIDevice *dev);
+bool pcie_cap_is_arifwd_enabled(const PCIDevice *dev);
 
 /* PCI express extended capability helper functions */
 uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id);
-- 
1.9.0




[Qemu-devel] [PATCH v2 3/4] ioh3420: Remove obsoleted, unused ioh3420_init function

2014-08-24 Thread Knut Omang
Signed-off-by: Knut Omang 
---
 hw/pci-bridge/ioh3420.c | 24 
 1 file changed, 24 deletions(-)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index aed2bf1..e6674a1 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -157,30 +157,6 @@ static void ioh3420_exitfn(PCIDevice *d)
 pci_bridge_exitfn(d);
 }
 
-PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction,
- const char *bus_name, pci_map_irq_fn map_irq,
- uint8_t port, uint8_t chassis, uint16_t slot)
-{
-PCIDevice *d;
-PCIBridge *br;
-DeviceState *qdev;
-
-d = pci_create_multifunction(bus, devfn, multifunction, "ioh3420");
-if (!d) {
-return NULL;
-}
-br = PCI_BRIDGE(d);
-
-qdev = DEVICE(d);
-pci_bridge_map_irq(br, bus_name, map_irq);
-qdev_prop_set_uint8(qdev, "port", port);
-qdev_prop_set_uint8(qdev, "chassis", chassis);
-qdev_prop_set_uint16(qdev, "slot", slot);
-qdev_init_nofail(qdev);
-
-return PCIE_SLOT(d);
-}
-
 static Property ioh3420_props[] = {
 DEFINE_PROP_BIT(COMPAT_PROP_PCP, PCIDevice, cap_present,
 QEMU_PCIE_SLTCAP_PCP_BITNR, true),
-- 
1.9.0




[Qemu-devel] [PATCH v2 1/4] pcie: Fix incorrect write to the ari capability next function field

2014-08-24 Thread Knut Omang
PCI_ARI_CAP_NFN, a macro for reading next function was used instead of
the intended write.

Signed-off-by: Knut Omang 
---
 hw/pci/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index a123c01..de0e967 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -630,5 +630,5 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, 
uint16_t nextfn)
 {
 pcie_add_capability(dev, PCI_EXT_CAP_ID_ARI, PCI_ARI_VER,
 offset, PCI_ARI_SIZEOF);
-pci_set_long(dev->config + offset + PCI_ARI_CAP, PCI_ARI_CAP_NFN(nextfn));
+pci_set_long(dev->config + offset + PCI_ARI_CAP, (nextfn & 0xff) << 8);
 }
-- 
1.9.0




[Qemu-devel] [PULL 11/11] vmxnet3: Pad short frames to minimum size (60 bytes)

2014-08-24 Thread Michael Tokarev
From: Ben Draper 

When running VMware ESXi under qemu-kvm the guest discards frames
that are too short. Short ARP Requests will be dropped, this prevents
guests on the same bridge as VMware ESXi from communicating. This patch
simply adds the padding on the network device itself.

Signed-off-by: Ben Draper 
Reviewed-by: Dmitry Fleytman 
Cc: qemu-sta...@nongnu.org
Signed-off-by: Michael Tokarev 
---
 hw/net/vmxnet3.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 791321f..f246fa1 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -34,6 +34,7 @@
 
 #define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1
 #define VMXNET3_MSIX_BAR_SIZE 0x2000
+#define MIN_BUF_SIZE 60
 
 #define VMXNET3_BAR0_IDX  (0)
 #define VMXNET3_BAR1_IDX  (1)
@@ -1871,12 +1872,21 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, 
size_t size)
 {
 VMXNET3State *s = qemu_get_nic_opaque(nc);
 size_t bytes_indicated;
+uint8_t min_buf[MIN_BUF_SIZE];
 
 if (!vmxnet3_can_receive(nc)) {
 VMW_PKPRN("Cannot receive now");
 return -1;
 }
 
+/* Pad to minimum Ethernet frame length */
+if (size < sizeof(min_buf)) {
+memcpy(min_buf, buf, size);
+memset(&min_buf[size], 0, sizeof(min_buf) - size);
+buf = min_buf;
+size = sizeof(min_buf);
+}
+
 if (s->peer_has_vhdr) {
 vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
 buf += sizeof(struct virtio_net_hdr);
-- 
1.7.10.4




[Qemu-devel] [PULL 07/11] slirp/misc: Use the GLib memory allocation APIs

2014-08-24 Thread Michael Tokarev
From: zhanghailiang 

Here we don't check the return value of malloc() which may fail.
Use the g_new() instead, which will abort the program when
there is not enough memory.

Also, use g_strdup instead of strdup and remove the unnecessary
strdup function.

Signed-off-by: zhanghailiang 
Reviewed-by: Alex Bennée 
Reviewed-by: Benoît Canet 
Signed-off-by: Michael Tokarev 
---
 slirp/misc.c |   20 +++-
 slirp/misc.h |4 
 slirp/slirp_config.h |3 ---
 3 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index b8eb74c..6543dc7 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -54,11 +54,11 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char 
*exec,
}
 
tmp_ptr = *ex_ptr;
-   *ex_ptr = (struct ex_list *)malloc(sizeof(struct ex_list));
+   *ex_ptr = g_new(struct ex_list, 1);
(*ex_ptr)->ex_fport = port;
(*ex_ptr)->ex_addr = addr;
(*ex_ptr)->ex_pty = do_pty;
-   (*ex_ptr)->ex_exec = (do_pty == 3) ? exec : strdup(exec);
+   (*ex_ptr)->ex_exec = (do_pty == 3) ? exec : g_strdup(exec);
(*ex_ptr)->ex_next = tmp_ptr;
return 0;
 }
@@ -187,7 +187,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
   bptr++;
c = *bptr;
*bptr++ = (char)0;
-   argv[i++] = strdup(curarg);
+   argv[i++] = g_strdup(curarg);
   } while (c);
 
 argv[i] = NULL;
@@ -228,20 +228,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
 }
 #endif
 
-#ifndef HAVE_STRDUP
-char *
-strdup(str)
-   const char *str;
-{
-   char *bptr;
-
-   bptr = (char *)malloc(strlen(str)+1);
-   strcpy(bptr, str);
-
-   return bptr;
-}
-#endif
-
 void slirp_connection_info(Slirp *slirp, Monitor *mon)
 {
 const char * const tcpstates[] = {
diff --git a/slirp/misc.h b/slirp/misc.h
index ba8beb1..41a3258 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -16,10 +16,6 @@ struct ex_list {
struct ex_list *ex_next;
 };
 
-#ifndef HAVE_STRDUP
-char *strdup(const char *);
-#endif
-
 #define EMU_NONE 0x0
 
 /* TCP emulations */
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 18db45c..896d802 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -72,9 +72,6 @@
 /* Define if you have strerror */
 #define HAVE_STRERROR
 
-/* Define if you have strdup() */
-#define HAVE_STRDUP
-
 /* Define according to how time.h should be included */
 #define TIME_WITH_SYS_TIME 0
 #undef HAVE_SYS_TIME_H
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 4/4] ioh3420: Enable ARI forwarding

2014-08-24 Thread Knut Omang
Signed-off-by: Knut Omang 
---
 hw/pci-bridge/ioh3420.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index e6674a1..cce2fdd 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -85,6 +85,7 @@ static void ioh3420_reset(DeviceState *qdev)
 pcie_cap_root_reset(d);
 pcie_cap_deverr_reset(d);
 pcie_cap_slot_reset(d);
+pcie_cap_arifwd_reset(d);
 pcie_aer_root_reset(d);
 pci_bridge_reset(qdev);
 pci_bridge_disable_base_limit(d);
@@ -119,6 +120,7 @@ static int ioh3420_initfn(PCIDevice *d)
 goto err_msi;
 }
 
+pcie_cap_arifwd_init(d);
 pcie_cap_deverr_init(d);
 pcie_cap_slot_init(d, s->slot);
 pcie_chassis_create(s->chassis);
-- 
1.9.0




[Qemu-devel] [PULL 08/11] po: Fix Makefile rules for in-tree builds without configuration

2014-08-24 Thread Michael Tokarev
From: Stefan Weil 

Adding 'update' to the phony targets fixes this error:

$ LANG=C make -C po update
make: Entering directory `/qemu/po'
  LINK  update
/qemu/po/de_DE.po: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [update] Error 1
make: Leaving directory `/qemu/po'

Some other phony targets (build, install) were also added, and the
existing .PHONY statement was moved to a more prominent position at
the beginning of the Makefile.

The patch also fixes a 2nd bug. The default target should be 'all',
but instead 'modules' (from rules.mak) was the default. Fix this by
adding 'all' as a target before any include statement.

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 po/Makefile |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/po/Makefile b/po/Makefile
index 669f865..1ab241a 100644
--- a/po/Makefile
+++ b/po/Makefile
@@ -4,6 +4,11 @@
 # Set SRC_PATH for in-tree builds without configuration.
 SRC_PATH=..
 
+# The default target must come before any include statements.
+all:
+
+.PHONY:all build clean install update
+
 -include ../config-host.mak
 include $(SRC_PATH)/rules.mak
 
@@ -45,5 +50,3 @@ $(PO_PATH)/messages.po: $(SRC_PATH)/ui/gtk.c
 
 $(PO_PATH)/%.po: $(PO_PATH)/messages.po
$(call quiet-command, msgmerge -q $@ $< > $@.bak && mv $@.bak $@, "  
GEN   $@")
-
-.PHONY: clean all
-- 
1.7.10.4




[Qemu-devel] [PULL 01/11] util/path: Use the GLib memory allocation routines

2014-08-24 Thread Michael Tokarev
From: zhanghailiang 

In this file, we don't check the return value of malloc/strdup/realloc which 
may fail.
Instead of using these routines, we use the GLib memory APIs 
g_malloc/g_strdup/g_realloc.
They will exit on allocation failure, so there is no need to test for failure,
which would be fine for setup.

Signed-off-by: zhanghailiang 
Reviewed-by: Alex Bennée 
Signed-off-by: Michael Tokarev 
---
 util/path.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/util/path.c b/util/path.c
index 5c59d9f..4e4877e 100644
--- a/util/path.c
+++ b/util/path.c
@@ -45,8 +45,8 @@ static struct pathelem *new_entry(const char *root,
   struct pathelem *parent,
   const char *name)
 {
-struct pathelem *new = malloc(sizeof(*new));
-new->name = strdup(name);
+struct pathelem *new = g_malloc(sizeof(*new));
+new->name = g_strdup(name);
 new->pathname = g_strdup_printf("%s/%s", root, name);
 new->num_entries = 0;
 return new;
@@ -88,7 +88,7 @@ static struct pathelem *add_entry(struct pathelem *root, 
const char *name,
 
 root->num_entries++;
 
-root = realloc(root, sizeof(*root)
+root = g_realloc(root, sizeof(*root)
+ sizeof(root->entries[0])*root->num_entries);
 e = &root->entries[root->num_entries-1];
 
@@ -161,8 +161,8 @@ void init_paths(const char *prefix)
 base = add_dir_maybe(base);
 if (base->num_entries == 0) {
 g_free(base->pathname);
-free(base->name);
-free(base);
+g_free(base->name);
+g_free(base);
 base = NULL;
 } else {
 set_parents(base, base);
-- 
1.7.10.4




[Qemu-devel] [PULL 05/11] dma: axidma: Variablise repeated s->streams[i] sub-expr

2014-08-24 Thread Michael Tokarev
From: Peter Crosthwaite 

This have 6 inline usages. Make it a bit more readable by using a local
variable.

Signed-off-by: Peter Crosthwaite 
Signed-off-by: Michael Tokarev 
---
 hw/dma/xilinx_axidma.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index ee60d3f..d06002d 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -553,10 +553,12 @@ static void xilinx_axidma_realize(DeviceState *dev, Error 
**errp)
 int i;
 
 for (i = 0; i < 2; i++) {
-s->streams[i].nr = i;
-s->streams[i].bh = qemu_bh_new(timer_hit, &s->streams[i]);
-s->streams[i].ptimer = ptimer_init(s->streams[i].bh);
-ptimer_set_freq(s->streams[i].ptimer, s->freqhz);
+struct Stream *st = &s->streams[i];
+
+st->nr = i;
+st->bh = qemu_bh_new(timer_hit, st);
+st->ptimer = ptimer_init(st->bh);
+ptimer_set_freq(st->ptimer, s->freqhz);
 }
 return;
 
-- 
1.7.10.4




[Qemu-devel] [PULL 04/11] microblaze: ml605: Get rid of ddr_base variable

2014-08-24 Thread Michael Tokarev
From: Peter Crosthwaite 

It's a constant based on a macro. Just use the macro in place.

Signed-off-by: Peter Crosthwaite 
Signed-off-by: Michael Tokarev 
---
 hw/microblaze/petalogix_ml605_mmu.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/microblaze/petalogix_ml605_mmu.c 
b/hw/microblaze/petalogix_ml605_mmu.c
index aea9c5b..6843abf 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -89,7 +89,6 @@ petalogix_ml605_init(MachineState *machine)
 SysBusDevice *busdev;
 DriveInfo *dinfo;
 int i;
-hwaddr ddr_base = MEMORY_BASEADDR;
 MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
 MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
 qemu_irq irq[32];
@@ -106,7 +105,7 @@ petalogix_ml605_init(MachineState *machine)
 
 memory_region_init_ram(phys_ram, NULL, "petalogix_ml605.ram", ram_size);
 vmstate_register_ram_global(phys_ram);
-memory_region_add_subregion(address_space_mem, ddr_base, phys_ram);
+memory_region_add_subregion(address_space_mem, MEMORY_BASEADDR, phys_ram);
 
 dinfo = drive_get(IF_PFLASH, 0, 0);
 /* 5th parameter 2 means bank-width
@@ -201,7 +200,7 @@ petalogix_ml605_init(MachineState *machine)
 }
 }
 
-microblaze_load_kernel(cpu, ddr_base, ram_size,
+microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size,
machine->initrd_filename,
BINARY_DEVICE_TREE_FILE,
machine_cpu_reset);
-- 
1.7.10.4




[Qemu-devel] [Bug 1354167] Re: On VM restart: Could not open 'poppy.qcow2': Could not read snapshots: File too large

2014-08-24 Thread Gary Roberts
I too am getting his bug.

Same error message Todd gets word for word.

Even going to the command prompt yields the same issue.

I have QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.2)

Thank you

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1354167

Title:
  On VM restart: Could not open 'poppy.qcow2': Could not read snapshots:
  File too large

Status in QEMU:
  New

Bug description:
  I'm unable to restart a VM.   virt-manager is giving me:

  Error starting domain: internal error: process exited while connecting
  to monitor: qemu-system-x86_64: -drive
  file=/var/lib/libvirt/images/poppy.qcow2,if=none,id=drive-virtio-
  disk0,format=qcow2: could not open disk image
  /var/lib/libvirt/images/poppy.qcow2: Could not read snapshots: File
  too large

  
  From the command line trying to check the image also gives me:
  qemu-img check poppy.qcow2
  qemu-img: Could not open 'poppy.qcow2': Could not read snapshots: File too 
large

  
  This bug appears with both the default install of qemu for ubuntu 14.04:
  qemu-img version 2.0.0, Copyright (c) 2004-2008 Fabrice Bellard

  And the latest version.
  qemu-img version 2.1.50, Copyright (c) 2004-2008 Fabrice Bellard

  
  Host: 
  Dual E5-2650 v2 @ 2.60GHz
  32GB Memory
  4TB Disk space (2.1TB Free) 

  Host OS: Ubuntu 14.04.1 LTS 64bit

  Guest:
  Ubuntu 14.04 64bit
  Storage Size: 500gb

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1354167/+subscriptions



[Qemu-devel] [PATCH] target-i386: Don't forbid NX bit on PAE PDEs and PTEs

2014-08-24 Thread William Grant
Commit e8f6d00c30ed88910d0d985f4b2bf41654172ceb ("target-i386: raise
page fault for reserved physical address bits") added a check that the
NX bit is not set on PAE PDPEs, but it also added it to rsvd_mask for
the rest of the function. This caused any PDEs or PTEs with NX set to be
erroneously rejected, making PAE guests with NX support unusable.

Signed-off-by: William Grant 
---
 target-i386/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index 47b982b..30cb0d0 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -615,8 +615,8 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr,
 if (!(pdpe & PG_PRESENT_MASK)) {
 goto do_fault;
 }
-rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK;
-if (pdpe & rsvd_mask) {
+rsvd_mask |= PG_HI_USER_MASK;
+if (pdpe & (rsvd_mask | PG_NX_MASK)) {
 goto do_fault_rsvd;
 }
 ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
-- 
2.1.0



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [Bug 1359243] Re: [BSOD 0xc000000d] Can't boot windows with qemu

2014-08-24 Thread Gannet
And where can I find it, 1.7.4 version ?

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1359243

Title:
  [BSOD 0xc00d] Can't boot windows with qemu

Status in QEMU:
  New

Bug description:
  Upgrading to latest qemu I found my VM unusable: tried windows
  8.1/7/WinPE with the same result: BSOD on boot with code error:
  0xc00d (please, look at screenshot in attachment).

  Command running VM:
  sudo qemu-system-x86_64 -m 4096 /var/lib/libvirt/images/win8.img (also with 
'-machine accel=kvm')
  Linux: 3.15.10 x86_64
  Kubuntu 14.04.1
  qemu: 2.1.1 (from ppa:jacob/virtualisation)
  qemu-kvm: 2.1.1 (from ppa:jacob/virtualisation)
  CPU: Intel C2Q9450

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1359243/+subscriptions



[Qemu-devel] [Bug 1359243] Re: [BSOD 0xc000000d] Can't boot windows with qemu

2014-08-24 Thread Gannet
I meаnt 1.7.5.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1359243

Title:
  [BSOD 0xc00d] Can't boot windows with qemu

Status in QEMU:
  New

Bug description:
  Upgrading to latest qemu I found my VM unusable: tried windows
  8.1/7/WinPE with the same result: BSOD on boot with code error:
  0xc00d (please, look at screenshot in attachment).

  Command running VM:
  sudo qemu-system-x86_64 -m 4096 /var/lib/libvirt/images/win8.img (also with 
'-machine accel=kvm')
  Linux: 3.15.10 x86_64
  Kubuntu 14.04.1
  qemu: 2.1.1 (from ppa:jacob/virtualisation)
  qemu-kvm: 2.1.1 (from ppa:jacob/virtualisation)
  CPU: Intel C2Q9450

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1359243/+subscriptions



Re: [Qemu-devel] latest rc: virtio-blk hangs forever after migration

2014-08-24 Thread Andrey Korolyov
Sorry, I was a bit inaccurate in my thoughts at Fri about necessary
amount of work, patch lays perfectly on 3.10 with bit of monkey
rewrites. The attached one fixed problem for me - it represents
0b10a1c87a2b0fb459baaefba9cb163dbb8d3344,
0bc830b05c667218d703f2026ec866c49df974fc,
44847dea79751e95665a439f8c63a65e51da8e1f and
673f7b4257a1fe7b181e1a1182ecc2b6b2b795f1.
diff -ru linux-3.10.11/arch/ia64/kvm/kvm-ia64.c linux-3.10.11.patched-ioapic/arch/ia64/kvm/kvm-ia64.c
--- linux-3.10.11/arch/ia64/kvm/kvm-ia64.c	2013-09-08 09:10:14.0 +0400
+++ linux-3.10.11.patched-ioapic/arch/ia64/kvm/kvm-ia64.c	2014-08-24 19:49:25.723072383 +0400
@@ -199,6 +199,7 @@
 	case KVM_CAP_IRQCHIP:
 	case KVM_CAP_MP_STATE:
 	case KVM_CAP_IRQ_INJECT_STATUS:
+	case KVM_CAP_IOAPIC_POLARITY_IGNORED:
 		r = 1;
 		break;
 	case KVM_CAP_COALESCED_MMIO:
diff -ru linux-3.10.11/arch/x86/kvm/x86.c linux-3.10.11.patched-ioapic/arch/x86/kvm/x86.c
--- linux-3.10.11/arch/x86/kvm/x86.c	2013-09-08 09:10:14.0 +0400
+++ linux-3.10.11.patched-ioapic/arch/x86/kvm/x86.c	2014-08-24 19:50:06.553716276 +0400
@@ -2537,6 +2537,7 @@
 	case KVM_CAP_GET_TSC_KHZ:
 	case KVM_CAP_KVMCLOCK_CTRL:
 	case KVM_CAP_READONLY_MEM:
+	case KVM_CAP_IOAPIC_POLARITY_IGNORED:
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 	case KVM_CAP_ASSIGN_DEV_IRQ:
 	case KVM_CAP_PCI_2_3:
diff -ru linux-3.10.11/include/uapi/linux/kvm.h linux-3.10.11.patched-ioapic/include/uapi/linux/kvm.h
--- linux-3.10.11/include/uapi/linux/kvm.h	2013-09-08 09:10:14.0 +0400
+++ linux-3.10.11.patched-ioapic/include/uapi/linux/kvm.h	2014-08-24 19:51:10.975577204 +0400
@@ -666,6 +666,7 @@
 #define KVM_CAP_IRQ_MPIC 90
 #define KVM_CAP_PPC_RTAS 91
 #define KVM_CAP_IRQ_XICS 92
+#define KVM_CAP_IOAPIC_POLARITY_IGNORED 93
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
diff -ru linux-3.10.11/virt/kvm/ioapic.c linux-3.10.11.patched-ioapic/virt/kvm/ioapic.c
--- linux-3.10.11/virt/kvm/ioapic.c	2013-09-08 09:10:14.0 +0400
+++ linux-3.10.11.patched-ioapic/virt/kvm/ioapic.c	2014-08-24 19:59:26.755137527 +0400
@@ -50,7 +50,7 @@
 #else
 #define ioapic_debug(fmt, arg...)
 #endif
-static int ioapic_deliver(struct kvm_ioapic *vioapic, int irq,
+static int ioapic_service(struct kvm_ioapic *vioapic, int irq
 		bool line_status);
 
 static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
@@ -163,23 +163,67 @@
 	return false;
 }
 
-static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx,
-		bool line_status)
+static int ioapic_set_irq(struct kvm_ioapic *ioapic, unsigned int irq,
+		int irq_level, bool line_status)
 {
-	union kvm_ioapic_redirect_entry *pent;
-	int injected = -1;
+	union kvm_ioapic_redirect_entry entry;
+	u32 mask = 1 << irq;
+	u32 old_irr;
+	int edge, ret;
 
-	pent = &ioapic->redirtbl[idx];
+	entry = ioapic->redirtbl[irq];
+	edge = (entry.fields.trig_mode == IOAPIC_EDGE_TRIG);
 
-	if (!pent->fields.mask) {
-		injected = ioapic_deliver(ioapic, idx, line_status);
-		if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG)
-			pent->fields.remote_irr = 1;
+	if (!irq_level) {
+		ioapic->irr &= ~mask;
+		ret = 1;
+		goto out;
+	}
+
+	/*
+	 * Return 0 for coalesced interrupts; for edge-triggered interrupts,
+	 * this only happens if a previous edge has not been delivered due
+	 * do masking.  For level interrupts, the remote_irr field tells
+	 * us if the interrupt is waiting for an EOI.
+	 *
+	 * RTC is special: it is edge-triggered, but userspace likes to know
+	 * if it has been already ack-ed via EOI because coalesced RTC
+	 * interrupts lead to time drift in Windows guests.  So we track
+	 * EOI manually for the RTC interrupt.
+	 */
+	if (irq == RTC_GSI && line_status &&
+		rtc_irq_check_coalesced(ioapic)) {
+		ret = 0;
+		goto out;
 	}
 
-	return injected;
+	old_irr = ioapic->irr;
+	ioapic->irr |= mask;
+	if ((edge && old_irr == ioapic->irr) ||
+	(!edge && entry.fields.remote_irr)) {
+		ret = 0;
+		goto out;
+	}
+
+	ret = ioapic_service(ioapic, irq, line_status);
+
+out:
+	trace_kvm_ioapic_set_irq(entry.bits, irq, ret == 0);
+	return ret;
+}
+
+static void kvm_ioapic_inject_all(struct kvm_ioapic *ioapic, unsigned long irr)
+{
+	u32 idx;
+
+	rtc_irq_eoi_tracking_reset(ioapic);
+	for_each_set_bit(idx, &irr, IOAPIC_NUM_PINS)
+		ioapic_set_irq(ioapic, idx, 1, true);
+
+	kvm_rtc_eoi_tracking_restore_all(ioapic);
 }
 
+
 static void update_handled_vectors(struct kvm_ioapic *ioapic)
 {
 	DECLARE_BITMAP(handled_vectors, 256);
@@ -282,12 +326,15 @@
 	}
 }
 
-static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq, bool line_status)
+static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
 {
 	union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq];
 	struct kvm_lapic_irq irqe;
 	int ret;
 
+	if (entry->fields.mask)
+	return -1;
+
 	ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "
 		 "vector=%x trig_mode=%x\n",
 		 entry->fields.dest_id, entry->fields.dest_mode,
@@ -302,6 +349,10 @@
 	irqe.level = 1;
 	irqe.shorthand = 0;
 
+	if (ir

Re: [Qemu-devel] [Fwd: [PATCH v4 07/21] iscsi: Handle failure for potentially large allocations]

2014-08-24 Thread Paolo Bonzini
Il 22/08/2014 10:42, Kevin Wolf ha scritto:
> > Unfortunately, I missed that one. The zeroblock is typicalls 512 Byte or 4K 
> > depending
> > on the blocksize.
> 
> I don't remember the details, but I think when I went through all
> drivers, I couldn't convince myself that a reasonable block size is
> enforced somewhere. So I just went ahead and converted the call to be on
> the safe side. It can never hurt anyway.

Yeah, a malicious iSCSI target could have unreasonable block sizes.

This means the minimum transfer size for SCSI devices could be on the
order of half a GiB, and that could cause other unbounded allocations in
the read-modify-write code.  Are those protected too?

Paolo



Re: [Qemu-devel] latest rc: virtio-blk hangs forever after migration

2014-08-24 Thread Paolo Bonzini
Il 24/08/2014 18:19, Andrey Korolyov ha scritto:
> Sorry, I was a bit inaccurate in my thoughts at Fri about necessary
> amount of work, patch lays perfectly on 3.10 with bit of monkey
> rewrites. The attached one fixed problem for me - it represents
> 0b10a1c87a2b0fb459baaefba9cb163dbb8d3344,
> 0bc830b05c667218d703f2026ec866c49df974fc,
> 44847dea79751e95665a439f8c63a65e51da8e1f and
> 673f7b4257a1fe7b181e1a1182ecc2b6b2b795f1.

So, with these changes, Marcelo's patch does not hang up your guest anymore?

Paolo




Re: [Qemu-devel] [PATCH v2] qcow2: Add bdrv_discard support

2014-08-24 Thread Jun Li

Hi Kevin and Stefan,

  As the realize of bdrv_discard, and this patch has been received, but 
I have some question.


This adds a bdrv_discard function to qcow2 that frees the discarded clusters.
It does not yet pass the discard on to the underlying file system driver, but
the space can be reused by future writes to the image.

Above content is on url: 
https://lists.gnu.org/archive/html/qemu-devel/2011-01/msg03100.html


I have following question:

Why bdrv_discard does not yet pass the discard on to the underlying file 
system driver? And this exist a potential issue: host cluster leak for 
qcow2. As qcow2 image can be created on RAW disk,
so this is not just "does not yet pass the discard on to the underlying 
file system driver".  Could you give some explanation why do not realize 
this function? Thx.


As I am trying to realize qcow2 shrinking, but hit bdrv_discard can not 
release the free cluster on host.



Best Regards,
Jun Li





Re: [Qemu-devel] latest rc: virtio-blk hangs forever after migration

2014-08-24 Thread Andrey Korolyov
On Sun, Aug 24, 2014 at 8:35 PM, Paolo Bonzini  wrote:
> Il 24/08/2014 18:19, Andrey Korolyov ha scritto:
>> Sorry, I was a bit inaccurate in my thoughts at Fri about necessary
>> amount of work, patch lays perfectly on 3.10 with bit of monkey
>> rewrites. The attached one fixed problem for me - it represents
>> 0b10a1c87a2b0fb459baaefba9cb163dbb8d3344,
>> 0bc830b05c667218d703f2026ec866c49df974fc,
>> 44847dea79751e95665a439f8c63a65e51da8e1f and
>> 673f7b4257a1fe7b181e1a1182ecc2b6b2b795f1.
>
> So, with these changes, Marcelo's patch does not hang up your guest anymore?
>
> Paolo
>

If I may reword, Marcelo`s proposed states sync with revert-revert of
agraf`s patch, does not break anything for Windows (migration works
well for any variant of emulator with modified kernel modules). Let me
check if initially reported issue (lost I/O interrupts) is gone for
the current situation (patched kernel plus Marcelo` patch).



[Qemu-devel] [Bug 1359243] Re: [BSOD 0xc000000d] Can't boot windows with qemu

2014-08-24 Thread Gannet
Well, I took it here: https://launchpad.net/ubuntu/+source/seabios.
Although it's for Utopic and, as noted, also unstable, but you're right.
It works ! Thanks.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1359243

Title:
  [BSOD 0xc00d] Can't boot windows with qemu

Status in QEMU:
  New

Bug description:
  Upgrading to latest qemu I found my VM unusable: tried windows
  8.1/7/WinPE with the same result: BSOD on boot with code error:
  0xc00d (please, look at screenshot in attachment).

  Command running VM:
  sudo qemu-system-x86_64 -m 4096 /var/lib/libvirt/images/win8.img (also with 
'-machine accel=kvm')
  Linux: 3.15.10 x86_64
  Kubuntu 14.04.1
  qemu: 2.1.1 (from ppa:jacob/virtualisation)
  qemu-kvm: 2.1.1 (from ppa:jacob/virtualisation)
  CPU: Intel C2Q9450

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1359243/+subscriptions



Re: [Qemu-devel] latest rc: virtio-blk hangs forever after migration

2014-08-24 Thread Andrey Korolyov
On Sun, Aug 24, 2014 at 8:57 PM, Andrey Korolyov  wrote:
> On Sun, Aug 24, 2014 at 8:35 PM, Paolo Bonzini  wrote:
>> Il 24/08/2014 18:19, Andrey Korolyov ha scritto:
>>> Sorry, I was a bit inaccurate in my thoughts at Fri about necessary
>>> amount of work, patch lays perfectly on 3.10 with bit of monkey
>>> rewrites. The attached one fixed problem for me - it represents
>>> 0b10a1c87a2b0fb459baaefba9cb163dbb8d3344,
>>> 0bc830b05c667218d703f2026ec866c49df974fc,
>>> 44847dea79751e95665a439f8c63a65e51da8e1f and
>>> 673f7b4257a1fe7b181e1a1182ecc2b6b2b795f1.
>>
>> So, with these changes, Marcelo's patch does not hang up your guest anymore?
>>
>> Paolo
>>
>
> If I may reword, Marcelo`s proposed states sync with revert-revert of
> agraf`s patch, does not break anything for Windows (migration works
> well for any variant of emulator with modified kernel modules). Let me
> check if initially reported issue (lost I/O interrupts) is gone for
> the current situation (patched kernel plus Marcelo` patch).


patched kernel + any 2.1 variant + Windows = works
patched kernel + patched 2.1 + Linux + disk workload = works fine
bare kernel + any 2.1 variant + Windows = disk stale
bare kernel + proposed patch from Marcelo + Linux + disk workload =
works fine (bare kernel + 2.1 release works at this point as tested
earlier)


Also guest 3.10.52 caused literally a rain of WTFs crashing emulator
with an emulation error in every case tested with live migration...
3.10.11 works fine. There will be another report soon I suppose though
it is nearly impossible to do a proper bisection in a sane time.



[Qemu-devel] [Bug 1359243] Re: [BSOD 0xc000000d] Can't boot windows with qemu

2014-08-24 Thread Michael Tokarev
So, the problem is with the ppa, not qemu. The ppa package does not
express dependencies correctly.  Closing as invalid.

** Changed in: qemu
   Status: New => Invalid

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1359243

Title:
  [BSOD 0xc00d] Can't boot windows with qemu

Status in QEMU:
  Invalid

Bug description:
  Upgrading to latest qemu I found my VM unusable: tried windows
  8.1/7/WinPE with the same result: BSOD on boot with code error:
  0xc00d (please, look at screenshot in attachment).

  Command running VM:
  sudo qemu-system-x86_64 -m 4096 /var/lib/libvirt/images/win8.img (also with 
'-machine accel=kvm')
  Linux: 3.15.10 x86_64
  Kubuntu 14.04.1
  qemu: 2.1.1 (from ppa:jacob/virtualisation)
  qemu-kvm: 2.1.1 (from ppa:jacob/virtualisation)
  CPU: Intel C2Q9450

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1359243/+subscriptions



Re: [Qemu-devel] [Fwd: [PATCH v4 07/21] iscsi: Handle failure for potentially large allocations]

2014-08-24 Thread Peter Lieven
Am 24.08.2014 um 18:30 schrieb Paolo Bonzini:
> Il 22/08/2014 10:42, Kevin Wolf ha scritto:
>>> Unfortunately, I missed that one. The zeroblock is typicalls 512 Byte or 4K 
>>> depending
>>> on the blocksize.
>> I don't remember the details, but I think when I went through all
>> drivers, I couldn't convince myself that a reasonable block size is
>> enforced somewhere. So I just went ahead and converted the call to be on
>> the safe side. It can never hurt anyway.
> Yeah, a malicious iSCSI target could have unreasonable block sizes.
Maybe we should just allow 512b or 4kb blocksize and refuse
all other?

Peter

>
> This means the minimum transfer size for SCSI devices could be on the
> order of half a GiB, and that could cause other unbounded allocations in
> the read-modify-write code.  Are those protected too?
>
> Paolo




Re: [Qemu-devel] [PATCH] qemu-iotests: stop using /tmp directly

2014-08-24 Thread Peter Wu
On Friday 22 August 2014 20:58:34 Benoît Canet wrote:
> The Friday 22 Aug 2014 à 13:25:43 (+0200), Peter Wu wrote :
> > Before this patch you could not run multiple tests concurrently as they
> > might clobber each other test files. This patch solves that by using
> > random temporary directory instead of `/tmp` (for writing output in the
> > individual tests and valgrind logs).
> > 
> > Furthermore, this patch stops removing everything in `/tmp/` matching a
> > certain pattern (`/tmp/*.{err,out,time}`). These might not be a property
> > of QEMU.
> > 
> > Running multiple concurrent tests in the same object directory is still
> > not supported though as the scratch directory and .bad and .notrun files
> > still interfere with each other. Also not touched is the situation that
> > /tmp/check.log and /tmp/check.sts are hard-coded (and thus unusable in
> > concurrent tests).
> > 
> > Signed-off-by: Peter Wu 
> > ---
> > Hi,
> > 
> > This patch introduces a dependency on mktemp of coreutils. I could still 
> > not get
> > concurrent tests to work fully reliably (test 030 failed randomly with QED):
> 
> Do we care about the BSDs ?
> 
> See the link in the anwser of: 
> http://stackoverflow.com/questions/2792675/how-portable-is-mktemp1
> 
> --tmpdir seems to be a GNUism.

And `-t` differs between FreeBSD and others too. There is probably nobody who
cares about locations other than /tmp, so what about:

QEMU_IOTESTS_TMPDIR=$(mktemp -d /tmp/qemu-iotests.)

What do you think of the idea of the patch in general?

Kind regards,
Peter
https://lekensteyn.nl

> > FAIL: test_ignore (__main__.TestEIO)
> > --
> > Traceback (most recent call last):
> >   File "030", line 223, in test_ignore
> > self.assert_qmp(result, 'return[0]/paused', False)
> >   File "/tmp/qemu/tests/qemu-iotests/iotests.py", line 233, in 
> > assert_qmp
> > result = self.dictpath(d, path)
> >   File "/tmp/qemu/tests/qemu-iotests/iotests.py", line 221, in dictpath
> > self.fail('invalid index "%s" in path "%s" in "%s"' % (idx, path, 
> > str(d)))
> > AssertionError: invalid index "0" in path "return[0]/paused" in "[]"
> > 
> > I still think that the patches are valuable though, it reduces predictable 
> > file
> > names.
> > 
> > Kind regards,
> > Peter
> > ---
> >  tests/qemu-iotests/001   | 2 +-
> >  tests/qemu-iotests/002   | 2 +-
> >  tests/qemu-iotests/003   | 2 +-
> >  tests/qemu-iotests/004   | 2 +-
> >  tests/qemu-iotests/005   | 2 +-
> >  tests/qemu-iotests/006   | 2 +-
> >  tests/qemu-iotests/007   | 2 +-
> >  tests/qemu-iotests/008   | 2 +-
> >  tests/qemu-iotests/009   | 2 +-
> >  tests/qemu-iotests/010   | 2 +-
> >  tests/qemu-iotests/011   | 2 +-
> >  tests/qemu-iotests/012   | 2 +-
> >  tests/qemu-iotests/013   | 2 +-
> >  tests/qemu-iotests/014   | 2 +-
> >  tests/qemu-iotests/015   | 2 +-
> >  tests/qemu-iotests/016   | 2 +-
> >  tests/qemu-iotests/017   | 2 +-
> >  tests/qemu-iotests/018   | 2 +-
> >  tests/qemu-iotests/019   | 2 +-
> >  tests/qemu-iotests/020   | 2 +-
> >  tests/qemu-iotests/021   | 2 +-
> >  tests/qemu-iotests/022   | 2 +-
> >  tests/qemu-iotests/023   | 2 +-
> >  tests/qemu-iotests/024   | 2 +-
> >  tests/qemu-iotests/025   | 2 +-
> >  tests/qemu-iotests/026   | 2 +-
> >  tests/qemu-iotests/027   | 2 +-
> >  tests/qemu-iotests/028   | 2 +-
> >  tests/qemu-iotests/029   | 2 +-
> >  tests/qemu-iotests/031   | 2 +-
> >  tests/qemu-iotests/032   | 2 +-
> >  tests/qemu-iotests/033   | 2 +-
> >  tests/qemu-iotests/034   | 2 +-
> >  tests/qemu-iotests/035   | 2 +-
> >  tests/qemu-iotests/036   | 2 +-
> >  tests/qemu-iotests/037   | 2 +-
> >  tests/qemu-iotests/038   | 2 +-
> >  tests/qemu-iotests/039   | 2 +-
> >  tests/qemu-iotests/042   | 2 +-
> >  tests/qemu-iotests/043   | 2 +-
> >  tests/qemu-iotests/046   | 2 +-
> >  tests/qemu-iotests/047   | 2 +-
> >  tests/qemu-iotests/049   | 2 +-
> >  tests/qemu-iotests/050   | 2 +-
> >  tests/qemu-iotests/051   | 2 +-
> >  tests/qemu-iotests/052   | 2 +-
> >  tests/qemu-iotests/053   | 2 +-
> >  tests/qemu-iotests/054   | 2 +-
> >  tests/qemu-iotests/058   | 2 +-
> >  tests/qemu-iotests/059   | 2 +-
> >  tests/qemu-iotests/060   | 2 +-
> >  tests/qemu-iotests/061   | 2 +-
> >  tests/qemu-iotests/062   | 2 +-
> >  tests/qemu-iotests/063   | 2 +-
> >  tests/qemu-iotests/064   | 2 +-
> >  tests/qemu-iotests/066   | 2 +-
> >  tests/qemu-iotests/067   | 2 +-
> >  tests/qemu-iotests/068   | 2 +-
> >  tests/qemu-iotests/069   | 2 +-
> >  tests/qemu-iotests/070   | 2 +-
> >  tests/qemu-iotests/071   | 2 +-
> >  tests/qemu-iotests/072   | 2 +-
> >  tests/qemu-iotests/073   | 2 +-
> >  tests/qemu-iotests/075  

Re: [Qemu-devel] latest rc: virtio-blk hangs forever after migration

2014-08-24 Thread Andrey Korolyov
Forgot to mention, _actual_ patch from above. Adding
cpu_synchronize_all_states() bringing old bug with lost interrupts
back.



Re: [Qemu-devel] [PATCH v2 0/4] q35: Minor fixes/enhancements to improve usability of root ports

2014-08-24 Thread Michael S. Tsirkin
On Sun, Aug 24, 2014 at 03:32:16PM +0200, Knut Omang wrote:
> These are some minor fixes necessary to be able to operate ARI capable devices
> in PCIe root ports on a q35 machine, using command line options like this:
> 
>  -device ioh3420,slot=0,id=pcie_port.0
>  -device ioh3420,slot=1,id=pcie_port.1
>  -device ,bus=pcie_port.0
>  -device ,bus=pcie_port.1
> 
> Changes since v1:
>   Removed "ioh3420: Provide a unique bus name and an interrupt mapping 
> function"
> as it is no longer necessary.
>   Added rename of ari -> arifwd for clarity and removal of obsolete init 
> function
>   (separate patches)
>   Use the renamed functions in ioh3420.


Applied, thanks!

> Knut Omang (4):
>   pcie: Fix incorrect write to the ari capability next function field
>   pcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*
>   ioh3420: Remove obsoleted, unused ioh3420_init function
>   ioh3420: Enable ARI forwarding
> 
>  hw/pci-bridge/ioh3420.c| 27 +++
>  hw/pci-bridge/xio3130_downstream.c |  4 ++--
>  hw/pci/pcie.c  | 13 +++--
>  include/hw/pci/pcie.h  |  7 ---
>  4 files changed, 16 insertions(+), 35 deletions(-)
> 
> -- 
> 1.9.0



[Qemu-devel] [PATCH] pcie: fix trailing whitespace

2014-08-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin 
---
 hw/pci/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 6cb6e0c..1babddf 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -498,7 +498,7 @@ void pcie_cap_flr_write_config(PCIDevice *dev,
 }
 
 /* Alternative Routing-ID Interpretation (ARI)
- * forwarding support for root and downstream ports 
+ * forwarding support for root and downstream ports
  */
 void pcie_cap_arifwd_init(PCIDevice *dev)
 {
-- 
MST



[Qemu-devel] [PULL 00/11] pci, pc fixes, features

2014-08-24 Thread Michael S. Tsirkin
The following changes since commit 2656eb7c599e306b95bad82b1372fc49ba3088f6:

  Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140819' 
into staging (2014-08-20 09:55:42 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 187de915e8d06aaf82be206aebc551c82bf0670c:

  pcie: fix trailing whitespace (2014-08-25 00:16:07 +0200)


pci, pc fixes, features

A bunch of bugfixes - these will make sense for 2.1.1

ACPI support for TPM and partial ARI support for PCIE.

Signed-off-by: Michael S. Tsirkin 


Gonglei (1):
  pcihp: fix possible array out of bounds

Knut Omang (4):
  pcie: Fix incorrect write to the ari capability next function field
  pcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*
  ioh3420: Remove obsoleted, unused ioh3420_init function
  ioh3420: Enable ARI forwarding

Michael S. Tsirkin (4):
  hostmem: set MPOL_MF_MOVE
  pc: reserve more memory for ACPI for new machine types
  ssdt-tpm: add generated hex file to git
  pcie: fix trailing whitespace

Paolo Bonzini (1):
  pci_bridge: manually destroy memory regions within PCIBridgeWindows

Stefan Berger (1):
  Add ACPI tables for TPM

 hw/i386/acpi-defs.h| 11 +
 hw/tpm/tpm_tis.h   |  8 +---
 include/hw/acpi/tpm.h  | 29 
 include/hw/i386/pc.h   |  2 +
 include/hw/pci/pcie.h  |  7 +--
 include/sysemu/tpm.h   |  7 +++
 backends/hostmem.c |  2 +-
 hw/acpi/pcihp.c|  2 +-
 hw/i386/acpi-build.c   | 45 ++
 hw/i386/pc.c   | 12 +++--
 hw/i386/pc_piix.c  |  1 +
 hw/i386/pc_q35.c   |  1 +
 hw/pci-bridge/ioh3420.c| 27 ++-
 hw/pci-bridge/xio3130_downstream.c |  4 +-
 hw/pci/pci_bridge.c|  6 +++
 hw/pci/pcie.c  | 13 +++---
 hw/i386/Makefile.objs  |  3 +-
 hw/i386/ssdt-tpm.dsl   | 43 +
 hw/i386/ssdt-tpm.hex.generated | 95 ++
 19 files changed, 270 insertions(+), 48 deletions(-)
 create mode 100644 include/hw/acpi/tpm.h
 create mode 100644 hw/i386/ssdt-tpm.dsl
 create mode 100644 hw/i386/ssdt-tpm.hex.generated




[Qemu-devel] [PULL 05/11] Add ACPI tables for TPM

2014-08-24 Thread Michael S. Tsirkin
From: Stefan Berger 

Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.

The latter follows this spec here:

http://www.trustedcomputinggroup.org/files/static_page_files/DCD4188E-1A4B-B294-D050A155FB6F7385/TCG_ACPIGeneralSpecification_PublicReview.pdf

This patch has Michael Tsirkin's patches folded in.

Signed-off-by: Stefan Berger 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Michael S. Tsirkin 
---
 hw/i386/acpi-defs.h   | 11 +++
 hw/tpm/tpm_tis.h  |  8 +---
 include/hw/acpi/tpm.h | 29 +
 include/sysemu/tpm.h  |  7 +++
 hw/i386/acpi-build.c  | 45 +
 hw/i386/Makefile.objs |  3 ++-
 hw/i386/ssdt-tpm.dsl  | 43 +++
 7 files changed, 138 insertions(+), 8 deletions(-)
 create mode 100644 include/hw/acpi/tpm.h
 create mode 100644 hw/i386/ssdt-tpm.dsl

diff --git a/hw/i386/acpi-defs.h b/hw/i386/acpi-defs.h
index e93babb..1bc974a 100644
--- a/hw/i386/acpi-defs.h
+++ b/hw/i386/acpi-defs.h
@@ -314,4 +314,15 @@ struct AcpiTableMcfg {
 } QEMU_PACKED;
 typedef struct AcpiTableMcfg AcpiTableMcfg;
 
+/*
+ * TCPA Description Table
+ */
+struct Acpi20Tcpa {
+ACPI_TABLE_HEADER_DEF/* ACPI common table header */
+uint16_t platform_class;
+uint32_t log_area_minimum_length;
+uint64_t log_area_start_address;
+} QEMU_PACKED;
+typedef struct Acpi20Tcpa Acpi20Tcpa;
+
 #endif
diff --git a/hw/tpm/tpm_tis.h b/hw/tpm/tpm_tis.h
index 916152a..1a0db23 100644
--- a/hw/tpm/tpm_tis.h
+++ b/hw/tpm/tpm_tis.h
@@ -18,23 +18,17 @@
 #define TPM_TPM_TIS_H
 
 #include "hw/isa/isa.h"
+#include "hw/acpi/tpm.h"
 #include "qemu-common.h"
 
-#define TPM_TIS_ADDR_BASE   0xFED4
-
 #define TPM_TIS_NUM_LOCALITIES  5 /* per spec */
 #define TPM_TIS_LOCALITY_SHIFT  12
 #define TPM_TIS_NO_LOCALITY 0xff
 
 #define TPM_TIS_IS_VALID_LOCTY(x)   ((x) < TPM_TIS_NUM_LOCALITIES)
 
-#define TPM_TIS_IRQ 5
-
 #define TPM_TIS_BUFFER_MAX  4096
 
-#define TYPE_TPM_TIS"tpm-tis"
-
-
 typedef enum {
 TPM_TIS_STATE_IDLE = 0,
 TPM_TIS_STATE_READY,
diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
new file mode 100644
index 000..792fcbf
--- /dev/null
+++ b/include/hw/acpi/tpm.h
@@ -0,0 +1,29 @@
+/*
+ * tpm.h - TPM ACPI definitions
+ *
+ * Copyright (C) 2014 IBM Corporation
+ *
+ * Authors:
+ *  Stefan Berger 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ * Implementation of the TIS interface according to specs found at
+ * http://www.trustedcomputinggroup.org
+ *
+ */
+#ifndef HW_ACPI_TPM_H
+#define HW_ACPI_TPM_H
+
+#define TPM_TIS_ADDR_BASE   0xFED4
+#define TPM_TIS_ADDR_SIZE   0x5000
+
+#define TPM_TIS_IRQ 5
+
+#define TPM_LOG_AREA_MINIMUM_SIZE   (64 * 1024)
+
+#define TPM_TCPA_ACPI_CLASS_CLIENT  0
+#define TPM_TCPA_ACPI_CLASS_SERVER  1
+
+#endif /* HW_ACPI_TPM_H */
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 13febdd..9b81ce9 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -20,4 +20,11 @@ int tpm_config_parse(QemuOptsList *opts_list, const char 
*optarg);
 int tpm_init(void);
 void tpm_cleanup(void);
 
+#define TYPE_TPM_TIS"tpm-tis"
+
+static inline bool tpm_find(void)
+{
+return object_resolve_path_type("", TYPE_TPM_TIS, NULL);
+}
+
 #endif /* QEMU_TPM_H */
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 10b84d0..85e5834 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -40,6 +40,8 @@
 #include "hw/loader.h"
 #include "hw/isa/isa.h"
 #include "hw/acpi/memory_hotplug.h"
+#include "sysemu/tpm.h"
+#include "hw/acpi/tpm.h"
 
 /* Supported chipsets: */
 #include "hw/acpi/piix4.h"
@@ -88,6 +90,7 @@ typedef struct AcpiPmInfo {
 
 typedef struct AcpiMiscInfo {
 bool has_hpet;
+bool has_tpm;
 DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
 const unsigned char *dsdt_code;
 unsigned dsdt_size;
@@ -210,6 +213,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
 static void acpi_get_misc_info(AcpiMiscInfo *info)
 {
 info->has_hpet = hpet_find();
+info->has_tpm = tpm_find();
 info->pvpanic_port = pvpanic_port();
 }
 
@@ -698,6 +702,7 @@ static inline char acpi_get_hex(uint32_t val)
 
 #include "hw/i386/ssdt-misc.hex"
 #include "hw/i386/ssdt-pcihp.hex"
+#include "hw/i386/ssdt-tpm.hex"
 
 static void
 build_append_notify_method(GArray *device, const char *name,
@@ -1201,6 +1206,39 @@ build_hpet(GArray *table_data, GArray *linker)
  (void *)hpet, "HPET", sizeof(*hpet), 1);
 }
 
+static void
+build_tpm_tcpa(GArray *table_data, GArray *linker)
+{
+Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
+/* the log area will come right after the TCPA table */
+uint64_t log_area_start_address = acpi_dat

[Qemu-devel] [PULL 01/11] hostmem: set MPOL_MF_MOVE

2014-08-24 Thread Michael S. Tsirkin
When memory is allocated on a wrong node, MPOL_MF_STRICT
doesn't move it - it just fails the allocation.
A simple way to reproduce the failure is with mlock=on
realtime feature.

The code comment actually says: "ensure policy won't be ignored"
so setting MPOL_MF_MOVE seems like a better way to do this.

Cc: qemu-sta...@nongnu.org
Signed-off-by: Michael S. Tsirkin 
---
 backends/hostmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/backends/hostmem.c b/backends/hostmem.c
index e7eec37..99e8f99 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -295,7 +295,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, 
Error **errp)
 /* ensure policy won't be ignored in case memory is preallocated
  * before mbind(). note: MPOL_MF_STRICT is ignored on hugepages so
  * this doesn't catch hugepage case. */
-unsigned flags = MPOL_MF_STRICT;
+unsigned flags = MPOL_MF_STRICT | MPOL_MF_MOVE;
 
 /* check for invalid host-nodes and policies and give more verbose
  * error messages than mbind(). */
-- 
MST




[Qemu-devel] [PULL 09/11] ioh3420: Remove obsoleted, unused ioh3420_init function

2014-08-24 Thread Michael S. Tsirkin
From: Knut Omang 

Signed-off-by: Knut Omang 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/pci-bridge/ioh3420.c | 24 
 1 file changed, 24 deletions(-)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index aed2bf1..e6674a1 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -157,30 +157,6 @@ static void ioh3420_exitfn(PCIDevice *d)
 pci_bridge_exitfn(d);
 }
 
-PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction,
- const char *bus_name, pci_map_irq_fn map_irq,
- uint8_t port, uint8_t chassis, uint16_t slot)
-{
-PCIDevice *d;
-PCIBridge *br;
-DeviceState *qdev;
-
-d = pci_create_multifunction(bus, devfn, multifunction, "ioh3420");
-if (!d) {
-return NULL;
-}
-br = PCI_BRIDGE(d);
-
-qdev = DEVICE(d);
-pci_bridge_map_irq(br, bus_name, map_irq);
-qdev_prop_set_uint8(qdev, "port", port);
-qdev_prop_set_uint8(qdev, "chassis", chassis);
-qdev_prop_set_uint16(qdev, "slot", slot);
-qdev_init_nofail(qdev);
-
-return PCIE_SLOT(d);
-}
-
 static Property ioh3420_props[] = {
 DEFINE_PROP_BIT(COMPAT_PROP_PCP, PCIDevice, cap_present,
 QEMU_PCIE_SLTCAP_PCP_BITNR, true),
-- 
MST




[Qemu-devel] [PULL 02/11] pci_bridge: manually destroy memory regions within PCIBridgeWindows

2014-08-24 Thread Michael S. Tsirkin
From: Paolo Bonzini 

The regions are destroyed and recreated on configuration space accesses.
We need to destroy them before the containing PCIBridgeWindows object
is freed.

Reported-by: Gonglei 
Reported-by: Knut Omang 
Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/pci/pci_bridge.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 1307265..40c97b1 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -219,6 +219,12 @@ static void pci_bridge_region_del(PCIBridge *br, 
PCIBridgeWindows *w)
 
 static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)
 {
+object_unparent(OBJECT(&w->alias_io));
+object_unparent(OBJECT(&w->alias_mem));
+object_unparent(OBJECT(&w->alias_pref_mem));
+object_unparent(OBJECT(&w->alias_vga[QEMU_PCI_VGA_IO_LO]));
+object_unparent(OBJECT(&w->alias_vga[QEMU_PCI_VGA_IO_HI]));
+object_unparent(OBJECT(&w->alias_vga[QEMU_PCI_VGA_MEM]));
 g_free(w);
 }
 
-- 
MST




[Qemu-devel] [PULL 03/11] pcihp: fix possible array out of bounds

2014-08-24 Thread Michael S. Tsirkin
From: Gonglei 

Prevent out-of-bounds array access on
acpi_pcihp_pci_status.

Signed-off-by: Gonglei 
Reviewed-by: Peter Crosthwaite 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Cc: qemu-sta...@nongnu.org
Reviewed-by: Marcel Apfelbaum 
---
 hw/acpi/pcihp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index fae663a..34dedf1 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, 
unsigned int size)
 uint32_t val = 0;
 int bsel = s->hotplug_select;
 
-if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) {
+if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
 return 0;
 }
 
-- 
MST




[Qemu-devel] [PULL 06/11] ssdt-tpm: add generated hex file to git

2014-08-24 Thread Michael S. Tsirkin
Needed for systems without IASL.

Signed-off-by: Michael S. Tsirkin 
---
 hw/i386/ssdt-tpm.hex.generated | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 hw/i386/ssdt-tpm.hex.generated

diff --git a/hw/i386/ssdt-tpm.hex.generated b/hw/i386/ssdt-tpm.hex.generated
new file mode 100644
index 000..4a916a8
--- /dev/null
+++ b/hw/i386/ssdt-tpm.hex.generated
@@ -0,0 +1,95 @@
+static unsigned char ssdt_tpm_aml[] = {
+0x53,
+0x53,
+0x44,
+0x54,
+0x5d,
+0x0,
+0x0,
+0x0,
+0x1,
+0xf,
+0x42,
+0x58,
+0x50,
+0x43,
+0x0,
+0x0,
+0x42,
+0x58,
+0x53,
+0x53,
+0x44,
+0x54,
+0x0,
+0x0,
+0x1,
+0x0,
+0x0,
+0x0,
+0x49,
+0x4e,
+0x54,
+0x4c,
+0x15,
+0x11,
+0x13,
+0x20,
+0x10,
+0x38,
+0x5c,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x5b,
+0x82,
+0x30,
+0x54,
+0x50,
+0x4d,
+0x5f,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xc,
+0x41,
+0xd0,
+0xc,
+0x31,
+0x8,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x11,
+0x11,
+0xa,
+0xe,
+0x86,
+0x9,
+0x0,
+0x1,
+0x0,
+0x0,
+0xd4,
+0xfe,
+0x0,
+0x50,
+0x0,
+0x0,
+0x79,
+0x0,
+0x14,
+0x9,
+0x5f,
+0x53,
+0x54,
+0x41,
+0x0,
+0xa4,
+0xa,
+0xf
+};
-- 
MST




[Qemu-devel] [PULL 10/11] ioh3420: Enable ARI forwarding

2014-08-24 Thread Michael S. Tsirkin
From: Knut Omang 

Signed-off-by: Knut Omang 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/pci-bridge/ioh3420.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index e6674a1..cce2fdd 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -85,6 +85,7 @@ static void ioh3420_reset(DeviceState *qdev)
 pcie_cap_root_reset(d);
 pcie_cap_deverr_reset(d);
 pcie_cap_slot_reset(d);
+pcie_cap_arifwd_reset(d);
 pcie_aer_root_reset(d);
 pci_bridge_reset(qdev);
 pci_bridge_disable_base_limit(d);
@@ -119,6 +120,7 @@ static int ioh3420_initfn(PCIDevice *d)
 goto err_msi;
 }
 
+pcie_cap_arifwd_init(d);
 pcie_cap_deverr_init(d);
 pcie_cap_slot_init(d, s->slot);
 pcie_chassis_create(s->chassis);
-- 
MST




[Qemu-devel] [PULL 08/11] pcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*

2014-08-24 Thread Michael S. Tsirkin
From: Knut Omang 

Rename helper functions to make a clearer distinction between
the PCIe capability/control register feature ARI forwarding and a
device that supports the ARI feature via an ARI extended PCIe capability.

Signed-off-by: Knut Omang 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 include/hw/pci/pcie.h  |  7 ---
 hw/pci-bridge/ioh3420.c|  1 +
 hw/pci-bridge/xio3130_downstream.c |  4 ++--
 hw/pci/pcie.c  | 11 ++-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index 7fe81f3..d139d58 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -103,9 +103,10 @@ void pcie_cap_flr_init(PCIDevice *dev);
 void pcie_cap_flr_write_config(PCIDevice *dev,
uint32_t addr, uint32_t val, int len);
 
-void pcie_cap_ari_init(PCIDevice *dev);
-void pcie_cap_ari_reset(PCIDevice *dev);
-bool pcie_cap_is_ari_enabled(const PCIDevice *dev);
+/* ARI forwarding capability and control */
+void pcie_cap_arifwd_init(PCIDevice *dev);
+void pcie_cap_arifwd_reset(PCIDevice *dev);
+bool pcie_cap_is_arifwd_enabled(const PCIDevice *dev);
 
 /* PCI express extended capability helper functions */
 uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id);
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index 7cd87fc..aed2bf1 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -118,6 +118,7 @@ static int ioh3420_initfn(PCIDevice *d)
 if (rc < 0) {
 goto err_msi;
 }
+
 pcie_cap_deverr_init(d);
 pcie_cap_slot_init(d, s->slot);
 pcie_chassis_create(s->chassis);
diff --git a/hw/pci-bridge/xio3130_downstream.c 
b/hw/pci-bridge/xio3130_downstream.c
index 51f20d7..b3a6479 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -50,7 +50,7 @@ static void xio3130_downstream_reset(DeviceState *qdev)
 
 pcie_cap_deverr_reset(d);
 pcie_cap_slot_reset(d);
-pcie_cap_ari_reset(d);
+pcie_cap_arifwd_reset(d);
 pci_bridge_reset(qdev);
 }
 
@@ -91,7 +91,7 @@ static int xio3130_downstream_initfn(PCIDevice *d)
 if (rc < 0) {
 goto err_pcie_cap;
 }
-pcie_cap_ari_init(d);
+pcie_cap_arifwd_init(d);
 rc = pcie_aer_init(d, XIO3130_AER_OFFSET);
 if (rc < 0) {
 goto err;
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index de0e967..6cb6e0c 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -497,9 +497,10 @@ void pcie_cap_flr_write_config(PCIDevice *dev,
 }
 }
 
-/* Alternative Routing-ID Interpretation (ARI) */
-/* ari forwarding support for down stream port */
-void pcie_cap_ari_init(PCIDevice *dev)
+/* Alternative Routing-ID Interpretation (ARI)
+ * forwarding support for root and downstream ports 
+ */
+void pcie_cap_arifwd_init(PCIDevice *dev)
 {
 uint32_t pos = dev->exp.exp_cap;
 pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_DEVCAP2,
@@ -508,13 +509,13 @@ void pcie_cap_ari_init(PCIDevice *dev)
PCI_EXP_DEVCTL2_ARI);
 }
 
-void pcie_cap_ari_reset(PCIDevice *dev)
+void pcie_cap_arifwd_reset(PCIDevice *dev)
 {
 uint8_t *devctl2 = dev->config + dev->exp.exp_cap + PCI_EXP_DEVCTL2;
 pci_long_test_and_clear_mask(devctl2, PCI_EXP_DEVCTL2_ARI);
 }
 
-bool pcie_cap_is_ari_enabled(const PCIDevice *dev)
+bool pcie_cap_is_arifwd_enabled(const PCIDevice *dev)
 {
 if (!pci_is_express(dev)) {
 return false;
-- 
MST




[Qemu-devel] [PULL 04/11] pc: reserve more memory for ACPI for new machine types

2014-08-24 Thread Michael S. Tsirkin
commit 868270f23d8db2cce83e4f082fe75e8625a5fbf9
acpi-build: tweak acpi migration limits
broke kernel loading with -kernel/-initrd: it doubled
the size of ACPI tables but did not reserve
enough memory.

As a result, issues on boot and halt are observed.

Fix this up by doubling reserved memory for new machine types.

Cc: qemu-sta...@nongnu.org
Reported-by: Stefan Hajnoczi 
Signed-off-by: Michael S. Tsirkin 
---
 include/hw/i386/pc.h |  2 ++
 hw/i386/pc.c | 12 +---
 hw/i386/pc_piix.c|  1 +
 hw/i386/pc_q35.c |  1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 0fca9e3..a39cb42 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -176,6 +176,8 @@ void pc_acpi_init(const char *default_dsdt);
 PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
 ram_addr_t above_4g_mem_size);
 
+void pc_set_legacy_acpi_data_size(void);
+
 #define PCI_HOST_PROP_PCI_HOLE_START   "pci-hole-start"
 #define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end"
 #define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start"
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 8fa8d2f..0ca4deb 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -73,7 +73,12 @@
 #endif
 
 /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables.  */
-#define ACPI_DATA_SIZE   0x1
+unsigned acpi_data_size = 0x2;
+void pc_set_legacy_acpi_data_size(void)
+{
+acpi_data_size = 0x1;
+}
+
 #define BIOS_CFG_IOPORT 0x510
 #define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0)
 #define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1)
@@ -811,8 +816,9 @@ static void load_linux(FWCfgState *fw_cfg,
 initrd_max = 0x37ff;
 }
 
-if (initrd_max >= max_ram_size-ACPI_DATA_SIZE)
-   initrd_max = max_ram_size-ACPI_DATA_SIZE-1;
+if (initrd_max >= max_ram_size - acpi_data_size) {
+initrd_max = max_ram_size - acpi_data_size - 1;
+}
 
 fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
 fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline)+1);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 47ac1b5..103d756 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -323,6 +323,7 @@ static void pc_compat_2_0(MachineState *machine)
 legacy_acpi_table_size = 6652;
 smbios_legacy_mode = true;
 has_reserved_memory = false;
+pc_set_legacy_acpi_data_size();
 }
 
 static void pc_compat_1_7(MachineState *machine)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 4b5a274..d4a907c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -280,6 +280,7 @@ static void pc_compat_2_0(MachineState *machine)
 {
 smbios_legacy_mode = true;
 has_reserved_memory = false;
+pc_set_legacy_acpi_data_size();
 }
 
 static void pc_compat_1_7(MachineState *machine)
-- 
MST




[Qemu-devel] [PULL 07/11] pcie: Fix incorrect write to the ari capability next function field

2014-08-24 Thread Michael S. Tsirkin
From: Knut Omang 

PCI_ARI_CAP_NFN, a macro for reading next function was used instead of
the intended write.

Signed-off-by: Knut Omang 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/pci/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index a123c01..de0e967 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -630,5 +630,5 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, 
uint16_t nextfn)
 {
 pcie_add_capability(dev, PCI_EXT_CAP_ID_ARI, PCI_ARI_VER,
 offset, PCI_ARI_SIZEOF);
-pci_set_long(dev->config + offset + PCI_ARI_CAP, PCI_ARI_CAP_NFN(nextfn));
+pci_set_long(dev->config + offset + PCI_ARI_CAP, (nextfn & 0xff) << 8);
 }
-- 
MST




[Qemu-devel] [PULL 11/11] pcie: fix trailing whitespace

2014-08-24 Thread Michael S. Tsirkin
Signed-off-by: Michael S. Tsirkin 
---
 hw/pci/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 6cb6e0c..1babddf 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -498,7 +498,7 @@ void pcie_cap_flr_write_config(PCIDevice *dev,
 }
 
 /* Alternative Routing-ID Interpretation (ARI)
- * forwarding support for root and downstream ports 
+ * forwarding support for root and downstream ports
  */
 void pcie_cap_arifwd_init(PCIDevice *dev)
 {
-- 
MST




Re: [Qemu-devel] [PATCH v2 4/4] ioh3420: Enable ARI forwarding

2014-08-24 Thread Michael S. Tsirkin
On Sun, Aug 24, 2014 at 03:32:20PM +0200, Knut Omang wrote:
> Signed-off-by: Knut Omang 

BTW pcie_cap_is_arifwd_enabled is still unused.
We really should use it to make ARI work properly, right?

> ---
>  hw/pci-bridge/ioh3420.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
> index e6674a1..cce2fdd 100644
> --- a/hw/pci-bridge/ioh3420.c
> +++ b/hw/pci-bridge/ioh3420.c
> @@ -85,6 +85,7 @@ static void ioh3420_reset(DeviceState *qdev)
>  pcie_cap_root_reset(d);
>  pcie_cap_deverr_reset(d);
>  pcie_cap_slot_reset(d);
> +pcie_cap_arifwd_reset(d);
>  pcie_aer_root_reset(d);
>  pci_bridge_reset(qdev);
>  pci_bridge_disable_base_limit(d);
> @@ -119,6 +120,7 @@ static int ioh3420_initfn(PCIDevice *d)
>  goto err_msi;
>  }
>  
> +pcie_cap_arifwd_init(d);
>  pcie_cap_deverr_init(d);
>  pcie_cap_slot_init(d, s->slot);
>  pcie_chassis_create(s->chassis);
> -- 
> 1.9.0



Re: [Qemu-devel] [PATCH v12 5/6] raw-posix: Add falloc and full preallocation option

2014-08-24 Thread Hu Tao
On Fri, Aug 22, 2014 at 12:58:23PM +0200, Kevin Wolf wrote:
> Am 11.07.2014 um 08:10 hat Hu Tao geschrieben:
> > This patch adds a new option preallocation for raw format, and implements
> > falloc and full preallocation.
> > 
> > Reviewed-by: Max Reitz 
> > Signed-off-by: Hu Tao 
> 
> raw-posix needs to error out if called with preallocation=metadata, it
> doesn't implement this option.

Yes.

> 
> Kevin



Re: [Qemu-devel] [PATCH v12 1/6] block: round up file size to nearest sector

2014-08-24 Thread Hu Tao
On Fri, Aug 22, 2014 at 12:55:51PM +0200, Kevin Wolf wrote:
> Am 11.07.2014 um 08:09 hat Hu Tao geschrieben:
> > Reviewed-by: Max Reitz 
> > Reviewed-by: Eric Blake 
> > Signed-off-by: Hu Tao 
> 
> If we make this change, shouldn't we do it consistently across all image
> formats? With this patch we have some formats that round up, and many
> others that round down.

We should.

> 
> Kevin



Re: [Qemu-devel] [PATCH v12 4/6] qapi: introduce PreallocMode and a new PreallocMode full.

2014-08-24 Thread Hu Tao
On Fri, Aug 22, 2014 at 12:57:15PM +0200, Kevin Wolf wrote:
> Am 11.07.2014 um 08:10 hat Hu Tao geschrieben:
> > This patch prepares for the subsequent patches.
> > 
> > Reviewed-by: Fam Zheng 
> > Reviewed-by: Eric Blake 
> > Reviewed-by: Max Reitz 
> > Signed-off-by: Hu Tao 
> 
> Strictly speaking, qcow2 should error out if it is given full or falloc
> after this patch. Two patches later it will actually interpret those
> values correctly, so it's not that big of a problem, but it would
> definitely be nicer.

Okay.

> 
> Kevin



Re: [Qemu-devel] [PATCH v2 3/4] target-openrisc: Add OpenCores keyboard device support

2014-08-24 Thread Jia Liu
Hi Valentin,

On Sat, Aug 23, 2014 at 1:05 AM, Valentin Manea
 wrote:
> Add support for the OpenCores keyboard device to the default OpenRisc
> machine.
>
> The OpenCores keyboard device is a simple open source keyboard device
> created by the OpenCores project(http://opencores.org/). By default it
> just forwards Linux like keycodes.
>
> Signed-off-by: Valentin Manea 
> ---
>  hw/openrisc/Makefile.objs  |   4 +-
>  hw/openrisc/ockbd.c| 165
> +
>  hw/openrisc/openrisc_sim.c |   3 +
>  3 files changed, 170 insertions(+), 2 deletions(-)
>  create mode 100644 hw/openrisc/ockbd.c
>
> diff --git a/hw/openrisc/Makefile.objs b/hw/openrisc/Makefile.objs
> index 1922a22..b907a40 100644
> --- a/hw/openrisc/Makefile.objs
> +++ b/hw/openrisc/Makefile.objs
> @@ -1,3 +1,3 @@
>  obj-y = pic_cpu.o cputimer.o
> -obj-y += openrisc_sim.o
> -obj-y += ocfb.o
> +obj-y += openrisc_sim.o
> +obj-y += ockbd.o ocfb.o

I think here should be look like this, or it will make a *.rej and
make patch failed.

obj-y = pic_cpu.o cputimer.o
obj-y += openrisc_sim.o
-obj-y += ocfb.o
+obj-y += ockbd.o ocfb.o

> diff --git a/hw/openrisc/ockbd.c b/hw/openrisc/ockbd.c
> new file mode 100644
> index 000..64a6505
> --- /dev/null
> +++ b/hw/openrisc/ockbd.c
> @@ -0,0 +1,165 @@
> +/*
> + * OpenCores Keyboard device
> + *
> + * Copyright (c) 2014 Valentin Manea
> + * Based on work by Sebastian Macke for jor1k http://s-macke.github.io/jor1k/
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "ui/console.h"
> +
> +#define TYPE_OCKB "ockb"
> +#define OCKB(obj) OBJECT_CHECK(OCKBState, (obj), TYPE_OCKB)
> +
> +#ifdef DEBUG
> +#define DPRINTF(fmt, ...)\
> +do { printf("ockb: " fmt , ## __VA_ARGS__); } while (0)
> +#else
> +#define DPRINTF(fmt, ...)
> +#endif
> +
> +typedef struct OCKBState {
> +SysBusDevice parent_obj;
> +
> +MemoryRegion iomem;
> +qemu_irq irq;
> +uint8_t data[16];
> +uint32_t rptr, wptr, count;
> +} OCKBState;
> +
> +
> +static void ockb_keycode(void *opaque, int keycode)
> +{
> +OCKBState *s = (OCKBState *) opaque;
> +/* The keycodes the driver expects are exactly the
> +   same as we receive them */
> +if (s->count < sizeof(s->data)) {
> +s->data[s->wptr] = keycode;
> +if (++s->wptr == sizeof(s->data)) {
> +s->wptr = 0;
> +}
> +s->count++;
> +}
> +qemu_irq_raise(s->irq);
> +}
> +
> +static uint64_t ockb_read(void *opaque, hwaddr offset,
> + unsigned size)
> +{
> +OCKBState *s = (OCKBState *) opaque;
> +int keycode;
> +
> +
> +if (offset >= 0x4) {
> +return 0;
> +}
> +
> +DPRINTF("read offset %u\n", (uint32_t)offset);
> +if (s->count == 0) {
> +qemu_irq_lower(s->irq);
> +return 0;
> +}
> +
> +keycode = s->data[s->rptr];
> +if (++s->rptr == sizeof(s->data)) {
> +s->rptr = 0;
> +}
> +s->count--;
> +
> +return keycode;
> +}
> +
> +static void ockb_write(void *opaque, hwaddr offset,
> +  uint64_t value, unsigned size)
> +{
> +/* Don't actually expect any write but don't fail */
> +DPRINTF("read offset %u\n", (uint32_t)offset);
> +}
> +
> +static const MemoryRegionOps ockb_ops = {
> +.read = ockb_read,
> +.write = ockb_write,
> +.endianness = DEVICE_NATIVE_ENDIAN,
> +};
> +
> +static int ockb_initfn(SysBusDevice *sbd)
> +{
> +DeviceState *dev = DEVICE(sbd);
> +OCKBState *s = OCKB(dev);
> +
> +memory_region_init_io(&s->iomem, OBJECT(s), &ockb_ops, s, "ockb", 0x100);
> +sysbus_init_mmio(sbd, &s->iomem);
> +sysbus_init_irq(sbd, &s->irq);
> +
> +qemu_add_kbd_event_handler(ockb_keycode, s);
> +
> +return 0;
> +}
> +
> +
> +static const VMStateDescri

Re: [Qemu-devel] [PATCH v12 0/6] qcow2, raw: add preallocation=full and preallocation=falloc

2014-08-24 Thread Hu Tao
On Fri, Aug 22, 2014 at 12:54:29PM +0200, Kevin Wolf wrote:
> Am 28.07.2014 um 10:48 hat Hu Tao geschrieben:
> > ping...
> > 
> > All the 6 patches have reviewed-by now.
> 
> Looks mostly good to me, I have only a few minor comments that wouldn't
> block inclusion but could be addressed in follow-up patches.
> 
> However, you have a dependency on a patch series from Max (you use
> minimal_blob_size()), which hasn't been reviewed and merged yet, so your
> series is blocked on that.
> 
> If you want to get your series merged quicker, you could replace this
> with a rough estimate that excludes the clusters used by refcount table
> and blocks. If full preallocation isn't really full, but only
> preallocation of 99.9%, that's probably good enough in practice.

How about my calculation in v10?
https://lists.nongnu.org/archive/html/qemu-devel/2014-06/msg02844.html

It doesn't depend on minimal_blob_size(). In most cases the calculated
size is the same as the size before this patch. I have no test results
on hand, but if you need I can do it.

Regards,
Hu



Re: [Qemu-devel] [PATCH v2 4/4] target-openrisc: Add LPC32XX touchscreen device

2014-08-24 Thread Jia Liu
Hi Valentin,


On Sat, Aug 23, 2014 at 1:06 AM, Valentin Manea
 wrote:
> The LPC32XX is a simple MMIO touch screen device with a Linux device
> driver. The device is suitable for small machines which require mouse
> input but have no suitable bus(SPI, I2C).
>
> Add the LPC32XX device to the default OpenRisc machine.
>
> Signed-off-by: Valentin Manea 
> ---
>  default-configs/or32-softmmu.mak |   1 +
>  hw/input/Makefile.objs   |   1 +
>  hw/input/lpc32xx.c   | 274
> +++
>  hw/openrisc/openrisc_sim.c   |   3 +
>  4 files changed, 279 insertions(+)
>  create mode 100644 hw/input/lpc32xx.c
>
> diff --git a/default-configs/or32-softmmu.mak
> b/default-configs/or32-softmmu.mak
> index 0e17a43..6e42d7e 100644
> --- a/default-configs/or32-softmmu.mak
> +++ b/default-configs/or32-softmmu.mak
> @@ -6,3 +6,4 @@ CONFIG_IDE_CORE=y
>  CONFIG_IDE_QDEV=y
>  CONFIG_IDE_MMIO=y
>  CONFIG_FRAMEBUFFER=y
> +CONFIG_LPC32XX=y
> diff --git a/hw/input/Makefile.objs b/hw/input/Makefile.objs
> index e8c80b9..7b9b055 100644
> --- a/hw/input/Makefile.objs
> +++ b/hw/input/Makefile.objs
> @@ -11,3 +11,4 @@ common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
>  obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
>  obj-$(CONFIG_PXA2XX) += pxa2xx_keypad.o
>  obj-$(CONFIG_TSC210X) += tsc210x.o
> +obj-$(CONFIG_LPC32XX) += lpc32xx.o
> diff --git a/hw/input/lpc32xx.c b/hw/input/lpc32xx.c
> new file mode 100644
> index 000..fbf68bc
> --- /dev/null
> +++ b/hw/input/lpc32xx.c
> @@ -0,0 +1,274 @@
> +/*
> + * OpenCores framebuffer device
> + *
> + * Copyright (c) 2014 Valentin Manea
> + * Based on work by Sebastian Macke for jor1k http://s-macke.github.io/jor1k/
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "hw/devices.h"
> +#include "ui/console.h"
> +#include "ui/input.h"
> +#include "qemu/timer.h"
> +
> +/*
> + * Touchscreen controller register offsets
> + */
> +#define LPC32XX_TSC_STAT0x00
> +#define LPC32XX_TSC_SEL 0x04
> +#define LPC32XX_TSC_CON 0x08
> +#define LPC32XX_TSC_FIFO0x0C
> +#define LPC32XX_TSC_DTR 0x10
> +#define LPC32XX_TSC_RTR 0x14
> +#define LPC32XX_TSC_UTR 0x18
> +#define LPC32XX_TSC_TTR 0x1C
> +#define LPC32XX_TSC_DXP 0x20
> +#define LPC32XX_TSC_MIN_X   0x24
> +#define LPC32XX_TSC_MAX_X   0x28
> +#define LPC32XX_TSC_MIN_Y   0x2C
> +#define LPC32XX_TSC_MAX_Y   0x30
> +#define LPC32XX_TSC_AUX_UTR 0x34
> +#define LPC32XX_TSC_AUX_MIN 0x38
> +#define LPC32XX_TSC_AUX_MAX 0x3C
> +
> +#define LPC32XX_TSC_STAT_FIFO_OVRRN (1 << 8)
> +#define LPC32XX_TSC_STAT_FIFO_EMPTY (1 << 7)
> +#define LPC32XX_TSC_FIFO_TS_P_LEVEL (1 << 31)
> +
> +#define LPC32XX_TSC_ADCCON_POWER_UP (1 << 2)
> +#define LPC32XX_TSC_ADCCON_AUTO_EN  (1 << 0)
> +
> +#define LPC32XX_TSC_FIFO_TS_P_LEVEL(1 << 31)
> +
> +#define LPC32XX_TSC_ADCDAT_VALUE_MASK  0x03FF
> +#define LPC32XX_TSC_FIFO_X_VAL(x)(((LPC32XX_TSC_ADCDAT_VALUE_MASK - x) & 
> \
> +  LPC32XX_TSC_ADCDAT_VALUE_MASK) << 16)
> +#define LPC32XX_TSC_FIFO_Y_VAL(y)((LPC32XX_TSC_ADCDAT_VALUE_MASK - y) & \
> +  LPC32XX_TSC_ADCDAT_VALUE_MASK)
> +
> +
> +#define LPC32XX_TSC_MIN_XY_VAL  0x0
> +#define LPC32XX_TSC_MAX_XY_VAL  0x3FF
> +
> +
> +#define TYPE_LPC32XX "lpc32xx"
> +#define LPC32XX(obj) OBJECT_CHECK(LPC32XXState, (obj), TYPE_LPC32XX)
> +
> +
> +#ifdef DEBUG
> +#define DPRINTF(fmt, ...)\
> +do { printf("lpc32xx: " fmt , ## __VA_ARGS__); } while (0)
> +#else
> +#define DPRINTF(fmt, ...)
> +#endif
> +
> +
> +typedef struct LPC32XXState {
> +SysBusDevice parent_obj;
> +
> +MemoryRegion iomem

Re: [Qemu-devel] [PATCH v12 6/6] qcow2: Add falloc and full preallocation option

2014-08-24 Thread Hu Tao
On Fri, Aug 22, 2014 at 01:00:53PM +0200, Kevin Wolf wrote:
> Am 11.07.2014 um 08:10 hat Hu Tao geschrieben:
> > This adds preallocation=falloc and preallocation=full mode to qcow2
> > image creation.
> > 
> > preallocation=full allocates disk space by writing zeros to disk to
> > ensure disk space in any cases.
> > 
> > preallocation=falloc likes preallocation=full, but allocates disk space
> > by posix_fallocate().
> > 
> > Signed-off-by: Hu Tao 
> > ---
> >  block/qcow2.c  | 31 --
> >  tests/qemu-iotests/082.out | 54 
> > +++---
> >  2 files changed, 56 insertions(+), 29 deletions(-)
> > 
> > diff --git a/block/qcow2.c b/block/qcow2.c
> > index cfba93b..f48e915 100644
> > --- a/block/qcow2.c
> > +++ b/block/qcow2.c
> > @@ -1593,6 +1593,9 @@ static int preallocate(BlockDriverState *bs)
> >  return 0;
> >  }
> >  
> > +static uint64_t minimal_blob_size(uint64_t ts, int cb, int spcb,
> > +  uint64_t overhead);
> > +
> >  static int qcow2_create2(const char *filename, int64_t total_size,
> >   const char *backing_file, const char 
> > *backing_format,
> >   int flags, size_t cluster_size, PreallocMode 
> > prealloc,
> > @@ -1628,6 +1631,29 @@ static int qcow2_create2(const char *filename, 
> > int64_t total_size,
> >  Error *local_err = NULL;
> >  int ret;
> >  
> > +if (prealloc == PREALLOC_MODE_FULL || prealloc == 
> > PREALLOC_MODE_FALLOC) {
> > +int64_t meta_size = 0;
> > +uint64_t nl2e;
> > +
> > +total_size = align_offset(total_size, cluster_size);
> 
> I don't think it's a good idea to let the virtual disk size depend on
> whether preallocation is enabled or not. You should always get the same
> rounding (which is rounding up to the next sector boundary).
> 
> Do you need full clusters for your calculations below or what is this
> good for? If so, please use a local variable and leave the value used
> for the bdrv_truncate() call unmodified.

Yes, it is for the calculation. I'll use a local variable for it.

Regards,
Hu



[Qemu-devel] [PATCH trivial v2] Fix debug print warning

2014-08-24 Thread arei.gonglei
From: Gonglei 

Steps:

1.enable qemu debug print, using simply scprit as below:
 grep "//#define DEBUG" * -rl | xargs sed -i "s/\/\/#define DEBUG/#define 
DEBUG/g"
2. make -j
3. get some warning:
hw/i2c/pm_smbus.c: In function 'smb_ioport_writeb':
hw/i2c/pm_smbus.c:142: warning: format '%04x' expects type 'unsigned int', but 
argument 2 has type 'hwaddr'
hw/i2c/pm_smbus.c:142: warning: format '%02x' expects type 'unsigned int', but 
argument 3 has type 'uint64_t'
hw/i2c/pm_smbus.c: In function 'smb_ioport_readb':
hw/i2c/pm_smbus.c:209: warning: format '%04x' expects type 'unsigned int', but 
argument 2 has type 'hwaddr'
hw/intc/i8259.c: In function 'pic_ioport_read':
hw/intc/i8259.c:373: warning: format '%02x' expects type 'unsigned int', but 
argument 2 has type 'hwaddr'
hw/input/pckbd.c: In function 'kbd_write_command':
hw/input/pckbd.c:232: warning: format '%02x' expects type 'unsigned int', but 
argument 2 has type 'uint64_t'
hw/input/pckbd.c: In function 'kbd_write_data':
hw/input/pckbd.c:333: warning: format '%02x' expects type 'unsigned int', but 
argument 2 has type 'uint64_t'
hw/isa/apm.c: In function 'apm_ioport_writeb':
hw/isa/apm.c:44: warning: format '%x' expects type 'unsigned int', but argument 
2 has type 'hwaddr'
hw/isa/apm.c:44: warning: format '%02x' expects type 'unsigned int', but 
argument 3 has type 'uint64_t'
hw/isa/apm.c: In function 'apm_ioport_readb':
hw/isa/apm.c:67: warning: format '%x' expects type 'unsigned int', but argument 
2 has type 'hwaddr'
hw/timer/mc146818rtc.c: In function 'cmos_ioport_write':
hw/timer/mc146818rtc.c:394: warning: format '%02x' expects type 'unsigned int', 
but argument 3 has type 'uint64_t'
hw/i386/pc.c: In function 'port92_write':
hw/i386/pc.c:479: warning: format '%02x' expects type 'unsigned int', but 
argument 2 has type 'uint64_t'

Fix them.

Cc: qemu-triv...@nongnu.org
Signed-off-by: Gonglei 
---
v2: using HWADDR_PRIx instead of PRIx64 for hwaddr variable suggested by Peter.
---
 hw/i2c/pm_smbus.c  | 5 +++--
 hw/i386/pc.c   | 2 +-
 hw/input/pckbd.c   | 4 ++--
 hw/intc/i8259.c| 2 +-
 hw/isa/apm.c   | 5 +++--
 hw/timer/mc146818rtc.c | 2 +-
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index fedb5fb..ce1713d 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -139,7 +139,8 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr, 
uint64_t val,
 {
 PMSMBus *s = opaque;
 
-SMBUS_DPRINTF("SMB writeb port=0x%04x val=0x%02x\n", addr, val);
+SMBUS_DPRINTF("SMB writeb port=0x%04" HWADDR_PRIx
+  " val=0x%02" PRIx64 "\n", addr, val);
 switch(addr) {
 case SMBHSTSTS:
 s->smb_stat = (~(val & 0xff)) & s->smb_stat;
@@ -206,7 +207,7 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, 
unsigned width)
 val = 0;
 break;
 }
-SMBUS_DPRINTF("SMB readb port=0x%04x val=0x%02x\n", addr, val);
+SMBUS_DPRINTF("SMB readb port=0x%04" HWADDR_PRIx " val=0x%02x\n", addr, 
val);
 return val;
 }
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 8fa8d2f..0b1ab1f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -476,7 +476,7 @@ static void port92_write(void *opaque, hwaddr addr, 
uint64_t val,
 Port92State *s = opaque;
 int oldval = s->outport;
 
-DPRINTF("port92: write 0x%02x\n", val);
+DPRINTF("port92: write 0x%02" PRIx64 "\n", val);
 s->outport = val;
 qemu_set_irq(*s->a20_out, (val >> 1) & 1);
 if ((val & 1) && !(oldval & 1)) {
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index ca1cffc..2ab8c87 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -229,7 +229,7 @@ static void kbd_write_command(void *opaque, hwaddr addr,
 {
 KBDState *s = opaque;
 
-DPRINTF("kbd: write cmd=0x%02x\n", val);
+DPRINTF("kbd: write cmd=0x%02" PRIx64 "\n", val);
 
 /* Bits 3-0 of the output port P2 of the keyboard controller may be pulsed
  * low for approximately 6 micro seconds. Bits 3-0 of the KBD_CCMD_PULSE
@@ -330,7 +330,7 @@ static void kbd_write_data(void *opaque, hwaddr addr,
 {
 KBDState *s = opaque;
 
-DPRINTF("kbd: write data=0x%02x\n", val);
+DPRINTF("kbd: write data=0x%02" PRIx64 "\n", val);
 
 switch(s->write_cmd) {
 case 0:
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index a563b82..c51901b 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -370,7 +370,7 @@ static uint64_t pic_ioport_read(void *opaque, hwaddr addr,
 ret = s->imr;
 }
 }
-DPRINTF("read: addr=0x%02x val=0x%02x\n", addr, ret);
+DPRINTF("read: addr=0x%02" HWADDR_PRIx " val=0x%02x\n", addr, ret);
 return ret;
 }
 
diff --git a/hw/isa/apm.c b/hw/isa/apm.c
index 054d529..26ab170 100644
--- a/hw/isa/apm.c
+++ b/hw/isa/apm.c
@@ -41,7 +41,8 @@ static void apm_ioport_writeb(void *opaque, hwaddr addr, 
uint64_t val,
 {
 APMState *apm = opaque;
 addr &= 1;
-APM_DPRINTF("apm_ioport_writeb addr=0x%x val=0x%02x\n", addr, val);
+ 

Re: [Qemu-devel] [PATCH v6 0/2] add read-pattern for block qourum

2014-08-24 Thread Liu Yuan
On Mon, Aug 18, 2014 at 05:41:03PM +0800, Liu Yuan wrote:
> v6:
>  - fix a unused warning introduced by last version
> 

Hi Stefan and Kevin,

   Benoît Canet has added Reviewed-by tag to both patches, could one of you pick
this patch set?

Thanks
Yuan



Re: [Qemu-devel] [question] e1000 interrupt storm happened because of its corresponding ioapic->irr bit always set

2014-08-24 Thread Jason Wang
On 08/23/2014 06:36 PM, Zhang Haoyu wrote:
> Hi, all
>
> I use a qemu-1.4.1/qemu-2.0.0 to run win7 guest, and encounter e1000 NIC 
> interrupt storm, 
> because "if (!ent->fields.mask && (ioapic->irr & (1 << i)))" is always true 
> in __kvm_ioapic_update_eoi().
>
> Any ideas?

We meet this several times: search the autoneg patches for an example of
workaround for this in qemu, and patch kvm: ioapic: conditionally delay
irq delivery during eoi broadcast for an workaround in kvm (rejected).

That was probably caused by something wrong in e1000 emulation which
causes interrupt to be injected into windows guest before its interrupt
handler is registered. And Windows guest does not have a mechanism to
detect and disable irq in such condition.

e1000 emulation is far from stable and complete (e.g run e1000 ethtool
selftest in linux guest may see lots of errors). It's complicate and
subtle (even has undocumented registers and behaviour). You should
better consider to use virtio which are more stable and fast in a kvm
guest (unless some intel guys are involved to improve e1000 emulation).

Thanks
>
> Thanks,
> Zhang Haoyu
>
>




Re: [Qemu-devel] [bisected] VNC server can't get all sent chars correctly

2014-08-24 Thread Gonglei (Arei)
Hi,

> From: Michael Tokarev [mailto:m...@tls.msk.ru]
> Sent: Saturday, August 23, 2014 4:56 PM
> To: qemu-devel
> Cc: Gerd Hoffmann; Gonglei (Arei); 758...@bugs.debian.org; Gabriele
> Giacone
> Subject: [bisected] VNC server can't get all sent chars correctly
> 
> There's a bug filed against debian qemu package, there:
> 
>  http://bugs.debian.org/758881
> 
> which says about problems sending keypress events over VNC to
> a qemu guest, -- some keypresses gets lost, at least.
> 
> The bisection between qemu 2.0 and 2.1 leads to this commit:
> 
> commit 2858ab09e6f708e381fc1a1cc87e747a690c4884
> Author: Gonglei 
> Date:   Thu Apr 24 20:06:19 2014 +0800
> 
> ps2: set ps/2 output buffer size as the same as kernel
> 
> According to the PS/2 Mouse/Keyboard Protocol, the keyboard outupt
> buffer size
> is 16 bytes. And the PS2_QUEUE_SIZE 256 was introduced in Qemu from
> the very
> beginning.
> 
> When I started a  redhat5.6 32bit guest, meanwhile tapped the keyboard
> as quickly as
> possible, the screen would show me "i8042.c: No controller found". As a
> result,
> I couldn't use the keyboard in the VNC client.
> 
> Previous discussion about the issue in maillist:
> 
> http://thread.gmane.org/gmane.comp.emulators.qemu/43294/focus=47180
> 
> This patch has been tested on redhat5.6 32-bit/suse11sp3 64-bit guests.
> More easy meathod to reproduce:
> 1.boot a guest with libvirt.
> 2.connect to VNC client.
> 3.as you see the BIOS, bootloader, Linux booting, run the follow simply
> shell script:
> for((i=0;i<1000;i++)) do virsh send-key redhat5.6 KEY_A; done
> 
> Actual results:
> dmesg show "i8042.c: No controller found." And the keyboard is out of
> work.
> 
> Signed-off-by: Gonglei 
> Reviewed-by: Juan Quintela 
> Signed-off-by: Gerd Hoffmann 
> 
> 
> So it looks like something else is not right here.  Before this patch,
> it wasn't possible to use keyboard with VNC client with redhat 5 guest.
> Now, it isn't possible to use keyboard with VNC in another scenario which
> worked before (so it is a regression compared with 2.0 version).
> 
> What do we do with this? :)
> 
I tested the same command line with the reported Bug, as below: 

./qemu-system-x86_64 -vnc :10 -enable-kvm -cpu host -m 1024 --kernel \
/home/linux --initrd /home/initrd.gz --append "locale=en_US keymap=us \ 
video=vesa:ywrap,mtrr vga=788"

And the VNC client I tested are TightVNC and RealVNC.

But I could not reproduce this issue.

So, I think maybe vncdotool client once send too many characters
(and ps2 queue length > PS2_QUEUE_SIZE), which leading to some 
characters are discarded by QEMU. More test cases will be useful IMHO.

Best regards,
-Gonglei


Re: [Qemu-devel] [PATCH v2] monitor: fix debug print compiling error

2014-08-24 Thread Gonglei (Arei)
Hi,

Cc'ing qemu-trivial. Please consider receiving, thanks.


Best regards,
-Gonglei


> -Original Message-
> From: Gonglei (Arei)
> Sent: Thursday, August 21, 2014 9:03 PM
> To: qemu-devel@nongnu.org
> Cc: lcapitul...@redhat.com; Huangweidong (C); peter.crosthwa...@xilinx.com;
> Gonglei (Arei)
> Subject: [PATCH v2] monitor: fix debug print compiling error
> 
> From: Gonglei 
> 
> error: 'i' undeclared (first use in this function)
> 
> Signed-off-by: Gonglei 
> ---
> v2:
>  avoid to mix code and declarations, add a pair of {}, thanks Peter.
> ---
>  monitor.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 34cee74..667efb7 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4747,8 +4747,11 @@ static void monitor_find_completion(void *opaque,
>  return;
>  }
>  #ifdef DEBUG_COMPLETION
> -for (i = 0; i < nb_args; i++) {
> -monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);
> +{
> +int i;
> +for (i = 0; i < nb_args; i++) {
> +monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);
> +}
>  }
>  #endif
> 
> --
> 1.7.12.4
> 




Re: [Qemu-devel] [RESEND v2 0/3] Fix some memory leaks about query memdev

2014-08-24 Thread chen.fan.f...@cn.fujitsu.com
ping...

This patches have been reviewed-by, only need someone ack it.

Thanks,
Chen

On Mon, 2014-08-18 at 14:46 +0800, Chen Fan wrote: 
> when using valgrind to test the command "query memdev", I had
> found some memory leaks. the test result:
> 
> ==13802== 4 bytes in 1 blocks are definitely lost in loss record 125 of 8,508
> ==13802==at 0x4A08934: malloc (vg_replace_malloc.c:291)
> ==13802==by 0x4A08AA8: realloc (vg_replace_malloc.c:687)
> ==13802==by 0x64C5736: g_realloc (in /usr/lib64/libglib-2.0.so.0.3400.2)
> ==13802==by 0x64DE226: ??? (in /usr/lib64/libglib-2.0.so.0.3400.2)
> ==13802==by 0x64DE279: g_string_sized_new (in 
> /usr/lib64/libglib-2.0.so.0.3400.2)
> ==13802==by 0x47CFBB: string_output_visitor_new 
> (string-output-visitor.c:341)
> ==13802==by 0x3F456F: object_property_get_uint16List (object.c:970)
> ==13802==by 0x1E8764: query_memdev (numa.c:361)
> ==13802==by 0x3F3248: object_child_foreach (object.c:686)
> ==13802==by 0x1E9141: qmp_query_memdev (numa.c:389)
> ==13802==by 0x2D79A0: qmp_marshal_input_query_memdev (qmp-marshal.c:5057)
> ==13802==by 0x1DD7D7: handle_qmp_command (monitor.c:5038)
> 
> ==15046== 48 (16 direct, 32 indirect) bytes in 1 blocks are definitely lost 
> in loss record 4,722 of 8,549
> ==15046==at 0x4A08934: malloc (vg_replace_malloc.c:291)
> ==15046==by 0x64C541D: ??? (in /usr/lib64/libglib-2.0.so.0.3400.2)
> ==15046==by 0x64C56E6: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.3400.2)
> ==15046==by 0x1E868C: query_memdev (numa.c:325)
> ==15046==by 0x3F3258: object_child_foreach (object.c:686)
> ==15046==by 0x1E9141: qmp_query_memdev (numa.c:389)
> ==15046==by 0x2DDFF3: hmp_info_memdev (hmp.c:1687)
> ==15046==by 0x1E4B08: handle_user_command (monitor.c:4119)
> ==15046==by 0x1E4E7A: monitor_command_cb (monitor.c:5156)
> ==15046==by 0x496056: readline_handle_byte (readline.c:391)
> ==15046==by 0x1E4BCE: monitor_read (monitor.c:5139)
> ==15046==by 0x2BCDEF: fd_chr_read (qemu-char.c:213)
> 
> 
> Chen Fan (3):
>   query-memdev: fix potential memory leaks
>   qom/object.c: fix string_output_get_string() memory leak
>   hmp: fix MemdevList memory leak
> 
>  hmp.c|  8 ++--
>  numa.c   | 15 +++
>  qom/object.c | 12 ++--
>  3 files changed, 23 insertions(+), 12 deletions(-)
> 



[Qemu-devel] [PATCH 3/6] device_tree.c: Format a blob in memory as dts stream and dump to a file.

2014-08-24 Thread john.liuli
From: Li Liu 

The outputed stream format is compatile with
'dtc -I dtb -O dts xxx.dtb'.

Signed-off-by: Li Liu 
---
 device_tree.c |   80 +
 1 file changed, 80 insertions(+)

diff --git a/device_tree.c b/device_tree.c
index 14d4015..1e407d2 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -416,3 +416,83 @@ static void dts_write_data(FILE *fp, const char *data, int 
len)
 fprintf(fp, "]");
 }
 }
+
+static void dts_write_prefix(FILE *fp, int depth)
+{
+int i;
+
+for (i = 0; i < depth; i++) {
+fprintf(fp, "%c", '\t');
+}
+}
+
+#define PALIGN(p, a) ((void *)(QEMU_ALIGN_UP((unsigned long)(p), (a
+#define GET_CELL(p)  (p += 4, *((const uint32_t *)(p - 4)))
+
+static void qemu_write_dts(FILE *fp, void *fdt)
+{
+const char *p, *name, *data;
+uint32_t tag;
+int len, num, depth = 0;
+int i;
+
+const char *fdt_struct = (const char *)fdt + fdt_off_dt_struct(fdt);
+const char *fdt_strings = (const char *)fdt + fdt_off_dt_strings(fdt);
+
+fprintf(fp, "/dts-v1/;\n");
+
+num = fdt_num_mem_rsv(fdt);
+fprintf(fp, "%s", num ? "\n" : "");
+for (i = 0; i < num; i++) {
+uint64_t addr, size;
+
+fdt_get_mem_rsv(fdt, i, &addr, &size);
+fprintf(fp, "/memreserve/\t0x%016llx 0x%016llx;\n",
+(unsigned long long)addr, (unsigned long long)size);
+}
+
+p = fdt_struct;
+while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
+if (tag == FDT_BEGIN_NODE) {
+name = p;
+p = PALIGN(p + strlen(name) + 1, 4);
+if (*name == '\0') {
+name = "/";
+}
+
+fprintf(fp, "\n");
+dts_write_prefix(fp, depth);
+fprintf(fp, "%s {\n", name);
+
+depth++;
+continue;
+}
+
+if (tag == FDT_END_NODE) {
+depth--;
+
+dts_write_prefix(fp, depth);
+fprintf(fp, "};\n");
+continue;
+}
+
+if (tag == FDT_NOP) {
+continue;
+}
+
+if (tag != FDT_PROP) {
+fprintf(stderr, "FDT: Unknown tag 0x%08x\n", tag);
+break;
+}
+
+len = fdt32_to_cpu(GET_CELL(p));
+name = fdt_strings + fdt32_to_cpu(GET_CELL(p));
+data = p;
+p = PALIGN(p + len, 4);
+
+dts_write_prefix(fp, depth);
+fprintf(fp, "%s", name);
+dts_write_data(fp, data, len);
+fprintf(fp, ";\n");
+}
+}
-- 
1.7.9.5





[Qemu-devel] [PATCH 1/6] device_tree.c: Introduce a function to check multiple strings for dts

2014-08-24 Thread john.liuli
From: Li Liu 

dts property's value can be multiple strings. So introduce a function
to check a data with a given length to see if it is all printable and
has a valid terminator. It can contain either a single string, or
multiple strings each of non-zero length.

Signed-off-by: Li Liu 
---
 device_tree.c |   32 
 1 file changed, 32 insertions(+)

diff --git a/device_tree.c b/device_tree.c
index ca83504..29d9acc 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -345,3 +345,35 @@ int qemu_fdt_setprop_sized_cells_from_array(void *fdt,
 return qemu_fdt_setprop(fdt, node_path, property, propcells,
 cellnum * sizeof(uint32_t));
 }
+
+/*
+ * Check a data of a given length to see if it is all printable and
+ * has a valid terminator. The data can contain either a single string,
+ * or multiple strings each of non-zero length.
+ */
+static int dts_is_printable_strings(const void *data, int len)
+{
+const char *str = (char *)data;
+int substrs = 0;
+int substr_len = 0;
+int i;
+
+for (i = 0; i < len; i++) {
+if (str[i] == '\0') {
+if (substr_len) {
+substr_len = 0;
+substrs++;
+continue;
+} else {
+/* substr is empty */
+return 0;
+}
+} else if (isprint(str[i])) {
+substr_len++;
+} else {
+return 0;
+}
+}
+
+return substrs && !substr_len;
+}
-- 
1.7.9.5





[Qemu-devel] [PATCH 0/6] add dumpdts ability to convert dtb to dts

2014-08-24 Thread john.liuli
From: Li Liu 

This patchset let qemu can convert dtb file to dts for two demands:

Some archtectures may generate the dtb file dynamically through
qemu device tree functions. So this let it's possiable to dump final
dtb to dts and save it as a reference.

For novices to debugging the issues caused by wrong dtb parameters.
It will be easy to check the dts directly without copying the
dtb which may be generated by 'dumpdtb' to the PC and dtc or fdtdump
it.

The outputed dts format is compatile with 'dtc -I dtb -O dts xxx.dtb'.
There's a new parameter 'dumpdts' which is similar to 'dumpdtb'. so try
it like '-machine dumpdts=/tmp/xxx.dts'.

Li Liu (6):
  device_tree.c: Introduce a function to check multiple strings for dts
  device_tree.c: dump three kind data types of dts to a file desciptor
  device_tree.c: Format a blob in memory as dts stream and dump to a
file.
  device_tree.c: add the main function to analyse the parameter
'dumpdts'
  machine: add 'dumpdts' parameter to 'machine' optslist.
  arm: Allow dumping generated dtb to dts file

 device_tree.c|  172 ++
 hw/arm/boot.c|1 +
 include/sysemu/device_tree.h |1 +
 vl.c |4 +
 4 files changed, 178 insertions(+)

-- 
1.7.9.5





[Qemu-devel] [PATCH 2/6] device_tree.c: dump three kind data types of dts to a file desciptor

2014-08-24 Thread john.liuli
From: Li Liu 

dump three kind data types 'strings', 'cell' and 'bytes' of dts
to a file desciptor.

Signed-off-by: Li Liu 
---
 device_tree.c |   39 +++
 1 file changed, 39 insertions(+)

diff --git a/device_tree.c b/device_tree.c
index 29d9acc..14d4015 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -377,3 +377,42 @@ static int dts_is_printable_strings(const void *data, int 
len)
 
 return substrs && !substr_len;
 }
+
+static void dts_write_data(FILE *fp, const char *data, int len)
+{
+int i;
+const char *p = data;
+const char *s;
+
+if (len == 0) {
+return;
+}
+
+if (dts_is_printable_strings(data, len)) {
+fprintf(fp, " = ");
+
+s = data;
+do {
+fprintf(fp, "\"%s\"", s);
+s += strlen(s) + 1;
+if (s < data + len) {
+fprintf(fp, ", ");
+}
+} while (s < data + len);
+} else if ((len % 4) == 0) {
+const uint32_t *cell = (const uint32_t *)data;
+
+fprintf(fp, " = <");
+for (i = 0; i < len; i += 4) {
+fprintf(fp, "0x%x%s", fdt32_to_cpu(cell[i / 4]),
+i < (len - 4) ? " " : "");
+}
+fprintf(fp, ">");
+} else {
+fprintf(fp, " = [");
+for (i = 0; i < len; i++) {
+fprintf(fp, "%02hhx%s", *p++, i < len - 1 ? " " : "");
+}
+fprintf(fp, "]");
+}
+}
-- 
1.7.9.5





[Qemu-devel] [PATCH 4/6] device_tree.c: add the main function to analyse the parameter 'dumpdts'

2014-08-24 Thread john.liuli
From: Li Liu 

add the main function to analyse the parameter 'dumpdts' as a
filename the dts will be dumped to.

Signed-off-by: Li Liu 
---
 device_tree.c|   21 +
 include/sysemu/device_tree.h |1 +
 2 files changed, 22 insertions(+)

diff --git a/device_tree.c b/device_tree.c
index 1e407d2..b9a924f 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -496,3 +496,24 @@ static void qemu_write_dts(FILE *fp, void *fdt)
 fprintf(fp, ";\n");
 }
 }
+
+void qemu_fdt_dumpdts(void *fdt)
+{
+FILE *fp;
+const char *filename = qemu_opt_get(qemu_get_machine_opts(), "dumpdts");
+
+if (!filename || !fdt) {
+return;
+}
+
+fp = fopen(filename, "w");
+if (!fp) {
+fprintf(stderr, "Failed to open file '%s'\n", filename);
+goto ret;
+}
+
+qemu_write_dts(fp, fdt);
+
+ret:
+fclose(fp);
+}
diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
index 899f05c..27145fb 100644
--- a/include/sysemu/device_tree.h
+++ b/include/sysemu/device_tree.h
@@ -50,6 +50,7 @@ int qemu_fdt_add_subnode(void *fdt, const char *name);
 } while (0)
 
 void qemu_fdt_dumpdtb(void *fdt, int size);
+void qemu_fdt_dumpdts(void *fdt);
 
 /**
  * qemu_fdt_setprop_sized_cells_from_array:
-- 
1.7.9.5





[Qemu-devel] [PATCH 5/6] machine: add 'dumpdts' parameter to 'machine' optslist.

2014-08-24 Thread john.liuli
From: Li Liu 

Signed-off-by: Li Liu 
---
 vl.c |4 
 1 file changed, 4 insertions(+)

diff --git a/vl.c b/vl.c
index b796c67..853f748 100644
--- a/vl.c
+++ b/vl.c
@@ -357,6 +357,10 @@ static QemuOptsList qemu_machine_opts = {
 .type = QEMU_OPT_STRING,
 .help = "Dump current dtb to a file and quit",
 }, {
+.name = "dumpdts",
+.type = QEMU_OPT_STRING,
+.help = "Convert current dtb to dts and dump to a file",
+},{
 .name = "phandle_start",
 .type = QEMU_OPT_NUMBER,
 .help = "The first phandle ID we may generate dynamically",
-- 
1.7.9.5





[Qemu-devel] [PATCH 6/6] arm: Allow dumping generated dtb to dts file

2014-08-24 Thread john.liuli
From: Li Liu 

By calling qemu_fdt_dumdts before qemu_fdt_dumpdtb.

Signed-off-by: Li Liu 
---
 hw/arm/boot.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index e32f2f4..18cc8ac 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -394,6 +394,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info 
*binfo)
 binfo->modify_dtb(binfo, fdt);
 }
 
+qemu_fdt_dumpdts(fdt);
 qemu_fdt_dumpdtb(fdt, size);
 
 cpu_physical_memory_write(addr, fdt, size);
-- 
1.7.9.5





Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

2014-08-24 Thread Chen, Tiejun

On 2014/8/24 19:12, Michael S. Tsirkin wrote:

On Fri, Aug 22, 2014 at 09:06:20AM +0800, Chen, Tiejun wrote:

On 2014/8/22 0:16, Konrad Rzeszutek Wilk wrote:

On Thu, Aug 21, 2014 at 09:28:28AM +0800, Tiejun Chen wrote:

Currenjly this ISA bridge should be fixed at 1f.0, and pass the


Currently


Fixed.




real vendor/device ids as the driver expect.


Could you add a bit more description to this patch please? Explain
the rationale, etc.


So rephrase as follows:

xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Currently IGD drivers always need to access PCH by 1f.0,


OK


and
identify PCH type with its own real vendor/device ids. This type
value help driver initialize correctly.


instead: PCH vendor/device id is used to identify the card.


Okay.





Signed-off-by: Tiejun Chen 
---
  hw/i386/pc_piix.c | 24 +++-
  1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7710724..b131fa3 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -50,7 +50,8 @@
  #include "cpu.h"
  #include "qemu/error-report.h"
  #ifdef CONFIG_XEN
-#  include 
+#include 
+#include 
  #endif

  #define MAX_IDE_BUS 2
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
  }
  }

+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+struct PCIDevice *dev;
+XenHostPCIDevice hdev;
+int r = 0;
+
+/* This shoudl be fixed at 1f.0 then pass vendor/device ids.


should

However I would remove the comment as it does not add anything extra
to the function. It is pretty clear what it is doing.

What would help is if you said:

Must be fixed at 1f.0 because .. bla blah


Like the patch description, so what about this,

 /* Currently IGD drivers always need to access PCH by 1f.0, and
  * identify PCH type with its own real vendor/device ids.
  */

Thanks
Tiejun




+ */
+dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+"xen-igd-passthrough-isa-bridge");
+if (dev) {
+r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+if (!r) {
+pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+pci_config_set_device_id(dev->config, hdev.device_id);


Can you, instead, implement the reverse logic, probing
the card and supplying the correct device id for PCH?



Here what is your so-called reverse logic as I already asked you 
previously? Do you mean I should list all PCHs with a combo illustrated 
with the vendor/device id in advance? Then look up if we can find a 
matched PCH? If yes, what is that benefit you expect in passthrough 
case? Shouldn't we pass these info to VM directly in passthrough case?


Thanks
Tiejun  



Re: [Qemu-devel] [PATCH v12 0/6] qcow2, raw: add preallocation=full and preallocation=falloc

2014-08-24 Thread Hu Tao
On Fri, Aug 22, 2014 at 05:00:08PM +0100, Richard W.M. Jones wrote:
> On Fri, Aug 22, 2014 at 05:53:22PM +0200, Kevin Wolf wrote:
> > Am 22.08.2014 um 17:34 hat Richard W.M. Jones geschrieben:
> > > On Fri, Aug 22, 2014 at 05:22:33PM +0200, Kevin Wolf wrote:
> > > > It's still useful because it happens to reduce the overhead in most
> > > > implementations and it's a relatively quick operation, but the best way
> > > > I know of to actually _fully_ preallocate is still writing zeros. Which
> > > > of the two the user wants, is a decision that qemu can't make for them.
> > > 
> > > This is a difficult situation.  Possibly the choice is between
> > > 
> > >  - efficiently make the file fully allocated, that works in the vast
> > >majority of cases, but don't go crazy (ie. fallocate)
> > > 
> > >  - really really try as hard as possible to make sure that future
> > >allocations will never fail (ie. write random non-zero data to the
> > >file)
> > > 
> > > Note that neither of these is the preallocation=... option as
> > > specified in this patch.
> > 
> > Isn't the first one exactly preallocation=falloc and the second is
> > preallocation=full, except that we're not writing non-zero blocks? (And
> > probably shouldn't, because that would change the content.)
> 
> Well no for a few reasons:
> 
> What is proposed to be called 'preallocation=falloc' should fall back
> to other methods (eg. writing random, writing zeroes).  It should
> also be called something more useful like 'preallocation=best'.

What if user cares about time(writing zeroes or non-zeroes is
time-consuming) and wants falloc only sometimes? I think this is the
main difference between preallocation=falloc and preallocation=full.

> 
> What is proposed to be called 'preallocation=full' should not write
> just zeroes.  It needs to write random data since otherwise lower
> layers could discard those writes and that would mean metadata
> allocations could still take time (or fail).  It could also be called
> something more useful, say, 'preallocation=tryveryhard'.

I agree with you on this one, but does it need to be random? does ~0 work?

Regards,
Hu

> 
> TBH I think this whole thing is overkill and we should just have a
> preallocation option that works like in libvirt.  Anything else is
> silly [see above] or pushes the problem to upper layers that are in no
> position to make that decision.
> 
> Remember that the upper layer is probably not even running on the same
> machine.  It has no knowledge of the backing LUN.  It doesn't know
> about the hypervisor kernel (ie. if fallocate will fail).
> 
> Rich.
> 
> -- 
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> Read my programming and virtualization blog: http://rwmj.wordpress.com
> virt-p2v converts physical machines to virtual machines.  Boot with a
> live CD or over the network (PXE) and turn machines into KVM guests.
> http://libguestfs.org/virt-v2v



Re: [Qemu-devel] [PATCH] block: Make op blockers recursive

2014-08-24 Thread Fam Zheng
On Fri, 08/22 18:11, Benoît Canet wrote:
> Since the block layer code is starting to modify the BDS graph right in the
> middle of BDS chains (block-mirror's replace parameter for example) QEMU needs
> to properly block and unblock whole BDS subtrees; recursion is a neat way to
> achieve this task.
> 
> This patch also takes care of modifying the op blockers users.

Is this going to replace backing_blocker?

I think it is too general an approach to control the operation properly,
because the op blocker may not work in the same way for all types of BDS
connections.  In other words, the choosing of op blockers are likely
conditional on graph edge types, that's why backing_blocker was added here. For
example, A VMDK extent connection will probably need a different set of
blockers than bs->file connection.

So could you explain in which cases is the recursive blocking/unblocking
useful?

Fam

> 
> Signed-off-by: Benoit Canet 
> ---
>  block.c   | 69 
> ---
>  block/blkverify.c | 21 +++
>  block/commit.c|  3 +++
>  block/mirror.c| 17 
>  block/quorum.c| 25 +
>  block/stream.c|  3 +++
>  block/vmdk.c  | 34 +++
>  include/block/block.h |  2 +-
>  include/block/block_int.h |  6 +
>  9 files changed, 171 insertions(+), 9 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 6fa0201..d964b6c 100644
> --- a/block.c
> +++ b/block.c
> @@ -5446,7 +5446,9 @@ bool bdrv_op_is_blocked(BlockDriverState *bs, 
> BlockOpType op, Error **errp)
>  return false;
>  }
>  
> -void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)
> +/* do the real work of blocking a BDS */
> +static void bdrv_do_op_block(BlockDriverState *bs, BlockOpType op,
> + Error *reason)
>  {
>  BdrvOpBlocker *blocker;
>  assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
> @@ -5456,7 +5458,9 @@ void bdrv_op_block(BlockDriverState *bs, BlockOpType 
> op, Error *reason)
>  QLIST_INSERT_HEAD(&bs->op_blockers[op], blocker, list);
>  }
>  
> -void bdrv_op_unblock(BlockDriverState *bs, BlockOpType op, Error *reason)
> +/* do the real work of unblocking a BDS */
> +static void bdrv_do_op_unblock(BlockDriverState *bs, BlockOpType op,
> +   Error *reason)
>  {
>  BdrvOpBlocker *blocker, *next;
>  assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
> @@ -5468,6 +5472,65 @@ void bdrv_op_unblock(BlockDriverState *bs, BlockOpType 
> op, Error *reason)
>  }
>  }
>  
> +static bool bdrv_op_is_blocked_by(BlockDriverState *bs, BlockOpType op,
> +  Error *reason)
> +{
> +BdrvOpBlocker *blocker, *next;
> +assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
> +QLIST_FOREACH_SAFE(blocker, &bs->op_blockers[op], list, next) {
> +if (blocker->reason == reason) {
> +return true;
> +}
> +}
> +return false;
> +}
> +
> +/* block recursively a BDS */
> +void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason)
> +{
> +if (!bs) {
> +return;
> +}
> +
> +/* prevent recursion loop */
> +if (bdrv_op_is_blocked_by(bs, op, reason)) {
> +return;
> +}
> +
> +/* block first for recursion loop protection to work */
> +bdrv_do_op_block(bs, op, reason);
> +
> +bdrv_op_block(bs->file, op, reason);
> +bdrv_op_block(bs->backing_hd, op, reason);
> +
> +if (bs->drv && bs->drv->bdrv_op_recursive_block) {
> +bs->drv->bdrv_op_recursive_block(bs, op, reason);
> +}
> +}
> +
> +/* unblock recursively a BDS */
> +void bdrv_op_unblock(BlockDriverState *bs, BlockOpType op, Error *reason)
> +{
> +if (!bs) {
> +return;
> +}
> +
> +/* prevent recursion loop */
> +if (!bdrv_op_is_blocked_by(bs, op, reason)) {
> +return;
> +}
> +
> +/* unblock first for recursion loop protection to work */
> +bdrv_do_op_unblock(bs, op, reason);
> +
> +bdrv_op_unblock(bs->file, op, reason);
> +bdrv_op_unblock(bs->backing_hd, op, reason);
> +
> +if (bs->drv && bs->drv->bdrv_op_recursive_unblock) {
> +bs->drv->bdrv_op_recursive_unblock(bs, op, reason);
> +}
> +}
> +
>  void bdrv_op_block_all(BlockDriverState *bs, Error *reason)
>  {
>  int i;
> @@ -5848,7 +5911,7 @@ BlockDriverState *check_to_replace_node(const char 
> *node_name, Error **errp)
>  return NULL;
>  }
>  
> -if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) {
> +if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_MIRROR_REPLACE, 
> errp)) {
>  return NULL;
>  }
>  
> diff --git a/block/blkverify.c b/block/blkverify.c
> index 621b785..75ec3df 100644
> --- a/block/blkverify.c
> +++ b/block/blkverify.c
> @@ -320,6 +320,24 @@ static void 
> blkverify_attach_aio_context(BlockDriverState *bs,
>  bdrv_attach_aio_

Re: [Qemu-devel] [PATCH v2 4/4] ioh3420: Enable ARI forwarding

2014-08-24 Thread Gonglei (Arei)
> From: Michael S. Tsirkin [mailto:m...@redhat.com]
> Subject: Re: [PATCH v2 4/4] ioh3420: Enable ARI forwarding
> 
> On Sun, Aug 24, 2014 at 03:32:20PM +0200, Knut Omang wrote:
> > Signed-off-by: Knut Omang 
> 
> BTW pcie_cap_is_arifwd_enabled is still unused.

Not yet, but I have posted a patch series:

[PATCH v2 0/2] add check for PCIe root ports and downstream ports

Which we used this function to check ARI Forwarding is enabled or not.
I hope you can help me review it, thanks a lot!

BTW, I will rebase my patches on Kunt's patch series. And will do some fixes 
about Hu Tao's and Marcel Apfelbaum's comments.

> We really should use it to make ARI work properly, right?
> 
Yes. I think we should.

Best regards,
-Gonglei

> > ---
> >  hw/pci-bridge/ioh3420.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
> > index e6674a1..cce2fdd 100644
> > --- a/hw/pci-bridge/ioh3420.c
> > +++ b/hw/pci-bridge/ioh3420.c
> > @@ -85,6 +85,7 @@ static void ioh3420_reset(DeviceState *qdev)
> >  pcie_cap_root_reset(d);
> >  pcie_cap_deverr_reset(d);
> >  pcie_cap_slot_reset(d);
> > +pcie_cap_arifwd_reset(d);
> >  pcie_aer_root_reset(d);
> >  pci_bridge_reset(qdev);
> >  pci_bridge_disable_base_limit(d);
> > @@ -119,6 +120,7 @@ static int ioh3420_initfn(PCIDevice *d)
> >  goto err_msi;
> >  }
> >
> > +pcie_cap_arifwd_init(d);
> >  pcie_cap_deverr_init(d);
> >  pcie_cap_slot_init(d, s->slot);
> >  pcie_chassis_create(s->chassis);
> > --
> > 1.9.0